3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, SysUtils
, Variants
, Classes
,
9 Graphics
, Controls
, Forms
, Dialogs
, StdCtrls
,
10 ExtCtrls
, ComCtrls
, ActnList
, Registry
, Math
, Types
;
16 TOptionsForm
= class (TForm
)
19 cbCheckerboard
: TCheckBox
;
20 cbCompress
: TCheckBox
;
22 cbLanguage
: TComboBox
;
23 PageControl
: TPageControl
;
24 TabGeneral
: TTabSheet
;
26 TabTesting
: TTabSheet
;
27 ColorDialog
: TColorDialog
;
29 cbShowDots
: TCheckBox
;
30 cbShowTexture
: TCheckBox
;
31 cbShowSize
: TCheckBox
;
48 sPreviewColor
: TShape
;
53 // Количество недавно открытых:
57 LabelLanguage
: TLabel
;
58 LabelGridSize
: TLabel
;
64 FindD2dDialog
: TOpenDialog
;
71 cbAllowExit
: TCheckBox
;
73 cbMonstersDM
: TCheckBox
;
74 cbTeamDamage
: TCheckBox
;
75 cbTwoPlayers
: TCheckBox
;
76 cbWeaponStay
: TCheckBox
;
84 procedure bGridClick(Sender
: TObject
);
85 procedure FormShow(Sender
: TObject
);
86 procedure bOKClick(Sender
: TObject
);
87 procedure bCancelClick(Sender
: TObject
);
88 procedure bBackClick(Sender
: TObject
);
89 procedure bPreviewClick(Sender
: TObject
);
90 procedure FormCreate(Sender
: TObject
);
91 procedure bChooseD2dClick(Sender
: TObject
);
94 { Private declarations }
96 { Public declarations }
100 OptionsForm
: TOptionsForm
;
102 procedure RegisterFileType(ext
: String; FileName
: String);
107 LazFileUtils
, f_main
, StdConvs
, CONFIG
, g_language
, g_resources
, g_options
;
111 procedure RegisterFileType(ext
: String; FileName
: String);
116 reg
:= TRegistry
.Create();
120 RootKey
:= HKEY_CLASSES_ROOT
;
121 OpenKey('.'+ext
,True);
122 WriteString('',ext
+'file');
124 CreateKey(ext
+'file');
125 OpenKey(ext
+'file\DefaultIcon',True);
126 WriteString('',FileName
+',0');
128 OpenKey(ext
+'file\shell\open\command',True);
129 WriteString('',FileName
+' "%1"');
135 procedure TOptionsForm
.bGridClick(Sender
: TObject
);
137 if ColorDialog
.Execute
then
138 sDotColor
.Brush
.Color
:= ColorDialog
.Color
;
141 procedure TOptionsForm
.bChooseD2dClick(Sender
: TObject
);
143 if FindD2dDialog
.Execute
then
144 edD2dExe
.Text := FindD2dDialog
.FileName
;
147 procedure TOptionsForm
.FormShow(Sender
: TObject
);
148 var list
: TStringList
;
150 sDotColor
.Brush
.Color
:= DotColor
;
151 cbShowDots
.Checked
:= DotEnable
;
152 cbShowTexture
.Checked
:= DrawTexturePanel
;
153 cbShowSize
.Checked
:= DrawPanelSize
;
154 eDotStepOne
.Text := IntToStr(DotStepOne
);
155 eDotStepTwo
.Text := IntToStr(DotStepTwo
);
156 sBackColor
.Brush
.Color
:= BackColor
;
157 sPreviewColor
.Brush
.Color
:= PreviewColor
;
158 cbCheckerboard
.Checked
:= UseCheckerboard
;
159 cbCompress
.Checked
:= Compress
;
160 cbBackup
.Checked
:= Backup
;
162 cbScale
.ItemIndex
:= 1
164 cbScale
.ItemIndex
:= 0;
166 cbDotSize
.ItemIndex
:= 1
168 cbDotSize
.ItemIndex
:= 0;
169 eRecent
.Text := IntToStr(RecentCount
);
172 cbLanguage
.Items
.BeginUpdate
;
173 cbLanguage
.Items
.Clear
;
174 cbLanguage
.Items
.Add('Auto');
175 list
:= g_Language_GetList();
176 cbLanguage
.Items
.AddStrings(list
);
178 cbLanguage
.ItemIndex
:= IfThen(gLanguage
= '', 0, cbLanguage
.Items
.IndexOf(gLanguage
));
180 cbLanguage
.Items
.EndUpdate
;
183 if TestGameMode
= 'TDM' then
184 rbTDM
.Checked
:= True
185 else if TestGameMode
= 'CTF' then
186 rbCTF
.Checked
:= True
187 else if TestGameMode
= 'COOP' then
188 rbCOOP
.Checked
:= True
190 rbDM
.Checked
:= True;
192 edTime
.Text := TestLimTime
;
193 edScore
.Text := TestLimScore
;
194 cbTwoPlayers
.Checked
:= TestOptionsTwoPlayers
;
195 cbTeamDamage
.Checked
:= TestOptionsTeamDamage
;
196 cbAllowExit
.Checked
:= TestOptionsAllowExit
;
197 cbWeaponStay
.Checked
:= TestOptionsWeaponStay
;
198 cbMonstersDM
.Checked
:= TestOptionsMonstersDM
;
199 cbMapOnce
.Checked
:= TestMapOnce
;
200 edD2dExe
.Text := TestD2dExe
;
201 edD2DArgs
.Text := TestD2DArgs
;
204 procedure TOptionsForm
.bOKClick(Sender
: TObject
);
214 if cbLanguage
.ItemIndex
>= 0 then
216 if cbLanguage
.ItemIndex
= 0 then str
:= '' else str
:= cbLanguage
.Items
[cbLanguage
.ItemIndex
];
217 if (str
= '') or (gLanguage
<> str
) then
220 g_Language_Set(gLanguage
);
224 DotColor
:= sDotColor
.Brush
.Color
;
225 DotEnable
:= cbShowDots
.Checked
;
227 if DotStep
= DotStepOne
then
231 DotStepOne
:= EnsureRange(StrToIntDef(eDotStepOne
.Text, 16), 4, 2048);
232 DotStepTwo
:= EnsureRange(StrToIntDef(eDotStepTwo
.Text, 8), 4, 2048);
234 DotStep
:= DotStepOne
236 DotStep
:= DotStepTwo
;
238 DrawTexturePanel
:= cbShowTexture
.Checked
;
239 DrawPanelSize
:= cbShowSize
.Checked
;
240 BackColor
:= sBackColor
.Brush
.Color
;
241 PreviewColor
:= sPreviewColor
.Brush
.Color
;
242 UseCheckerboard
:= cbCheckerboard
.Checked
;
244 if cbScale
.ItemIndex
= 1 then
249 if cbDotSize
.ItemIndex
= 1 then
256 re
:= Min(Max(StrToIntDef(eRecent
.Text, 5), 2), 10);
257 Compress
:= cbCompress
.Checked
;
258 Backup
:= cbBackup
.Checked
;
262 if rbTDM
.Checked
then
263 TestGameMode
:= 'TDM'
264 else if rbCTF
.Checked
then
265 TestGameMode
:= 'CTF'
266 else if rbCOOP
.Checked
then
267 TestGameMode
:= 'COOP'
269 TestGameMode
:= 'DM';
271 TestLimTime
:= edTime
.Text;
272 if (not TryStrToInt(TestLimTime
, n
)) then
275 TestLimScore
:= edScore
.Text;
276 if (not TryStrToInt(TestLimScore
, n
)) then
279 TestOptionsTwoPlayers
:= cbTwoPlayers
.Checked
;
280 TestOptionsTeamDamage
:= cbTeamDamage
.Checked
;
281 TestOptionsAllowExit
:= cbAllowExit
.Checked
;
282 TestOptionsWeaponStay
:= cbWeaponStay
.Checked
;
283 TestOptionsMonstersDM
:= cbMonstersDM
.Checked
;
284 TestMapOnce
:= cbMapOnce
.Checked
;
286 TestD2dExe
:= edD2dExe
.Text;
287 TestD2DArgs
:= edD2DArgs
.Text;
291 config
:= TConfig
.CreateFile(CfgFileName
);
293 config
.WriteInt('Editor', 'DotColor', DotColor
);
294 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
295 config
.WriteInt('Editor', 'DotStepOne', DotStepOne
);
296 config
.WriteInt('Editor', 'DotStepTwo', DotStepTwo
);
297 config
.WriteInt('Editor', 'DotStep', DotStep
);
298 config
.WriteInt('Editor', 'DotSize', cbDotSize
.ItemIndex
);
299 config
.WriteBool('Editor', 'DrawTexturePanel', DrawTexturePanel
);
300 config
.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize
);
301 config
.WriteInt('Editor', 'BackColor', BackColor
);
302 config
.WriteInt('Editor', 'PreviewColor', PreviewColor
);
303 config
.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard
);
304 config
.WriteInt('Editor', 'Scale', cbScale
.ItemIndex
);
305 config
.WriteStr('Editor', 'Language', gLanguage
);
307 config
.WriteInt('Editor', 'RecentCount', re
);
308 config
.WriteBool('Editor', 'Compress', Compress
);
309 config
.WriteBool('Editor', 'Backup', Backup
);
311 config
.WriteStr('TestRun', 'GameMode', TestGameMode
);
312 config
.WriteStr('TestRun', 'LimTime', TestLimTime
);
313 config
.WriteStr('TestRun', 'LimScore', TestLimScore
);
314 config
.WriteBool('TestRun', 'TwoPlayers', TestOptionsTwoPlayers
);
315 config
.WriteBool('TestRun', 'TeamDamage', TestOptionsTeamDamage
);
316 config
.WriteBool('TestRun', 'AllowExit', TestOptionsAllowExit
);
317 config
.WriteBool('TestRun', 'WeaponStay', TestOptionsWeaponStay
);
318 config
.WriteBool('TestRun', 'MonstersDM', TestOptionsMonstersDM
);
319 config
.WriteBool('TestRun', 'MapOnce', TestMapOnce
);
320 {$IF DEFINED(DARWIN)}
321 config
.WriteStr('TestRun', 'ExeDrawin', TestD2dExe
);
322 {$ELSEIF DEFINED(WINDOWS)}
323 config
.WriteStr('TestRun', 'ExeWindows', TestD2dExe
);
325 config
.WriteStr('TestRun', 'ExeUnix', TestD2dExe
);
327 config
.WriteStr('TestRun', 'Args', TestD2DArgs
);
329 if RecentCount
<> re
then
332 MainForm
.RefreshRecentMenu();
335 config
.SaveFile(CfgFileName
);
340 procedure TOptionsForm
.bCancelClick(Sender
: TObject
);
345 procedure TOptionsForm
.bBackClick(Sender
: TObject
);
347 if ColorDialog
.Execute
then
348 sBackColor
.Brush
.Color
:= ColorDialog
.Color
;
351 procedure TOptionsForm
.bPreviewClick(Sender
: TObject
);
353 if ColorDialog
.Execute
then
354 sPreviewColor
.Brush
.Color
:= ColorDialog
.Color
;
357 procedure TOptionsForm
.FormCreate(Sender
: TObject
);
359 {$IF DEFINED(DARWIN)}
360 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
361 FindD2dDialog
.InitialDir
:= ExtractFileDir(TestD2dExe
)
363 FindD2dDialog
.InitialDir
:= TestD2dExe
;
364 FindD2dDialog
.DefaultExt
:= '.app';
365 FindD2dDialog
.Filter
:= 'Doom 2D Forever.app|*.app|Doom 2D Forever (Unix Executable)|Doom2DF;*';
366 {$ELSEIF DEFINED(WINDOWS)}
367 FindD2dDialog
.InitialDir
:= TestD2dExe
;
368 FindD2dDialog
.DefaultExt
:= '.exe';
369 FindD2dDialog
.Filter
:= 'Doom2DF.exe|Doom2DF.exe;*.exe';
371 FindD2dDialog
.InitialDir
:= TestD2dExe
;
372 FindD2dDialog
.DefaultExt
:= '';
373 FindD2dDialog
.Filter
:= 'Doom2DF|Doom2DF;*';