DEADSOFTWARE

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