DEADSOFTWARE

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