DEADSOFTWARE

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