DEADSOFTWARE

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