DEADSOFTWARE

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