DEADSOFTWARE

game: disable gibs for server
[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, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_menu;
18 interface
20 procedure g_Menu_Init();
21 procedure g_Menu_Free();
22 procedure g_Menu_Reset();
23 procedure g_Menu_AskLanguage();
25 procedure g_Menu_Show_SaveMenu();
26 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
27 procedure g_Menu_Show_GameSetGame();
28 procedure g_Menu_Show_OptionsVideo();
29 procedure g_Menu_Show_OptionsSound();
30 procedure g_Menu_Show_EndGameMenu();
31 procedure g_Menu_Show_QuitGameMenu();
33 var
34 PromptIP: string;
35 PromptPort: Word;
36 TempScale: Integer = -1;
37 TempResScale: Integer = -1;
39 implementation
41 uses
42 {$IFDEF ENABLE_GFX}
43 g_gfx,
44 {$ENDIF}
45 {$IFDEF ENABLE_GIBS}
46 g_gibs,
47 {$ENDIF}
48 g_gui, r_textures, r_graphics, g_game, g_map,
49 g_base, g_basic, g_console, g_sound, g_player, g_options, g_weapons,
50 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
51 MAPDEF, Math, g_saveload,
52 g_language, e_res,
53 g_net, g_netmsg, g_netmaster, g_items, e_input,
54 utils, wadreader, g_system, r_render, r_game;
57 type TYNCallback = procedure (yes:Boolean);
59 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
60 begin
61 if win.UserData = nil then exit;
62 case Key of
63 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
64 IK_N: TYNCallback(win.UserData)(false);
65 end;
66 end;
68 procedure YesButtonCB (ctl: TGUITextButton);
69 begin
70 if ctl.UserData = nil then exit;
71 TYNCallback(ctl.UserData)(true);
72 end;
74 procedure NoButtonCB (ctl: TGUITextButton);
75 begin
76 if ctl.UserData = nil then exit;
77 TYNCallback(ctl.UserData)(false);
78 end;
80 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
81 var
82 menu: TGUIMenu;
83 begin
84 //if length(Text) = 0 then exit;
85 Result := TGUIWindow.Create(WinName);
86 with Result do
87 begin
88 //OnKeyDownEx := @YNKeyDownProc;
89 //UserData := @ActionProc;
90 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
91 with menu do
92 begin
93 Name := '__temp_yes_no_menu:'+WinName;
94 YesNo := true;
95 AddText(Text, MaxLen);
96 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
97 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
98 end;
99 DefControl := '__temp_yes_no_menu:'+WinName;
100 SetActive(nil);
101 end;
102 end;
105 procedure ProcChangeColor(Sender: TGUIControl); forward;
106 procedure ProcSelectModel(Sender: TGUIControl); forward;
108 procedure ProcApplyOptions();
109 var
110 menu: TGUIMenu;
111 i: Integer;
112 begin
113 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
115 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
116 gBPP := 16
117 else
118 gBPP := 32;
120 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
122 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
123 glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
124 gLerpActors := TGUISwitch(menu.GetControl('swInterp')).ItemIndex = 0;
126 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
128 g_Sound_SetupAllVolumes(
129 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
130 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
131 );
133 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
134 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
135 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
136 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
137 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
139 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
141 {$IFDEF ENABLE_GFX}
142 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
143 {$ENDIF}
144 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
145 {$IFDEF ENABLE_GIBS}
146 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
147 {$ENDIF}
148 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
150 {$IFDEF ENABLE_GIBS}
151 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
152 0: gGibsCount := 0;
153 1: gGibsCount := 8;
154 2: gGibsCount := 16;
155 3: gGibsCount := 32;
156 else gGibsCount := 48;
157 end;
158 {$ENDIF}
160 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
161 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
162 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
163 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
164 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
165 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
166 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
167 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
168 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
169 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex;
170 gPlayerIndicatorStyle := TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')).ItemIndex;
171 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
172 begin
173 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
174 g_dbg_scale := TempScale + 1;
175 end;
177 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
179 with menu do
180 begin
181 g_Console_BindKey(g_Console_FindBind(1, 'screenshot'), '');
182 g_Console_BindKey(g_Console_FindBind(1, '+p1_scores', '-p1_scores'), '');
183 g_Console_BindKey(g_Console_FindBind(1, 'togglechat'), '');
184 g_Console_BindKey(g_Console_FindBind(1, 'toggleteamchat'), '');
185 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key, 'screenshot');
186 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key, '+p1_scores', '-p1_scores');
187 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key, 'togglechat');
188 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key, 'toggleteamchat');
189 end;
191 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
192 with menu do
193 begin
194 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveright', '-p1_moveright'), '');
195 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft'), '');
196 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookup', '-p1_lookup'), '');
197 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown'), '');
198 g_Console_BindKey(g_Console_FindBind(1, '+p1_attack', '-p1_attack'), '');
199 g_Console_BindKey(g_Console_FindBind(1, '+p1_jump', '-p1_jump'), '');
200 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext'), '');
201 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev'), '');
202 g_Console_BindKey(g_Console_FindBind(1, '+p1_activate', '-p1_activate'), '');
203 g_Console_BindKey(g_Console_FindBind(1, '+p1_strafe', '-p1_strafe'), '');
204 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p1_moveright', '-p1_moveright');
205 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p1_moveleft', '-p1_moveleft');
206 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p1_lookup', '-p1_lookup');
207 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p1_lookdown', '-p1_lookdown');
208 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p1_attack', '-p1_attack');
209 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p1_jump', '-p1_jump');
210 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p1_weapnext', '-p1_weapnext');
211 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p1_weapprev', '-p1_weapprev');
212 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p1_activate', '-p1_activate');
213 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p1_strafe', '-p1_strafe');
214 // second set
215 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveright', '-p1_moveright'), '');
216 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft'), '');
217 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookup', '-p1_lookup'), '');
218 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown'), '');
219 g_Console_BindKey(g_Console_FindBind(2, '+p1_attack', '-p1_attack'), '');
220 g_Console_BindKey(g_Console_FindBind(2, '+p1_jump', '-p1_jump'), '');
221 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext'), '');
222 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev'), '');
223 g_Console_BindKey(g_Console_FindBind(2, '+p1_activate', '-p1_activate'), '');
224 g_Console_BindKey(g_Console_FindBind(2, '+p1_strafe', '-p1_strafe'), '');
225 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p1_moveright', '-p1_moveright');
226 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p1_moveleft', '-p1_moveleft');
227 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p1_lookup', '-p1_lookup');
228 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p1_lookdown', '-p1_lookdown');
229 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p1_attack', '-p1_attack');
230 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p1_jump', '-p1_jump');
231 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p1_weapnext', '-p1_weapnext');
232 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p1_weapprev', '-p1_weapprev');
233 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p1_activate', '-p1_activate');
234 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p1_strafe', '-p1_strafe');
235 end;
237 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
238 with menu do
239 begin
240 for i := WP_FIRST to WP_LAST do
241 begin
242 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1)), '');
243 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p1_weapon ' + IntToStr(i + 1));
244 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1)), '');
245 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p1_weapon ' + IntToStr(i + 1));
246 end;
247 end;
249 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
250 with menu do
251 begin
252 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveright', '-p2_moveright'), '');
253 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft'), '');
254 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookup', '-p2_lookup'), '');
255 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown'), '');
256 g_Console_BindKey(g_Console_FindBind(1, '+p2_attack', '-p2_attack'), '');
257 g_Console_BindKey(g_Console_FindBind(1, '+p2_jump', '-p2_jump'), '');
258 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext'), '');
259 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev'), '');
260 g_Console_BindKey(g_Console_FindBind(1, '+p2_activate', '-p2_activate'), '');
261 g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe', '-p2_strafe'), '');
262 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright', '-p2_moveright');
263 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft', '-p2_moveleft');
264 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup', '-p2_lookup');
265 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown', '-p2_lookdown');
266 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack', '-p2_attack');
267 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump', '-p2_jump');
268 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p2_weapnext', '-p2_weapnext');
269 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p2_weapprev', '-p2_weapprev');
270 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate', '-p2_activate');
271 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe', '-p2_strafe');
272 // second set
273 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright', '-p2_moveright'), '');
274 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft'), '');
275 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookup', '-p2_lookup'), '');
276 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown'), '');
277 g_Console_BindKey(g_Console_FindBind(2, '+p2_attack', '-p2_attack'), '');
278 g_Console_BindKey(g_Console_FindBind(2, '+p2_jump', '-p2_jump'), '');
279 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext'), '');
280 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev'), '');
281 g_Console_BindKey(g_Console_FindBind(2, '+p2_activate', '-p2_activate'), '');
282 g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe', '-p2_strafe'), '');
283 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright', '-p2_moveright');
284 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft', '-p2_moveleft');
285 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup', '-p2_lookup');
286 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown', '-p2_lookdown');
287 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack', '-p2_attack');
288 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump', '-p2_jump');
289 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p2_weapnext', '-p2_weapnext');
290 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p2_weapprev', '-p2_weapprev');
291 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate', '-p2_activate');
292 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe', '-p2_strafe');
293 end;
295 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
296 with menu do
297 begin
298 for i := WP_FIRST to WP_LAST do
299 begin
300 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1)), '');
301 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p2_weapon ' + IntToStr(i + 1));
302 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1)), '');
303 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p2_weapon ' + IntToStr(i + 1));
304 end;
305 end;
307 if e_HasJoysticks then
308 begin
309 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
310 with menu do
311 begin
312 for i := 0 to e_MaxJoys - 1 do
313 if e_JoystickAvailable[i] then
314 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20)
315 end
316 end;
318 if g_touch_enabled then
319 begin
320 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
321 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
322 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
323 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
324 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
325 end;
327 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
329 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
330 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
331 TEAM_RED, TEAM_BLUE);
333 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
334 begin
335 gPlayer1Settings.Model := Model.GetName();
336 gPlayer1Settings.Color := Model.Color;
337 end;
339 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
341 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
342 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
343 TEAM_RED, TEAM_BLUE);
344 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
345 begin
346 gPlayer2Settings.Model := Model.GetName();
347 gPlayer2Settings.Color := Model.Color;
348 end;
350 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
351 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
353 if g_Game_IsServer then
354 begin
355 if gPlayer1 <> nil then
356 begin
357 gPlayer1.SetModel(gPlayer1Settings.Model);
358 gPlayer1.Name := gPlayer1Settings.Name;
359 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
360 gPlayer1.SetColor(gPlayer1Settings.Color)
361 else
362 if gPlayer1.Team <> gPlayer1Settings.Team then
363 gPlayer1.SwitchTeam;
365 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
366 end;
368 if gPlayer2 <> nil then
369 begin
370 gPlayer2.SetModel(gPlayer2Settings.Model);
371 gPlayer2.Name := gPlayer2Settings.Name;
372 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
373 gPlayer2.SetColor(gPlayer2Settings.Color)
374 else
375 if gPlayer2.Team <> gPlayer2Settings.Team then
376 gPlayer2.SwitchTeam;
377 end;
378 end;
380 if g_Game_IsClient then MC_SEND_PlayerSettings;
382 g_Console_WriteGameConfig;
383 end;
385 procedure ReadOptions();
386 var
387 menu: TGUIMenu;
388 i: Integer;
389 begin
390 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
392 with TGUISwitch(menu.GetControl('swBPP')) do
393 if gBPP = 16 then
394 ItemIndex := 0
395 else
396 ItemIndex := 1;
398 with TGUISwitch(menu.GetControl('swTextureFilter')) do
399 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
401 with TGUISwitch(menu.GetControl('swVSync')) do
402 if gVSync then ItemIndex := 0 else ItemIndex := 1;
404 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
405 if not glNPOTOverride then ItemIndex := 0 else ItemIndex := 1;
407 with TGUISwitch(menu.GetControl('swInterp')) do
408 if gLerpActors then ItemIndex := 0 else ItemIndex := 1;
410 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
412 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
413 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
414 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
416 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
417 if gMuteWhenInactive then
418 ItemIndex := 1
419 else
420 ItemIndex := 0;
422 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
424 with TGUISwitch(menu.GetControl('swSoundEffects')) do
425 if gSoundEffectsDF then
426 ItemIndex := 1
427 else
428 ItemIndex := 0;
430 with TGUISwitch(menu.GetControl('swChatSpeech')) do
431 if gUseChatSounds then
432 ItemIndex := 0
433 else
434 ItemIndex := 1;
436 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
437 with menu do
438 begin
439 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p1_moveright', '-p1_moveright');
440 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft');
441 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p1_lookup', '-p1_lookup');
442 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown');
443 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack', '-p1_attack');
444 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump', '-p1_jump');
445 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext');
446 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev');
447 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate', '-p1_activate');
448 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe', '-p1_strafe');
449 // second set
450 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright', '-p1_moveright');
451 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft');
452 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p1_lookup', '-p1_lookup');
453 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown');
454 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack', '-p1_attack');
455 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump', '-p1_jump');
456 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext');
457 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev');
458 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate', '-p1_activate');
459 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe', '-p1_strafe');
460 end;
462 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
463 with menu do
464 begin
465 for i := WP_FIRST to WP_LAST do
466 begin
467 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1));
468 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1));
469 end;
470 end;
472 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
473 with menu do
474 begin
475 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright', '-p2_moveright');
476 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft');
477 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup', '-p2_lookup');
478 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown');
479 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack', '-p2_attack');
480 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump', '-p2_jump');
481 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext');
482 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev');
483 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate', '-p2_activate');
484 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe', '-p2_strafe');
485 // second set
486 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright', '-p2_moveright');
487 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft');
488 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup', '-p2_lookup');
489 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown');
490 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack', '-p2_attack');
491 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump', '-p2_jump');
492 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext');
493 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev');
494 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate', '-p2_activate');
495 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe', '-p2_strafe');
496 end;
498 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
499 with menu do
500 begin
501 for i := WP_FIRST to WP_LAST do
502 begin
503 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
504 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
505 end;
506 end;
508 if e_HasJoysticks then
509 begin
510 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
511 with menu do
512 begin
513 for i := 0 to e_MaxJoys - 1 do
514 if e_JoystickAvailable[i] then
515 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20)
516 end
517 end;
519 if g_touch_enabled then
520 begin
521 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
522 with TGUISwitch(menu.GetControl('swTouchAlt')) do
523 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
524 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
525 with TGUISwitch(menu.GetControl('swTouchFire')) do
526 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
527 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
528 end;
530 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
531 with menu do
532 begin
533 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
534 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+p1_scores', '-p1_scores');
535 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
536 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
537 end;
539 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
541 {$IFDEF ENABLE_GFX}
542 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
543 {$ENDIF}
544 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
545 {$IFDEF ENABLE_GIBS}
546 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
547 {$ENDIF}
548 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
549 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
551 with TGUISwitch(menu.GetControl('swScreenFlash')) do
552 ItemIndex := gFlash;
554 with TGUISwitch(menu.GetControl('swBloodType')) do
555 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
557 with TGUISwitch(menu.GetControl('swCorpseType')) do
558 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
560 with TGUISwitch(menu.GetControl('swGibsType')) do
561 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
563 {$IFDEF ENABLE_GIBS}
564 with TGUISwitch(menu.GetControl('swGibsCount')) do
565 begin
566 case gGibsCount of
567 0: ItemIndex := 0;
568 8: ItemIndex := 1;
569 16: ItemIndex := 2;
570 32: ItemIndex := 3;
571 else ItemIndex := 4;
572 end;
573 end;
574 {$ENDIF}
576 with TGUISwitch(menu.GetControl('swBackGround')) do
577 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
579 with TGUISwitch(menu.GetControl('swMessages')) do
580 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
582 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
583 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
585 with TGUISwitch(menu.GetControl('swChatBubble')) do
586 ItemIndex := gChatBubble;
588 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
589 ItemIndex := gPlayerIndicator;
591 with TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')) do
592 ItemIndex := gPlayerIndicatorStyle;
594 TempScale := Round(g_dbg_scale - 1);
595 TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
597 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
599 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
600 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
602 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
603 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
605 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
606 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
607 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
609 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
611 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
612 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
614 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
615 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
617 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
618 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
619 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
621 ProcSelectModel(nil);
622 end;
624 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
625 begin
626 // don't turn off monsters in DM
628 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
629 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
630 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
631 else
632 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
635 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
636 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
637 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
638 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
640 end;
642 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
643 begin
644 // don't turn off monsters in DM
646 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
647 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
648 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
649 else
650 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
653 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
654 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
655 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
656 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
658 end;
660 function LatchGameOptions(const MenuName: string): Byte;
661 var
662 Map: string;
663 begin
664 Result := GM_NONE;
666 with TGUIMenu(g_ActiveWindow.GetControl(MenuName)) do
667 begin
668 Map := TGUILabel(GetControl('lbMap')).Text;
669 if Map = '' then
670 Exit;
671 if not isWadPath(Map) then
672 Exit;
674 Result := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
675 gsGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
676 gsTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
677 gsGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
678 gsMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
679 gsItemRespawnTime := StrToIntDef(TGUIEdit(GetControl('edItemRespawnTime')).Text, 0);
680 gsPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
681 gsMap := Map;
683 gsGameFlags := 0;
684 if TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0 then
685 gsGameFlags := gsGameFlags or GAME_OPTION_TEAMDAMAGE;
686 if TGUISwitch(GetControl('swDeathmatchKeys')).ItemIndex = 0 then
687 gsGameFlags := gsGameFlags or GAME_OPTION_DMKEYS;
688 if TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0 then
689 gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWEXIT;
690 if TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0 then
691 gsGameFlags := gsGameFlags or GAME_OPTION_WEAPONSTAY;
692 if TGUISwitch(GetControl('swMonsters')).ItemIndex = 0 then
693 gsGameFlags := gsGameFlags or GAME_OPTION_MONSTERS;
695 case TGUISwitch(GetControl('swTeamHit')).ItemIndex of
696 1: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE;
697 2: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITPROJECTILE;
698 0: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
699 end;
701 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
702 1: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSMONSTER;
703 2: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
704 else gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER;
705 end;
707 // TODO: get this crap out of here
708 gGameSettings.ItemRespawnTime := gsItemRespawnTime;
709 gGameSettings.WarmupTime := gsWarmupTime;
710 gGameSettings.SpawnInvul := gsSpawnInvul;
711 end;
712 end;
714 procedure ProcStartCustomGame();
715 var
716 GameMode: Byte;
717 begin
718 GameMode := LatchGameOptions('mCustomGameMenu');
719 if GameMode = GM_NONE then Exit;
721 g_Console_WriteGameConfig;
722 g_Game_StartCustom(gsMap, GameMode, gsTimeLimit, gsGoalLimit,
723 gsMaxLives, gsGameFlags, gsPlayers);
724 end;
727 procedure ProcStartNetGame();
728 var
729 GameMode: Byte;
730 begin
731 GameMode := LatchGameOptions('mNetServerMenu');
732 if GameMode = GM_NONE then Exit;
734 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
735 begin
736 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
737 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
738 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
739 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
740 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
741 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
742 end;
744 g_Console_WriteGameConfig;
745 g_Game_StartServer(gsMap, GameMode, gsTimeLimit, gsGoalLimit, gsMaxLives,
746 gsGameFlags, gsPlayers, 0, NetPort);
747 end;
749 procedure ProcConnectNetGame();
750 var
751 PW: String;
752 begin
753 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
754 begin
755 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
756 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
757 PW := TGUIEdit(GetControl('edPW')).Text;
758 end;
760 g_Console_WriteGameConfig;
761 g_Game_StartClient(NetClientIP, NetClientPort, PW);
762 end;
764 procedure ProcEnterPassword();
765 var
766 PW: string;
767 begin
768 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
769 begin
770 NetClientIP := PromptIP;
771 NetClientPort := PromptPort;
772 PW := TGUIEdit(GetControl('edPW')).Text;
773 end;
775 g_Console_WriteGameConfig;
776 g_Game_StartClient(NetClientIP, NetClientPort, PW);
777 end;
779 procedure ProcServerlist();
780 begin
781 if not NetInitDone then
782 begin
783 if (not g_Net_Init()) then
784 begin
785 g_Console_Add('NET: ERROR: Failed to init ENet!');
786 Exit;
787 end
788 else
789 NetInitDone := True;
790 end;
792 g_Net_Slist_Set(NetMasterList);
794 gState := STATE_SLIST;
795 g_ActiveWindow := nil;
797 slWaitStr := _lc[I_NET_SLIST_WAIT];
799 r_Render_Draw;
800 sys_Repaint;
802 slReturnPressed := True;
803 if g_Net_Slist_Fetch(slCurrent) then
804 begin
805 if slCurrent = nil then
806 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
807 end
808 else
809 slWaitStr := _lc[I_NET_SLIST_ERROR];
810 g_Serverlist_GenerateTable(slCurrent, slTable);
811 end;
813 procedure ProcStartCampaign();
814 var
815 WAD: String;
816 TwoPlayers: Boolean;
817 n: Byte;
818 begin
819 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
820 begin
821 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
822 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
823 end;
824 WAD := e_FindWadRel(MegawadDirs, WAD);
826 if TwoPlayers then
827 n := 2
828 else
829 n := 1;
830 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
831 end;
833 procedure ProcSelectMap(Sender: TGUIControl);
834 var
835 win: TGUIWindow;
836 a: TMapInfo;
837 wad, map, res: String;
838 begin
839 win := g_GUI_GetWindow('SelectMapMenu');
840 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
841 begin
842 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
843 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
845 if (wad = '') or (map = '') then
846 begin // Ýòî íå êàðòà
847 TGUILabel(GetControl('lbMapName')).Text := '';
848 TGUILabel(GetControl('lbMapAuthor')).Text := '';
849 TGUILabel(GetControl('lbMapSize')).Text := '';
850 TGUIMemo(GetControl('meMapDescription')).SetText('');
851 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
852 TGUILabel(win.GetControl('lbMapScale')).Text := '';
853 end
854 else // Ýòî êàðòà
855 begin
856 res := wad+':\'+map;
858 a := g_Map_GetMapInfo(res);
860 TGUILabel(GetControl('lbMapName')).Text := a.Name;
861 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
862 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
863 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
864 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
865 TGUILabel(win.GetControl('lbMapScale')).Text :=
866 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
867 end;
868 end;
869 end;
871 procedure ProcSelectWAD(Sender: TGUIControl);
872 var
873 wad: String;
874 list: SSArray;
875 begin
876 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
877 begin
878 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
880 with TGUIListBox(GetControl('lsMapRes')) do
881 begin
882 Clear();
884 if wad <> '' then
885 begin
886 list := g_Map_GetMapsList(wad);
888 if list <> nil then
889 begin
890 Items := list;
891 ItemIndex := 0;
892 end
893 end;
894 end;
895 end;
897 ProcSelectMap(nil);
898 end;
900 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
901 var
902 win: TGUIWindow;
903 a: TMegaWADInfo;
904 wad, fn: String;
905 begin
906 win := g_GUI_GetWindow('CampaignMenu');
907 with TGUIMenu(win.GetControl('mCampaignMenu')) do
908 begin
909 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
911 if wad = '' then
912 begin
913 TGUILabel(GetControl('lbWADName')).Text := '';
914 TGUILabel(GetControl('lbWADAuthor')).Text := '';
915 TGUIMemo(GetControl('meWADDescription')).SetText('');
916 end;
918 a := g_Game_GetMegaWADInfo(wad);
920 TGUILabel(GetControl('lbWADName')).Text := a.Name;
921 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
922 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
924 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
926 if a.pic <> '' then
927 begin
928 fn := g_ExtractWadName(a.pic);
929 if fn = '' then
930 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
931 else
932 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
933 end;
934 end;
935 end;
937 procedure ProcChangeColor(Sender: TGUIControl);
938 var
939 window: TGUIWindow;
940 begin
941 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
942 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
943 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
944 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
945 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
946 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
948 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
949 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
950 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
951 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
952 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
953 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
954 end;
956 procedure ProcSelectModel(Sender: TGUIControl);
957 var
958 a: string;
959 window: TGUIWindow;
960 begin
961 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
962 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
963 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
965 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
966 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
967 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
969 ProcChangeColor(nil);
970 end;
972 procedure MenuLoadData();
973 begin
974 e_WriteLog('Loading menu data...', TMsgType.Notify);
976 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD+':TEXTURES\MAINLOGO');
977 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
978 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
979 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
980 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
981 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
982 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
983 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
984 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
985 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
986 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
987 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
988 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
989 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
990 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
991 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
992 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
993 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
994 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
995 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
996 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
997 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
998 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
999 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1000 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1002 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1003 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1004 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1005 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1006 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1007 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1008 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1009 end;
1011 procedure MenuFreeData();
1012 begin
1013 e_CharFont_Remove(gMenuFont);
1014 e_CharFont_Remove(gMenuSmallFont);
1016 g_Texture_Delete('MAINMENU_LOGO');
1017 g_Texture_Delete('MAINMENU_MARKER1');
1018 g_Texture_Delete('MAINMENU_MARKER2');
1019 g_Texture_Delete('SCROLL_LEFT');
1020 g_Texture_Delete('SCROLL_RIGHT');
1021 g_Texture_Delete('SCROLL_MIDDLE');
1022 g_Texture_Delete('SCROLL_MARKER');
1023 g_Texture_Delete('EDIT_LEFT');
1024 g_Texture_Delete('EDIT_RIGHT');
1025 g_Texture_Delete('EDIT_MIDDLE');
1026 g_Texture_Delete('BOX1');
1027 g_Texture_Delete('BOX2');
1028 g_Texture_Delete('BOX3');
1029 g_Texture_Delete('BOX4');
1030 g_Texture_Delete('BOX5');
1031 g_Texture_Delete('BOX6');
1032 g_Texture_Delete('BOX7');
1033 g_Texture_Delete('BOX8');
1034 g_Texture_Delete('BOX9');
1035 g_Texture_Delete('BSCROLL_UP_A');
1036 g_Texture_Delete('BSCROLL_UP_U');
1037 g_Texture_Delete('BSCROLL_DOWN_A');
1038 g_Texture_Delete('BSCROLL_DOWN_U');
1039 g_Texture_Delete('BSCROLL_MIDDLE');
1040 g_Texture_Delete('NOPIC');
1042 g_Sound_Delete('MENU_SELECT');
1043 g_Sound_Delete('MENU_OPEN');
1044 g_Sound_Delete('MENU_CLOSE');
1045 g_Sound_Delete('MENU_CHANGE');
1046 g_Sound_Delete('SCROLL_ADD');
1047 g_Sound_Delete('SCROLL_SUB');
1048 g_Sound_Delete('SOUND_PLAYER_FALL');
1049 end;
1051 procedure ProcAuthorsMenu();
1052 begin
1053 gMusic.SetByName('MUSIC_INTERMUS');
1054 gMusic.Play();
1055 end;
1057 procedure ProcExitMenuKeyDown (yes: Boolean);
1058 var
1059 s: ShortString;
1060 snd: TPlayableSound;
1061 res: Boolean;
1062 begin
1063 if yes then
1064 begin
1065 g_Game_StopAllSounds(True);
1066 case (Random(18)) of
1067 0: s := 'SOUND_MONSTER_PAIN';
1068 1: s := 'SOUND_MONSTER_DIE_3';
1069 2: s := 'SOUND_MONSTER_SLOP';
1070 3: s := 'SOUND_MONSTER_DEMON_DIE';
1071 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1072 5: s := 'SOUND_MONSTER_MAN_DIE';
1073 6: s := 'SOUND_MONSTER_BSP_DIE';
1074 7: s := 'SOUND_MONSTER_VILE_DIE';
1075 8: s := 'SOUND_MONSTER_SKEL_DIE';
1076 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1077 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1078 11: s := 'SOUND_MONSTER_BARON_DIE';
1079 12: s := 'SOUND_MONSTER_CACO_DIE';
1080 13: s := 'SOUND_MONSTER_CYBER_DIE';
1081 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1082 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1083 else s := 'SOUND_PLAYER_FALL';
1084 end;
1085 snd := TPlayableSound.Create();
1086 res := snd.SetByName(s);
1087 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1088 if res then
1089 begin
1090 snd.Play(True);
1091 while snd.IsPlaying() do begin end;
1092 end;
1093 g_Game_Quit();
1094 exit;
1095 end;
1096 g_GUI_HideWindow();
1097 end;
1099 procedure ProcLoadMenu();
1100 var
1101 a: Integer;
1102 valid: Boolean;
1103 begin
1104 for a := 1 to 8 do
1105 begin
1106 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1107 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1108 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1109 end;
1110 end;
1112 procedure ProcSaveMenu();
1113 var
1114 a: Integer;
1115 valid: Boolean;
1116 name: AnsiString;
1117 begin
1118 for a := 1 to 8 do
1119 begin
1120 name := g_GetSaveName(a, valid);
1121 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1122 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1123 end;
1124 end;
1126 procedure ProcSaveGame(Sender: TGUIControl);
1127 var
1128 a: Integer;
1129 begin
1130 if g_Game_IsNet then Exit;
1131 if g_Game_IsTestMap then Exit;
1132 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1133 g_Game_PauseAllSounds(True);
1134 g_SaveGame(a, TGUIEdit(Sender).Text);
1136 g_ActiveWindow := nil;
1137 g_Game_Pause(False);
1138 end;
1140 procedure ProcLoadGame(Sender: TGUIControl);
1141 var
1142 a: Integer;
1143 begin
1144 if g_Game_IsNet then Exit;
1145 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1146 if g_LoadGame(a) then
1147 begin
1148 g_Game_PauseAllSounds(False)
1149 end
1150 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1151 begin
1152 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1153 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1154 //g_ActiveWindow := nil;
1155 end;
1156 end;
1158 procedure ProcSinglePlayer (n: Integer);
1159 var wad, map: AnsiString;
1160 begin
1161 assert(n >= 1);
1162 wad := g_ExtractWadName(gDefaultMegawadStart);
1163 map := g_ExtractFilePathName(gDefaultMegawadStart);
1164 if e_FindResource(AllMapDirs, wad) then
1165 begin
1166 wad := ExpandFileName(wad);
1167 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1168 end
1169 end;
1171 procedure ProcSingle1Player;
1172 begin
1173 ProcSinglePlayer(1)
1174 end;
1176 procedure ProcSingle2Players;
1177 begin
1178 ProcSinglePlayer(2)
1179 end;
1181 procedure ProcSelectMapMenu();
1182 var
1183 menu: TGUIMenu;
1184 wad_lb: TGUIFileListBox;
1185 map_lb: TGUIListBox;
1186 map: String;
1187 begin
1188 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1189 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1190 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1192 if wad_lb.SelectedItem() <> '' then
1193 map := map_lb.SelectedItem()
1194 else
1195 map := '';
1197 wad_lb.UpdateFileList();
1198 map_lb.Clear();
1200 if wad_lb.SelectedItem() <> '' then
1201 begin
1202 ProcSelectWAD(nil);
1203 map_lb.SelectItem(map);
1205 if map_lb.SelectedItem() <> '' then
1206 ProcSelectMap(nil);
1207 end;
1209 g_GUI_ShowWindow('SelectMapMenu');
1210 end;
1212 procedure ProcSelectCampaignMenu();
1213 var
1214 menu: TGUIMenu;
1215 wad_lb: TGUIFileListBox;
1216 begin
1217 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1218 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1220 wad_lb.UpdateFileList();
1222 if wad_lb.SelectedItem() <> '' then
1223 ProcSelectCampaignWAD(nil);
1224 end;
1226 procedure ProcSetMap();
1227 var
1228 wad, map, res: String;
1229 begin
1230 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1231 begin
1232 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1233 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1234 end;
1236 if (wad = '') or (map = '') then
1237 Exit;
1239 wad := e_FindWadRel(MapDirs, WAD);
1241 res := wad+':\'+map;
1243 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1244 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1245 end;
1247 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1248 var
1249 menu: TGUIMenu;
1250 begin
1251 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1253 g_Sound_SetupAllVolumes(
1254 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1255 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1256 );
1257 end;
1259 procedure ProcChangeGameSettings(Sender: TGUIControl);
1260 var
1261 menu: TGUIMenu;
1262 begin
1263 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1264 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1265 begin
1266 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1267 g_dbg_scale := TempScale + 1;
1268 end;
1269 end;
1271 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1272 var
1273 menu: TGUIMenu;
1274 begin
1275 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1276 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1277 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1278 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1279 end;
1281 procedure ProcOptionsPlayersMIMenu();
1282 var
1283 s, a: string;
1284 i: Integer;
1285 begin
1286 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1288 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1290 if a = '' then Exit;
1292 i := g_PlayerModel_GetIndex(a);
1293 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1294 begin
1295 TGUILabel(GetControl('lbName')).Text := PlayerModelsArray[i].Name;
1296 TGUILabel(GetControl('lbAuthor')).Text := PlayerModelsArray[i].Author;
1297 TGUIMemo(GetControl('meComment')).SetText(PlayerModelsArray[i].Description);
1299 if PlayerModelsArray[i].HaveWeapon then
1300 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1301 else
1302 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1303 end;
1305 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1306 end;
1308 procedure ProcOptionsPlayersAnim();
1309 var
1310 s: String;
1311 begin
1312 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1313 s := 'P1'
1314 else
1315 s := 'P2';
1317 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1318 begin
1319 NextAnim();
1320 Model.AnimState.Loop := True;
1321 end;
1322 end;
1324 procedure ProcOptionsPlayersWeap();
1325 var
1326 s: String;
1327 begin
1328 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1329 s := 'P1'
1330 else
1331 s := 'P2';
1333 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1334 NextWeapon();
1335 end;
1337 procedure ProcOptionsPlayersRot();
1338 var
1339 s: string;
1340 begin
1341 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1342 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1343 begin
1344 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1345 end;
1346 end;
1348 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1349 begin
1350 if yes then
1351 begin
1352 g_Options_SetDefault();
1353 ReadOptions();
1354 end;
1355 g_GUI_HideWindow();
1356 end;
1358 procedure ProcSavedMenuKeyDown (yes: Boolean);
1359 begin
1360 if yes then ReadOptions();
1361 g_GUI_HideWindow();
1362 end;
1364 procedure ProcAuthorsClose();
1365 begin
1366 gMusic.SetByName('MUSIC_MENU');
1367 gMusic.Play();
1368 gState := STATE_MENU;
1369 end;
1371 procedure ProcGMClose();
1372 begin
1373 g_Game_InGameMenu(False);
1374 end;
1376 procedure ProcGMShow();
1377 var
1378 Enabled: Boolean;
1379 begin
1380 Enabled := True;
1381 if (gGameSettings.GameType = GT_SINGLE) and
1382 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1383 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1384 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1385 if not gGameOn then
1386 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1387 if g_Game_IsTestMap then
1388 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1389 TGUIMainMenu(g_ActiveWindow.GetControl(
1390 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1391 end;
1393 procedure ProcChangePlayers();
1394 var
1395 TeamGame, Spectator, AddTwo: Boolean;
1396 P1Team{, P2Team}: Byte;
1397 bP2: TGUITextButton;
1398 begin
1399 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1400 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1401 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1402 P1Team := TEAM_NONE;
1403 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1404 // TODO
1405 //P2Team := TEAM_NONE;
1406 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1408 TGUIMainMenu(g_ActiveWindow.GetControl(
1409 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1410 TGUIMainMenu(g_ActiveWindow.GetControl(
1411 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1412 TGUIMainMenu(g_ActiveWindow.GetControl(
1413 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1415 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1416 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1417 bP2.Enabled := AddTwo and not Spectator;
1418 if bP2.Enabled then
1419 bP2.Color := MAINMENU_ITEMS_COLOR
1420 else
1421 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1422 if gPlayer2 = nil then
1423 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1424 else
1425 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1427 TGUIMainMenu(g_ActiveWindow.GetControl(
1428 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1429 end;
1431 procedure ProcJoinRed();
1432 begin
1433 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1434 Exit;
1435 if g_Game_IsServer then
1436 begin
1437 if gPlayer1 = nil then
1438 g_Game_AddPlayer(TEAM_RED)
1439 else
1440 begin
1441 if gPlayer1.Team <> TEAM_RED then
1442 begin
1443 gPlayer1.SwitchTeam;
1444 gPlayer1Settings.Team := gPlayer1.Team;
1445 end;
1447 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1448 end;
1449 end
1450 else
1451 begin
1452 gPlayer1Settings.Team := TEAM_RED;
1453 MC_SEND_PlayerSettings;
1454 if gPlayer1 = nil then
1455 g_Game_AddPlayer(TEAM_RED);
1456 end;
1457 g_ActiveWindow := nil;
1458 g_Game_Pause(False);
1459 end;
1461 procedure ProcJoinBlue();
1462 begin
1463 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1464 Exit;
1465 if g_Game_IsServer then
1466 begin
1467 if gPlayer1 = nil then
1468 g_Game_AddPlayer(TEAM_BLUE)
1469 else
1470 begin
1471 if gPlayer1.Team <> TEAM_BLUE then
1472 begin
1473 gPlayer1.SwitchTeam;
1474 gPlayer1Settings.Team := gPlayer1.Team;
1475 end;
1477 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1478 end;
1479 end
1480 else
1481 begin
1482 gPlayer1Settings.Team := TEAM_BLUE;
1483 MC_SEND_PlayerSettings;
1484 if gPlayer1 = nil then
1485 g_Game_AddPlayer(TEAM_BLUE);
1486 end;
1487 g_ActiveWindow := nil;
1488 g_Game_Pause(False);
1489 end;
1491 procedure ProcJoinGame();
1492 begin
1493 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1494 Exit;
1495 if gPlayer1 = nil then
1496 g_Game_AddPlayer();
1497 g_ActiveWindow := nil;
1498 g_Game_Pause(False);
1499 end;
1501 procedure ProcSwitchP2();
1502 begin
1503 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1504 Exit;
1505 if gPlayer1 = nil then
1506 Exit;
1507 if gPlayer2 = nil then
1508 g_Game_AddPlayer()
1509 else
1510 g_Game_RemovePlayer();
1511 g_ActiveWindow := nil;
1512 g_Game_Pause(False);
1513 end;
1515 procedure ProcSpectate();
1516 begin
1517 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1518 Exit;
1519 g_Game_Spectate();
1520 g_ActiveWindow := nil;
1521 g_Game_Pause(False);
1522 end;
1524 procedure ProcRestartMenuKeyDown (yes: Boolean);
1525 begin
1526 if yes then g_Game_Restart() else g_GUI_HideWindow;
1527 end;
1529 procedure ProcEndMenuKeyDown (yes: Boolean);
1530 begin
1531 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1532 end;
1534 procedure ProcSetRussianLanguage;
1535 begin
1536 if gLanguage <> LANGUAGE_RUSSIAN then
1537 begin
1538 gLanguage := LANGUAGE_RUSSIAN;
1539 gLanguageChange := True;
1540 gAskLanguage := False;
1541 ProcApplyOptions();
1542 end;
1543 end;
1545 procedure ProcSetEnglishLanguage;
1546 begin
1547 if gLanguage <> LANGUAGE_ENGLISH then
1548 begin
1549 gLanguage := LANGUAGE_ENGLISH;
1550 gLanguageChange := True;
1551 gAskLanguage := False;
1552 ProcApplyOptions();
1553 end;
1554 end;
1556 procedure ReadGameSettings();
1557 var
1558 menu: TGUIMenu;
1559 begin
1560 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1562 with gGameSettings do
1563 begin
1564 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1565 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1566 ItemIndex := 0
1567 else
1568 ItemIndex := 1;
1569 with TGUISwitch(menu.GetControl('swTeamHit')) do
1570 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1571 ItemIndex := 0
1572 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1573 ItemIndex := 1
1574 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1575 ItemIndex := 2
1576 else
1577 ItemIndex := 3;
1578 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1579 if LongBool(Options and GAME_OPTION_DMKEYS) then
1580 ItemIndex := 0
1581 else
1582 ItemIndex := 1;
1584 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1585 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1586 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1588 with TGUISwitch(menu.GetControl('swBotsVS')) do
1589 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1590 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1591 ItemIndex := 2
1592 else
1593 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1594 ItemIndex := 1
1595 else
1596 ItemIndex := 0;
1598 if GameType in [GT_CUSTOM, GT_SERVER] then
1599 begin
1600 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1601 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1602 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1603 begin
1604 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1605 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1606 end
1607 else
1608 begin
1609 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1610 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1611 end;
1612 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1613 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1614 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1615 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1616 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1617 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1618 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1619 end
1620 else
1621 begin
1622 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1623 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1624 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1625 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1626 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1627 begin
1628 Enabled := False;
1629 Text := '';
1630 end;
1631 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1632 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1633 begin
1634 Enabled := False;
1635 Text := '';
1636 end;
1637 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1638 with TGUIEdit(menu.GetControl('edMaxLives')) do
1639 begin
1640 Enabled := False;
1641 Text := '';
1642 end;
1643 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1644 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1645 end;
1646 end;
1647 end;
1649 procedure ProcApplyGameSet();
1650 var
1651 menu: TGUIMenu;
1652 a, b, n: Integer;
1653 stat: TPlayerStatArray;
1654 begin
1655 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1657 if not g_Game_IsServer then Exit;
1659 with gGameSettings do
1660 begin
1661 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1662 begin
1663 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1664 Options := Options or GAME_OPTION_TEAMDAMAGE
1665 else
1666 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1667 end;
1669 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1670 begin
1671 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1672 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1673 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1674 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1675 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1676 end;
1677 end;
1679 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1680 begin
1681 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1682 Options := Options or GAME_OPTION_DMKEYS
1683 else
1684 Options := Options and (not GAME_OPTION_DMKEYS);
1685 end;
1687 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1688 begin
1689 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1691 if n = 0 then
1692 TimeLimit := 0
1693 else
1694 begin
1695 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1697 TimeLimit := Max(n, b);
1698 end;
1699 end;
1701 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1702 begin
1703 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1705 if n = 0 then
1706 GoalLimit := 0
1707 else
1708 begin
1709 b := 0;
1710 if GameMode = GM_DM then
1711 begin // DM
1712 stat := g_Player_GetStats();
1713 if stat <> nil then
1714 for a := 0 to High(stat) do
1715 if stat[a].Frags > b then
1716 b := stat[a].Frags;
1717 end
1718 else // CTF
1719 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1721 GoalLimit := Max(n, b);
1722 end;
1723 end;
1725 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1726 begin
1727 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1728 if n < 0 then n := 0;
1729 if n > 255 then n := 255;
1730 if n = 0 then
1731 MaxLives := 0
1732 else
1733 begin
1734 b := 0;
1735 stat := g_Player_GetStats();
1736 if stat <> nil then
1737 for a := 0 to High(stat) do
1738 if stat[a].Lives > b then
1739 b := stat[a].Lives;
1741 MaxLives := Max(n, b);
1742 end;
1743 end;
1745 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1746 begin
1747 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1748 1:
1749 begin
1750 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1751 Options := Options or GAME_OPTION_BOTVSMONSTER;
1752 end;
1753 2:
1754 begin
1755 Options := Options or GAME_OPTION_BOTVSPLAYER;
1756 Options := Options or GAME_OPTION_BOTVSMONSTER;
1757 end;
1758 else
1759 begin
1760 Options := Options or GAME_OPTION_BOTVSPLAYER;
1761 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1762 end;
1763 end;
1764 end;
1766 // don't forget to latch this shit
1767 gsGameFlags := Options;
1768 gsMaxLives := MaxLives;
1769 gsGoalLimit := GoalLimit;
1770 gsTimeLimit := TimeLimit;
1771 end;
1773 if g_Game_IsNet then MH_SEND_GameSettings;
1774 end;
1776 procedure ProcVideoOptionsRes();
1777 var
1778 menu: TGUIMenu;
1779 list: SSArray;
1780 begin
1781 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1783 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1784 IntToStr(gWinSizeX) +
1785 ' x ' + IntToStr(gWinSizeY) +
1786 ', ' + IntToStr(gBPP) + ' bpp';
1788 with TGUIListBox(menu.GetControl('lsResolution')) do
1789 begin
1790 list := sys_GetDisplayModes(gBPP);
1791 if list <> nil then
1792 begin
1793 Items := list;
1794 ItemIndex := Length(list)
1795 end
1796 else
1797 begin
1798 Clear
1799 end
1800 end;
1802 with TGUISwitch(menu.GetControl('swFullScreen')) do
1803 if gFullscreen then
1804 ItemIndex := 0
1805 else
1806 ItemIndex := 1;
1808 TempResScale := Round(r_pixel_scale - 1);
1809 with TGUISwitch(menu.GetControl('swResFactor')) do
1810 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1811 end;
1813 procedure ProcApplyVideoOptions();
1814 var
1815 menu: TGUIMenu;
1816 Fullscreen: Boolean;
1817 SWidth, SHeight: Integer;
1818 ScaleChanged: Boolean;
1819 str: String;
1820 begin
1821 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1823 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1824 if str <> '' then
1825 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1826 else
1827 begin
1828 SWidth := gWinSizeX;
1829 SHeight := gWinSizeY;
1830 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1831 end;
1833 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1835 ScaleChanged := False;
1836 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1837 begin
1838 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1839 r_pixel_scale := TempResScale + 1;
1840 ScaleChanged := True;
1841 end;
1843 if (SWidth <> gWinSizeX) or
1844 (SHeight <> gWinSizeY) or
1845 (Fullscreen <> gFullscreen) or
1846 ScaleChanged then
1847 begin
1848 gResolutionChange := True;
1849 gRC_Width := SWidth;
1850 gRC_Height := SHeight;
1851 gRC_FullScreen := Fullscreen;
1852 gRC_Maximized := gWinMaximized;
1853 end;
1855 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1856 ProcApplyOptions();
1857 end;
1859 procedure ProcSetFirstRussianLanguage;
1860 begin
1861 gLanguage := LANGUAGE_RUSSIAN;
1862 gLanguageChange := True;
1863 gAskLanguage := False;
1864 end;
1866 procedure ProcSetFirstEnglishLanguage;
1867 begin
1868 gLanguage := LANGUAGE_ENGLISH;
1869 gLanguageChange := True;
1870 gAskLanguage := False;
1871 end;
1873 procedure ProcRecallAddress();
1874 begin
1875 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1876 begin
1877 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1878 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1879 end;
1880 end;
1882 procedure CreateFirstLanguageMenu();
1883 var
1884 Menu: TGUIWindow;
1885 begin
1886 Menu := TGUIWindow.Create('FirstLanguageMenu');
1888 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1889 begin
1890 Name := 'mmFirstLanguageMenu';
1891 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1892 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1893 end;
1895 Menu.DefControl := 'mmFirstLanguageMenu';
1896 Menu.MainWindow := True;
1897 g_GUI_AddWindow(Menu);
1898 end;
1900 procedure g_Menu_AskLanguage();
1901 begin
1902 CreateFirstLanguageMenu();
1903 g_GUI_ShowWindow('FirstLanguageMenu');
1904 end;
1906 procedure CreatePlayerOptionsMenu(s: String);
1907 var
1908 Menu: TGUIWindow;
1909 a: String;
1910 begin
1911 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1912 if s = 'P1' then
1913 a := _lc[I_MENU_PLAYER_1]
1914 else
1915 a := _lc[I_MENU_PLAYER_2];
1916 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1917 begin
1918 Name := 'mOptionsPlayers'+s+'Menu';
1919 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1920 begin
1921 Name := 'ed'+s+'Name';
1922 MaxLength := 12;
1923 Width := 12;
1924 end;
1925 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1926 begin
1927 Name := 'sw'+s+'Team';
1928 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1929 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1930 end ;
1931 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1932 begin
1933 Name := 'ls'+s+'Model';
1934 Sort := True;
1935 Items := g_PlayerModel_GetNames();
1936 OnChange := ProcSelectModel;
1937 end;
1938 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1939 begin
1940 Name := 'sc'+s+'Red';
1941 Max := 16;
1942 OnChange := ProcChangeColor;
1943 end;
1944 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1945 begin
1946 Name := 'sc'+s+'Green';
1947 Max := 16;
1948 OnChange := ProcChangeColor;
1949 end;
1950 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1951 begin
1952 Name := 'sc'+s+'Blue';
1953 Max := 16;
1954 OnChange := ProcChangeColor;
1955 end;
1956 AddSpace();
1957 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1958 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1959 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1960 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1962 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1963 begin
1964 Name := 'mv'+s+'Model';
1965 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1966 Y := GetControl('ls'+s+'Model').Y;
1967 end;
1968 end;
1969 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1970 g_GUI_AddWindow(Menu);
1971 end;
1973 procedure CreateAllMenus();
1974 var
1975 Menu: TGUIWindow;
1976 //SR: TSearchRec;
1977 a, cx, _y, i: Integer;
1978 //list: SSArray;
1979 begin
1980 Menu := TGUIWindow.Create('MainMenu');
1981 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
1982 begin
1983 Name := 'mmMainMenu';
1984 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1985 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1986 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1987 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1988 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1989 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1990 end;
1991 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1992 begin
1993 Color := _RGB(255, 255, 255);
1994 X := gScreenWidth-GetWidth-8;
1995 Y := gScreenHeight-GetHeight-8;
1996 end;
1997 Menu.DefControl := 'mmMainMenu';
1998 Menu.MainWindow := True;
1999 g_GUI_AddWindow(Menu);
2001 Menu := TGUIWindow.Create('NewGameMenu');
2002 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2003 begin
2004 Name := 'mmNewGameMenu';
2005 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2006 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2007 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2008 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2009 end;
2010 Menu.DefControl := 'mmNewGameMenu';
2011 g_GUI_AddWindow(Menu);
2013 Menu := TGUIWindow.Create('NetGameMenu');
2014 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2015 begin
2016 Name := 'mmNetGameMenu';
2017 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2018 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2019 end;
2020 Menu.DefControl := 'mmNetGameMenu';
2021 g_GUI_AddWindow(Menu);
2023 Menu := TGUIWindow.Create('NetServerMenu');
2024 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2025 begin
2026 Name := 'mNetServerMenu';
2027 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2028 begin
2029 Name := 'edSrvName';
2030 OnlyDigits := False;
2031 Width := 16;
2032 MaxLength := 64;
2033 Text := NetServerName;
2034 end;
2035 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2036 begin
2037 Name := 'edSrvPassword';
2038 OnlyDigits := False;
2039 Width := 16;
2040 MaxLength := 24;
2041 Text := NetPassword;
2042 end;
2043 with AddEdit(_lc[I_NET_PORT]) do
2044 begin
2045 Name := 'edPort';
2046 OnlyDigits := True;
2047 Width := 4;
2048 MaxLength := 5;
2049 Text := IntToStr(NetPort);
2050 end;
2051 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2052 begin
2053 Name := 'edMaxPlayers';
2054 OnlyDigits := True;
2055 Width := 4;
2056 MaxLength := 2;
2057 Text := IntToStr(NetMaxClients);
2058 end;
2059 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2060 begin
2061 Name := 'swUseMaster';
2062 AddItem(_lc[I_MENU_YES]);
2063 AddItem(_lc[I_MENU_NO]);
2064 if NetUseMaster then
2065 ItemIndex := 0
2066 else
2067 ItemIndex := 1;
2068 end;
2069 AddSpace();
2070 with AddLabel(_lc[I_MENU_MAP]) do
2071 begin
2072 Name := 'lbMap';
2073 FixedLength := 16;
2074 Text := gsMap;
2075 OnClick := @ProcSelectMapMenu;
2076 end;
2077 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2078 begin
2079 Name := 'swGameMode';
2080 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2081 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2082 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2083 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2084 case g_Game_TextToMode(gsGameMode) of
2085 GM_NONE,
2086 GM_DM: ItemIndex := 0;
2087 GM_TDM: ItemIndex := 1;
2088 GM_CTF: ItemIndex := 2;
2089 GM_SINGLE,
2090 GM_COOP: ItemIndex := 3;
2091 end;
2092 OnChange := ProcSwitchMonstersCustom;
2093 end;
2094 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2095 begin
2096 Name := 'edTimeLimit';
2097 OnlyDigits := True;
2098 Width := 4;
2099 MaxLength := 5;
2100 if gsTimeLimit > 0 then
2101 Text := IntToStr(gsTimeLimit);
2102 end;
2103 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2104 begin
2105 Name := 'edGoalLimit';
2106 OnlyDigits := True;
2107 Width := 4;
2108 MaxLength := 5;
2109 if gsGoalLimit > 0 then
2110 Text := IntToStr(gsGoalLimit);
2111 end;
2112 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2113 begin
2114 Name := 'edMaxLives';
2115 OnlyDigits := True;
2116 Width := 4;
2117 MaxLength := 5;
2118 if gsMaxLives > 0 then
2119 Text := IntToStr(gsMaxLives);
2120 end;
2121 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2122 begin
2123 Name := 'edItemRespawnTime';
2124 OnlyDigits := True;
2125 Width := 4;
2126 MaxLength := 5;
2127 if gsItemRespawnTime > 0 then
2128 Text := IntToStr(gsItemRespawnTime);
2129 end;
2130 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2131 begin
2132 Name := 'swPlayers';
2133 AddItem(_lc[I_MENU_COUNT_NONE]);
2134 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2135 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2136 ItemIndex := gsPlayers;
2137 end;
2138 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2139 begin
2140 Name := 'swTeamDamage';
2141 AddItem(_lc[I_MENU_YES]);
2142 AddItem(_lc[I_MENU_NO]);
2143 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2144 ItemIndex := 0
2145 else
2146 ItemIndex := 1;
2147 end;
2148 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2149 begin
2150 Name := 'swTeamHit';
2151 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2152 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2153 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2154 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2155 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2156 ItemIndex := 0
2157 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2158 ItemIndex := 1
2159 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2160 ItemIndex := 2
2161 else
2162 ItemIndex := 3;
2163 end;
2164 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2165 begin
2166 Name := 'swDeathmatchKeys';
2167 AddItem(_lc[I_MENU_YES]);
2168 AddItem(_lc[I_MENU_NO]);
2169 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2170 ItemIndex := 0
2171 else
2172 ItemIndex := 1;
2173 end;
2174 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2175 begin
2176 Name := 'swEnableExits';
2177 AddItem(_lc[I_MENU_YES]);
2178 AddItem(_lc[I_MENU_NO]);
2179 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2180 ItemIndex := 0
2181 else
2182 ItemIndex := 1;
2183 end;
2184 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2185 begin
2186 Name := 'swWeaponStay';
2187 AddItem(_lc[I_MENU_YES]);
2188 AddItem(_lc[I_MENU_NO]);
2189 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2190 ItemIndex := 0
2191 else
2192 ItemIndex := 1;
2193 end;
2194 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2195 begin
2196 Name := 'swMonsters';
2197 AddItem(_lc[I_MENU_YES]);
2198 AddItem(_lc[I_MENU_NO]);
2199 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2200 ItemIndex := 0
2201 else
2202 ItemIndex := 1;
2203 end;
2204 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2205 begin
2206 Name := 'swBotsVS';
2207 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2208 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2209 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2210 ItemIndex := 2;
2211 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2212 ItemIndex := 0;
2213 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2214 ItemIndex := 1;
2215 end;
2216 AddSpace();
2217 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2219 ReAlign();
2220 end;
2221 Menu.DefControl := 'mNetServerMenu';
2222 g_GUI_AddWindow(Menu);
2224 Menu := TGUIWindow.Create('NetClientMenu');
2225 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2226 begin
2227 Name := 'mNetClientMenu';
2229 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2230 AddSpace();
2232 with AddEdit(_lc[I_NET_ADDRESS]) do
2233 begin
2234 Name := 'edIP';
2235 OnlyDigits :=False;
2236 Width := 12;
2237 MaxLength := 64;
2238 Text := 'localhost';
2239 end;
2240 with AddEdit(_lc[I_NET_PORT]) do
2241 begin
2242 Name := 'edPort';
2243 OnlyDigits := True;
2244 Width := 4;
2245 MaxLength := 5;
2246 Text := '25666';
2247 end;
2248 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2249 begin
2250 Name := 'edPW';
2251 OnlyDigits := False;
2252 Width := 12;
2253 MaxLength := 32;
2254 Text := '';
2255 end;
2257 AddSpace();
2258 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2260 ReAlign();
2261 end;
2262 Menu.DefControl := 'mNetClientMenu';
2263 g_GUI_AddWindow(Menu);
2265 Menu := TGUIWindow.Create('LoadMenu');
2266 Menu.OnShow := ProcLoadMenu;
2267 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2268 begin
2269 Name := 'mmLoadMenu';
2271 for a := 1 to 8 do
2272 with AddEdit('') do
2273 begin
2274 Name := 'edSlot'+IntToStr(a);
2275 Width := 16;
2276 MaxLength := 16;
2277 OnEnter := ProcLoadGame;
2278 end;
2279 end;
2280 Menu.DefControl := 'mmLoadMenu';
2281 g_GUI_AddWindow(Menu);
2283 Menu := TGUIWindow.Create('SaveMenu');
2284 Menu.OnShow := ProcSaveMenu;
2285 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2286 begin
2287 Name := 'mmSaveMenu';
2289 for a := 1 to 8 do
2290 with AddEdit('') do
2291 begin
2292 Name := 'edSlot'+IntToStr(a);
2293 Width := 16;
2294 MaxLength := 16;
2295 OnChange := ProcSaveGame;
2296 end;
2297 end;
2298 Menu.DefControl := 'mmSaveMenu';
2299 g_GUI_AddWindow(Menu);
2301 Menu := TGUIWindow.Create('CustomGameMenu');
2302 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2303 begin
2304 Name := 'mCustomGameMenu';
2305 with AddLabel(_lc[I_MENU_MAP]) do
2306 begin
2307 Name := 'lbMap';
2308 FixedLength := 16;
2309 Text := gsMap;
2310 OnClick := @ProcSelectMapMenu;
2311 end;
2312 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2313 begin
2314 Name := 'swGameMode';
2315 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2316 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2317 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2318 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2319 case g_Game_TextToMode(gsGameMode) of
2320 GM_NONE,
2321 GM_DM: ItemIndex := 0;
2322 GM_TDM: ItemIndex := 1;
2323 GM_CTF: ItemIndex := 2;
2324 GM_SINGLE,
2325 GM_COOP: ItemIndex := 3;
2326 end;
2327 OnChange := ProcSwitchMonstersCustom;
2328 end;
2329 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2330 begin
2331 Name := 'edTimeLimit';
2332 OnlyDigits := True;
2333 Width := 4;
2334 MaxLength := 5;
2335 if gsTimeLimit > 0 then
2336 Text := IntToStr(gsTimeLimit);
2337 end;
2338 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2339 begin
2340 Name := 'edGoalLimit';
2341 OnlyDigits := True;
2342 Width := 4;
2343 MaxLength := 5;
2344 if gsGoalLimit > 0 then
2345 Text := IntToStr(gsGoalLimit);
2346 end;
2347 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2348 begin
2349 Name := 'edMaxLives';
2350 OnlyDigits := True;
2351 Width := 4;
2352 MaxLength := 5;
2353 if gsMaxLives > 0 then
2354 Text := IntToStr(gsMaxLives);
2355 end;
2356 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2357 begin
2358 Name := 'edItemRespawnTime';
2359 OnlyDigits := True;
2360 Width := 4;
2361 MaxLength := 5;
2362 if gsItemRespawnTime > 0 then
2363 Text := IntToStr(gsItemRespawnTime);
2364 end;
2365 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2366 begin
2367 Name := 'swPlayers';
2368 AddItem(_lc[I_MENU_COUNT_NONE]);
2369 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2370 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2371 ItemIndex := gsPlayers;
2372 end;
2373 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2374 begin
2375 Name := 'swTeamDamage';
2376 AddItem(_lc[I_MENU_YES]);
2377 AddItem(_lc[I_MENU_NO]);
2378 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2379 ItemIndex := 0
2380 else
2381 ItemIndex := 1;
2382 end;
2383 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2384 begin
2385 Name := 'swTeamHit';
2386 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2387 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2388 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2389 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2390 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2391 ItemIndex := 0
2392 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2393 ItemIndex := 1
2394 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2395 ItemIndex := 2
2396 else
2397 ItemIndex := 3;
2398 end;
2399 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2400 begin
2401 Name := 'swDeathmatchKeys';
2402 AddItem(_lc[I_MENU_YES]);
2403 AddItem(_lc[I_MENU_NO]);
2404 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2405 ItemIndex := 0
2406 else
2407 ItemIndex := 1;
2408 end;
2409 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2410 begin
2411 Name := 'swEnableExits';
2412 AddItem(_lc[I_MENU_YES]);
2413 AddItem(_lc[I_MENU_NO]);
2414 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2415 ItemIndex := 0
2416 else
2417 ItemIndex := 1;
2418 end;
2419 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2420 begin
2421 Name := 'swWeaponStay';
2422 AddItem(_lc[I_MENU_YES]);
2423 AddItem(_lc[I_MENU_NO]);
2424 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2425 ItemIndex := 0
2426 else
2427 ItemIndex := 1;
2428 end;
2429 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2430 begin
2431 Name := 'swMonsters';
2432 AddItem(_lc[I_MENU_YES]);
2433 AddItem(_lc[I_MENU_NO]);
2434 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2435 ItemIndex := 0
2436 else
2437 ItemIndex := 1;
2438 end;
2439 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2440 begin
2441 Name := 'swBotsVS';
2442 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2443 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2444 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2445 ItemIndex := 2;
2446 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2447 ItemIndex := 0;
2448 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2449 ItemIndex := 1;
2450 end;
2451 AddSpace();
2452 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2454 ReAlign();
2455 end;
2456 Menu.DefControl := 'mCustomGameMenu';
2457 g_GUI_AddWindow(Menu);
2459 Menu := TGUIWindow.Create('CampaignMenu');
2460 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2461 begin
2462 Name := 'mCampaignMenu';
2464 AddSpace();
2465 AddSpace();
2466 AddSpace();
2467 AddSpace();
2468 AddSpace();
2469 AddSpace();
2471 with AddFileList('', 15, 4) do
2472 begin
2473 Name := 'lsWAD';
2474 OnChange := ProcSelectCampaignWAD;
2476 Sort := True;
2477 Dirs := True;
2478 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2479 SetBase(MegawadDirs);
2480 end;
2482 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2483 begin
2484 Name := 'lbWADName';
2485 FixedLength := 8;
2486 Enabled := False;
2487 end;
2488 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2489 begin
2490 Name := 'lbWADAuthor';
2491 FixedLength := 8;
2492 Enabled := False;
2493 end;
2494 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2495 with AddMemo('', 15, 3) do
2496 begin
2497 Name := 'meWADDescription';
2498 Color := MENU_ITEMSCTRL_COLOR;
2499 end;
2500 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2501 begin
2502 Name := 'swPlayers';
2503 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2504 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2505 end;
2506 AddSpace();
2507 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2509 ReAlign();
2511 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2512 begin
2513 Name := 'mpWADImage';
2514 DefaultRes := 'NOPIC';
2515 X := GetControl('lsWAD').X+4;
2516 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2517 end;
2518 end;
2519 Menu.DefControl := 'mCampaignMenu';
2520 g_GUI_AddWindow(Menu);
2522 Menu := TGUIWindow.Create('SelectMapMenu');
2523 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2524 begin
2525 Name := 'mSelectMapMenu';
2526 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2527 begin
2528 Name := 'lsMapWAD';
2529 OnChange := ProcSelectWAD;
2531 Sort := True;
2532 Dirs := True;
2533 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2534 SetBase(MapDirs);
2535 end;
2536 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2537 begin
2538 Name := 'lsMapRes';
2539 Sort := True;
2540 OnChange := ProcSelectMap;
2541 end;
2542 AddSpace();
2543 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2544 begin
2545 Name := 'lbMapName';
2546 FixedLength := 24;
2547 Enabled := False;
2548 end;
2549 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2550 begin
2551 Name := 'lbMapAuthor';
2552 FixedLength := 16;
2553 Enabled := False;
2554 end;
2555 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2556 begin
2557 Name := 'lbMapSize';
2558 FixedLength := 10;
2559 Enabled := False;
2560 end;
2561 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2562 begin
2563 Name := 'meMapDescription';
2564 end;
2566 ReAlign();
2568 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2569 begin
2570 Name := 'mpMapPreview';
2571 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2572 Y := GetControl('lsMapWAD').Y;
2573 end;
2574 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2575 begin
2576 Name := 'lbMapScale';
2577 FixedLength := 8;
2578 Enabled := False;
2579 Color := MENU_ITEMSCTRL_COLOR;
2580 X := GetControl('lsMapWAD').X +
2581 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2582 2 + MAPPREVIEW_WIDTH*4;
2583 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2584 end;
2585 end;
2586 Menu.OnClose := ProcSetMap;
2587 Menu.DefControl := 'mSelectMapMenu';
2588 g_GUI_AddWindow(Menu);
2590 Menu := TGUIWindow.Create('OptionsMenu');
2591 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2592 begin
2593 Name := 'mmOptionsMenu';
2594 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2595 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2596 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2597 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2598 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2599 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2600 AddSpace();
2601 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2602 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2603 end;
2604 Menu.OnClose := ProcApplyOptions;
2605 Menu.DefControl := 'mmOptionsMenu';
2606 g_GUI_AddWindow(Menu);
2608 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2609 gMenuSmallFont, @ProcSavedMenuKeyDown);
2610 g_GUI_AddWindow(Menu);
2612 Menu := TGUIWindow.Create('OptionsVideoMenu');
2613 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2614 begin
2615 Name := 'mOptionsVideoMenu';
2616 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2617 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2618 begin
2619 Name := 'swBPP';
2620 AddItem('16');
2621 AddItem('32');
2622 end;
2623 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2624 begin
2625 Name := 'swVSync';
2626 AddItem(_lc[I_MENU_YES]);
2627 AddItem(_lc[I_MENU_NO]);
2628 end;
2629 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2630 begin
2631 Name := 'swTextureFilter';
2632 AddItem(_lc[I_MENU_YES]);
2633 AddItem(_lc[I_MENU_NO]);
2634 end;
2635 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2636 begin
2637 Name := 'swInterp';
2638 AddItem(_lc[I_MENU_YES]);
2639 AddItem(_lc[I_MENU_NO]);
2640 end;
2641 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2642 begin
2643 Name := 'swLegacyNPOT';
2644 AddItem(_lc[I_MENU_NO]);
2645 AddItem(_lc[I_MENU_YES]);
2646 end;
2647 AddSpace();
2648 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2649 ReAlign();
2650 end;
2651 Menu.DefControl := 'mOptionsVideoMenu';
2652 g_GUI_AddWindow(Menu);
2654 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2655 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2656 begin
2657 Name := 'mOptionsVideoResMenu';
2658 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2659 begin
2660 Name := 'lbCurrentRes';
2661 FixedLength := 24;
2662 Enabled := False;
2663 end;
2664 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2665 begin
2666 Name := 'lsResolution';
2667 Sort := False;
2668 end;
2669 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2670 begin
2671 Name := 'swFullScreen';
2672 AddItem(_lc[I_MENU_YES]);
2673 AddItem(_lc[I_MENU_NO]);
2674 end;
2675 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2676 begin
2677 Name := 'swResFactor';
2678 AddItem('1x');
2679 for i := 2 to gRC_Width div 640 do
2680 AddItem(IntToStr(i) + 'x');
2681 end;
2682 AddSpace();
2683 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2684 UpdateIndex();
2685 end;
2686 Menu.DefControl := 'mOptionsVideoResMenu';
2687 g_GUI_AddWindow(Menu);
2689 Menu := TGUIWindow.Create('OptionsSoundMenu');
2690 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2691 begin
2692 Name := 'mOptionsSoundMenu';
2693 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2694 begin
2695 Name := 'scMusicLevel';
2696 Max := 16;
2697 OnChange := ProcChangeSoundSettings;
2698 end;
2699 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2700 begin
2701 Name := 'scSoundLevel';
2702 Max := 16;
2703 OnChange := ProcChangeSoundSettings;
2704 end;
2705 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2706 begin
2707 Name := 'scMaxSimSounds';
2708 Max := 16;
2709 end;
2710 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2711 begin;
2712 Name := 'swAnnouncer';
2713 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2714 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2715 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2716 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2717 end;
2718 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2719 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2720 begin;
2721 Name := 'swSoundEffects';
2722 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2723 AddItem(_lc[I_MENU_COMPAT_DF]);
2724 end;
2725 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2726 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2727 begin;
2728 Name := 'swChatSpeech';
2729 AddItem(_lc[I_MENU_YES]);
2730 AddItem(_lc[I_MENU_NO]);
2731 end;
2732 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2733 begin
2734 Name := 'swInactiveSounds';
2735 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2736 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2737 end;
2738 ReAlign();
2739 end;
2740 Menu.DefControl := 'mOptionsSoundMenu';
2741 g_GUI_AddWindow(Menu);
2743 Menu := TGUIWindow.Create('OptionsGameMenu');
2744 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2745 begin
2746 Name := 'mOptionsGameMenu';
2747 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2748 begin
2749 Name := 'scParticlesCount';
2750 Max := 20;
2751 end;
2752 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2753 begin
2754 Name := 'swBloodCount';
2755 AddItem(_lc[I_MENU_COUNT_NONE]);
2756 AddItem(_lc[I_MENU_COUNT_SMALL]);
2757 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2758 AddItem(_lc[I_MENU_COUNT_BIG]);
2759 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2760 end;
2761 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2762 begin
2763 Name := 'scShellsMax';
2764 Max := 20;
2765 end;
2766 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2767 begin
2768 Name := 'scGibsMax';
2769 Max := 20;
2770 end;
2771 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2772 begin
2773 Name := 'scCorpsesMax';
2774 Max := 20;
2775 end;
2776 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2777 begin
2778 Name := 'swGibsCount';
2779 AddItem(_lc[I_MENU_COUNT_NONE]);
2780 AddItem(_lc[I_MENU_COUNT_SMALL]);
2781 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2782 AddItem(_lc[I_MENU_COUNT_BIG]);
2783 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2784 end;
2785 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2786 begin
2787 Name := 'swCorpseType';
2788 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2789 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2790 end;
2791 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2792 begin
2793 Name := 'swGibsType';
2794 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2795 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2796 end;
2797 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2798 begin
2799 Name := 'swBloodType';
2800 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2801 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2802 end;
2803 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2804 begin
2805 Name := 'swScreenFlash';
2806 AddItem(_lc[I_MENU_NO]);
2807 AddItem(_lc[I_MENU_COMPAT_DF]);
2808 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2809 end;
2810 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2811 begin
2812 Name := 'swBackground';
2813 AddItem(_lc[I_MENU_YES]);
2814 AddItem(_lc[I_MENU_NO]);
2815 end;
2816 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2817 begin
2818 Name := 'swMessages';
2819 AddItem(_lc[I_MENU_YES]);
2820 AddItem(_lc[I_MENU_NO]);
2821 end;
2822 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2823 begin
2824 Name := 'swRevertPlayers';
2825 AddItem(_lc[I_MENU_YES]);
2826 AddItem(_lc[I_MENU_NO]);
2827 end;
2828 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2829 begin
2830 Name := 'swChatBubble';
2831 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2832 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2833 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2834 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2835 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2836 end;
2837 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2838 begin
2839 Name := 'swPlayerIndicator';
2840 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2841 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2842 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2843 end;
2844 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2845 begin
2846 Name := 'swPlayerIndicatorStyle';
2847 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2848 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2849 end;
2850 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2851 begin
2852 Name := 'scScaleFactor';
2853 Max := 10;
2854 OnChange := ProcChangeGameSettings;
2855 end;
2856 ReAlign();
2857 end;
2858 Menu.DefControl := 'mOptionsGameMenu';
2859 g_GUI_AddWindow(Menu);
2861 Menu := TGUIWindow.Create('OptionsControlsMenu');
2862 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2863 begin
2864 Name := 'mOptionsControlsMenu';
2865 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2866 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2867 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2868 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2869 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2870 AddSpace();
2871 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2872 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2873 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2874 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2875 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2876 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2877 if e_HasJoysticks then
2878 begin
2879 AddSpace();
2880 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2881 end;
2882 if g_touch_enabled then
2883 begin
2884 AddSpace();
2885 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2886 end;
2887 end;
2888 Menu.DefControl := 'mOptionsControlsMenu';
2889 g_GUI_AddWindow(Menu);
2891 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2892 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2893 begin
2894 Name := 'mOptionsControlsP1Menu';
2895 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2896 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2897 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2898 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2899 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2900 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2901 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2902 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2903 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2904 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2905 end;
2906 Menu.DefControl := 'mOptionsControlsP1Menu';
2907 g_GUI_AddWindow(Menu);
2909 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2910 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2911 begin
2912 Name := 'mOptionsControlsP1MenuWeapons';
2913 for i := WP_FIRST to WP_LAST do
2914 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2915 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2916 end;
2917 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2918 g_GUI_AddWindow(Menu);
2920 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2921 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2922 begin
2923 Name := 'mOptionsControlsP2Menu';
2924 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2925 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2926 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2927 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2928 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2929 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2930 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2931 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2932 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2933 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2934 end;
2935 Menu.DefControl := 'mOptionsControlsP2Menu';
2936 g_GUI_AddWindow(Menu);
2938 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2939 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2940 begin
2941 Name := 'mOptionsControlsP2MenuWeapons';
2942 for i := WP_FIRST to WP_LAST do
2943 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2944 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2945 end;
2946 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2947 g_GUI_AddWindow(Menu);
2949 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2950 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2951 begin
2952 Name := 'mOptionsControlsJoystickMenu';
2953 for i := 0 to e_MaxJoys - 1 do
2954 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2955 begin
2956 Name := 'scDeadzone' + IntToStr(i);
2957 Max := 20
2958 end
2959 end;
2960 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2961 g_GUI_AddWindow(Menu);
2963 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2964 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2965 begin
2966 Name := 'mOptionsControlsTouchMenu';
2967 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2968 begin
2969 Name := 'swTouchAlt';
2970 AddItem(_lc[I_MENU_NO]);
2971 AddItem(_lc[I_MENU_YES]);
2972 OnChange := ProcChangeTouchSettings;
2973 end;
2974 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2975 begin
2976 Name := 'scTouchSize';
2977 Max := 20;
2978 OnChange := ProcChangeTouchSettings;
2979 end;
2980 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2981 begin
2982 Name := 'swTouchFire';
2983 AddItem(_lc[I_MENU_NO]);
2984 AddItem(_lc[I_MENU_YES]);
2985 end;
2986 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2987 begin
2988 Name := 'scTouchOffset';
2989 Max := 20;
2990 OnChange := ProcChangeTouchSettings;
2991 end;
2992 end;
2993 Menu.DefControl := 'mOptionsControlsTouchMenu';
2994 g_GUI_AddWindow(Menu);
2996 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2997 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2998 begin
2999 Name := 'mOptionsPlayersMenu';
3000 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3001 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3002 end;
3003 Menu.DefControl := 'mOptionsPlayersMenu';
3004 g_GUI_AddWindow(Menu);
3006 CreatePlayerOptionsMenu('P1');
3007 CreatePlayerOptionsMenu('P2');
3009 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3010 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3011 begin
3012 Name := 'mOptionsPlayersMIMenu';
3013 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3014 begin
3015 Name := 'lbName';
3016 FixedLength := 16;
3017 end;
3018 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3019 begin
3020 Name := 'lbAuthor';
3021 FixedLength := 16;
3022 end;
3023 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3024 begin
3025 Name := 'meComment';
3026 end;
3027 AddSpace();
3028 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3029 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3030 begin
3031 Name := 'lbWeapon';
3032 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3033 end;
3034 ReAlign();
3035 end;
3036 Menu.DefControl := 'mOptionsPlayersMIMenu';
3037 g_GUI_AddWindow(Menu);
3039 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3040 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3041 begin
3042 Name := 'mOptionsLanguageMenu';
3043 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3044 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3045 ReAlign();
3046 end;
3047 Menu.DefControl := 'mOptionsLanguageMenu';
3048 g_GUI_AddWindow(Menu);
3050 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3051 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3052 g_GUI_AddWindow(Menu);
3054 Menu := TGUIWindow.Create('AuthorsMenu');
3055 Menu.BackTexture := 'INTER';
3056 Menu.OnClose := ProcAuthorsClose;
3058 // Çàãîëîâîê:
3059 _y := 16;
3060 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3061 begin
3062 Color := _RGB(255, 0, 0);
3063 X := (gScreenWidth div 2)-(GetWidth() div 2);
3064 Y := _y;
3065 _y := _y+GetHeight();
3066 end;
3067 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3068 begin
3069 Color := _RGB(255, 0, 0);
3070 X := (gScreenWidth div 2)-(GetWidth() div 2);
3071 Y := _y;
3072 _y := _y+GetHeight()+32;
3073 end;
3074 // ×òî äåëàë: Êòî äåëàë
3075 cx := gScreenWidth div 2 - 320 + 64;
3076 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3077 begin
3078 Color := _RGB(255, 0, 0);
3079 X := cx;
3080 Y := _y;
3081 _y := _y+22;
3082 end;
3083 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3084 begin
3085 Color := _RGB(255, 255, 255);
3086 X := cx+32;
3087 Y := _y;
3088 _y := _y+36;
3089 end;
3090 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3091 begin
3092 Color := _RGB(255, 0, 0);
3093 X := cx;
3094 Y := _y;
3095 _y := _y+22;
3096 end;
3097 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3098 begin
3099 Color := _RGB(255, 255, 255);
3100 X := cx+32;
3101 Y := _y;
3102 _y := _y+22;
3103 end;
3104 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3105 begin
3106 Color := _RGB(255, 255, 255);
3107 X := cx+32;
3108 Y := _y;
3109 _y := _y+36;
3110 end;
3111 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3112 begin
3113 Color := _RGB(255, 0, 0);
3114 X := cx;
3115 Y := _y;
3116 _y := _y+22;
3117 end;
3118 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3119 begin
3120 Color := _RGB(255, 255, 255);
3121 X := cx+32;
3122 Y := _y;
3123 _y := _y+36;
3124 end;
3125 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3126 begin
3127 Color := _RGB(255, 0, 0);
3128 X := cx;
3129 Y := _y;
3130 _y := _y+22;
3131 end;
3132 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3133 begin
3134 Color := _RGB(255, 255, 255);
3135 X := cx+32;
3136 Y := _y;
3137 _y := gScreenHeight - 128;
3138 end;
3139 // Çàêëþ÷åíèå:
3140 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3141 begin
3142 Color := _RGB(255, 0, 0);
3143 X := cx;
3144 Y := _y;
3145 _y := _y+16;
3146 end;
3147 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3148 begin
3149 Color := _RGB(255, 255, 255);
3150 X := cx+32;
3151 Y := _y;
3152 _y := _y+GetHeight();
3153 end;
3154 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3155 begin
3156 Color := _RGB(255, 255, 255);
3157 X := cx+32;
3158 Y := _y;
3159 _y := _y+GetHeight();
3160 end;
3161 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3162 begin
3163 Color := _RGB(255, 255, 255);
3164 X := cx+32;
3165 Y := _y;
3166 _y := gScreenHeight - 32;
3167 end;
3168 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3169 begin
3170 Color := _RGB(255, 0, 0);
3171 X := gScreenWidth div 2 - GetWidth() div 2;
3172 Y := _y;
3173 end;
3174 g_GUI_AddWindow(Menu);
3176 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3177 gMenuSmallFont, @ProcExitMenuKeyDown);
3178 g_GUI_AddWindow(Menu);
3180 Menu := TGUIWindow.Create('GameSingleMenu');
3181 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3182 begin
3183 Name := 'mmGameSingleMenu';
3184 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3185 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3186 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3187 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3188 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3189 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3190 end;
3191 Menu.DefControl := 'mmGameSingleMenu';
3192 Menu.MainWindow := True;
3193 Menu.OnClose := ProcGMClose;
3194 Menu.OnShow := ProcGMShow;
3195 g_GUI_AddWindow(Menu);
3197 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3198 gMenuSmallFont, @ProcEndMenuKeyDown);
3199 g_GUI_AddWindow(Menu);
3201 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3202 gMenuSmallFont, @ProcRestartMenuKeyDown);
3203 g_GUI_AddWindow(Menu);
3205 Menu := TGUIWindow.Create('GameCustomMenu');
3206 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3207 begin
3208 Name := 'mmGameCustomMenu';
3209 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3210 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3211 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3212 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3213 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3214 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3215 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3216 end;
3217 Menu.DefControl := 'mmGameCustomMenu';
3218 Menu.MainWindow := True;
3219 Menu.OnClose := ProcGMClose;
3220 Menu.OnShow := ProcGMShow;
3221 g_GUI_AddWindow(Menu);
3223 Menu := TGUIWindow.Create('GameServerMenu');
3224 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3225 begin
3226 Name := 'mmGameServerMenu';
3227 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3228 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3229 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3230 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3231 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3232 end;
3233 Menu.DefControl := 'mmGameServerMenu';
3234 Menu.MainWindow := True;
3235 Menu.OnClose := ProcGMClose;
3236 Menu.OnShow := ProcGMShow;
3237 g_GUI_AddWindow(Menu);
3239 Menu := TGUIWindow.Create('GameClientMenu');
3240 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3241 begin
3242 Name := 'mmGameClientMenu';
3243 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3244 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3245 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3246 end;
3247 Menu.DefControl := 'mmGameClientMenu';
3248 Menu.MainWindow := True;
3249 Menu.OnClose := ProcGMClose;
3250 Menu.OnShow := ProcGMShow;
3251 g_GUI_AddWindow(Menu);
3253 Menu := TGUIWindow.Create('ClientPasswordMenu');
3254 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3255 begin
3256 Name := 'mClientPasswordMenu';
3257 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3258 begin
3259 Name := 'edPW';
3260 Width := 12;
3261 MaxLength := 32;
3262 end;
3263 AddSpace;
3265 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3266 ReAlign();
3267 end;
3268 Menu.DefControl := 'mClientPasswordMenu';
3269 g_GUI_AddWindow(Menu);
3271 Menu := TGUIWindow.Create('GameSetGameMenu');
3272 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3273 begin
3274 Name := 'mGameSetGameMenu';
3275 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3276 begin
3277 Name := 'swTeamDamage';
3278 AddItem(_lc[I_MENU_YES]);
3279 AddItem(_lc[I_MENU_NO]);
3280 ItemIndex := 1;
3281 end;
3282 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3283 begin
3284 Name := 'swTeamHit';
3285 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3286 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3287 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3288 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3289 ItemIndex := 0
3290 end;
3291 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3292 begin
3293 Name := 'swDeathmatchKeys';
3294 AddItem(_lc[I_MENU_YES]);
3295 AddItem(_lc[I_MENU_NO]);
3296 ItemIndex := 1;
3297 end;
3298 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3299 begin
3300 Name := 'edTimeLimit';
3301 OnlyDigits := True;
3302 Width := 4;
3303 MaxLength := 5;
3304 end;
3305 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3306 begin
3307 Name := 'edGoalLimit';
3308 OnlyDigits := True;
3309 Width := 4;
3310 MaxLength := 5;
3311 end;
3312 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3313 begin
3314 Name := 'edMaxLives';
3315 OnlyDigits := True;
3316 Width := 4;
3317 MaxLength := 5;
3318 end;
3319 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3320 begin
3321 Name := 'swBotsVS';
3322 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3323 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3324 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3325 ItemIndex := 2;
3326 end;
3328 ReAlign();
3329 end;
3330 Menu.DefControl := 'mGameSetGameMenu';
3331 Menu.OnClose := ProcApplyGameSet;
3332 g_GUI_AddWindow(Menu);
3334 Menu := TGUIWindow.Create('TeamMenu');
3335 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3336 begin
3337 Name := 'mmTeamMenu';
3338 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3339 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3340 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3341 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3342 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3343 end;
3344 Menu.DefControl := 'mmTeamMenu';
3345 Menu.OnShow := ProcChangePlayers;
3346 g_GUI_AddWindow(Menu);
3347 end;
3349 procedure g_Menu_Show_SaveMenu();
3350 begin
3351 if g_Game_IsTestMap then
3352 Exit;
3353 if gGameSettings.GameType = GT_SINGLE then
3354 g_GUI_ShowWindow('GameSingleMenu')
3355 else
3356 begin
3357 if g_Game_IsClient then
3358 Exit
3359 else
3360 if g_Game_IsNet then
3361 Exit
3362 else
3363 g_GUI_ShowWindow('GameCustomMenu');
3364 end;
3365 g_GUI_ShowWindow('SaveMenu');
3366 g_Sound_PlayEx('MENU_OPEN');
3367 end;
3369 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3370 begin
3371 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3372 if gGameSettings.GameType = GT_SINGLE then
3373 begin
3374 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3375 end
3376 else
3377 begin
3378 if g_Game_IsClient then exit;
3379 if g_Game_IsNet then exit;
3380 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3381 end;
3382 g_GUI_ShowWindow('LoadMenu');
3383 g_Sound_PlayEx('MENU_OPEN');
3384 end;
3386 procedure g_Menu_Show_GameSetGame();
3387 begin
3388 if gGameSettings.GameType = GT_SINGLE then
3389 g_GUI_ShowWindow('GameSingleMenu')
3390 else
3391 begin
3392 if g_Game_IsClient then
3393 Exit
3394 else
3395 if g_Game_IsNet then
3396 g_GUI_ShowWindow('GameServerMenu')
3397 else
3398 g_GUI_ShowWindow('GameCustomMenu');
3399 end;
3400 ReadGameSettings();
3401 g_GUI_ShowWindow('GameSetGameMenu');
3402 g_Sound_PlayEx('MENU_OPEN');
3403 end;
3405 procedure g_Menu_Show_OptionsVideo();
3406 begin
3407 if gGameSettings.GameType = GT_SINGLE then
3408 g_GUI_ShowWindow('GameSingleMenu')
3409 else
3410 begin
3411 if g_Game_IsClient then
3412 g_GUI_ShowWindow('GameClientMenu')
3413 else
3414 if g_Game_IsNet then
3415 g_GUI_ShowWindow('GameServerMenu')
3416 else
3417 g_GUI_ShowWindow('GameCustomMenu');
3418 end;
3419 ReadOptions();
3420 g_GUI_ShowWindow('OptionsMenu');
3421 g_GUI_ShowWindow('OptionsVideoMenu');
3422 g_Sound_PlayEx('MENU_OPEN');
3423 end;
3425 procedure g_Menu_Show_OptionsSound();
3426 begin
3427 if gGameSettings.GameType = GT_SINGLE then
3428 g_GUI_ShowWindow('GameSingleMenu')
3429 else
3430 begin
3431 if g_Game_IsClient then
3432 g_GUI_ShowWindow('GameClientMenu')
3433 else
3434 if g_Game_IsNet then
3435 g_GUI_ShowWindow('GameServerMenu')
3436 else
3437 g_GUI_ShowWindow('GameCustomMenu');
3438 end;
3439 ReadOptions();
3440 g_GUI_ShowWindow('OptionsMenu');
3441 g_GUI_ShowWindow('OptionsSoundMenu');
3442 g_Sound_PlayEx('MENU_OPEN');
3443 end;
3445 procedure g_Menu_Show_EndGameMenu();
3446 begin
3447 g_GUI_ShowWindow('EndGameMenu');
3448 g_Sound_PlayEx('MENU_OPEN');
3449 end;
3451 procedure g_Menu_Show_QuitGameMenu();
3452 begin
3453 g_GUI_ShowWindow('ExitMenu');
3454 g_Sound_PlayEx('MENU_OPEN');
3455 end;
3457 procedure g_Menu_Init();
3458 begin
3459 MenuLoadData();
3460 CreateAllMenus();
3461 end;
3463 procedure g_Menu_Free();
3464 begin
3465 MenuFreeData();
3466 end;
3468 procedure g_Menu_Reset();
3469 var
3470 ex: Boolean;
3471 begin
3472 g_GUI_SaveMenuPos();
3473 ex := g_GUI_Destroy();
3475 if ex then
3476 begin
3477 e_WriteLog('Recreating menu...', TMsgType.Notify);
3479 CreateAllMenus();
3481 if gDebugMode then
3482 g_Game_SetDebugMode();
3484 g_GUI_LoadMenuPos();
3485 end;
3486 end;
3488 end.