DEADSOFTWARE

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