DEADSOFTWARE

added opengl and sdl2 wrappers to allegro (WIP)
[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', 1), 1), 255);
955 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 1), 1), 255);
956 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
958 e_LogWritefln('LoadStdFont cwdt=%s chgt=%s spc=%s', [cwdt, chgt, spc]);
960 if g_Texture_Get('FONT_STD', ID) then
961 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
963 config.Free();
964 end;
966 if cfglen <> 0 then FreeMem(cfgdata);
967 end;
969 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
970 var
971 cwdt, chgt: Byte;
972 spc: ShortInt;
973 CharID: DWORD;
974 wad: TWADFile;
975 cfgdata, fntdata: Pointer;
976 cfglen, fntlen: Integer;
977 config: TConfig;
978 chrwidth: Integer;
979 a: Byte;
980 begin
981 cfglen := 0;
982 fntlen := 0;
984 wad := TWADFile.Create;
985 if wad.ReadFile(GameWAD) then
986 begin
987 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
988 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
989 end;
990 wad.Free();
992 if cfglen <> 0 then
993 begin
994 config := TConfig.CreateMem(cfgdata, cfglen);
995 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
996 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
998 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
999 FontID := e_CharFont_Create(spc);
1001 for a := 0 to 255 do
1002 begin
1003 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1004 if chrwidth = 0 then Continue;
1006 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1007 cwdt, chgt) then
1008 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1009 end;
1011 config.Free();
1012 end;
1014 if cfglen <> 0 then FreeMem(cfgdata);
1015 if fntlen <> 0 then FreeMem(fntdata);
1016 end;
1018 procedure MenuLoadData();
1019 begin
1020 e_WriteLog('Loading menu data...', TMsgType.Notify);
1022 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1023 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1024 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1025 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1026 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1027 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1028 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1029 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1030 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1031 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1032 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1033 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1034 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1035 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1036 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1037 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1038 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1039 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1040 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1041 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1042 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1043 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1044 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1045 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1047 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1048 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1049 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1050 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1051 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1052 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1053 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1054 end;
1056 procedure MenuFreeData();
1057 begin
1058 e_CharFont_Remove(gMenuFont);
1059 e_CharFont_Remove(gMenuSmallFont);
1061 g_Texture_Delete('MAINMENU_MARKER1');
1062 g_Texture_Delete('MAINMENU_MARKER2');
1063 g_Texture_Delete('SCROLL_LEFT');
1064 g_Texture_Delete('SCROLL_RIGHT');
1065 g_Texture_Delete('SCROLL_MIDDLE');
1066 g_Texture_Delete('SCROLL_MARKER');
1067 g_Texture_Delete('EDIT_LEFT');
1068 g_Texture_Delete('EDIT_RIGHT');
1069 g_Texture_Delete('EDIT_MIDDLE');
1070 g_Texture_Delete('BOX1');
1071 g_Texture_Delete('BOX2');
1072 g_Texture_Delete('BOX3');
1073 g_Texture_Delete('BOX4');
1074 g_Texture_Delete('BOX5');
1075 g_Texture_Delete('BOX6');
1076 g_Texture_Delete('BOX7');
1077 g_Texture_Delete('BOX8');
1078 g_Texture_Delete('BOX9');
1079 g_Texture_Delete('BSCROLL_UP_A');
1080 g_Texture_Delete('BSCROLL_UP_U');
1081 g_Texture_Delete('BSCROLL_DOWN_A');
1082 g_Texture_Delete('BSCROLL_DOWN_U');
1083 g_Texture_Delete('BSCROLL_MIDDLE');
1084 g_Texture_Delete('NOPIC');
1086 g_Sound_Delete('MENU_SELECT');
1087 g_Sound_Delete('MENU_OPEN');
1088 g_Sound_Delete('MENU_CLOSE');
1089 g_Sound_Delete('MENU_CHANGE');
1090 g_Sound_Delete('SCROLL_ADD');
1091 g_Sound_Delete('SCROLL_SUB');
1092 g_Sound_Delete('SOUND_PLAYER_FALL');
1093 end;
1095 procedure ProcAuthorsMenu();
1096 begin
1097 gMusic.SetByName('MUSIC_INTERMUS');
1098 gMusic.Play();
1099 end;
1101 procedure ProcExitMenuKeyDown (yes: Boolean);
1102 var
1103 s: ShortString;
1104 snd: TPlayableSound;
1105 res: Boolean;
1106 begin
1107 if yes then
1108 begin
1109 g_Game_StopAllSounds(True);
1110 case (Random(18)) of
1111 0: s := 'SOUND_MONSTER_PAIN';
1112 1: s := 'SOUND_MONSTER_DIE_3';
1113 2: s := 'SOUND_MONSTER_SLOP';
1114 3: s := 'SOUND_MONSTER_DEMON_DIE';
1115 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1116 5: s := 'SOUND_MONSTER_MAN_DIE';
1117 6: s := 'SOUND_MONSTER_BSP_DIE';
1118 7: s := 'SOUND_MONSTER_VILE_DIE';
1119 8: s := 'SOUND_MONSTER_SKEL_DIE';
1120 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1121 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1122 11: s := 'SOUND_MONSTER_BARON_DIE';
1123 12: s := 'SOUND_MONSTER_CACO_DIE';
1124 13: s := 'SOUND_MONSTER_CYBER_DIE';
1125 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1126 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1127 else s := 'SOUND_PLAYER_FALL';
1128 end;
1129 snd := TPlayableSound.Create();
1130 res := snd.SetByName(s);
1131 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1132 if res then
1133 begin
1134 snd.Play(True);
1135 while snd.IsPlaying() do begin end;
1136 end;
1137 g_Game_Quit();
1138 exit;
1139 end;
1140 g_GUI_HideWindow();
1141 end;
1143 procedure ProcLoadMenu();
1144 var
1145 a: Integer;
1146 valid: Boolean;
1147 begin
1148 for a := 1 to 8 do
1149 begin
1150 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1151 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1152 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1153 end;
1154 end;
1156 procedure ProcSaveMenu();
1157 var
1158 a: Integer;
1159 valid: Boolean;
1160 name: AnsiString;
1161 begin
1162 for a := 1 to 8 do
1163 begin
1164 name := g_GetSaveName(a, valid);
1165 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1166 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1167 end;
1168 end;
1170 procedure ProcSaveGame(Sender: TGUIControl);
1171 var
1172 a: Integer;
1173 begin
1174 if g_Game_IsNet then Exit;
1175 if g_Game_IsTestMap then Exit;
1176 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1177 g_Game_PauseAllSounds(True);
1178 g_SaveGame(a, TGUIEdit(Sender).Text);
1180 g_ActiveWindow := nil;
1181 g_Game_Pause(False);
1182 end;
1184 procedure ProcLoadGame(Sender: TGUIControl);
1185 var
1186 a: Integer;
1187 begin
1188 if g_Game_IsNet then Exit;
1189 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1190 if g_LoadGame(a) then
1191 begin
1192 g_Game_PauseAllSounds(False)
1193 end
1194 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1195 begin
1196 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1197 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1198 //g_ActiveWindow := nil;
1199 end;
1200 end;
1202 procedure ProcSingle1Player();
1203 begin
1204 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1205 end;
1207 procedure ProcSingle2Players();
1208 begin
1209 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1210 end;
1212 procedure ProcSelectMapMenu();
1213 var
1214 menu: TGUIMenu;
1215 wad_lb: TGUIFileListBox;
1216 map_lb: TGUIListBox;
1217 map: String;
1218 begin
1219 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1220 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1221 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1223 if wad_lb.SelectedItem() <> '' then
1224 map := map_lb.SelectedItem()
1225 else
1226 map := '';
1228 wad_lb.UpdateFileList();
1229 map_lb.Clear();
1231 if wad_lb.SelectedItem() <> '' then
1232 begin
1233 ProcSelectWAD(nil);
1234 map_lb.SelectItem(map);
1236 if map_lb.SelectedItem() <> '' then
1237 ProcSelectMap(nil);
1238 end;
1240 g_GUI_ShowWindow('SelectMapMenu');
1241 end;
1243 procedure ProcSelectCampaignMenu();
1244 var
1245 menu: TGUIMenu;
1246 wad_lb: TGUIFileListBox;
1247 begin
1248 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1249 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1251 wad_lb.UpdateFileList();
1253 if wad_lb.SelectedItem() <> '' then
1254 ProcSelectCampaignWAD(nil);
1255 end;
1257 procedure ProcSetMap();
1258 var
1259 wad, map, res: String;
1260 begin
1261 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1262 begin
1263 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1264 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1265 end;
1267 if (wad = '') or (map = '') then
1268 Exit;
1270 res := wad+':\'+map;
1272 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1273 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1274 end;
1276 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1277 var
1278 menu: TGUIMenu;
1279 begin
1280 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1282 g_Sound_SetupAllVolumes(
1283 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1284 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1285 );
1286 end;
1288 procedure ProcChangeGameSettings(Sender: TGUIControl);
1289 var
1290 menu: TGUIMenu;
1291 begin
1292 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1293 g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
1294 end;
1296 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1297 var
1298 menu: TGUIMenu;
1299 begin
1300 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1301 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1302 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1303 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1304 end;
1306 procedure ProcOptionsPlayersMIMenu();
1307 var
1308 s, a: string;
1309 b: TModelInfo;
1310 begin
1311 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1313 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1315 if a = '' then Exit;
1317 b := g_PlayerModel_GetInfo(a);
1319 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1320 begin
1321 TGUILabel(GetControl('lbName')).Text := b.Name;
1322 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1323 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1325 if b.HaveWeapon then
1326 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1327 else
1328 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1329 end;
1331 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1332 end;
1334 procedure ProcOptionsPlayersAnim();
1335 var
1336 s: String;
1337 begin
1338 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1339 s := 'P1'
1340 else
1341 s := 'P2';
1343 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1344 begin
1345 NextAnim();
1346 Model.GetCurrentAnimation.Loop := True;
1347 Model.GetCurrentAnimationMask.Loop := True;
1348 end;
1349 end;
1351 procedure ProcOptionsPlayersWeap();
1352 var
1353 s: String;
1354 begin
1355 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1356 s := 'P1'
1357 else
1358 s := 'P2';
1360 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1361 NextWeapon();
1362 end;
1364 procedure ProcOptionsPlayersRot();
1365 var
1366 s: string;
1367 begin
1368 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1369 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1370 begin
1371 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1372 end;
1373 end;
1375 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1376 begin
1377 if yes then
1378 begin
1379 g_Options_SetDefault();
1380 ReadOptions();
1381 end;
1382 g_GUI_HideWindow();
1383 end;
1385 procedure ProcSavedMenuKeyDown (yes: Boolean);
1386 begin
1387 if yes then ReadOptions();
1388 g_GUI_HideWindow();
1389 end;
1391 procedure ProcAuthorsClose();
1392 begin
1393 gMusic.SetByName('MUSIC_MENU');
1394 gMusic.Play();
1395 gState := STATE_MENU;
1396 end;
1398 procedure ProcGMClose();
1399 begin
1400 g_Game_InGameMenu(False);
1401 end;
1403 procedure ProcGMShow();
1404 var
1405 Enabled: Boolean;
1406 begin
1407 Enabled := True;
1408 if (gGameSettings.GameType = GT_SINGLE) and
1409 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1410 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1411 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1412 if not gGameOn then
1413 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1414 if g_Game_IsTestMap then
1415 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1416 TGUIMainMenu(g_ActiveWindow.GetControl(
1417 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1418 end;
1420 procedure ProcChangePlayers();
1421 var
1422 TeamGame, Spectator, AddTwo: Boolean;
1423 P1Team{, P2Team}: Byte;
1424 bP2: TGUITextButton;
1425 begin
1426 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1427 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1428 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1429 P1Team := TEAM_NONE;
1430 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1431 // TODO
1432 //P2Team := TEAM_NONE;
1433 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1435 TGUIMainMenu(g_ActiveWindow.GetControl(
1436 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1437 TGUIMainMenu(g_ActiveWindow.GetControl(
1438 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1439 TGUIMainMenu(g_ActiveWindow.GetControl(
1440 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1442 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1443 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1444 bP2.Enabled := AddTwo and not Spectator;
1445 if bP2.Enabled then
1446 bP2.Color := MAINMENU_ITEMS_COLOR
1447 else
1448 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1449 if gPlayer2 = nil then
1450 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1451 else
1452 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1454 TGUIMainMenu(g_ActiveWindow.GetControl(
1455 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1456 end;
1458 procedure ProcJoinRed();
1459 begin
1460 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1461 Exit;
1462 if g_Game_IsServer then
1463 begin
1464 if gPlayer1 = nil then
1465 g_Game_AddPlayer(TEAM_RED)
1466 else
1467 begin
1468 if gPlayer1.Team <> TEAM_RED then
1469 begin
1470 gPlayer1.SwitchTeam;
1471 gPlayer1Settings.Team := gPlayer1.Team;
1472 end;
1474 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1475 end;
1476 end
1477 else
1478 begin
1479 gPlayer1Settings.Team := TEAM_RED;
1480 MC_SEND_PlayerSettings;
1481 if gPlayer1 = nil then
1482 g_Game_AddPlayer(TEAM_RED);
1483 end;
1484 g_ActiveWindow := nil;
1485 g_Game_Pause(False);
1486 end;
1488 procedure ProcJoinBlue();
1489 begin
1490 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1491 Exit;
1492 if g_Game_IsServer then
1493 begin
1494 if gPlayer1 = nil then
1495 g_Game_AddPlayer(TEAM_BLUE)
1496 else
1497 begin
1498 if gPlayer1.Team <> TEAM_BLUE then
1499 begin
1500 gPlayer1.SwitchTeam;
1501 gPlayer1Settings.Team := gPlayer1.Team;
1502 end;
1504 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1505 end;
1506 end
1507 else
1508 begin
1509 gPlayer1Settings.Team := TEAM_BLUE;
1510 MC_SEND_PlayerSettings;
1511 if gPlayer1 = nil then
1512 g_Game_AddPlayer(TEAM_BLUE);
1513 end;
1514 g_ActiveWindow := nil;
1515 g_Game_Pause(False);
1516 end;
1518 procedure ProcJoinGame();
1519 begin
1520 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1521 Exit;
1522 if gPlayer1 = nil then
1523 g_Game_AddPlayer();
1524 g_ActiveWindow := nil;
1525 g_Game_Pause(False);
1526 end;
1528 procedure ProcSwitchP2();
1529 begin
1530 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1531 Exit;
1532 if gPlayer1 = nil then
1533 Exit;
1534 if gPlayer2 = nil then
1535 g_Game_AddPlayer()
1536 else
1537 g_Game_RemovePlayer();
1538 g_ActiveWindow := nil;
1539 g_Game_Pause(False);
1540 end;
1542 procedure ProcSpectate();
1543 begin
1544 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1545 Exit;
1546 g_Game_Spectate();
1547 g_ActiveWindow := nil;
1548 g_Game_Pause(False);
1549 end;
1551 procedure ProcRestartMenuKeyDown (yes: Boolean);
1552 begin
1553 if yes then g_Game_Restart() else g_GUI_HideWindow;
1554 end;
1556 procedure ProcEndMenuKeyDown (yes: Boolean);
1557 begin
1558 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1559 end;
1561 procedure ProcSetRussianLanguage();
1562 begin
1563 if gLanguage <> LANGUAGE_RUSSIAN then
1564 begin
1565 gLanguage := LANGUAGE_RUSSIAN;
1566 gLanguageChange := True;
1567 gAskLanguage := False;
1569 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1571 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1572 ProcApplyOptions();
1573 end;
1574 end;
1576 procedure ProcSetEnglishLanguage();
1577 begin
1578 if gLanguage <> LANGUAGE_ENGLISH then
1579 begin
1580 gLanguage := LANGUAGE_ENGLISH;
1581 gLanguageChange := True;
1582 gAskLanguage := False;
1584 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1586 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1587 ProcApplyOptions();
1588 end;
1589 end;
1591 procedure ReadGameSettings();
1592 var
1593 menu: TGUIMenu;
1594 begin
1595 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1597 with gGameSettings do
1598 begin
1599 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1600 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1601 ItemIndex := 0
1602 else
1603 ItemIndex := 1;
1605 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1606 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1607 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1609 with TGUISwitch(menu.GetControl('swBotsVS')) do
1610 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1611 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1612 ItemIndex := 2
1613 else
1614 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1615 ItemIndex := 1
1616 else
1617 ItemIndex := 0;
1619 if GameType in [GT_CUSTOM, GT_SERVER] then
1620 begin
1621 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1622 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1623 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1624 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1625 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1626 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1627 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1628 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1629 end
1630 else
1631 begin
1632 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1633 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1634 begin
1635 Enabled := False;
1636 Text := '';
1637 end;
1638 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1639 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1640 begin
1641 Enabled := False;
1642 Text := '';
1643 end;
1644 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1645 with TGUIEdit(menu.GetControl('edMaxLives')) do
1646 begin
1647 Enabled := False;
1648 Text := '';
1649 end;
1650 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1651 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1652 end;
1653 end;
1654 end;
1656 procedure ProcApplyGameSet();
1657 var
1658 menu: TGUIMenu;
1659 a, b, n: Integer;
1660 stat: TPlayerStatArray;
1661 begin
1662 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1664 if not g_Game_IsServer then Exit;
1666 with gGameSettings do
1667 begin
1668 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1669 begin
1670 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1671 Options := Options or GAME_OPTION_TEAMDAMAGE
1672 else
1673 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1674 end;
1676 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1677 begin
1678 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1680 if n = 0 then
1681 TimeLimit := 0
1682 else
1683 begin
1684 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1686 TimeLimit := Max(n, b);
1687 end;
1688 end;
1690 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1691 begin
1692 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1694 if n = 0 then
1695 GoalLimit := 0
1696 else
1697 begin
1698 b := 0;
1699 if GameMode = GM_DM then
1700 begin // DM
1701 stat := g_Player_GetStats();
1702 if stat <> nil then
1703 for a := 0 to High(stat) do
1704 if stat[a].Frags > b then
1705 b := stat[a].Frags;
1706 end
1707 else // CTF
1708 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1710 GoalLimit := Max(n, b);
1711 end;
1712 end;
1714 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1715 begin
1716 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1717 if n < 0 then n := 0;
1718 if n > 255 then n := 255;
1719 if n = 0 then
1720 MaxLives := 0
1721 else
1722 begin
1723 b := 0;
1724 stat := g_Player_GetStats();
1725 if stat <> nil then
1726 for a := 0 to High(stat) do
1727 if stat[a].Lives > b then
1728 b := stat[a].Lives;
1730 MaxLives := Max(n, b);
1731 end;
1732 end;
1734 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1735 begin
1736 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1737 1:
1738 begin
1739 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1740 Options := Options or GAME_OPTION_BOTVSMONSTER;
1741 end;
1742 2:
1743 begin
1744 Options := Options or GAME_OPTION_BOTVSPLAYER;
1745 Options := Options or GAME_OPTION_BOTVSMONSTER;
1746 end;
1747 else
1748 begin
1749 Options := Options or GAME_OPTION_BOTVSPLAYER;
1750 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1751 end;
1752 end;
1753 end;
1754 end;
1756 if g_Game_IsNet then MH_SEND_GameSettings;
1757 end;
1759 procedure ProcVideoOptionsRes();
1760 var
1761 menu: TGUIMenu;
1762 list: SSArray;
1763 SR: DWORD;
1764 begin
1765 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1767 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1768 IntToStr(gScreenWidth) +
1769 ' x ' + IntToStr(gScreenHeight) +
1770 ', ' + IntToStr(gBPP) + ' bpp';
1772 with TGUIListBox(menu.GetControl('lsResolution')) do
1773 begin
1774 list := GetDisplayModes(gBPP, SR);
1776 if list <> nil then
1777 begin
1778 Items := list;
1779 ItemIndex := SR;
1780 end
1781 else
1782 Clear();
1783 end;
1785 with TGUISwitch(menu.GetControl('swFullScreen')) do
1786 if gFullscreen then
1787 ItemIndex := 0
1788 else
1789 ItemIndex := 1;
1790 end;
1792 procedure ProcApplyVideoOptions();
1793 var
1794 menu: TGUIMenu;
1795 Fullscreen: Boolean;
1796 SWidth, SHeight: Integer;
1797 str: String;
1798 begin
1799 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1801 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1802 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1804 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1806 if (SWidth <> gScreenWidth) or
1807 (SHeight <> gScreenHeight) or
1808 (Fullscreen <> gFullscreen) then
1809 begin
1810 gResolutionChange := True;
1811 gRC_Width := SWidth;
1812 gRC_Height := SHeight;
1813 gRC_FullScreen := Fullscreen;
1814 gRC_Maximized := gWinMaximized;
1815 end;
1817 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1818 ProcApplyOptions();
1819 end;
1821 procedure ProcSetFirstRussianLanguage();
1822 begin
1823 gLanguage := LANGUAGE_RUSSIAN;
1824 gLanguageChange := True;
1825 gAskLanguage := False;
1827 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1828 end;
1830 procedure ProcSetFirstEnglishLanguage();
1831 begin
1832 gLanguage := LANGUAGE_ENGLISH;
1833 gLanguageChange := True;
1834 gAskLanguage := False;
1836 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1837 end;
1839 procedure ProcRecallAddress();
1840 begin
1841 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1842 begin
1843 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1844 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1845 end;
1846 end;
1848 procedure CreateFirstLanguageMenu();
1849 var
1850 Menu: TGUIWindow;
1851 begin
1852 Menu := TGUIWindow.Create('FirstLanguageMenu');
1854 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1855 begin
1856 Name := 'mmFirstLanguageMenu';
1857 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1858 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1859 end;
1861 Menu.DefControl := 'mmFirstLanguageMenu';
1862 Menu.MainWindow := True;
1863 g_GUI_AddWindow(Menu);
1864 end;
1866 procedure g_Menu_AskLanguage();
1867 begin
1868 CreateFirstLanguageMenu();
1869 g_GUI_ShowWindow('FirstLanguageMenu');
1870 end;
1872 procedure CreatePlayerOptionsMenu(s: String);
1873 var
1874 Menu: TGUIWindow;
1875 a: String;
1876 begin
1877 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1878 if s = 'P1' then
1879 a := _lc[I_MENU_PLAYER_1]
1880 else
1881 a := _lc[I_MENU_PLAYER_2];
1882 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1883 begin
1884 Name := 'mOptionsPlayers'+s+'Menu';
1885 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1886 begin
1887 Name := 'ed'+s+'Name';
1888 MaxLength := 12;
1889 Width := 12;
1890 end;
1891 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1892 begin
1893 Name := 'sw'+s+'Team';
1894 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1895 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1896 end ;
1897 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1898 begin
1899 Name := 'ls'+s+'Model';
1900 Sort := True;
1901 Items := g_PlayerModel_GetNames();
1902 OnChange := ProcSelectModel;
1903 end;
1904 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1905 begin
1906 Name := 'sc'+s+'Red';
1907 Max := 16;
1908 OnChange := ProcChangeColor;
1909 end;
1910 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1911 begin
1912 Name := 'sc'+s+'Green';
1913 Max := 16;
1914 OnChange := ProcChangeColor;
1915 end;
1916 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1917 begin
1918 Name := 'sc'+s+'Blue';
1919 Max := 16;
1920 OnChange := ProcChangeColor;
1921 end;
1922 AddSpace();
1923 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1924 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1925 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1926 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1928 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1929 begin
1930 Name := 'mv'+s+'Model';
1931 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1932 Y := GetControl('ls'+s+'Model').Y;
1933 end;
1934 end;
1935 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1936 g_GUI_AddWindow(Menu);
1937 end;
1939 procedure CreateAllMenus();
1940 var
1941 Menu: TGUIWindow;
1942 //SR: TSearchRec;
1943 a, cx, _y, i: Integer;
1944 //list: SSArray;
1945 begin
1946 Menu := TGUIWindow.Create('MainMenu');
1947 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1948 begin
1949 Name := 'mmMainMenu';
1950 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1951 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1952 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1953 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1954 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1955 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1956 end;
1957 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1958 begin
1959 Color := _RGB(255, 255, 255);
1960 X := gScreenWidth-GetWidth-8;
1961 Y := gScreenHeight-GetHeight-8;
1962 end;
1963 Menu.DefControl := 'mmMainMenu';
1964 Menu.MainWindow := True;
1965 g_GUI_AddWindow(Menu);
1967 Menu := TGUIWindow.Create('NewGameMenu');
1968 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
1969 begin
1970 Name := 'mmNewGameMenu';
1971 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1972 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1973 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1974 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1975 end;
1976 Menu.DefControl := 'mmNewGameMenu';
1977 g_GUI_AddWindow(Menu);
1979 Menu := TGUIWindow.Create('NetGameMenu');
1980 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
1981 begin
1982 Name := 'mmNetGameMenu';
1983 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1984 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1985 end;
1986 Menu.DefControl := 'mmNetGameMenu';
1987 g_GUI_AddWindow(Menu);
1989 Menu := TGUIWindow.Create('NetServerMenu');
1990 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
1991 begin
1992 Name := 'mNetServerMenu';
1993 with AddEdit(_lc[I_NET_SERVER_NAME]) do
1994 begin
1995 Name := 'edSrvName';
1996 OnlyDigits := False;
1997 Width := 16;
1998 MaxLength := 64;
1999 Text := NetServerName;
2000 end;
2001 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2002 begin
2003 Name := 'edSrvPassword';
2004 OnlyDigits := False;
2005 Width := 16;
2006 MaxLength := 24;
2007 Text := NetPassword;
2008 end;
2009 with AddEdit(_lc[I_NET_PORT]) do
2010 begin
2011 Name := 'edPort';
2012 OnlyDigits := True;
2013 Width := 4;
2014 MaxLength := 5;
2015 Text := IntToStr(NetPort);
2016 end;
2017 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2018 begin
2019 Name := 'edMaxPlayers';
2020 OnlyDigits := True;
2021 Width := 4;
2022 MaxLength := 2;
2023 Text := IntToStr(NetMaxClients);
2024 end;
2025 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2026 begin
2027 Name := 'swUseMaster';
2028 AddItem(_lc[I_MENU_YES]);
2029 AddItem(_lc[I_MENU_NO]);
2030 if NetUseMaster then
2031 ItemIndex := 0
2032 else
2033 ItemIndex := 1;
2034 end;
2035 AddSpace();
2036 with AddLabel(_lc[I_MENU_MAP]) do
2037 begin
2038 Name := 'lbMap';
2039 FixedLength := 16;
2040 Text := gnMap;
2041 OnClick := @ProcSelectMapMenu;
2042 end;
2043 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2044 begin
2045 Name := 'swGameMode';
2046 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2047 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2048 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2049 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2050 case g_Game_TextToMode(gnGameMode) of
2051 GM_NONE,
2052 GM_DM: ItemIndex := 0;
2053 GM_TDM: ItemIndex := 1;
2054 GM_CTF: ItemIndex := 2;
2055 GM_SINGLE,
2056 GM_COOP: ItemIndex := 3;
2057 end;
2058 OnChange := ProcSwitchMonstersNet;
2059 end;
2060 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2061 begin
2062 Name := 'edTimeLimit';
2063 OnlyDigits := True;
2064 Width := 4;
2065 MaxLength := 5;
2066 if gnTimeLimit > 0 then
2067 Text := IntToStr(gnTimeLimit);
2068 end;
2069 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2070 begin
2071 Name := 'edGoalLimit';
2072 OnlyDigits := True;
2073 Width := 4;
2074 MaxLength := 5;
2075 if gnGoalLimit > 0 then
2076 Text := IntToStr(gnGoalLimit);
2077 end;
2078 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2079 begin
2080 Name := 'edMaxLives';
2081 OnlyDigits := True;
2082 Width := 4;
2083 MaxLength := 3;
2084 if gnMaxLives > 0 then
2085 Text := IntToStr(gnMaxLives);
2086 end;
2087 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2088 begin
2089 Name := 'swPlayers';
2090 AddItem(_lc[I_MENU_COUNT_NONE]);
2091 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2092 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2093 ItemIndex := gnPlayers;
2094 end;
2095 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2096 begin
2097 Name := 'swTeamDamage';
2098 AddItem(_lc[I_MENU_YES]);
2099 AddItem(_lc[I_MENU_NO]);
2100 if gnTeamDamage then
2101 ItemIndex := 0
2102 else
2103 ItemIndex := 1;
2104 end;
2105 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2106 begin
2107 Name := 'swEnableExits';
2108 AddItem(_lc[I_MENU_YES]);
2109 AddItem(_lc[I_MENU_NO]);
2110 if gnAllowExit then
2111 ItemIndex := 0
2112 else
2113 ItemIndex := 1;
2114 end;
2115 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2116 begin
2117 Name := 'swWeaponStay';
2118 AddItem(_lc[I_MENU_YES]);
2119 AddItem(_lc[I_MENU_NO]);
2120 if gnWeaponStay then
2121 ItemIndex := 0
2122 else
2123 ItemIndex := 1;
2124 end;
2125 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2126 begin
2127 Name := 'swMonsters';
2128 AddItem(_lc[I_MENU_YES]);
2129 AddItem(_lc[I_MENU_NO]);
2130 if gnMonsters then
2131 ItemIndex := 0
2132 else
2133 ItemIndex := 1;
2134 end;
2135 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2136 begin
2137 Name := 'swBotsVS';
2138 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2139 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2140 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2141 ItemIndex := 2;
2142 if gnBotsVS = 'Players' then
2143 ItemIndex := 0;
2144 if gnBotsVS = 'Monsters' then
2145 ItemIndex := 1;
2146 end;
2147 AddSpace();
2148 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2150 ReAlign();
2151 end;
2152 Menu.DefControl := 'mNetServerMenu';
2153 g_GUI_AddWindow(Menu);
2155 Menu := TGUIWindow.Create('NetClientMenu');
2156 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2157 begin
2158 Name := 'mNetClientMenu';
2160 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2161 AddSpace();
2163 with AddEdit(_lc[I_NET_ADDRESS]) do
2164 begin
2165 Name := 'edIP';
2166 OnlyDigits :=False;
2167 Width := 12;
2168 MaxLength := 64;
2169 Text := 'localhost';
2170 end;
2171 with AddEdit(_lc[I_NET_PORT]) do
2172 begin
2173 Name := 'edPort';
2174 OnlyDigits := True;
2175 Width := 4;
2176 MaxLength := 5;
2177 Text := '25666';
2178 end;
2179 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2180 begin
2181 Name := 'edPW';
2182 OnlyDigits := False;
2183 Width := 12;
2184 MaxLength := 32;
2185 Text := '';
2186 end;
2188 AddSpace();
2189 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2191 ReAlign();
2192 end;
2193 Menu.DefControl := 'mNetClientMenu';
2194 g_GUI_AddWindow(Menu);
2196 Menu := TGUIWindow.Create('LoadMenu');
2197 Menu.OnShow := ProcLoadMenu;
2198 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2199 begin
2200 Name := 'mmLoadMenu';
2202 for a := 1 to 8 do
2203 with AddEdit('') do
2204 begin
2205 Name := 'edSlot'+IntToStr(a);
2206 Width := 16;
2207 MaxLength := 16;
2208 OnEnter := ProcLoadGame;
2209 end;
2210 end;
2211 Menu.DefControl := 'mmLoadMenu';
2212 g_GUI_AddWindow(Menu);
2214 Menu := TGUIWindow.Create('SaveMenu');
2215 Menu.OnShow := ProcSaveMenu;
2216 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2217 begin
2218 Name := 'mmSaveMenu';
2220 for a := 1 to 8 do
2221 with AddEdit('') do
2222 begin
2223 Name := 'edSlot'+IntToStr(a);
2224 Width := 16;
2225 MaxLength := 16;
2226 OnChange := ProcSaveGame;
2227 end;
2228 end;
2229 Menu.DefControl := 'mmSaveMenu';
2230 g_GUI_AddWindow(Menu);
2232 Menu := TGUIWindow.Create('CustomGameMenu');
2233 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2234 begin
2235 Name := 'mCustomGameMenu';
2236 with AddLabel(_lc[I_MENU_MAP]) do
2237 begin
2238 Name := 'lbMap';
2239 FixedLength := 16;
2240 Text := gcMap;
2241 OnClick := @ProcSelectMapMenu;
2242 end;
2243 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2244 begin
2245 Name := 'swGameMode';
2246 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2247 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2248 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2249 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2250 case g_Game_TextToMode(gcGameMode) of
2251 GM_NONE,
2252 GM_DM: ItemIndex := 0;
2253 GM_TDM: ItemIndex := 1;
2254 GM_CTF: ItemIndex := 2;
2255 GM_SINGLE,
2256 GM_COOP: ItemIndex := 3;
2257 end;
2258 OnChange := ProcSwitchMonstersCustom;
2259 end;
2260 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2261 begin
2262 Name := 'edTimeLimit';
2263 OnlyDigits := True;
2264 Width := 4;
2265 MaxLength := 5;
2266 if gcTimeLimit > 0 then
2267 Text := IntToStr(gcTimeLimit);
2268 end;
2269 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2270 begin
2271 Name := 'edGoalLimit';
2272 OnlyDigits := True;
2273 Width := 4;
2274 MaxLength := 5;
2275 if gcGoalLimit > 0 then
2276 Text := IntToStr(gcGoalLimit);
2277 end;
2278 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2279 begin
2280 Name := 'edMaxLives';
2281 OnlyDigits := True;
2282 Width := 4;
2283 MaxLength := 5;
2284 if gcMaxLives > 0 then
2285 Text := IntToStr(gcMaxLives);
2286 end;
2287 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2288 begin
2289 Name := 'swPlayers';
2290 AddItem(_lc[I_MENU_COUNT_NONE]);
2291 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2292 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2293 ItemIndex := gcPlayers;
2294 end;
2295 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2296 begin
2297 Name := 'swTeamDamage';
2298 AddItem(_lc[I_MENU_YES]);
2299 AddItem(_lc[I_MENU_NO]);
2300 if gcTeamDamage then
2301 ItemIndex := 0
2302 else
2303 ItemIndex := 1;
2304 end;
2305 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2306 begin
2307 Name := 'swEnableExits';
2308 AddItem(_lc[I_MENU_YES]);
2309 AddItem(_lc[I_MENU_NO]);
2310 if gcAllowExit then
2311 ItemIndex := 0
2312 else
2313 ItemIndex := 1;
2314 end;
2315 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2316 begin
2317 Name := 'swWeaponStay';
2318 AddItem(_lc[I_MENU_YES]);
2319 AddItem(_lc[I_MENU_NO]);
2320 if gcWeaponStay then
2321 ItemIndex := 0
2322 else
2323 ItemIndex := 1;
2324 end;
2325 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2326 begin
2327 Name := 'swMonsters';
2328 AddItem(_lc[I_MENU_YES]);
2329 AddItem(_lc[I_MENU_NO]);
2330 if gcMonsters then
2331 ItemIndex := 0
2332 else
2333 ItemIndex := 1;
2334 end;
2335 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2336 begin
2337 Name := 'swBotsVS';
2338 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2339 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2340 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2341 ItemIndex := 2;
2342 if gcBotsVS = 'Players' then
2343 ItemIndex := 0;
2344 if gcBotsVS = 'Monsters' then
2345 ItemIndex := 1;
2346 end;
2347 AddSpace();
2348 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2350 ReAlign();
2351 end;
2352 Menu.DefControl := 'mCustomGameMenu';
2353 g_GUI_AddWindow(Menu);
2355 Menu := TGUIWindow.Create('CampaignMenu');
2356 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2357 begin
2358 Name := 'mCampaignMenu';
2360 AddSpace();
2361 AddSpace();
2362 AddSpace();
2363 AddSpace();
2364 AddSpace();
2365 AddSpace();
2367 with AddFileList('', 15, 4) do
2368 begin
2369 Name := 'lsWAD';
2370 OnChange := ProcSelectCampaignWAD;
2372 Sort := True;
2373 Dirs := True;
2374 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2375 SetBase(MapsDir+'megawads/');
2376 end;
2378 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2379 begin
2380 Name := 'lbWADName';
2381 FixedLength := 8;
2382 Enabled := False;
2383 end;
2384 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2385 begin
2386 Name := 'lbWADAuthor';
2387 FixedLength := 8;
2388 Enabled := False;
2389 end;
2390 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2391 with AddMemo('', 15, 3) do
2392 begin
2393 Name := 'meWADDescription';
2394 Color := MENU_ITEMSCTRL_COLOR;
2395 end;
2396 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2397 begin
2398 Name := 'swPlayers';
2399 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2400 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2401 end;
2402 AddSpace();
2403 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2405 ReAlign();
2407 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2408 begin
2409 Name := 'mpWADImage';
2410 DefaultRes := 'NOPIC';
2411 X := GetControl('lsWAD').X+4;
2412 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2413 end;
2414 end;
2415 Menu.DefControl := 'mCampaignMenu';
2416 g_GUI_AddWindow(Menu);
2418 Menu := TGUIWindow.Create('SelectMapMenu');
2419 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2420 begin
2421 Name := 'mSelectMapMenu';
2422 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2423 begin
2424 Name := 'lsMapWAD';
2425 OnChange := ProcSelectWAD;
2427 Sort := True;
2428 Dirs := True;
2429 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2430 SetBase(MapsDir);
2431 end;
2432 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2433 begin
2434 Name := 'lsMapRes';
2435 Sort := True;
2436 OnChange := ProcSelectMap;
2437 end;
2438 AddSpace();
2439 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2440 begin
2441 Name := 'lbMapName';
2442 FixedLength := 24;
2443 Enabled := False;
2444 end;
2445 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2446 begin
2447 Name := 'lbMapAuthor';
2448 FixedLength := 16;
2449 Enabled := False;
2450 end;
2451 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2452 begin
2453 Name := 'lbMapSize';
2454 FixedLength := 10;
2455 Enabled := False;
2456 end;
2457 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2458 begin
2459 Name := 'meMapDescription';
2460 end;
2462 ReAlign();
2464 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2465 begin
2466 Name := 'mpMapPreview';
2467 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2468 Y := GetControl('lsMapWAD').Y;
2469 end;
2470 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2471 begin
2472 Name := 'lbMapScale';
2473 FixedLength := 8;
2474 Enabled := False;
2475 Color := MENU_ITEMSCTRL_COLOR;
2476 X := GetControl('lsMapWAD').X +
2477 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2478 2 + MAPPREVIEW_WIDTH*4;
2479 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2480 end;
2481 end;
2482 Menu.OnClose := ProcSetMap;
2483 Menu.DefControl := 'mSelectMapMenu';
2484 g_GUI_AddWindow(Menu);
2486 Menu := TGUIWindow.Create('OptionsMenu');
2487 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2488 begin
2489 Name := 'mmOptionsMenu';
2490 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2491 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2492 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2493 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2494 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2495 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2496 AddSpace();
2497 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2498 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2499 end;
2500 Menu.OnClose := ProcApplyOptions;
2501 Menu.DefControl := 'mmOptionsMenu';
2502 g_GUI_AddWindow(Menu);
2504 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2505 gMenuSmallFont, @ProcSavedMenuKeyDown);
2506 g_GUI_AddWindow(Menu);
2508 Menu := TGUIWindow.Create('OptionsVideoMenu');
2509 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2510 begin
2511 Name := 'mOptionsVideoMenu';
2512 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2513 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2514 begin
2515 Name := 'swBPP';
2516 AddItem('16');
2517 AddItem('32');
2518 end;
2519 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2520 begin
2521 Name := 'swVSync';
2522 AddItem(_lc[I_MENU_YES]);
2523 AddItem(_lc[I_MENU_NO]);
2524 end;
2525 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2526 begin
2527 Name := 'swTextureFilter';
2528 AddItem(_lc[I_MENU_YES]);
2529 AddItem(_lc[I_MENU_NO]);
2530 end;
2531 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2532 begin
2533 Name := 'swLegacyNPOT';
2534 AddItem(_lc[I_MENU_NO]);
2535 AddItem(_lc[I_MENU_YES]);
2536 end;
2537 AddSpace();
2538 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2539 ReAlign();
2540 end;
2541 Menu.DefControl := 'mOptionsVideoMenu';
2542 g_GUI_AddWindow(Menu);
2544 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2545 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2546 begin
2547 Name := 'mOptionsVideoResMenu';
2548 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2549 begin
2550 Name := 'lbCurrentRes';
2551 FixedLength := 24;
2552 Enabled := False;
2553 end;
2554 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2555 begin
2556 Name := 'lsResolution';
2557 Sort := False;
2558 end;
2559 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2560 begin
2561 Name := 'swFullScreen';
2562 AddItem(_lc[I_MENU_YES]);
2563 AddItem(_lc[I_MENU_NO]);
2564 end;
2565 AddSpace();
2566 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2567 UpdateIndex();
2568 end;
2569 Menu.DefControl := 'mOptionsVideoResMenu';
2570 g_GUI_AddWindow(Menu);
2572 Menu := TGUIWindow.Create('OptionsSoundMenu');
2573 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2574 begin
2575 Name := 'mOptionsSoundMenu';
2576 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2577 begin
2578 Name := 'scMusicLevel';
2579 Max := 16;
2580 OnChange := ProcChangeSoundSettings;
2581 end;
2582 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2583 begin
2584 Name := 'scSoundLevel';
2585 Max := 16;
2586 OnChange := ProcChangeSoundSettings;
2587 end;
2588 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2589 begin
2590 Name := 'scMaxSimSounds';
2591 Max := 16;
2592 end;
2593 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2594 begin;
2595 Name := 'swAnnouncer';
2596 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2597 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2598 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2599 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2600 end;
2601 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2602 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2603 begin;
2604 Name := 'swSoundEffects';
2605 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2606 AddItem(_lc[I_MENU_COMPAT_DF]);
2607 end;
2608 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2609 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2610 begin;
2611 Name := 'swChatSpeech';
2612 AddItem(_lc[I_MENU_YES]);
2613 AddItem(_lc[I_MENU_NO]);
2614 end;
2615 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2616 begin
2617 Name := 'swInactiveSounds';
2618 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2619 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2620 end;
2621 ReAlign();
2622 end;
2623 Menu.DefControl := 'mOptionsSoundMenu';
2624 g_GUI_AddWindow(Menu);
2626 Menu := TGUIWindow.Create('OptionsGameMenu');
2627 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2628 begin
2629 Name := 'mOptionsGameMenu';
2630 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2631 begin
2632 Name := 'scParticlesCount';
2633 Max := 20;
2634 end;
2635 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2636 begin
2637 Name := 'swBloodCount';
2638 AddItem(_lc[I_MENU_COUNT_NONE]);
2639 AddItem(_lc[I_MENU_COUNT_SMALL]);
2640 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2641 AddItem(_lc[I_MENU_COUNT_BIG]);
2642 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2643 end;
2644 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2645 begin
2646 Name := 'scShellsMax';
2647 Max := 20;
2648 end;
2649 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2650 begin
2651 Name := 'scGibsMax';
2652 Max := 20;
2653 end;
2654 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2655 begin
2656 Name := 'scCorpsesMax';
2657 Max := 20;
2658 end;
2659 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2660 begin
2661 Name := 'swGibsCount';
2662 AddItem(_lc[I_MENU_COUNT_NONE]);
2663 AddItem(_lc[I_MENU_COUNT_SMALL]);
2664 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2665 AddItem(_lc[I_MENU_COUNT_BIG]);
2666 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2667 end;
2668 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2669 begin
2670 Name := 'swCorpseType';
2671 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2672 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2673 end;
2674 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2675 begin
2676 Name := 'swGibsType';
2677 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2678 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2679 end;
2680 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2681 begin
2682 Name := 'swBloodType';
2683 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2684 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2685 end;
2686 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2687 begin
2688 Name := 'swScreenFlash';
2689 AddItem(_lc[I_MENU_NO]);
2690 AddItem(_lc[I_MENU_COMPAT_DF]);
2691 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2692 end;
2693 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2694 begin
2695 Name := 'swBackground';
2696 AddItem(_lc[I_MENU_YES]);
2697 AddItem(_lc[I_MENU_NO]);
2698 end;
2699 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2700 begin
2701 Name := 'swMessages';
2702 AddItem(_lc[I_MENU_YES]);
2703 AddItem(_lc[I_MENU_NO]);
2704 end;
2705 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2706 begin
2707 Name := 'swRevertPlayers';
2708 AddItem(_lc[I_MENU_YES]);
2709 AddItem(_lc[I_MENU_NO]);
2710 end;
2711 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2712 begin
2713 Name := 'swChatBubble';
2714 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2715 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2716 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2717 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2718 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2719 end;
2720 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2721 begin
2722 Name := 'swPlayerIndicator';
2723 AddItem(_lc[I_MENU_YES]);
2724 AddItem(_lc[I_MENU_NO]);
2725 end;
2726 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2727 begin
2728 Name := 'scScaleFactor';
2729 Max := 10;
2730 OnChange := ProcChangeGameSettings;
2731 end;
2732 ReAlign();
2733 end;
2734 Menu.DefControl := 'mOptionsGameMenu';
2735 g_GUI_AddWindow(Menu);
2737 Menu := TGUIWindow.Create('OptionsControlsMenu');
2738 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2739 begin
2740 Name := 'mOptionsControlsMenu';
2741 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2742 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2743 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2744 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2745 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2746 AddSpace();
2747 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2748 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2749 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2750 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2751 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2752 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2753 if e_JoysticksAvailable <> 0 then
2754 begin
2755 AddSpace();
2756 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2757 end;
2758 if g_touch_enabled then
2759 begin
2760 AddSpace();
2761 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2762 end;
2763 end;
2764 Menu.DefControl := 'mOptionsControlsMenu';
2765 g_GUI_AddWindow(Menu);
2767 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2768 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2769 begin
2770 Name := 'mOptionsControlsP1Menu';
2771 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2772 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2773 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2774 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2775 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2776 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2777 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2778 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2779 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2780 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2781 end;
2782 Menu.DefControl := 'mOptionsControlsP1Menu';
2783 g_GUI_AddWindow(Menu);
2785 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2786 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2787 begin
2788 Name := 'mOptionsControlsP1MenuWeapons';
2789 for i := WP_FIRST to WP_LAST do
2790 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2791 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2792 end;
2793 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2794 g_GUI_AddWindow(Menu);
2796 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2797 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2798 begin
2799 Name := 'mOptionsControlsP2Menu';
2800 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2801 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2802 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2803 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2804 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2805 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2806 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2807 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2808 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2809 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2810 end;
2811 Menu.DefControl := 'mOptionsControlsP2Menu';
2812 g_GUI_AddWindow(Menu);
2814 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2815 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2816 begin
2817 Name := 'mOptionsControlsP2MenuWeapons';
2818 for i := WP_FIRST to WP_LAST do
2819 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2820 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2821 end;
2822 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2823 g_GUI_AddWindow(Menu);
2825 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2826 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2827 begin
2828 Name := 'mOptionsControlsJoystickMenu';
2829 for i := 0 to e_JoysticksAvailable-1 do
2830 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2831 begin
2832 Name := 'scDeadzone' + IntToStr(i);
2833 Max := 20;
2834 end;
2835 end;
2836 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2837 g_GUI_AddWindow(Menu);
2839 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2840 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2841 begin
2842 Name := 'mOptionsControlsTouchMenu';
2843 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2844 begin
2845 Name := 'swTouchAlt';
2846 AddItem(_lc[I_MENU_NO]);
2847 AddItem(_lc[I_MENU_YES]);
2848 OnChange := ProcChangeTouchSettings;
2849 end;
2850 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2851 begin
2852 Name := 'scTouchSize';
2853 Max := 20;
2854 OnChange := ProcChangeTouchSettings;
2855 end;
2856 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2857 begin
2858 Name := 'swTouchFire';
2859 AddItem(_lc[I_MENU_NO]);
2860 AddItem(_lc[I_MENU_YES]);
2861 end;
2862 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2863 begin
2864 Name := 'scTouchOffset';
2865 Max := 20;
2866 OnChange := ProcChangeTouchSettings;
2867 end;
2868 end;
2869 Menu.DefControl := 'mOptionsControlsTouchMenu';
2870 g_GUI_AddWindow(Menu);
2872 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2873 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2874 begin
2875 Name := 'mOptionsPlayersMenu';
2876 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2877 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2878 end;
2879 Menu.DefControl := 'mOptionsPlayersMenu';
2880 g_GUI_AddWindow(Menu);
2882 CreatePlayerOptionsMenu('P1');
2883 CreatePlayerOptionsMenu('P2');
2885 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2886 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2887 begin
2888 Name := 'mOptionsPlayersMIMenu';
2889 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2890 begin
2891 Name := 'lbName';
2892 FixedLength := 16;
2893 end;
2894 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2895 begin
2896 Name := 'lbAuthor';
2897 FixedLength := 16;
2898 end;
2899 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2900 begin
2901 Name := 'meComment';
2902 end;
2903 AddSpace();
2904 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2905 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2906 begin
2907 Name := 'lbWeapon';
2908 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2909 end;
2910 ReAlign();
2911 end;
2912 Menu.DefControl := 'mOptionsPlayersMIMenu';
2913 g_GUI_AddWindow(Menu);
2915 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2916 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2917 begin
2918 Name := 'mOptionsLanguageMenu';
2919 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2920 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2921 ReAlign();
2922 end;
2923 Menu.DefControl := 'mOptionsLanguageMenu';
2924 g_GUI_AddWindow(Menu);
2926 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2927 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2928 g_GUI_AddWindow(Menu);
2930 Menu := TGUIWindow.Create('AuthorsMenu');
2931 Menu.BackTexture := 'INTER';
2932 Menu.OnClose := ProcAuthorsClose;
2934 // Çàãîëîâîê:
2935 _y := 16;
2936 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2937 begin
2938 Color := _RGB(255, 0, 0);
2939 X := (gScreenWidth div 2)-(GetWidth() div 2);
2940 Y := _y;
2941 _y := _y+GetHeight();
2942 end;
2943 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2944 begin
2945 Color := _RGB(255, 0, 0);
2946 X := (gScreenWidth div 2)-(GetWidth() div 2);
2947 Y := _y;
2948 _y := _y+GetHeight()+32;
2949 end;
2950 // ×òî äåëàë: Êòî äåëàë
2951 cx := gScreenWidth div 2 - 320 + 64;
2952 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
2953 begin
2954 Color := _RGB(255, 0, 0);
2955 X := cx;
2956 Y := _y;
2957 _y := _y+22;
2958 end;
2959 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
2960 begin
2961 Color := _RGB(255, 255, 255);
2962 X := cx+32;
2963 Y := _y;
2964 _y := _y+36;
2965 end;
2966 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
2967 begin
2968 Color := _RGB(255, 0, 0);
2969 X := cx;
2970 Y := _y;
2971 _y := _y+22;
2972 end;
2973 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
2974 begin
2975 Color := _RGB(255, 255, 255);
2976 X := cx+32;
2977 Y := _y;
2978 _y := _y+22;
2979 end;
2980 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
2981 begin
2982 Color := _RGB(255, 255, 255);
2983 X := cx+32;
2984 Y := _y;
2985 _y := _y+36;
2986 end;
2987 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
2988 begin
2989 Color := _RGB(255, 0, 0);
2990 X := cx;
2991 Y := _y;
2992 _y := _y+22;
2993 end;
2994 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
2995 begin
2996 Color := _RGB(255, 255, 255);
2997 X := cx+32;
2998 Y := _y;
2999 _y := _y+36;
3000 end;
3001 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3002 begin
3003 Color := _RGB(255, 0, 0);
3004 X := cx;
3005 Y := _y;
3006 _y := _y+22;
3007 end;
3008 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3009 begin
3010 Color := _RGB(255, 255, 255);
3011 X := cx+32;
3012 Y := _y;
3013 _y := gScreenHeight - 128;
3014 end;
3015 // Çàêëþ÷åíèå:
3016 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3017 begin
3018 Color := _RGB(255, 0, 0);
3019 X := cx;
3020 Y := _y;
3021 _y := _y+16;
3022 end;
3023 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3024 begin
3025 Color := _RGB(255, 255, 255);
3026 X := cx+32;
3027 Y := _y;
3028 _y := _y+GetHeight();
3029 end;
3030 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3031 begin
3032 Color := _RGB(255, 255, 255);
3033 X := cx+32;
3034 Y := _y;
3035 _y := _y+GetHeight();
3036 end;
3037 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3038 begin
3039 Color := _RGB(255, 255, 255);
3040 X := cx+32;
3041 Y := _y;
3042 _y := gScreenHeight - 32;
3043 end;
3044 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3045 begin
3046 Color := _RGB(255, 0, 0);
3047 X := gScreenWidth div 2 - GetWidth() div 2;
3048 Y := _y;
3049 end;
3050 g_GUI_AddWindow(Menu);
3052 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3053 gMenuSmallFont, @ProcExitMenuKeyDown);
3054 g_GUI_AddWindow(Menu);
3056 Menu := TGUIWindow.Create('GameSingleMenu');
3057 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3058 begin
3059 Name := 'mmGameSingleMenu';
3060 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3061 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3062 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3063 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3064 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3065 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3066 end;
3067 Menu.DefControl := 'mmGameSingleMenu';
3068 Menu.MainWindow := True;
3069 Menu.OnClose := ProcGMClose;
3070 Menu.OnShow := ProcGMShow;
3071 g_GUI_AddWindow(Menu);
3073 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3074 gMenuSmallFont, @ProcEndMenuKeyDown);
3075 g_GUI_AddWindow(Menu);
3077 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3078 gMenuSmallFont, @ProcRestartMenuKeyDown);
3079 g_GUI_AddWindow(Menu);
3081 Menu := TGUIWindow.Create('GameCustomMenu');
3082 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3083 begin
3084 Name := 'mmGameCustomMenu';
3085 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3086 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3087 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3088 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3089 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3090 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3091 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3092 end;
3093 Menu.DefControl := 'mmGameCustomMenu';
3094 Menu.MainWindow := True;
3095 Menu.OnClose := ProcGMClose;
3096 Menu.OnShow := ProcGMShow;
3097 g_GUI_AddWindow(Menu);
3099 Menu := TGUIWindow.Create('GameServerMenu');
3100 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3101 begin
3102 Name := 'mmGameServerMenu';
3103 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3104 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3105 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3106 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3107 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3108 end;
3109 Menu.DefControl := 'mmGameServerMenu';
3110 Menu.MainWindow := True;
3111 Menu.OnClose := ProcGMClose;
3112 Menu.OnShow := ProcGMShow;
3113 g_GUI_AddWindow(Menu);
3115 Menu := TGUIWindow.Create('GameClientMenu');
3116 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3117 begin
3118 Name := 'mmGameClientMenu';
3119 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3120 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3121 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3122 end;
3123 Menu.DefControl := 'mmGameClientMenu';
3124 Menu.MainWindow := True;
3125 Menu.OnClose := ProcGMClose;
3126 Menu.OnShow := ProcGMShow;
3127 g_GUI_AddWindow(Menu);
3129 Menu := TGUIWindow.Create('ClientPasswordMenu');
3130 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3131 begin
3132 Name := 'mClientPasswordMenu';
3133 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3134 begin
3135 Name := 'edPW';
3136 Width := 12;
3137 MaxLength := 32;
3138 end;
3139 AddSpace;
3141 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3142 ReAlign();
3143 end;
3144 Menu.DefControl := 'mClientPasswordMenu';
3145 g_GUI_AddWindow(Menu);
3147 Menu := TGUIWindow.Create('GameSetGameMenu');
3148 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3149 begin
3150 Name := 'mGameSetGameMenu';
3151 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3152 begin
3153 Name := 'swTeamDamage';
3154 AddItem(_lc[I_MENU_YES]);
3155 AddItem(_lc[I_MENU_NO]);
3156 ItemIndex := 1;
3157 end;
3158 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3159 begin
3160 Name := 'edTimeLimit';
3161 OnlyDigits := True;
3162 Width := 4;
3163 MaxLength := 5;
3164 end;
3165 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3166 begin
3167 Name := 'edGoalLimit';
3168 OnlyDigits := True;
3169 Width := 4;
3170 MaxLength := 5;
3171 end;
3172 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3173 begin
3174 Name := 'edMaxLives';
3175 OnlyDigits := True;
3176 Width := 4;
3177 MaxLength := 5;
3178 end;
3179 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3180 begin
3181 Name := 'swBotsVS';
3182 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3183 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3184 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3185 ItemIndex := 2;
3186 end;
3188 ReAlign();
3189 end;
3190 Menu.DefControl := 'mGameSetGameMenu';
3191 Menu.OnClose := ProcApplyGameSet;
3192 g_GUI_AddWindow(Menu);
3194 Menu := TGUIWindow.Create('TeamMenu');
3195 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3196 begin
3197 Name := 'mmTeamMenu';
3198 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3199 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3200 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3201 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3202 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3203 end;
3204 Menu.DefControl := 'mmTeamMenu';
3205 Menu.OnShow := ProcChangePlayers;
3206 g_GUI_AddWindow(Menu);
3207 end;
3209 procedure g_Menu_Show_SaveMenu();
3210 begin
3211 if g_Game_IsTestMap then
3212 Exit;
3213 if gGameSettings.GameType = GT_SINGLE then
3214 g_GUI_ShowWindow('GameSingleMenu')
3215 else
3216 begin
3217 if g_Game_IsClient then
3218 Exit
3219 else
3220 if g_Game_IsNet then
3221 Exit
3222 else
3223 g_GUI_ShowWindow('GameCustomMenu');
3224 end;
3225 g_GUI_ShowWindow('SaveMenu');
3226 g_Sound_PlayEx('MENU_OPEN');
3227 end;
3229 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3230 begin
3231 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3232 if gGameSettings.GameType = GT_SINGLE then
3233 begin
3234 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3235 end
3236 else
3237 begin
3238 if g_Game_IsClient then exit;
3239 if g_Game_IsNet then exit;
3240 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3241 end;
3242 g_GUI_ShowWindow('LoadMenu');
3243 g_Sound_PlayEx('MENU_OPEN');
3244 end;
3246 procedure g_Menu_Show_GameSetGame();
3247 begin
3248 if gGameSettings.GameType = GT_SINGLE then
3249 g_GUI_ShowWindow('GameSingleMenu')
3250 else
3251 begin
3252 if g_Game_IsClient then
3253 Exit
3254 else
3255 if g_Game_IsNet then
3256 g_GUI_ShowWindow('GameServerMenu')
3257 else
3258 g_GUI_ShowWindow('GameCustomMenu');
3259 end;
3260 ReadGameSettings();
3261 g_GUI_ShowWindow('GameSetGameMenu');
3262 g_Sound_PlayEx('MENU_OPEN');
3263 end;
3265 procedure g_Menu_Show_OptionsVideo();
3266 begin
3267 if gGameSettings.GameType = GT_SINGLE then
3268 g_GUI_ShowWindow('GameSingleMenu')
3269 else
3270 begin
3271 if g_Game_IsClient then
3272 g_GUI_ShowWindow('GameClientMenu')
3273 else
3274 if g_Game_IsNet then
3275 g_GUI_ShowWindow('GameServerMenu')
3276 else
3277 g_GUI_ShowWindow('GameCustomMenu');
3278 end;
3279 ReadOptions();
3280 g_GUI_ShowWindow('OptionsMenu');
3281 g_GUI_ShowWindow('OptionsVideoMenu');
3282 g_Sound_PlayEx('MENU_OPEN');
3283 end;
3285 procedure g_Menu_Show_OptionsSound();
3286 begin
3287 if gGameSettings.GameType = GT_SINGLE then
3288 g_GUI_ShowWindow('GameSingleMenu')
3289 else
3290 begin
3291 if g_Game_IsClient then
3292 g_GUI_ShowWindow('GameClientMenu')
3293 else
3294 if g_Game_IsNet then
3295 g_GUI_ShowWindow('GameServerMenu')
3296 else
3297 g_GUI_ShowWindow('GameCustomMenu');
3298 end;
3299 ReadOptions();
3300 g_GUI_ShowWindow('OptionsMenu');
3301 g_GUI_ShowWindow('OptionsSoundMenu');
3302 g_Sound_PlayEx('MENU_OPEN');
3303 end;
3305 procedure g_Menu_Show_EndGameMenu();
3306 begin
3307 g_GUI_ShowWindow('EndGameMenu');
3308 g_Sound_PlayEx('MENU_OPEN');
3309 end;
3311 procedure g_Menu_Show_QuitGameMenu();
3312 begin
3313 g_GUI_ShowWindow('ExitMenu');
3314 g_Sound_PlayEx('MENU_OPEN');
3315 end;
3317 procedure g_Menu_Init();
3318 begin
3319 MenuLoadData();
3320 g_GUI_Init();
3321 CreateAllMenus();
3322 end;
3324 procedure g_Menu_Free();
3325 begin
3326 g_GUI_Destroy();
3328 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3330 MenuFreeData();
3331 end;
3333 procedure g_Menu_Reset();
3334 var
3335 ex: Boolean;
3336 begin
3337 g_GUI_SaveMenuPos();
3338 ex := g_GUI_Destroy();
3340 if ex then
3341 begin
3342 e_WriteLog('Recreating menu...', TMsgType.Notify);
3344 CreateAllMenus();
3346 if gDebugMode then
3347 g_Game_SetDebugMode();
3349 g_GUI_LoadMenuPos();
3350 end;
3351 end;
3353 end.