DEADSOFTWARE

vsync option should be applied without restarting now
[d2df-sdl.git] / src / game / g_menu.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_menu;
19 interface
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
25 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
36 var
37 gMenuFont: DWORD;
38 gMenuSmallFont: DWORD;
39 PromptIP: string;
40 PromptPort: Word;
42 implementation
44 uses
45 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
46 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
47 e_log, SysUtils, CONFIG, g_playermodel, DateUtils, sdl2,
48 MAPDEF, Math, g_saveload,
49 e_texture, GL, GLExt, g_language,
50 g_net, g_netmsg, g_netmaster, g_items, e_input,
51 utils, wadreader;
54 type TYNCallback = procedure (yes:Boolean);
56 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
57 begin
58 if win.UserData = nil then exit;
59 case Key of
60 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
61 IK_N: TYNCallback(win.UserData)(false);
62 end;
63 end;
65 procedure YesButtonCB (ctl: TGUITextButton);
66 begin
67 if ctl.UserData = nil then exit;
68 TYNCallback(ctl.UserData)(true);
69 end;
71 procedure NoButtonCB (ctl: TGUITextButton);
72 begin
73 if ctl.UserData = nil then exit;
74 TYNCallback(ctl.UserData)(false);
75 end;
77 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
78 var
79 menu: TGUIMenu;
80 begin
81 //if length(Text) = 0 then exit;
82 Result := TGUIWindow.Create(WinName);
83 with Result do
84 begin
85 //OnKeyDownEx := @YNKeyDownProc;
86 //UserData := @ActionProc;
87 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
88 with menu do
89 begin
90 Name := '__temp_yes_no_menu:'+WinName;
91 YesNo := true;
92 AddText(Text, MaxLen);
93 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
94 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
95 end;
96 DefControl := '__temp_yes_no_menu:'+WinName;
97 SetActive(nil);
98 end;
99 end;
102 procedure ProcChangeColor(Sender: TGUIControl); forward;
103 procedure ProcSelectModel(Sender: TGUIControl); forward;
105 procedure ProcApplyOptions();
106 var
107 menu: TGUIMenu;
108 i: Integer;
109 ovs: Boolean;
110 v: Byte;
111 begin
112 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
114 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
115 gBPP := 16
116 else
117 gBPP := 32;
119 ovs := gVSync;
120 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
121 {$IF not DEFINED(HEADLESS)}
122 if (ovs <> gVSync) then
123 begin
124 if (gVSync) then v := 1 else v := 0;
125 if (SDL_GL_SetSwapInterval(v) <> 0) then writeln('oops; can''t change vsync option, restart required')
126 else writeln('vsync changed');
127 end;
128 {$ENDIF}
130 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
131 glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
133 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
135 g_Sound_SetupAllVolumes(
136 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
137 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
138 );
140 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
141 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
142 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
143 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
144 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
146 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
148 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
149 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
150 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
151 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
153 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
154 0: gGibsCount := 0;
155 1: gGibsCount := 8;
156 2: gGibsCount := 16;
157 3: gGibsCount := 32;
158 else gGibsCount := 48;
159 end;
161 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
162 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
163 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
164 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
165 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
166 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
167 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
168 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
169 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
171 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
173 with menu, gGameControls.GameControls do
174 begin
175 TakeScreenshot := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key;
176 Stat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key;
177 Chat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key;
178 TeamChat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key;
179 end;
181 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
182 with menu, gGameControls.P1Control do
183 begin
184 KeyRight := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0;
185 KeyLeft := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0;
186 KeyUp := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0;
187 KeyDown := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0;
188 KeyFire := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0;
189 KeyJump := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0;
190 KeyNextWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0;
191 KeyPrevWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0;
192 KeyOpen := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0;
193 KeyStrafe := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0;
194 // second set
195 KeyRight2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1;
196 KeyLeft2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1;
197 KeyUp2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1;
198 KeyDown2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1;
199 KeyFire2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1;
200 KeyJump2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1;
201 KeyNextWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1;
202 KeyPrevWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1;
203 KeyOpen2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1;
204 KeyStrafe2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1;
205 end;
207 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
208 with menu, gGameControls.P1Control do
209 begin
210 for i := WP_FIRST to WP_LAST do
211 begin
212 KeyWeapon[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0;
213 KeyWeapon2[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1;
214 end;
215 end;
217 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
218 with menu, gGameControls.P2Control do
219 begin
220 KeyRight := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0;
221 KeyLeft := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0;
222 KeyUp := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0;
223 KeyDown := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0;
224 KeyFire := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0;
225 KeyJump := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0;
226 KeyNextWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0;
227 KeyPrevWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0;
228 KeyOpen := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0;
229 KeyStrafe := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0;
230 // second set
231 KeyRight2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1;
232 KeyLeft2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1;
233 KeyUp2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1;
234 KeyDown2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1;
235 KeyFire2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1;
236 KeyJump2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1;
237 KeyNextWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1;
238 KeyPrevWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1;
239 KeyOpen2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1;
240 KeyStrafe2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1;
241 end;
243 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
244 with menu, gGameControls.P2Control do
245 begin
246 for i := WP_FIRST to WP_LAST do
247 begin
248 KeyWeapon[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0;
249 KeyWeapon2[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1;
250 end;
251 end;
253 if e_JoysticksAvailable > 0 then
254 begin
255 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
256 with menu do
257 begin
258 for i := 0 to e_JoysticksAvailable-1 do
259 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20);
260 end;
261 end;
263 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
265 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
266 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
267 TEAM_RED, TEAM_BLUE);
269 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
270 begin
271 gPlayer1Settings.Model := Model.Name;
272 gPlayer1Settings.Color := Model.Color;
273 end;
275 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
277 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
278 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
279 TEAM_RED, TEAM_BLUE);
280 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
281 begin
282 gPlayer2Settings.Model := Model.Name;
283 gPlayer2Settings.Color := Model.Color;
284 end;
286 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := 'Player1';
287 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := 'Player2';
289 if g_Game_IsServer then
290 begin
291 if gPlayer1 <> nil then
292 begin
293 gPlayer1.SetModel(gPlayer1Settings.Model);
294 gPlayer1.Name := gPlayer1Settings.Name;
295 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
296 gPlayer1.SetColor(gPlayer1Settings.Color)
297 else
298 if gPlayer1.Team <> gPlayer1Settings.Team then
299 gPlayer1.SwitchTeam;
301 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
302 end;
304 if gPlayer2 <> nil then
305 begin
306 gPlayer2.SetModel(gPlayer2Settings.Model);
307 gPlayer2.Name := gPlayer2Settings.Name;
308 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
309 gPlayer2.SetColor(gPlayer2Settings.Color)
310 else
311 if gPlayer2.Team <> gPlayer2Settings.Team then
312 gPlayer2.SwitchTeam;
313 end;
314 end;
316 if g_Game_IsClient then MC_SEND_PlayerSettings;
318 g_Options_Write(GameDir+'/'+CONFIG_FILENAME);
319 end;
321 procedure ReadOptions();
322 var
323 menu: TGUIMenu;
324 i: Integer;
325 begin
326 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
328 with TGUISwitch(menu.GetControl('swBPP')) do
329 if gBPP = 16 then
330 ItemIndex := 0
331 else
332 ItemIndex := 1;
334 with TGUISwitch(menu.GetControl('swTextureFilter')) do
335 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
337 with TGUISwitch(menu.GetControl('swVSync')) do
338 if gVSync then ItemIndex := 0 else ItemIndex := 1;
340 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
341 if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1;
343 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
345 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
346 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
347 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
349 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
350 if gMuteWhenInactive then
351 ItemIndex := 1
352 else
353 ItemIndex := 0;
355 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
357 with TGUISwitch(menu.GetControl('swSoundEffects')) do
358 if gSoundEffectsDF then
359 ItemIndex := 1
360 else
361 ItemIndex := 0;
363 with TGUISwitch(menu.GetControl('swChatSpeech')) do
364 if gUseChatSounds then
365 ItemIndex := 0
366 else
367 ItemIndex := 1;
369 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
370 with menu, gGameControls.P1Control do
371 begin
372 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := KeyRight;
373 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := KeyLeft;
374 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := KeyUp;
375 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := KeyDown;
376 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := KeyFire;
377 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := KeyJump;
378 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := KeyNextWeapon;
379 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := KeyPrevWeapon;
380 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := KeyOpen;
381 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := KeyStrafe;
382 // second set
383 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := KeyRight2;
384 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := KeyLeft2;
385 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := KeyUp2;
386 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := KeyDown2;
387 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := KeyFire2;
388 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := KeyJump2;
389 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := KeyNextWeapon2;
390 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := KeyPrevWeapon2;
391 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := KeyOpen2;
392 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := KeyStrafe2;
393 end;
395 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
396 with menu, gGameControls.P1Control do
397 begin
398 for i := WP_FIRST to WP_LAST do
399 begin
400 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := KeyWeapon[i];
401 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := KeyWeapon2[i];
402 end;
403 end;
405 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
406 with menu, gGameControls.P2Control do
407 begin
408 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := KeyRight;
409 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := KeyLeft;
410 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := KeyUp;
411 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := KeyDown;
412 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := KeyFire;
413 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := KeyJump;
414 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := KeyNextWeapon;
415 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := KeyPrevWeapon;
416 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := KeyOpen;
417 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := KeyStrafe;
418 // second set
419 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := KeyRight2;
420 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := KeyLeft2;
421 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := KeyUp2;
422 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := KeyDown2;
423 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := KeyFire2;
424 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := KeyJump2;
425 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := KeyNextWeapon2;
426 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := KeyPrevWeapon2;
427 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := KeyOpen2;
428 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := KeyStrafe2;
429 end;
431 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
432 with menu, gGameControls.P2Control do
433 begin
434 for i := WP_FIRST to WP_LAST do
435 begin
436 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := KeyWeapon[i];
437 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := KeyWeapon2[i];
438 end;
439 end;
441 if e_JoysticksAvailable > 0 then
442 begin
443 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
444 with menu do
445 begin
446 for i := 0 to e_JoysticksAvailable-1 do
447 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20);
448 end;
449 end;
451 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
452 with menu, gGameControls.GameControls do
453 begin
454 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := TakeScreenshot;
455 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := Stat;
456 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := Chat;
457 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := TeamChat;
458 end;
460 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
462 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
463 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
464 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
465 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
466 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
468 with TGUISwitch(menu.GetControl('swScreenFlash')) do
469 ItemIndex := gFlash;
471 with TGUISwitch(menu.GetControl('swBloodType')) do
472 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
474 with TGUISwitch(menu.GetControl('swCorpseType')) do
475 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
477 with TGUISwitch(menu.GetControl('swGibsType')) do
478 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
480 with TGUISwitch(menu.GetControl('swGibsCount')) do
481 case gGibsCount of
482 0: ItemIndex := 0;
483 8: ItemIndex := 1;
484 16: ItemIndex := 2;
485 32: ItemIndex := 3;
486 else ItemIndex := 4;
487 end;
489 with TGUISwitch(menu.GetControl('swBackGround')) do
490 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
492 with TGUISwitch(menu.GetControl('swMessages')) do
493 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
495 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
496 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
498 with TGUISwitch(menu.GetControl('swChatBubble')) do
499 ItemIndex := gChatBubble;
501 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
503 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
504 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
506 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
507 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
509 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
510 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
511 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
513 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
515 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
516 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
518 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
519 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
521 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
522 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
523 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
525 ProcSelectModel(nil);
526 end;
528 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
529 begin
530 // don't turn off monsters in DM
532 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
533 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
534 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
535 else
536 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
539 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
540 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
541 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
542 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
544 end;
546 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
547 begin
548 // don't turn off monsters in DM
550 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
551 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
552 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
553 else
554 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
557 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
558 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
559 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
560 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
562 end;
564 procedure ProcStartCustomGame();
565 var
566 Map: String;
567 GameMode: Byte;
568 Options: LongWord;
569 begin
570 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
571 begin
572 Map := TGUILabel(GetControl('lbMap')).Text;
573 if Map = '' then
574 Exit;
575 if not isWadPath(Map) then
576 Exit;
578 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
579 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
580 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
581 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
582 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
584 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
585 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
586 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
587 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
588 Options := 0;
589 if gcTeamDamage then
590 Options := Options or GAME_OPTION_TEAMDAMAGE;
591 if gcAllowExit then
592 Options := Options or GAME_OPTION_ALLOWEXIT;
593 if gcWeaponStay then
594 Options := Options or GAME_OPTION_WEAPONSTAY;
595 if gcMonsters then
596 Options := Options or GAME_OPTION_MONSTERS;
597 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
599 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
600 1: begin
601 Options := Options or GAME_OPTION_BOTVSMONSTER;
602 gcBotsVS := 'Monsters';
603 end;
604 2: begin
605 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
606 gcBotsVS := 'Everybody';
607 end;
608 else begin
609 Options := Options or GAME_OPTION_BOTVSPLAYER;
610 gcBotsVS := 'Players';
611 end;
612 end;
614 gcMap := Map;
615 end;
617 g_Options_Write_Gameplay_Custom(GameDir+'/'+CONFIG_FILENAME);
619 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
620 gcMaxLives, Options, gcPlayers);
621 end;
624 procedure ProcStartNetGame();
625 var
626 Map: String;
627 GameMode: Byte;
628 Options: LongWord;
629 begin
630 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
631 begin
632 Map := TGUILabel(GetControl('lbMap')).Text;
633 if Map = '' then
634 Exit;
635 if not isWadPath(Map) then
636 Exit;
638 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
639 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
640 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
641 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
642 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
643 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
645 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
646 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
647 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
648 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
649 Options := 0;
650 if gnTeamDamage then
651 Options := Options or GAME_OPTION_TEAMDAMAGE;
652 if gnAllowExit then
653 Options := Options or GAME_OPTION_ALLOWEXIT;
654 if gnWeaponStay then
655 Options := Options or GAME_OPTION_WEAPONSTAY;
656 if gnMonsters then
657 Options := Options or GAME_OPTION_MONSTERS;
658 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
660 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
661 1: begin
662 Options := Options or GAME_OPTION_BOTVSMONSTER;
663 gnBotsVS := 'Monsters';
664 end;
665 2: begin
666 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
667 gnBotsVS := 'Everybody';
668 end;
669 else begin
670 Options := Options or GAME_OPTION_BOTVSPLAYER;
671 gnBotsVS := 'Players';
672 end;
673 end;
675 gnMap := Map;
676 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
677 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
678 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
679 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
680 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
681 end;
683 g_Options_Write_Net_Server(GameDir+'/'+CONFIG_FILENAME);
684 g_Options_Write_Gameplay_Net(GameDir+'/'+CONFIG_FILENAME);
686 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
687 Options, gnPlayers, 0, NetPort);
688 end;
690 procedure ProcConnectNetGame();
691 var
692 PW: String;
693 begin
694 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
695 begin
696 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
697 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
698 PW := TGUIEdit(GetControl('edPW')).Text;
699 end;
701 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
702 g_Game_StartClient(NetClientIP, NetClientPort, PW);
703 end;
705 procedure ProcEnterPassword();
706 var
707 PW: string;
708 begin
709 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
710 begin
711 NetClientIP := PromptIP;
712 NetClientPort := PromptPort;
713 PW := TGUIEdit(GetControl('edPW')).Text;
714 end;
716 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
717 g_Game_StartClient(NetClientIP, NetClientPort, PW);
718 end;
720 procedure ProcServerlist();
721 begin
722 if not NetInitDone then
723 begin
724 if (not g_Net_Init()) then
725 begin
726 g_Console_Add('NET: ERROR: Failed to init ENet!');
727 Exit;
728 end
729 else
730 NetInitDone := True;
731 end;
733 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
735 gState := STATE_SLIST;
736 g_ActiveWindow := nil;
738 slWaitStr := _lc[I_NET_SLIST_WAIT];
740 g_Game_Draw;
741 ReDrawWindow;
743 slReturnPressed := True;
744 if g_Net_Slist_Fetch(slCurrent) then
745 begin
746 if slCurrent = nil then
747 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
748 end
749 else
750 slWaitStr := _lc[I_NET_SLIST_ERROR];
751 end;
753 procedure ProcStartCampaign();
754 var
755 WAD: String;
756 TwoPlayers: Boolean;
757 n: Byte;
758 begin
759 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
760 begin
761 WAD := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
762 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
763 end;
765 if TwoPlayers then
766 n := 2
767 else
768 n := 1;
769 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
770 end;
772 procedure ProcSelectMap(Sender: TGUIControl);
773 var
774 win: TGUIWindow;
775 a: TMapInfo;
776 wad, map, res: String;
777 begin
778 win := g_GUI_GetWindow('SelectMapMenu');
779 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
780 begin
781 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
782 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
784 if (wad = '') or (map = '') then
785 begin // Ýòî íå êàðòà
786 TGUILabel(GetControl('lbMapName')).Text := '';
787 TGUILabel(GetControl('lbMapAuthor')).Text := '';
788 TGUILabel(GetControl('lbMapSize')).Text := '';
789 TGUIMemo(GetControl('meMapDescription')).SetText('');
790 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
791 TGUILabel(win.GetControl('lbMapScale')).Text := '';
792 end
793 else // Ýòî êàðòà
794 begin
795 res := wad+':\'+map;
797 a := g_Map_GetMapInfo(res);
799 TGUILabel(GetControl('lbMapName')).Text := a.Name;
800 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
801 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
802 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
803 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
804 TGUILabel(win.GetControl('lbMapScale')).Text :=
805 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
806 end;
807 end;
808 end;
810 procedure ProcSelectWAD(Sender: TGUIControl);
811 var
812 wad: String;
813 list: SSArray;
814 begin
815 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
816 begin
817 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
819 with TGUIListBox(GetControl('lsMapRes')) do
820 begin
821 Clear();
823 if wad <> '' then
824 begin
825 list := g_Map_GetMapsList(wad);
827 if list <> nil then
828 begin
829 Items := list;
830 ItemIndex := 0;
831 end
832 end;
833 end;
834 end;
836 ProcSelectMap(nil);
837 end;
839 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
840 var
841 win: TGUIWindow;
842 a: TMegaWADInfo;
843 wad, fn: String;
844 begin
845 win := g_GUI_GetWindow('CampaignMenu');
846 with TGUIMenu(win.GetControl('mCampaignMenu')) do
847 begin
848 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
850 if wad = '' then
851 begin
852 TGUILabel(GetControl('lbWADName')).Text := '';
853 TGUILabel(GetControl('lbWADAuthor')).Text := '';
854 TGUIMemo(GetControl('meWADDescription')).SetText('');
855 end;
857 a := g_Game_GetMegaWADInfo(wad);
859 TGUILabel(GetControl('lbWADName')).Text := a.Name;
860 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
861 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
863 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
865 if a.pic <> '' then
866 begin
867 fn := g_ExtractWadName(a.pic);
868 if fn = '' then
869 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
870 else
871 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
872 end;
873 end;
874 end;
876 procedure ProcChangeColor(Sender: TGUIControl);
877 var
878 window: TGUIWindow;
879 begin
880 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
881 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
882 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
883 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
884 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
885 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
887 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
888 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
889 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
890 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
891 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
892 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
893 end;
895 procedure ProcSelectModel(Sender: TGUIControl);
896 var
897 a: string;
898 window: TGUIWindow;
899 begin
900 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
901 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
902 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
904 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
905 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
906 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
908 ProcChangeColor(nil);
909 end;
911 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
912 var
913 cwdt, chgt: Byte;
914 spc: ShortInt;
915 ID: DWORD;
916 wad: TWADFile;
917 cfgdata: Pointer;
918 cfglen: Integer;
919 config: TConfig;
920 begin
921 cfglen := 0;
923 wad := TWADFile.Create;
924 if wad.ReadFile(GameWAD) then
925 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
926 wad.Free();
928 if cfglen <> 0 then
929 begin
930 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
932 config := TConfig.CreateMem(cfgdata, cfglen);
933 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
934 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
935 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
937 if g_Texture_Get('FONT_STD', ID) then
938 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
940 config.Free();
941 end;
943 if cfglen <> 0 then FreeMem(cfgdata);
944 end;
946 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
947 var
948 cwdt, chgt: Byte;
949 spc: ShortInt;
950 CharID: DWORD;
951 wad: TWADFile;
952 cfgdata, fntdata: Pointer;
953 cfglen, fntlen: Integer;
954 config: TConfig;
955 chrwidth: Integer;
956 a: Byte;
957 begin
958 cfglen := 0;
959 fntlen := 0;
961 wad := TWADFile.Create;
962 if wad.ReadFile(GameWAD) then
963 begin
964 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
965 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
966 end;
967 wad.Free();
969 if cfglen <> 0 then
970 begin
971 config := TConfig.CreateMem(cfgdata, cfglen);
972 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
973 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
975 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
976 FontID := e_CharFont_Create(spc);
978 for a := 0 to 255 do
979 begin
980 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
981 if chrwidth = 0 then Continue;
983 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
984 cwdt, chgt) then
985 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
986 end;
988 config.Free();
989 end;
991 if cfglen <> 0 then FreeMem(cfgdata);
992 if fntlen <> 0 then FreeMem(fntdata);
993 end;
995 procedure MenuLoadData();
996 begin
997 e_WriteLog('Loading menu data...', TMsgType.Notify);
999 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1000 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1001 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1002 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1003 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1004 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1005 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1006 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1007 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1008 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1009 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1010 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1011 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1012 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1013 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1014 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1015 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1016 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1017 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1018 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1019 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1020 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1021 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1022 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1024 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1025 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1026 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1027 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1028 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1029 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1030 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1031 end;
1033 procedure MenuFreeData();
1034 begin
1035 e_CharFont_Remove(gMenuFont);
1036 e_CharFont_Remove(gMenuSmallFont);
1038 g_Texture_Delete('MAINMENU_MARKER1');
1039 g_Texture_Delete('MAINMENU_MARKER2');
1040 g_Texture_Delete('SCROLL_LEFT');
1041 g_Texture_Delete('SCROLL_RIGHT');
1042 g_Texture_Delete('SCROLL_MIDDLE');
1043 g_Texture_Delete('SCROLL_MARKER');
1044 g_Texture_Delete('EDIT_LEFT');
1045 g_Texture_Delete('EDIT_RIGHT');
1046 g_Texture_Delete('EDIT_MIDDLE');
1047 g_Texture_Delete('BOX1');
1048 g_Texture_Delete('BOX2');
1049 g_Texture_Delete('BOX3');
1050 g_Texture_Delete('BOX4');
1051 g_Texture_Delete('BOX5');
1052 g_Texture_Delete('BOX6');
1053 g_Texture_Delete('BOX7');
1054 g_Texture_Delete('BOX8');
1055 g_Texture_Delete('BOX9');
1056 g_Texture_Delete('BSCROLL_UP_A');
1057 g_Texture_Delete('BSCROLL_UP_U');
1058 g_Texture_Delete('BSCROLL_DOWN_A');
1059 g_Texture_Delete('BSCROLL_DOWN_U');
1060 g_Texture_Delete('BSCROLL_MIDDLE');
1061 g_Texture_Delete('NOPIC');
1063 g_Sound_Delete('MENU_SELECT');
1064 g_Sound_Delete('MENU_OPEN');
1065 g_Sound_Delete('MENU_CLOSE');
1066 g_Sound_Delete('MENU_CHANGE');
1067 g_Sound_Delete('SCROLL_ADD');
1068 g_Sound_Delete('SCROLL_SUB');
1069 g_Sound_Delete('SOUND_PLAYER_FALL');
1070 end;
1072 procedure ProcAuthorsMenu();
1073 begin
1074 gMusic.SetByName('MUSIC_INTERMUS');
1075 gMusic.Play();
1076 end;
1078 procedure ProcExitMenuKeyDown (yes: Boolean);
1079 var
1080 s: ShortString;
1081 snd: TPlayableSound;
1082 res: Boolean;
1083 begin
1084 if yes then
1085 begin
1086 g_Game_StopAllSounds(True);
1087 case (Random(18)) of
1088 0: s := 'SOUND_MONSTER_PAIN';
1089 1: s := 'SOUND_MONSTER_DIE_3';
1090 2: s := 'SOUND_MONSTER_SLOP';
1091 3: s := 'SOUND_MONSTER_DEMON_DIE';
1092 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1093 5: s := 'SOUND_MONSTER_MAN_DIE';
1094 6: s := 'SOUND_MONSTER_BSP_DIE';
1095 7: s := 'SOUND_MONSTER_VILE_DIE';
1096 8: s := 'SOUND_MONSTER_SKEL_DIE';
1097 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1098 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1099 11: s := 'SOUND_MONSTER_BARON_DIE';
1100 12: s := 'SOUND_MONSTER_CACO_DIE';
1101 13: s := 'SOUND_MONSTER_CYBER_DIE';
1102 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1103 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1104 else s := 'SOUND_PLAYER_FALL';
1105 end;
1106 snd := TPlayableSound.Create();
1107 res := snd.SetByName(s);
1108 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1109 if res then
1110 begin
1111 snd.Play(True);
1112 while snd.IsPlaying() do begin end;
1113 end;
1114 g_Game_Quit();
1115 exit;
1116 end;
1117 g_GUI_HideWindow();
1118 end;
1120 procedure ProcLoadMenu();
1121 var
1122 a: Integer;
1123 valid: Boolean;
1124 begin
1125 for a := 1 to 8 do
1126 begin
1127 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1128 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1129 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1130 end;
1131 end;
1133 procedure ProcSaveMenu();
1134 var
1135 a: Integer;
1136 valid: Boolean;
1137 name: AnsiString;
1138 begin
1139 for a := 1 to 8 do
1140 begin
1141 name := g_GetSaveName(a, valid);
1142 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1143 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1144 end;
1145 end;
1147 procedure ProcSaveGame(Sender: TGUIControl);
1148 var
1149 a: Integer;
1150 begin
1151 if g_Game_IsNet then Exit;
1152 if g_Game_IsTestMap then Exit;
1153 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1154 g_Game_PauseAllSounds(True);
1155 g_SaveGame(a, TGUIEdit(Sender).Text);
1157 g_ActiveWindow := nil;
1158 g_Game_Pause(False);
1159 end;
1161 procedure ProcLoadGame(Sender: TGUIControl);
1162 var
1163 a: Integer;
1164 begin
1165 if g_Game_IsNet then Exit;
1166 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1167 if g_LoadGame(a) then
1168 begin
1169 g_Game_PauseAllSounds(False)
1170 end
1171 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1172 begin
1173 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1174 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1175 //g_ActiveWindow := nil;
1176 end;
1177 end;
1179 procedure ProcSingle1Player();
1180 begin
1181 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1182 end;
1184 procedure ProcSingle2Players();
1185 begin
1186 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1187 end;
1189 procedure ProcSelectMapMenu();
1190 var
1191 menu: TGUIMenu;
1192 wad_lb: TGUIFileListBox;
1193 map_lb: TGUIListBox;
1194 map: String;
1195 begin
1196 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1197 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1198 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1200 if wad_lb.SelectedItem() <> '' then
1201 map := map_lb.SelectedItem()
1202 else
1203 map := '';
1205 wad_lb.UpdateFileList();
1206 map_lb.Clear();
1208 if wad_lb.SelectedItem() <> '' then
1209 begin
1210 ProcSelectWAD(nil);
1211 map_lb.SelectItem(map);
1213 if map_lb.SelectedItem() <> '' then
1214 ProcSelectMap(nil);
1215 end;
1217 g_GUI_ShowWindow('SelectMapMenu');
1218 end;
1220 procedure ProcSelectCampaignMenu();
1221 var
1222 menu: TGUIMenu;
1223 wad_lb: TGUIFileListBox;
1224 begin
1225 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1226 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1228 wad_lb.UpdateFileList();
1230 if wad_lb.SelectedItem() <> '' then
1231 ProcSelectCampaignWAD(nil);
1232 end;
1234 procedure ProcSetMap();
1235 var
1236 wad, map, res: String;
1237 begin
1238 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1239 begin
1240 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1241 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1242 end;
1244 if (wad = '') or (map = '') then
1245 Exit;
1247 res := wad+':\'+map;
1249 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1250 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1251 end;
1253 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1254 var
1255 menu: TGUIMenu;
1256 begin
1257 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1259 g_Sound_SetupAllVolumes(
1260 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1261 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1262 );
1263 end;
1265 procedure ProcOptionsPlayersMIMenu();
1266 var
1267 s, a: string;
1268 b: TModelInfo;
1269 begin
1270 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1272 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1274 if a = '' then Exit;
1276 b := g_PlayerModel_GetInfo(a);
1278 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1279 begin
1280 TGUILabel(GetControl('lbName')).Text := b.Name;
1281 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1282 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1284 if b.HaveWeapon then
1285 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1286 else
1287 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1288 end;
1290 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1291 end;
1293 procedure ProcOptionsPlayersAnim();
1294 var
1295 s: String;
1296 begin
1297 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1298 s := 'P1'
1299 else
1300 s := 'P2';
1302 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1303 begin
1304 NextAnim();
1305 Model.GetCurrentAnimation.Loop := True;
1306 Model.GetCurrentAnimationMask.Loop := True;
1307 end;
1308 end;
1310 procedure ProcOptionsPlayersWeap();
1311 var
1312 s: String;
1313 begin
1314 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1315 s := 'P1'
1316 else
1317 s := 'P2';
1319 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1320 NextWeapon();
1321 end;
1323 procedure ProcOptionsPlayersRot();
1324 var
1325 s: string;
1326 begin
1327 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1328 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1329 begin
1330 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1331 end;
1332 end;
1334 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1335 begin
1336 if yes then
1337 begin
1338 g_Options_SetDefault();
1339 ReadOptions();
1340 end;
1341 g_GUI_HideWindow();
1342 end;
1344 procedure ProcSavedMenuKeyDown (yes: Boolean);
1345 begin
1346 if yes then ReadOptions();
1347 g_GUI_HideWindow();
1348 end;
1350 procedure ProcAuthorsClose();
1351 begin
1352 gMusic.SetByName('MUSIC_MENU');
1353 gMusic.Play();
1354 gState := STATE_MENU;
1355 end;
1357 procedure ProcGMClose();
1358 begin
1359 g_Game_InGameMenu(False);
1360 end;
1362 procedure ProcGMShow();
1363 var
1364 Enabled: Boolean;
1365 begin
1366 Enabled := True;
1367 if (gGameSettings.GameType = GT_SINGLE) and
1368 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1369 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1370 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1371 if not gGameOn then
1372 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1373 if g_Game_IsTestMap then
1374 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1375 TGUIMainMenu(g_ActiveWindow.GetControl(
1376 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1377 end;
1379 procedure ProcChangePlayers();
1380 var
1381 TeamGame, Spectator, AddTwo: Boolean;
1382 P1Team{, P2Team}: Byte;
1383 bP2: TGUITextButton;
1384 begin
1385 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1386 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1387 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1388 P1Team := TEAM_NONE;
1389 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1390 // TODO
1391 //P2Team := TEAM_NONE;
1392 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1394 TGUIMainMenu(g_ActiveWindow.GetControl(
1395 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1396 TGUIMainMenu(g_ActiveWindow.GetControl(
1397 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1398 TGUIMainMenu(g_ActiveWindow.GetControl(
1399 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1401 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1402 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1403 bP2.Enabled := AddTwo and not Spectator;
1404 if bP2.Enabled then
1405 bP2.Color := MAINMENU_ITEMS_COLOR
1406 else
1407 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1408 if gPlayer2 = nil then
1409 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1410 else
1411 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1413 TGUIMainMenu(g_ActiveWindow.GetControl(
1414 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1415 end;
1417 procedure ProcJoinRed();
1418 begin
1419 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1420 Exit;
1421 if g_Game_IsServer then
1422 begin
1423 if gPlayer1 = nil then
1424 g_Game_AddPlayer(TEAM_RED)
1425 else
1426 begin
1427 if gPlayer1.Team <> TEAM_RED then
1428 begin
1429 gPlayer1.SwitchTeam;
1430 gPlayer1Settings.Team := gPlayer1.Team;
1431 end;
1433 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1434 end;
1435 end
1436 else
1437 begin
1438 gPlayer1Settings.Team := TEAM_RED;
1439 MC_SEND_PlayerSettings;
1440 if gPlayer1 = nil then
1441 g_Game_AddPlayer(TEAM_RED);
1442 end;
1443 g_ActiveWindow := nil;
1444 g_Game_Pause(False);
1445 end;
1447 procedure ProcJoinBlue();
1448 begin
1449 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1450 Exit;
1451 if g_Game_IsServer then
1452 begin
1453 if gPlayer1 = nil then
1454 g_Game_AddPlayer(TEAM_BLUE)
1455 else
1456 begin
1457 if gPlayer1.Team <> TEAM_BLUE then
1458 begin
1459 gPlayer1.SwitchTeam;
1460 gPlayer1Settings.Team := gPlayer1.Team;
1461 end;
1463 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1464 end;
1465 end
1466 else
1467 begin
1468 gPlayer1Settings.Team := TEAM_BLUE;
1469 MC_SEND_PlayerSettings;
1470 if gPlayer1 = nil then
1471 g_Game_AddPlayer(TEAM_BLUE);
1472 end;
1473 g_ActiveWindow := nil;
1474 g_Game_Pause(False);
1475 end;
1477 procedure ProcJoinGame();
1478 begin
1479 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1480 Exit;
1481 if gPlayer1 = nil then
1482 g_Game_AddPlayer();
1483 g_ActiveWindow := nil;
1484 g_Game_Pause(False);
1485 end;
1487 procedure ProcSwitchP2();
1488 begin
1489 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1490 Exit;
1491 if gPlayer1 = nil then
1492 Exit;
1493 if gPlayer2 = nil then
1494 g_Game_AddPlayer()
1495 else
1496 g_Game_RemovePlayer();
1497 g_ActiveWindow := nil;
1498 g_Game_Pause(False);
1499 end;
1501 procedure ProcSpectate();
1502 begin
1503 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1504 Exit;
1505 g_Game_Spectate();
1506 g_ActiveWindow := nil;
1507 g_Game_Pause(False);
1508 end;
1510 procedure ProcRestartMenuKeyDown (yes: Boolean);
1511 begin
1512 if yes then g_Game_Restart() else g_GUI_HideWindow;
1513 end;
1515 procedure ProcEndMenuKeyDown (yes: Boolean);
1516 begin
1517 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1518 end;
1520 procedure ProcSetRussianLanguage();
1521 begin
1522 if gLanguage <> LANGUAGE_RUSSIAN then
1523 begin
1524 gLanguage := LANGUAGE_RUSSIAN;
1525 gLanguageChange := True;
1526 gAskLanguage := False;
1528 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1530 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1531 ProcApplyOptions();
1532 end;
1533 end;
1535 procedure ProcSetEnglishLanguage();
1536 begin
1537 if gLanguage <> LANGUAGE_ENGLISH then
1538 begin
1539 gLanguage := LANGUAGE_ENGLISH;
1540 gLanguageChange := True;
1541 gAskLanguage := False;
1543 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1545 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1546 ProcApplyOptions();
1547 end;
1548 end;
1550 procedure ReadGameSettings();
1551 var
1552 menu: TGUIMenu;
1553 begin
1554 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1556 with gGameSettings do
1557 begin
1558 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1559 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1560 ItemIndex := 0
1561 else
1562 ItemIndex := 1;
1564 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1565 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1566 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1568 with TGUISwitch(menu.GetControl('swBotsVS')) do
1569 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1570 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1571 ItemIndex := 2
1572 else
1573 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1574 ItemIndex := 1
1575 else
1576 ItemIndex := 0;
1578 if GameType in [GT_CUSTOM, GT_SERVER] then
1579 begin
1580 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1581 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1582 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1583 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1584 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1585 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1586 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1587 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1588 end
1589 else
1590 begin
1591 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1592 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1593 begin
1594 Enabled := False;
1595 Text := '';
1596 end;
1597 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1598 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1599 begin
1600 Enabled := False;
1601 Text := '';
1602 end;
1603 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1604 with TGUIEdit(menu.GetControl('edMaxLives')) do
1605 begin
1606 Enabled := False;
1607 Text := '';
1608 end;
1609 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1610 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1611 end;
1612 end;
1613 end;
1615 procedure ProcApplyGameSet();
1616 var
1617 menu: TGUIMenu;
1618 a, b, n: Integer;
1619 stat: TPlayerStatArray;
1620 begin
1621 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1623 if not g_Game_IsServer then Exit;
1625 with gGameSettings do
1626 begin
1627 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1628 begin
1629 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1630 Options := Options or GAME_OPTION_TEAMDAMAGE
1631 else
1632 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1633 end;
1635 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1636 begin
1637 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1639 if n = 0 then
1640 TimeLimit := 0
1641 else
1642 begin
1643 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1645 TimeLimit := Max(n, b);
1646 end;
1647 end;
1649 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1650 begin
1651 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1653 if n = 0 then
1654 GoalLimit := 0
1655 else
1656 begin
1657 b := 0;
1658 if GameMode = GM_DM then
1659 begin // DM
1660 stat := g_Player_GetStats();
1661 if stat <> nil then
1662 for a := 0 to High(stat) do
1663 if stat[a].Frags > b then
1664 b := stat[a].Frags;
1665 end
1666 else // CTF
1667 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1669 GoalLimit := Max(n, b);
1670 end;
1671 end;
1673 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1674 begin
1675 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1676 if n < 0 then n := 0;
1677 if n > 255 then n := 255;
1678 if n = 0 then
1679 MaxLives := 0
1680 else
1681 begin
1682 b := 0;
1683 stat := g_Player_GetStats();
1684 if stat <> nil then
1685 for a := 0 to High(stat) do
1686 if stat[a].Lives > b then
1687 b := stat[a].Lives;
1689 MaxLives := Max(n, b);
1690 end;
1691 end;
1693 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1694 begin
1695 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1696 1:
1697 begin
1698 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1699 Options := Options or GAME_OPTION_BOTVSMONSTER;
1700 end;
1701 2:
1702 begin
1703 Options := Options or GAME_OPTION_BOTVSPLAYER;
1704 Options := Options or GAME_OPTION_BOTVSMONSTER;
1705 end;
1706 else
1707 begin
1708 Options := Options or GAME_OPTION_BOTVSPLAYER;
1709 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1710 end;
1711 end;
1712 end;
1713 end;
1715 if g_Game_IsNet then MH_SEND_GameSettings;
1716 end;
1718 procedure ProcVideoOptionsRes();
1719 var
1720 menu: TGUIMenu;
1721 list: SSArray;
1722 SR: DWORD;
1723 begin
1724 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1726 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1727 IntToStr(gScreenWidth) +
1728 ' x ' + IntToStr(gScreenHeight) +
1729 ', ' + IntToStr(gBPP) + ' bpp';
1731 with TGUIListBox(menu.GetControl('lsResolution')) do
1732 begin
1733 list := GetDisplayModes(gBPP, SR);
1735 if list <> nil then
1736 begin
1737 Items := list;
1738 ItemIndex := SR;
1739 end
1740 else
1741 Clear();
1742 end;
1744 with TGUISwitch(menu.GetControl('swFullScreen')) do
1745 if gFullscreen then
1746 ItemIndex := 0
1747 else
1748 ItemIndex := 1;
1749 end;
1751 procedure ProcApplyVideoOptions();
1752 var
1753 menu: TGUIMenu;
1754 Fullscreen: Boolean;
1755 SWidth, SHeight: Integer;
1756 str: String;
1757 begin
1758 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1760 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1761 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1763 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1765 if (SWidth <> gScreenWidth) or
1766 (SHeight <> gScreenHeight) or
1767 (Fullscreen <> gFullscreen) then
1768 begin
1769 gResolutionChange := True;
1770 gRC_Width := SWidth;
1771 gRC_Height := SHeight;
1772 gRC_FullScreen := Fullscreen;
1773 gRC_Maximized := gWinMaximized;
1774 end;
1776 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1777 ProcApplyOptions();
1778 end;
1780 procedure ProcSetFirstRussianLanguage();
1781 begin
1782 gLanguage := LANGUAGE_RUSSIAN;
1783 gLanguageChange := True;
1784 gAskLanguage := False;
1786 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1787 end;
1789 procedure ProcSetFirstEnglishLanguage();
1790 begin
1791 gLanguage := LANGUAGE_ENGLISH;
1792 gLanguageChange := True;
1793 gAskLanguage := False;
1795 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1796 end;
1798 procedure ProcRecallAddress();
1799 begin
1800 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1801 begin
1802 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1803 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1804 end;
1805 end;
1807 procedure CreateFirstLanguageMenu();
1808 var
1809 Menu: TGUIWindow;
1810 begin
1811 Menu := TGUIWindow.Create('FirstLanguageMenu');
1813 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1814 begin
1815 Name := 'mmFirstLanguageMenu';
1816 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1817 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1818 end;
1820 Menu.DefControl := 'mmFirstLanguageMenu';
1821 Menu.MainWindow := True;
1822 g_GUI_AddWindow(Menu);
1823 end;
1825 procedure g_Menu_AskLanguage();
1826 begin
1827 CreateFirstLanguageMenu();
1828 g_GUI_ShowWindow('FirstLanguageMenu');
1829 end;
1831 procedure CreatePlayerOptionsMenu(s: String);
1832 var
1833 Menu: TGUIWindow;
1834 a: String;
1835 begin
1836 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1837 if s = 'P1' then
1838 a := _lc[I_MENU_PLAYER_1]
1839 else
1840 a := _lc[I_MENU_PLAYER_2];
1841 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1842 begin
1843 Name := 'mOptionsPlayers'+s+'Menu';
1844 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1845 begin
1846 Name := 'ed'+s+'Name';
1847 MaxLength := 12;
1848 Width := 12;
1849 end;
1850 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1851 begin
1852 Name := 'sw'+s+'Team';
1853 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1854 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1855 end ;
1856 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1857 begin
1858 Name := 'ls'+s+'Model';
1859 Sort := True;
1860 Items := g_PlayerModel_GetNames();
1861 OnChange := ProcSelectModel;
1862 end;
1863 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1864 begin
1865 Name := 'sc'+s+'Red';
1866 Max := 16;
1867 OnChange := ProcChangeColor;
1868 end;
1869 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1870 begin
1871 Name := 'sc'+s+'Green';
1872 Max := 16;
1873 OnChange := ProcChangeColor;
1874 end;
1875 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1876 begin
1877 Name := 'sc'+s+'Blue';
1878 Max := 16;
1879 OnChange := ProcChangeColor;
1880 end;
1881 AddSpace();
1882 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1883 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1884 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1885 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1887 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1888 begin
1889 Name := 'mv'+s+'Model';
1890 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1891 Y := GetControl('ls'+s+'Model').Y;
1892 end;
1893 end;
1894 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1895 g_GUI_AddWindow(Menu);
1896 end;
1898 procedure CreateAllMenus();
1899 var
1900 Menu: TGUIWindow;
1901 //SR: TSearchRec;
1902 a, cx, _y, i: Integer;
1903 //list: SSArray;
1904 begin
1905 Menu := TGUIWindow.Create('MainMenu');
1906 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1907 begin
1908 Name := 'mmMainMenu';
1909 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1910 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1911 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1912 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1913 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1914 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1915 end;
1916 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1917 begin
1918 Color := _RGB(255, 255, 255);
1919 X := gScreenWidth-GetWidth-8;
1920 Y := gScreenHeight-GetHeight-8;
1921 end;
1922 Menu.DefControl := 'mmMainMenu';
1923 Menu.MainWindow := True;
1924 g_GUI_AddWindow(Menu);
1926 Menu := TGUIWindow.Create('NewGameMenu');
1927 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
1928 begin
1929 Name := 'mmNewGameMenu';
1930 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1931 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1932 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1933 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1934 end;
1935 Menu.DefControl := 'mmNewGameMenu';
1936 g_GUI_AddWindow(Menu);
1938 Menu := TGUIWindow.Create('NetGameMenu');
1939 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
1940 begin
1941 Name := 'mmNetGameMenu';
1942 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1943 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1944 end;
1945 Menu.DefControl := 'mmNetGameMenu';
1946 g_GUI_AddWindow(Menu);
1948 Menu := TGUIWindow.Create('NetServerMenu');
1949 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
1950 begin
1951 Name := 'mNetServerMenu';
1952 with AddEdit(_lc[I_NET_SERVER_NAME]) do
1953 begin
1954 Name := 'edSrvName';
1955 OnlyDigits := False;
1956 Width := 16;
1957 MaxLength := 64;
1958 Text := NetServerName;
1959 end;
1960 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
1961 begin
1962 Name := 'edSrvPassword';
1963 OnlyDigits := False;
1964 Width := 16;
1965 MaxLength := 24;
1966 Text := NetPassword;
1967 end;
1968 with AddEdit(_lc[I_NET_PORT]) do
1969 begin
1970 Name := 'edPort';
1971 OnlyDigits := True;
1972 Width := 4;
1973 MaxLength := 5;
1974 Text := IntToStr(NetPort);
1975 end;
1976 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
1977 begin
1978 Name := 'edMaxPlayers';
1979 OnlyDigits := True;
1980 Width := 4;
1981 MaxLength := 2;
1982 Text := IntToStr(NetMaxClients);
1983 end;
1984 with AddSwitch(_lc[I_NET_USE_MASTER]) do
1985 begin
1986 Name := 'swUseMaster';
1987 AddItem(_lc[I_MENU_YES]);
1988 AddItem(_lc[I_MENU_NO]);
1989 if NetUseMaster then
1990 ItemIndex := 0
1991 else
1992 ItemIndex := 1;
1993 end;
1994 AddSpace();
1995 with AddLabel(_lc[I_MENU_MAP]) do
1996 begin
1997 Name := 'lbMap';
1998 FixedLength := 16;
1999 Text := gnMap;
2000 OnClick := @ProcSelectMapMenu;
2001 end;
2002 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2003 begin
2004 Name := 'swGameMode';
2005 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2006 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2007 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2008 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2009 case g_Game_TextToMode(gnGameMode) of
2010 GM_NONE,
2011 GM_DM: ItemIndex := 0;
2012 GM_TDM: ItemIndex := 1;
2013 GM_CTF: ItemIndex := 2;
2014 GM_SINGLE,
2015 GM_COOP: ItemIndex := 3;
2016 end;
2017 OnChange := ProcSwitchMonstersNet;
2018 end;
2019 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2020 begin
2021 Name := 'edTimeLimit';
2022 OnlyDigits := True;
2023 Width := 4;
2024 MaxLength := 5;
2025 if gnTimeLimit > 0 then
2026 Text := IntToStr(gnTimeLimit);
2027 end;
2028 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2029 begin
2030 Name := 'edGoalLimit';
2031 OnlyDigits := True;
2032 Width := 4;
2033 MaxLength := 5;
2034 if gnGoalLimit > 0 then
2035 Text := IntToStr(gnGoalLimit);
2036 end;
2037 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2038 begin
2039 Name := 'edMaxLives';
2040 OnlyDigits := True;
2041 Width := 4;
2042 MaxLength := 3;
2043 if gnMaxLives > 0 then
2044 Text := IntToStr(gnMaxLives);
2045 end;
2046 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2047 begin
2048 Name := 'swPlayers';
2049 AddItem(_lc[I_MENU_COUNT_NONE]);
2050 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2051 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2052 ItemIndex := gnPlayers;
2053 end;
2054 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2055 begin
2056 Name := 'swTeamDamage';
2057 AddItem(_lc[I_MENU_YES]);
2058 AddItem(_lc[I_MENU_NO]);
2059 if gnTeamDamage then
2060 ItemIndex := 0
2061 else
2062 ItemIndex := 1;
2063 end;
2064 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2065 begin
2066 Name := 'swEnableExits';
2067 AddItem(_lc[I_MENU_YES]);
2068 AddItem(_lc[I_MENU_NO]);
2069 if gnAllowExit then
2070 ItemIndex := 0
2071 else
2072 ItemIndex := 1;
2073 end;
2074 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2075 begin
2076 Name := 'swWeaponStay';
2077 AddItem(_lc[I_MENU_YES]);
2078 AddItem(_lc[I_MENU_NO]);
2079 if gnWeaponStay then
2080 ItemIndex := 0
2081 else
2082 ItemIndex := 1;
2083 end;
2084 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2085 begin
2086 Name := 'swMonsters';
2087 AddItem(_lc[I_MENU_YES]);
2088 AddItem(_lc[I_MENU_NO]);
2089 if gnMonsters then
2090 ItemIndex := 0
2091 else
2092 ItemIndex := 1;
2093 end;
2094 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2095 begin
2096 Name := 'swBotsVS';
2097 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2098 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2099 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2100 ItemIndex := 2;
2101 if gnBotsVS = 'Players' then
2102 ItemIndex := 0;
2103 if gnBotsVS = 'Monsters' then
2104 ItemIndex := 1;
2105 end;
2106 AddSpace();
2107 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2109 ReAlign();
2110 end;
2111 Menu.DefControl := 'mNetServerMenu';
2112 g_GUI_AddWindow(Menu);
2114 Menu := TGUIWindow.Create('NetClientMenu');
2115 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2116 begin
2117 Name := 'mNetClientMenu';
2119 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2120 AddSpace();
2122 with AddEdit(_lc[I_NET_ADDRESS]) do
2123 begin
2124 Name := 'edIP';
2125 OnlyDigits :=False;
2126 Width := 12;
2127 MaxLength := 64;
2128 Text := 'localhost';
2129 end;
2130 with AddEdit(_lc[I_NET_PORT]) do
2131 begin
2132 Name := 'edPort';
2133 OnlyDigits := True;
2134 Width := 4;
2135 MaxLength := 5;
2136 Text := '25666';
2137 end;
2138 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2139 begin
2140 Name := 'edPW';
2141 OnlyDigits := False;
2142 Width := 12;
2143 MaxLength := 32;
2144 Text := '';
2145 end;
2147 AddSpace();
2148 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2150 ReAlign();
2151 end;
2152 Menu.DefControl := 'mNetClientMenu';
2153 g_GUI_AddWindow(Menu);
2155 Menu := TGUIWindow.Create('LoadMenu');
2156 Menu.OnShow := ProcLoadMenu;
2157 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2158 begin
2159 Name := 'mmLoadMenu';
2161 for a := 1 to 8 do
2162 with AddEdit('') do
2163 begin
2164 Name := 'edSlot'+IntToStr(a);
2165 Width := 16;
2166 MaxLength := 16;
2167 OnEnter := ProcLoadGame;
2168 end;
2169 end;
2170 Menu.DefControl := 'mmLoadMenu';
2171 g_GUI_AddWindow(Menu);
2173 Menu := TGUIWindow.Create('SaveMenu');
2174 Menu.OnShow := ProcSaveMenu;
2175 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2176 begin
2177 Name := 'mmSaveMenu';
2179 for a := 1 to 8 do
2180 with AddEdit('') do
2181 begin
2182 Name := 'edSlot'+IntToStr(a);
2183 Width := 16;
2184 MaxLength := 16;
2185 OnChange := ProcSaveGame;
2186 end;
2187 end;
2188 Menu.DefControl := 'mmSaveMenu';
2189 g_GUI_AddWindow(Menu);
2191 Menu := TGUIWindow.Create('CustomGameMenu');
2192 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2193 begin
2194 Name := 'mCustomGameMenu';
2195 with AddLabel(_lc[I_MENU_MAP]) do
2196 begin
2197 Name := 'lbMap';
2198 FixedLength := 16;
2199 Text := gcMap;
2200 OnClick := @ProcSelectMapMenu;
2201 end;
2202 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2203 begin
2204 Name := 'swGameMode';
2205 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2206 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2207 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2208 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2209 case g_Game_TextToMode(gcGameMode) of
2210 GM_NONE,
2211 GM_DM: ItemIndex := 0;
2212 GM_TDM: ItemIndex := 1;
2213 GM_CTF: ItemIndex := 2;
2214 GM_SINGLE,
2215 GM_COOP: ItemIndex := 3;
2216 end;
2217 OnChange := ProcSwitchMonstersCustom;
2218 end;
2219 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2220 begin
2221 Name := 'edTimeLimit';
2222 OnlyDigits := True;
2223 Width := 4;
2224 MaxLength := 5;
2225 if gcTimeLimit > 0 then
2226 Text := IntToStr(gcTimeLimit);
2227 end;
2228 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2229 begin
2230 Name := 'edGoalLimit';
2231 OnlyDigits := True;
2232 Width := 4;
2233 MaxLength := 5;
2234 if gcGoalLimit > 0 then
2235 Text := IntToStr(gcGoalLimit);
2236 end;
2237 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2238 begin
2239 Name := 'edMaxLives';
2240 OnlyDigits := True;
2241 Width := 4;
2242 MaxLength := 5;
2243 if gcMaxLives > 0 then
2244 Text := IntToStr(gcMaxLives);
2245 end;
2246 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2247 begin
2248 Name := 'swPlayers';
2249 AddItem(_lc[I_MENU_COUNT_NONE]);
2250 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2251 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2252 ItemIndex := gcPlayers;
2253 end;
2254 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2255 begin
2256 Name := 'swTeamDamage';
2257 AddItem(_lc[I_MENU_YES]);
2258 AddItem(_lc[I_MENU_NO]);
2259 if gcTeamDamage then
2260 ItemIndex := 0
2261 else
2262 ItemIndex := 1;
2263 end;
2264 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2265 begin
2266 Name := 'swEnableExits';
2267 AddItem(_lc[I_MENU_YES]);
2268 AddItem(_lc[I_MENU_NO]);
2269 if gcAllowExit then
2270 ItemIndex := 0
2271 else
2272 ItemIndex := 1;
2273 end;
2274 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2275 begin
2276 Name := 'swWeaponStay';
2277 AddItem(_lc[I_MENU_YES]);
2278 AddItem(_lc[I_MENU_NO]);
2279 if gcWeaponStay then
2280 ItemIndex := 0
2281 else
2282 ItemIndex := 1;
2283 end;
2284 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2285 begin
2286 Name := 'swMonsters';
2287 AddItem(_lc[I_MENU_YES]);
2288 AddItem(_lc[I_MENU_NO]);
2289 if gcMonsters then
2290 ItemIndex := 0
2291 else
2292 ItemIndex := 1;
2293 end;
2294 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2295 begin
2296 Name := 'swBotsVS';
2297 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2298 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2299 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2300 ItemIndex := 2;
2301 if gcBotsVS = 'Players' then
2302 ItemIndex := 0;
2303 if gcBotsVS = 'Monsters' then
2304 ItemIndex := 1;
2305 end;
2306 AddSpace();
2307 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2309 ReAlign();
2310 end;
2311 Menu.DefControl := 'mCustomGameMenu';
2312 g_GUI_AddWindow(Menu);
2314 Menu := TGUIWindow.Create('CampaignMenu');
2315 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2316 begin
2317 Name := 'mCampaignMenu';
2319 AddSpace();
2320 AddSpace();
2321 AddSpace();
2322 AddSpace();
2323 AddSpace();
2324 AddSpace();
2326 with AddFileList('', 15, 4) do
2327 begin
2328 Name := 'lsWAD';
2329 OnChange := ProcSelectCampaignWAD;
2331 Sort := True;
2332 Dirs := True;
2333 FileMask := '*.wad|*.pk3|*.zip';
2334 SetBase(MapsDir+'megawads/');
2335 end;
2337 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2338 begin
2339 Name := 'lbWADName';
2340 FixedLength := 8;
2341 Enabled := False;
2342 end;
2343 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2344 begin
2345 Name := 'lbWADAuthor';
2346 FixedLength := 8;
2347 Enabled := False;
2348 end;
2349 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2350 with AddMemo('', 15, 3) do
2351 begin
2352 Name := 'meWADDescription';
2353 Color := MENU_ITEMSCTRL_COLOR;
2354 end;
2355 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2356 begin
2357 Name := 'swPlayers';
2358 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2359 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2360 end;
2361 AddSpace();
2362 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2364 ReAlign();
2366 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2367 begin
2368 Name := 'mpWADImage';
2369 DefaultRes := 'NOPIC';
2370 X := GetControl('lsWAD').X+4;
2371 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2372 end;
2373 end;
2374 Menu.DefControl := 'mCampaignMenu';
2375 g_GUI_AddWindow(Menu);
2377 Menu := TGUIWindow.Create('SelectMapMenu');
2378 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2379 begin
2380 Name := 'mSelectMapMenu';
2381 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2382 begin
2383 Name := 'lsMapWAD';
2384 OnChange := ProcSelectWAD;
2386 Sort := True;
2387 Dirs := True;
2388 FileMask := '*.wad|*.pk3|*.zip';
2389 SetBase(MapsDir);
2390 end;
2391 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2392 begin
2393 Name := 'lsMapRes';
2394 Sort := True;
2395 OnChange := ProcSelectMap;
2396 end;
2397 AddSpace();
2398 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2399 begin
2400 Name := 'lbMapName';
2401 FixedLength := 24;
2402 Enabled := False;
2403 end;
2404 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2405 begin
2406 Name := 'lbMapAuthor';
2407 FixedLength := 16;
2408 Enabled := False;
2409 end;
2410 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2411 begin
2412 Name := 'lbMapSize';
2413 FixedLength := 10;
2414 Enabled := False;
2415 end;
2416 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2417 begin
2418 Name := 'meMapDescription';
2419 end;
2421 ReAlign();
2423 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2424 begin
2425 Name := 'mpMapPreview';
2426 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2427 Y := GetControl('lsMapWAD').Y;
2428 end;
2429 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2430 begin
2431 Name := 'lbMapScale';
2432 FixedLength := 8;
2433 Enabled := False;
2434 Color := MENU_ITEMSCTRL_COLOR;
2435 X := GetControl('lsMapWAD').X +
2436 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2437 2 + MAPPREVIEW_WIDTH*4;
2438 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2439 end;
2440 end;
2441 Menu.OnClose := ProcSetMap;
2442 Menu.DefControl := 'mSelectMapMenu';
2443 g_GUI_AddWindow(Menu);
2445 Menu := TGUIWindow.Create('OptionsMenu');
2446 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2447 begin
2448 Name := 'mmOptionsMenu';
2449 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2450 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2451 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2452 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2453 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2454 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2455 AddSpace();
2456 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2457 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2458 end;
2459 Menu.OnClose := ProcApplyOptions;
2460 Menu.DefControl := 'mmOptionsMenu';
2461 g_GUI_AddWindow(Menu);
2463 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2464 gMenuSmallFont, @ProcSavedMenuKeyDown);
2465 g_GUI_AddWindow(Menu);
2467 Menu := TGUIWindow.Create('OptionsVideoMenu');
2468 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2469 begin
2470 Name := 'mOptionsVideoMenu';
2471 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2472 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2473 begin
2474 Name := 'swBPP';
2475 AddItem('16');
2476 AddItem('32');
2477 end;
2478 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2479 begin
2480 Name := 'swVSync';
2481 AddItem(_lc[I_MENU_YES]);
2482 AddItem(_lc[I_MENU_NO]);
2483 end;
2484 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2485 begin
2486 Name := 'swTextureFilter';
2487 AddItem(_lc[I_MENU_YES]);
2488 AddItem(_lc[I_MENU_NO]);
2489 end;
2490 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2491 begin
2492 Name := 'swLegacyNPOT';
2493 AddItem(_lc[I_MENU_NO]);
2494 AddItem(_lc[I_MENU_YES]);
2495 end;
2496 AddSpace();
2497 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2498 ReAlign();
2499 end;
2500 Menu.DefControl := 'mOptionsVideoMenu';
2501 g_GUI_AddWindow(Menu);
2503 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2504 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2505 begin
2506 Name := 'mOptionsVideoResMenu';
2507 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2508 begin
2509 Name := 'lbCurrentRes';
2510 FixedLength := 24;
2511 Enabled := False;
2512 end;
2513 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2514 begin
2515 Name := 'lsResolution';
2516 Sort := False;
2517 end;
2518 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2519 begin
2520 Name := 'swFullScreen';
2521 AddItem(_lc[I_MENU_YES]);
2522 AddItem(_lc[I_MENU_NO]);
2523 end;
2524 AddSpace();
2525 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2526 UpdateIndex();
2527 end;
2528 Menu.DefControl := 'mOptionsVideoResMenu';
2529 g_GUI_AddWindow(Menu);
2531 Menu := TGUIWindow.Create('OptionsSoundMenu');
2532 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2533 begin
2534 Name := 'mOptionsSoundMenu';
2535 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2536 begin
2537 Name := 'scMusicLevel';
2538 Max := 16;
2539 OnChange := ProcChangeSoundSettings;
2540 end;
2541 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2542 begin
2543 Name := 'scSoundLevel';
2544 Max := 16;
2545 OnChange := ProcChangeSoundSettings;
2546 end;
2547 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2548 begin
2549 Name := 'scMaxSimSounds';
2550 Max := 16;
2551 end;
2552 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2553 begin;
2554 Name := 'swAnnouncer';
2555 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2556 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2557 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2558 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2559 end;
2560 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2561 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2562 begin;
2563 Name := 'swSoundEffects';
2564 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2565 AddItem(_lc[I_MENU_COMPAT_DF]);
2566 end;
2567 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2568 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2569 begin;
2570 Name := 'swChatSpeech';
2571 AddItem(_lc[I_MENU_YES]);
2572 AddItem(_lc[I_MENU_NO]);
2573 end;
2574 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2575 begin
2576 Name := 'swInactiveSounds';
2577 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2578 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2579 end;
2580 ReAlign();
2581 end;
2582 Menu.DefControl := 'mOptionsSoundMenu';
2583 g_GUI_AddWindow(Menu);
2585 Menu := TGUIWindow.Create('OptionsGameMenu');
2586 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2587 begin
2588 Name := 'mOptionsGameMenu';
2589 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2590 begin
2591 Name := 'scParticlesCount';
2592 Max := 20;
2593 end;
2594 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2595 begin
2596 Name := 'swBloodCount';
2597 AddItem(_lc[I_MENU_COUNT_NONE]);
2598 AddItem(_lc[I_MENU_COUNT_SMALL]);
2599 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2600 AddItem(_lc[I_MENU_COUNT_BIG]);
2601 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2602 end;
2603 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2604 begin
2605 Name := 'scShellsMax';
2606 Max := 20;
2607 end;
2608 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2609 begin
2610 Name := 'scGibsMax';
2611 Max := 20;
2612 end;
2613 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2614 begin
2615 Name := 'scCorpsesMax';
2616 Max := 20;
2617 end;
2618 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2619 begin
2620 Name := 'swGibsCount';
2621 AddItem(_lc[I_MENU_COUNT_NONE]);
2622 AddItem(_lc[I_MENU_COUNT_SMALL]);
2623 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2624 AddItem(_lc[I_MENU_COUNT_BIG]);
2625 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2626 end;
2627 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2628 begin
2629 Name := 'swCorpseType';
2630 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2631 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2632 end;
2633 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2634 begin
2635 Name := 'swGibsType';
2636 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2637 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2638 end;
2639 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2640 begin
2641 Name := 'swBloodType';
2642 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2643 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2644 end;
2645 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2646 begin
2647 Name := 'swScreenFlash';
2648 AddItem(_lc[I_MENU_NO]);
2649 AddItem(_lc[I_MENU_COMPAT_DF]);
2650 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2651 end;
2652 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2653 begin
2654 Name := 'swBackground';
2655 AddItem(_lc[I_MENU_YES]);
2656 AddItem(_lc[I_MENU_NO]);
2657 end;
2658 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2659 begin
2660 Name := 'swMessages';
2661 AddItem(_lc[I_MENU_YES]);
2662 AddItem(_lc[I_MENU_NO]);
2663 end;
2664 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2665 begin
2666 Name := 'swRevertPlayers';
2667 AddItem(_lc[I_MENU_YES]);
2668 AddItem(_lc[I_MENU_NO]);
2669 end;
2670 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2671 begin
2672 Name := 'swChatBubble';
2673 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2674 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2675 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2676 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2677 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2678 end;
2679 ReAlign();
2680 end;
2681 Menu.DefControl := 'mOptionsGameMenu';
2682 g_GUI_AddWindow(Menu);
2684 Menu := TGUIWindow.Create('OptionsControlsMenu');
2685 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2686 begin
2687 Name := 'mOptionsControlsMenu';
2688 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2689 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2690 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2691 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2692 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2693 AddSpace();
2694 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2695 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2696 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2697 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2698 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2699 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2700 AddSpace();
2701 if e_JoysticksAvailable <> 0 then
2702 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2703 end;
2704 Menu.DefControl := 'mOptionsControlsMenu';
2705 g_GUI_AddWindow(Menu);
2707 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2708 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2709 begin
2710 Name := 'mOptionsControlsP1Menu';
2711 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2712 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2713 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2714 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2715 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2716 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2717 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2718 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2719 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2720 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2721 end;
2722 Menu.DefControl := 'mOptionsControlsP1Menu';
2723 g_GUI_AddWindow(Menu);
2725 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2726 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2727 begin
2728 Name := 'mOptionsControlsP1MenuWeapons';
2729 for i := WP_FIRST to WP_LAST do
2730 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2731 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2732 end;
2733 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2734 g_GUI_AddWindow(Menu);
2736 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2737 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2738 begin
2739 Name := 'mOptionsControlsP2Menu';
2740 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2741 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2742 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2743 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2744 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2745 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2746 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2747 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2748 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2749 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2750 end;
2751 Menu.DefControl := 'mOptionsControlsP2Menu';
2752 g_GUI_AddWindow(Menu);
2754 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2755 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2756 begin
2757 Name := 'mOptionsControlsP2MenuWeapons';
2758 for i := WP_FIRST to WP_LAST do
2759 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2760 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2761 end;
2762 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2763 g_GUI_AddWindow(Menu);
2765 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2766 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2767 begin
2768 Name := 'mOptionsControlsJoystickMenu';
2769 for i := 0 to e_JoysticksAvailable-1 do
2770 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2771 begin
2772 Name := 'scDeadzone' + IntToStr(i);
2773 Max := 20;
2774 end;
2775 end;
2776 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2777 g_GUI_AddWindow(Menu);
2779 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2780 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2781 begin
2782 Name := 'mOptionsPlayersMenu';
2783 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2784 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2785 end;
2786 Menu.DefControl := 'mOptionsPlayersMenu';
2787 g_GUI_AddWindow(Menu);
2789 CreatePlayerOptionsMenu('P1');
2790 CreatePlayerOptionsMenu('P2');
2792 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2793 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2794 begin
2795 Name := 'mOptionsPlayersMIMenu';
2796 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2797 begin
2798 Name := 'lbName';
2799 FixedLength := 16;
2800 end;
2801 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2802 begin
2803 Name := 'lbAuthor';
2804 FixedLength := 16;
2805 end;
2806 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2807 begin
2808 Name := 'meComment';
2809 end;
2810 AddSpace();
2811 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2812 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2813 begin
2814 Name := 'lbWeapon';
2815 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2816 end;
2817 ReAlign();
2818 end;
2819 Menu.DefControl := 'mOptionsPlayersMIMenu';
2820 g_GUI_AddWindow(Menu);
2822 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2823 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2824 begin
2825 Name := 'mOptionsLanguageMenu';
2826 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2827 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2828 ReAlign();
2829 end;
2830 Menu.DefControl := 'mOptionsLanguageMenu';
2831 g_GUI_AddWindow(Menu);
2833 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2834 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2835 g_GUI_AddWindow(Menu);
2837 Menu := TGUIWindow.Create('AuthorsMenu');
2838 Menu.BackTexture := 'INTER';
2839 Menu.OnClose := ProcAuthorsClose;
2841 // Çàãîëîâîê:
2842 _y := 16;
2843 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2844 begin
2845 Color := _RGB(255, 0, 0);
2846 X := (gScreenWidth div 2)-(GetWidth() div 2);
2847 Y := _y;
2848 _y := _y+GetHeight();
2849 end;
2850 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2851 begin
2852 Color := _RGB(255, 0, 0);
2853 X := (gScreenWidth div 2)-(GetWidth() div 2);
2854 Y := _y;
2855 _y := _y+GetHeight()+32;
2856 end;
2857 // ×òî äåëàë: Êòî äåëàë
2858 cx := gScreenWidth div 2 - 320 + 64;
2859 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
2860 begin
2861 Color := _RGB(255, 0, 0);
2862 X := cx;
2863 Y := _y;
2864 _y := _y+22;
2865 end;
2866 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
2867 begin
2868 Color := _RGB(255, 255, 255);
2869 X := cx+32;
2870 Y := _y;
2871 _y := _y+36;
2872 end;
2873 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
2874 begin
2875 Color := _RGB(255, 0, 0);
2876 X := cx;
2877 Y := _y;
2878 _y := _y+22;
2879 end;
2880 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
2881 begin
2882 Color := _RGB(255, 255, 255);
2883 X := cx+32;
2884 Y := _y;
2885 _y := _y+22;
2886 end;
2887 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
2888 begin
2889 Color := _RGB(255, 255, 255);
2890 X := cx+32;
2891 Y := _y;
2892 _y := _y+36;
2893 end;
2894 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
2895 begin
2896 Color := _RGB(255, 0, 0);
2897 X := cx;
2898 Y := _y;
2899 _y := _y+22;
2900 end;
2901 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
2902 begin
2903 Color := _RGB(255, 255, 255);
2904 X := cx+32;
2905 Y := _y;
2906 _y := _y+36;
2907 end;
2908 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
2909 begin
2910 Color := _RGB(255, 0, 0);
2911 X := cx;
2912 Y := _y;
2913 _y := _y+22;
2914 end;
2915 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
2916 begin
2917 Color := _RGB(255, 255, 255);
2918 X := cx+32;
2919 Y := _y;
2920 _y := gScreenHeight - 128;
2921 end;
2922 // Çàêëþ÷åíèå:
2923 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
2924 begin
2925 Color := _RGB(255, 0, 0);
2926 X := cx;
2927 Y := _y;
2928 _y := _y+16;
2929 end;
2930 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
2931 begin
2932 Color := _RGB(255, 255, 255);
2933 X := cx+32;
2934 Y := _y;
2935 _y := _y+GetHeight();
2936 end;
2937 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
2938 begin
2939 Color := _RGB(255, 255, 255);
2940 X := cx+32;
2941 Y := _y;
2942 _y := _y+GetHeight();
2943 end;
2944 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
2945 begin
2946 Color := _RGB(255, 255, 255);
2947 X := cx+32;
2948 Y := _y;
2949 _y := gScreenHeight - 32;
2950 end;
2951 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
2952 begin
2953 Color := _RGB(255, 0, 0);
2954 X := gScreenWidth div 2 - GetWidth() div 2;
2955 Y := _y;
2956 end;
2957 g_GUI_AddWindow(Menu);
2959 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
2960 gMenuSmallFont, @ProcExitMenuKeyDown);
2961 g_GUI_AddWindow(Menu);
2963 Menu := TGUIWindow.Create('GameSingleMenu');
2964 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2965 begin
2966 Name := 'mmGameSingleMenu';
2967 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2968 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2969 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2970 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2971 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2972 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2973 end;
2974 Menu.DefControl := 'mmGameSingleMenu';
2975 Menu.MainWindow := True;
2976 Menu.OnClose := ProcGMClose;
2977 Menu.OnShow := ProcGMShow;
2978 g_GUI_AddWindow(Menu);
2980 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
2981 gMenuSmallFont, @ProcEndMenuKeyDown);
2982 g_GUI_AddWindow(Menu);
2984 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
2985 gMenuSmallFont, @ProcRestartMenuKeyDown);
2986 g_GUI_AddWindow(Menu);
2988 Menu := TGUIWindow.Create('GameCustomMenu');
2989 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2990 begin
2991 Name := 'mmGameCustomMenu';
2992 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2993 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2994 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2995 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2996 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2997 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2998 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2999 end;
3000 Menu.DefControl := 'mmGameCustomMenu';
3001 Menu.MainWindow := True;
3002 Menu.OnClose := ProcGMClose;
3003 Menu.OnShow := ProcGMShow;
3004 g_GUI_AddWindow(Menu);
3006 Menu := TGUIWindow.Create('GameServerMenu');
3007 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3008 begin
3009 Name := 'mmGameServerMenu';
3010 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3011 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3012 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3013 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3014 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3015 end;
3016 Menu.DefControl := 'mmGameServerMenu';
3017 Menu.MainWindow := True;
3018 Menu.OnClose := ProcGMClose;
3019 Menu.OnShow := ProcGMShow;
3020 g_GUI_AddWindow(Menu);
3022 Menu := TGUIWindow.Create('GameClientMenu');
3023 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3024 begin
3025 Name := 'mmGameClientMenu';
3026 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3027 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3028 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3029 end;
3030 Menu.DefControl := 'mmGameClientMenu';
3031 Menu.MainWindow := True;
3032 Menu.OnClose := ProcGMClose;
3033 Menu.OnShow := ProcGMShow;
3034 g_GUI_AddWindow(Menu);
3036 Menu := TGUIWindow.Create('ClientPasswordMenu');
3037 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3038 begin
3039 Name := 'mClientPasswordMenu';
3040 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3041 begin
3042 Name := 'edPW';
3043 Width := 12;
3044 MaxLength := 32;
3045 end;
3046 AddSpace;
3048 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3049 ReAlign();
3050 end;
3051 Menu.DefControl := 'mClientPasswordMenu';
3052 g_GUI_AddWindow(Menu);
3054 Menu := TGUIWindow.Create('GameSetGameMenu');
3055 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3056 begin
3057 Name := 'mGameSetGameMenu';
3058 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3059 begin
3060 Name := 'swTeamDamage';
3061 AddItem(_lc[I_MENU_YES]);
3062 AddItem(_lc[I_MENU_NO]);
3063 ItemIndex := 1;
3064 end;
3065 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3066 begin
3067 Name := 'edTimeLimit';
3068 OnlyDigits := True;
3069 Width := 4;
3070 MaxLength := 5;
3071 end;
3072 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3073 begin
3074 Name := 'edGoalLimit';
3075 OnlyDigits := True;
3076 Width := 4;
3077 MaxLength := 5;
3078 end;
3079 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3080 begin
3081 Name := 'edMaxLives';
3082 OnlyDigits := True;
3083 Width := 4;
3084 MaxLength := 5;
3085 end;
3086 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3087 begin
3088 Name := 'swBotsVS';
3089 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3090 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3091 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3092 ItemIndex := 2;
3093 end;
3095 ReAlign();
3096 end;
3097 Menu.DefControl := 'mGameSetGameMenu';
3098 Menu.OnClose := ProcApplyGameSet;
3099 g_GUI_AddWindow(Menu);
3101 Menu := TGUIWindow.Create('TeamMenu');
3102 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3103 begin
3104 Name := 'mmTeamMenu';
3105 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3106 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3107 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3108 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3109 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3110 end;
3111 Menu.DefControl := 'mmTeamMenu';
3112 Menu.OnShow := ProcChangePlayers;
3113 g_GUI_AddWindow(Menu);
3114 end;
3116 procedure g_Menu_Show_SaveMenu();
3117 begin
3118 if g_Game_IsTestMap then
3119 Exit;
3120 if gGameSettings.GameType = GT_SINGLE then
3121 g_GUI_ShowWindow('GameSingleMenu')
3122 else
3123 begin
3124 if g_Game_IsClient then
3125 Exit
3126 else
3127 if g_Game_IsNet then
3128 Exit
3129 else
3130 g_GUI_ShowWindow('GameCustomMenu');
3131 end;
3132 g_GUI_ShowWindow('SaveMenu');
3133 g_Sound_PlayEx('MENU_OPEN');
3134 end;
3136 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3137 begin
3138 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3139 if gGameSettings.GameType = GT_SINGLE then
3140 begin
3141 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3142 end
3143 else
3144 begin
3145 if g_Game_IsClient then exit;
3146 if g_Game_IsNet then exit;
3147 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3148 end;
3149 g_GUI_ShowWindow('LoadMenu');
3150 g_Sound_PlayEx('MENU_OPEN');
3151 end;
3153 procedure g_Menu_Show_GameSetGame();
3154 begin
3155 if gGameSettings.GameType = GT_SINGLE then
3156 g_GUI_ShowWindow('GameSingleMenu')
3157 else
3158 begin
3159 if g_Game_IsClient then
3160 Exit
3161 else
3162 if g_Game_IsNet then
3163 g_GUI_ShowWindow('GameServerMenu')
3164 else
3165 g_GUI_ShowWindow('GameCustomMenu');
3166 end;
3167 ReadGameSettings();
3168 g_GUI_ShowWindow('GameSetGameMenu');
3169 g_Sound_PlayEx('MENU_OPEN');
3170 end;
3172 procedure g_Menu_Show_OptionsVideo();
3173 begin
3174 if gGameSettings.GameType = GT_SINGLE then
3175 g_GUI_ShowWindow('GameSingleMenu')
3176 else
3177 begin
3178 if g_Game_IsClient then
3179 g_GUI_ShowWindow('GameClientMenu')
3180 else
3181 if g_Game_IsNet then
3182 g_GUI_ShowWindow('GameServerMenu')
3183 else
3184 g_GUI_ShowWindow('GameCustomMenu');
3185 end;
3186 ReadOptions();
3187 g_GUI_ShowWindow('OptionsMenu');
3188 g_GUI_ShowWindow('OptionsVideoMenu');
3189 g_Sound_PlayEx('MENU_OPEN');
3190 end;
3192 procedure g_Menu_Show_OptionsSound();
3193 begin
3194 if gGameSettings.GameType = GT_SINGLE then
3195 g_GUI_ShowWindow('GameSingleMenu')
3196 else
3197 begin
3198 if g_Game_IsClient then
3199 g_GUI_ShowWindow('GameClientMenu')
3200 else
3201 if g_Game_IsNet then
3202 g_GUI_ShowWindow('GameServerMenu')
3203 else
3204 g_GUI_ShowWindow('GameCustomMenu');
3205 end;
3206 ReadOptions();
3207 g_GUI_ShowWindow('OptionsMenu');
3208 g_GUI_ShowWindow('OptionsSoundMenu');
3209 g_Sound_PlayEx('MENU_OPEN');
3210 end;
3212 procedure g_Menu_Show_EndGameMenu();
3213 begin
3214 g_GUI_ShowWindow('EndGameMenu');
3215 g_Sound_PlayEx('MENU_OPEN');
3216 end;
3218 procedure g_Menu_Show_QuitGameMenu();
3219 begin
3220 g_GUI_ShowWindow('ExitMenu');
3221 g_Sound_PlayEx('MENU_OPEN');
3222 end;
3224 procedure g_Menu_Init();
3225 begin
3226 MenuLoadData();
3227 g_GUI_Init();
3228 CreateAllMenus();
3229 end;
3231 procedure g_Menu_Free();
3232 begin
3233 g_GUI_Destroy();
3235 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3237 MenuFreeData();
3238 end;
3240 procedure g_Menu_Reset();
3241 var
3242 ex: Boolean;
3243 begin
3244 g_GUI_SaveMenuPos();
3245 ex := g_GUI_Destroy();
3247 if ex then
3248 begin
3249 e_WriteLog('Recreating menu...', TMsgType.Notify);
3251 CreateAllMenus();
3253 if gDebugMode then
3254 g_Game_SetDebugMode();
3256 g_GUI_LoadMenuPos();
3257 end;
3258 end;
3260 end.