DEADSOFTWARE

5cd389bf42ff5b970267fe35e77ca35e9cb9cac5
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$MODE DELPHI}
17 unit g_menu;
19 interface
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
25 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu();
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
36 var
37 gMenuFont: DWORD;
38 gMenuSmallFont: DWORD;
39 PromptIP: string;
40 PromptPort: Word;
42 implementation
44 uses
45 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
46 g_basic, g_console, g_sound, g_gfx, g_player, g_options,
47 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
48 MAPSTRUCT, wadreader, Math, g_saveload,
49 e_textures, GL, GLExt, g_language,
50 g_net, g_netmsg, g_netmaster, g_items, e_input;
53 type TYNCallback = procedure (yes:Boolean);
55 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
56 begin
57 if win.UserData = nil then exit;
58 case Key of
59 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
60 IK_N: TYNCallback(win.UserData)(false);
61 end;
62 end;
64 procedure YesButtonCB (ctl: TGUITextButton);
65 begin
66 if ctl.UserData = nil then exit;
67 TYNCallback(ctl.UserData)(true);
68 end;
70 procedure NoButtonCB (ctl: TGUITextButton);
71 begin
72 if ctl.UserData = nil then exit;
73 TYNCallback(ctl.UserData)(false);
74 end;
76 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
77 var
78 menu: TGUIMenu;
79 begin
80 //if length(Text) = 0 then exit;
81 Result := TGUIWindow.Create(WinName);
82 with Result do
83 begin
84 //OnKeyDownEx := @YNKeyDownProc;
85 //UserData := @ActionProc;
86 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
87 with menu do
88 begin
89 Name := '__temp_yes_no_menu:'+WinName;
90 YesNo := true;
91 AddText(Text, MaxLen);
92 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
93 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
94 end;
95 DefControl := '__temp_yes_no_menu:'+WinName;
96 SetActive(nil);
97 end;
98 end;
101 procedure ProcChangeColor(Sender: TGUIControl); forward;
102 procedure ProcSelectModel(Sender: TGUIControl); forward;
104 procedure ProcApplyOptions();
105 var
106 menu: TGUIMenu;
107 i: Integer;
108 begin
109 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
111 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
112 gBPP := 16
113 else
114 gBPP := 32;
115 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
116 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
117 glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
119 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
121 g_Sound_SetupAllVolumes(
122 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
123 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
124 );
126 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
127 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
128 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
129 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
131 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
133 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
134 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
135 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
136 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
138 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
139 0: gGibsCount := 0;
140 1: gGibsCount := 8;
141 2: gGibsCount := 16;
142 3: gGibsCount := 32;
143 else gGibsCount := 48;
144 end;
146 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
147 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
148 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
149 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
150 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
151 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
152 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
153 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
154 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
156 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
158 with menu, gGameControls.GameControls do
159 begin
160 TakeScreenshot := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key;
161 Stat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key;
162 Chat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key;
163 TeamChat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key;
164 end;
166 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
167 with menu, gGameControls.P1Control do
168 begin
169 KeyRight := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key;
170 KeyLeft := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key;
171 KeyUp := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key;
172 KeyDown := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key;
173 KeyFire := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key;
174 KeyJump := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key;
175 KeyNextWeapon := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key;
176 KeyPrevWeapon := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key;
177 KeyOpen := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key;
178 end;
180 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuAlt').GetControl('mOptionsControlsP1MenuAlt'));
181 with menu, gGameControls.P1Control do
182 begin
183 KeyRight2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key;
184 KeyLeft2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key;
185 KeyUp2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key;
186 KeyDown2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key;
187 KeyFire2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key;
188 KeyJump2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key;
189 KeyNextWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key;
190 KeyPrevWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key;
191 KeyOpen2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key;
192 KeyStrafe2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key;
193 end;
195 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
196 with menu, gGameControls.P2Control do
197 begin
198 KeyRight := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key;
199 KeyLeft := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key;
200 KeyUp := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key;
201 KeyDown := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key;
202 KeyFire := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key;
203 KeyJump := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key;
204 KeyNextWeapon := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key;
205 KeyPrevWeapon := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key;
206 KeyOpen := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key;
207 end;
209 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuAlt').GetControl('mOptionsControlsP2MenuAlt'));
210 with menu, gGameControls.P2Control do
211 begin
212 KeyRight2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key;
213 KeyLeft2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key;
214 KeyUp2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key;
215 KeyDown2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key;
216 KeyFire2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key;
217 KeyJump2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key;
218 KeyNextWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key;
219 KeyPrevWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key;
220 KeyOpen2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key;
221 KeyStrafe2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key;
222 end;
224 if e_JoysticksAvailable > 0 then
225 begin
226 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
227 with menu do
228 begin
229 for i := 0 to e_JoysticksAvailable-1 do
230 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20);
231 end;
232 end;
234 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
236 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
237 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
238 TEAM_RED, TEAM_BLUE);
240 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
241 begin
242 gPlayer1Settings.Model := Model.Name;
243 gPlayer1Settings.Color := Model.Color;
244 end;
246 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
248 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
249 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
250 TEAM_RED, TEAM_BLUE);
251 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
252 begin
253 gPlayer2Settings.Model := Model.Name;
254 gPlayer2Settings.Color := Model.Color;
255 end;
257 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := 'Player1';
258 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := 'Player2';
260 if g_Game_IsServer then
261 begin
262 if gPlayer1 <> nil then
263 begin
264 gPlayer1.SetModel(gPlayer1Settings.Model);
265 gPlayer1.Name := gPlayer1Settings.Name;
266 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
267 gPlayer1.SetColor(gPlayer1Settings.Color)
268 else
269 if gPlayer1.Team <> gPlayer1Settings.Team then
270 gPlayer1.SwitchTeam;
272 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
273 end;
275 if gPlayer2 <> nil then
276 begin
277 gPlayer2.SetModel(gPlayer2Settings.Model);
278 gPlayer2.Name := gPlayer2Settings.Name;
279 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
280 gPlayer2.SetColor(gPlayer2Settings.Color)
281 else
282 if gPlayer2.Team <> gPlayer2Settings.Team then
283 gPlayer2.SwitchTeam;
284 end;
285 end;
287 if g_Game_IsClient then MC_SEND_PlayerSettings;
289 g_Options_Write(GameDir+'/'+CONFIG_FILENAME);
290 end;
292 procedure ReadOptions();
293 var
294 menu: TGUIMenu;
295 i: Integer;
296 begin
297 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
299 with TGUISwitch(menu.GetControl('swBPP')) do
300 if gBPP = 16 then
301 ItemIndex := 0
302 else
303 ItemIndex := 1;
305 with TGUISwitch(menu.GetControl('swTextureFilter')) do
306 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
308 with TGUISwitch(menu.GetControl('swVSync')) do
309 if gVSync then ItemIndex := 0 else ItemIndex := 1;
311 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
312 if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1;
314 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
316 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
317 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
318 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
320 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
321 if gMuteWhenInactive then
322 ItemIndex := 1
323 else
324 ItemIndex := 0;
326 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
328 with TGUISwitch(menu.GetControl('swSoundEffects')) do
329 if gSoundEffectsDF then
330 ItemIndex := 1
331 else
332 ItemIndex := 0;
334 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
335 with menu, gGameControls.P1Control do
336 begin
337 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key := KeyRight;
338 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key := KeyLeft;
339 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key := KeyUp;
340 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key := KeyDown;
341 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key := KeyFire;
342 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key := KeyJump;
343 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key := KeyNextWeapon;
344 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key := KeyPrevWeapon;
345 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key := KeyOpen;
346 end;
348 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuAlt').GetControl('mOptionsControlsP1MenuAlt'));
349 with menu, gGameControls.P1Control do
350 begin
351 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key := KeyRight2;
352 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key := KeyLeft2;
353 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key := KeyUp2;
354 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key := KeyDown2;
355 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key := KeyFire2;
356 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key := KeyJump2;
357 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key := KeyNextWeapon2;
358 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key := KeyPrevWeapon2;
359 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key := KeyOpen2;
360 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key := KeyStrafe2;
361 end;
363 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
364 with menu, gGameControls.P2Control do
365 begin
366 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key := KeyRight;
367 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key := KeyLeft;
368 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key := KeyUp;
369 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key := KeyDown;
370 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key := KeyFire;
371 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key := KeyJump;
372 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key := KeyNextWeapon;
373 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key := KeyPrevWeapon;
374 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key := KeyOpen;
375 end;
377 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuAlt').GetControl('mOptionsControlsP2MenuAlt'));
378 with menu, gGameControls.P2Control do
379 begin
380 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key := KeyRight2;
381 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key := KeyLeft2;
382 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_UP])).Key := KeyUp2;
383 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key := KeyDown2;
384 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key := KeyFire2;
385 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key := KeyJump2;
386 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key := KeyNextWeapon2;
387 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key := KeyPrevWeapon2;
388 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key := KeyOpen2;
389 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key := KeyStrafe2;
390 end;
392 if e_JoysticksAvailable > 0 then
393 begin
394 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
395 with menu do
396 begin
397 for i := 0 to e_JoysticksAvailable-1 do
398 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20);
399 end;
400 end;
402 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
403 with menu, gGameControls.GameControls do
404 begin
405 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := TakeScreenshot;
406 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := Stat;
407 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := Chat;
408 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := TeamChat;
409 end;
411 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
413 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
414 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
415 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
416 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
417 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
419 with TGUISwitch(menu.GetControl('swScreenFlash')) do
420 ItemIndex := gFlash;
422 with TGUISwitch(menu.GetControl('swBloodType')) do
423 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
425 with TGUISwitch(menu.GetControl('swCorpseType')) do
426 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
428 with TGUISwitch(menu.GetControl('swGibsType')) do
429 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
431 with TGUISwitch(menu.GetControl('swGibsCount')) do
432 case gGibsCount of
433 0: ItemIndex := 0;
434 8: ItemIndex := 1;
435 16: ItemIndex := 2;
436 32: ItemIndex := 3;
437 else ItemIndex := 4;
438 end;
440 with TGUISwitch(menu.GetControl('swBackGround')) do
441 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
443 with TGUISwitch(menu.GetControl('swMessages')) do
444 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
446 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
447 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
449 with TGUISwitch(menu.GetControl('swChatBubble')) do
450 ItemIndex := gChatBubble;
452 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
454 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
455 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
457 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
458 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
460 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
461 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
462 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
464 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
466 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
467 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
469 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
470 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
472 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
473 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
474 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
476 ProcSelectModel(nil);
477 end;
479 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
480 begin
481 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
482 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
483 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
484 else
485 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
486 end;
488 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
489 begin
490 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
491 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
492 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
493 else
494 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
495 end;
497 procedure ProcStartCustomGame();
498 var
499 Map: String;
500 GameMode: Byte;
501 Options: LongWord;
502 begin
503 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
504 begin
505 Map := TGUILabel(GetControl('lbMap')).Text;
506 if Map = '' then
507 Exit;
508 if Pos(':\', Map) = 0 then
509 Exit;
511 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
512 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
513 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
514 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
515 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
517 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
518 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
519 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
520 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
521 Options := 0;
522 if gcTeamDamage then
523 Options := Options or GAME_OPTION_TEAMDAMAGE;
524 if gcAllowExit then
525 Options := Options or GAME_OPTION_ALLOWEXIT;
526 if gcWeaponStay then
527 Options := Options or GAME_OPTION_WEAPONSTAY;
528 if gcMonsters then
529 Options := Options or GAME_OPTION_MONSTERS;
530 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
532 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
533 1: begin
534 Options := Options or GAME_OPTION_BOTVSMONSTER;
535 gcBotsVS := 'Monsters';
536 end;
537 2: begin
538 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
539 gcBotsVS := 'Everybody';
540 end;
541 else begin
542 Options := Options or GAME_OPTION_BOTVSPLAYER;
543 gcBotsVS := 'Players';
544 end;
545 end;
547 gcMap := Map;
548 end;
550 g_Options_Write_Gameplay_Custom(GameDir+'/'+CONFIG_FILENAME);
552 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
553 gcMaxLives, Options, gcPlayers);
554 end;
557 procedure ProcStartNetGame();
558 var
559 Map: String;
560 GameMode: Byte;
561 Options: LongWord;
562 begin
563 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
564 begin
565 Map := TGUILabel(GetControl('lbMap')).Text;
566 if Map = '' then
567 Exit;
568 if Pos(':\', Map) = 0 then
569 Exit;
571 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
572 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
573 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
574 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
575 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
576 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
578 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
579 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
580 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
581 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
582 Options := 0;
583 if gnTeamDamage then
584 Options := Options or GAME_OPTION_TEAMDAMAGE;
585 if gnAllowExit then
586 Options := Options or GAME_OPTION_ALLOWEXIT;
587 if gnWeaponStay then
588 Options := Options or GAME_OPTION_WEAPONSTAY;
589 if gnMonsters then
590 Options := Options or GAME_OPTION_MONSTERS;
591 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
593 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
594 1: begin
595 Options := Options or GAME_OPTION_BOTVSMONSTER;
596 gnBotsVS := 'Monsters';
597 end;
598 2: begin
599 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
600 gnBotsVS := 'Everybody';
601 end;
602 else begin
603 Options := Options or GAME_OPTION_BOTVSPLAYER;
604 gnBotsVS := 'Players';
605 end;
606 end;
608 gnMap := Map;
609 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
610 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
611 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
612 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
613 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
614 end;
616 g_Options_Write_Net_Server(GameDir+'/'+CONFIG_FILENAME);
617 g_Options_Write_Gameplay_Net(GameDir+'/'+CONFIG_FILENAME);
619 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
620 Options, gnPlayers, 0, NetPort);
621 end;
623 procedure ProcConnectNetGame();
624 var
625 PW: String;
626 begin
627 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
628 begin
629 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
630 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
631 PW := TGUIEdit(GetControl('edPW')).Text;
632 end;
634 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
635 g_Game_StartClient(NetClientIP, NetClientPort, PW);
636 end;
638 procedure ProcEnterPassword();
639 var
640 PW: string;
641 begin
642 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
643 begin
644 NetClientIP := PromptIP;
645 NetClientPort := PromptPort;
646 PW := TGUIEdit(GetControl('edPW')).Text;
647 end;
649 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
650 g_Game_StartClient(NetClientIP, NetClientPort, PW);
651 end;
653 procedure ProcServerlist();
654 begin
655 if not NetInitDone then
656 begin
657 if (not g_Net_Init()) then
658 begin
659 g_Console_Add('NET: ERROR: Failed to init ENet!');
660 Exit;
661 end
662 else
663 NetInitDone := True;
664 end;
666 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
668 gState := STATE_SLIST;
669 g_ActiveWindow := nil;
671 slWaitStr := _lc[I_NET_SLIST_WAIT];
673 g_Game_Draw;
674 ReDrawWindow;
676 slReturnPressed := True;
677 if g_Net_Slist_Fetch(slCurrent) then
678 begin
679 if slCurrent = nil then
680 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
681 end
682 else
683 slWaitStr := _lc[I_NET_SLIST_ERROR];
684 end;
686 procedure ProcStartCampaign();
687 var
688 WAD: String;
689 TwoPlayers: Boolean;
690 n: Byte;
691 begin
692 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
693 begin
694 WAD := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
695 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
696 end;
698 if TwoPlayers then
699 n := 2
700 else
701 n := 1;
702 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
703 end;
705 procedure ProcSelectMap(Sender: TGUIControl);
706 var
707 win: TGUIWindow;
708 a: TMapInfo;
709 wad, map, res: String;
710 begin
711 win := g_GUI_GetWindow('SelectMapMenu');
712 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
713 begin
714 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
715 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
717 if (wad = '') or (map = '') then
718 begin // Ýòî íå êàðòà
719 TGUILabel(GetControl('lbMapName')).Text := '';
720 TGUILabel(GetControl('lbMapAuthor')).Text := '';
721 TGUILabel(GetControl('lbMapSize')).Text := '';
722 TGUIMemo(GetControl('meMapDescription')).SetText('');
723 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
724 TGUILabel(win.GetControl('lbMapScale')).Text := '';
725 end
726 else // Ýòî êàðòà
727 begin
728 res := wad+':\'+map;
730 a := g_Map_GetMapInfo(res);
732 TGUILabel(GetControl('lbMapName')).Text := a.Name;
733 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
734 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
735 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
736 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
737 TGUILabel(win.GetControl('lbMapScale')).Text :=
738 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
739 end;
740 end;
741 end;
743 procedure ProcSelectWAD(Sender: TGUIControl);
744 var
745 wad: String;
746 list: SArray;
747 begin
748 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
749 begin
750 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
752 with TGUIListBox(GetControl('lsMapRes')) do
753 begin
754 Clear();
756 if wad <> '' then
757 begin
758 list := g_Map_GetMapsList(wad);
760 if list <> nil then
761 begin
762 Items := list;
763 ItemIndex := 0;
764 end
765 end;
766 end;
767 end;
769 ProcSelectMap(nil);
770 end;
772 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
773 var
774 win: TGUIWindow;
775 a: TMegaWADInfo;
776 wad, fn: String;
777 begin
778 win := g_GUI_GetWindow('CampaignMenu');
779 with TGUIMenu(win.GetControl('mCampaignMenu')) do
780 begin
781 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
783 if wad = '' then
784 begin
785 TGUILabel(GetControl('lbWADName')).Text := '';
786 TGUILabel(GetControl('lbWADAuthor')).Text := '';
787 TGUIMemo(GetControl('meWADDescription')).SetText('');
788 end;
790 a := g_Game_GetMegaWADInfo(wad);
792 TGUILabel(GetControl('lbWADName')).Text := a.Name;
793 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
794 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
796 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
798 if a.pic <> '' then
799 begin
800 fn := g_ExtractWadName(a.pic);
801 if fn = '' then
802 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
803 else
804 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
805 end;
806 end;
807 end;
809 procedure ProcChangeColor(Sender: TGUIControl);
810 var
811 window: TGUIWindow;
812 begin
813 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
814 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
815 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
816 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
817 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
818 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
820 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
821 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
822 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
823 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
824 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
825 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
826 end;
828 procedure ProcSelectModel(Sender: TGUIControl);
829 var
830 a: string;
831 window: TGUIWindow;
832 begin
833 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
834 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
835 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
837 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
838 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
839 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
841 ProcChangeColor(nil);
842 end;
844 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
845 var
846 cwdt, chgt: Byte;
847 spc: ShortInt;
848 ID: DWORD;
849 wad: TWADFile;
850 cfgdata: Pointer;
851 cfglen: Integer;
852 config: TConfig;
853 begin
854 cfglen := 0;
856 wad := TWADFile.Create;
857 if wad.ReadFile(GameWAD) then
858 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
859 wad.Free();
861 if cfglen <> 0 then
862 begin
863 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
865 config := TConfig.CreateMem(cfgdata, cfglen);
866 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
867 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
868 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
870 if g_Texture_Get('FONT_STD', ID) then
871 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
873 config.Free();
874 end;
876 if cfglen <> 0 then FreeMem(cfgdata);
877 end;
879 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
880 var
881 cwdt, chgt: Byte;
882 spc: ShortInt;
883 CharID: DWORD;
884 wad: TWADFile;
885 cfgdata, fntdata: Pointer;
886 cfglen, fntlen: Integer;
887 config: TConfig;
888 chrwidth: Integer;
889 a: Byte;
890 begin
891 cfglen := 0;
892 fntlen := 0;
894 wad := TWADFile.Create;
895 if wad.ReadFile(GameWAD) then
896 begin
897 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
898 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
899 end;
900 wad.Free();
902 if cfglen <> 0 then
903 begin
904 config := TConfig.CreateMem(cfgdata, cfglen);
905 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
906 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
908 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
909 FontID := e_CharFont_Create(spc);
911 for a := 0 to 255 do
912 begin
913 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
914 if chrwidth = 0 then Continue;
916 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
917 cwdt, chgt) then
918 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
919 end;
921 config.Free();
922 end;
924 if cfglen <> 0 then FreeMem(cfgdata);
925 if fntlen <> 0 then FreeMem(fntdata);
926 end;
928 procedure MenuLoadData();
929 begin
930 e_WriteLog('Loading menu data...', MSG_NOTIFY);
932 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
933 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
934 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
935 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
936 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
937 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
938 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
939 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
940 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
941 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
942 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
943 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
944 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
945 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
946 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
947 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
948 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
949 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
950 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
951 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
952 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
953 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
954 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
955 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
957 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
958 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
959 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
960 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
961 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
962 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
963 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
964 end;
966 procedure MenuFreeData();
967 begin
968 e_CharFont_Remove(gMenuFont);
969 e_CharFont_Remove(gMenuSmallFont);
971 g_Texture_Delete('MAINMENU_MARKER1');
972 g_Texture_Delete('MAINMENU_MARKER2');
973 g_Texture_Delete('SCROLL_LEFT');
974 g_Texture_Delete('SCROLL_RIGHT');
975 g_Texture_Delete('SCROLL_MIDDLE');
976 g_Texture_Delete('SCROLL_MARKER');
977 g_Texture_Delete('EDIT_LEFT');
978 g_Texture_Delete('EDIT_RIGHT');
979 g_Texture_Delete('EDIT_MIDDLE');
980 g_Texture_Delete('BOX1');
981 g_Texture_Delete('BOX2');
982 g_Texture_Delete('BOX3');
983 g_Texture_Delete('BOX4');
984 g_Texture_Delete('BOX5');
985 g_Texture_Delete('BOX6');
986 g_Texture_Delete('BOX7');
987 g_Texture_Delete('BOX8');
988 g_Texture_Delete('BOX9');
989 g_Texture_Delete('BSCROLL_UP_A');
990 g_Texture_Delete('BSCROLL_UP_U');
991 g_Texture_Delete('BSCROLL_DOWN_A');
992 g_Texture_Delete('BSCROLL_DOWN_U');
993 g_Texture_Delete('BSCROLL_MIDDLE');
994 g_Texture_Delete('NOPIC');
996 g_Sound_Delete('MENU_SELECT');
997 g_Sound_Delete('MENU_OPEN');
998 g_Sound_Delete('MENU_CLOSE');
999 g_Sound_Delete('MENU_CHANGE');
1000 g_Sound_Delete('SCROLL_ADD');
1001 g_Sound_Delete('SCROLL_SUB');
1002 g_Sound_Delete('SOUND_PLAYER_FALL');
1003 end;
1005 procedure ProcAuthorsMenu();
1006 begin
1007 gMusic.SetByName('MUSIC_INTERMUS');
1008 gMusic.Play();
1009 end;
1011 procedure ProcExitMenuKeyDown (yes: Boolean);
1012 var
1013 s: ShortString;
1014 snd: TPlayableSound;
1015 res: Boolean;
1016 begin
1017 if yes then
1018 begin
1019 g_Game_StopAllSounds(True);
1020 case (Random(18)) of
1021 0: s := 'SOUND_MONSTER_PAIN';
1022 1: s := 'SOUND_MONSTER_DIE_3';
1023 2: s := 'SOUND_MONSTER_SLOP';
1024 3: s := 'SOUND_MONSTER_DEMON_DIE';
1025 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1026 5: s := 'SOUND_MONSTER_MAN_DIE';
1027 6: s := 'SOUND_MONSTER_BSP_DIE';
1028 7: s := 'SOUND_MONSTER_VILE_DIE';
1029 8: s := 'SOUND_MONSTER_SKEL_DIE';
1030 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1031 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1032 11: s := 'SOUND_MONSTER_BARON_DIE';
1033 12: s := 'SOUND_MONSTER_CACO_DIE';
1034 13: s := 'SOUND_MONSTER_CYBER_DIE';
1035 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1036 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1037 else s := 'SOUND_PLAYER_FALL';
1038 end;
1039 snd := TPlayableSound.Create();
1040 res := snd.SetByName(s);
1041 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1042 if res then
1043 begin
1044 snd.Play(True);
1045 while snd.IsPlaying() do begin end;
1046 end;
1047 g_Game_Quit();
1048 exit;
1049 end;
1050 g_GUI_HideWindow();
1051 end;
1053 procedure ProcLoadMenu();
1054 var
1055 a: Integer;
1056 begin
1057 for a := 1 to 8 do
1058 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text :=
1059 g_GetSaveName(a);
1060 end;
1062 procedure ProcSaveMenu();
1063 var
1064 a: Integer;
1065 begin
1066 for a := 1 to 8 do
1067 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text :=
1068 g_GetSaveName(a);
1069 end;
1071 procedure ProcSaveGame(Sender: TGUIControl);
1072 var
1073 a: Integer;
1074 begin
1075 if g_Game_IsNet then Exit;
1076 if g_Game_IsTestMap then Exit;
1077 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1078 g_Game_PauseAllSounds(True);
1079 g_SaveGame(a, TGUIEdit(Sender).Text);
1081 g_ActiveWindow := nil;
1082 g_Game_Pause(False);
1083 end;
1085 procedure ProcLoadGame(Sender: TGUIControl);
1086 var
1087 a: Integer;
1088 begin
1089 if g_Game_IsNet then Exit;
1090 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1091 if g_LoadGame(a) then
1092 g_Game_PauseAllSounds(False)
1093 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1094 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1095 end;
1097 procedure ProcSingle1Player();
1098 begin
1099 g_Game_StartSingle('megawads/DOOM2D.WAD:\MAP01', False, 1);
1100 end;
1102 procedure ProcSingle2Players();
1103 begin
1104 g_Game_StartSingle('megawads/DOOM2D.WAD:\MAP01', True, 2);
1105 end;
1107 procedure ProcSelectMapMenu();
1108 var
1109 menu: TGUIMenu;
1110 wad_lb: TGUIFileListBox;
1111 map_lb: TGUIListBox;
1112 map: String;
1113 begin
1114 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1115 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1116 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1118 if wad_lb.SelectedItem() <> '' then
1119 map := map_lb.SelectedItem()
1120 else
1121 map := '';
1123 wad_lb.UpdateFileList();
1124 map_lb.Clear();
1126 if wad_lb.SelectedItem() <> '' then
1127 begin
1128 ProcSelectWAD(nil);
1129 map_lb.SelectItem(map);
1131 if map_lb.SelectedItem() <> '' then
1132 ProcSelectMap(nil);
1133 end;
1135 g_GUI_ShowWindow('SelectMapMenu');
1136 end;
1138 procedure ProcSelectCampaignMenu();
1139 var
1140 menu: TGUIMenu;
1141 wad_lb: TGUIFileListBox;
1142 begin
1143 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1144 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1146 wad_lb.UpdateFileList();
1148 if wad_lb.SelectedItem() <> '' then
1149 ProcSelectCampaignWAD(nil);
1150 end;
1152 procedure ProcSetMap();
1153 var
1154 wad, map, res: String;
1155 begin
1156 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1157 begin
1158 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1159 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1160 end;
1162 if (wad = '') or (map = '') then
1163 Exit;
1165 res := wad+':\'+map;
1167 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1168 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1169 end;
1171 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1172 var
1173 menu: TGUIMenu;
1174 begin
1175 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1177 g_Sound_SetupAllVolumes(
1178 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1179 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1180 );
1181 end;
1183 procedure ProcOptionsPlayersMIMenu();
1184 var
1185 s, a: string;
1186 b: TModelInfo;
1187 begin
1188 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1190 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1192 if a = '' then Exit;
1194 b := g_PlayerModel_GetInfo(a);
1196 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1197 begin
1198 TGUILabel(GetControl('lbName')).Text := b.Name;
1199 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1200 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1202 if b.HaveWeapon then
1203 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1204 else
1205 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1206 end;
1208 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1209 end;
1211 procedure ProcOptionsPlayersAnim();
1212 var
1213 s: String;
1214 begin
1215 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1216 s := 'P1'
1217 else
1218 s := 'P2';
1220 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1221 begin
1222 NextAnim();
1223 Model.GetCurrentAnimation.Loop := True;
1224 Model.GetCurrentAnimationMask.Loop := True;
1225 end;
1226 end;
1228 procedure ProcOptionsPlayersWeap();
1229 var
1230 s: String;
1231 begin
1232 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1233 s := 'P1'
1234 else
1235 s := 'P2';
1237 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1238 NextWeapon();
1239 end;
1241 procedure ProcOptionsPlayersRot();
1242 var
1243 s: string;
1244 begin
1245 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1246 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1247 if Direction = D_LEFT then Direction := D_RIGHT else Direction := D_LEFT;
1248 end;
1250 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1251 begin
1252 if yes then
1253 begin
1254 g_Options_SetDefault();
1255 ReadOptions();
1256 end;
1257 g_GUI_HideWindow();
1258 end;
1260 procedure ProcSavedMenuKeyDown (yes: Boolean);
1261 begin
1262 if yes then ReadOptions();
1263 g_GUI_HideWindow();
1264 end;
1266 procedure ProcAuthorsClose();
1267 begin
1268 gMusic.SetByName('MUSIC_MENU');
1269 gMusic.Play();
1270 gState := STATE_MENU;
1271 end;
1273 procedure ProcGMClose();
1274 begin
1275 g_Game_InGameMenu(False);
1276 end;
1278 procedure ProcGMShow();
1279 var
1280 Enabled: Boolean;
1281 begin
1282 Enabled := True;
1283 if (gGameSettings.GameType = GT_SINGLE) and
1284 ((gPlayer1 = nil) or (not gPlayer1.Live)) and
1285 ((gPlayer2 = nil) or (not gPlayer2.Live)) then
1286 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1287 if not gGameOn then
1288 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1289 if g_Game_IsTestMap then
1290 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1291 TGUIMainMenu(g_ActiveWindow.GetControl(
1292 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1293 end;
1295 procedure ProcChangePlayers();
1296 var
1297 TeamGame, Spectator, AddTwo: Boolean;
1298 P1Team{, P2Team}: Byte;
1299 bP2: TGUITextButton;
1300 begin
1301 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1302 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1303 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1304 P1Team := TEAM_NONE;
1305 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1306 // TODO
1307 //P2Team := TEAM_NONE;
1308 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1310 TGUIMainMenu(g_ActiveWindow.GetControl(
1311 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1312 TGUIMainMenu(g_ActiveWindow.GetControl(
1313 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1314 TGUIMainMenu(g_ActiveWindow.GetControl(
1315 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1317 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1318 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1319 bP2.Enabled := AddTwo and not Spectator;
1320 if bP2.Enabled then
1321 bP2.Color := MAINMENU_ITEMS_COLOR
1322 else
1323 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1324 if gPlayer2 = nil then
1325 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1326 else
1327 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1329 TGUIMainMenu(g_ActiveWindow.GetControl(
1330 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1331 end;
1333 procedure ProcJoinRed();
1334 begin
1335 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1336 Exit;
1337 if g_Game_IsServer then
1338 begin
1339 if gPlayer1 = nil then
1340 g_Game_AddPlayer(TEAM_RED)
1341 else
1342 begin
1343 if gPlayer1.Team <> TEAM_RED then
1344 begin
1345 gPlayer1.SwitchTeam;
1346 gPlayer1Settings.Team := gPlayer1.Team;
1347 end;
1349 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1350 end;
1351 end
1352 else
1353 begin
1354 gPlayer1Settings.Team := TEAM_RED;
1355 MC_SEND_PlayerSettings;
1356 if gPlayer1 = nil then
1357 g_Game_AddPlayer(TEAM_RED);
1358 end;
1359 g_ActiveWindow := nil;
1360 g_Game_Pause(False);
1361 end;
1363 procedure ProcJoinBlue();
1364 begin
1365 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1366 Exit;
1367 if g_Game_IsServer then
1368 begin
1369 if gPlayer1 = nil then
1370 g_Game_AddPlayer(TEAM_BLUE)
1371 else
1372 begin
1373 if gPlayer1.Team <> TEAM_BLUE then
1374 begin
1375 gPlayer1.SwitchTeam;
1376 gPlayer1Settings.Team := gPlayer1.Team;
1377 end;
1379 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1380 end;
1381 end
1382 else
1383 begin
1384 gPlayer1Settings.Team := TEAM_BLUE;
1385 MC_SEND_PlayerSettings;
1386 if gPlayer1 = nil then
1387 g_Game_AddPlayer(TEAM_BLUE);
1388 end;
1389 g_ActiveWindow := nil;
1390 g_Game_Pause(False);
1391 end;
1393 procedure ProcJoinGame();
1394 begin
1395 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1396 Exit;
1397 if gPlayer1 = nil then
1398 g_Game_AddPlayer();
1399 g_ActiveWindow := nil;
1400 g_Game_Pause(False);
1401 end;
1403 procedure ProcSwitchP2();
1404 begin
1405 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1406 Exit;
1407 if gPlayer1 = nil then
1408 Exit;
1409 if gPlayer2 = nil then
1410 g_Game_AddPlayer()
1411 else
1412 g_Game_RemovePlayer();
1413 g_ActiveWindow := nil;
1414 g_Game_Pause(False);
1415 end;
1417 procedure ProcSpectate();
1418 begin
1419 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1420 Exit;
1421 g_Game_Spectate();
1422 g_ActiveWindow := nil;
1423 g_Game_Pause(False);
1424 end;
1426 procedure ProcRestartMenuKeyDown (yes: Boolean);
1427 begin
1428 if yes then g_Game_Restart() else g_GUI_HideWindow;
1429 end;
1431 procedure ProcEndMenuKeyDown (yes: Boolean);
1432 begin
1433 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1434 end;
1436 procedure ProcSetRussianLanguage();
1437 begin
1438 if gLanguage <> LANGUAGE_RUSSIAN then
1439 begin
1440 gLanguage := LANGUAGE_RUSSIAN;
1441 gLanguageChange := True;
1442 gAskLanguage := False;
1444 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1446 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1447 ProcApplyOptions();
1448 end;
1449 end;
1451 procedure ProcSetEnglishLanguage();
1452 begin
1453 if gLanguage <> LANGUAGE_ENGLISH then
1454 begin
1455 gLanguage := LANGUAGE_ENGLISH;
1456 gLanguageChange := True;
1457 gAskLanguage := False;
1459 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1461 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1462 ProcApplyOptions();
1463 end;
1464 end;
1466 procedure ReadGameSettings();
1467 var
1468 menu: TGUIMenu;
1469 begin
1470 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1472 with gGameSettings do
1473 begin
1474 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1475 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1476 ItemIndex := 0
1477 else
1478 ItemIndex := 1;
1480 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1481 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1482 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1484 with TGUISwitch(menu.GetControl('swBotsVS')) do
1485 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1486 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1487 ItemIndex := 2
1488 else
1489 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1490 ItemIndex := 1
1491 else
1492 ItemIndex := 0;
1494 if GameType in [GT_CUSTOM, GT_SERVER] then
1495 begin
1496 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1497 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1498 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1499 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1500 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1501 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1502 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1503 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1504 end
1505 else
1506 begin
1507 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1508 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1509 begin
1510 Enabled := False;
1511 Text := '';
1512 end;
1513 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1514 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1515 begin
1516 Enabled := False;
1517 Text := '';
1518 end;
1519 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1520 with TGUIEdit(menu.GetControl('edMaxLives')) do
1521 begin
1522 Enabled := False;
1523 Text := '';
1524 end;
1525 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1526 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1527 end;
1528 end;
1529 end;
1531 procedure ProcApplyGameSet();
1532 var
1533 menu: TGUIMenu;
1534 a, b, n: Integer;
1535 stat: TPlayerStatArray;
1536 begin
1537 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1539 if not g_Game_IsServer then Exit;
1541 with gGameSettings do
1542 begin
1543 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1544 begin
1545 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1546 Options := Options or GAME_OPTION_TEAMDAMAGE
1547 else
1548 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1549 end;
1551 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1552 begin
1553 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1555 if n = 0 then
1556 TimeLimit := 0
1557 else
1558 begin
1559 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1561 TimeLimit := Max(n, b);
1562 end;
1563 end;
1565 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1566 begin
1567 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1569 if n = 0 then
1570 GoalLimit := 0
1571 else
1572 begin
1573 b := 0;
1574 if GameMode = GM_DM then
1575 begin // DM
1576 stat := g_Player_GetStats();
1577 if stat <> nil then
1578 for a := 0 to High(stat) do
1579 if stat[a].Frags > b then
1580 b := stat[a].Frags;
1581 end
1582 else // CTF
1583 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1585 GoalLimit := Max(n, b);
1586 end;
1587 end;
1589 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1590 begin
1591 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1592 if n < 0 then n := 0;
1593 if n > 255 then n := 255;
1594 if n = 0 then
1595 MaxLives := 0
1596 else
1597 begin
1598 b := 0;
1599 stat := g_Player_GetStats();
1600 if stat <> nil then
1601 for a := 0 to High(stat) do
1602 if stat[a].Lives > b then
1603 b := stat[a].Lives;
1605 MaxLives := Max(n, b);
1606 end;
1607 end;
1609 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1610 begin
1611 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1612 1:
1613 begin
1614 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1615 Options := Options or GAME_OPTION_BOTVSMONSTER;
1616 end;
1617 2:
1618 begin
1619 Options := Options or GAME_OPTION_BOTVSPLAYER;
1620 Options := Options or GAME_OPTION_BOTVSMONSTER;
1621 end;
1622 else
1623 begin
1624 Options := Options or GAME_OPTION_BOTVSPLAYER;
1625 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1626 end;
1627 end;
1628 end;
1629 end;
1631 if g_Game_IsNet then MH_SEND_GameSettings;
1632 end;
1634 procedure ProcVideoOptionsRes();
1635 var
1636 menu: TGUIMenu;
1637 list: SArray;
1638 SR: DWORD;
1639 begin
1640 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1642 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1643 IntToStr(gScreenWidth) +
1644 ' x ' + IntToStr(gScreenHeight) +
1645 ', ' + IntToStr(gBPP) + ' bpp';
1647 with TGUIListBox(menu.GetControl('lsResolution')) do
1648 begin
1649 list := GetDisplayModes(gBPP, SR);
1651 if list <> nil then
1652 begin
1653 Items := list;
1654 ItemIndex := SR;
1655 end
1656 else
1657 Clear();
1658 end;
1660 with TGUISwitch(menu.GetControl('swFullScreen')) do
1661 if gFullscreen then
1662 ItemIndex := 0
1663 else
1664 ItemIndex := 1;
1665 end;
1667 procedure ProcApplyVideoOptions();
1668 var
1669 menu: TGUIMenu;
1670 Fullscreen: Boolean;
1671 SWidth, SHeight: Integer;
1672 str: String;
1673 begin
1674 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1676 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1677 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1679 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1681 if (SWidth <> gScreenWidth) or
1682 (SHeight <> gScreenHeight) or
1683 (Fullscreen <> gFullscreen) then
1684 begin
1685 gResolutionChange := True;
1686 gRC_Width := SWidth;
1687 gRC_Height := SHeight;
1688 gRC_FullScreen := Fullscreen;
1689 gRC_Maximized := gWinMaximized;
1690 end;
1692 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1693 ProcApplyOptions();
1694 end;
1696 procedure ProcSetFirstRussianLanguage();
1697 begin
1698 gLanguage := LANGUAGE_RUSSIAN;
1699 gLanguageChange := True;
1700 gAskLanguage := False;
1702 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1703 end;
1705 procedure ProcSetFirstEnglishLanguage();
1706 begin
1707 gLanguage := LANGUAGE_ENGLISH;
1708 gLanguageChange := True;
1709 gAskLanguage := False;
1711 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1712 end;
1714 procedure ProcRecallAddress();
1715 begin
1716 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1717 begin
1718 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1719 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1720 end;
1721 end;
1723 procedure CreateFirstLanguageMenu();
1724 var
1725 Menu: TGUIWindow;
1726 begin
1727 Menu := TGUIWindow.Create('FirstLanguageMenu');
1729 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1730 begin
1731 Name := 'mmFirstLanguageMenu';
1732 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1733 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1734 end;
1736 Menu.DefControl := 'mmFirstLanguageMenu';
1737 Menu.MainWindow := True;
1738 g_GUI_AddWindow(Menu);
1739 end;
1741 procedure g_Menu_AskLanguage();
1742 begin
1743 CreateFirstLanguageMenu();
1744 g_GUI_ShowWindow('FirstLanguageMenu');
1745 end;
1747 procedure CreatePlayerOptionsMenu(s: String);
1748 var
1749 Menu: TGUIWindow;
1750 a: String;
1751 begin
1752 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1753 if s = 'P1' then
1754 a := _lc[I_MENU_PLAYER_1]
1755 else
1756 a := _lc[I_MENU_PLAYER_2];
1757 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1758 begin
1759 Name := 'mOptionsPlayers'+s+'Menu';
1760 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1761 begin
1762 Name := 'ed'+s+'Name';
1763 MaxLength := 12;
1764 Width := 12;
1765 end;
1766 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1767 begin
1768 Name := 'sw'+s+'Team';
1769 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1770 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1771 end ;
1772 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1773 begin
1774 Name := 'ls'+s+'Model';
1775 Sort := True;
1776 Items := g_PlayerModel_GetNames();
1777 OnChange := ProcSelectModel;
1778 end;
1779 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1780 begin
1781 Name := 'sc'+s+'Red';
1782 Max := 16;
1783 OnChange := ProcChangeColor;
1784 end;
1785 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1786 begin
1787 Name := 'sc'+s+'Green';
1788 Max := 16;
1789 OnChange := ProcChangeColor;
1790 end;
1791 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1792 begin
1793 Name := 'sc'+s+'Blue';
1794 Max := 16;
1795 OnChange := ProcChangeColor;
1796 end;
1797 AddSpace();
1798 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1799 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1800 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1801 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1803 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1804 begin
1805 Name := 'mv'+s+'Model';
1806 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1807 Y := GetControl('ls'+s+'Model').Y;
1808 end;
1809 end;
1810 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1811 g_GUI_AddWindow(Menu);
1812 end;
1814 procedure CreateAllMenus();
1815 var
1816 Menu: TGUIWindow;
1817 //SR: TSearchRec;
1818 a, cx, _y, i: Integer;
1819 //list: SArray;
1820 begin
1821 Menu := TGUIWindow.Create('MainMenu');
1822 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1823 begin
1824 Name := 'mmMainMenu';
1825 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1826 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1827 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1828 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1829 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1830 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1831 end;
1832 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1833 begin
1834 Color := _RGB(255, 255, 255);
1835 X := gScreenWidth-GetWidth-8;
1836 Y := gScreenHeight-GetHeight-8;
1837 end;
1838 Menu.DefControl := 'mmMainMenu';
1839 Menu.MainWindow := True;
1840 g_GUI_AddWindow(Menu);
1842 Menu := TGUIWindow.Create('NewGameMenu');
1843 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
1844 begin
1845 Name := 'mmNewGameMenu';
1846 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1847 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1848 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1849 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1850 end;
1851 Menu.DefControl := 'mmNewGameMenu';
1852 g_GUI_AddWindow(Menu);
1854 Menu := TGUIWindow.Create('NetGameMenu');
1855 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
1856 begin
1857 Name := 'mmNetGameMenu';
1858 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1859 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1860 end;
1861 Menu.DefControl := 'mmNetGameMenu';
1862 g_GUI_AddWindow(Menu);
1864 Menu := TGUIWindow.Create('NetServerMenu');
1865 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
1866 begin
1867 Name := 'mNetServerMenu';
1868 with AddEdit(_lc[I_NET_SERVER_NAME]) do
1869 begin
1870 Name := 'edSrvName';
1871 OnlyDigits := False;
1872 Width := 16;
1873 MaxLength := 64;
1874 Text := NetServerName;
1875 end;
1876 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
1877 begin
1878 Name := 'edSrvPassword';
1879 OnlyDigits := False;
1880 Width := 16;
1881 MaxLength := 24;
1882 Text := NetPassword;
1883 end;
1884 with AddEdit(_lc[I_NET_PORT]) do
1885 begin
1886 Name := 'edPort';
1887 OnlyDigits := True;
1888 Width := 4;
1889 MaxLength := 5;
1890 Text := IntToStr(NetPort);
1891 end;
1892 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
1893 begin
1894 Name := 'edMaxPlayers';
1895 OnlyDigits := True;
1896 Width := 4;
1897 MaxLength := 2;
1898 Text := IntToStr(NetMaxClients);
1899 end;
1900 with AddSwitch(_lc[I_NET_USE_MASTER]) do
1901 begin
1902 Name := 'swUseMaster';
1903 AddItem(_lc[I_MENU_YES]);
1904 AddItem(_lc[I_MENU_NO]);
1905 if NetUseMaster then
1906 ItemIndex := 0
1907 else
1908 ItemIndex := 1;
1909 end;
1910 AddSpace();
1911 with AddLabel(_lc[I_MENU_MAP]) do
1912 begin
1913 Name := 'lbMap';
1914 FixedLength := 16;
1915 Text := gnMap;
1916 OnClick := @ProcSelectMapMenu;
1917 end;
1918 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
1919 begin
1920 Name := 'swGameMode';
1921 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
1922 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
1923 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
1924 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
1925 case g_Game_TextToMode(gnGameMode) of
1926 GM_NONE,
1927 GM_DM: ItemIndex := 0;
1928 GM_TDM: ItemIndex := 1;
1929 GM_CTF: ItemIndex := 2;
1930 GM_SINGLE,
1931 GM_COOP: ItemIndex := 3;
1932 end;
1933 OnChange := ProcSwitchMonstersNet;
1934 end;
1935 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
1936 begin
1937 Name := 'edTimeLimit';
1938 OnlyDigits := True;
1939 Width := 4;
1940 MaxLength := 5;
1941 if gnTimeLimit > 0 then
1942 Text := IntToStr(gnTimeLimit);
1943 end;
1944 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
1945 begin
1946 Name := 'edGoalLimit';
1947 OnlyDigits := True;
1948 Width := 4;
1949 MaxLength := 5;
1950 if gnGoalLimit > 0 then
1951 Text := IntToStr(gnGoalLimit);
1952 end;
1953 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
1954 begin
1955 Name := 'edMaxLives';
1956 OnlyDigits := True;
1957 Width := 4;
1958 MaxLength := 3;
1959 if gnMaxLives > 0 then
1960 Text := IntToStr(gnMaxLives);
1961 end;
1962 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
1963 begin
1964 Name := 'swPlayers';
1965 AddItem(_lc[I_MENU_COUNT_NONE]);
1966 AddItem(_lc[I_MENU_PLAYERS_ONE]);
1967 AddItem(_lc[I_MENU_PLAYERS_TWO]);
1968 ItemIndex := gnPlayers;
1969 end;
1970 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
1971 begin
1972 Name := 'swTeamDamage';
1973 AddItem(_lc[I_MENU_YES]);
1974 AddItem(_lc[I_MENU_NO]);
1975 if gnTeamDamage then
1976 ItemIndex := 0
1977 else
1978 ItemIndex := 1;
1979 end;
1980 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
1981 begin
1982 Name := 'swEnableExits';
1983 AddItem(_lc[I_MENU_YES]);
1984 AddItem(_lc[I_MENU_NO]);
1985 if gnAllowExit then
1986 ItemIndex := 0
1987 else
1988 ItemIndex := 1;
1989 end;
1990 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
1991 begin
1992 Name := 'swWeaponStay';
1993 AddItem(_lc[I_MENU_YES]);
1994 AddItem(_lc[I_MENU_NO]);
1995 if gnWeaponStay then
1996 ItemIndex := 0
1997 else
1998 ItemIndex := 1;
1999 end;
2000 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2001 begin
2002 Name := 'swMonsters';
2003 AddItem(_lc[I_MENU_YES]);
2004 AddItem(_lc[I_MENU_NO]);
2005 if gnMonsters then
2006 ItemIndex := 0
2007 else
2008 ItemIndex := 1;
2009 end;
2010 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2011 begin
2012 Name := 'swBotsVS';
2013 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2014 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2015 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2016 ItemIndex := 2;
2017 if gnBotsVS = 'Players' then
2018 ItemIndex := 0;
2019 if gnBotsVS = 'Monsters' then
2020 ItemIndex := 1;
2021 end;
2022 AddSpace();
2023 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2025 ReAlign();
2026 end;
2027 Menu.DefControl := 'mNetServerMenu';
2028 g_GUI_AddWindow(Menu);
2030 Menu := TGUIWindow.Create('NetClientMenu');
2031 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2032 begin
2033 Name := 'mNetClientMenu';
2035 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2036 AddSpace();
2038 with AddEdit(_lc[I_NET_ADDRESS]) do
2039 begin
2040 Name := 'edIP';
2041 OnlyDigits :=False;
2042 Width := 12;
2043 MaxLength := 64;
2044 Text := 'localhost';
2045 end;
2046 with AddEdit(_lc[I_NET_PORT]) do
2047 begin
2048 Name := 'edPort';
2049 OnlyDigits := True;
2050 Width := 4;
2051 MaxLength := 5;
2052 Text := '25666';
2053 end;
2054 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2055 begin
2056 Name := 'edPW';
2057 OnlyDigits := False;
2058 Width := 12;
2059 MaxLength := 32;
2060 Text := '';
2061 end;
2063 AddSpace();
2064 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2066 ReAlign();
2067 end;
2068 Menu.DefControl := 'mNetClientMenu';
2069 g_GUI_AddWindow(Menu);
2071 Menu := TGUIWindow.Create('LoadMenu');
2072 Menu.OnShow := ProcLoadMenu;
2073 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2074 begin
2075 Name := 'mmLoadMenu';
2077 for a := 1 to 8 do
2078 with AddEdit('') do
2079 begin
2080 Name := 'edSlot'+IntToStr(a);
2081 Width := 16;
2082 MaxLength := 16;
2083 OnEnter := ProcLoadGame;
2084 end;
2085 end;
2086 Menu.DefControl := 'mmLoadMenu';
2087 g_GUI_AddWindow(Menu);
2089 Menu := TGUIWindow.Create('SaveMenu');
2090 Menu.OnShow := ProcSaveMenu;
2091 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2092 begin
2093 Name := 'mmSaveMenu';
2095 for a := 1 to 8 do
2096 with AddEdit('') do
2097 begin
2098 Name := 'edSlot'+IntToStr(a);
2099 Width := 16;
2100 MaxLength := 16;
2101 OnChange := ProcSaveGame;
2102 end;
2103 end;
2104 Menu.DefControl := 'mmSaveMenu';
2105 g_GUI_AddWindow(Menu);
2107 Menu := TGUIWindow.Create('CustomGameMenu');
2108 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2109 begin
2110 Name := 'mCustomGameMenu';
2111 with AddLabel(_lc[I_MENU_MAP]) do
2112 begin
2113 Name := 'lbMap';
2114 FixedLength := 16;
2115 Text := gcMap;
2116 OnClick := @ProcSelectMapMenu;
2117 end;
2118 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2119 begin
2120 Name := 'swGameMode';
2121 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2122 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2123 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2124 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2125 case g_Game_TextToMode(gcGameMode) of
2126 GM_NONE,
2127 GM_DM: ItemIndex := 0;
2128 GM_TDM: ItemIndex := 1;
2129 GM_CTF: ItemIndex := 2;
2130 GM_SINGLE,
2131 GM_COOP: ItemIndex := 3;
2132 end;
2133 OnChange := ProcSwitchMonstersCustom;
2134 end;
2135 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2136 begin
2137 Name := 'edTimeLimit';
2138 OnlyDigits := True;
2139 Width := 4;
2140 MaxLength := 5;
2141 if gcTimeLimit > 0 then
2142 Text := IntToStr(gcTimeLimit);
2143 end;
2144 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2145 begin
2146 Name := 'edGoalLimit';
2147 OnlyDigits := True;
2148 Width := 4;
2149 MaxLength := 5;
2150 if gcGoalLimit > 0 then
2151 Text := IntToStr(gcGoalLimit);
2152 end;
2153 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2154 begin
2155 Name := 'edMaxLives';
2156 OnlyDigits := True;
2157 Width := 4;
2158 MaxLength := 5;
2159 if gcMaxLives > 0 then
2160 Text := IntToStr(gcMaxLives);
2161 end;
2162 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2163 begin
2164 Name := 'swPlayers';
2165 AddItem(_lc[I_MENU_COUNT_NONE]);
2166 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2167 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2168 ItemIndex := gcPlayers;
2169 end;
2170 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2171 begin
2172 Name := 'swTeamDamage';
2173 AddItem(_lc[I_MENU_YES]);
2174 AddItem(_lc[I_MENU_NO]);
2175 if gcTeamDamage then
2176 ItemIndex := 0
2177 else
2178 ItemIndex := 1;
2179 end;
2180 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2181 begin
2182 Name := 'swEnableExits';
2183 AddItem(_lc[I_MENU_YES]);
2184 AddItem(_lc[I_MENU_NO]);
2185 if gcAllowExit then
2186 ItemIndex := 0
2187 else
2188 ItemIndex := 1;
2189 end;
2190 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2191 begin
2192 Name := 'swWeaponStay';
2193 AddItem(_lc[I_MENU_YES]);
2194 AddItem(_lc[I_MENU_NO]);
2195 if gcWeaponStay then
2196 ItemIndex := 0
2197 else
2198 ItemIndex := 1;
2199 end;
2200 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2201 begin
2202 Name := 'swMonsters';
2203 AddItem(_lc[I_MENU_YES]);
2204 AddItem(_lc[I_MENU_NO]);
2205 if gcMonsters then
2206 ItemIndex := 0
2207 else
2208 ItemIndex := 1;
2209 end;
2210 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2211 begin
2212 Name := 'swBotsVS';
2213 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2214 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2215 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2216 ItemIndex := 2;
2217 if gcBotsVS = 'Players' then
2218 ItemIndex := 0;
2219 if gcBotsVS = 'Monsters' then
2220 ItemIndex := 1;
2221 end;
2222 AddSpace();
2223 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2225 ReAlign();
2226 end;
2227 Menu.DefControl := 'mCustomGameMenu';
2228 g_GUI_AddWindow(Menu);
2230 Menu := TGUIWindow.Create('CampaignMenu');
2231 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2232 begin
2233 Name := 'mCampaignMenu';
2235 AddSpace();
2236 AddSpace();
2237 AddSpace();
2238 AddSpace();
2239 AddSpace();
2240 AddSpace();
2242 with AddFileList('', 15, 4) do
2243 begin
2244 Name := 'lsWAD';
2245 OnChange := ProcSelectCampaignWAD;
2247 Sort := True;
2248 Dirs := True;
2249 FileMask := '*.wad|*.pk3|*.zip';
2250 SetBase(MapsDir+'megawads/');
2251 end;
2253 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2254 begin
2255 Name := 'lbWADName';
2256 FixedLength := 8;
2257 Enabled := False;
2258 end;
2259 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2260 begin
2261 Name := 'lbWADAuthor';
2262 FixedLength := 8;
2263 Enabled := False;
2264 end;
2265 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2266 with AddMemo('', 15, 3) do
2267 begin
2268 Name := 'meWADDescription';
2269 Color := MENU_ITEMSCTRL_COLOR;
2270 end;
2271 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2272 begin
2273 Name := 'swPlayers';
2274 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2275 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2276 end;
2277 AddSpace();
2278 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2280 ReAlign();
2282 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2283 begin
2284 Name := 'mpWADImage';
2285 DefaultRes := 'NOPIC';
2286 X := GetControl('lsWAD').X+4;
2287 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2288 end;
2289 end;
2290 Menu.DefControl := 'mCampaignMenu';
2291 g_GUI_AddWindow(Menu);
2293 Menu := TGUIWindow.Create('SelectMapMenu');
2294 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2295 begin
2296 Name := 'mSelectMapMenu';
2297 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2298 begin
2299 Name := 'lsMapWAD';
2300 OnChange := ProcSelectWAD;
2302 Sort := True;
2303 Dirs := True;
2304 FileMask := '*.wad|*.pk3|*.zip';
2305 SetBase(MapsDir);
2306 end;
2307 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2308 begin
2309 Name := 'lsMapRes';
2310 Sort := True;
2311 OnChange := ProcSelectMap;
2312 end;
2313 AddSpace();
2314 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2315 begin
2316 Name := 'lbMapName';
2317 FixedLength := 24;
2318 Enabled := False;
2319 end;
2320 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2321 begin
2322 Name := 'lbMapAuthor';
2323 FixedLength := 16;
2324 Enabled := False;
2325 end;
2326 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2327 begin
2328 Name := 'lbMapSize';
2329 FixedLength := 10;
2330 Enabled := False;
2331 end;
2332 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2333 begin
2334 Name := 'meMapDescription';
2335 end;
2337 ReAlign();
2339 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2340 begin
2341 Name := 'mpMapPreview';
2342 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2343 Y := GetControl('lsMapWAD').Y;
2344 end;
2345 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2346 begin
2347 Name := 'lbMapScale';
2348 FixedLength := 8;
2349 Enabled := False;
2350 Color := MENU_ITEMSCTRL_COLOR;
2351 X := GetControl('lsMapWAD').X +
2352 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2353 2 + MAPPREVIEW_WIDTH*4;
2354 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2355 end;
2356 end;
2357 Menu.OnClose := ProcSetMap;
2358 Menu.DefControl := 'mSelectMapMenu';
2359 g_GUI_AddWindow(Menu);
2361 Menu := TGUIWindow.Create('OptionsMenu');
2362 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2363 begin
2364 Name := 'mmOptionsMenu';
2365 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2366 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2367 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2368 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2369 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2370 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2371 AddSpace();
2372 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2373 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2374 end;
2375 Menu.OnClose := ProcApplyOptions;
2376 Menu.DefControl := 'mmOptionsMenu';
2377 g_GUI_AddWindow(Menu);
2379 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2380 gMenuSmallFont, @ProcSavedMenuKeyDown);
2381 g_GUI_AddWindow(Menu);
2383 Menu := TGUIWindow.Create('OptionsVideoMenu');
2384 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2385 begin
2386 Name := 'mOptionsVideoMenu';
2387 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2388 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2389 begin
2390 Name := 'swBPP';
2391 AddItem('16');
2392 AddItem('32');
2393 end;
2394 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2395 begin
2396 Name := 'swVSync';
2397 AddItem(_lc[I_MENU_YES]);
2398 AddItem(_lc[I_MENU_NO]);
2399 end;
2400 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2401 begin
2402 Name := 'swTextureFilter';
2403 AddItem(_lc[I_MENU_YES]);
2404 AddItem(_lc[I_MENU_NO]);
2405 end;
2406 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2407 begin
2408 Name := 'swLegacyNPOT';
2409 AddItem(_lc[I_MENU_NO]);
2410 AddItem(_lc[I_MENU_YES]);
2411 end;
2412 AddSpace();
2413 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2414 ReAlign();
2415 end;
2416 Menu.DefControl := 'mOptionsVideoMenu';
2417 g_GUI_AddWindow(Menu);
2419 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2420 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2421 begin
2422 Name := 'mOptionsVideoResMenu';
2423 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2424 begin
2425 Name := 'lbCurrentRes';
2426 FixedLength := 24;
2427 Enabled := False;
2428 end;
2429 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2430 begin
2431 Name := 'lsResolution';
2432 Sort := False;
2433 end;
2434 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2435 begin
2436 Name := 'swFullScreen';
2437 AddItem(_lc[I_MENU_YES]);
2438 AddItem(_lc[I_MENU_NO]);
2439 end;
2440 AddSpace();
2441 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2442 UpdateIndex();
2443 end;
2444 Menu.DefControl := 'mOptionsVideoResMenu';
2445 g_GUI_AddWindow(Menu);
2447 Menu := TGUIWindow.Create('OptionsSoundMenu');
2448 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2449 begin
2450 Name := 'mOptionsSoundMenu';
2451 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2452 begin
2453 Name := 'scMusicLevel';
2454 Max := 16;
2455 OnChange := ProcChangeSoundSettings;
2456 end;
2457 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2458 begin
2459 Name := 'scSoundLevel';
2460 Max := 16;
2461 OnChange := ProcChangeSoundSettings;
2462 end;
2463 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2464 begin
2465 Name := 'scMaxSimSounds';
2466 Max := 16;
2467 end;
2468 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2469 begin;
2470 Name := 'swAnnouncer';
2471 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2472 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2473 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2474 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2475 end;
2476 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2477 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2478 begin;
2479 Name := 'swSoundEffects';
2480 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2481 AddItem(_lc[I_MENU_COMPAT_DF]);
2482 end;
2483 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2484 begin
2485 Name := 'swInactiveSounds';
2486 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2487 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2488 end;
2489 ReAlign();
2490 end;
2491 Menu.DefControl := 'mOptionsSoundMenu';
2492 g_GUI_AddWindow(Menu);
2494 Menu := TGUIWindow.Create('OptionsGameMenu');
2495 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2496 begin
2497 Name := 'mOptionsGameMenu';
2498 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2499 begin
2500 Name := 'scParticlesCount';
2501 Max := 20;
2502 end;
2503 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2504 begin
2505 Name := 'swBloodCount';
2506 AddItem(_lc[I_MENU_COUNT_NONE]);
2507 AddItem(_lc[I_MENU_COUNT_SMALL]);
2508 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2509 AddItem(_lc[I_MENU_COUNT_BIG]);
2510 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2511 end;
2512 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2513 begin
2514 Name := 'scShellsMax';
2515 Max := 20;
2516 end;
2517 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2518 begin
2519 Name := 'scGibsMax';
2520 Max := 20;
2521 end;
2522 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2523 begin
2524 Name := 'scCorpsesMax';
2525 Max := 20;
2526 end;
2527 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2528 begin
2529 Name := 'swGibsCount';
2530 AddItem(_lc[I_MENU_COUNT_NONE]);
2531 AddItem(_lc[I_MENU_COUNT_SMALL]);
2532 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2533 AddItem(_lc[I_MENU_COUNT_BIG]);
2534 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2535 end;
2536 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2537 begin
2538 Name := 'swCorpseType';
2539 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2540 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2541 end;
2542 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2543 begin
2544 Name := 'swGibsType';
2545 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2546 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2547 end;
2548 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2549 begin
2550 Name := 'swBloodType';
2551 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2552 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2553 end;
2554 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2555 begin
2556 Name := 'swScreenFlash';
2557 AddItem(_lc[I_MENU_NO]);
2558 AddItem(_lc[I_MENU_COMPAT_DF]);
2559 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2560 end;
2561 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2562 begin
2563 Name := 'swBackground';
2564 AddItem(_lc[I_MENU_YES]);
2565 AddItem(_lc[I_MENU_NO]);
2566 end;
2567 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2568 begin
2569 Name := 'swMessages';
2570 AddItem(_lc[I_MENU_YES]);
2571 AddItem(_lc[I_MENU_NO]);
2572 end;
2573 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2574 begin
2575 Name := 'swRevertPlayers';
2576 AddItem(_lc[I_MENU_YES]);
2577 AddItem(_lc[I_MENU_NO]);
2578 end;
2579 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2580 begin
2581 Name := 'swChatBubble';
2582 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2583 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2584 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2585 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2586 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2587 end;
2588 ReAlign();
2589 end;
2590 Menu.DefControl := 'mOptionsGameMenu';
2591 g_GUI_AddWindow(Menu);
2593 Menu := TGUIWindow.Create('OptionsControlsMenu');
2594 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2595 begin
2596 Name := 'mOptionsControlsMenu';
2597 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2598 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2599 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2600 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2601 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2602 AddSpace();
2603 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsControlsP1Menu');
2604 AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');
2605 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsControlsP2Menu');
2606 AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');
2607 AddSpace();
2608 if e_JoysticksAvailable <> 0 then
2609 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2610 end;
2611 Menu.DefControl := 'mOptionsControlsMenu';
2612 g_GUI_AddWindow(Menu);
2614 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2615 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1]))) do
2616 begin
2617 Name := 'mOptionsControlsP1Menu';
2618 AddKeyRead(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2619 AddKeyRead(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2620 AddKeyRead(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2621 AddKeyRead(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2622 AddKeyRead(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2623 AddKeyRead(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2624 AddKeyRead(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2625 AddKeyRead(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2626 AddKeyRead(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2627 end;
2628 Menu.DefControl := 'mOptionsControlsP1Menu';
2629 g_GUI_AddWindow(Menu);
2631 Menu := TGUIWindow.Create('OptionsControlsP1MenuAlt');
2632 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1]))) do
2633 begin
2634 Name := 'mOptionsControlsP1MenuAlt';
2635 AddKeyRead(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2636 AddKeyRead(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2637 AddKeyRead(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2638 AddKeyRead(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2639 AddKeyRead(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2640 AddKeyRead(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2641 AddKeyRead(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2642 AddKeyRead(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2643 AddKeyRead(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2644 AddKeyRead(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2645 end;
2646 Menu.DefControl := 'mOptionsControlsP1MenuAlt';
2647 g_GUI_AddWindow(Menu);
2649 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2650 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2]))) do
2651 begin
2652 Name := 'mOptionsControlsP2Menu';
2653 AddKeyRead(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2654 AddKeyRead(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2655 AddKeyRead(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2656 AddKeyRead(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2657 AddKeyRead(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2658 AddKeyRead(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2659 AddKeyRead(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2660 AddKeyRead(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2661 AddKeyRead(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2662 end;
2663 Menu.DefControl := 'mOptionsControlsP2Menu';
2664 g_GUI_AddWindow(Menu);
2666 Menu := TGUIWindow.Create('OptionsControlsP2MenuAlt');
2667 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2]))) do
2668 begin
2669 Name := 'mOptionsControlsP2MenuAlt';
2670 AddKeyRead(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2671 AddKeyRead(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2672 AddKeyRead(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2673 AddKeyRead(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2674 AddKeyRead(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2675 AddKeyRead(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2676 AddKeyRead(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2677 AddKeyRead(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2678 AddKeyRead(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2679 AddKeyRead(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2680 end;
2681 Menu.DefControl := 'mOptionsControlsP2MenuAlt';
2682 g_GUI_AddWindow(Menu);
2684 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2685 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2686 begin
2687 Name := 'mOptionsControlsJoystickMenu';
2688 for i := 0 to e_JoysticksAvailable-1 do
2689 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2690 begin
2691 Name := 'scDeadzone' + IntToStr(i);
2692 Max := 20;
2693 end;
2694 end;
2695 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2696 g_GUI_AddWindow(Menu);
2698 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2699 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2700 begin
2701 Name := 'mOptionsPlayersMenu';
2702 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2703 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2704 end;
2705 Menu.DefControl := 'mOptionsPlayersMenu';
2706 g_GUI_AddWindow(Menu);
2708 CreatePlayerOptionsMenu('P1');
2709 CreatePlayerOptionsMenu('P2');
2711 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2712 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2713 begin
2714 Name := 'mOptionsPlayersMIMenu';
2715 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2716 begin
2717 Name := 'lbName';
2718 FixedLength := 16;
2719 end;
2720 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2721 begin
2722 Name := 'lbAuthor';
2723 FixedLength := 16;
2724 end;
2725 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2726 begin
2727 Name := 'meComment';
2728 end;
2729 AddSpace();
2730 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2731 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2732 begin
2733 Name := 'lbWeapon';
2734 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2735 end;
2736 ReAlign();
2737 end;
2738 Menu.DefControl := 'mOptionsPlayersMIMenu';
2739 g_GUI_AddWindow(Menu);
2741 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2742 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2743 begin
2744 Name := 'mOptionsLanguageMenu';
2745 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2746 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2747 ReAlign();
2748 end;
2749 Menu.DefControl := 'mOptionsLanguageMenu';
2750 g_GUI_AddWindow(Menu);
2752 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2753 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2754 g_GUI_AddWindow(Menu);
2756 Menu := TGUIWindow.Create('AuthorsMenu');
2757 Menu.BackTexture := 'INTER';
2758 Menu.OnClose := ProcAuthorsClose;
2760 // Çàãîëîâîê:
2761 _y := 16;
2762 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2763 begin
2764 Color := _RGB(255, 0, 0);
2765 X := (gScreenWidth div 2)-(GetWidth() div 2);
2766 Y := _y;
2767 _y := _y+GetHeight();
2768 end;
2769 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2770 begin
2771 Color := _RGB(255, 0, 0);
2772 X := (gScreenWidth div 2)-(GetWidth() div 2);
2773 Y := _y;
2774 _y := _y+GetHeight()+32;
2775 end;
2776 // ×òî äåëàë: Êòî äåëàë
2777 cx := gScreenWidth div 2 - 320 + 64;
2778 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
2779 begin
2780 Color := _RGB(255, 0, 0);
2781 X := cx;
2782 Y := _y;
2783 _y := _y+22;
2784 end;
2785 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
2786 begin
2787 Color := _RGB(255, 255, 255);
2788 X := cx+32;
2789 Y := _y;
2790 _y := _y+36;
2791 end;
2792 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
2793 begin
2794 Color := _RGB(255, 0, 0);
2795 X := cx;
2796 Y := _y;
2797 _y := _y+22;
2798 end;
2799 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
2800 begin
2801 Color := _RGB(255, 255, 255);
2802 X := cx+32;
2803 Y := _y;
2804 _y := _y+22;
2805 end;
2806 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
2807 begin
2808 Color := _RGB(255, 255, 255);
2809 X := cx+32;
2810 Y := _y;
2811 _y := _y+36;
2812 end;
2813 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
2814 begin
2815 Color := _RGB(255, 0, 0);
2816 X := cx;
2817 Y := _y;
2818 _y := _y+22;
2819 end;
2820 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
2821 begin
2822 Color := _RGB(255, 255, 255);
2823 X := cx+32;
2824 Y := _y;
2825 _y := _y+36;
2826 end;
2827 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
2828 begin
2829 Color := _RGB(255, 0, 0);
2830 X := cx;
2831 Y := _y;
2832 _y := _y+22;
2833 end;
2834 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
2835 begin
2836 Color := _RGB(255, 255, 255);
2837 X := cx+32;
2838 Y := _y;
2839 _y := gScreenHeight - 128;
2840 end;
2841 // Çàêëþ÷åíèå:
2842 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
2843 begin
2844 Color := _RGB(255, 0, 0);
2845 X := cx;
2846 Y := _y;
2847 _y := _y+16;
2848 end;
2849 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
2850 begin
2851 Color := _RGB(255, 255, 255);
2852 X := cx+32;
2853 Y := _y;
2854 _y := _y+GetHeight();
2855 end;
2856 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
2857 begin
2858 Color := _RGB(255, 255, 255);
2859 X := cx+32;
2860 Y := _y;
2861 _y := _y+GetHeight();
2862 end;
2863 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
2864 begin
2865 Color := _RGB(255, 255, 255);
2866 X := cx+32;
2867 Y := _y;
2868 _y := gScreenHeight - 32;
2869 end;
2870 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
2871 begin
2872 Color := _RGB(255, 0, 0);
2873 X := gScreenWidth div 2 - GetWidth() div 2;
2874 Y := _y;
2875 end;
2876 g_GUI_AddWindow(Menu);
2878 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
2879 gMenuSmallFont, @ProcExitMenuKeyDown);
2880 g_GUI_AddWindow(Menu);
2882 Menu := TGUIWindow.Create('GameSingleMenu');
2883 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2884 begin
2885 Name := 'mmGameSingleMenu';
2886 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2887 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2888 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2889 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2890 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2891 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2892 end;
2893 Menu.DefControl := 'mmGameSingleMenu';
2894 Menu.MainWindow := True;
2895 Menu.OnClose := ProcGMClose;
2896 Menu.OnShow := ProcGMShow;
2897 g_GUI_AddWindow(Menu);
2899 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
2900 gMenuSmallFont, @ProcEndMenuKeyDown);
2901 g_GUI_AddWindow(Menu);
2903 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
2904 gMenuSmallFont, @ProcRestartMenuKeyDown);
2905 g_GUI_AddWindow(Menu);
2907 Menu := TGUIWindow.Create('GameCustomMenu');
2908 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2909 begin
2910 Name := 'mmGameCustomMenu';
2911 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2912 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2913 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2914 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2915 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2916 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2917 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2918 end;
2919 Menu.DefControl := 'mmGameCustomMenu';
2920 Menu.MainWindow := True;
2921 Menu.OnClose := ProcGMClose;
2922 Menu.OnShow := ProcGMShow;
2923 g_GUI_AddWindow(Menu);
2925 Menu := TGUIWindow.Create('GameServerMenu');
2926 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2927 begin
2928 Name := 'mmGameServerMenu';
2929 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2930 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2931 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2932 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2933 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2934 end;
2935 Menu.DefControl := 'mmGameServerMenu';
2936 Menu.MainWindow := True;
2937 Menu.OnClose := ProcGMClose;
2938 Menu.OnShow := ProcGMShow;
2939 g_GUI_AddWindow(Menu);
2941 Menu := TGUIWindow.Create('GameClientMenu');
2942 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2943 begin
2944 Name := 'mmGameClientMenu';
2945 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2946 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2947 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2948 end;
2949 Menu.DefControl := 'mmGameClientMenu';
2950 Menu.MainWindow := True;
2951 Menu.OnClose := ProcGMClose;
2952 Menu.OnShow := ProcGMShow;
2953 g_GUI_AddWindow(Menu);
2955 Menu := TGUIWindow.Create('ClientPasswordMenu');
2956 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
2957 begin
2958 Name := 'mClientPasswordMenu';
2959 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2960 begin
2961 Name := 'edPW';
2962 Width := 12;
2963 MaxLength := 32;
2964 end;
2965 AddSpace;
2967 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
2968 ReAlign();
2969 end;
2970 Menu.DefControl := 'mClientPasswordMenu';
2971 g_GUI_AddWindow(Menu);
2973 Menu := TGUIWindow.Create('GameSetGameMenu');
2974 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
2975 begin
2976 Name := 'mGameSetGameMenu';
2977 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2978 begin
2979 Name := 'swTeamDamage';
2980 AddItem(_lc[I_MENU_YES]);
2981 AddItem(_lc[I_MENU_NO]);
2982 ItemIndex := 1;
2983 end;
2984 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2985 begin
2986 Name := 'edTimeLimit';
2987 OnlyDigits := True;
2988 Width := 4;
2989 MaxLength := 5;
2990 end;
2991 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2992 begin
2993 Name := 'edGoalLimit';
2994 OnlyDigits := True;
2995 Width := 4;
2996 MaxLength := 5;
2997 end;
2998 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2999 begin
3000 Name := 'edMaxLives';
3001 OnlyDigits := True;
3002 Width := 4;
3003 MaxLength := 5;
3004 end;
3005 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3006 begin
3007 Name := 'swBotsVS';
3008 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3009 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3010 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3011 ItemIndex := 2;
3012 end;
3014 ReAlign();
3015 end;
3016 Menu.DefControl := 'mGameSetGameMenu';
3017 Menu.OnClose := ProcApplyGameSet;
3018 g_GUI_AddWindow(Menu);
3020 Menu := TGUIWindow.Create('TeamMenu');
3021 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3022 begin
3023 Name := 'mmTeamMenu';
3024 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3025 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3026 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3027 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3028 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3029 end;
3030 Menu.DefControl := 'mmTeamMenu';
3031 Menu.OnShow := ProcChangePlayers;
3032 g_GUI_AddWindow(Menu);
3033 end;
3035 procedure g_Menu_Show_SaveMenu();
3036 begin
3037 if g_Game_IsTestMap then
3038 Exit;
3039 if gGameSettings.GameType = GT_SINGLE then
3040 g_GUI_ShowWindow('GameSingleMenu')
3041 else
3042 begin
3043 if g_Game_IsClient then
3044 Exit
3045 else
3046 if g_Game_IsNet then
3047 Exit
3048 else
3049 g_GUI_ShowWindow('GameCustomMenu');
3050 end;
3051 g_GUI_ShowWindow('SaveMenu');
3052 g_Sound_PlayEx('MENU_OPEN');
3053 end;
3055 procedure g_Menu_Show_LoadMenu();
3056 begin
3057 if gGameSettings.GameType = GT_SINGLE then
3058 g_GUI_ShowWindow('GameSingleMenu')
3059 else
3060 begin
3061 if g_Game_IsClient then
3062 Exit
3063 else
3064 if g_Game_IsNet then
3065 Exit
3066 else
3067 g_GUI_ShowWindow('GameCustomMenu');
3068 end;
3069 g_GUI_ShowWindow('LoadMenu');
3070 g_Sound_PlayEx('MENU_OPEN');
3071 end;
3073 procedure g_Menu_Show_GameSetGame();
3074 begin
3075 if gGameSettings.GameType = GT_SINGLE then
3076 g_GUI_ShowWindow('GameSingleMenu')
3077 else
3078 begin
3079 if g_Game_IsClient then
3080 Exit
3081 else
3082 if g_Game_IsNet then
3083 g_GUI_ShowWindow('GameServerMenu')
3084 else
3085 g_GUI_ShowWindow('GameCustomMenu');
3086 end;
3087 ReadGameSettings();
3088 g_GUI_ShowWindow('GameSetGameMenu');
3089 g_Sound_PlayEx('MENU_OPEN');
3090 end;
3092 procedure g_Menu_Show_OptionsVideo();
3093 begin
3094 if gGameSettings.GameType = GT_SINGLE then
3095 g_GUI_ShowWindow('GameSingleMenu')
3096 else
3097 begin
3098 if g_Game_IsClient then
3099 g_GUI_ShowWindow('GameClientMenu')
3100 else
3101 if g_Game_IsNet then
3102 g_GUI_ShowWindow('GameServerMenu')
3103 else
3104 g_GUI_ShowWindow('GameCustomMenu');
3105 end;
3106 ReadOptions();
3107 g_GUI_ShowWindow('OptionsMenu');
3108 g_GUI_ShowWindow('OptionsVideoMenu');
3109 g_Sound_PlayEx('MENU_OPEN');
3110 end;
3112 procedure g_Menu_Show_OptionsSound();
3113 begin
3114 if gGameSettings.GameType = GT_SINGLE then
3115 g_GUI_ShowWindow('GameSingleMenu')
3116 else
3117 begin
3118 if g_Game_IsClient then
3119 g_GUI_ShowWindow('GameClientMenu')
3120 else
3121 if g_Game_IsNet then
3122 g_GUI_ShowWindow('GameServerMenu')
3123 else
3124 g_GUI_ShowWindow('GameCustomMenu');
3125 end;
3126 ReadOptions();
3127 g_GUI_ShowWindow('OptionsMenu');
3128 g_GUI_ShowWindow('OptionsSoundMenu');
3129 g_Sound_PlayEx('MENU_OPEN');
3130 end;
3132 procedure g_Menu_Show_EndGameMenu();
3133 begin
3134 g_GUI_ShowWindow('EndGameMenu');
3135 g_Sound_PlayEx('MENU_OPEN');
3136 end;
3138 procedure g_Menu_Show_QuitGameMenu();
3139 begin
3140 g_GUI_ShowWindow('ExitMenu');
3141 g_Sound_PlayEx('MENU_OPEN');
3142 end;
3144 procedure g_Menu_Init();
3145 begin
3146 MenuLoadData();
3147 g_GUI_Init();
3148 CreateAllMenus();
3149 end;
3151 procedure g_Menu_Free();
3152 begin
3153 g_GUI_Destroy();
3155 e_WriteLog('Releasing menu data...', MSG_NOTIFY);
3157 MenuFreeData();
3158 end;
3160 procedure g_Menu_Reset();
3161 var
3162 ex: Boolean;
3163 begin
3164 g_GUI_SaveMenuPos();
3165 ex := g_GUI_Destroy();
3167 if ex then
3168 begin
3169 e_WriteLog('Recreating menu...', MSG_NOTIFY);
3171 CreateAllMenus();
3173 if gDebugMode then
3174 g_Game_SetDebugMode();
3176 g_GUI_LoadMenuPos();
3177 end;
3178 end;
3180 end.