DEADSOFTWARE

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