DEADSOFTWARE

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