DEADSOFTWARE

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