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
, StrUtils
, 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 var info
: TSearchRec
; s
: String; i
: Integer;
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 if FindFirst(LangDir
+ DirectorySeparator
+ '*.mo', faAnyFile
, info
) = 0 then
178 s
:= ExtractFileNameWithoutExt(info
.Name
);
179 // TODO: check encoding part in name (editor.ru_RU.UTF-8.mo)
180 i
:= Max(RPos('.', s
), 1);
181 s
:= Copy(s
, i
+ 1, Length(s
) - i
);
182 cbLanguage
.Items
.Add(s
);
183 until FindNext(info
) <> 0;
186 cbLanguage
.ItemIndex
:= IfThen(gLanguage
= '', 0, cbLanguage
.Items
.IndexOf(gLanguage
));
188 cbLanguage
.Items
.EndUpdate
;
191 if TestGameMode
= 'TDM' then
192 rbTDM
.Checked
:= True
193 else if TestGameMode
= 'CTF' then
194 rbCTF
.Checked
:= True
195 else if TestGameMode
= 'COOP' then
196 rbCOOP
.Checked
:= True
198 rbDM
.Checked
:= True;
200 edTime
.Text := TestLimTime
;
201 edScore
.Text := TestLimScore
;
202 cbTwoPlayers
.Checked
:= TestOptionsTwoPlayers
;
203 cbTeamDamage
.Checked
:= TestOptionsTeamDamage
;
204 cbAllowExit
.Checked
:= TestOptionsAllowExit
;
205 cbWeaponStay
.Checked
:= TestOptionsWeaponStay
;
206 cbMonstersDM
.Checked
:= TestOptionsMonstersDM
;
207 cbMapOnce
.Checked
:= TestMapOnce
;
208 edD2dExe
.Text := TestD2dExe
;
209 edD2DArgs
.Text := TestD2DArgs
;
212 procedure TOptionsForm
.bOKClick(Sender
: TObject
);
222 if cbLanguage
.ItemIndex
<= 0 then str
:= '' else str
:= cbLanguage
.Items
[cbLanguage
.ItemIndex
];
223 if (str
= '') or (gLanguage
<> str
) then
226 g_Language_Set(gLanguage
);
229 DotColor
:= sDotColor
.Brush
.Color
;
230 DotEnable
:= cbShowDots
.Checked
;
232 if DotStep
= DotStepOne
then
236 DotStepOne
:= EnsureRange(StrToIntDef(eDotStepOne
.Text, 16), 4, 2048);
237 DotStepTwo
:= EnsureRange(StrToIntDef(eDotStepTwo
.Text, 8), 4, 2048);
239 DotStep
:= DotStepOne
241 DotStep
:= DotStepTwo
;
243 DrawTexturePanel
:= cbShowTexture
.Checked
;
244 DrawPanelSize
:= cbShowSize
.Checked
;
245 BackColor
:= sBackColor
.Brush
.Color
;
246 PreviewColor
:= sPreviewColor
.Brush
.Color
;
247 UseCheckerboard
:= cbCheckerboard
.Checked
;
249 if cbScale
.ItemIndex
= 1 then
254 if cbDotSize
.ItemIndex
= 1 then
261 re
:= Min(Max(StrToIntDef(eRecent
.Text, 5), 2), 10);
262 Compress
:= cbCompress
.Checked
;
263 Backup
:= cbBackup
.Checked
;
267 if rbTDM
.Checked
then
268 TestGameMode
:= 'TDM'
269 else if rbCTF
.Checked
then
270 TestGameMode
:= 'CTF'
271 else if rbCOOP
.Checked
then
272 TestGameMode
:= 'COOP'
274 TestGameMode
:= 'DM';
276 TestLimTime
:= edTime
.Text;
277 if (not TryStrToInt(TestLimTime
, n
)) then
280 TestLimScore
:= edScore
.Text;
281 if (not TryStrToInt(TestLimScore
, n
)) then
284 TestOptionsTwoPlayers
:= cbTwoPlayers
.Checked
;
285 TestOptionsTeamDamage
:= cbTeamDamage
.Checked
;
286 TestOptionsAllowExit
:= cbAllowExit
.Checked
;
287 TestOptionsWeaponStay
:= cbWeaponStay
.Checked
;
288 TestOptionsMonstersDM
:= cbMonstersDM
.Checked
;
289 TestMapOnce
:= cbMapOnce
.Checked
;
291 TestD2dExe
:= edD2dExe
.Text;
292 TestD2DArgs
:= edD2DArgs
.Text;
296 config
:= TConfig
.CreateFile(CfgFileName
);
298 config
.WriteInt('Editor', 'DotColor', DotColor
);
299 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
300 config
.WriteInt('Editor', 'DotStepOne', DotStepOne
);
301 config
.WriteInt('Editor', 'DotStepTwo', DotStepTwo
);
302 config
.WriteInt('Editor', 'DotStep', DotStep
);
303 config
.WriteInt('Editor', 'DotSize', cbDotSize
.ItemIndex
);
304 config
.WriteBool('Editor', 'DrawTexturePanel', DrawTexturePanel
);
305 config
.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize
);
306 config
.WriteInt('Editor', 'BackColor', BackColor
);
307 config
.WriteInt('Editor', 'PreviewColor', PreviewColor
);
308 config
.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard
);
309 config
.WriteInt('Editor', 'Scale', cbScale
.ItemIndex
);
310 config
.WriteStr('Editor', 'Language', gLanguage
);
312 config
.WriteInt('Editor', 'RecentCount', re
);
313 config
.WriteBool('Editor', 'Compress', Compress
);
314 config
.WriteBool('Editor', 'Backup', Backup
);
316 config
.WriteStr('TestRun', 'GameMode', TestGameMode
);
317 config
.WriteStr('TestRun', 'LimTime', TestLimTime
);
318 config
.WriteStr('TestRun', 'LimScore', TestLimScore
);
319 config
.WriteBool('TestRun', 'TwoPlayers', TestOptionsTwoPlayers
);
320 config
.WriteBool('TestRun', 'TeamDamage', TestOptionsTeamDamage
);
321 config
.WriteBool('TestRun', 'AllowExit', TestOptionsAllowExit
);
322 config
.WriteBool('TestRun', 'WeaponStay', TestOptionsWeaponStay
);
323 config
.WriteBool('TestRun', 'MonstersDM', TestOptionsMonstersDM
);
324 config
.WriteBool('TestRun', 'MapOnce', TestMapOnce
);
325 {$IF DEFINED(DARWIN)}
326 config
.WriteStr('TestRun', 'ExeDrawin', TestD2dExe
);
327 {$ELSEIF DEFINED(WINDOWS)}
328 config
.WriteStr('TestRun', 'ExeWindows', TestD2dExe
);
330 config
.WriteStr('TestRun', 'ExeUnix', TestD2dExe
);
332 config
.WriteStr('TestRun', 'Args', TestD2DArgs
);
334 if RecentCount
<> re
then
337 MainForm
.RefreshRecentMenu();
340 config
.SaveFile(CfgFileName
);
345 procedure TOptionsForm
.bCancelClick(Sender
: TObject
);
350 procedure TOptionsForm
.bBackClick(Sender
: TObject
);
352 if ColorDialog
.Execute
then
353 sBackColor
.Brush
.Color
:= ColorDialog
.Color
;
356 procedure TOptionsForm
.bPreviewClick(Sender
: TObject
);
358 if ColorDialog
.Execute
then
359 sPreviewColor
.Brush
.Color
:= ColorDialog
.Color
;
362 procedure TOptionsForm
.FormCreate(Sender
: TObject
);
364 {$IF DEFINED(DARWIN)}
365 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
366 FindD2dDialog
.InitialDir
:= ExtractFileDir(TestD2dExe
)
368 FindD2dDialog
.InitialDir
:= TestD2dExe
;
369 FindD2dDialog
.DefaultExt
:= '.app';
370 FindD2dDialog
.Filter
:= 'Doom 2D Forever.app|*.app|Doom 2D Forever (Unix Executable)|Doom2DF;*';
371 {$ELSEIF DEFINED(WINDOWS)}
372 FindD2dDialog
.InitialDir
:= TestD2dExe
;
373 FindD2dDialog
.DefaultExt
:= '.exe';
374 FindD2dDialog
.Filter
:= 'Doom2DF.exe|Doom2DF.exe;*.exe';
376 FindD2dDialog
.InitialDir
:= TestD2dExe
;
377 FindD2dDialog
.DefaultExt
:= '';
378 FindD2dDialog
.Filter
:= 'Doom2DF|Doom2DF;*';