3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, SysUtils
, Variants
, Classes
,
9 Graphics
, Controls
, Forms
, Dialogs
, StdCtrls
,
10 ExtCtrls
, ComCtrls
, ActnList
, Spin
, EditBtn
, Registry
, Math
, Types
;
16 TOptionsForm
= class (TForm
)
19 cbAllowExit
: TCheckBox
;
21 cbCheckerboard
: TCheckBox
;
22 cbCompress
: TCheckBox
;
23 cbLanguage
: TComboBox
;
25 cbMonstersDM
: TCheckBox
;
26 cbShowDots
: TCheckBox
;
27 cbShowSize
: TCheckBox
;
28 cbShowTexture
: TCheckBox
;
29 cbTeamDamage
: TCheckBox
;
30 cbTwoPlayers
: TCheckBox
;
31 cbWeaponStay
: TCheckBox
;
32 ColorButton1
: TColorButton
;
33 ColorButton2
: TColorButton
;
34 ColorButton3
: TColorButton
;
38 ExeEdit
: TFileNameEdit
;
43 LabelGridSize
: TLabel
;
44 LabelLanguage
: TLabel
;
52 PageControl
: TPageControl
;
63 TabGeneral
: TTabSheet
;
64 TabTesting
: TTabSheet
;
66 procedure FormShow(Sender
: TObject
);
67 procedure bOKClick(Sender
: TObject
);
68 procedure bCancelClick(Sender
: TObject
);
69 procedure FormCreate(Sender
: TObject
);
73 OptionsForm
: TOptionsForm
;
75 procedure RegisterFileType(ext
: String; FileName
: String);
80 LazFileUtils
, f_main
, StdConvs
, CONFIG
, g_language
, g_resources
, g_options
;
84 procedure RegisterFileType(ext
: String; FileName
: String);
89 reg
:= TRegistry
.Create();
93 RootKey
:= HKEY_CLASSES_ROOT
;
94 OpenKey('.'+ext
,True);
95 WriteString('',ext
+'file');
97 CreateKey(ext
+'file');
98 OpenKey(ext
+'file\DefaultIcon',True);
99 WriteString('',FileName
+',0');
101 OpenKey(ext
+'file\shell\open\command',True);
102 WriteString('',FileName
+' "%1"');
108 procedure TOptionsForm
.FormShow(Sender
: TObject
);
109 var list
: TStringList
;
112 ColorButton1
.ButtonColor
:= DotColor
;
113 ColorButton2
.ButtonColor
:= BackColor
;
114 ColorButton3
.ButtonColor
:= PreviewColor
;
115 SpinEdit1
.Value
:= DotStepOne
;
116 SpinEdit2
.Value
:= DotStepTwo
;
118 cbShowDots
.Checked
:= DotEnable
;
119 cbShowTexture
.Checked
:= DrawTexturePanel
;
120 cbShowSize
.Checked
:= DrawPanelSize
;
121 cbCheckerboard
.Checked
:= UseCheckerboard
;
123 SpinEdit4
.Value
:= DotSize
;
124 SpinEdit5
.Value
:= Scale
;
127 cbLanguage
.Items
.BeginUpdate
;
128 cbLanguage
.Items
.Clear
;
129 cbLanguage
.Items
.Add(MsgLabEsLanguageAuto
);
130 list
:= g_Language_GetList();
131 cbLanguage
.Items
.AddStrings(list
);
133 cbLanguage
.ItemIndex
:= IfThen(gLanguage
= '', 0, cbLanguage
.Items
.IndexOf(gLanguage
));
135 cbLanguage
.Items
.EndUpdate
;
139 cbCompress
.Checked
:= Compress
;
140 cbBackup
.Checked
:= Backup
;
141 SpinEdit3
.Value
:= RecentCount
;
144 ExeEdit
.Text := TestD2dExe
;
145 edD2DArgs
.Text := TestD2DArgs
;
147 rbDM
.Checked
:= TestGameMode
= 'DM';
148 rbTDM
.Checked
:= TestGameMode
= 'TDM';
149 rbCTF
.Checked
:= TestGameMode
= 'CTF';
150 rbCOOP
.Checked
:= TestGameMode
= 'COOP';
152 edTime
.Text := TestLimTime
;
153 edScore
.Text := TestLimScore
;
154 cbTwoPlayers
.Checked
:= TestOptionsTwoPlayers
;
155 cbTeamDamage
.Checked
:= TestOptionsTeamDamage
;
156 cbAllowExit
.Checked
:= TestOptionsAllowExit
;
157 cbWeaponStay
.Checked
:= TestOptionsWeaponStay
;
158 cbMonstersDM
.Checked
:= TestOptionsMonstersDM
;
159 cbMapOnce
.Checked
:= TestMapOnce
;
162 procedure TOptionsForm
.bOKClick(Sender
: TObject
);
170 if cbLanguage
.ItemIndex
>= 0 then
172 if cbLanguage
.ItemIndex
= 0 then str
:= '' else str
:= cbLanguage
.Items
[cbLanguage
.ItemIndex
];
173 if (str
= '') or (gLanguage
<> str
) then
176 g_Language_Set(gLanguage
);
180 DotColor
:= ColorButton1
.ButtonColor
;
181 BackColor
:= ColorButton2
.ButtonColor
;
182 PreviewColor
:= ColorButton3
.ButtonColor
;
184 DotEnable
:= cbShowDots
.Checked
;
185 DotStep
:= IfThen(DotStep
= DotStepOne
, SpinEdit1
.Value
, SpinEdit2
.Value
);
186 DotStepOne
:= SpinEdit1
.Value
;
187 DotStepTwo
:= SpinEdit2
.Value
;
189 DrawTexturePanel
:= cbShowTexture
.Checked
;
190 DrawPanelSize
:= cbShowSize
.Checked
;
191 UseCheckerboard
:= cbCheckerboard
.Checked
;
192 DotSize
:= SpinEdit4
.Value
;
193 Scale
:= SpinEdit5
.Value
;
196 re
:= SpinEdit3
.Value
;
197 Compress
:= cbCompress
.Checked
;
198 Backup
:= cbBackup
.Checked
;
201 TestD2DExe
:= ExeEdit
.Text;
202 TestD2DArgs
:= edD2DArgs
.Text;
204 TestGameMode
:= 'DM';
205 if rbTDM
.Checked
then TestGameMode
:= 'TDM';
206 if rbCTF
.Checked
then TestGameMode
:= 'CTF';
207 if rbCOOP
.Checked
then TestGameMode
:= 'COOP';
208 if rbDM
.Checked
then TestGameMode
:= 'DM';
210 TestLimTime
:= edTime
.Text;
211 if (not TryStrToInt(TestLimTime
, n
)) then
214 TestLimScore
:= edScore
.Text;
215 if (not TryStrToInt(TestLimScore
, n
)) then
218 TestOptionsTwoPlayers
:= cbTwoPlayers
.Checked
;
219 TestOptionsTeamDamage
:= cbTeamDamage
.Checked
;
220 TestOptionsAllowExit
:= cbAllowExit
.Checked
;
221 TestOptionsWeaponStay
:= cbWeaponStay
.Checked
;
222 TestOptionsMonstersDM
:= cbMonstersDM
.Checked
;
223 TestMapOnce
:= cbMapOnce
.Checked
;
226 config
:= TConfig
.CreateFile(CfgFileName
);
228 config
.WriteInt('Editor', 'DotColor', DotColor
);
229 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
230 config
.WriteInt('Editor', 'DotStepOne', DotStepOne
);
231 config
.WriteInt('Editor', 'DotStepTwo', DotStepTwo
);
232 config
.WriteInt('Editor', 'DotStep', DotStep
);
233 config
.WriteInt('Editor', 'DotSize', SpinEdit4
.Value
);
234 config
.WriteBool('Editor', 'DrawTexturePanel', DrawTexturePanel
);
235 config
.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize
);
236 config
.WriteInt('Editor', 'BackColor', BackColor
);
237 config
.WriteInt('Editor', 'PreviewColor', PreviewColor
);
238 config
.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard
);
239 config
.WriteInt('Editor', 'Scale', SpinEdit5
.Value
);
240 config
.WriteStr('Editor', 'Language', gLanguage
);
242 config
.WriteInt('Editor', 'RecentCount', re
);
243 config
.WriteBool('Editor', 'Compress', Compress
);
244 config
.WriteBool('Editor', 'Backup', Backup
);
246 config
.WriteStr('TestRun', 'GameMode', TestGameMode
);
247 config
.WriteStr('TestRun', 'LimTime', TestLimTime
);
248 config
.WriteStr('TestRun', 'LimScore', TestLimScore
);
249 config
.WriteBool('TestRun', 'TwoPlayers', TestOptionsTwoPlayers
);
250 config
.WriteBool('TestRun', 'TeamDamage', TestOptionsTeamDamage
);
251 config
.WriteBool('TestRun', 'AllowExit', TestOptionsAllowExit
);
252 config
.WriteBool('TestRun', 'WeaponStay', TestOptionsWeaponStay
);
253 config
.WriteBool('TestRun', 'MonstersDM', TestOptionsMonstersDM
);
254 config
.WriteBool('TestRun', 'MapOnce', TestMapOnce
);
255 {$IF DEFINED(DARWIN)}
256 config
.WriteStr('TestRun', 'ExeDrawin', TestD2dExe
);
257 {$ELSEIF DEFINED(WINDOWS)}
258 config
.WriteStr('TestRun', 'ExeWindows', TestD2dExe
);
260 config
.WriteStr('TestRun', 'ExeUnix', TestD2dExe
);
262 config
.WriteStr('TestRun', 'Args', TestD2DArgs
);
264 if RecentCount
<> re
then
267 MainForm
.RefreshRecentMenu();
270 config
.SaveFile(CfgFileName
);
275 procedure TOptionsForm
.bCancelClick(Sender
: TObject
);
280 procedure TOptionsForm
.FormCreate(Sender
: TObject
);
282 {$IF DEFINED(DARWIN)}
283 if LowerCase(ExtractFileExt(TestD2DExe
)) = '.app' then
284 ExeEdit
.InitialDir
:= ExtractFileDir(TestD2DExe
)
286 ExeEdit
.InitialDir
:= TestD2DExe
;
288 ExeEdit
.InitialDir
:= TestD2DExe
;