DEADSOFTWARE

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