DEADSOFTWARE

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