DEADSOFTWARE

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