DEADSOFTWARE

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