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
;
13 TOptionsForm
= class (TForm
)
16 cbAllowExit
: TCheckBox
;
17 cbCheckerboard
: TCheckBox
;
18 cbLanguage
: TComboBox
;
20 cbMonstersDM
: TCheckBox
;
21 cbShowDots
: TCheckBox
;
22 cbShowSize
: TCheckBox
;
23 cbShowTexture
: TCheckBox
;
24 cbTeamDamage
: TCheckBox
;
25 cbTwoPlayers
: TCheckBox
;
26 cbWeaponStay
: TCheckBox
;
27 ColorButton1
: TColorButton
;
28 ColorButton2
: TColorButton
;
29 ColorButton3
: TColorButton
;
33 ExeEdit
: TFileNameEdit
;
38 LabelGridSize
: TLabel
;
39 LabelLanguage
: TLabel
;
47 PageControl
: TPageControl
;
58 TabGeneral
: TTabSheet
;
59 TabTesting
: TTabSheet
;
61 procedure FormShow(Sender
: TObject
);
62 procedure bOKClick(Sender
: TObject
);
63 procedure bCancelClick(Sender
: TObject
);
64 procedure FormCreate(Sender
: TObject
);
68 OptionsForm
: TOptionsForm
;
70 procedure RegisterFileType(ext
: String; FileName
: String);
75 LazFileUtils
, f_main
, StdConvs
, CONFIG
, WADEDITOR
, g_language
, g_options
;
79 procedure RegisterFileType(ext
: String; FileName
: String);
84 reg
:= TRegistry
.Create();
88 RootKey
:= HKEY_CLASSES_ROOT
;
89 OpenKey('.'+ext
,True);
90 WriteString('',ext
+'file');
92 CreateKey(ext
+'file');
93 OpenKey(ext
+'file\DefaultIcon',True);
94 WriteString('',FileName
+',0');
96 OpenKey(ext
+'file\shell\open\command',True);
97 WriteString('',FileName
+' "%1"');
103 procedure TOptionsForm
.FormShow(Sender
: TObject
);
104 var list
: TStringList
;
107 ColorButton1
.ButtonColor
:= DotColor
;
108 ColorButton2
.ButtonColor
:= BackColor
;
109 ColorButton3
.ButtonColor
:= PreviewColor
;
110 SpinEdit1
.Value
:= DotStepOne
;
111 SpinEdit2
.Value
:= DotStepTwo
;
113 cbShowDots
.Checked
:= DotEnable
;
114 cbShowTexture
.Checked
:= DrawTexturePanel
;
115 cbShowSize
.Checked
:= DrawPanelSize
;
116 cbCheckerboard
.Checked
:= UseCheckerboard
;
118 SpinEdit4
.Value
:= DotSize
;
119 SpinEdit5
.Value
:= Scale
;
122 cbLanguage
.Items
.BeginUpdate
;
123 cbLanguage
.Items
.Clear
;
124 cbLanguage
.Items
.Add(MsgLabEsLanguageAuto
);
125 list
:= g_Language_GetList();
126 cbLanguage
.Items
.AddStrings(list
);
128 cbLanguage
.ItemIndex
:= IfThen(gLanguage
= '', 0, cbLanguage
.Items
.IndexOf(gLanguage
));
130 cbLanguage
.Items
.EndUpdate
;
134 SpinEdit3
.Value
:= RecentCount
;
137 ExeEdit
.Text := TestD2dExe
;
138 edD2DArgs
.Text := TestD2DArgs
;
140 rbDM
.Checked
:= TestGameMode
= 'DM';
141 rbTDM
.Checked
:= TestGameMode
= 'TDM';
142 rbCTF
.Checked
:= TestGameMode
= 'CTF';
143 rbCOOP
.Checked
:= TestGameMode
= 'COOP';
145 edTime
.Text := TestLimTime
;
146 edScore
.Text := TestLimScore
;
147 cbTwoPlayers
.Checked
:= TestOptionsTwoPlayers
;
148 cbTeamDamage
.Checked
:= TestOptionsTeamDamage
;
149 cbAllowExit
.Checked
:= TestOptionsAllowExit
;
150 cbWeaponStay
.Checked
:= TestOptionsWeaponStay
;
151 cbMonstersDM
.Checked
:= TestOptionsMonstersDM
;
152 cbMapOnce
.Checked
:= TestMapOnce
;
155 procedure TOptionsForm
.bOKClick(Sender
: TObject
);
163 if cbLanguage
.ItemIndex
>= 0 then
165 if cbLanguage
.ItemIndex
= 0 then str
:= '' else str
:= cbLanguage
.Items
[cbLanguage
.ItemIndex
];
166 if (str
= '') or (gLanguage
<> str
) then
169 g_Language_Set(gLanguage
);
173 DotColor
:= ColorButton1
.ButtonColor
;
174 BackColor
:= ColorButton2
.ButtonColor
;
175 PreviewColor
:= ColorButton3
.ButtonColor
;
177 DotEnable
:= cbShowDots
.Checked
;
178 DotStep
:= IfThen(DotStep
= DotStepOne
, SpinEdit1
.Value
, SpinEdit2
.Value
);
179 DotStepOne
:= SpinEdit1
.Value
;
180 DotStepTwo
:= SpinEdit2
.Value
;
182 DrawTexturePanel
:= cbShowTexture
.Checked
;
183 DrawPanelSize
:= cbShowSize
.Checked
;
184 UseCheckerboard
:= cbCheckerboard
.Checked
;
185 DotSize
:= SpinEdit4
.Value
;
186 Scale
:= SpinEdit5
.Value
;
189 re
:= SpinEdit3
.Value
;
192 TestD2DExe
:= ExeEdit
.Text;
193 TestD2DArgs
:= edD2DArgs
.Text;
195 TestGameMode
:= 'DM';
196 if rbTDM
.Checked
then TestGameMode
:= 'TDM';
197 if rbCTF
.Checked
then TestGameMode
:= 'CTF';
198 if rbCOOP
.Checked
then TestGameMode
:= 'COOP';
199 if rbDM
.Checked
then TestGameMode
:= 'DM';
201 TestLimTime
:= edTime
.Text;
202 if (not TryStrToInt(TestLimTime
, n
)) then
205 TestLimScore
:= edScore
.Text;
206 if (not TryStrToInt(TestLimScore
, n
)) then
209 TestOptionsTwoPlayers
:= cbTwoPlayers
.Checked
;
210 TestOptionsTeamDamage
:= cbTeamDamage
.Checked
;
211 TestOptionsAllowExit
:= cbAllowExit
.Checked
;
212 TestOptionsWeaponStay
:= cbWeaponStay
.Checked
;
213 TestOptionsMonstersDM
:= cbMonstersDM
.Checked
;
214 TestMapOnce
:= cbMapOnce
.Checked
;
217 config
:= TConfig
.CreateFile(CfgFileName
);
219 config
.WriteInt('WADEditor', 'LogLevel', gWADEditorLogLevel
);
221 config
.WriteInt('Editor', 'DotColor', DotColor
);
222 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
223 config
.WriteInt('Editor', 'DotStepOne', DotStepOne
);
224 config
.WriteInt('Editor', 'DotStepTwo', DotStepTwo
);
225 config
.WriteInt('Editor', 'DotStep', DotStep
);
226 config
.WriteInt('Editor', 'DotSize', SpinEdit4
.Value
);
227 config
.WriteBool('Editor', 'DrawTexturePanel', DrawTexturePanel
);
228 config
.WriteBool('Editor', 'DrawPanelSize', DrawPanelSize
);
229 config
.WriteInt('Editor', 'BackColor', BackColor
);
230 config
.WriteInt('Editor', 'PreviewColor', PreviewColor
);
231 config
.WriteBool('Editor', 'UseCheckerboard', UseCheckerboard
);
232 config
.WriteInt('Editor', 'Scale', SpinEdit5
.Value
);
233 config
.WriteStr('Editor', 'Language', gLanguage
);
235 config
.WriteInt('Editor', 'RecentCount', re
);
237 config
.WriteStr('TestRun', 'GameMode', TestGameMode
);
238 config
.WriteStr('TestRun', 'LimTime', TestLimTime
);
239 config
.WriteStr('TestRun', 'LimScore', TestLimScore
);
240 config
.WriteBool('TestRun', 'TwoPlayers', TestOptionsTwoPlayers
);
241 config
.WriteBool('TestRun', 'TeamDamage', TestOptionsTeamDamage
);
242 config
.WriteBool('TestRun', 'AllowExit', TestOptionsAllowExit
);
243 config
.WriteBool('TestRun', 'WeaponStay', TestOptionsWeaponStay
);
244 config
.WriteBool('TestRun', 'MonstersDM', TestOptionsMonstersDM
);
245 config
.WriteBool('TestRun', 'MapOnce', TestMapOnce
);
246 {$IF DEFINED(DARWIN)}
247 config
.WriteStr('TestRun', 'ExeDrawin', TestD2dExe
);
248 {$ELSEIF DEFINED(WINDOWS)}
249 config
.WriteStr('TestRun', 'ExeWindows', TestD2dExe
);
251 config
.WriteStr('TestRun', 'ExeUnix', TestD2dExe
);
253 config
.WriteStr('TestRun', 'Args', TestD2DArgs
);
255 if RecentCount
<> re
then
258 MainForm
.RefreshRecentMenu();
261 config
.SaveFile(CfgFileName
);
266 procedure TOptionsForm
.bCancelClick(Sender
: TObject
);
271 procedure TOptionsForm
.FormCreate(Sender
: TObject
);
273 {$IF DEFINED(DARWIN)}
274 if LowerCase(ExtractFileExt(TestD2DExe
)) = '.app' then
275 ExeEdit
.InitialDir
:= ExtractFileDir(TestD2DExe
)
277 ExeEdit
.InitialDir
:= TestD2DExe
;
279 ExeEdit
.InitialDir
:= TestD2DExe
;