DEADSOFTWARE

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