DEADSOFTWARE

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