DEADSOFTWARE

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