1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

remember custom .ini settings

This commit is contained in:
FunkyFr3sh 2021-07-02 01:19:12 +02:00
parent 9d4cea12d1
commit 3686a54e60
2 changed files with 223 additions and 190 deletions

View File

@ -12,6 +12,13 @@
#pragma resource "*.dfm"
TConfigForm *ConfigForm;
bool Initialized;
/* Save previous settings so we don't override custom settings */
int Maxfps;
int Savesettings;
int Hook;
int Minfps;
//---------------------------------------------------------------------------
__fastcall TConfigForm::TConfigForm(TComponent* Owner)
: TForm(Owner)
@ -97,14 +104,14 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
{
}
int maxfps = ini->ReadInteger("ddraw", "maxfps", -1);
MaxfpsChk->State = maxfps != 0 ? tssOn : tssOff;
Maxfps = ini->ReadInteger("ddraw", "maxfps", -1);
MaxfpsChk->State = Maxfps != 0 ? tssOn : tssOff;
BoxingChk->State = GetBool(ini, "boxing", false) ? tssOn : tssOff;
BorderChk->State = GetBool(ini, "border", false) ? tssOn : tssOff;
int savesettings = ini->ReadInteger("ddraw", "savesettings", 1);
SavesettingsChk->State = savesettings != 0 ? tssOn : tssOff;
Savesettings = ini->ReadInteger("ddraw", "savesettings", 1);
SavesettingsChk->State = Savesettings != 0 ? tssOn : tssOff;
/* Compatibility Settings */
@ -117,6 +124,9 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
case -2:
MaxgameticksCbx->ItemIndex = 1;
break;
case 0:
MaxgameticksCbx->ItemIndex = 2;
break;
case 1000:
MaxgameticksCbx->ItemIndex = 3;
break;
@ -135,16 +145,21 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
case 15:
MaxgameticksCbx->ItemIndex = 8;
break;
case 0:
default:
MaxgameticksCbx->ItemIndex = 2;
MaxgameticksCbx->AddItem(IntToStr(maxgameticks), NULL);
MaxgameticksCbx->ItemIndex = 9;
break;
}
NoactivateappChk->State = GetBool(ini, "noactivateapp", false) ? tssOn : tssOff;
HookChk->State = ini->ReadInteger("ddraw", "hook", 4) == 2 ? tssOn : tssOff;
MinfpsChk->State = ini->ReadInteger("ddraw", "minfps", 0) != 0 ? tssOn : tssOff;
Hook = ini->ReadInteger("ddraw", "hook", 4);
HookChk->State = Hook == 2 ? tssOn : tssOff;
Minfps = ini->ReadInteger("ddraw", "minfps", 0);
MinfpsChk->State = Minfps != 0 ? tssOn : tssOff;
FixpitchChk->State = GetBool(ini, "fixpitch", false) ? tssOn : tssOff;
NonexclusiveChk->State = GetBool(ini, "nonexclusive", false) ? tssOn : tssOff;
@ -204,10 +219,12 @@ void TConfigForm::SaveSettings()
ini->WriteString("ddraw", "renderer", LowerCase(RendererCbx->Text));
ini->WriteString("ddraw", "shader", ShaderCbx->Text);
int maxfps = Maxfps == 0 ? -1 : Maxfps;
ini->WriteInteger(
"ddraw",
"maxfps",
MaxfpsChk->State == tssOn ? -1 : 0);
MaxfpsChk->State == tssOn ? maxfps : 0);
ini->WriteString(
"ddraw",
@ -219,10 +236,19 @@ void TConfigForm::SaveSettings()
"border",
BorderChk->State == tssOn ? "true" : "false");
int savesettings = Savesettings == 0 ? 1 : Savesettings;
ini->WriteInteger(
"ddraw",
"savesettings",
SavesettingsChk->State == tssOn ? 1 : 0);
SavesettingsChk->State == tssOn ? savesettings : 0);
if (Savesettings != 0 && SavesettingsChk->State == tssOff) {
ini->WriteInteger("ddraw", "width", 0);
ini->WriteInteger("ddraw", "height", 0);
ini->WriteInteger("ddraw", "posX", -32000);
ini->WriteInteger("ddraw", "posY", -32000);
}
/* Compatibility Settings */
@ -254,6 +280,9 @@ void TConfigForm::SaveSettings()
case 8:
ini->WriteInteger("ddraw", "maxgameticks", 15);
break;
case 9:
ini->WriteString("ddraw", "maxgameticks", MaxgameticksCbx->Text);
break;
default:
break;
}
@ -263,18 +292,22 @@ void TConfigForm::SaveSettings()
"noactivateapp",
NoactivateappChk->State == tssOn ? "true" : "false");
int hook = Hook != 2 ? Hook : 4;
ini->WriteInteger(
"ddraw",
"hook",
HookChk->State == tssOn ? 2 : 4);
HookChk->State == tssOn ? 2 : hook);
if (HookChk->State == tssOn)
ini->WriteString("ddraw", "renderer", "gdi");
int minfps = Minfps == 0 ? -1 : Minfps;
ini->WriteInteger(
"ddraw",
"minfps",
MinfpsChk->State == tssOn ? -1 : 0);
MinfpsChk->State == tssOn ? minfps : 0);
ini->WriteString(
"ddraw",

View File

@ -2682,184 +2682,6 @@ object ConfigForm: TConfigForm
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object AdvDisplayPnl: TPanel
Left = 191
Top = 8
Width = 499
Height = 465
Color = clWhite
ParentBackground = False
ShowCaption = False
TabOrder = 2
Visible = False
StyleElements = [seFont, seBorder]
object RendererLbl: TLabel
Left = 40
Top = 28
Width = 64
Height = 21
Caption = 'Renderer'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object SavesettingsLbl: TLabel
Left = 40
Top = 386
Width = 212
Height = 21
Margins.Top = 18
Caption = 'Save window position and size'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object ShaderLbl: TLabel
Left = 40
Top = 105
Width = 110
Height = 21
Margins.Top = 18
Caption = 'OpenGL Shader'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MaxfpsLbl: TLabel
Left = 40
Top = 182
Width = 111
Height = 21
Margins.Top = 18
Caption = 'Limit frame rate'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BorderLbl: TLabel
Left = 40
Top = 318
Width = 293
Height = 21
Margins.Top = 18
Caption = 'Show window borders in windowed mode'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BoxingLbl: TLabel
Left = 40
Top = 250
Width = 220
Height = 21
Margins.Top = 18
Caption = 'Windowboxing / Integer scaling'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object RendererCbx: TComboBox
Left = 48
Top = 55
Width = 185
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 0
OnChange = RendererCbxChange
Items.Strings = (
'Automatic'
'Direct3D9'
'OpenGL'
'GDI')
end
object BorderChk: TToggleSwitch
Left = 40
Top = 345
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 1
OnClick = BorderChkClick
end
object SavesettingsChk: TToggleSwitch
Left = 40
Top = 413
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 2
OnClick = SavesettingsChkClick
end
object ShaderCbx: TComboBox
Left = 48
Top = 132
Width = 425
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 3
OnChange = ShaderCbxChange
end
object MaxfpsChk: TToggleSwitch
Left = 40
Top = 209
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 4
OnClick = MaxfpsChkClick
end
object BoxingChk: TToggleSwitch
Left = 40
Top = 277
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 5
OnClick = BoxingChkClick
end
end
object DisplayPnl: TPanel
Left = 191
Top = 8
@ -3178,6 +3000,184 @@ object ConfigForm: TConfigForm
OnClick = NonexclusiveChkClick
end
end
object AdvDisplayPnl: TPanel
Left = 191
Top = 8
Width = 499
Height = 465
Color = clWhite
ParentBackground = False
ShowCaption = False
TabOrder = 2
Visible = False
StyleElements = [seFont, seBorder]
object RendererLbl: TLabel
Left = 40
Top = 28
Width = 64
Height = 21
Caption = 'Renderer'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object SavesettingsLbl: TLabel
Left = 40
Top = 386
Width = 212
Height = 21
Margins.Top = 18
Caption = 'Save window position and size'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object ShaderLbl: TLabel
Left = 40
Top = 105
Width = 110
Height = 21
Margins.Top = 18
Caption = 'OpenGL Shader'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MaxfpsLbl: TLabel
Left = 40
Top = 182
Width = 111
Height = 21
Margins.Top = 18
Caption = 'Limit frame rate'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BorderLbl: TLabel
Left = 40
Top = 318
Width = 293
Height = 21
Margins.Top = 18
Caption = 'Show window borders in windowed mode'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object BoxingLbl: TLabel
Left = 40
Top = 250
Width = 220
Height = 21
Margins.Top = 18
Caption = 'Windowboxing / Integer scaling'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object RendererCbx: TComboBox
Left = 48
Top = 55
Width = 185
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 0
OnChange = RendererCbxChange
Items.Strings = (
'Automatic'
'Direct3D9'
'OpenGL'
'GDI')
end
object BorderChk: TToggleSwitch
Left = 40
Top = 345
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 1
OnClick = BorderChkClick
end
object SavesettingsChk: TToggleSwitch
Left = 40
Top = 413
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 2
OnClick = SavesettingsChkClick
end
object ShaderCbx: TComboBox
Left = 48
Top = 132
Width = 425
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 3
OnChange = ShaderCbxChange
end
object MaxfpsChk: TToggleSwitch
Left = 40
Top = 209
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 4
OnClick = MaxfpsChkClick
end
object BoxingChk: TToggleSwitch
Left = 40
Top = 277
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 5
OnClick = BoxingChkClick
end
end
object MenuPnl: TPanel
Left = 0
Top = 8