DEADSOFTWARE

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