DEADSOFTWARE

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