DEADSOFTWARE

d9a8c6d7a16d39be58481ba48c93467af4a5d7e9
[d2df-sdl.git] / src / game / g_menu.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_menu;
18 interface
20 procedure g_Menu_Init();
21 procedure g_Menu_Free();
22 procedure g_Menu_Reset();
23 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
24 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
25 procedure g_Menu_AskLanguage();
27 procedure g_Menu_Show_SaveMenu();
28 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
29 procedure g_Menu_Show_GameSetGame();
30 procedure g_Menu_Show_OptionsVideo();
31 procedure g_Menu_Show_OptionsSound();
32 procedure g_Menu_Show_EndGameMenu();
33 procedure g_Menu_Show_QuitGameMenu();
35 var
36 gMenuFont: DWORD;
37 gMenuSmallFont: DWORD;
38 PromptIP: string;
39 PromptPort: Word;
40 TempScale: Integer = -1;
41 TempResScale: Integer = -1;
43 implementation
45 uses
46 {$INCLUDE ../nogl/noGLuses.inc}
47 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
48 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
49 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
50 MAPDEF, Math, g_saveload,
51 e_texture, g_language, e_res,
52 g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
53 utils, wadreader, g_system;
56 type TYNCallback = procedure (yes:Boolean);
58 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
59 begin
60 if win.UserData = nil then exit;
61 case Key of
62 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
63 IK_N: TYNCallback(win.UserData)(false);
64 end;
65 end;
67 procedure YesButtonCB (ctl: TGUITextButton);
68 begin
69 if ctl.UserData = nil then exit;
70 TYNCallback(ctl.UserData)(true);
71 end;
73 procedure NoButtonCB (ctl: TGUITextButton);
74 begin
75 if ctl.UserData = nil then exit;
76 TYNCallback(ctl.UserData)(false);
77 end;
79 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
80 var
81 menu: TGUIMenu;
82 begin
83 //if length(Text) = 0 then exit;
84 Result := TGUIWindow.Create(WinName);
85 with Result do
86 begin
87 //OnKeyDownEx := @YNKeyDownProc;
88 //UserData := @ActionProc;
89 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
90 with menu do
91 begin
92 Name := '__temp_yes_no_menu:'+WinName;
93 YesNo := true;
94 AddText(Text, MaxLen);
95 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
96 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
97 end;
98 DefControl := '__temp_yes_no_menu:'+WinName;
99 SetActive(nil);
100 end;
101 end;
104 procedure ProcChangeColor(Sender: TGUIControl); forward;
105 procedure ProcSelectModel(Sender: TGUIControl); forward;
107 procedure ProcApplyOptions();
108 var
109 menu: TGUIMenu;
110 i: Integer;
111 ovs: Boolean;
112 begin
113 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
115 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
116 gBPP := 16
117 else
118 gBPP := 32;
120 ovs := gVSync;
121 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
122 if (ovs <> gVSync) then
123 sys_EnableVSync(gVSync);
125 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
126 glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
127 gLerpActors := TGUISwitch(menu.GetControl('swInterp')).ItemIndex = 0;
129 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
131 g_Sound_SetupAllVolumes(
132 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
133 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
134 );
136 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
137 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
138 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
139 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
140 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
142 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
144 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
145 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
146 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
147 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
149 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
150 0: gGibsCount := 0;
151 1: gGibsCount := 8;
152 2: gGibsCount := 16;
153 3: gGibsCount := 32;
154 else gGibsCount := 48;
155 end;
157 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
158 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
159 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
160 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
161 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
162 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
163 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
164 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
165 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
166 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex;
167 gPlayerIndicatorStyle := TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')).ItemIndex;
168 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
169 begin
170 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
171 g_dbg_scale := TempScale + 1;
172 end;
175 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
177 with menu do
178 begin
179 g_Console_BindKey(g_Console_FindBind(1, 'screenshot'), '');
180 g_Console_BindKey(g_Console_FindBind(1, '+scores', '-scores'), '');
181 g_Console_BindKey(g_Console_FindBind(1, 'togglechat'), '');
182 g_Console_BindKey(g_Console_FindBind(1, 'toggleteamchat'), '');
183 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key, 'screenshot');
184 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key, '+scores', '-scores');
185 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key, 'togglechat');
186 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key, 'toggleteamchat');
187 end;
189 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
190 with menu do
191 begin
192 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveright', '-p1_moveright'), '');
193 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft'), '');
194 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookup', '-p1_lookup'), '');
195 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown'), '');
196 g_Console_BindKey(g_Console_FindBind(1, '+p1_attack', '-p1_attack'), '');
197 g_Console_BindKey(g_Console_FindBind(1, '+p1_jump', '-p1_jump'), '');
198 g_Console_BindKey(g_Console_FindBind(1, '+p1_activate', '-p1_activate'), '');
199 g_Console_BindKey(g_Console_FindBind(1, '+p1_strafe', '-p1_strafe'), '');
200 g_Console_BindKey(g_Console_FindBind(1, 'p1_dropflag', ''), '');
201 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapnext', ''), '');
202 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapprev', ''), '');
203 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p1_moveright', '-p1_moveright');
204 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p1_moveleft', '-p1_moveleft');
205 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p1_lookup', '-p1_lookup');
206 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p1_lookdown', '-p1_lookdown');
207 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p1_attack', '-p1_attack');
208 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p1_jump', '-p1_jump');
209 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p1_activate', '-p1_activate');
210 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p1_strafe', '-p1_strafe');
211 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0, 'p1_dropflag', '');
212 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, 'p1_weapnext', '', True);
213 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, 'p1_weapprev', '', True);
214 // second set
215 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveright', '-p1_moveright'), '');
216 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft'), '');
217 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookup', '-p1_lookup'), '');
218 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown'), '');
219 g_Console_BindKey(g_Console_FindBind(2, '+p1_attack', '-p1_attack'), '');
220 g_Console_BindKey(g_Console_FindBind(2, '+p1_jump', '-p1_jump'), '');
221 g_Console_BindKey(g_Console_FindBind(2, '+p1_activate', '-p1_activate'), '');
222 g_Console_BindKey(g_Console_FindBind(2, '+p1_strafe', '-p1_strafe'), '');
223 g_Console_BindKey(g_Console_FindBind(2, 'p1_dropflag', ''), '');
224 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapnext', ''), '');
225 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapprev', ''), '');
226 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p1_moveright', '-p1_moveright');
227 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p1_moveleft', '-p1_moveleft');
228 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p1_lookup', '-p1_lookup');
229 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p1_lookdown', '-p1_lookdown');
230 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p1_attack', '-p1_attack');
231 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p1_jump', '-p1_jump');
232 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p1_activate', '-p1_activate');
233 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p1_strafe', '-p1_strafe');
234 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1, 'p1_dropflag', '');
235 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, 'p1_weapnext', '', True);
236 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, 'p1_weapprev', '', True);
237 end;
239 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
240 with menu do
241 begin
242 for i := WP_FIRST to WP_LAST do
243 begin
244 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1)), '');
245 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p1_weapon ' + IntToStr(i + 1));
246 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1)), '');
247 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p1_weapon ' + IntToStr(i + 1));
248 end;
249 end;
251 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
252 with menu do
253 begin
254 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveright', '-p2_moveright'), '');
255 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft'), '');
256 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookup', '-p2_lookup'), '');
257 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown'), '');
258 g_Console_BindKey(g_Console_FindBind(1, '+p2_attack', '-p2_attack'), '');
259 g_Console_BindKey(g_Console_FindBind(1, '+p2_jump', '-p2_jump'), '');
260 g_Console_BindKey(g_Console_FindBind(1, '+p2_activate', '-p2_activate'), '');
261 g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe', '-p2_strafe'), '');
262 g_Console_BindKey(g_Console_FindBind(1, 'p2_dropflag', ''), '');
263 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapnext', ''), '');
264 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapprev', ''), '');
265 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright', '-p2_moveright');
266 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft', '-p2_moveleft');
267 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup', '-p2_lookup');
268 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown', '-p2_lookdown');
269 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack', '-p2_attack');
270 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump', '-p2_jump');
271 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate', '-p2_activate');
272 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe', '-p2_strafe');
273 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0, 'p2_dropflag', '');
274 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, 'p2_weapnext', '', True);
275 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, 'p2_weapprev', '', True);
276 // second set
277 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright', '-p2_moveright'), '');
278 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft'), '');
279 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookup', '-p2_lookup'), '');
280 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown'), '');
281 g_Console_BindKey(g_Console_FindBind(2, '+p2_attack', '-p2_attack'), '');
282 g_Console_BindKey(g_Console_FindBind(2, '+p2_jump', '-p2_jump'), '');
283 g_Console_BindKey(g_Console_FindBind(2, '+p2_activate', '-p2_activate'), '');
284 g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe', '-p2_strafe'), '');
285 g_Console_BindKey(g_Console_FindBind(2, 'p2_dropflag', ''), '');
286 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapnext', ''), '');
287 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapprev', ''), '');
288 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright', '-p2_moveright');
289 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft', '-p2_moveleft');
290 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup', '-p2_lookup');
291 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown', '-p2_lookdown');
292 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack', '-p2_attack');
293 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump', '-p2_jump');
294 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate', '-p2_activate');
295 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe', '-p2_strafe');
296 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1, 'p2_dropflag', '');
297 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, 'p2_weapnext', '', True);
298 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, 'p2_weapprev', '', True);
299 end;
301 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
302 with menu do
303 begin
304 for i := WP_FIRST to WP_LAST do
305 begin
306 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1)), '');
307 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p2_weapon ' + IntToStr(i + 1));
308 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1)), '');
309 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p2_weapon ' + IntToStr(i + 1));
310 end;
311 end;
313 if e_HasJoysticks then
314 begin
315 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
316 with menu do
317 begin
318 for i := 0 to e_MaxJoys - 1 do
319 if e_JoystickAvailable[i] then
320 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20)
321 end
322 end;
324 if g_touch_enabled then
325 begin
326 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
327 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
328 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
329 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
330 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
331 end;
333 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
334 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
335 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
336 TEAM_RED, TEAM_BLUE);
337 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
338 begin
339 gPlayer1Settings.Model := Model.Name;
340 gPlayer1Settings.Color := Model.Color;
341 end;
343 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
344 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
345 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
346 TEAM_RED, TEAM_BLUE);
347 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
348 begin
349 gPlayer2Settings.Model := Model.Name;
350 gPlayer2Settings.Color := Model.Color;
351 end;
353 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1WeaponMenu').GetControl('mOptionsPlayersP1WeaponMenu'));
354 gPlayer1Settings.WeaponSwitch := TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex;
355 gPlayer1Settings.SwitchToEmpty := TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex;
356 gPlayer1Settings.SkipFist := TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex;
357 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP1WeaponMenu').GetControl('mOptionsPreferencesP1WeaponMenu'));
358 with menu do
359 begin
360 for i := WP_FIRST to WP_LAST+1 do
361 begin
362 gPlayer1Settings.WeaponPreferences[i] := TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex;
363 end;
364 end;
366 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2WeaponMenu').GetControl('mOptionsPlayersP2WeaponMenu'));
367 gPlayer2Settings.WeaponSwitch := TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex;
368 gPlayer2Settings.SwitchToEmpty := TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex;
369 gPlayer2Settings.SkipFist := TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex;
370 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP2WeaponMenu').GetControl('mOptionsPreferencesP2WeaponMenu'));
371 with menu do
372 begin
373 for i := WP_FIRST to WP_LAST+1 do
374 begin
375 gPlayer2Settings.WeaponPreferences[i] := TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex;
376 end;
377 end;
379 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
380 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
382 if g_Game_IsServer then
383 begin
384 if gPlayer1 <> nil then
385 begin
386 gPlayer1.SetModel(gPlayer1Settings.Model);
387 gPlayer1.Name := gPlayer1Settings.Name;
388 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
389 gPlayer1.SetColor(gPlayer1Settings.Color)
390 else
391 if gPlayer1.Team <> gPlayer1Settings.Team then
392 gPlayer1.SwitchTeam;
393 gPlayer1.WeapSwitchMode := gPlayer1Settings.WeaponSwitch;
394 gPlayer1.setWeaponPrefs(gPlayer1Settings.WeaponPreferences);
395 gPlayer1.SwitchToEmpty := gPlayer1Settings.SwitchToEmpty;
396 gPlayer1.SkipFist := gPlayer1Settings.SkipFist;
397 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
398 end;
400 if gPlayer2 <> nil then
401 begin
402 gPlayer2.SetModel(gPlayer2Settings.Model);
403 gPlayer2.Name := gPlayer2Settings.Name;
404 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
405 gPlayer2.SetColor(gPlayer2Settings.Color)
406 else
407 if gPlayer2.Team <> gPlayer2Settings.Team then
408 gPlayer2.SwitchTeam;
409 gPlayer2.WeapSwitchMode := gPlayer2Settings.WeaponSwitch;
410 gPlayer2.setWeaponPrefs(gPlayer2Settings.WeaponPreferences);
411 gPlayer2.SwitchToEmpty := gPlayer2Settings.SwitchToEmpty;
412 gPlayer2.SkipFist := gPlayer2Settings.SkipFist;
413 //if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer2.UID);
414 end;
415 end;
417 if g_Game_IsClient then
418 begin
419 MC_SEND_PlayerSettings;
420 gPlayer1.setWeaponPrefs(gPlayer1Settings.WeaponPreferences);
421 end;
423 g_Console_WriteGameConfig;
424 end;
426 procedure ReadOptions();
427 var
428 menu: TGUIMenu;
429 i: Integer;
430 begin
431 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
433 with TGUISwitch(menu.GetControl('swBPP')) do
434 if gBPP = 16 then
435 ItemIndex := 0
436 else
437 ItemIndex := 1;
439 with TGUISwitch(menu.GetControl('swTextureFilter')) do
440 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
442 with TGUISwitch(menu.GetControl('swVSync')) do
443 if gVSync then ItemIndex := 0 else ItemIndex := 1;
445 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
446 if not glNPOTOverride then ItemIndex := 0 else ItemIndex := 1;
448 with TGUISwitch(menu.GetControl('swInterp')) do
449 if gLerpActors then ItemIndex := 0 else ItemIndex := 1;
451 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
453 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
454 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
455 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
457 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
458 if gMuteWhenInactive then
459 ItemIndex := 1
460 else
461 ItemIndex := 0;
463 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
465 with TGUISwitch(menu.GetControl('swSoundEffects')) do
466 if gSoundEffectsDF then
467 ItemIndex := 1
468 else
469 ItemIndex := 0;
471 with TGUISwitch(menu.GetControl('swChatSpeech')) do
472 if gUseChatSounds then
473 ItemIndex := 0
474 else
475 ItemIndex := 1;
477 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
478 with menu do
479 begin
480 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p1_moveright', '-p1_moveright');
481 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft');
482 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p1_lookup', '-p1_lookup');
483 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown');
484 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack', '-p1_attack');
485 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump', '-p1_jump');
486 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate', '-p1_activate');
487 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe', '-p1_strafe');
488 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0 := g_Console_FindBind(1, 'p1_dropflag', '');
489 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, 'p1_weapnext', '');
490 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, 'p1_weapprev', '');
491 // second set
492 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright', '-p1_moveright');
493 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft');
494 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p1_lookup', '-p1_lookup');
495 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown');
496 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack', '-p1_attack');
497 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump', '-p1_jump');
498 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate', '-p1_activate');
499 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe', '-p1_strafe');
500 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1 := g_Console_FindBind(2, 'p1_dropflag', '');
501 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, 'p1_weapnext', '');
502 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, 'p1_weapprev', '');
503 end;
505 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
506 with menu do
507 begin
508 for i := WP_FIRST to WP_LAST do
509 begin
510 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1));
511 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1));
512 end;
513 end;
515 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
516 with menu do
517 begin
518 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright', '-p2_moveright');
519 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft');
520 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup', '-p2_lookup');
521 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown');
522 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack', '-p2_attack');
523 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump', '-p2_jump');
524 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate', '-p2_activate');
525 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe', '-p2_strafe');
526 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0 := g_Console_FindBind(1, 'p2_dropflag', '');
527 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, 'p2_weapnext', '');
528 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, 'p2_weapprev', '');
529 // second set
530 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright', '-p2_moveright');
531 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft');
532 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup', '-p2_lookup');
533 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown');
534 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack', '-p2_attack');
535 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump', '-p2_jump');
536 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate', '-p2_activate');
537 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe', '-p2_strafe');
538 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1 := g_Console_FindBind(2, 'p2_dropflag', '');
539 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, 'p2_weapnext', '');
540 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, 'p2_weapprev', '');
541 end;
543 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
544 with menu do
545 begin
546 for i := WP_FIRST to WP_LAST do
547 begin
548 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
549 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
550 end;
551 end;
553 if e_HasJoysticks then
554 begin
555 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
556 with menu do
557 begin
558 for i := 0 to e_MaxJoys - 1 do
559 if e_JoystickAvailable[i] then
560 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20)
561 end
562 end;
564 if g_touch_enabled then
565 begin
566 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
567 with TGUISwitch(menu.GetControl('swTouchAlt')) do
568 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
569 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
570 with TGUISwitch(menu.GetControl('swTouchFire')) do
571 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
572 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
573 end;
575 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
576 with menu do
577 begin
578 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
579 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+scores', '-scores');
580 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
581 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
582 end;
584 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
586 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
587 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
588 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
589 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
590 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
592 with TGUISwitch(menu.GetControl('swScreenFlash')) do
593 ItemIndex := gFlash;
595 with TGUISwitch(menu.GetControl('swBloodType')) do
596 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
598 with TGUISwitch(menu.GetControl('swCorpseType')) do
599 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
601 with TGUISwitch(menu.GetControl('swGibsType')) do
602 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
604 with TGUISwitch(menu.GetControl('swGibsCount')) do
605 case gGibsCount of
606 0: ItemIndex := 0;
607 8: ItemIndex := 1;
608 16: ItemIndex := 2;
609 32: ItemIndex := 3;
610 else ItemIndex := 4;
611 end;
613 with TGUISwitch(menu.GetControl('swBackGround')) do
614 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
616 with TGUISwitch(menu.GetControl('swMessages')) do
617 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
619 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
620 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
622 with TGUISwitch(menu.GetControl('swChatBubble')) do
623 ItemIndex := gChatBubble;
625 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
626 ItemIndex := gPlayerIndicator;
628 with TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')) do
629 ItemIndex := gPlayerIndicatorStyle;
631 TempScale := Round(g_dbg_scale - 1);
632 TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
634 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
636 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
637 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
639 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
640 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
642 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
643 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
644 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
646 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1WeaponMenu').GetControl('mOptionsPlayersP1WeaponMenu'));
647 TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex := gPlayer1Settings.WeaponSwitch;
648 TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex := gPlayer1Settings.SwitchToEmpty;
649 TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex := gPlayer1Settings.SkipFist;
650 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP1WeaponMenu').GetControl('mOptionsPreferencesP1WeaponMenu'));
651 for i := WP_FIRST to WP_LAST+1 do
652 begin
653 if (gPlayer1Settings.WeaponPreferences[i] > 0) and (gPlayer1Settings.WeaponPreferences[i] <= WP_LAST+1) then TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := gPlayer1Settings.WeaponPreferences[i]
654 else TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := 0;
655 end;
657 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2WeaponMenu').GetControl('mOptionsPlayersP2WeaponMenu'));
658 TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex := gPlayer2Settings.WeaponSwitch;
659 TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex := gPlayer2Settings.SwitchToEmpty;
660 TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex := gPlayer2Settings.SkipFist;
661 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP2WeaponMenu').GetControl('mOptionsPreferencesP2WeaponMenu'));
662 for i := WP_FIRST to WP_LAST+1 do
663 begin
664 if (gPlayer2Settings.WeaponPreferences[i] > 0) and (gPlayer2Settings.WeaponPreferences[i] <= WP_LAST+1) then TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := gPlayer2Settings.WeaponPreferences[i]
665 else TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := 0;
666 end;
668 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
670 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
671 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
673 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
674 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
676 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
677 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
678 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
680 ProcSelectModel(nil);
681 end;
683 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
684 begin
685 // don't turn off monsters in DM
687 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
688 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
689 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
690 else
691 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
694 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
695 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
696 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
697 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
699 end;
701 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
702 begin
703 // don't turn off monsters in DM
705 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
706 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
707 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
708 else
709 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
712 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
713 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
714 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
715 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
717 end;
719 function LatchGameOptions(const MenuName: string): Byte;
720 var
721 Map: string;
722 begin
723 Result := GM_NONE;
725 with TGUIMenu(g_ActiveWindow.GetControl(MenuName)) do
726 begin
727 Map := TGUILabel(GetControl('lbMap')).Text;
728 if Map = '' then
729 Exit;
730 if not isWadPath(Map) then
731 Exit;
733 Result := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
734 gsGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
735 gsTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
736 gsScoreLimit := StrToIntDef(TGUIEdit(GetControl('edScoreLimit')).Text, 0);
737 gsMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
738 gsItemRespawnTime := StrToIntDef(TGUIEdit(GetControl('edItemRespawnTime')).Text, 0);
739 gsRulezRespawnTime := StrToIntDef(TGUIEdit(GetControl('edRulezRespawnTime')).Text, 0);
740 gsRulezRespawnRandom := StrToIntDef(TGUIEdit(GetControl('edRulezRespawnRandom')).Text, 0);
741 gsPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
742 gsMap := Map;
744 gsGameFlags := 0;
745 if TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0 then
746 gsGameFlags := gsGameFlags or GAME_OPTION_TEAMDAMAGE;
747 if TGUISwitch(GetControl('swTeamAbsorbDamage')).ItemIndex = 0 then
748 gsGameFlags := gsGameFlags or GAME_OPTION_TEAMABSORBDAMAGE;
749 if TGUISwitch(GetControl('swDeathmatchKeys')).ItemIndex = 0 then
750 gsGameFlags := gsGameFlags or GAME_OPTION_DMKEYS;
751 if TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0 then
752 gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWEXIT;
753 if TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0 then
754 gsGameFlags := gsGameFlags or GAME_OPTION_WEAPONSTAY;
755 if TGUISwitch(GetControl('swMonsters')).ItemIndex = 0 then
756 gsGameFlags := gsGameFlags or GAME_OPTION_MONSTERS;
757 if TGUISwitch(GetControl('swRulezRandom')).ItemIndex = 0 then
758 gsGameFlags := gsGameFlags or GAME_OPTION_RULEZRANDOM;
760 case TGUISwitch(GetControl('swTeamHit')).ItemIndex of
761 1: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE;
762 2: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITPROJECTILE;
763 0: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
764 end;
766 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
767 1: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSMONSTER;
768 2: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
769 else gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER;
770 end;
772 case TGUISwitch(GetControl('swFlagDrop')).ItemIndex of
773 0: gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
774 1: gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWDROPFLAG;
775 else gsGameFlags := gsGameFlags and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
776 end;
778 // TODO: get this crap out of here
779 gGameSettings.ItemRespawnTime := gsItemRespawnTime;
780 gGameSettings.RulezRespawnTime := gsRulezRespawnTime;
781 gGameSettings.RulezRespawnRandom := gsRulezRespawnRandom;
782 gGameSettings.WarmupTime := gsWarmupTime;
783 gGameSettings.SpawnInvul := gsSpawnInvul;
784 end;
785 end;
787 procedure ProcStartCustomGame();
788 var
789 GameMode: Byte;
790 begin
791 GameMode := LatchGameOptions('mCustomGameMenu');
792 if GameMode = GM_NONE then Exit;
794 g_Console_WriteGameConfig;
795 g_Game_StartCustom(gsMap, GameMode, gsTimeLimit, gsScoreLimit,
796 gsMaxLives, gsGameFlags, gsPlayers);
797 end;
800 procedure ProcStartNetGame();
801 var
802 GameMode: Byte;
803 begin
804 GameMode := LatchGameOptions('mNetServerMenu');
805 if GameMode = GM_NONE then Exit;
807 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
808 begin
809 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
810 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
811 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
812 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
813 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
814 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
815 end;
817 g_Console_WriteGameConfig;
818 g_Game_StartServer(gsMap, GameMode, gsTimeLimit, gsScoreLimit, gsMaxLives,
819 gsGameFlags, gsPlayers, 0, NetPort);
820 end;
822 procedure ProcConnectNetGame();
823 var
824 PW: String;
825 begin
826 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
827 begin
828 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
829 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
830 PW := TGUIEdit(GetControl('edPW')).Text;
831 end;
833 g_Console_WriteGameConfig;
834 g_Game_StartClient(NetClientIP, NetClientPort, PW);
835 end;
837 procedure ProcEnterPassword();
838 var
839 PW: string;
840 begin
841 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
842 begin
843 NetClientIP := PromptIP;
844 NetClientPort := PromptPort;
845 PW := TGUIEdit(GetControl('edPW')).Text;
846 end;
848 g_Console_WriteGameConfig;
849 g_Game_StartClient(NetClientIP, NetClientPort, PW);
850 end;
852 procedure ProcServerlist();
853 begin
854 if not NetInitDone then
855 begin
856 if (not g_Net_Init()) then
857 begin
858 g_Console_Add('NET: ERROR: Failed to init ENet!');
859 Exit;
860 end
861 else
862 NetInitDone := True;
863 end;
865 g_Net_Slist_Set(NetMasterList);
867 gState := STATE_SLIST;
868 g_ActiveWindow := nil;
870 slWaitStr := _lc[I_NET_SLIST_WAIT];
872 g_Game_Draw;
873 sys_Repaint;
875 slReturnPressed := True;
876 if g_Net_Slist_Fetch(slCurrent) then
877 begin
878 if slCurrent = nil then
879 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
880 end
881 else
882 slWaitStr := _lc[I_NET_SLIST_ERROR];
883 g_Serverlist_GenerateTable(slCurrent, slTable);
884 end;
886 procedure ProcStartCampaign();
887 var
888 WAD: String;
889 TwoPlayers: Boolean;
890 n: Byte;
891 begin
892 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
893 begin
894 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
895 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
896 end;
897 WAD := e_FindWadRel(MegawadDirs, WAD);
899 if TwoPlayers then
900 n := 2
901 else
902 n := 1;
903 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
904 end;
906 procedure ProcSelectMap(Sender: TGUIControl);
907 var
908 win: TGUIWindow;
909 a: TMapInfo;
910 wad, map, res: String;
911 begin
912 win := g_GUI_GetWindow('SelectMapMenu');
913 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
914 begin
915 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
916 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
918 if (wad = '') or (map = '') then
919 begin // Ýòî íå êàðòà
920 TGUILabel(GetControl('lbMapName')).Text := '';
921 TGUILabel(GetControl('lbMapAuthor')).Text := '';
922 TGUILabel(GetControl('lbMapSize')).Text := '';
923 TGUIMemo(GetControl('meMapDescription')).SetText('');
924 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
925 TGUILabel(win.GetControl('lbMapScale')).Text := '';
926 end
927 else // Ýòî êàðòà
928 begin
929 res := wad+':\'+map;
931 a := g_Map_GetMapInfo(res);
933 TGUILabel(GetControl('lbMapName')).Text := a.Name;
934 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
935 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
936 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
937 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
938 TGUILabel(win.GetControl('lbMapScale')).Text :=
939 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
940 end;
941 end;
942 end;
944 procedure ProcSelectWAD(Sender: TGUIControl);
945 var
946 wad: String;
947 list: SSArray;
948 begin
949 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
950 begin
951 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
953 with TGUIListBox(GetControl('lsMapRes')) do
954 begin
955 Clear();
957 if wad <> '' then
958 begin
959 list := g_Map_GetMapsList(wad);
961 if list <> nil then
962 begin
963 Items := list;
964 ItemIndex := 0;
965 end
966 end;
967 end;
968 end;
970 ProcSelectMap(nil);
971 end;
973 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
974 var
975 win: TGUIWindow;
976 a: TMegaWADInfo;
977 wad, fn: String;
978 begin
979 win := g_GUI_GetWindow('CampaignMenu');
980 with TGUIMenu(win.GetControl('mCampaignMenu')) do
981 begin
982 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
984 if wad = '' then
985 begin
986 TGUILabel(GetControl('lbWADName')).Text := '';
987 TGUILabel(GetControl('lbWADAuthor')).Text := '';
988 TGUIMemo(GetControl('meWADDescription')).SetText('');
989 end;
991 a := g_Game_GetMegaWADInfo(wad);
993 TGUILabel(GetControl('lbWADName')).Text := a.Name;
994 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
995 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
997 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
999 if a.pic <> '' then
1000 begin
1001 fn := g_ExtractWadName(a.pic);
1002 if fn = '' then
1003 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
1004 else
1005 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
1006 end;
1007 end;
1008 end;
1010 procedure ProcChangeColor(Sender: TGUIControl);
1011 var
1012 window: TGUIWindow;
1013 begin
1014 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1015 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
1016 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
1017 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
1018 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
1019 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
1021 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1022 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
1023 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
1024 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
1025 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
1026 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
1027 end;
1029 procedure ProcSelectModel(Sender: TGUIControl);
1030 var
1031 a: string;
1032 window: TGUIWindow;
1033 begin
1034 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1035 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
1036 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
1038 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1039 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
1040 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
1042 ProcChangeColor(nil);
1043 end;
1045 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
1046 var
1047 cwdt, chgt: Byte;
1048 spc: ShortInt;
1049 ID: DWORD;
1050 wad: TWADFile;
1051 cfgdata: Pointer;
1052 cfglen: Integer;
1053 config: TConfig;
1054 begin
1055 cfglen := 0;
1057 wad := TWADFile.Create;
1058 if wad.ReadFile(GameWAD) then
1059 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
1060 wad.Free();
1062 if cfglen <> 0 then
1063 begin
1064 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
1066 config := TConfig.CreateMem(cfgdata, cfglen);
1067 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1068 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1069 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1071 if g_Texture_Get('FONT_STD', ID) then
1072 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
1074 config.Free();
1075 end;
1077 if cfglen <> 0 then FreeMem(cfgdata);
1078 end;
1080 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
1081 var
1082 cwdt, chgt: Byte;
1083 spc: ShortInt;
1084 CharID: DWORD;
1085 wad: TWADFile;
1086 cfgdata, fntdata: Pointer;
1087 cfglen, fntlen: Integer;
1088 config: TConfig;
1089 chrwidth: Integer;
1090 a: Byte;
1091 begin
1092 cfglen := 0;
1093 fntlen := 0;
1095 wad := TWADFile.Create;
1096 if wad.ReadFile(GameWAD) then
1097 begin
1098 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1099 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1100 end;
1101 wad.Free();
1103 if cfglen <> 0 then
1104 begin
1105 config := TConfig.CreateMem(cfgdata, cfglen);
1106 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1107 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1109 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1110 FontID := e_CharFont_Create(spc);
1112 for a := 0 to 255 do
1113 begin
1114 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1115 if chrwidth = 0 then Continue;
1117 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1118 cwdt, chgt) then
1119 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1120 end;
1122 config.Free();
1123 end;
1125 if cfglen <> 0 then FreeMem(cfgdata);
1126 if fntlen <> 0 then FreeMem(fntdata);
1127 end;
1129 procedure MenuLoadData();
1130 begin
1131 e_WriteLog('Loading menu data...', TMsgType.Notify);
1133 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD+':TEXTURES\MAINLOGO');
1134 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1135 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1136 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1137 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1138 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1139 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1140 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1141 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1142 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1143 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1144 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1145 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1146 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1147 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1148 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1149 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1150 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1151 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1152 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1153 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1154 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1155 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1156 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1157 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1159 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1160 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1161 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1162 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1163 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1164 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1165 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1166 end;
1168 procedure MenuFreeData();
1169 begin
1170 e_CharFont_Remove(gMenuFont);
1171 e_CharFont_Remove(gMenuSmallFont);
1173 g_Texture_Delete('MAINMENU_LOGO');
1174 g_Texture_Delete('MAINMENU_MARKER1');
1175 g_Texture_Delete('MAINMENU_MARKER2');
1176 g_Texture_Delete('SCROLL_LEFT');
1177 g_Texture_Delete('SCROLL_RIGHT');
1178 g_Texture_Delete('SCROLL_MIDDLE');
1179 g_Texture_Delete('SCROLL_MARKER');
1180 g_Texture_Delete('EDIT_LEFT');
1181 g_Texture_Delete('EDIT_RIGHT');
1182 g_Texture_Delete('EDIT_MIDDLE');
1183 g_Texture_Delete('BOX1');
1184 g_Texture_Delete('BOX2');
1185 g_Texture_Delete('BOX3');
1186 g_Texture_Delete('BOX4');
1187 g_Texture_Delete('BOX5');
1188 g_Texture_Delete('BOX6');
1189 g_Texture_Delete('BOX7');
1190 g_Texture_Delete('BOX8');
1191 g_Texture_Delete('BOX9');
1192 g_Texture_Delete('BSCROLL_UP_A');
1193 g_Texture_Delete('BSCROLL_UP_U');
1194 g_Texture_Delete('BSCROLL_DOWN_A');
1195 g_Texture_Delete('BSCROLL_DOWN_U');
1196 g_Texture_Delete('BSCROLL_MIDDLE');
1197 g_Texture_Delete('NOPIC');
1199 g_Sound_Delete('MENU_SELECT');
1200 g_Sound_Delete('MENU_OPEN');
1201 g_Sound_Delete('MENU_CLOSE');
1202 g_Sound_Delete('MENU_CHANGE');
1203 g_Sound_Delete('SCROLL_ADD');
1204 g_Sound_Delete('SCROLL_SUB');
1205 g_Sound_Delete('SOUND_PLAYER_FALL');
1206 end;
1208 procedure ProcAuthorsMenu();
1209 begin
1210 gMusic.SetByName('MUSIC_INTERMUS');
1211 gMusic.Play();
1212 end;
1214 procedure ProcExitMenuKeyDown (yes: Boolean);
1215 var
1216 s: ShortString;
1217 snd: TPlayableSound;
1218 res: Boolean;
1219 begin
1220 if yes then
1221 begin
1222 g_Game_StopAllSounds(True);
1223 case (Random(18)) of
1224 0: s := 'SOUND_MONSTER_PAIN';
1225 1: s := 'SOUND_MONSTER_DIE_3';
1226 2: s := 'SOUND_MONSTER_SLOP';
1227 3: s := 'SOUND_MONSTER_DEMON_DIE';
1228 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1229 5: s := 'SOUND_MONSTER_MAN_DIE';
1230 6: s := 'SOUND_MONSTER_BSP_DIE';
1231 7: s := 'SOUND_MONSTER_VILE_DIE';
1232 8: s := 'SOUND_MONSTER_SKEL_DIE';
1233 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1234 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1235 11: s := 'SOUND_MONSTER_BARON_DIE';
1236 12: s := 'SOUND_MONSTER_CACO_DIE';
1237 13: s := 'SOUND_MONSTER_CYBER_DIE';
1238 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1239 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1240 else s := 'SOUND_PLAYER_FALL';
1241 end;
1242 snd := TPlayableSound.Create();
1243 res := snd.SetByName(s);
1244 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1245 if res then
1246 begin
1247 snd.Play(True);
1248 while snd.IsPlaying() do begin end;
1249 end;
1250 g_Game_Quit();
1251 exit;
1252 end;
1253 g_GUI_HideWindow();
1254 end;
1256 procedure ProcLoadMenu();
1257 var
1258 a: Integer;
1259 valid: Boolean;
1260 begin
1261 for a := 1 to 8 do
1262 begin
1263 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1264 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1265 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1266 end;
1267 end;
1269 procedure ProcSaveMenu();
1270 var
1271 a: Integer;
1272 valid: Boolean;
1273 name: AnsiString;
1274 begin
1275 for a := 1 to 8 do
1276 begin
1277 name := g_GetSaveName(a, valid);
1278 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1279 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1280 end;
1281 end;
1283 procedure ProcSaveGame(Sender: TGUIControl);
1284 var
1285 a: Integer;
1286 begin
1287 if g_Game_IsNet then Exit;
1288 if g_Game_IsTestMap then Exit;
1289 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1290 g_Game_PauseAllSounds(True);
1291 g_SaveGame(a, TGUIEdit(Sender).Text);
1293 g_ActiveWindow := nil;
1294 g_Game_Pause(False);
1295 end;
1297 procedure ProcLoadGame(Sender: TGUIControl);
1298 var
1299 a: Integer;
1300 begin
1301 if g_Game_IsNet then Exit;
1302 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1303 if g_LoadGame(a) then
1304 begin
1305 g_Game_PauseAllSounds(False)
1306 end
1307 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1308 begin
1309 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1310 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1311 //g_ActiveWindow := nil;
1312 end;
1313 end;
1315 procedure ProcSinglePlayer (n: Integer);
1316 var wad, map: AnsiString;
1317 begin
1318 assert(n >= 1);
1319 wad := g_ExtractWadName(gDefaultMegawadStart);
1320 map := g_ExtractFilePathName(gDefaultMegawadStart);
1321 if e_FindResource(AllMapDirs, wad) then
1322 begin
1323 wad := ExpandFileName(wad);
1324 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1325 end
1326 end;
1328 procedure ProcSingle1Player;
1329 begin
1330 ProcSinglePlayer(1)
1331 end;
1333 procedure ProcSingle2Players;
1334 begin
1335 ProcSinglePlayer(2)
1336 end;
1338 procedure ProcSelectMapMenu();
1339 var
1340 menu: TGUIMenu;
1341 wad_lb: TGUIFileListBox;
1342 map_lb: TGUIListBox;
1343 map: String;
1344 begin
1345 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1346 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1347 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1349 if wad_lb.SelectedItem() <> '' then
1350 map := map_lb.SelectedItem()
1351 else
1352 map := '';
1354 wad_lb.UpdateFileList();
1355 map_lb.Clear();
1357 if wad_lb.SelectedItem() <> '' then
1358 begin
1359 ProcSelectWAD(nil);
1360 map_lb.SelectItem(map);
1362 if map_lb.SelectedItem() <> '' then
1363 ProcSelectMap(nil);
1364 end;
1366 g_GUI_ShowWindow('SelectMapMenu');
1367 end;
1369 procedure ProcSelectCampaignMenu();
1370 var
1371 menu: TGUIMenu;
1372 wad_lb: TGUIFileListBox;
1373 begin
1374 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1375 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1377 wad_lb.UpdateFileList();
1379 if wad_lb.SelectedItem() <> '' then
1380 ProcSelectCampaignWAD(nil);
1381 end;
1383 procedure ProcSetMap();
1384 var
1385 wad, map, res: String;
1386 begin
1387 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1388 begin
1389 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1390 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1391 end;
1393 if (wad = '') or (map = '') then
1394 Exit;
1396 wad := e_FindWadRel(MapDirs, WAD);
1398 res := wad+':\'+map;
1400 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1401 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1402 end;
1404 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1405 var
1406 menu: TGUIMenu;
1407 begin
1408 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1410 g_Sound_SetupAllVolumes(
1411 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1412 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1413 );
1414 end;
1416 procedure ProcChangeGameSettings(Sender: TGUIControl);
1417 var
1418 menu: TGUIMenu;
1419 begin
1420 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1421 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1422 begin
1423 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1424 g_dbg_scale := TempScale + 1;
1425 end;
1426 end;
1428 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1429 var
1430 menu: TGUIMenu;
1431 begin
1432 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1433 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1434 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1435 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1436 end;
1438 procedure ProcOptionsPlayersMIMenu();
1439 var
1440 s, a: string;
1441 b: TModelInfo;
1442 begin
1443 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1445 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1447 if a = '' then Exit;
1449 b := g_PlayerModel_GetInfo(a);
1451 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1452 begin
1453 TGUILabel(GetControl('lbName')).Text := b.Name;
1454 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1455 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1457 if b.HaveWeapon then
1458 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1459 else
1460 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1461 end;
1463 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1464 end;
1466 procedure ProcOptionsPlayerP1WeaponMenu();
1467 var
1468 a: string;
1469 begin
1470 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P1'+'Menu')).GetControl('ls'+'P1'+'Model')).SelectedItem;
1471 if a = '' then Exit;
1472 g_GUI_ShowWindow('OptionsPlayersP1WeaponMenu');
1473 end;
1475 procedure ProcOptionsPlayerP1WeaponPreferencesMenu();
1476 begin
1477 g_GUI_ShowWindow('OptionsPreferencesP1WeaponMenu');
1478 end;
1480 procedure ProcOptionsPlayerP2WeaponMenu();
1481 var
1482 a: string;
1483 begin
1484 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P2'+'Menu')).GetControl('ls'+'P2'+'Model')).SelectedItem;
1485 if a = '' then Exit;
1486 g_GUI_ShowWindow('OptionsPlayersP2WeaponMenu');
1487 end;
1489 procedure ProcOptionsPlayerP2WeaponPreferencesMenu();
1490 begin
1491 g_GUI_ShowWindow('OptionsPreferencesP2WeaponMenu');
1492 end;
1494 procedure ProcOptionsPlayersAnim();
1495 var
1496 s: String;
1497 begin
1498 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1499 s := 'P1'
1500 else
1501 s := 'P2';
1503 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1504 begin
1505 NextAnim();
1506 Model.GetCurrentAnimation.Loop := True;
1507 Model.GetCurrentAnimationMask.Loop := True;
1508 end;
1509 end;
1511 procedure ProcOptionsPlayersWeap();
1512 var
1513 s: String;
1514 begin
1515 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1516 s := 'P1'
1517 else
1518 s := 'P2';
1520 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1521 NextWeapon();
1522 end;
1524 procedure ProcOptionsPlayersRot();
1525 var
1526 s: string;
1527 begin
1528 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1529 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1530 begin
1531 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1532 end;
1533 end;
1535 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1536 begin
1537 if yes then
1538 begin
1539 g_Options_SetDefault();
1540 ReadOptions();
1541 end;
1542 g_GUI_HideWindow();
1543 end;
1545 procedure ProcSavedMenuKeyDown (yes: Boolean);
1546 begin
1547 if yes then ReadOptions();
1548 g_GUI_HideWindow();
1549 end;
1551 procedure ProcAuthorsClose();
1552 begin
1553 gMusic.SetByName('MUSIC_MENU');
1554 gMusic.Play();
1555 gState := STATE_MENU;
1556 end;
1558 procedure ProcGMClose();
1559 begin
1560 g_Game_InGameMenu(False);
1561 end;
1563 procedure ProcGMShow();
1564 var
1565 Enabled: Boolean;
1566 begin
1567 Enabled := True;
1568 if (gGameSettings.GameType = GT_SINGLE) and
1569 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1570 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1571 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1572 if not gGameOn then
1573 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1574 if g_Game_IsTestMap then
1575 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1576 TGUIMainMenu(g_ActiveWindow.GetControl(
1577 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1578 end;
1580 procedure ProcChangePlayers();
1581 var
1582 TeamGame, Spectator, AddTwo: Boolean;
1583 P1Team{, P2Team}: Byte;
1584 bP2: TGUITextButton;
1585 begin
1586 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1587 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1588 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1589 P1Team := TEAM_NONE;
1590 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1591 // TODO
1592 //P2Team := TEAM_NONE;
1593 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1595 TGUIMainMenu(g_ActiveWindow.GetControl(
1596 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1597 TGUIMainMenu(g_ActiveWindow.GetControl(
1598 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1599 TGUIMainMenu(g_ActiveWindow.GetControl(
1600 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1602 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1603 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1604 bP2.Enabled := AddTwo and not Spectator;
1605 if bP2.Enabled then
1606 bP2.Color := MAINMENU_ITEMS_COLOR
1607 else
1608 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1609 if gPlayer2 = nil then
1610 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1611 else
1612 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1614 TGUIMainMenu(g_ActiveWindow.GetControl(
1615 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1616 end;
1618 procedure ProcJoinRed();
1619 begin
1620 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1621 Exit;
1622 if g_Game_IsServer then
1623 begin
1624 if gPlayer1 = nil then
1625 g_Game_AddPlayer(TEAM_RED)
1626 else
1627 begin
1628 if gPlayer1.Team <> TEAM_RED then
1629 begin
1630 gPlayer1.SwitchTeam;
1631 gPlayer1Settings.Team := gPlayer1.Team;
1632 end;
1634 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1635 end;
1636 end
1637 else
1638 begin
1639 gPlayer1Settings.Team := TEAM_RED;
1640 MC_SEND_PlayerSettings;
1641 if gPlayer1 = nil then
1642 g_Game_AddPlayer(TEAM_RED);
1643 end;
1644 g_ActiveWindow := nil;
1645 g_Game_Pause(False);
1646 end;
1648 procedure ProcJoinBlue();
1649 begin
1650 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1651 Exit;
1652 if g_Game_IsServer then
1653 begin
1654 if gPlayer1 = nil then
1655 g_Game_AddPlayer(TEAM_BLUE)
1656 else
1657 begin
1658 if gPlayer1.Team <> TEAM_BLUE then
1659 begin
1660 gPlayer1.SwitchTeam;
1661 gPlayer1Settings.Team := gPlayer1.Team;
1662 end;
1664 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1665 end;
1666 end
1667 else
1668 begin
1669 gPlayer1Settings.Team := TEAM_BLUE;
1670 MC_SEND_PlayerSettings;
1671 if gPlayer1 = nil then
1672 g_Game_AddPlayer(TEAM_BLUE);
1673 end;
1674 g_ActiveWindow := nil;
1675 g_Game_Pause(False);
1676 end;
1678 procedure ProcJoinGame();
1679 begin
1680 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1681 Exit;
1682 if gPlayer1 = nil then
1683 g_Game_AddPlayer();
1684 g_ActiveWindow := nil;
1685 g_Game_Pause(False);
1686 end;
1688 procedure ProcSwitchP2();
1689 begin
1690 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1691 Exit;
1692 if gPlayer1 = nil then
1693 Exit;
1694 if gPlayer2 = nil then
1695 g_Game_AddPlayer()
1696 else
1697 g_Game_RemovePlayer();
1698 g_ActiveWindow := nil;
1699 g_Game_Pause(False);
1700 end;
1702 procedure ProcSpectate();
1703 begin
1704 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1705 Exit;
1706 g_Game_Spectate();
1707 g_ActiveWindow := nil;
1708 g_Game_Pause(False);
1709 end;
1711 procedure ProcRestartMenuKeyDown (yes: Boolean);
1712 begin
1713 if yes then g_Game_Restart() else g_GUI_HideWindow;
1714 end;
1716 procedure ProcEndMenuKeyDown (yes: Boolean);
1717 begin
1718 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1719 end;
1721 procedure ProcSetRussianLanguage;
1722 begin
1723 if gLanguage <> LANGUAGE_RUSSIAN then
1724 begin
1725 gLanguage := LANGUAGE_RUSSIAN;
1726 gLanguageChange := True;
1727 gAskLanguage := False;
1728 ProcApplyOptions();
1729 end;
1730 end;
1732 procedure ProcSetEnglishLanguage;
1733 begin
1734 if gLanguage <> LANGUAGE_ENGLISH then
1735 begin
1736 gLanguage := LANGUAGE_ENGLISH;
1737 gLanguageChange := True;
1738 gAskLanguage := False;
1739 ProcApplyOptions();
1740 end;
1741 end;
1743 procedure ReadGameSettings();
1744 var
1745 menu: TGUIMenu;
1746 begin
1747 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1749 with gGameSettings do
1750 begin
1751 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1752 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1753 ItemIndex := 0
1754 else
1755 ItemIndex := 1;
1756 with TGUISwitch(menu.GetControl('swTeamHit')) do
1757 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1758 ItemIndex := 0
1759 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1760 ItemIndex := 1
1761 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1762 ItemIndex := 2
1763 else
1764 ItemIndex := 3;
1765 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1766 if LongBool(Options and GAME_OPTION_DMKEYS) then
1767 ItemIndex := 0
1768 else
1769 ItemIndex := 1;
1770 with TGUISwitch(menu.GetControl('swFlagDrop')) do
1771 if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) and LongBool(Options and GAME_OPTION_THROWFLAG) then
1772 ItemIndex := 0
1773 else if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) then
1774 ItemIndex := 1
1775 else
1776 ItemIndex := 2;
1778 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1779 TGUIEdit(menu.GetControl('edScoreLimit')).Text := IntToStr(ScoreLimit);
1780 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1782 with TGUISwitch(menu.GetControl('swBotsVS')) do
1783 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1784 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1785 ItemIndex := 2
1786 else
1787 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1788 ItemIndex := 1
1789 else
1790 ItemIndex := 0;
1792 if GameType in [GT_CUSTOM, GT_SERVER] then
1793 begin
1794 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1795 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1796 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1797 begin
1798 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1799 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1800 end
1801 else
1802 begin
1803 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1804 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1805 end;
1806 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1807 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1808 TGUIEdit(menu.GetControl('edScoreLimit')).Enabled := True;
1809 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_ITEMSTEXT_COLOR;
1810 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1811 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1812 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1813 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := True;
1814 end
1815 else
1816 begin
1817 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1818 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1819 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1820 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1821 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1822 begin
1823 Enabled := False;
1824 Text := '';
1825 end;
1826 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1827 with TGUIEdit(menu.GetControl('edScoreLimit')) do
1828 begin
1829 Enabled := False;
1830 Text := '';
1831 end;
1832 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1833 with TGUIEdit(menu.GetControl('edMaxLives')) do
1834 begin
1835 Enabled := False;
1836 Text := '';
1837 end;
1838 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1839 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1840 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := False;
1841 end;
1842 end;
1843 end;
1845 procedure ProcApplyGameSet();
1846 var
1847 menu: TGUIMenu;
1848 a, b, n: Integer;
1849 stat: TPlayerStatArray;
1850 begin
1851 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1853 if not g_Game_IsServer then Exit;
1855 with gGameSettings do
1856 begin
1857 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1858 begin
1859 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1860 Options := Options or GAME_OPTION_TEAMDAMAGE
1861 else
1862 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1863 end;
1865 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1866 begin
1867 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1868 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1869 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1870 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1871 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1872 end;
1873 end;
1875 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1876 begin
1877 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1878 Options := Options or GAME_OPTION_DMKEYS
1879 else
1880 Options := Options and (not GAME_OPTION_DMKEYS);
1881 end;
1883 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1884 begin
1885 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1887 if n = 0 then
1888 TimeLimit := 0
1889 else
1890 begin
1891 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1893 TimeLimit := Max(n, b);
1894 end;
1895 end;
1897 if TGUIEdit(menu.GetControl('edScoreLimit')).Enabled then
1898 begin
1899 n := StrToIntDef(TGUIEdit(menu.GetControl('edScoreLimit')).Text, ScoreLimit);
1901 if n = 0 then
1902 ScoreLimit := 0
1903 else
1904 begin
1905 b := 0;
1906 if GameMode = GM_DM then
1907 begin // DM
1908 stat := g_Player_GetStats();
1909 if stat <> nil then
1910 for a := 0 to High(stat) do
1911 if stat[a].Frags > b then
1912 b := stat[a].Frags;
1913 end
1914 else // CTF
1915 b := Max(gTeamStat[TEAM_RED].Score, gTeamStat[TEAM_BLUE].Score);
1917 ScoreLimit := Max(n, b);
1918 end;
1919 end;
1921 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1922 begin
1923 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, MaxLives);
1924 if n < 0 then n := 0;
1925 if n > 255 then n := 255;
1926 if n = 0 then
1927 MaxLives := 0
1928 else
1929 begin
1930 b := 0;
1931 stat := g_Player_GetStats();
1932 if stat <> nil then
1933 for a := 0 to High(stat) do
1934 if stat[a].Lives > b then
1935 b := stat[a].Lives;
1937 MaxLives := Max(n, b);
1938 end;
1939 end;
1941 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1942 begin
1943 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1944 1:
1945 begin
1946 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1947 Options := Options or GAME_OPTION_BOTVSMONSTER;
1948 end;
1949 2:
1950 begin
1951 Options := Options or GAME_OPTION_BOTVSPLAYER;
1952 Options := Options or GAME_OPTION_BOTVSMONSTER;
1953 end;
1954 else
1955 begin
1956 Options := Options or GAME_OPTION_BOTVSPLAYER;
1957 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1958 end;
1959 end;
1960 end;
1962 if TGUISwitch(menu.GetControl('swFlagDrop')).Enabled then
1963 begin
1964 case TGUISwitch(menu.GetControl('swFlagDrop')).ItemIndex of
1965 0: Options := Options or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
1966 1: Options := Options or GAME_OPTION_ALLOWDROPFLAG;
1967 else Options := Options and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
1968 end;
1969 end;
1971 // don't forget to latch this shit
1972 gsGameFlags := Options;
1973 gsMaxLives := MaxLives;
1974 gsScoreLimit := ScoreLimit;
1975 gsTimeLimit := TimeLimit;
1976 end;
1978 if g_Game_IsNet then MH_SEND_GameSettings;
1979 end;
1981 procedure ProcVideoOptionsRes();
1982 var
1983 menu: TGUIMenu;
1984 list: SSArray;
1985 begin
1986 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1988 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1989 IntToStr(gWinSizeX) +
1990 ' x ' + IntToStr(gWinSizeY) +
1991 ', ' + IntToStr(gBPP) + ' bpp';
1993 with TGUIListBox(menu.GetControl('lsResolution')) do
1994 begin
1995 list := sys_GetDisplayModes(gBPP);
1996 if list <> nil then
1997 begin
1998 Items := list;
1999 ItemIndex := -1; (* nothing selected *)
2000 end
2001 else
2002 begin
2003 Clear
2004 end
2005 end;
2007 with TGUISwitch(menu.GetControl('swFullScreen')) do
2008 if gFullscreen then
2009 ItemIndex := 0
2010 else
2011 ItemIndex := 1;
2013 TempResScale := Round(r_pixel_scale - 1);
2014 with TGUISwitch(menu.GetControl('swResFactor')) do
2015 ItemIndex := Max(Min(TempResScale, gRC_Width div 640 - 1), 0);
2016 end;
2018 procedure ProcApplyVideoOptions();
2019 var
2020 menu: TGUIMenu;
2021 Fullscreen: Boolean;
2022 SWidth, SHeight: Integer;
2023 ScaleChanged: Boolean;
2024 str: String;
2025 begin
2026 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
2028 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
2029 if str <> '' then
2030 SScanf(str, '%dx%d', [@SWidth, @SHeight])
2031 else
2032 begin
2033 SWidth := gWinSizeX;
2034 SHeight := gWinSizeY;
2035 TempResScale := Min(TempResScale, SWidth div 640 - 1);
2036 end;
2038 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
2040 ScaleChanged := False;
2041 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
2042 begin
2043 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
2044 r_pixel_scale := TempResScale + 1;
2045 ScaleChanged := True;
2046 end;
2048 if (SWidth <> gWinSizeX) or
2049 (SHeight <> gWinSizeY) or
2050 (Fullscreen <> gFullscreen) or
2051 ScaleChanged then
2052 begin
2053 gResolutionChange := True;
2054 gRC_Width := SWidth;
2055 gRC_Height := SHeight;
2056 gRC_FullScreen := Fullscreen;
2057 gRC_Maximized := gWinMaximized;
2058 end;
2060 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
2061 ProcApplyOptions();
2062 end;
2064 procedure ProcSetFirstRussianLanguage;
2065 begin
2066 gLanguage := LANGUAGE_RUSSIAN;
2067 gLanguageChange := True;
2068 gAskLanguage := False;
2069 end;
2071 procedure ProcSetFirstEnglishLanguage;
2072 begin
2073 gLanguage := LANGUAGE_ENGLISH;
2074 gLanguageChange := True;
2075 gAskLanguage := False;
2076 end;
2078 procedure ProcRecallAddress();
2079 begin
2080 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
2081 begin
2082 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
2083 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
2084 end;
2085 end;
2087 procedure CreateFirstLanguageMenu();
2088 var
2089 Menu: TGUIWindow;
2090 begin
2091 Menu := TGUIWindow.Create('FirstLanguageMenu');
2093 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
2094 begin
2095 Name := 'mmFirstLanguageMenu';
2096 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
2097 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
2098 end;
2100 Menu.DefControl := 'mmFirstLanguageMenu';
2101 Menu.MainWindow := True;
2102 g_GUI_AddWindow(Menu);
2103 end;
2105 procedure g_Menu_AskLanguage();
2106 begin
2107 CreateFirstLanguageMenu();
2108 g_GUI_ShowWindow('FirstLanguageMenu');
2109 end;
2111 procedure CreatePlayerOptionsMenu(s: String);
2112 var
2113 Menu: TGUIWindow;
2114 a: String;
2115 begin
2116 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2117 if s = 'P1' then
2118 a := _lc[I_MENU_PLAYER_1]
2119 else
2120 a := _lc[I_MENU_PLAYER_2];
2121 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
2122 begin
2123 Name := 'mOptionsPlayers'+s+'Menu';
2124 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2125 begin
2126 Name := 'ed'+s+'Name';
2127 MaxLength := 12;
2128 Width := 12;
2129 end;
2130 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2131 begin
2132 Name := 'sw'+s+'Team';
2133 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2134 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2135 end ;
2136 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2137 begin
2138 Name := 'ls'+s+'Model';
2139 Sort := True;
2140 Items := g_PlayerModel_GetNames();
2141 OnChange := ProcSelectModel;
2142 end;
2143 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2144 begin
2145 Name := 'sc'+s+'Red';
2146 Max := 16;
2147 OnChange := ProcChangeColor;
2148 end;
2149 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2150 begin
2151 Name := 'sc'+s+'Green';
2152 Max := 16;
2153 OnChange := ProcChangeColor;
2154 end;
2155 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2156 begin
2157 Name := 'sc'+s+'Blue';
2158 Max := 16;
2159 OnChange := ProcChangeColor;
2160 end;
2161 AddSpace();
2162 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2163 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2164 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2165 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2166 if s = 'P1' then AddButton(@ProcOptionsPlayerP1WeaponMenu, _lc[I_MENU_WEAPON])
2167 else AddButton(@ProcOptionsPlayerP2WeaponMenu, _lc[I_MENU_WEAPON]);
2168 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2169 begin
2170 Name := 'mv'+s+'Model';
2171 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2172 Y := GetControl('ls'+s+'Model').Y;
2173 end;
2174 end;
2175 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2176 g_GUI_AddWindow(Menu);
2177 end;
2179 procedure CreateAllMenus();
2180 var
2181 Menu: TGUIWindow;
2182 //SR: TSearchRec;
2183 a, cx, _y, i: Integer;
2184 //list: SSArray;
2185 begin
2186 Menu := TGUIWindow.Create('MainMenu');
2187 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2188 begin
2189 Name := 'mmMainMenu';
2190 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2191 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2192 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2193 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2194 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2195 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2196 end;
2197 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2198 begin
2199 Color := _RGB(255, 255, 255);
2200 X := gScreenWidth-GetWidth-8;
2201 Y := gScreenHeight-GetHeight-8;
2202 end;
2203 Menu.DefControl := 'mmMainMenu';
2204 Menu.MainWindow := True;
2205 g_GUI_AddWindow(Menu);
2207 Menu := TGUIWindow.Create('NewGameMenu');
2208 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2209 begin
2210 Name := 'mmNewGameMenu';
2211 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2212 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2213 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2214 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2215 end;
2216 Menu.DefControl := 'mmNewGameMenu';
2217 g_GUI_AddWindow(Menu);
2219 Menu := TGUIWindow.Create('NetGameMenu');
2220 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2221 begin
2222 Name := 'mmNetGameMenu';
2223 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2224 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2225 end;
2226 Menu.DefControl := 'mmNetGameMenu';
2227 g_GUI_AddWindow(Menu);
2229 Menu := TGUIWindow.Create('NetServerMenu');
2230 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2231 begin
2232 Name := 'mNetServerMenu';
2233 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2234 begin
2235 Name := 'edSrvName';
2236 OnlyDigits := False;
2237 Width := 16;
2238 MaxLength := 64;
2239 Text := NetServerName;
2240 end;
2241 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2242 begin
2243 Name := 'edSrvPassword';
2244 OnlyDigits := False;
2245 Width := 16;
2246 MaxLength := 24;
2247 Text := NetPassword;
2248 end;
2249 with AddEdit(_lc[I_NET_PORT]) do
2250 begin
2251 Name := 'edPort';
2252 OnlyDigits := True;
2253 Width := 4;
2254 MaxLength := 5;
2255 Text := IntToStr(NetPort);
2256 end;
2257 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2258 begin
2259 Name := 'edMaxPlayers';
2260 OnlyDigits := True;
2261 Width := 4;
2262 MaxLength := 2;
2263 Text := IntToStr(NetMaxClients);
2264 end;
2265 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2266 begin
2267 Name := 'swUseMaster';
2268 AddItem(_lc[I_MENU_YES]);
2269 AddItem(_lc[I_MENU_NO]);
2270 if NetUseMaster then
2271 ItemIndex := 0
2272 else
2273 ItemIndex := 1;
2274 end;
2275 AddSpace();
2276 with AddLabel(_lc[I_MENU_MAP]) do
2277 begin
2278 Name := 'lbMap';
2279 FixedLength := 16;
2280 Text := gsMap;
2281 OnClick := @ProcSelectMapMenu;
2282 end;
2283 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2284 begin
2285 Name := 'swGameMode';
2286 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2287 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2288 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2289 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2290 case g_Game_TextToMode(gsGameMode) of
2291 GM_NONE,
2292 GM_DM: ItemIndex := 0;
2293 GM_TDM: ItemIndex := 1;
2294 GM_CTF: ItemIndex := 2;
2295 GM_SINGLE,
2296 GM_COOP: ItemIndex := 3;
2297 end;
2298 OnChange := ProcSwitchMonstersCustom;
2299 end;
2300 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2301 begin
2302 Name := 'edTimeLimit';
2303 OnlyDigits := True;
2304 Width := 4;
2305 MaxLength := 5;
2306 if gsTimeLimit > 0 then
2307 Text := IntToStr(gsTimeLimit);
2308 end;
2309 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2310 begin
2311 Name := 'edScoreLimit';
2312 OnlyDigits := True;
2313 Width := 4;
2314 MaxLength := 5;
2315 if gsScoreLimit > 0 then
2316 Text := IntToStr(gsScoreLimit);
2317 end;
2318 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2319 begin
2320 Name := 'edMaxLives';
2321 OnlyDigits := True;
2322 Width := 4;
2323 MaxLength := 5;
2324 if gsMaxLives > 0 then
2325 Text := IntToStr(gsMaxLives);
2326 end;
2327 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2328 begin
2329 Name := 'edItemRespawnTime';
2330 OnlyDigits := True;
2331 Width := 4;
2332 MaxLength := 5;
2333 if gsItemRespawnTime > 0 then
2334 Text := IntToStr(gsItemRespawnTime);
2335 end;
2336 AddSpace(); // Rulez Respawn block
2337 with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_TIME]) do
2338 begin
2339 Name := 'edRulezRespawnTime';
2340 OnlyDigits := True;
2341 Width := 4;
2342 MaxLength := 5;
2343 if gsRulezRespawnTime > 0 then
2344 Text := IntToStr(gsRulezRespawnTime);
2345 end;
2346 with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_RANDOM]) do
2347 begin
2348 Name := 'edRulezRespawnRandom';
2349 OnlyDigits := True;
2350 Width := 4;
2351 MaxLength := 5;
2352 if gsRulezRespawnRandom > 0 then
2353 Text := IntToStr(gsRulezRespawnRandom);
2354 end;
2355 with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do
2356 begin
2357 Name := 'swRulezRandom';
2358 AddItem(_lc[I_MENU_YES]);
2359 AddItem(_lc[I_MENU_NO]);
2360 if LongBool(gsGameFlags and GAME_OPTION_RULEZRANDOM) then
2361 ItemIndex := 0
2362 else
2363 ItemIndex := 1;
2364 end;
2365 AddSpace();
2366 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2367 begin
2368 Name := 'swPlayers';
2369 AddItem(_lc[I_MENU_COUNT_NONE]);
2370 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2371 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2372 ItemIndex := gsPlayers;
2373 end;
2374 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2375 begin
2376 Name := 'swTeamDamage';
2377 AddItem(_lc[I_MENU_YES]);
2378 AddItem(_lc[I_MENU_NO]);
2379 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2380 ItemIndex := 0
2381 else
2382 ItemIndex := 1;
2383 end;
2384 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2385 begin
2386 Name := 'swTeamHit';
2387 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2388 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2389 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2390 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2391 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2392 ItemIndex := 0
2393 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2394 ItemIndex := 1
2395 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2396 ItemIndex := 2
2397 else
2398 ItemIndex := 3;
2399 end;
2400 with AddSwitch(_lc[I_MENU_ENABLE_TEAM_DAMAGE_ABSOBR]) do
2401 begin
2402 Name := 'swTeamAbsorbDamage';
2403 AddItem(_lc[I_MENU_YES]);
2404 AddItem(_lc[I_MENU_NO]);
2405 if LongBool(gsGameFlags and GAME_OPTION_TEAMABSORBDAMAGE) then
2406 ItemIndex := 0
2407 else
2408 ItemIndex := 1;
2409 end;
2410 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2411 begin
2412 Name := 'swDeathmatchKeys';
2413 AddItem(_lc[I_MENU_YES]);
2414 AddItem(_lc[I_MENU_NO]);
2415 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2416 ItemIndex := 0
2417 else
2418 ItemIndex := 1;
2419 end;
2420 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2421 begin
2422 Name := 'swEnableExits';
2423 AddItem(_lc[I_MENU_YES]);
2424 AddItem(_lc[I_MENU_NO]);
2425 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2426 ItemIndex := 0
2427 else
2428 ItemIndex := 1;
2429 end;
2430 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2431 begin
2432 Name := 'swWeaponStay';
2433 AddItem(_lc[I_MENU_YES]);
2434 AddItem(_lc[I_MENU_NO]);
2435 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2436 ItemIndex := 0
2437 else
2438 ItemIndex := 1;
2439 end;
2440 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2441 begin
2442 Name := 'swMonsters';
2443 AddItem(_lc[I_MENU_YES]);
2444 AddItem(_lc[I_MENU_NO]);
2445 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2446 ItemIndex := 0
2447 else
2448 ItemIndex := 1;
2449 end;
2450 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2451 begin
2452 Name := 'swBotsVS';
2453 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2454 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2455 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2456 ItemIndex := 2;
2457 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2458 ItemIndex := 0;
2459 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2460 ItemIndex := 1;
2461 end;
2462 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2463 begin
2464 Name := 'swFlagDrop';
2465 AddItem(_lc[I_MENU_FLAG_THROW]);
2466 AddItem(_lc[I_MENU_YES]);
2467 AddItem(_lc[I_MENU_NO]);
2468 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2469 ItemIndex := 0
2470 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2471 ItemIndex := 1
2472 else
2473 ItemIndex := 2;
2474 end;
2475 AddSpace();
2476 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2478 ReAlign();
2479 end;
2480 Menu.DefControl := 'mNetServerMenu';
2481 g_GUI_AddWindow(Menu);
2483 Menu := TGUIWindow.Create('NetClientMenu');
2484 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2485 begin
2486 Name := 'mNetClientMenu';
2488 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2489 AddSpace();
2491 with AddEdit(_lc[I_NET_ADDRESS]) do
2492 begin
2493 Name := 'edIP';
2494 OnlyDigits :=False;
2495 Width := 12;
2496 MaxLength := 64;
2497 Text := 'localhost';
2498 end;
2499 with AddEdit(_lc[I_NET_PORT]) do
2500 begin
2501 Name := 'edPort';
2502 OnlyDigits := True;
2503 Width := 4;
2504 MaxLength := 5;
2505 Text := '25666';
2506 end;
2507 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2508 begin
2509 Name := 'edPW';
2510 OnlyDigits := False;
2511 Width := 12;
2512 MaxLength := 32;
2513 Text := '';
2514 end;
2516 AddSpace();
2517 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2519 ReAlign();
2520 end;
2521 Menu.DefControl := 'mNetClientMenu';
2522 g_GUI_AddWindow(Menu);
2524 Menu := TGUIWindow.Create('LoadMenu');
2525 Menu.OnShow := ProcLoadMenu;
2526 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2527 begin
2528 Name := 'mmLoadMenu';
2530 for a := 1 to 8 do
2531 with AddEdit('') do
2532 begin
2533 Name := 'edSlot'+IntToStr(a);
2534 Width := 16;
2535 MaxLength := 16;
2536 OnEnter := ProcLoadGame;
2537 end;
2538 end;
2539 Menu.DefControl := 'mmLoadMenu';
2540 g_GUI_AddWindow(Menu);
2542 Menu := TGUIWindow.Create('SaveMenu');
2543 Menu.OnShow := ProcSaveMenu;
2544 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2545 begin
2546 Name := 'mmSaveMenu';
2548 for a := 1 to 8 do
2549 with AddEdit('') do
2550 begin
2551 Name := 'edSlot'+IntToStr(a);
2552 Width := 16;
2553 MaxLength := 16;
2554 OnChange := ProcSaveGame;
2555 end;
2556 end;
2557 Menu.DefControl := 'mmSaveMenu';
2558 g_GUI_AddWindow(Menu);
2560 Menu := TGUIWindow.Create('CustomGameMenu');
2561 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2562 begin
2563 Name := 'mCustomGameMenu';
2564 with AddLabel(_lc[I_MENU_MAP]) do
2565 begin
2566 Name := 'lbMap';
2567 FixedLength := 16;
2568 Text := gsMap;
2569 OnClick := @ProcSelectMapMenu;
2570 end;
2571 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2572 begin
2573 Name := 'swGameMode';
2574 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2575 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2576 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2577 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2578 case g_Game_TextToMode(gsGameMode) of
2579 GM_NONE,
2580 GM_DM: ItemIndex := 0;
2581 GM_TDM: ItemIndex := 1;
2582 GM_CTF: ItemIndex := 2;
2583 GM_SINGLE,
2584 GM_COOP: ItemIndex := 3;
2585 end;
2586 OnChange := ProcSwitchMonstersCustom;
2587 end;
2588 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2589 begin
2590 Name := 'edTimeLimit';
2591 OnlyDigits := True;
2592 Width := 4;
2593 MaxLength := 5;
2594 if gsTimeLimit > 0 then
2595 Text := IntToStr(gsTimeLimit);
2596 end;
2597 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2598 begin
2599 Name := 'edScoreLimit';
2600 OnlyDigits := True;
2601 Width := 4;
2602 MaxLength := 5;
2603 if gsScoreLimit > 0 then
2604 Text := IntToStr(gsScoreLimit);
2605 end;
2606 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2607 begin
2608 Name := 'edMaxLives';
2609 OnlyDigits := True;
2610 Width := 4;
2611 MaxLength := 5;
2612 if gsMaxLives > 0 then
2613 Text := IntToStr(gsMaxLives);
2614 end;
2615 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2616 begin
2617 Name := 'edItemRespawnTime';
2618 OnlyDigits := True;
2619 Width := 4;
2620 MaxLength := 5;
2621 if gsItemRespawnTime > 0 then
2622 Text := IntToStr(gsItemRespawnTime);
2623 end;
2624 AddSpace(); // Rulez Respawn block
2625 with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_TIME]) do
2626 begin
2627 Name := 'edRulezRespawnTime';
2628 OnlyDigits := True;
2629 Width := 4;
2630 MaxLength := 5;
2631 if gsRulezRespawnTime > 0 then
2632 Text := IntToStr(gsRulezRespawnTime);
2633 end;
2634 with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_RANDOM]) do
2635 begin
2636 Name := 'edRulezRespawnRandom';
2637 OnlyDigits := True;
2638 Width := 4;
2639 MaxLength := 5;
2640 if gsRulezRespawnRandom > 0 then
2641 Text := IntToStr(gsRulezRespawnRandom);
2642 end;
2643 with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do
2644 begin
2645 Name := 'swRulezRandom';
2646 AddItem(_lc[I_MENU_YES]);
2647 AddItem(_lc[I_MENU_NO]);
2648 if LongBool(gsGameFlags and GAME_OPTION_RULEZRANDOM) then
2649 ItemIndex := 0
2650 else
2651 ItemIndex := 1;
2652 end;
2653 AddSpace();
2654 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2655 begin
2656 Name := 'swPlayers';
2657 AddItem(_lc[I_MENU_COUNT_NONE]);
2658 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2659 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2660 ItemIndex := gsPlayers;
2661 end;
2662 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2663 begin
2664 Name := 'swTeamDamage';
2665 AddItem(_lc[I_MENU_YES]);
2666 AddItem(_lc[I_MENU_NO]);
2667 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2668 ItemIndex := 0
2669 else
2670 ItemIndex := 1;
2671 end;
2672 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2673 begin
2674 Name := 'swTeamHit';
2675 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2676 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2677 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2678 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2679 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2680 ItemIndex := 0
2681 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2682 ItemIndex := 1
2683 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2684 ItemIndex := 2
2685 else
2686 ItemIndex := 3;
2687 end;
2688 with AddSwitch(_lc[I_MENU_ENABLE_TEAM_DAMAGE_ABSOBR]) do
2689 begin
2690 Name := 'swTeamAbsorbDamage';
2691 AddItem(_lc[I_MENU_YES]);
2692 AddItem(_lc[I_MENU_NO]);
2693 if LongBool(gsGameFlags and GAME_OPTION_TEAMABSORBDAMAGE) then
2694 ItemIndex := 0
2695 else
2696 ItemIndex := 1;
2697 end;
2698 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2699 begin
2700 Name := 'swDeathmatchKeys';
2701 AddItem(_lc[I_MENU_YES]);
2702 AddItem(_lc[I_MENU_NO]);
2703 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2704 ItemIndex := 0
2705 else
2706 ItemIndex := 1;
2707 end;
2708 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2709 begin
2710 Name := 'swEnableExits';
2711 AddItem(_lc[I_MENU_YES]);
2712 AddItem(_lc[I_MENU_NO]);
2713 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2714 ItemIndex := 0
2715 else
2716 ItemIndex := 1;
2717 end;
2718 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2719 begin
2720 Name := 'swWeaponStay';
2721 AddItem(_lc[I_MENU_YES]);
2722 AddItem(_lc[I_MENU_NO]);
2723 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2724 ItemIndex := 0
2725 else
2726 ItemIndex := 1;
2727 end;
2728 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2729 begin
2730 Name := 'swMonsters';
2731 AddItem(_lc[I_MENU_YES]);
2732 AddItem(_lc[I_MENU_NO]);
2733 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2734 ItemIndex := 0
2735 else
2736 ItemIndex := 1;
2737 end;
2738 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2739 begin
2740 Name := 'swBotsVS';
2741 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2742 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2743 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2744 ItemIndex := 2;
2745 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2746 ItemIndex := 0;
2747 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2748 ItemIndex := 1;
2749 end;
2750 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2751 begin
2752 Name := 'swFlagDrop';
2753 AddItem(_lc[I_MENU_FLAG_THROW]);
2754 AddItem(_lc[I_MENU_YES]);
2755 AddItem(_lc[I_MENU_NO]);
2756 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2757 ItemIndex := 0
2758 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2759 ItemIndex := 1
2760 else
2761 ItemIndex := 2;
2762 end;
2763 AddSpace();
2764 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2766 ReAlign();
2767 end;
2768 Menu.DefControl := 'mCustomGameMenu';
2769 g_GUI_AddWindow(Menu);
2771 Menu := TGUIWindow.Create('CampaignMenu');
2772 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2773 begin
2774 Name := 'mCampaignMenu';
2776 AddSpace();
2777 AddSpace();
2778 AddSpace();
2779 AddSpace();
2780 AddSpace();
2781 AddSpace();
2783 with AddFileList('', 15, 4) do
2784 begin
2785 Name := 'lsWAD';
2786 OnChange := ProcSelectCampaignWAD;
2788 Sort := True;
2789 Dirs := True;
2790 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2791 SetBase(MegawadDirs);
2792 end;
2794 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2795 begin
2796 Name := 'lbWADName';
2797 FixedLength := 8;
2798 Enabled := False;
2799 end;
2800 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2801 begin
2802 Name := 'lbWADAuthor';
2803 FixedLength := 8;
2804 Enabled := False;
2805 end;
2806 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2807 with AddMemo('', 15, 3) do
2808 begin
2809 Name := 'meWADDescription';
2810 Color := MENU_ITEMSCTRL_COLOR;
2811 end;
2812 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2813 begin
2814 Name := 'swPlayers';
2815 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2816 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2817 end;
2818 AddSpace();
2819 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2821 ReAlign();
2823 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2824 begin
2825 Name := 'mpWADImage';
2826 DefaultRes := 'NOPIC';
2827 X := GetControl('lsWAD').X+4;
2828 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2829 end;
2830 end;
2831 Menu.DefControl := 'mCampaignMenu';
2832 g_GUI_AddWindow(Menu);
2834 Menu := TGUIWindow.Create('SelectMapMenu');
2835 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2836 begin
2837 Name := 'mSelectMapMenu';
2838 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2839 begin
2840 Name := 'lsMapWAD';
2841 OnChange := ProcSelectWAD;
2843 Sort := True;
2844 Dirs := True;
2845 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2846 SetBase(MapDirs);
2847 end;
2848 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2849 begin
2850 Name := 'lsMapRes';
2851 Sort := True;
2852 OnChange := ProcSelectMap;
2853 end;
2854 AddSpace();
2855 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2856 begin
2857 Name := 'lbMapName';
2858 FixedLength := 24;
2859 Enabled := False;
2860 end;
2861 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2862 begin
2863 Name := 'lbMapAuthor';
2864 FixedLength := 16;
2865 Enabled := False;
2866 end;
2867 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2868 begin
2869 Name := 'lbMapSize';
2870 FixedLength := 10;
2871 Enabled := False;
2872 end;
2873 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 20, 4) do
2874 begin
2875 Name := 'meMapDescription';
2876 end;
2878 ReAlign();
2880 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2881 begin
2882 Name := 'mpMapPreview';
2883 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2884 Y := GetControl('lsMapWAD').Y;
2885 end;
2886 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2887 begin
2888 Name := 'lbMapScale';
2889 FixedLength := 8;
2890 Enabled := False;
2891 Color := MENU_ITEMSCTRL_COLOR;
2892 X := GetControl('lsMapWAD').X +
2893 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2894 2 + MAPPREVIEW_WIDTH*4;
2895 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2896 end;
2897 end;
2898 Menu.OnClose := ProcSetMap;
2899 Menu.DefControl := 'mSelectMapMenu';
2900 g_GUI_AddWindow(Menu);
2902 Menu := TGUIWindow.Create('OptionsMenu');
2903 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2904 begin
2905 Name := 'mmOptionsMenu';
2906 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2907 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2908 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2909 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2910 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2911 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2912 AddSpace();
2913 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2914 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2915 end;
2916 Menu.OnClose := ProcApplyOptions;
2917 Menu.DefControl := 'mmOptionsMenu';
2918 g_GUI_AddWindow(Menu);
2920 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2921 gMenuSmallFont, @ProcSavedMenuKeyDown);
2922 g_GUI_AddWindow(Menu);
2924 Menu := TGUIWindow.Create('OptionsVideoMenu');
2925 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2926 begin
2927 Name := 'mOptionsVideoMenu';
2928 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2929 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2930 begin
2931 Name := 'swBPP';
2932 AddItem('16');
2933 AddItem('32');
2934 end;
2935 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2936 begin
2937 Name := 'swVSync';
2938 AddItem(_lc[I_MENU_YES]);
2939 AddItem(_lc[I_MENU_NO]);
2940 end;
2941 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2942 begin
2943 Name := 'swTextureFilter';
2944 AddItem(_lc[I_MENU_YES]);
2945 AddItem(_lc[I_MENU_NO]);
2946 end;
2947 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2948 begin
2949 Name := 'swInterp';
2950 AddItem(_lc[I_MENU_YES]);
2951 AddItem(_lc[I_MENU_NO]);
2952 end;
2953 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2954 begin
2955 Name := 'swLegacyNPOT';
2956 AddItem(_lc[I_MENU_NO]);
2957 AddItem(_lc[I_MENU_YES]);
2958 end;
2959 AddSpace();
2960 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2961 ReAlign();
2962 end;
2963 Menu.DefControl := 'mOptionsVideoMenu';
2964 g_GUI_AddWindow(Menu);
2966 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2967 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2968 begin
2969 Name := 'mOptionsVideoResMenu';
2970 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2971 begin
2972 Name := 'lbCurrentRes';
2973 FixedLength := 24;
2974 Enabled := False;
2975 end;
2976 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2977 begin
2978 Name := 'lsResolution';
2979 Sort := False;
2980 end;
2981 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2982 begin
2983 Name := 'swFullScreen';
2984 AddItem(_lc[I_MENU_YES]);
2985 AddItem(_lc[I_MENU_NO]);
2986 end;
2987 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2988 begin
2989 Name := 'swResFactor';
2990 AddItem('1x');
2991 for i := 2 to gRC_Width div 640 do
2992 AddItem(IntToStr(i) + 'x');
2993 end;
2994 AddSpace();
2995 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2996 UpdateIndex();
2997 end;
2998 Menu.DefControl := 'mOptionsVideoResMenu';
2999 g_GUI_AddWindow(Menu);
3001 Menu := TGUIWindow.Create('OptionsSoundMenu');
3002 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
3003 begin
3004 Name := 'mOptionsSoundMenu';
3005 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
3006 begin
3007 Name := 'scMusicLevel';
3008 Max := 16;
3009 OnChange := ProcChangeSoundSettings;
3010 end;
3011 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
3012 begin
3013 Name := 'scSoundLevel';
3014 Max := 16;
3015 OnChange := ProcChangeSoundSettings;
3016 end;
3017 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
3018 begin
3019 Name := 'scMaxSimSounds';
3020 Max := 16;
3021 end;
3022 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
3023 begin;
3024 Name := 'swAnnouncer';
3025 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
3026 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
3027 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
3028 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
3029 end;
3030 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
3031 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
3032 begin;
3033 Name := 'swSoundEffects';
3034 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
3035 AddItem(_lc[I_MENU_COMPAT_DF]);
3036 end;
3037 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
3038 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
3039 begin;
3040 Name := 'swChatSpeech';
3041 AddItem(_lc[I_MENU_YES]);
3042 AddItem(_lc[I_MENU_NO]);
3043 end;
3044 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
3045 begin
3046 Name := 'swInactiveSounds';
3047 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
3048 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
3049 end;
3050 ReAlign();
3051 end;
3052 Menu.DefControl := 'mOptionsSoundMenu';
3053 g_GUI_AddWindow(Menu);
3055 Menu := TGUIWindow.Create('OptionsGameMenu');
3056 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
3057 begin
3058 Name := 'mOptionsGameMenu';
3059 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
3060 begin
3061 Name := 'scParticlesCount';
3062 Max := 20;
3063 end;
3064 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
3065 begin
3066 Name := 'swBloodCount';
3067 AddItem(_lc[I_MENU_COUNT_NONE]);
3068 AddItem(_lc[I_MENU_COUNT_SMALL]);
3069 AddItem(_lc[I_MENU_COUNT_NORMAL]);
3070 AddItem(_lc[I_MENU_COUNT_BIG]);
3071 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
3072 end;
3073 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
3074 begin
3075 Name := 'scShellsMax';
3076 Max := 20;
3077 end;
3078 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
3079 begin
3080 Name := 'scGibsMax';
3081 Max := 20;
3082 end;
3083 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
3084 begin
3085 Name := 'scCorpsesMax';
3086 Max := 20;
3087 end;
3088 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
3089 begin
3090 Name := 'swGibsCount';
3091 AddItem(_lc[I_MENU_COUNT_NONE]);
3092 AddItem(_lc[I_MENU_COUNT_SMALL]);
3093 AddItem(_lc[I_MENU_COUNT_NORMAL]);
3094 AddItem(_lc[I_MENU_COUNT_BIG]);
3095 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
3096 end;
3097 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
3098 begin
3099 Name := 'swCorpseType';
3100 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
3101 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
3102 end;
3103 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
3104 begin
3105 Name := 'swGibsType';
3106 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
3107 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
3108 end;
3109 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
3110 begin
3111 Name := 'swBloodType';
3112 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
3113 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
3114 end;
3115 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
3116 begin
3117 Name := 'swScreenFlash';
3118 AddItem(_lc[I_MENU_NO]);
3119 AddItem(_lc[I_MENU_COMPAT_DF]);
3120 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
3121 end;
3122 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
3123 begin
3124 Name := 'swBackground';
3125 AddItem(_lc[I_MENU_YES]);
3126 AddItem(_lc[I_MENU_NO]);
3127 end;
3128 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
3129 begin
3130 Name := 'swMessages';
3131 AddItem(_lc[I_MENU_YES]);
3132 AddItem(_lc[I_MENU_NO]);
3133 end;
3134 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
3135 begin
3136 Name := 'swRevertPlayers';
3137 AddItem(_lc[I_MENU_YES]);
3138 AddItem(_lc[I_MENU_NO]);
3139 end;
3140 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
3141 begin
3142 Name := 'swChatBubble';
3143 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
3144 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
3145 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
3146 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
3147 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
3148 end;
3149 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
3150 begin
3151 Name := 'swPlayerIndicator';
3152 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
3153 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
3154 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
3155 end;
3156 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
3157 begin
3158 Name := 'swPlayerIndicatorStyle';
3159 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
3160 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
3161 end;
3162 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
3163 begin
3164 Name := 'scScaleFactor';
3165 Max := 10;
3166 OnChange := ProcChangeGameSettings;
3167 end;
3168 ReAlign();
3169 end;
3170 Menu.DefControl := 'mOptionsGameMenu';
3171 g_GUI_AddWindow(Menu);
3173 Menu := TGUIWindow.Create('OptionsControlsMenu');
3174 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
3175 begin
3176 Name := 'mOptionsControlsMenu';
3177 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
3178 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
3179 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
3180 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
3181 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
3182 AddSpace();
3183 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
3184 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
3185 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
3186 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
3187 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
3188 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
3189 if e_HasJoysticks then
3190 begin
3191 AddSpace();
3192 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
3193 end;
3194 if g_touch_enabled then
3195 begin
3196 AddSpace();
3197 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
3198 end;
3199 end;
3200 Menu.DefControl := 'mOptionsControlsMenu';
3201 g_GUI_AddWindow(Menu);
3203 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
3204 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
3205 begin
3206 Name := 'mOptionsControlsP1Menu';
3207 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3208 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3209 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3210 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3211 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3212 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3213 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3214 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3215 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3216 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3217 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3218 end;
3219 Menu.DefControl := 'mOptionsControlsP1Menu';
3220 g_GUI_AddWindow(Menu);
3222 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
3223 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
3224 begin
3225 Name := 'mOptionsControlsP1MenuWeapons';
3226 for i := WP_FIRST to WP_LAST do
3227 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3228 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3229 end;
3230 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
3231 g_GUI_AddWindow(Menu);
3233 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
3234 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
3235 begin
3236 Name := 'mOptionsControlsP2Menu';
3237 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3238 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3239 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3240 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3241 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3242 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3243 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3244 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3245 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3246 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3247 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3248 end;
3249 Menu.DefControl := 'mOptionsControlsP2Menu';
3250 g_GUI_AddWindow(Menu);
3252 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3253 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3254 begin
3255 Name := 'mOptionsControlsP2MenuWeapons';
3256 for i := WP_FIRST to WP_LAST do
3257 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3258 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3259 end;
3260 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3261 g_GUI_AddWindow(Menu);
3263 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3264 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3265 begin
3266 Name := 'mOptionsControlsJoystickMenu';
3267 for i := 0 to e_MaxJoys - 1 do
3268 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3269 begin
3270 Name := 'scDeadzone' + IntToStr(i);
3271 Max := 20
3272 end
3273 end;
3274 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3275 g_GUI_AddWindow(Menu);
3277 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3278 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
3279 begin
3280 Name := 'mOptionsControlsTouchMenu';
3281 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3282 begin
3283 Name := 'swTouchAlt';
3284 AddItem(_lc[I_MENU_NO]);
3285 AddItem(_lc[I_MENU_YES]);
3286 OnChange := ProcChangeTouchSettings;
3287 end;
3288 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3289 begin
3290 Name := 'scTouchSize';
3291 Max := 20;
3292 OnChange := ProcChangeTouchSettings;
3293 end;
3294 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3295 begin
3296 Name := 'swTouchFire';
3297 AddItem(_lc[I_MENU_NO]);
3298 AddItem(_lc[I_MENU_YES]);
3299 end;
3300 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3301 begin
3302 Name := 'scTouchOffset';
3303 Max := 20;
3304 OnChange := ProcChangeTouchSettings;
3305 end;
3306 end;
3307 Menu.DefControl := 'mOptionsControlsTouchMenu';
3308 g_GUI_AddWindow(Menu);
3310 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3311 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3312 begin
3313 Name := 'mOptionsPlayersMenu';
3314 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3315 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3316 end;
3317 Menu.DefControl := 'mOptionsPlayersMenu';
3318 g_GUI_AddWindow(Menu);
3320 CreatePlayerOptionsMenu('P1');
3321 CreatePlayerOptionsMenu('P2');
3323 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3324 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3325 begin
3326 Name := 'mOptionsPlayersMIMenu';
3327 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3328 begin
3329 Name := 'lbName';
3330 FixedLength := 16;
3331 end;
3332 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3333 begin
3334 Name := 'lbAuthor';
3335 FixedLength := 16;
3336 end;
3337 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3338 begin
3339 Name := 'meComment';
3340 end;
3341 AddSpace();
3342 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3343 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3344 begin
3345 Name := 'lbWeapon';
3346 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3347 end;
3348 ReAlign();
3349 end;
3350 Menu.DefControl := 'mOptionsPlayersMIMenu';
3351 g_GUI_AddWindow(Menu);
3353 Menu := TGUIWindow.Create('OptionsPlayersP1WeaponMenu');
3354 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3355 begin
3356 Name := 'mOptionsPlayersP1WeaponMenu';
3357 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3358 begin
3359 Name := 'swWeaponAutoswitch';
3360 AddItem(_lc[I_MENU_NO]);
3361 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3362 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3363 end;
3364 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3365 begin
3366 Name := 'swWeaponAllowEmpty';
3367 AddItem(_lc[I_MENU_YES]);
3368 AddItem(_lc[I_MENU_NO]);
3369 end;
3370 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3371 begin
3372 Name := 'swWeaponAllowFist';
3373 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3374 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3375 end;
3376 AddButton(@ProcOptionsPlayerP1WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3377 ReAlign();
3378 end;
3379 Menu.DefControl := 'mOptionsPlayersP1WeaponMenu';
3380 g_GUI_AddWindow(Menu);
3382 Menu := TGUIWindow.Create('OptionsPreferencesP1WeaponMenu');
3383 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_1]))) do
3384 begin
3385 Name := 'mOptionsPreferencesP1WeaponMenu';
3386 for i := WP_FIRST to WP_LAST do
3387 begin
3388 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3389 begin
3390 Name := IntToStr(i);
3391 for a := WP_FIRST to WP_LAST+1 do
3392 begin
3393 AddItem(IntToStr(a));
3394 end;
3395 ItemIndex := i
3396 end;
3397 end;
3398 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3399 begin
3400 Name := IntToStr(WP_LAST+1);
3401 for a := WP_FIRST to WP_LAST+1 do
3402 begin
3403 AddItem(IntToStr(a));
3404 end;
3405 ItemIndex := WP_LAST + 1;
3406 end;
3407 end;
3408 Menu.DefControl := 'mOptionsPreferencesP1WeaponMenu';
3409 g_GUI_AddWindow(Menu);
3412 Menu := TGUIWindow.Create('OptionsPlayersP2WeaponMenu');
3413 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3414 begin
3415 Name := 'mOptionsPlayersP2WeaponMenu';
3416 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3417 begin
3418 Name := 'swWeaponAutoswitch';
3419 AddItem(_lc[I_MENU_NO]);
3420 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3421 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3422 end;
3423 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3424 begin
3425 Name := 'swWeaponAllowEmpty';
3426 AddItem(_lc[I_MENU_YES]);
3427 AddItem(_lc[I_MENU_NO]);
3428 end;
3429 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3430 begin
3431 Name := 'swWeaponAllowFist';
3432 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3433 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3434 end;
3435 AddButton(@ProcOptionsPlayerP2WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3436 ReAlign();
3437 end;
3438 Menu.DefControl := 'mOptionsPlayersP2WeaponMenu';
3439 g_GUI_AddWindow(Menu);
3441 Menu := TGUIWindow.Create('OptionsPreferencesP2WeaponMenu');
3442 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_2]))) do
3443 begin
3444 Name := 'mOptionsPreferencesP2WeaponMenu';
3445 for i := WP_FIRST to WP_LAST do
3446 begin
3447 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3448 begin
3449 Name := IntToStr(i);
3450 for a := WP_FIRST to WP_LAST+1 do
3451 begin
3452 AddItem(IntToStr(a));
3453 end;
3454 ItemIndex := i
3455 end;
3456 end;
3457 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3458 begin
3459 Name := IntToStr(WP_LAST+1);
3460 for a := WP_FIRST to WP_LAST+1 do
3461 begin
3462 AddItem(IntToStr(a));
3463 end;
3464 ItemIndex := WP_LAST + 1;
3465 end;
3466 end;
3467 Menu.DefControl := 'mOptionsPreferencesP2WeaponMenu';
3468 g_GUI_AddWindow(Menu);
3470 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3471 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3472 begin
3473 Name := 'mOptionsLanguageMenu';
3474 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3475 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3476 ReAlign();
3477 end;
3478 Menu.DefControl := 'mOptionsLanguageMenu';
3479 g_GUI_AddWindow(Menu);
3481 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3482 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3483 g_GUI_AddWindow(Menu);
3485 Menu := TGUIWindow.Create('AuthorsMenu');
3486 Menu.BackTexture := 'INTER';
3487 Menu.OnClose := ProcAuthorsClose;
3489 // Çàãîëîâîê:
3490 _y := 16;
3491 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3492 begin
3493 Color := _RGB(255, 0, 0);
3494 X := (gScreenWidth div 2)-(GetWidth() div 2);
3495 Y := _y;
3496 _y := _y+GetHeight();
3497 end;
3498 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3499 begin
3500 Color := _RGB(255, 0, 0);
3501 X := (gScreenWidth div 2)-(GetWidth() div 2);
3502 Y := _y;
3503 _y := _y+GetHeight()+32;
3504 end;
3505 // ×òî äåëàë: Êòî äåëàë
3506 cx := gScreenWidth div 2 - 320 + 64;
3507 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3508 begin
3509 Color := _RGB(255, 0, 0);
3510 X := cx;
3511 Y := _y;
3512 _y := _y+22;
3513 end;
3514 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3515 begin
3516 Color := _RGB(255, 255, 255);
3517 X := cx+32;
3518 Y := _y;
3519 _y := _y+36;
3520 end;
3521 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3522 begin
3523 Color := _RGB(255, 0, 0);
3524 X := cx;
3525 Y := _y;
3526 _y := _y+22;
3527 end;
3528 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3529 begin
3530 Color := _RGB(255, 255, 255);
3531 X := cx+32;
3532 Y := _y;
3533 _y := _y+22;
3534 end;
3535 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3536 begin
3537 Color := _RGB(255, 255, 255);
3538 X := cx+32;
3539 Y := _y;
3540 _y := _y+36;
3541 end;
3542 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3543 begin
3544 Color := _RGB(255, 0, 0);
3545 X := cx;
3546 Y := _y;
3547 _y := _y+22;
3548 end;
3549 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3550 begin
3551 Color := _RGB(255, 255, 255);
3552 X := cx+32;
3553 Y := _y;
3554 _y := _y+36;
3555 end;
3556 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3557 begin
3558 Color := _RGB(255, 0, 0);
3559 X := cx;
3560 Y := _y;
3561 _y := _y+22;
3562 end;
3563 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3564 begin
3565 Color := _RGB(255, 255, 255);
3566 X := cx+32;
3567 Y := _y;
3568 _y := gScreenHeight - 128;
3569 end;
3570 // Çàêëþ÷åíèå:
3571 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3572 begin
3573 Color := _RGB(255, 0, 0);
3574 X := cx;
3575 Y := _y;
3576 _y := _y+16;
3577 end;
3578 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3579 begin
3580 Color := _RGB(255, 255, 255);
3581 X := cx+32;
3582 Y := _y;
3583 _y := _y+GetHeight();
3584 end;
3585 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3586 begin
3587 Color := _RGB(255, 255, 255);
3588 X := cx+32;
3589 Y := _y;
3590 _y := _y+GetHeight();
3591 end;
3592 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3593 begin
3594 Color := _RGB(255, 255, 255);
3595 X := cx+32;
3596 Y := _y;
3597 _y := gScreenHeight - 32;
3598 end;
3599 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3600 begin
3601 Color := _RGB(255, 0, 0);
3602 X := gScreenWidth div 2 - GetWidth() div 2;
3603 Y := _y;
3604 end;
3605 g_GUI_AddWindow(Menu);
3607 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3608 gMenuSmallFont, @ProcExitMenuKeyDown);
3609 g_GUI_AddWindow(Menu);
3611 Menu := TGUIWindow.Create('GameSingleMenu');
3612 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3613 begin
3614 Name := 'mmGameSingleMenu';
3615 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3616 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3617 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3618 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3619 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3620 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3621 end;
3622 Menu.DefControl := 'mmGameSingleMenu';
3623 Menu.MainWindow := True;
3624 Menu.OnClose := ProcGMClose;
3625 Menu.OnShow := ProcGMShow;
3626 g_GUI_AddWindow(Menu);
3628 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3629 gMenuSmallFont, @ProcEndMenuKeyDown);
3630 g_GUI_AddWindow(Menu);
3632 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3633 gMenuSmallFont, @ProcRestartMenuKeyDown);
3634 g_GUI_AddWindow(Menu);
3636 Menu := TGUIWindow.Create('GameCustomMenu');
3637 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3638 begin
3639 Name := 'mmGameCustomMenu';
3640 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3641 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3642 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3643 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3644 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3645 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3646 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3647 end;
3648 Menu.DefControl := 'mmGameCustomMenu';
3649 Menu.MainWindow := True;
3650 Menu.OnClose := ProcGMClose;
3651 Menu.OnShow := ProcGMShow;
3652 g_GUI_AddWindow(Menu);
3654 Menu := TGUIWindow.Create('GameServerMenu');
3655 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3656 begin
3657 Name := 'mmGameServerMenu';
3658 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3659 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3660 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3661 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3662 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3663 end;
3664 Menu.DefControl := 'mmGameServerMenu';
3665 Menu.MainWindow := True;
3666 Menu.OnClose := ProcGMClose;
3667 Menu.OnShow := ProcGMShow;
3668 g_GUI_AddWindow(Menu);
3670 Menu := TGUIWindow.Create('GameClientMenu');
3671 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3672 begin
3673 Name := 'mmGameClientMenu';
3674 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3675 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3676 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3677 end;
3678 Menu.DefControl := 'mmGameClientMenu';
3679 Menu.MainWindow := True;
3680 Menu.OnClose := ProcGMClose;
3681 Menu.OnShow := ProcGMShow;
3682 g_GUI_AddWindow(Menu);
3684 Menu := TGUIWindow.Create('ClientPasswordMenu');
3685 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3686 begin
3687 Name := 'mClientPasswordMenu';
3688 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3689 begin
3690 Name := 'edPW';
3691 Width := 12;
3692 MaxLength := 32;
3693 end;
3694 AddSpace;
3696 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3697 ReAlign();
3698 end;
3699 Menu.DefControl := 'mClientPasswordMenu';
3700 g_GUI_AddWindow(Menu);
3702 Menu := TGUIWindow.Create('GameSetGameMenu');
3703 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3704 begin
3705 Name := 'mGameSetGameMenu';
3706 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3707 begin
3708 Name := 'swTeamDamage';
3709 AddItem(_lc[I_MENU_YES]);
3710 AddItem(_lc[I_MENU_NO]);
3711 ItemIndex := 1;
3712 end;
3713 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3714 begin
3715 Name := 'swTeamHit';
3716 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3717 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3718 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3719 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3720 ItemIndex := 0
3721 end;
3722 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3723 begin
3724 Name := 'swDeathmatchKeys';
3725 AddItem(_lc[I_MENU_YES]);
3726 AddItem(_lc[I_MENU_NO]);
3727 ItemIndex := 1;
3728 end;
3729 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3730 begin
3731 Name := 'edTimeLimit';
3732 OnlyDigits := True;
3733 Width := 4;
3734 MaxLength := 5;
3735 end;
3736 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
3737 begin
3738 Name := 'edScoreLimit';
3739 OnlyDigits := True;
3740 Width := 4;
3741 MaxLength := 5;
3742 end;
3743 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3744 begin
3745 Name := 'edMaxLives';
3746 OnlyDigits := True;
3747 Width := 4;
3748 MaxLength := 5;
3749 end;
3750 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3751 begin
3752 Name := 'swBotsVS';
3753 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3754 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3755 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3756 ItemIndex := 2;
3757 end;
3758 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
3759 begin
3760 Name := 'swFlagDrop';
3761 AddItem(_lc[I_MENU_FLAG_THROW]);
3762 AddItem(_lc[I_MENU_YES]);
3763 AddItem(_lc[I_MENU_NO]);
3764 ItemIndex := 2;
3765 end;
3767 ReAlign();
3768 end;
3769 Menu.DefControl := 'mGameSetGameMenu';
3770 Menu.OnClose := ProcApplyGameSet;
3771 g_GUI_AddWindow(Menu);
3773 Menu := TGUIWindow.Create('TeamMenu');
3774 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3775 begin
3776 Name := 'mmTeamMenu';
3777 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3778 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3779 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3780 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3781 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3782 end;
3783 Menu.DefControl := 'mmTeamMenu';
3784 Menu.OnShow := ProcChangePlayers;
3785 g_GUI_AddWindow(Menu);
3786 end;
3788 procedure g_Menu_Show_SaveMenu();
3789 begin
3790 if g_Game_IsTestMap then
3791 Exit;
3792 if gGameSettings.GameType = GT_SINGLE then
3793 g_GUI_ShowWindow('GameSingleMenu')
3794 else
3795 begin
3796 if g_Game_IsClient then
3797 Exit
3798 else
3799 if g_Game_IsNet then
3800 Exit
3801 else
3802 g_GUI_ShowWindow('GameCustomMenu');
3803 end;
3804 g_GUI_ShowWindow('SaveMenu');
3805 g_Sound_PlayEx('MENU_OPEN');
3806 end;
3808 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3809 begin
3810 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3811 if gGameSettings.GameType = GT_SINGLE then
3812 begin
3813 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3814 end
3815 else
3816 begin
3817 if g_Game_IsClient then exit;
3818 if g_Game_IsNet then exit;
3819 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3820 end;
3821 g_GUI_ShowWindow('LoadMenu');
3822 g_Sound_PlayEx('MENU_OPEN');
3823 end;
3825 procedure g_Menu_Show_GameSetGame();
3826 begin
3827 if gGameSettings.GameType = GT_SINGLE then
3828 g_GUI_ShowWindow('GameSingleMenu')
3829 else
3830 begin
3831 if g_Game_IsClient then
3832 Exit
3833 else
3834 if g_Game_IsNet then
3835 g_GUI_ShowWindow('GameServerMenu')
3836 else
3837 g_GUI_ShowWindow('GameCustomMenu');
3838 end;
3839 ReadGameSettings();
3840 g_GUI_ShowWindow('GameSetGameMenu');
3841 g_Sound_PlayEx('MENU_OPEN');
3842 end;
3844 procedure g_Menu_Show_OptionsVideo();
3845 begin
3846 if gGameSettings.GameType = GT_SINGLE then
3847 g_GUI_ShowWindow('GameSingleMenu')
3848 else
3849 begin
3850 if g_Game_IsClient then
3851 g_GUI_ShowWindow('GameClientMenu')
3852 else
3853 if g_Game_IsNet then
3854 g_GUI_ShowWindow('GameServerMenu')
3855 else
3856 g_GUI_ShowWindow('GameCustomMenu');
3857 end;
3858 ReadOptions();
3859 g_GUI_ShowWindow('OptionsMenu');
3860 g_GUI_ShowWindow('OptionsVideoMenu');
3861 g_Sound_PlayEx('MENU_OPEN');
3862 end;
3864 procedure g_Menu_Show_OptionsSound();
3865 begin
3866 if gGameSettings.GameType = GT_SINGLE then
3867 g_GUI_ShowWindow('GameSingleMenu')
3868 else
3869 begin
3870 if g_Game_IsClient then
3871 g_GUI_ShowWindow('GameClientMenu')
3872 else
3873 if g_Game_IsNet then
3874 g_GUI_ShowWindow('GameServerMenu')
3875 else
3876 g_GUI_ShowWindow('GameCustomMenu');
3877 end;
3878 ReadOptions();
3879 g_GUI_ShowWindow('OptionsMenu');
3880 g_GUI_ShowWindow('OptionsSoundMenu');
3881 g_Sound_PlayEx('MENU_OPEN');
3882 end;
3884 procedure g_Menu_Show_EndGameMenu();
3885 begin
3886 g_GUI_ShowWindow('EndGameMenu');
3887 g_Sound_PlayEx('MENU_OPEN');
3888 end;
3890 procedure g_Menu_Show_QuitGameMenu();
3891 begin
3892 g_GUI_ShowWindow('ExitMenu');
3893 g_Sound_PlayEx('MENU_OPEN');
3894 end;
3896 procedure g_Menu_Init();
3897 begin
3898 MenuLoadData();
3899 g_GUI_Init();
3900 CreateAllMenus();
3901 end;
3903 procedure g_Menu_Free();
3904 begin
3905 g_GUI_Destroy();
3907 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3909 MenuFreeData();
3910 end;
3912 procedure g_Menu_Reset();
3913 var
3914 ex: Boolean;
3915 begin
3916 g_GUI_SaveMenuPos();
3917 ex := g_GUI_Destroy();
3919 if ex then
3920 begin
3921 e_WriteLog('Recreating menu...', TMsgType.Notify);
3923 CreateAllMenus();
3925 if gDebugMode then
3926 g_Game_SetDebugMode();
3928 g_GUI_LoadMenuPos();
3929 end;
3930 end;
3932 end.