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 FormActivate(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
.FormActivate(Sender
: TObject
);
148 const langfilename
= 'editor';
149 var info
: TSearchRec
;
151 sDotColor
.Brush
.Color
:= DotColor
;
152 cbShowDots
.Checked
:= DotEnable
;
153 cbShowTexture
.Checked
:= DrawTexturePanel
;
154 cbShowSize
.Checked
:= DrawPanelSize
;
155 eDotStepOne
.Text := IntToStr(DotStepOne
);
156 eDotStepTwo
.Text := IntToStr(DotStepTwo
);
157 sBackColor
.Brush
.Color
:= BackColor
;
158 sPreviewColor
.Brush
.Color
:= PreviewColor
;
159 cbCheckerboard
.Checked
:= UseCheckerboard
;
160 cbCompress
.Checked
:= Compress
;
161 cbBackup
.Checked
:= Backup
;
163 cbScale
.ItemIndex
:= 1
165 cbScale
.ItemIndex
:= 0;
167 cbDotSize
.ItemIndex
:= 1
169 cbDotSize
.ItemIndex
:= 0;
170 eRecent
.Text := IntToStr(RecentCount
);
173 cbLanguage
.Items
.BeginUpdate
;
174 cbLanguage
.Items
.Clear
;
175 cbLanguage
.Items
.Add('Auto');
176 if FindFirst(LangDir
+ DirectorySeparator
+ langfilename
+ '.*.mo', faAnyFile
, info
) = 0 then
179 cbLanguage
.Items
.Add(Copy(ExtractFileNameWithoutExt(info
.Name
), Length(langfilename
) + 2));
180 until FindNext(info
) <> 0;
183 cbLanguage
.ItemIndex
:= IfThen(gLanguage
= '', 0, cbLanguage
.Items
.IndexOf(gLanguage
));
185 cbLanguage
.Items
.EndUpdate
;
188 if TestGameMode
= 'TDM' then
189 rbTDM
.Checked
:= True
190 else if TestGameMode
= 'CTF' then
191 rbCTF
.Checked
:= True
192 else if TestGameMode
= 'COOP' then
193 rbCOOP
.Checked
:= True
195 rbDM
.Checked
:= True;
197 edTime
.Text := TestLimTime
;
198 edScore
.Text := TestLimScore
;
199 cbTwoPlayers
.Checked
:= TestOptionsTwoPlayers
;
200 cbTeamDamage
.Checked
:= TestOptionsTeamDamage
;
201 cbAllowExit
.Checked
:= TestOptionsAllowExit
;
202 cbWeaponStay
.Checked
:= TestOptionsWeaponStay
;
203 cbMonstersDM
.Checked
:= TestOptionsMonstersDM
;
204 cbMapOnce
.Checked
:= TestMapOnce
;
205 edD2dExe
.Text := TestD2dExe
;
206 edD2DArgs
.Text := TestD2DArgs
;
209 procedure TOptionsForm
.bOKClick(Sender
: TObject
);
219 if cbLanguage
.ItemIndex
<= 0 then str
:= '' else str
:= cbLanguage
.Items
[cbLanguage
.ItemIndex
];
220 if (str
= '') or (gLanguage
<> str
) then
223 g_Language_Set(gLanguage
);
226 DotColor
:= sDotColor
.Brush
.Color
;
227 DotEnable
:= cbShowDots
.Checked
;
229 if DotStep
= DotStepOne
then
233 DotStepOne
:= EnsureRange(StrToIntDef(eDotStepOne
.Text, 16), 4, 2048);
234 DotStepTwo
:= EnsureRange(StrToIntDef(eDotStepTwo
.Text, 8), 4, 2048);
236 DotStep
:= DotStepOne
238 DotStep
:= DotStepTwo
;
240 DrawTexturePanel
:= cbShowTexture
.Checked
;
241 DrawPanelSize
:= cbShowSize
.Checked
;
242 BackColor
:= sBackColor
.Brush
.Color
;
243 PreviewColor
:= sPreviewColor
.Brush
.Color
;
244 UseCheckerboard
:= cbCheckerboard
.Checked
;
246 if cbScale
.ItemIndex
= 1 then
251 if cbDotSize
.ItemIndex
= 1 then
258 re
:= Min(Max(StrToIntDef(eRecent
.Text, 5), 2), 10);
259 Compress
:= cbCompress
.Checked
;
260 Backup
:= cbBackup
.Checked
;
264 if rbTDM
.Checked
then
265 TestGameMode
:= 'TDM'
266 else if rbCTF
.Checked
then
267 TestGameMode
:= 'CTF'
268 else if rbCOOP
.Checked
then
269 TestGameMode
:= 'COOP'
271 TestGameMode
:= 'DM';
273 TestLimTime
:= edTime
.Text;
274 if (not TryStrToInt(TestLimTime
, n
)) then
277 TestLimScore
:= edScore
.Text;
278 if (not TryStrToInt(TestLimScore
, n
)) then
281 TestOptionsTwoPlayers
:= cbTwoPlayers
.Checked
;
282 TestOptionsTeamDamage
:= cbTeamDamage
.Checked
;
283 TestOptionsAllowExit
:= cbAllowExit
.Checked
;
284 TestOptionsWeaponStay
:= cbWeaponStay
.Checked
;
285 TestOptionsMonstersDM
:= cbMonstersDM
.Checked
;
286 TestMapOnce
:= cbMapOnce
.Checked
;
288 TestD2dExe
:= edD2dExe
.Text;
289 TestD2DArgs
:= edD2DArgs
.Text;
293 config
:= TConfig
.CreateFile(CfgFileName
);
295 config
.WriteInt('Editor', 'DotColor', DotColor
);
296 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
297 config
.WriteInt('Editor', 'DotStepOne', DotStepOne
);
298 config
.WriteInt('Editor', 'DotStepTwo', DotStepTwo
);
299 config
.WriteInt('Editor', 'DotStep', DotStep
);
300 config
.WriteInt('Editor', 'DotSize', cbDotSize
.ItemIndex
);
301 config
.WriteBool('Editor', 'DrawTexturePanel', DrawTexturePanel
);
302 config
.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize
);
303 config
.WriteInt('Editor', 'BackColor', BackColor
);
304 config
.WriteInt('Editor', 'PreviewColor', PreviewColor
);
305 config
.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard
);
306 config
.WriteInt('Editor', 'Scale', cbScale
.ItemIndex
);
307 config
.WriteStr('Editor', 'Language', gLanguage
);
309 config
.WriteInt('Editor', 'RecentCount', re
);
310 config
.WriteBool('Editor', 'Compress', Compress
);
311 config
.WriteBool('Editor', 'Backup', Backup
);
313 config
.WriteStr('TestRun', 'GameMode', TestGameMode
);
314 config
.WriteStr('TestRun', 'LimTime', TestLimTime
);
315 config
.WriteStr('TestRun', 'LimScore', TestLimScore
);
316 config
.WriteBool('TestRun', 'TwoPlayers', TestOptionsTwoPlayers
);
317 config
.WriteBool('TestRun', 'TeamDamage', TestOptionsTeamDamage
);
318 config
.WriteBool('TestRun', 'AllowExit', TestOptionsAllowExit
);
319 config
.WriteBool('TestRun', 'WeaponStay', TestOptionsWeaponStay
);
320 config
.WriteBool('TestRun', 'MonstersDM', TestOptionsMonstersDM
);
321 config
.WriteBool('TestRun', 'MapOnce', TestMapOnce
);
322 {$IF DEFINED(DARWIN)}
323 config
.WriteStr('TestRun', 'ExeDrawin', TestD2dExe
);
324 {$ELSEIF DEFINED(WINDOWS)}
325 config
.WriteStr('TestRun', 'ExeWindows', TestD2dExe
);
327 config
.WriteStr('TestRun', 'ExeUnix', TestD2dExe
);
329 config
.WriteStr('TestRun', 'Args', TestD2DArgs
);
331 if RecentCount
<> re
then
334 MainForm
.RefreshRecentMenu();
337 config
.SaveFile(CfgFileName
);
342 procedure TOptionsForm
.bCancelClick(Sender
: TObject
);
347 procedure TOptionsForm
.bBackClick(Sender
: TObject
);
349 if ColorDialog
.Execute
then
350 sBackColor
.Brush
.Color
:= ColorDialog
.Color
;
353 procedure TOptionsForm
.bPreviewClick(Sender
: TObject
);
355 if ColorDialog
.Execute
then
356 sPreviewColor
.Brush
.Color
:= ColorDialog
.Color
;
359 procedure TOptionsForm
.FormCreate(Sender
: TObject
);
361 {$IF DEFINED(DARWIN)}
362 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
363 FindD2dDialog
.InitialDir
:= ExtractFileDir(TestD2dExe
)
365 FindD2dDialog
.InitialDir
:= TestD2dExe
;
366 FindD2dDialog
.DefaultExt
:= '.app';
367 FindD2dDialog
.Filter
:= 'Doom 2D Forever.app|*.app|Doom 2D Forever (Unix Executable)|Doom2DF;*';
368 {$ELSEIF DEFINED(WINDOWS)}
369 FindD2dDialog
.InitialDir
:= TestD2dExe
;
370 FindD2dDialog
.DefaultExt
:= '.exe';
371 FindD2dDialog
.Filter
:= 'Doom2DF.exe|Doom2DF.exe;*.exe';
373 FindD2dDialog
.InitialDir
:= TestD2dExe
;
374 FindD2dDialog
.DefaultExt
:= '';
375 FindD2dDialog
.Filter
:= 'Doom2DF|Doom2DF;*';