DEADSOFTWARE

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