DEADSOFTWARE

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