DEADSOFTWARE

field namefix: `FLive` -> `FAlive`; `live` -> `alive`
[d2df-sdl.git] / src / game / g_menu.pas
1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_menu;
19 interface
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
25 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
36 var
37 gMenuFont: DWORD;
38 gMenuSmallFont: DWORD;
39 PromptIP: string;
40 PromptPort: Word;
42 implementation
44 uses
45 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
46 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
47 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
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
511 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
512 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
513 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
514 else
515 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
518 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
519 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
520 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
521 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
523 end;
525 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
526 begin
527 // don't turn off monsters in DM
529 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
530 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
531 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
532 else
533 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
536 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
537 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
538 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
539 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
541 end;
543 procedure ProcStartCustomGame();
544 var
545 Map: String;
546 GameMode: Byte;
547 Options: LongWord;
548 begin
549 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
550 begin
551 Map := TGUILabel(GetControl('lbMap')).Text;
552 if Map = '' then
553 Exit;
554 if Pos(':\', Map) = 0 then
555 Exit;
557 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
558 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
559 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
560 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
561 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
563 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
564 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
565 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
566 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
567 Options := 0;
568 if gcTeamDamage then
569 Options := Options or GAME_OPTION_TEAMDAMAGE;
570 if gcAllowExit then
571 Options := Options or GAME_OPTION_ALLOWEXIT;
572 if gcWeaponStay then
573 Options := Options or GAME_OPTION_WEAPONSTAY;
574 if gcMonsters then
575 Options := Options or GAME_OPTION_MONSTERS;
576 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
578 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
579 1: begin
580 Options := Options or GAME_OPTION_BOTVSMONSTER;
581 gcBotsVS := 'Monsters';
582 end;
583 2: begin
584 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
585 gcBotsVS := 'Everybody';
586 end;
587 else begin
588 Options := Options or GAME_OPTION_BOTVSPLAYER;
589 gcBotsVS := 'Players';
590 end;
591 end;
593 gcMap := Map;
594 end;
596 g_Options_Write_Gameplay_Custom(GameDir+'/'+CONFIG_FILENAME);
598 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
599 gcMaxLives, Options, gcPlayers);
600 end;
603 procedure ProcStartNetGame();
604 var
605 Map: String;
606 GameMode: Byte;
607 Options: LongWord;
608 begin
609 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
610 begin
611 Map := TGUILabel(GetControl('lbMap')).Text;
612 if Map = '' then
613 Exit;
614 if Pos(':\', Map) = 0 then
615 Exit;
617 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
618 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
619 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
620 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
621 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
622 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
624 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
625 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
626 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
627 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
628 Options := 0;
629 if gnTeamDamage then
630 Options := Options or GAME_OPTION_TEAMDAMAGE;
631 if gnAllowExit then
632 Options := Options or GAME_OPTION_ALLOWEXIT;
633 if gnWeaponStay then
634 Options := Options or GAME_OPTION_WEAPONSTAY;
635 if gnMonsters then
636 Options := Options or GAME_OPTION_MONSTERS;
637 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
639 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
640 1: begin
641 Options := Options or GAME_OPTION_BOTVSMONSTER;
642 gnBotsVS := 'Monsters';
643 end;
644 2: begin
645 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
646 gnBotsVS := 'Everybody';
647 end;
648 else begin
649 Options := Options or GAME_OPTION_BOTVSPLAYER;
650 gnBotsVS := 'Players';
651 end;
652 end;
654 gnMap := Map;
655 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
656 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
657 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
658 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
659 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
660 end;
662 g_Options_Write_Net_Server(GameDir+'/'+CONFIG_FILENAME);
663 g_Options_Write_Gameplay_Net(GameDir+'/'+CONFIG_FILENAME);
665 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
666 Options, gnPlayers, 0, NetPort);
667 end;
669 procedure ProcConnectNetGame();
670 var
671 PW: String;
672 begin
673 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
674 begin
675 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
676 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
677 PW := TGUIEdit(GetControl('edPW')).Text;
678 end;
680 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
681 g_Game_StartClient(NetClientIP, NetClientPort, PW);
682 end;
684 procedure ProcEnterPassword();
685 var
686 PW: string;
687 begin
688 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
689 begin
690 NetClientIP := PromptIP;
691 NetClientPort := PromptPort;
692 PW := TGUIEdit(GetControl('edPW')).Text;
693 end;
695 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
696 g_Game_StartClient(NetClientIP, NetClientPort, PW);
697 end;
699 procedure ProcServerlist();
700 begin
701 if not NetInitDone then
702 begin
703 if (not g_Net_Init()) then
704 begin
705 g_Console_Add('NET: ERROR: Failed to init ENet!');
706 Exit;
707 end
708 else
709 NetInitDone := True;
710 end;
712 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
714 gState := STATE_SLIST;
715 g_ActiveWindow := nil;
717 slWaitStr := _lc[I_NET_SLIST_WAIT];
719 g_Game_Draw;
720 ReDrawWindow;
722 slReturnPressed := True;
723 if g_Net_Slist_Fetch(slCurrent) then
724 begin
725 if slCurrent = nil then
726 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
727 end
728 else
729 slWaitStr := _lc[I_NET_SLIST_ERROR];
730 end;
732 procedure ProcStartCampaign();
733 var
734 WAD: String;
735 TwoPlayers: Boolean;
736 n: Byte;
737 begin
738 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
739 begin
740 WAD := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
741 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
742 end;
744 if TwoPlayers then
745 n := 2
746 else
747 n := 1;
748 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
749 end;
751 procedure ProcSelectMap(Sender: TGUIControl);
752 var
753 win: TGUIWindow;
754 a: TMapInfo;
755 wad, map, res: String;
756 begin
757 win := g_GUI_GetWindow('SelectMapMenu');
758 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
759 begin
760 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
761 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
763 if (wad = '') or (map = '') then
764 begin // Ýòî íå êàðòà
765 TGUILabel(GetControl('lbMapName')).Text := '';
766 TGUILabel(GetControl('lbMapAuthor')).Text := '';
767 TGUILabel(GetControl('lbMapSize')).Text := '';
768 TGUIMemo(GetControl('meMapDescription')).SetText('');
769 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
770 TGUILabel(win.GetControl('lbMapScale')).Text := '';
771 end
772 else // Ýòî êàðòà
773 begin
774 res := wad+':\'+map;
776 a := g_Map_GetMapInfo(res);
778 TGUILabel(GetControl('lbMapName')).Text := a.Name;
779 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
780 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
781 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
782 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
783 TGUILabel(win.GetControl('lbMapScale')).Text :=
784 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
785 end;
786 end;
787 end;
789 procedure ProcSelectWAD(Sender: TGUIControl);
790 var
791 wad: String;
792 list: SArray;
793 begin
794 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
795 begin
796 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
798 with TGUIListBox(GetControl('lsMapRes')) do
799 begin
800 Clear();
802 if wad <> '' then
803 begin
804 list := g_Map_GetMapsList(wad);
806 if list <> nil then
807 begin
808 Items := list;
809 ItemIndex := 0;
810 end
811 end;
812 end;
813 end;
815 ProcSelectMap(nil);
816 end;
818 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
819 var
820 win: TGUIWindow;
821 a: TMegaWADInfo;
822 wad, fn: String;
823 begin
824 win := g_GUI_GetWindow('CampaignMenu');
825 with TGUIMenu(win.GetControl('mCampaignMenu')) do
826 begin
827 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
829 if wad = '' then
830 begin
831 TGUILabel(GetControl('lbWADName')).Text := '';
832 TGUILabel(GetControl('lbWADAuthor')).Text := '';
833 TGUIMemo(GetControl('meWADDescription')).SetText('');
834 end;
836 a := g_Game_GetMegaWADInfo(wad);
838 TGUILabel(GetControl('lbWADName')).Text := a.Name;
839 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
840 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
842 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
844 if a.pic <> '' then
845 begin
846 fn := g_ExtractWadName(a.pic);
847 if fn = '' then
848 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
849 else
850 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
851 end;
852 end;
853 end;
855 procedure ProcChangeColor(Sender: TGUIControl);
856 var
857 window: TGUIWindow;
858 begin
859 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
860 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
861 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
862 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
863 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
864 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
866 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
867 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
868 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
869 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
870 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
871 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
872 end;
874 procedure ProcSelectModel(Sender: TGUIControl);
875 var
876 a: string;
877 window: TGUIWindow;
878 begin
879 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
880 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
881 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
883 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
884 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
885 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
887 ProcChangeColor(nil);
888 end;
890 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
891 var
892 cwdt, chgt: Byte;
893 spc: ShortInt;
894 ID: DWORD;
895 wad: TWADFile;
896 cfgdata: Pointer;
897 cfglen: Integer;
898 config: TConfig;
899 begin
900 cfglen := 0;
902 wad := TWADFile.Create;
903 if wad.ReadFile(GameWAD) then
904 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
905 wad.Free();
907 if cfglen <> 0 then
908 begin
909 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
911 config := TConfig.CreateMem(cfgdata, cfglen);
912 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
913 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
914 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
916 if g_Texture_Get('FONT_STD', ID) then
917 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
919 config.Free();
920 end;
922 if cfglen <> 0 then FreeMem(cfgdata);
923 end;
925 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
926 var
927 cwdt, chgt: Byte;
928 spc: ShortInt;
929 CharID: DWORD;
930 wad: TWADFile;
931 cfgdata, fntdata: Pointer;
932 cfglen, fntlen: Integer;
933 config: TConfig;
934 chrwidth: Integer;
935 a: Byte;
936 begin
937 cfglen := 0;
938 fntlen := 0;
940 wad := TWADFile.Create;
941 if wad.ReadFile(GameWAD) then
942 begin
943 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
944 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
945 end;
946 wad.Free();
948 if cfglen <> 0 then
949 begin
950 config := TConfig.CreateMem(cfgdata, cfglen);
951 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
952 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
954 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
955 FontID := e_CharFont_Create(spc);
957 for a := 0 to 255 do
958 begin
959 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
960 if chrwidth = 0 then Continue;
962 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
963 cwdt, chgt) then
964 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
965 end;
967 config.Free();
968 end;
970 if cfglen <> 0 then FreeMem(cfgdata);
971 if fntlen <> 0 then FreeMem(fntdata);
972 end;
974 procedure MenuLoadData();
975 begin
976 e_WriteLog('Loading menu data...', MSG_NOTIFY);
978 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
979 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
980 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
981 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
982 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
983 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
984 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
985 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
986 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
987 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
988 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
989 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
990 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
991 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
992 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
993 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
994 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
995 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
996 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
997 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
998 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
999 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1000 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1001 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1003 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1004 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1005 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1006 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1007 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1008 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1009 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1010 end;
1012 procedure MenuFreeData();
1013 begin
1014 e_CharFont_Remove(gMenuFont);
1015 e_CharFont_Remove(gMenuSmallFont);
1017 g_Texture_Delete('MAINMENU_MARKER1');
1018 g_Texture_Delete('MAINMENU_MARKER2');
1019 g_Texture_Delete('SCROLL_LEFT');
1020 g_Texture_Delete('SCROLL_RIGHT');
1021 g_Texture_Delete('SCROLL_MIDDLE');
1022 g_Texture_Delete('SCROLL_MARKER');
1023 g_Texture_Delete('EDIT_LEFT');
1024 g_Texture_Delete('EDIT_RIGHT');
1025 g_Texture_Delete('EDIT_MIDDLE');
1026 g_Texture_Delete('BOX1');
1027 g_Texture_Delete('BOX2');
1028 g_Texture_Delete('BOX3');
1029 g_Texture_Delete('BOX4');
1030 g_Texture_Delete('BOX5');
1031 g_Texture_Delete('BOX6');
1032 g_Texture_Delete('BOX7');
1033 g_Texture_Delete('BOX8');
1034 g_Texture_Delete('BOX9');
1035 g_Texture_Delete('BSCROLL_UP_A');
1036 g_Texture_Delete('BSCROLL_UP_U');
1037 g_Texture_Delete('BSCROLL_DOWN_A');
1038 g_Texture_Delete('BSCROLL_DOWN_U');
1039 g_Texture_Delete('BSCROLL_MIDDLE');
1040 g_Texture_Delete('NOPIC');
1042 g_Sound_Delete('MENU_SELECT');
1043 g_Sound_Delete('MENU_OPEN');
1044 g_Sound_Delete('MENU_CLOSE');
1045 g_Sound_Delete('MENU_CHANGE');
1046 g_Sound_Delete('SCROLL_ADD');
1047 g_Sound_Delete('SCROLL_SUB');
1048 g_Sound_Delete('SOUND_PLAYER_FALL');
1049 end;
1051 procedure ProcAuthorsMenu();
1052 begin
1053 gMusic.SetByName('MUSIC_INTERMUS');
1054 gMusic.Play();
1055 end;
1057 procedure ProcExitMenuKeyDown (yes: Boolean);
1058 var
1059 s: ShortString;
1060 snd: TPlayableSound;
1061 res: Boolean;
1062 begin
1063 if yes then
1064 begin
1065 g_Game_StopAllSounds(True);
1066 case (Random(18)) of
1067 0: s := 'SOUND_MONSTER_PAIN';
1068 1: s := 'SOUND_MONSTER_DIE_3';
1069 2: s := 'SOUND_MONSTER_SLOP';
1070 3: s := 'SOUND_MONSTER_DEMON_DIE';
1071 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1072 5: s := 'SOUND_MONSTER_MAN_DIE';
1073 6: s := 'SOUND_MONSTER_BSP_DIE';
1074 7: s := 'SOUND_MONSTER_VILE_DIE';
1075 8: s := 'SOUND_MONSTER_SKEL_DIE';
1076 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1077 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1078 11: s := 'SOUND_MONSTER_BARON_DIE';
1079 12: s := 'SOUND_MONSTER_CACO_DIE';
1080 13: s := 'SOUND_MONSTER_CYBER_DIE';
1081 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1082 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1083 else s := 'SOUND_PLAYER_FALL';
1084 end;
1085 snd := TPlayableSound.Create();
1086 res := snd.SetByName(s);
1087 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1088 if res then
1089 begin
1090 snd.Play(True);
1091 while snd.IsPlaying() do begin end;
1092 end;
1093 g_Game_Quit();
1094 exit;
1095 end;
1096 g_GUI_HideWindow();
1097 end;
1099 procedure ProcLoadMenu();
1100 var
1101 a: Integer;
1102 begin
1103 for a := 1 to 8 do
1104 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text :=
1105 g_GetSaveName(a);
1106 end;
1108 procedure ProcSaveMenu();
1109 var
1110 a: Integer;
1111 begin
1112 for a := 1 to 8 do
1113 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text :=
1114 g_GetSaveName(a);
1115 end;
1117 procedure ProcSaveGame(Sender: TGUIControl);
1118 var
1119 a: Integer;
1120 begin
1121 if g_Game_IsNet then Exit;
1122 if g_Game_IsTestMap then Exit;
1123 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1124 g_Game_PauseAllSounds(True);
1125 g_SaveGame(a, TGUIEdit(Sender).Text);
1127 g_ActiveWindow := nil;
1128 g_Game_Pause(False);
1129 end;
1131 procedure ProcLoadGame(Sender: TGUIControl);
1132 var
1133 a: Integer;
1134 begin
1135 if g_Game_IsNet then Exit;
1136 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1137 if g_LoadGame(a) then
1138 g_Game_PauseAllSounds(False)
1139 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1140 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1141 end;
1143 procedure ProcSingle1Player();
1144 begin
1145 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1146 end;
1148 procedure ProcSingle2Players();
1149 begin
1150 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1151 end;
1153 procedure ProcSelectMapMenu();
1154 var
1155 menu: TGUIMenu;
1156 wad_lb: TGUIFileListBox;
1157 map_lb: TGUIListBox;
1158 map: String;
1159 begin
1160 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1161 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1162 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1164 if wad_lb.SelectedItem() <> '' then
1165 map := map_lb.SelectedItem()
1166 else
1167 map := '';
1169 wad_lb.UpdateFileList();
1170 map_lb.Clear();
1172 if wad_lb.SelectedItem() <> '' then
1173 begin
1174 ProcSelectWAD(nil);
1175 map_lb.SelectItem(map);
1177 if map_lb.SelectedItem() <> '' then
1178 ProcSelectMap(nil);
1179 end;
1181 g_GUI_ShowWindow('SelectMapMenu');
1182 end;
1184 procedure ProcSelectCampaignMenu();
1185 var
1186 menu: TGUIMenu;
1187 wad_lb: TGUIFileListBox;
1188 begin
1189 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1190 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1192 wad_lb.UpdateFileList();
1194 if wad_lb.SelectedItem() <> '' then
1195 ProcSelectCampaignWAD(nil);
1196 end;
1198 procedure ProcSetMap();
1199 var
1200 wad, map, res: String;
1201 begin
1202 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1203 begin
1204 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1205 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1206 end;
1208 if (wad = '') or (map = '') then
1209 Exit;
1211 res := wad+':\'+map;
1213 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1214 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1215 end;
1217 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1218 var
1219 menu: TGUIMenu;
1220 begin
1221 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1223 g_Sound_SetupAllVolumes(
1224 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1225 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1226 );
1227 end;
1229 procedure ProcOptionsPlayersMIMenu();
1230 var
1231 s, a: string;
1232 b: TModelInfo;
1233 begin
1234 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1236 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1238 if a = '' then Exit;
1240 b := g_PlayerModel_GetInfo(a);
1242 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1243 begin
1244 TGUILabel(GetControl('lbName')).Text := b.Name;
1245 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1246 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1248 if b.HaveWeapon then
1249 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1250 else
1251 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1252 end;
1254 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1255 end;
1257 procedure ProcOptionsPlayersAnim();
1258 var
1259 s: String;
1260 begin
1261 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1262 s := 'P1'
1263 else
1264 s := 'P2';
1266 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1267 begin
1268 NextAnim();
1269 Model.GetCurrentAnimation.Loop := True;
1270 Model.GetCurrentAnimationMask.Loop := True;
1271 end;
1272 end;
1274 procedure ProcOptionsPlayersWeap();
1275 var
1276 s: String;
1277 begin
1278 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1279 s := 'P1'
1280 else
1281 s := 'P2';
1283 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1284 NextWeapon();
1285 end;
1287 procedure ProcOptionsPlayersRot();
1288 var
1289 s: string;
1290 begin
1291 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1292 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1293 if Direction = D_LEFT then Direction := D_RIGHT else Direction := D_LEFT;
1294 end;
1296 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1297 begin
1298 if yes then
1299 begin
1300 g_Options_SetDefault();
1301 ReadOptions();
1302 end;
1303 g_GUI_HideWindow();
1304 end;
1306 procedure ProcSavedMenuKeyDown (yes: Boolean);
1307 begin
1308 if yes then ReadOptions();
1309 g_GUI_HideWindow();
1310 end;
1312 procedure ProcAuthorsClose();
1313 begin
1314 gMusic.SetByName('MUSIC_MENU');
1315 gMusic.Play();
1316 gState := STATE_MENU;
1317 end;
1319 procedure ProcGMClose();
1320 begin
1321 g_Game_InGameMenu(False);
1322 end;
1324 procedure ProcGMShow();
1325 var
1326 Enabled: Boolean;
1327 begin
1328 Enabled := True;
1329 if (gGameSettings.GameType = GT_SINGLE) and
1330 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1331 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1332 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1333 if not gGameOn then
1334 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1335 if g_Game_IsTestMap then
1336 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1337 TGUIMainMenu(g_ActiveWindow.GetControl(
1338 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1339 end;
1341 procedure ProcChangePlayers();
1342 var
1343 TeamGame, Spectator, AddTwo: Boolean;
1344 P1Team{, P2Team}: Byte;
1345 bP2: TGUITextButton;
1346 begin
1347 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1348 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1349 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1350 P1Team := TEAM_NONE;
1351 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1352 // TODO
1353 //P2Team := TEAM_NONE;
1354 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1356 TGUIMainMenu(g_ActiveWindow.GetControl(
1357 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1358 TGUIMainMenu(g_ActiveWindow.GetControl(
1359 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1360 TGUIMainMenu(g_ActiveWindow.GetControl(
1361 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1363 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1364 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1365 bP2.Enabled := AddTwo and not Spectator;
1366 if bP2.Enabled then
1367 bP2.Color := MAINMENU_ITEMS_COLOR
1368 else
1369 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1370 if gPlayer2 = nil then
1371 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1372 else
1373 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1375 TGUIMainMenu(g_ActiveWindow.GetControl(
1376 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1377 end;
1379 procedure ProcJoinRed();
1380 begin
1381 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1382 Exit;
1383 if g_Game_IsServer then
1384 begin
1385 if gPlayer1 = nil then
1386 g_Game_AddPlayer(TEAM_RED)
1387 else
1388 begin
1389 if gPlayer1.Team <> TEAM_RED then
1390 begin
1391 gPlayer1.SwitchTeam;
1392 gPlayer1Settings.Team := gPlayer1.Team;
1393 end;
1395 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1396 end;
1397 end
1398 else
1399 begin
1400 gPlayer1Settings.Team := TEAM_RED;
1401 MC_SEND_PlayerSettings;
1402 if gPlayer1 = nil then
1403 g_Game_AddPlayer(TEAM_RED);
1404 end;
1405 g_ActiveWindow := nil;
1406 g_Game_Pause(False);
1407 end;
1409 procedure ProcJoinBlue();
1410 begin
1411 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1412 Exit;
1413 if g_Game_IsServer then
1414 begin
1415 if gPlayer1 = nil then
1416 g_Game_AddPlayer(TEAM_BLUE)
1417 else
1418 begin
1419 if gPlayer1.Team <> TEAM_BLUE then
1420 begin
1421 gPlayer1.SwitchTeam;
1422 gPlayer1Settings.Team := gPlayer1.Team;
1423 end;
1425 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1426 end;
1427 end
1428 else
1429 begin
1430 gPlayer1Settings.Team := TEAM_BLUE;
1431 MC_SEND_PlayerSettings;
1432 if gPlayer1 = nil then
1433 g_Game_AddPlayer(TEAM_BLUE);
1434 end;
1435 g_ActiveWindow := nil;
1436 g_Game_Pause(False);
1437 end;
1439 procedure ProcJoinGame();
1440 begin
1441 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1442 Exit;
1443 if gPlayer1 = nil then
1444 g_Game_AddPlayer();
1445 g_ActiveWindow := nil;
1446 g_Game_Pause(False);
1447 end;
1449 procedure ProcSwitchP2();
1450 begin
1451 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1452 Exit;
1453 if gPlayer1 = nil then
1454 Exit;
1455 if gPlayer2 = nil then
1456 g_Game_AddPlayer()
1457 else
1458 g_Game_RemovePlayer();
1459 g_ActiveWindow := nil;
1460 g_Game_Pause(False);
1461 end;
1463 procedure ProcSpectate();
1464 begin
1465 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1466 Exit;
1467 g_Game_Spectate();
1468 g_ActiveWindow := nil;
1469 g_Game_Pause(False);
1470 end;
1472 procedure ProcRestartMenuKeyDown (yes: Boolean);
1473 begin
1474 if yes then g_Game_Restart() else g_GUI_HideWindow;
1475 end;
1477 procedure ProcEndMenuKeyDown (yes: Boolean);
1478 begin
1479 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1480 end;
1482 procedure ProcSetRussianLanguage();
1483 begin
1484 if gLanguage <> LANGUAGE_RUSSIAN then
1485 begin
1486 gLanguage := LANGUAGE_RUSSIAN;
1487 gLanguageChange := True;
1488 gAskLanguage := False;
1490 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1492 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1493 ProcApplyOptions();
1494 end;
1495 end;
1497 procedure ProcSetEnglishLanguage();
1498 begin
1499 if gLanguage <> LANGUAGE_ENGLISH then
1500 begin
1501 gLanguage := LANGUAGE_ENGLISH;
1502 gLanguageChange := True;
1503 gAskLanguage := False;
1505 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1507 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1508 ProcApplyOptions();
1509 end;
1510 end;
1512 procedure ReadGameSettings();
1513 var
1514 menu: TGUIMenu;
1515 begin
1516 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1518 with gGameSettings do
1519 begin
1520 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1521 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1522 ItemIndex := 0
1523 else
1524 ItemIndex := 1;
1526 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1527 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1528 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1530 with TGUISwitch(menu.GetControl('swBotsVS')) do
1531 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1532 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1533 ItemIndex := 2
1534 else
1535 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1536 ItemIndex := 1
1537 else
1538 ItemIndex := 0;
1540 if GameType in [GT_CUSTOM, GT_SERVER] then
1541 begin
1542 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1543 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1544 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1545 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1546 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1547 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1548 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1549 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1550 end
1551 else
1552 begin
1553 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1554 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1555 begin
1556 Enabled := False;
1557 Text := '';
1558 end;
1559 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1560 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1561 begin
1562 Enabled := False;
1563 Text := '';
1564 end;
1565 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1566 with TGUIEdit(menu.GetControl('edMaxLives')) do
1567 begin
1568 Enabled := False;
1569 Text := '';
1570 end;
1571 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1572 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1573 end;
1574 end;
1575 end;
1577 procedure ProcApplyGameSet();
1578 var
1579 menu: TGUIMenu;
1580 a, b, n: Integer;
1581 stat: TPlayerStatArray;
1582 begin
1583 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1585 if not g_Game_IsServer then Exit;
1587 with gGameSettings do
1588 begin
1589 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1590 begin
1591 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1592 Options := Options or GAME_OPTION_TEAMDAMAGE
1593 else
1594 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1595 end;
1597 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1598 begin
1599 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1601 if n = 0 then
1602 TimeLimit := 0
1603 else
1604 begin
1605 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1607 TimeLimit := Max(n, b);
1608 end;
1609 end;
1611 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1612 begin
1613 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1615 if n = 0 then
1616 GoalLimit := 0
1617 else
1618 begin
1619 b := 0;
1620 if GameMode = GM_DM then
1621 begin // DM
1622 stat := g_Player_GetStats();
1623 if stat <> nil then
1624 for a := 0 to High(stat) do
1625 if stat[a].Frags > b then
1626 b := stat[a].Frags;
1627 end
1628 else // CTF
1629 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1631 GoalLimit := Max(n, b);
1632 end;
1633 end;
1635 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1636 begin
1637 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1638 if n < 0 then n := 0;
1639 if n > 255 then n := 255;
1640 if n = 0 then
1641 MaxLives := 0
1642 else
1643 begin
1644 b := 0;
1645 stat := g_Player_GetStats();
1646 if stat <> nil then
1647 for a := 0 to High(stat) do
1648 if stat[a].Lives > b then
1649 b := stat[a].Lives;
1651 MaxLives := Max(n, b);
1652 end;
1653 end;
1655 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1656 begin
1657 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1658 1:
1659 begin
1660 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1661 Options := Options or GAME_OPTION_BOTVSMONSTER;
1662 end;
1663 2:
1664 begin
1665 Options := Options or GAME_OPTION_BOTVSPLAYER;
1666 Options := Options or GAME_OPTION_BOTVSMONSTER;
1667 end;
1668 else
1669 begin
1670 Options := Options or GAME_OPTION_BOTVSPLAYER;
1671 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1672 end;
1673 end;
1674 end;
1675 end;
1677 if g_Game_IsNet then MH_SEND_GameSettings;
1678 end;
1680 procedure ProcVideoOptionsRes();
1681 var
1682 menu: TGUIMenu;
1683 list: SArray;
1684 SR: DWORD;
1685 begin
1686 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1688 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1689 IntToStr(gScreenWidth) +
1690 ' x ' + IntToStr(gScreenHeight) +
1691 ', ' + IntToStr(gBPP) + ' bpp';
1693 with TGUIListBox(menu.GetControl('lsResolution')) do
1694 begin
1695 list := GetDisplayModes(gBPP, SR);
1697 if list <> nil then
1698 begin
1699 Items := list;
1700 ItemIndex := SR;
1701 end
1702 else
1703 Clear();
1704 end;
1706 with TGUISwitch(menu.GetControl('swFullScreen')) do
1707 if gFullscreen then
1708 ItemIndex := 0
1709 else
1710 ItemIndex := 1;
1711 end;
1713 procedure ProcApplyVideoOptions();
1714 var
1715 menu: TGUIMenu;
1716 Fullscreen: Boolean;
1717 SWidth, SHeight: Integer;
1718 str: String;
1719 begin
1720 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1722 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1723 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1725 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1727 if (SWidth <> gScreenWidth) or
1728 (SHeight <> gScreenHeight) or
1729 (Fullscreen <> gFullscreen) then
1730 begin
1731 gResolutionChange := True;
1732 gRC_Width := SWidth;
1733 gRC_Height := SHeight;
1734 gRC_FullScreen := Fullscreen;
1735 gRC_Maximized := gWinMaximized;
1736 end;
1738 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1739 ProcApplyOptions();
1740 end;
1742 procedure ProcSetFirstRussianLanguage();
1743 begin
1744 gLanguage := LANGUAGE_RUSSIAN;
1745 gLanguageChange := True;
1746 gAskLanguage := False;
1748 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1749 end;
1751 procedure ProcSetFirstEnglishLanguage();
1752 begin
1753 gLanguage := LANGUAGE_ENGLISH;
1754 gLanguageChange := True;
1755 gAskLanguage := False;
1757 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1758 end;
1760 procedure ProcRecallAddress();
1761 begin
1762 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1763 begin
1764 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1765 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1766 end;
1767 end;
1769 procedure CreateFirstLanguageMenu();
1770 var
1771 Menu: TGUIWindow;
1772 begin
1773 Menu := TGUIWindow.Create('FirstLanguageMenu');
1775 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1776 begin
1777 Name := 'mmFirstLanguageMenu';
1778 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1779 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1780 end;
1782 Menu.DefControl := 'mmFirstLanguageMenu';
1783 Menu.MainWindow := True;
1784 g_GUI_AddWindow(Menu);
1785 end;
1787 procedure g_Menu_AskLanguage();
1788 begin
1789 CreateFirstLanguageMenu();
1790 g_GUI_ShowWindow('FirstLanguageMenu');
1791 end;
1793 procedure CreatePlayerOptionsMenu(s: String);
1794 var
1795 Menu: TGUIWindow;
1796 a: String;
1797 begin
1798 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1799 if s = 'P1' then
1800 a := _lc[I_MENU_PLAYER_1]
1801 else
1802 a := _lc[I_MENU_PLAYER_2];
1803 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1804 begin
1805 Name := 'mOptionsPlayers'+s+'Menu';
1806 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1807 begin
1808 Name := 'ed'+s+'Name';
1809 MaxLength := 12;
1810 Width := 12;
1811 end;
1812 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1813 begin
1814 Name := 'sw'+s+'Team';
1815 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1816 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1817 end ;
1818 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1819 begin
1820 Name := 'ls'+s+'Model';
1821 Sort := True;
1822 Items := g_PlayerModel_GetNames();
1823 OnChange := ProcSelectModel;
1824 end;
1825 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1826 begin
1827 Name := 'sc'+s+'Red';
1828 Max := 16;
1829 OnChange := ProcChangeColor;
1830 end;
1831 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1832 begin
1833 Name := 'sc'+s+'Green';
1834 Max := 16;
1835 OnChange := ProcChangeColor;
1836 end;
1837 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1838 begin
1839 Name := 'sc'+s+'Blue';
1840 Max := 16;
1841 OnChange := ProcChangeColor;
1842 end;
1843 AddSpace();
1844 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1845 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1846 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1847 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1849 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1850 begin
1851 Name := 'mv'+s+'Model';
1852 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1853 Y := GetControl('ls'+s+'Model').Y;
1854 end;
1855 end;
1856 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1857 g_GUI_AddWindow(Menu);
1858 end;
1860 procedure CreateAllMenus();
1861 var
1862 Menu: TGUIWindow;
1863 //SR: TSearchRec;
1864 a, cx, _y, i: Integer;
1865 //list: SArray;
1866 begin
1867 Menu := TGUIWindow.Create('MainMenu');
1868 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1869 begin
1870 Name := 'mmMainMenu';
1871 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1872 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1873 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1874 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1875 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1876 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1877 end;
1878 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1879 begin
1880 Color := _RGB(255, 255, 255);
1881 X := gScreenWidth-GetWidth-8;
1882 Y := gScreenHeight-GetHeight-8;
1883 end;
1884 Menu.DefControl := 'mmMainMenu';
1885 Menu.MainWindow := True;
1886 g_GUI_AddWindow(Menu);
1888 Menu := TGUIWindow.Create('NewGameMenu');
1889 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
1890 begin
1891 Name := 'mmNewGameMenu';
1892 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1893 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1894 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1895 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1896 end;
1897 Menu.DefControl := 'mmNewGameMenu';
1898 g_GUI_AddWindow(Menu);
1900 Menu := TGUIWindow.Create('NetGameMenu');
1901 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
1902 begin
1903 Name := 'mmNetGameMenu';
1904 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1905 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1906 end;
1907 Menu.DefControl := 'mmNetGameMenu';
1908 g_GUI_AddWindow(Menu);
1910 Menu := TGUIWindow.Create('NetServerMenu');
1911 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
1912 begin
1913 Name := 'mNetServerMenu';
1914 with AddEdit(_lc[I_NET_SERVER_NAME]) do
1915 begin
1916 Name := 'edSrvName';
1917 OnlyDigits := False;
1918 Width := 16;
1919 MaxLength := 64;
1920 Text := NetServerName;
1921 end;
1922 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
1923 begin
1924 Name := 'edSrvPassword';
1925 OnlyDigits := False;
1926 Width := 16;
1927 MaxLength := 24;
1928 Text := NetPassword;
1929 end;
1930 with AddEdit(_lc[I_NET_PORT]) do
1931 begin
1932 Name := 'edPort';
1933 OnlyDigits := True;
1934 Width := 4;
1935 MaxLength := 5;
1936 Text := IntToStr(NetPort);
1937 end;
1938 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
1939 begin
1940 Name := 'edMaxPlayers';
1941 OnlyDigits := True;
1942 Width := 4;
1943 MaxLength := 2;
1944 Text := IntToStr(NetMaxClients);
1945 end;
1946 with AddSwitch(_lc[I_NET_USE_MASTER]) do
1947 begin
1948 Name := 'swUseMaster';
1949 AddItem(_lc[I_MENU_YES]);
1950 AddItem(_lc[I_MENU_NO]);
1951 if NetUseMaster then
1952 ItemIndex := 0
1953 else
1954 ItemIndex := 1;
1955 end;
1956 AddSpace();
1957 with AddLabel(_lc[I_MENU_MAP]) do
1958 begin
1959 Name := 'lbMap';
1960 FixedLength := 16;
1961 Text := gnMap;
1962 OnClick := @ProcSelectMapMenu;
1963 end;
1964 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
1965 begin
1966 Name := 'swGameMode';
1967 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
1968 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
1969 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
1970 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
1971 case g_Game_TextToMode(gnGameMode) of
1972 GM_NONE,
1973 GM_DM: ItemIndex := 0;
1974 GM_TDM: ItemIndex := 1;
1975 GM_CTF: ItemIndex := 2;
1976 GM_SINGLE,
1977 GM_COOP: ItemIndex := 3;
1978 end;
1979 OnChange := ProcSwitchMonstersNet;
1980 end;
1981 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
1982 begin
1983 Name := 'edTimeLimit';
1984 OnlyDigits := True;
1985 Width := 4;
1986 MaxLength := 5;
1987 if gnTimeLimit > 0 then
1988 Text := IntToStr(gnTimeLimit);
1989 end;
1990 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
1991 begin
1992 Name := 'edGoalLimit';
1993 OnlyDigits := True;
1994 Width := 4;
1995 MaxLength := 5;
1996 if gnGoalLimit > 0 then
1997 Text := IntToStr(gnGoalLimit);
1998 end;
1999 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2000 begin
2001 Name := 'edMaxLives';
2002 OnlyDigits := True;
2003 Width := 4;
2004 MaxLength := 3;
2005 if gnMaxLives > 0 then
2006 Text := IntToStr(gnMaxLives);
2007 end;
2008 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2009 begin
2010 Name := 'swPlayers';
2011 AddItem(_lc[I_MENU_COUNT_NONE]);
2012 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2013 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2014 ItemIndex := gnPlayers;
2015 end;
2016 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2017 begin
2018 Name := 'swTeamDamage';
2019 AddItem(_lc[I_MENU_YES]);
2020 AddItem(_lc[I_MENU_NO]);
2021 if gnTeamDamage then
2022 ItemIndex := 0
2023 else
2024 ItemIndex := 1;
2025 end;
2026 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2027 begin
2028 Name := 'swEnableExits';
2029 AddItem(_lc[I_MENU_YES]);
2030 AddItem(_lc[I_MENU_NO]);
2031 if gnAllowExit then
2032 ItemIndex := 0
2033 else
2034 ItemIndex := 1;
2035 end;
2036 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2037 begin
2038 Name := 'swWeaponStay';
2039 AddItem(_lc[I_MENU_YES]);
2040 AddItem(_lc[I_MENU_NO]);
2041 if gnWeaponStay then
2042 ItemIndex := 0
2043 else
2044 ItemIndex := 1;
2045 end;
2046 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2047 begin
2048 Name := 'swMonsters';
2049 AddItem(_lc[I_MENU_YES]);
2050 AddItem(_lc[I_MENU_NO]);
2051 if gnMonsters then
2052 ItemIndex := 0
2053 else
2054 ItemIndex := 1;
2055 end;
2056 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2057 begin
2058 Name := 'swBotsVS';
2059 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2060 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2061 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2062 ItemIndex := 2;
2063 if gnBotsVS = 'Players' then
2064 ItemIndex := 0;
2065 if gnBotsVS = 'Monsters' then
2066 ItemIndex := 1;
2067 end;
2068 AddSpace();
2069 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2071 ReAlign();
2072 end;
2073 Menu.DefControl := 'mNetServerMenu';
2074 g_GUI_AddWindow(Menu);
2076 Menu := TGUIWindow.Create('NetClientMenu');
2077 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2078 begin
2079 Name := 'mNetClientMenu';
2081 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2082 AddSpace();
2084 with AddEdit(_lc[I_NET_ADDRESS]) do
2085 begin
2086 Name := 'edIP';
2087 OnlyDigits :=False;
2088 Width := 12;
2089 MaxLength := 64;
2090 Text := 'localhost';
2091 end;
2092 with AddEdit(_lc[I_NET_PORT]) do
2093 begin
2094 Name := 'edPort';
2095 OnlyDigits := True;
2096 Width := 4;
2097 MaxLength := 5;
2098 Text := '25666';
2099 end;
2100 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2101 begin
2102 Name := 'edPW';
2103 OnlyDigits := False;
2104 Width := 12;
2105 MaxLength := 32;
2106 Text := '';
2107 end;
2109 AddSpace();
2110 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2112 ReAlign();
2113 end;
2114 Menu.DefControl := 'mNetClientMenu';
2115 g_GUI_AddWindow(Menu);
2117 Menu := TGUIWindow.Create('LoadMenu');
2118 Menu.OnShow := ProcLoadMenu;
2119 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2120 begin
2121 Name := 'mmLoadMenu';
2123 for a := 1 to 8 do
2124 with AddEdit('') do
2125 begin
2126 Name := 'edSlot'+IntToStr(a);
2127 Width := 16;
2128 MaxLength := 16;
2129 OnEnter := ProcLoadGame;
2130 end;
2131 end;
2132 Menu.DefControl := 'mmLoadMenu';
2133 g_GUI_AddWindow(Menu);
2135 Menu := TGUIWindow.Create('SaveMenu');
2136 Menu.OnShow := ProcSaveMenu;
2137 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2138 begin
2139 Name := 'mmSaveMenu';
2141 for a := 1 to 8 do
2142 with AddEdit('') do
2143 begin
2144 Name := 'edSlot'+IntToStr(a);
2145 Width := 16;
2146 MaxLength := 16;
2147 OnChange := ProcSaveGame;
2148 end;
2149 end;
2150 Menu.DefControl := 'mmSaveMenu';
2151 g_GUI_AddWindow(Menu);
2153 Menu := TGUIWindow.Create('CustomGameMenu');
2154 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2155 begin
2156 Name := 'mCustomGameMenu';
2157 with AddLabel(_lc[I_MENU_MAP]) do
2158 begin
2159 Name := 'lbMap';
2160 FixedLength := 16;
2161 Text := gcMap;
2162 OnClick := @ProcSelectMapMenu;
2163 end;
2164 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2165 begin
2166 Name := 'swGameMode';
2167 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2168 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2169 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2170 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2171 case g_Game_TextToMode(gcGameMode) of
2172 GM_NONE,
2173 GM_DM: ItemIndex := 0;
2174 GM_TDM: ItemIndex := 1;
2175 GM_CTF: ItemIndex := 2;
2176 GM_SINGLE,
2177 GM_COOP: ItemIndex := 3;
2178 end;
2179 OnChange := ProcSwitchMonstersCustom;
2180 end;
2181 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2182 begin
2183 Name := 'edTimeLimit';
2184 OnlyDigits := True;
2185 Width := 4;
2186 MaxLength := 5;
2187 if gcTimeLimit > 0 then
2188 Text := IntToStr(gcTimeLimit);
2189 end;
2190 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2191 begin
2192 Name := 'edGoalLimit';
2193 OnlyDigits := True;
2194 Width := 4;
2195 MaxLength := 5;
2196 if gcGoalLimit > 0 then
2197 Text := IntToStr(gcGoalLimit);
2198 end;
2199 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2200 begin
2201 Name := 'edMaxLives';
2202 OnlyDigits := True;
2203 Width := 4;
2204 MaxLength := 5;
2205 if gcMaxLives > 0 then
2206 Text := IntToStr(gcMaxLives);
2207 end;
2208 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2209 begin
2210 Name := 'swPlayers';
2211 AddItem(_lc[I_MENU_COUNT_NONE]);
2212 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2213 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2214 ItemIndex := gcPlayers;
2215 end;
2216 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2217 begin
2218 Name := 'swTeamDamage';
2219 AddItem(_lc[I_MENU_YES]);
2220 AddItem(_lc[I_MENU_NO]);
2221 if gcTeamDamage then
2222 ItemIndex := 0
2223 else
2224 ItemIndex := 1;
2225 end;
2226 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2227 begin
2228 Name := 'swEnableExits';
2229 AddItem(_lc[I_MENU_YES]);
2230 AddItem(_lc[I_MENU_NO]);
2231 if gcAllowExit then
2232 ItemIndex := 0
2233 else
2234 ItemIndex := 1;
2235 end;
2236 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2237 begin
2238 Name := 'swWeaponStay';
2239 AddItem(_lc[I_MENU_YES]);
2240 AddItem(_lc[I_MENU_NO]);
2241 if gcWeaponStay then
2242 ItemIndex := 0
2243 else
2244 ItemIndex := 1;
2245 end;
2246 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2247 begin
2248 Name := 'swMonsters';
2249 AddItem(_lc[I_MENU_YES]);
2250 AddItem(_lc[I_MENU_NO]);
2251 if gcMonsters then
2252 ItemIndex := 0
2253 else
2254 ItemIndex := 1;
2255 end;
2256 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2257 begin
2258 Name := 'swBotsVS';
2259 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2260 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2261 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2262 ItemIndex := 2;
2263 if gcBotsVS = 'Players' then
2264 ItemIndex := 0;
2265 if gcBotsVS = 'Monsters' then
2266 ItemIndex := 1;
2267 end;
2268 AddSpace();
2269 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2271 ReAlign();
2272 end;
2273 Menu.DefControl := 'mCustomGameMenu';
2274 g_GUI_AddWindow(Menu);
2276 Menu := TGUIWindow.Create('CampaignMenu');
2277 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2278 begin
2279 Name := 'mCampaignMenu';
2281 AddSpace();
2282 AddSpace();
2283 AddSpace();
2284 AddSpace();
2285 AddSpace();
2286 AddSpace();
2288 with AddFileList('', 15, 4) do
2289 begin
2290 Name := 'lsWAD';
2291 OnChange := ProcSelectCampaignWAD;
2293 Sort := True;
2294 Dirs := True;
2295 FileMask := '*.wad|*.pk3|*.zip';
2296 SetBase(MapsDir+'megawads/');
2297 end;
2299 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2300 begin
2301 Name := 'lbWADName';
2302 FixedLength := 8;
2303 Enabled := False;
2304 end;
2305 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2306 begin
2307 Name := 'lbWADAuthor';
2308 FixedLength := 8;
2309 Enabled := False;
2310 end;
2311 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2312 with AddMemo('', 15, 3) do
2313 begin
2314 Name := 'meWADDescription';
2315 Color := MENU_ITEMSCTRL_COLOR;
2316 end;
2317 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2318 begin
2319 Name := 'swPlayers';
2320 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2321 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2322 end;
2323 AddSpace();
2324 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2326 ReAlign();
2328 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2329 begin
2330 Name := 'mpWADImage';
2331 DefaultRes := 'NOPIC';
2332 X := GetControl('lsWAD').X+4;
2333 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2334 end;
2335 end;
2336 Menu.DefControl := 'mCampaignMenu';
2337 g_GUI_AddWindow(Menu);
2339 Menu := TGUIWindow.Create('SelectMapMenu');
2340 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2341 begin
2342 Name := 'mSelectMapMenu';
2343 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2344 begin
2345 Name := 'lsMapWAD';
2346 OnChange := ProcSelectWAD;
2348 Sort := True;
2349 Dirs := True;
2350 FileMask := '*.wad|*.pk3|*.zip';
2351 SetBase(MapsDir);
2352 end;
2353 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2354 begin
2355 Name := 'lsMapRes';
2356 Sort := True;
2357 OnChange := ProcSelectMap;
2358 end;
2359 AddSpace();
2360 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2361 begin
2362 Name := 'lbMapName';
2363 FixedLength := 24;
2364 Enabled := False;
2365 end;
2366 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2367 begin
2368 Name := 'lbMapAuthor';
2369 FixedLength := 16;
2370 Enabled := False;
2371 end;
2372 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2373 begin
2374 Name := 'lbMapSize';
2375 FixedLength := 10;
2376 Enabled := False;
2377 end;
2378 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2379 begin
2380 Name := 'meMapDescription';
2381 end;
2383 ReAlign();
2385 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2386 begin
2387 Name := 'mpMapPreview';
2388 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2389 Y := GetControl('lsMapWAD').Y;
2390 end;
2391 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2392 begin
2393 Name := 'lbMapScale';
2394 FixedLength := 8;
2395 Enabled := False;
2396 Color := MENU_ITEMSCTRL_COLOR;
2397 X := GetControl('lsMapWAD').X +
2398 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2399 2 + MAPPREVIEW_WIDTH*4;
2400 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2401 end;
2402 end;
2403 Menu.OnClose := ProcSetMap;
2404 Menu.DefControl := 'mSelectMapMenu';
2405 g_GUI_AddWindow(Menu);
2407 Menu := TGUIWindow.Create('OptionsMenu');
2408 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2409 begin
2410 Name := 'mmOptionsMenu';
2411 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2412 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2413 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2414 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2415 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2416 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2417 AddSpace();
2418 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2419 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2420 end;
2421 Menu.OnClose := ProcApplyOptions;
2422 Menu.DefControl := 'mmOptionsMenu';
2423 g_GUI_AddWindow(Menu);
2425 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2426 gMenuSmallFont, @ProcSavedMenuKeyDown);
2427 g_GUI_AddWindow(Menu);
2429 Menu := TGUIWindow.Create('OptionsVideoMenu');
2430 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2431 begin
2432 Name := 'mOptionsVideoMenu';
2433 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2434 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2435 begin
2436 Name := 'swBPP';
2437 AddItem('16');
2438 AddItem('32');
2439 end;
2440 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2441 begin
2442 Name := 'swVSync';
2443 AddItem(_lc[I_MENU_YES]);
2444 AddItem(_lc[I_MENU_NO]);
2445 end;
2446 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2447 begin
2448 Name := 'swTextureFilter';
2449 AddItem(_lc[I_MENU_YES]);
2450 AddItem(_lc[I_MENU_NO]);
2451 end;
2452 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2453 begin
2454 Name := 'swLegacyNPOT';
2455 AddItem(_lc[I_MENU_NO]);
2456 AddItem(_lc[I_MENU_YES]);
2457 end;
2458 AddSpace();
2459 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2460 ReAlign();
2461 end;
2462 Menu.DefControl := 'mOptionsVideoMenu';
2463 g_GUI_AddWindow(Menu);
2465 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2466 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2467 begin
2468 Name := 'mOptionsVideoResMenu';
2469 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2470 begin
2471 Name := 'lbCurrentRes';
2472 FixedLength := 24;
2473 Enabled := False;
2474 end;
2475 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2476 begin
2477 Name := 'lsResolution';
2478 Sort := False;
2479 end;
2480 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2481 begin
2482 Name := 'swFullScreen';
2483 AddItem(_lc[I_MENU_YES]);
2484 AddItem(_lc[I_MENU_NO]);
2485 end;
2486 AddSpace();
2487 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2488 UpdateIndex();
2489 end;
2490 Menu.DefControl := 'mOptionsVideoResMenu';
2491 g_GUI_AddWindow(Menu);
2493 Menu := TGUIWindow.Create('OptionsSoundMenu');
2494 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2495 begin
2496 Name := 'mOptionsSoundMenu';
2497 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2498 begin
2499 Name := 'scMusicLevel';
2500 Max := 16;
2501 OnChange := ProcChangeSoundSettings;
2502 end;
2503 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2504 begin
2505 Name := 'scSoundLevel';
2506 Max := 16;
2507 OnChange := ProcChangeSoundSettings;
2508 end;
2509 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2510 begin
2511 Name := 'scMaxSimSounds';
2512 Max := 16;
2513 end;
2514 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2515 begin;
2516 Name := 'swAnnouncer';
2517 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2518 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2519 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2520 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2521 end;
2522 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2523 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2524 begin;
2525 Name := 'swSoundEffects';
2526 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2527 AddItem(_lc[I_MENU_COMPAT_DF]);
2528 end;
2529 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2530 begin
2531 Name := 'swInactiveSounds';
2532 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2533 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2534 end;
2535 ReAlign();
2536 end;
2537 Menu.DefControl := 'mOptionsSoundMenu';
2538 g_GUI_AddWindow(Menu);
2540 Menu := TGUIWindow.Create('OptionsGameMenu');
2541 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2542 begin
2543 Name := 'mOptionsGameMenu';
2544 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2545 begin
2546 Name := 'scParticlesCount';
2547 Max := 20;
2548 end;
2549 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2550 begin
2551 Name := 'swBloodCount';
2552 AddItem(_lc[I_MENU_COUNT_NONE]);
2553 AddItem(_lc[I_MENU_COUNT_SMALL]);
2554 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2555 AddItem(_lc[I_MENU_COUNT_BIG]);
2556 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2557 end;
2558 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2559 begin
2560 Name := 'scShellsMax';
2561 Max := 20;
2562 end;
2563 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2564 begin
2565 Name := 'scGibsMax';
2566 Max := 20;
2567 end;
2568 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2569 begin
2570 Name := 'scCorpsesMax';
2571 Max := 20;
2572 end;
2573 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2574 begin
2575 Name := 'swGibsCount';
2576 AddItem(_lc[I_MENU_COUNT_NONE]);
2577 AddItem(_lc[I_MENU_COUNT_SMALL]);
2578 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2579 AddItem(_lc[I_MENU_COUNT_BIG]);
2580 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2581 end;
2582 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2583 begin
2584 Name := 'swCorpseType';
2585 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2586 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2587 end;
2588 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2589 begin
2590 Name := 'swGibsType';
2591 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2592 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2593 end;
2594 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2595 begin
2596 Name := 'swBloodType';
2597 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2598 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2599 end;
2600 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2601 begin
2602 Name := 'swScreenFlash';
2603 AddItem(_lc[I_MENU_NO]);
2604 AddItem(_lc[I_MENU_COMPAT_DF]);
2605 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2606 end;
2607 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2608 begin
2609 Name := 'swBackground';
2610 AddItem(_lc[I_MENU_YES]);
2611 AddItem(_lc[I_MENU_NO]);
2612 end;
2613 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2614 begin
2615 Name := 'swMessages';
2616 AddItem(_lc[I_MENU_YES]);
2617 AddItem(_lc[I_MENU_NO]);
2618 end;
2619 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2620 begin
2621 Name := 'swRevertPlayers';
2622 AddItem(_lc[I_MENU_YES]);
2623 AddItem(_lc[I_MENU_NO]);
2624 end;
2625 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2626 begin
2627 Name := 'swChatBubble';
2628 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2629 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2630 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2631 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2632 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2633 end;
2634 ReAlign();
2635 end;
2636 Menu.DefControl := 'mOptionsGameMenu';
2637 g_GUI_AddWindow(Menu);
2639 Menu := TGUIWindow.Create('OptionsControlsMenu');
2640 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2641 begin
2642 Name := 'mOptionsControlsMenu';
2643 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2644 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2645 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2646 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2647 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2648 AddSpace();
2649 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2650 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2651 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2652 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2653 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2654 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2655 AddSpace();
2656 if e_JoysticksAvailable <> 0 then
2657 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2658 end;
2659 Menu.DefControl := 'mOptionsControlsMenu';
2660 g_GUI_AddWindow(Menu);
2662 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2663 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2664 begin
2665 Name := 'mOptionsControlsP1Menu';
2666 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2667 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2668 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2669 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2670 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2671 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2672 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2673 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2674 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2675 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2676 end;
2677 Menu.DefControl := 'mOptionsControlsP1Menu';
2678 g_GUI_AddWindow(Menu);
2680 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2681 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2682 begin
2683 Name := 'mOptionsControlsP1MenuWeapons';
2684 for i := WP_FIRST to WP_LAST do
2685 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2686 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2687 end;
2688 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2689 g_GUI_AddWindow(Menu);
2691 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2692 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2693 begin
2694 Name := 'mOptionsControlsP2Menu';
2695 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2696 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2697 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2698 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2699 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2700 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2701 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2702 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2703 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2704 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2705 end;
2706 Menu.DefControl := 'mOptionsControlsP2Menu';
2707 g_GUI_AddWindow(Menu);
2709 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2710 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2711 begin
2712 Name := 'mOptionsControlsP2MenuWeapons';
2713 for i := WP_FIRST to WP_LAST do
2714 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2715 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2716 end;
2717 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2718 g_GUI_AddWindow(Menu);
2720 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2721 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2722 begin
2723 Name := 'mOptionsControlsJoystickMenu';
2724 for i := 0 to e_JoysticksAvailable-1 do
2725 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2726 begin
2727 Name := 'scDeadzone' + IntToStr(i);
2728 Max := 20;
2729 end;
2730 end;
2731 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2732 g_GUI_AddWindow(Menu);
2734 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2735 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2736 begin
2737 Name := 'mOptionsPlayersMenu';
2738 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2739 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2740 end;
2741 Menu.DefControl := 'mOptionsPlayersMenu';
2742 g_GUI_AddWindow(Menu);
2744 CreatePlayerOptionsMenu('P1');
2745 CreatePlayerOptionsMenu('P2');
2747 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2748 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2749 begin
2750 Name := 'mOptionsPlayersMIMenu';
2751 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2752 begin
2753 Name := 'lbName';
2754 FixedLength := 16;
2755 end;
2756 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2757 begin
2758 Name := 'lbAuthor';
2759 FixedLength := 16;
2760 end;
2761 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2762 begin
2763 Name := 'meComment';
2764 end;
2765 AddSpace();
2766 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2767 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2768 begin
2769 Name := 'lbWeapon';
2770 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2771 end;
2772 ReAlign();
2773 end;
2774 Menu.DefControl := 'mOptionsPlayersMIMenu';
2775 g_GUI_AddWindow(Menu);
2777 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2778 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2779 begin
2780 Name := 'mOptionsLanguageMenu';
2781 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2782 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2783 ReAlign();
2784 end;
2785 Menu.DefControl := 'mOptionsLanguageMenu';
2786 g_GUI_AddWindow(Menu);
2788 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2789 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2790 g_GUI_AddWindow(Menu);
2792 Menu := TGUIWindow.Create('AuthorsMenu');
2793 Menu.BackTexture := 'INTER';
2794 Menu.OnClose := ProcAuthorsClose;
2796 // Çàãîëîâîê:
2797 _y := 16;
2798 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2799 begin
2800 Color := _RGB(255, 0, 0);
2801 X := (gScreenWidth div 2)-(GetWidth() div 2);
2802 Y := _y;
2803 _y := _y+GetHeight();
2804 end;
2805 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2806 begin
2807 Color := _RGB(255, 0, 0);
2808 X := (gScreenWidth div 2)-(GetWidth() div 2);
2809 Y := _y;
2810 _y := _y+GetHeight()+32;
2811 end;
2812 // ×òî äåëàë: Êòî äåëàë
2813 cx := gScreenWidth div 2 - 320 + 64;
2814 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
2815 begin
2816 Color := _RGB(255, 0, 0);
2817 X := cx;
2818 Y := _y;
2819 _y := _y+22;
2820 end;
2821 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
2822 begin
2823 Color := _RGB(255, 255, 255);
2824 X := cx+32;
2825 Y := _y;
2826 _y := _y+36;
2827 end;
2828 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
2829 begin
2830 Color := _RGB(255, 0, 0);
2831 X := cx;
2832 Y := _y;
2833 _y := _y+22;
2834 end;
2835 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
2836 begin
2837 Color := _RGB(255, 255, 255);
2838 X := cx+32;
2839 Y := _y;
2840 _y := _y+22;
2841 end;
2842 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
2843 begin
2844 Color := _RGB(255, 255, 255);
2845 X := cx+32;
2846 Y := _y;
2847 _y := _y+36;
2848 end;
2849 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
2850 begin
2851 Color := _RGB(255, 0, 0);
2852 X := cx;
2853 Y := _y;
2854 _y := _y+22;
2855 end;
2856 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
2857 begin
2858 Color := _RGB(255, 255, 255);
2859 X := cx+32;
2860 Y := _y;
2861 _y := _y+36;
2862 end;
2863 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
2864 begin
2865 Color := _RGB(255, 0, 0);
2866 X := cx;
2867 Y := _y;
2868 _y := _y+22;
2869 end;
2870 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
2871 begin
2872 Color := _RGB(255, 255, 255);
2873 X := cx+32;
2874 Y := _y;
2875 _y := gScreenHeight - 128;
2876 end;
2877 // Çàêëþ÷åíèå:
2878 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
2879 begin
2880 Color := _RGB(255, 0, 0);
2881 X := cx;
2882 Y := _y;
2883 _y := _y+16;
2884 end;
2885 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
2886 begin
2887 Color := _RGB(255, 255, 255);
2888 X := cx+32;
2889 Y := _y;
2890 _y := _y+GetHeight();
2891 end;
2892 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
2893 begin
2894 Color := _RGB(255, 255, 255);
2895 X := cx+32;
2896 Y := _y;
2897 _y := _y+GetHeight();
2898 end;
2899 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
2900 begin
2901 Color := _RGB(255, 255, 255);
2902 X := cx+32;
2903 Y := _y;
2904 _y := gScreenHeight - 32;
2905 end;
2906 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
2907 begin
2908 Color := _RGB(255, 0, 0);
2909 X := gScreenWidth div 2 - GetWidth() div 2;
2910 Y := _y;
2911 end;
2912 g_GUI_AddWindow(Menu);
2914 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
2915 gMenuSmallFont, @ProcExitMenuKeyDown);
2916 g_GUI_AddWindow(Menu);
2918 Menu := TGUIWindow.Create('GameSingleMenu');
2919 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2920 begin
2921 Name := 'mmGameSingleMenu';
2922 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2923 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2924 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2925 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2926 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2927 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2928 end;
2929 Menu.DefControl := 'mmGameSingleMenu';
2930 Menu.MainWindow := True;
2931 Menu.OnClose := ProcGMClose;
2932 Menu.OnShow := ProcGMShow;
2933 g_GUI_AddWindow(Menu);
2935 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
2936 gMenuSmallFont, @ProcEndMenuKeyDown);
2937 g_GUI_AddWindow(Menu);
2939 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
2940 gMenuSmallFont, @ProcRestartMenuKeyDown);
2941 g_GUI_AddWindow(Menu);
2943 Menu := TGUIWindow.Create('GameCustomMenu');
2944 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2945 begin
2946 Name := 'mmGameCustomMenu';
2947 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2948 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2949 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2950 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2951 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2952 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2953 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2954 end;
2955 Menu.DefControl := 'mmGameCustomMenu';
2956 Menu.MainWindow := True;
2957 Menu.OnClose := ProcGMClose;
2958 Menu.OnShow := ProcGMShow;
2959 g_GUI_AddWindow(Menu);
2961 Menu := TGUIWindow.Create('GameServerMenu');
2962 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2963 begin
2964 Name := 'mmGameServerMenu';
2965 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2966 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2967 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2968 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2969 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2970 end;
2971 Menu.DefControl := 'mmGameServerMenu';
2972 Menu.MainWindow := True;
2973 Menu.OnClose := ProcGMClose;
2974 Menu.OnShow := ProcGMShow;
2975 g_GUI_AddWindow(Menu);
2977 Menu := TGUIWindow.Create('GameClientMenu');
2978 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2979 begin
2980 Name := 'mmGameClientMenu';
2981 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2982 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2983 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2984 end;
2985 Menu.DefControl := 'mmGameClientMenu';
2986 Menu.MainWindow := True;
2987 Menu.OnClose := ProcGMClose;
2988 Menu.OnShow := ProcGMShow;
2989 g_GUI_AddWindow(Menu);
2991 Menu := TGUIWindow.Create('ClientPasswordMenu');
2992 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
2993 begin
2994 Name := 'mClientPasswordMenu';
2995 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2996 begin
2997 Name := 'edPW';
2998 Width := 12;
2999 MaxLength := 32;
3000 end;
3001 AddSpace;
3003 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3004 ReAlign();
3005 end;
3006 Menu.DefControl := 'mClientPasswordMenu';
3007 g_GUI_AddWindow(Menu);
3009 Menu := TGUIWindow.Create('GameSetGameMenu');
3010 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3011 begin
3012 Name := 'mGameSetGameMenu';
3013 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3014 begin
3015 Name := 'swTeamDamage';
3016 AddItem(_lc[I_MENU_YES]);
3017 AddItem(_lc[I_MENU_NO]);
3018 ItemIndex := 1;
3019 end;
3020 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3021 begin
3022 Name := 'edTimeLimit';
3023 OnlyDigits := True;
3024 Width := 4;
3025 MaxLength := 5;
3026 end;
3027 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3028 begin
3029 Name := 'edGoalLimit';
3030 OnlyDigits := True;
3031 Width := 4;
3032 MaxLength := 5;
3033 end;
3034 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3035 begin
3036 Name := 'edMaxLives';
3037 OnlyDigits := True;
3038 Width := 4;
3039 MaxLength := 5;
3040 end;
3041 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3042 begin
3043 Name := 'swBotsVS';
3044 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3045 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3046 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3047 ItemIndex := 2;
3048 end;
3050 ReAlign();
3051 end;
3052 Menu.DefControl := 'mGameSetGameMenu';
3053 Menu.OnClose := ProcApplyGameSet;
3054 g_GUI_AddWindow(Menu);
3056 Menu := TGUIWindow.Create('TeamMenu');
3057 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3058 begin
3059 Name := 'mmTeamMenu';
3060 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3061 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3062 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3063 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3064 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3065 end;
3066 Menu.DefControl := 'mmTeamMenu';
3067 Menu.OnShow := ProcChangePlayers;
3068 g_GUI_AddWindow(Menu);
3069 end;
3071 procedure g_Menu_Show_SaveMenu();
3072 begin
3073 if g_Game_IsTestMap then
3074 Exit;
3075 if gGameSettings.GameType = GT_SINGLE then
3076 g_GUI_ShowWindow('GameSingleMenu')
3077 else
3078 begin
3079 if g_Game_IsClient then
3080 Exit
3081 else
3082 if g_Game_IsNet then
3083 Exit
3084 else
3085 g_GUI_ShowWindow('GameCustomMenu');
3086 end;
3087 g_GUI_ShowWindow('SaveMenu');
3088 g_Sound_PlayEx('MENU_OPEN');
3089 end;
3091 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3092 begin
3093 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3094 if gGameSettings.GameType = GT_SINGLE then
3095 begin
3096 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3097 end
3098 else
3099 begin
3100 if g_Game_IsClient then exit;
3101 if g_Game_IsNet then exit;
3102 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3103 end;
3104 g_GUI_ShowWindow('LoadMenu');
3105 g_Sound_PlayEx('MENU_OPEN');
3106 end;
3108 procedure g_Menu_Show_GameSetGame();
3109 begin
3110 if gGameSettings.GameType = GT_SINGLE then
3111 g_GUI_ShowWindow('GameSingleMenu')
3112 else
3113 begin
3114 if g_Game_IsClient then
3115 Exit
3116 else
3117 if g_Game_IsNet then
3118 g_GUI_ShowWindow('GameServerMenu')
3119 else
3120 g_GUI_ShowWindow('GameCustomMenu');
3121 end;
3122 ReadGameSettings();
3123 g_GUI_ShowWindow('GameSetGameMenu');
3124 g_Sound_PlayEx('MENU_OPEN');
3125 end;
3127 procedure g_Menu_Show_OptionsVideo();
3128 begin
3129 if gGameSettings.GameType = GT_SINGLE then
3130 g_GUI_ShowWindow('GameSingleMenu')
3131 else
3132 begin
3133 if g_Game_IsClient then
3134 g_GUI_ShowWindow('GameClientMenu')
3135 else
3136 if g_Game_IsNet then
3137 g_GUI_ShowWindow('GameServerMenu')
3138 else
3139 g_GUI_ShowWindow('GameCustomMenu');
3140 end;
3141 ReadOptions();
3142 g_GUI_ShowWindow('OptionsMenu');
3143 g_GUI_ShowWindow('OptionsVideoMenu');
3144 g_Sound_PlayEx('MENU_OPEN');
3145 end;
3147 procedure g_Menu_Show_OptionsSound();
3148 begin
3149 if gGameSettings.GameType = GT_SINGLE then
3150 g_GUI_ShowWindow('GameSingleMenu')
3151 else
3152 begin
3153 if g_Game_IsClient then
3154 g_GUI_ShowWindow('GameClientMenu')
3155 else
3156 if g_Game_IsNet then
3157 g_GUI_ShowWindow('GameServerMenu')
3158 else
3159 g_GUI_ShowWindow('GameCustomMenu');
3160 end;
3161 ReadOptions();
3162 g_GUI_ShowWindow('OptionsMenu');
3163 g_GUI_ShowWindow('OptionsSoundMenu');
3164 g_Sound_PlayEx('MENU_OPEN');
3165 end;
3167 procedure g_Menu_Show_EndGameMenu();
3168 begin
3169 g_GUI_ShowWindow('EndGameMenu');
3170 g_Sound_PlayEx('MENU_OPEN');
3171 end;
3173 procedure g_Menu_Show_QuitGameMenu();
3174 begin
3175 g_GUI_ShowWindow('ExitMenu');
3176 g_Sound_PlayEx('MENU_OPEN');
3177 end;
3179 procedure g_Menu_Init();
3180 begin
3181 MenuLoadData();
3182 g_GUI_Init();
3183 CreateAllMenus();
3184 end;
3186 procedure g_Menu_Free();
3187 begin
3188 g_GUI_Destroy();
3190 e_WriteLog('Releasing menu data...', MSG_NOTIFY);
3192 MenuFreeData();
3193 end;
3195 procedure g_Menu_Reset();
3196 var
3197 ex: Boolean;
3198 begin
3199 g_GUI_SaveMenuPos();
3200 ex := g_GUI_Destroy();
3202 if ex then
3203 begin
3204 e_WriteLog('Recreating menu...', MSG_NOTIFY);
3206 CreateAllMenus();
3208 if gDebugMode then
3209 g_Game_SetDebugMode();
3211 g_GUI_LoadMenuPos();
3212 end;
3213 end;
3215 end.