a663bb20d5fc1200c972a87c0cb26eaec9636122
3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, SysUtils
, Variants
, Classes
,
9 Graphics
, Controls
, Forms
, Dialogs
, StdCtrls
,
10 ExtCtrls
, ComCtrls
, Registry
, Math
, Types
;
16 TOptionsForm
= class (TForm
)
19 cbCheckerboard
: TCheckBox
;
20 cbCompress
: TCheckBox
;
22 PageControl
: TPageControl
;
23 TabGeneral
: TTabSheet
;
25 TabTesting
: TTabSheet
;
26 ColorDialog
: TColorDialog
;
28 cbShowDots
: TCheckBox
;
29 cbShowTexture
: TCheckBox
;
30 cbShowSize
: TCheckBox
;
47 sPreviewColor
: TShape
;
52 // Количество недавно открытых:
56 LabelLanguage
: TLabel
;
57 rbRussian
: TRadioButton
;
58 rbEnglish
: TRadioButton
;
59 LabelGridSize
: TLabel
;
65 FindD2dDialog
: TOpenDialog
;
72 cbAllowExit
: TCheckBox
;
74 cbMonstersDM
: TCheckBox
;
75 cbTeamDamage
: TCheckBox
;
76 cbTwoPlayers
: TCheckBox
;
77 cbWeaponStay
: TCheckBox
;
85 procedure bGridClick(Sender
: TObject
);
86 procedure FormActivate(Sender
: TObject
);
87 procedure bOKClick(Sender
: TObject
);
88 procedure bCancelClick(Sender
: TObject
);
89 procedure bBackClick(Sender
: TObject
);
90 procedure bPreviewClick(Sender
: TObject
);
91 procedure FormCreate(Sender
: TObject
);
92 procedure bChooseD2dClick(Sender
: TObject
);
95 { Private declarations }
97 { Public declarations }
101 OptionsForm
: TOptionsForm
;
103 procedure RegisterFileType(ext
: String; FileName
: String);
108 f_main
, StdConvs
, CONFIG
, g_language
, g_resources
, g_options
;
112 procedure RegisterFileType(ext
: String; FileName
: String);
117 reg
:= TRegistry
.Create();
121 RootKey
:= HKEY_CLASSES_ROOT
;
122 OpenKey('.'+ext
,True);
123 WriteString('',ext
+'file');
125 CreateKey(ext
+'file');
126 OpenKey(ext
+'file\DefaultIcon',True);
127 WriteString('',FileName
+',0');
129 OpenKey(ext
+'file\shell\open\command',True);
130 WriteString('',FileName
+' "%1"');
136 procedure TOptionsForm
.bGridClick(Sender
: TObject
);
138 if ColorDialog
.Execute
then
139 sDotColor
.Brush
.Color
:= ColorDialog
.Color
;
142 procedure TOptionsForm
.bChooseD2dClick(Sender
: TObject
);
144 if FindD2dDialog
.Execute
then
145 edD2dExe
.Text := FindD2dDialog
.FileName
;
148 procedure TOptionsForm
.FormActivate(Sender
: TObject
);
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 if gLanguage
= LANGUAGE_RUSSIAN
then
174 rbRussian
.Checked
:= True;
175 rbEnglish
.Checked
:= False;
179 rbRussian
.Checked
:= False;
180 rbEnglish
.Checked
:= True;
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 rbRussian
.Checked
then
215 str
:= LANGUAGE_RUSSIAN
217 str
:= LANGUAGE_ENGLISH
;
219 // Нужно сменить язык:
220 if gLanguage
<> str
then
223 //e_WriteLog('Read language file', MSG_NOTIFY);
224 //g_Language_Load(EditorDir+'\data\'+gLanguage+LANGUAGE_FILE_NAME);
225 g_Language_Set(gLanguage
);
228 DotColor
:= sDotColor
.Brush
.Color
;
229 DotEnable
:= cbShowDots
.Checked
;
231 if DotStep
= DotStepOne
then
235 DotStepOne
:= EnsureRange(StrToIntDef(eDotStepOne
.Text, 16), 4, 2048);
236 DotStepTwo
:= EnsureRange(StrToIntDef(eDotStepTwo
.Text, 8), 4, 2048);
238 DotStep
:= DotStepOne
240 DotStep
:= DotStepTwo
;
242 DrawTexturePanel
:= cbShowTexture
.Checked
;
243 DrawPanelSize
:= cbShowSize
.Checked
;
244 BackColor
:= sBackColor
.Brush
.Color
;
245 PreviewColor
:= sPreviewColor
.Brush
.Color
;
246 UseCheckerboard
:= cbCheckerboard
.Checked
;
248 if cbScale
.ItemIndex
= 1 then
253 if cbDotSize
.ItemIndex
= 1 then
260 re
:= Min(Max(StrToIntDef(eRecent
.Text, 5), 2), 10);
261 Compress
:= cbCompress
.Checked
;
262 Backup
:= cbBackup
.Checked
;
266 if rbTDM
.Checked
then
267 TestGameMode
:= 'TDM'
268 else if rbCTF
.Checked
then
269 TestGameMode
:= 'CTF'
270 else if rbCOOP
.Checked
then
271 TestGameMode
:= 'COOP'
273 TestGameMode
:= 'DM';
275 TestLimTime
:= edTime
.Text;
276 if (not TryStrToInt(TestLimTime
, n
)) then
279 TestLimScore
:= edScore
.Text;
280 if (not TryStrToInt(TestLimScore
, n
)) then
283 TestOptionsTwoPlayers
:= cbTwoPlayers
.Checked
;
284 TestOptionsTeamDamage
:= cbTeamDamage
.Checked
;
285 TestOptionsAllowExit
:= cbAllowExit
.Checked
;
286 TestOptionsWeaponStay
:= cbWeaponStay
.Checked
;
287 TestOptionsMonstersDM
:= cbMonstersDM
.Checked
;
288 TestMapOnce
:= cbMapOnce
.Checked
;
290 TestD2dExe
:= edD2dExe
.Text;
291 TestD2DArgs
:= edD2DArgs
.Text;
295 config
:= TConfig
.CreateFile(CfgFileName
);
297 config
.WriteInt('Editor', 'DotColor', DotColor
);
298 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
299 config
.WriteInt('Editor', 'DotStepOne', DotStepOne
);
300 config
.WriteInt('Editor', 'DotStepTwo', DotStepTwo
);
301 config
.WriteInt('Editor', 'DotStep', DotStep
);
302 config
.WriteInt('Editor', 'DotSize', cbDotSize
.ItemIndex
);
303 config
.WriteBool('Editor', 'DrawTexturePanel', DrawTexturePanel
);
304 config
.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize
);
305 config
.WriteInt('Editor', 'BackColor', BackColor
);
306 config
.WriteInt('Editor', 'PreviewColor', PreviewColor
);
307 config
.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard
);
308 config
.WriteInt('Editor', 'Scale', cbScale
.ItemIndex
);
309 config
.WriteStr('Editor', 'Language', gLanguage
);
311 config
.WriteInt('Editor', 'RecentCount', re
);
312 config
.WriteBool('Editor', 'Compress', Compress
);
313 config
.WriteBool('Editor', 'Backup', Backup
);
315 config
.WriteStr('TestRun', 'GameMode', TestGameMode
);
316 config
.WriteStr('TestRun', 'LimTime', TestLimTime
);
317 config
.WriteStr('TestRun', 'LimScore', TestLimScore
);
318 config
.WriteBool('TestRun', 'TwoPlayers', TestOptionsTwoPlayers
);
319 config
.WriteBool('TestRun', 'TeamDamage', TestOptionsTeamDamage
);
320 config
.WriteBool('TestRun', 'AllowExit', TestOptionsAllowExit
);
321 config
.WriteBool('TestRun', 'WeaponStay', TestOptionsWeaponStay
);
322 config
.WriteBool('TestRun', 'MonstersDM', TestOptionsMonstersDM
);
323 config
.WriteBool('TestRun', 'MapOnce', TestMapOnce
);
324 {$IF DEFINED(DARWIN)}
325 config
.WriteStr('TestRun', 'ExeDrawin', TestD2dExe
);
326 {$ELSEIF DEFINED(WINDOWS)}
327 config
.WriteStr('TestRun', 'ExeWindows', TestD2dExe
);
329 config
.WriteStr('TestRun', 'ExeUnix', TestD2dExe
);
331 config
.WriteStr('TestRun', 'Args', TestD2DArgs
);
333 if RecentCount
<> re
then
336 MainForm
.RefreshRecentMenu();
339 config
.SaveFile(CfgFileName
);
344 procedure TOptionsForm
.bCancelClick(Sender
: TObject
);
349 procedure TOptionsForm
.bBackClick(Sender
: TObject
);
351 if ColorDialog
.Execute
then
352 sBackColor
.Brush
.Color
:= ColorDialog
.Color
;
355 procedure TOptionsForm
.bPreviewClick(Sender
: TObject
);
357 if ColorDialog
.Execute
then
358 sPreviewColor
.Brush
.Color
:= ColorDialog
.Color
;
361 procedure TOptionsForm
.FormCreate(Sender
: TObject
);
363 {$IF DEFINED(DARWIN)}
364 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
365 FindD2dDialog
.InitialDir
:= ExtractFileDir(TestD2dExe
)
367 FindD2dDialog
.InitialDir
:= TestD2dExe
;
368 FindD2dDialog
.DefaultExt
:= '.app';
369 FindD2dDialog
.Filter
:= 'Doom 2D Forever.app|*.app|Doom 2D Forever (Unix Executable)|Doom2DF;*';
370 {$ELSEIF DEFINED(WINDOWS)}
371 FindD2dDialog
.InitialDir
:= TestD2dExe
;
372 FindD2dDialog
.DefaultExt
:= '.exe';
373 FindD2dDialog
.Filter
:= 'Doom2DF.exe|Doom2DF.exe;*.exe';
375 FindD2dDialog
.InitialDir
:= TestD2dExe
;
376 FindD2dDialog
.DefaultExt
:= '';
377 FindD2dDialog
.Filter
:= 'Doom2DF|Doom2DF;*';