DEADSOFTWARE

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