DEADSOFTWARE

Editor still case-sensitive, so file names changed manually
[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
13 TMapTestForm = class (TForm)
14 bOK: TButton;
15 bCancel: TButton;
16 GroupBox1: TGroupBox;
17 // Режим игры:
18 rbDM: TRadioButton;
19 rbTDM: TRadioButton;
20 rbCTF: TRadioButton;
21 rbCOOP: TRadioButton;
22 // Опции:
23 cbTwoPlayers: TCheckBox;
24 cbTeamDamage: TCheckBox;
25 cbAllowExit: TCheckBox;
26 cbWeaponStay: TCheckBox;
27 cbMonstersDM: TCheckBox;
28 cbMapOnce: TCheckBox;
29 // Лимит времени:
30 LabelTime: TLabel;
31 edTime: TEdit;
32 UpDown2: TUpDown;
33 LabelSecs: TLabel;
34 // Лимит очков:
35 LabelScore: TLabel;
36 edScore: TEdit;
37 UpDown1: TUpDown;
38 // Путь:
39 LabelPath: TLabel;
40 edD2dexe: TEdit;
41 bChooseD2d: TButton;
42 FindD2dDialog: TOpenDialog;
44 procedure bOKClick(Sender: TObject);
45 procedure bCancelClick(Sender: TObject);
46 procedure FormActivate(Sender: TObject);
47 procedure FormCreate(Sender: TObject);
48 procedure bChooseD2dClick(Sender: TObject);
50 private
51 { Private declarations }
52 public
53 { Public declarations }
54 end;
56 var
57 MapTestForm: TMapTestForm;
59 implementation
61 uses
62 f_main, CONFIG;
64 {$R *.lfm}
66 procedure TMapTestForm.bOKClick(Sender: TObject);
67 var
68 config: TConfig;
69 s: String;
70 n: Integer;
72 begin
73 config := TConfig.CreateFile(EditorDir+'Editor.cfg');
75 if rbTDM.Checked then
76 s := 'TDM'
77 else
78 if rbCTF.Checked then
79 s := 'CTF'
80 else
81 if rbCOOP.Checked then
82 s := 'COOP'
83 else
84 s := 'DM';
85 config.WriteStr('TestRun', 'GameMode', s);
86 TestGameMode := s;
88 s := edTime.Text;
89 if (not TryStrToInt(s, n)) then
90 s := '0';
91 config.WriteStr('TestRun', 'LimTime', s);
92 TestLimTime := s;
94 s := edScore.Text;
95 if (not TryStrToInt(s, n)) then
96 s := '0';
97 config.WriteStr('TestRun', 'LimScore', s);
98 TestLimScore := s;
100 config.WriteBool('TestRun', 'TwoPlayers', cbTwoPlayers.Checked);
101 TestOptionsTwoPlayers := cbTwoPlayers.Checked;
102 config.WriteBool('TestRun', 'TeamDamage', cbTeamDamage.Checked);
103 TestOptionsTeamDamage := cbTeamDamage.Checked;
104 config.WriteBool('TestRun', 'AllowExit', cbAllowExit.Checked);
105 TestOptionsAllowExit := cbAllowExit.Checked;
106 config.WriteBool('TestRun', 'WeaponStay', cbWeaponStay.Checked);
107 TestOptionsWeaponStay := cbWeaponStay.Checked;
108 config.WriteBool('TestRun', 'MonstersDM', cbMonstersDM.Checked);
109 TestOptionsMonstersDM := cbMonstersDM.Checked;
111 config.WriteBool('TestRun', 'MapOnce', cbMapOnce.Checked);
112 TestMapOnce := cbMapOnce.Checked;
114 config.WriteStr('TestRun', 'Exe', edD2dExe.Text);
115 TestD2dExe := edD2dExe.Text;
117 config.SaveFile(EditorDir+'Editor.cfg');
118 config.Free();
119 Close();
120 end;
122 procedure TMapTestForm.bCancelClick(Sender: TObject);
123 begin
124 Close();
125 end;
127 procedure TMapTestForm.FormActivate(Sender: TObject);
128 begin
129 if TestGameMode = 'TDM' then
130 rbTDM.Checked := True
131 else
132 if TestGameMode = 'CTF' then
133 rbCTF.Checked := True
134 else
135 if TestGameMode = 'COOP' then
136 rbCOOP.Checked := True
137 else
138 rbDM.Checked := True;
140 edTime.Text := TestLimTime;
141 edScore.Text := TestLimScore;
142 cbTwoPlayers.Checked := TestOptionsTwoPlayers;
143 cbTeamDamage.Checked := TestOptionsTeamDamage;
144 cbAllowExit.Checked := TestOptionsAllowExit;
145 cbWeaponStay.Checked := TestOptionsWeaponStay;
146 cbMonstersDM.Checked := TestOptionsMonstersDM;
147 cbMapOnce.Checked := TestMapOnce;
148 edD2dExe.Text := TestD2dExe;
149 end;
151 procedure TMapTestForm.FormCreate(Sender: TObject);
152 var
153 config: TConfig;
155 begin
156 config := TConfig.CreateFile(EditorDir+'Editor.cfg');
158 TestGameMode := config.ReadStr('TestRun', 'GameMode', 'DM');
159 TestLimTime := config.ReadStr('TestRun', 'LimTime', '0');
160 TestLimScore := config.ReadStr('TestRun', 'LimScore', '0');
161 TestOptionsTwoPlayers := config.ReadBool('TestRun', 'TwoPlayers', False);
162 TestOptionsTeamDamage := config.ReadBool('TestRun', 'TeamDamage', False);
163 TestOptionsAllowExit := config.ReadBool('TestRun', 'AllowExit', True);
164 TestOptionsWeaponStay := config.ReadBool('TestRun', 'WeaponStay', False);
165 TestOptionsMonstersDM := config.ReadBool('TestRun', 'MonstersDM', False);
166 TestMapOnce := config.ReadBool('TestRun', 'MapOnce', False);
167 TestD2dExe := config.ReadStr('TestRun', 'Exe', EditorDir+'Doom2DF.exe');
169 config.Free();
171 FindD2dDialog.InitialDir := TestD2dExe;
172 end;
174 procedure TMapTestForm.bChooseD2dClick(Sender: TObject);
175 begin
176 if FindD2dDialog.Execute then
177 begin
178 edD2dExe.Text := FindD2dDialog.FileName;
179 end;
180 end;
182 end.