1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-25 01:57:47 +01:00

disable Vsync checkbox in case we are in borderelss or windowed mode to avoid unnecessary input lag

This commit is contained in:
FunkyFr3sh 2024-08-10 08:07:15 +02:00
parent b1c74f1628
commit 6f540a9603
3 changed files with 35 additions and 10 deletions

View File

@ -9,6 +9,7 @@
#include <SysUtils.hpp> #include <SysUtils.hpp>
#include <Registry.hpp> #include <Registry.hpp>
#include <System.Hash.hpp> #include <System.Hash.hpp>
#include <VersionHelpers.h>
#include "ConfigFormUnit.h" #include "ConfigFormUnit.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#pragma package(smart_init) #pragma package(smart_init)
@ -1197,6 +1198,11 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
delete ini; delete ini;
VsyncChk->Enabled = VsyncAllowed();
if (!VsyncChk->Enabled) {
VsyncChk->State = tssOff;
}
Initialized = true; Initialized = true;
} }
@ -1618,8 +1624,31 @@ bool TConfigForm::GetBool(TIniFile *ini, System::UnicodeString key, bool defValu
return s == "true" || s == "yes" || s == "1"; return s == "true" || s == "yes" || s == "1";
} }
bool TConfigForm::VsyncAllowed()
{
if (GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version")) {
return true;
}
if (!IsWindows8OrGreater()) {
return true;
}
if (NonexclusiveChk->State == tssOff &&
(PresentationCbx->ItemIndex == 0 || PresentationCbx->ItemIndex == 1)) {
return true;
}
return false;
}
void __fastcall TConfigForm::PresentationCbxChange(TObject *Sender) void __fastcall TConfigForm::PresentationCbxChange(TObject *Sender)
{ {
VsyncChk->Enabled = VsyncAllowed();
if (!VsyncChk->Enabled) {
VsyncChk->State = tssOff;
}
SaveSettings(); SaveSettings();
} }
@ -1728,6 +1757,11 @@ void __fastcall TConfigForm::SinglecpuChkClick(TObject *Sender)
void __fastcall TConfigForm::NonexclusiveChkClick(TObject *Sender) void __fastcall TConfigForm::NonexclusiveChkClick(TObject *Sender)
{ {
VsyncChk->Enabled = VsyncAllowed();
if (!VsyncChk->Enabled) {
VsyncChk->State = tssOff;
}
SaveSettings(); SaveSettings();
} }

View File

@ -2696,8 +2696,6 @@ object ConfigForm: TConfigForm
ShowCaption = False ShowCaption = False
TabOrder = 1 TabOrder = 1
StyleElements = [seFont, seBorder] StyleElements = [seFont, seBorder]
ExplicitWidth = 495
ExplicitHeight = 464
DesignSize = ( DesignSize = (
499 499
465) 465)
@ -2885,7 +2883,6 @@ object ConfigForm: TConfigForm
TabOrder = 5 TabOrder = 5
StyleElements = [seFont, seBorder] StyleElements = [seFont, seBorder]
OnClick = ThemePnlClick OnClick = ThemePnlClick
ExplicitLeft = 471
end end
end end
object CompatibilityPnl: TPanel object CompatibilityPnl: TPanel
@ -2901,8 +2898,6 @@ object ConfigForm: TConfigForm
TabOrder = 3 TabOrder = 3
Visible = False Visible = False
StyleElements = [seFont, seBorder] StyleElements = [seFont, seBorder]
ExplicitWidth = 495
ExplicitHeight = 464
object MaxgameticksLbl: TLabel object MaxgameticksLbl: TLabel
Left = 40 Left = 40
Top = 28 Top = 28
@ -3083,8 +3078,6 @@ object ConfigForm: TConfigForm
TabOrder = 2 TabOrder = 2
Visible = False Visible = False
StyleElements = [seFont, seBorder] StyleElements = [seFont, seBorder]
ExplicitWidth = 495
ExplicitHeight = 464
object RendererLbl: TLabel object RendererLbl: TLabel
Left = 40 Left = 40
Top = 28 Top = 28
@ -3309,8 +3302,6 @@ object ConfigForm: TConfigForm
TabOrder = 4 TabOrder = 4
Visible = False Visible = False
StyleElements = [seFont, seBorder] StyleElements = [seFont, seBorder]
ExplicitWidth = 495
ExplicitHeight = 464
object ToggleWindowedLbl: TLabel object ToggleWindowedLbl: TLabel
Left = 40 Left = 40
Top = 27 Top = 27
@ -3538,7 +3529,6 @@ object ConfigForm: TConfigForm
Color = clMenu Color = clMenu
ParentBackground = False ParentBackground = False
TabOrder = 0 TabOrder = 0
ExplicitHeight = 467
DesignSize = ( DesignSize = (
233 233
468) 468)

View File

@ -118,6 +118,7 @@ private: // Benutzer-Deklarationen
virtual void __fastcall CreateParams(TCreateParams & Params); virtual void __fastcall CreateParams(TCreateParams & Params);
void SaveSettings(); void SaveSettings();
bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue); bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue);
bool VsyncAllowed();
void ApplyTranslation(TIniFile *ini); void ApplyTranslation(TIniFile *ini);
System::UnicodeString GetKeyText(WORD key); System::UnicodeString GetKeyText(WORD key);
WORD GetKeyCode(System::UnicodeString text); WORD GetKeyCode(System::UnicodeString text);