DEADSOFTWARE

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