DEADSOFTWARE

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