DEADSOFTWARE

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