DEADSOFTWARE

add build info
[d2df-editor.git] / src / editor / f_maptest.pas
1 unit f_maptest;
3 {$INCLUDE ../shared/a_modes.inc}
5 interface
7 uses
8 LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes,
9 Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
10 ComCtrls;
12 type
14 { TMapTestForm }
16 TMapTestForm = class (TForm)
17 bOK: TButton;
18 bCancel: TButton;
19 GroupBox1: TGroupBox;
20 LabelArgs: TLabel;
21 // Режим игры:
22 rbDM: TRadioButton;
23 rbTDM: TRadioButton;
24 rbCTF: TRadioButton;
25 rbCOOP: TRadioButton;
26 // Опции:
27 cbTwoPlayers: TCheckBox;
28 cbTeamDamage: TCheckBox;
29 cbAllowExit: TCheckBox;
30 cbWeaponStay: TCheckBox;
31 cbMonstersDM: TCheckBox;
32 cbMapOnce: TCheckBox;
33 // Лимит времени:
34 LabelTime: TLabel;
35 edTime: TEdit;
36 UpDown2: TUpDown;
37 LabelSecs: TLabel;
38 // Лимит очков:
39 LabelScore: TLabel;
40 edScore: TEdit;
41 UpDown1: TUpDown;
42 // Путь:
43 LabelPath: TLabel;
44 edD2dexe: TEdit;
45 edD2DArgs: TEdit;
46 bChooseD2d: TButton;
47 FindD2dDialog: TOpenDialog;
49 procedure bOKClick(Sender: TObject);
50 procedure bCancelClick(Sender: TObject);
51 procedure FormActivate(Sender: TObject);
52 procedure FormCreate(Sender: TObject);
53 procedure bChooseD2dClick(Sender: TObject);
55 private
56 { Private declarations }
57 public
58 { Public declarations }
59 end;
61 var
62 MapTestForm: TMapTestForm;
64 implementation
66 uses
67 f_main, CONFIG;
69 {$R *.lfm}
71 procedure TMapTestForm.bOKClick(Sender: TObject);
72 var
73 config: TConfig;
74 s: String;
75 n: Integer;
77 begin
78 config := TConfig.CreateFile(EditorDir+'Editor.cfg');
80 if rbTDM.Checked then
81 s := 'TDM'
82 else
83 if rbCTF.Checked then
84 s := 'CTF'
85 else
86 if rbCOOP.Checked then
87 s := 'COOP'
88 else
89 s := 'DM';
90 config.WriteStr('TestRun', 'GameMode', s);
91 TestGameMode := s;
93 s := edTime.Text;
94 if (not TryStrToInt(s, n)) then
95 s := '0';
96 config.WriteStr('TestRun', 'LimTime', s);
97 TestLimTime := s;
99 s := edScore.Text;
100 if (not TryStrToInt(s, n)) then
101 s := '0';
102 config.WriteStr('TestRun', 'LimScore', s);
103 TestLimScore := s;
105 config.WriteBool('TestRun', 'TwoPlayers', cbTwoPlayers.Checked);
106 TestOptionsTwoPlayers := cbTwoPlayers.Checked;
107 config.WriteBool('TestRun', 'TeamDamage', cbTeamDamage.Checked);
108 TestOptionsTeamDamage := cbTeamDamage.Checked;
109 config.WriteBool('TestRun', 'AllowExit', cbAllowExit.Checked);
110 TestOptionsAllowExit := cbAllowExit.Checked;
111 config.WriteBool('TestRun', 'WeaponStay', cbWeaponStay.Checked);
112 TestOptionsWeaponStay := cbWeaponStay.Checked;
113 config.WriteBool('TestRun', 'MonstersDM', cbMonstersDM.Checked);
114 TestOptionsMonstersDM := cbMonstersDM.Checked;
116 config.WriteBool('TestRun', 'MapOnce', cbMapOnce.Checked);
117 TestMapOnce := cbMapOnce.Checked;
119 config.WriteStr('TestRun', 'Exe', edD2dExe.Text);
120 TestD2dExe := edD2dExe.Text;
121 config.WriteStr('TestRun', 'Args', edD2DArgs.Text);
122 TestD2DArgs := edD2DArgs.Text;
124 config.SaveFile(EditorDir+'Editor.cfg');
125 config.Free();
126 Close();
127 end;
129 procedure TMapTestForm.bCancelClick(Sender: TObject);
130 begin
131 Close();
132 end;
134 procedure TMapTestForm.FormActivate(Sender: TObject);
135 begin
136 if TestGameMode = 'TDM' then
137 rbTDM.Checked := True
138 else
139 if TestGameMode = 'CTF' then
140 rbCTF.Checked := True
141 else
142 if TestGameMode = 'COOP' then
143 rbCOOP.Checked := True
144 else
145 rbDM.Checked := True;
147 edTime.Text := TestLimTime;
148 edScore.Text := TestLimScore;
149 cbTwoPlayers.Checked := TestOptionsTwoPlayers;
150 cbTeamDamage.Checked := TestOptionsTeamDamage;
151 cbAllowExit.Checked := TestOptionsAllowExit;
152 cbWeaponStay.Checked := TestOptionsWeaponStay;
153 cbMonstersDM.Checked := TestOptionsMonstersDM;
154 cbMapOnce.Checked := TestMapOnce;
155 edD2dExe.Text := TestD2dExe;
156 edD2DArgs.Text := TestD2DArgs;
157 end;
159 procedure TMapTestForm.FormCreate(Sender: TObject);
160 var
161 config: TConfig;
163 begin
164 config := TConfig.CreateFile(EditorDir+'Editor.cfg');
166 TestGameMode := config.ReadStr('TestRun', 'GameMode', 'DM');
167 TestLimTime := config.ReadStr('TestRun', 'LimTime', '0');
168 TestLimScore := config.ReadStr('TestRun', 'LimScore', '0');
169 TestOptionsTwoPlayers := config.ReadBool('TestRun', 'TwoPlayers', False);
170 TestOptionsTeamDamage := config.ReadBool('TestRun', 'TeamDamage', False);
171 TestOptionsAllowExit := config.ReadBool('TestRun', 'AllowExit', True);
172 TestOptionsWeaponStay := config.ReadBool('TestRun', 'WeaponStay', False);
173 TestOptionsMonstersDM := config.ReadBool('TestRun', 'MonstersDM', False);
174 TestMapOnce := config.ReadBool('TestRun', 'MapOnce', False);
175 TestD2dExe := config.ReadStr('TestRun', 'Exe', EditorDir+'Doom2DF.exe');
176 TestD2DArgs := config.ReadStr('TestRun', 'Args', '');
178 config.Free();
180 FindD2dDialog.InitialDir := TestD2dExe;
181 end;
183 procedure TMapTestForm.bChooseD2dClick(Sender: TObject);
184 begin
185 if FindD2dDialog.Execute then
186 begin
187 edD2dExe.Text := FindD2dDialog.FileName;
188 end;
189 end;
191 end.