DEADSOFTWARE

d409cc6f484bcb9974ec707452c7ea19b3fc9cc2
[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 // TODO: get this crap out of here
687 gGameSettings.ItemRespawnTime := gsItemRespawnTime;
688 gGameSettings.WarmupTime := gsWarmupTime;
689 gGameSettings.SpawnInvul := gsSpawnInvul;
690 end;
691 end;
693 procedure ProcStartCustomGame();
694 var
695 GameMode: Byte;
696 begin
697 GameMode := LatchGameOptions('mCustomGameMenu');
698 if GameMode = GM_NONE then Exit;
700 g_Console_WriteGameConfig;
701 g_Game_StartCustom(gsMap, GameMode, gsTimeLimit, gsGoalLimit,
702 gsMaxLives, gsGameFlags, gsPlayers);
703 end;
706 procedure ProcStartNetGame();
707 var
708 GameMode: Byte;
709 begin
710 GameMode := LatchGameOptions('mNetServerMenu');
711 if GameMode = GM_NONE then Exit;
713 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
714 begin
715 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
716 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
717 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
718 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
719 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
720 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
721 end;
723 g_Console_WriteGameConfig;
724 g_Game_StartServer(gsMap, GameMode, gsTimeLimit, gsGoalLimit, gsMaxLives,
725 gsGameFlags, gsPlayers, 0, NetPort);
726 end;
728 procedure ProcConnectNetGame();
729 var
730 PW: String;
731 begin
732 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
733 begin
734 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
735 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
736 PW := TGUIEdit(GetControl('edPW')).Text;
737 end;
739 g_Console_WriteGameConfig;
740 g_Game_StartClient(NetClientIP, NetClientPort, PW);
741 end;
743 procedure ProcEnterPassword();
744 var
745 PW: string;
746 begin
747 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
748 begin
749 NetClientIP := PromptIP;
750 NetClientPort := PromptPort;
751 PW := TGUIEdit(GetControl('edPW')).Text;
752 end;
754 g_Console_WriteGameConfig;
755 g_Game_StartClient(NetClientIP, NetClientPort, PW);
756 end;
758 procedure ProcServerlist();
759 begin
760 if not NetInitDone then
761 begin
762 if (not g_Net_Init()) then
763 begin
764 g_Console_Add('NET: ERROR: Failed to init ENet!');
765 Exit;
766 end
767 else
768 NetInitDone := True;
769 end;
771 g_Net_Slist_Set(NetMasterList);
773 gState := STATE_SLIST;
774 g_ActiveWindow := nil;
776 slWaitStr := _lc[I_NET_SLIST_WAIT];
778 g_Game_Draw;
779 sys_Repaint;
781 slReturnPressed := True;
782 if g_Net_Slist_Fetch(slCurrent) then
783 begin
784 if slCurrent = nil then
785 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
786 end
787 else
788 slWaitStr := _lc[I_NET_SLIST_ERROR];
789 g_Serverlist_GenerateTable(slCurrent, slTable);
790 end;
792 procedure ProcStartCampaign();
793 var
794 WAD: String;
795 TwoPlayers: Boolean;
796 n: Byte;
797 begin
798 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
799 begin
800 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
801 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
802 end;
803 WAD := e_FindWadRel(MegawadDirs, WAD);
805 if TwoPlayers then
806 n := 2
807 else
808 n := 1;
809 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
810 end;
812 procedure ProcSelectMap(Sender: TGUIControl);
813 var
814 win: TGUIWindow;
815 a: TMapInfo;
816 wad, map, res: String;
817 begin
818 win := g_GUI_GetWindow('SelectMapMenu');
819 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
820 begin
821 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
822 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
824 if (wad = '') or (map = '') then
825 begin // Ýòî íå êàðòà
826 TGUILabel(GetControl('lbMapName')).Text := '';
827 TGUILabel(GetControl('lbMapAuthor')).Text := '';
828 TGUILabel(GetControl('lbMapSize')).Text := '';
829 TGUIMemo(GetControl('meMapDescription')).SetText('');
830 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
831 TGUILabel(win.GetControl('lbMapScale')).Text := '';
832 end
833 else // Ýòî êàðòà
834 begin
835 res := wad+':\'+map;
837 a := g_Map_GetMapInfo(res);
839 TGUILabel(GetControl('lbMapName')).Text := a.Name;
840 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
841 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
842 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
843 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
844 TGUILabel(win.GetControl('lbMapScale')).Text :=
845 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
846 end;
847 end;
848 end;
850 procedure ProcSelectWAD(Sender: TGUIControl);
851 var
852 wad: String;
853 list: SSArray;
854 begin
855 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
856 begin
857 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
859 with TGUIListBox(GetControl('lsMapRes')) do
860 begin
861 Clear();
863 if wad <> '' then
864 begin
865 list := g_Map_GetMapsList(wad);
867 if list <> nil then
868 begin
869 Items := list;
870 ItemIndex := 0;
871 end
872 end;
873 end;
874 end;
876 ProcSelectMap(nil);
877 end;
879 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
880 var
881 win: TGUIWindow;
882 a: TMegaWADInfo;
883 wad, fn: String;
884 begin
885 win := g_GUI_GetWindow('CampaignMenu');
886 with TGUIMenu(win.GetControl('mCampaignMenu')) do
887 begin
888 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
890 if wad = '' then
891 begin
892 TGUILabel(GetControl('lbWADName')).Text := '';
893 TGUILabel(GetControl('lbWADAuthor')).Text := '';
894 TGUIMemo(GetControl('meWADDescription')).SetText('');
895 end;
897 a := g_Game_GetMegaWADInfo(wad);
899 TGUILabel(GetControl('lbWADName')).Text := a.Name;
900 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
901 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
903 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
905 if a.pic <> '' then
906 begin
907 fn := g_ExtractWadName(a.pic);
908 if fn = '' then
909 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
910 else
911 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
912 end;
913 end;
914 end;
916 procedure ProcChangeColor(Sender: TGUIControl);
917 var
918 window: TGUIWindow;
919 begin
920 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
921 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
922 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
923 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
924 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
925 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
927 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
928 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
929 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
930 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
931 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
932 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
933 end;
935 procedure ProcSelectModel(Sender: TGUIControl);
936 var
937 a: string;
938 window: TGUIWindow;
939 begin
940 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
941 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
942 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
944 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
945 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
946 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
948 ProcChangeColor(nil);
949 end;
951 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
952 var
953 cwdt, chgt: Byte;
954 spc: ShortInt;
955 ID: DWORD;
956 wad: TWADFile;
957 cfgdata: Pointer;
958 cfglen: Integer;
959 config: TConfig;
960 begin
961 cfglen := 0;
963 wad := TWADFile.Create;
964 if wad.ReadFile(GameWAD) then
965 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
966 wad.Free();
968 if cfglen <> 0 then
969 begin
970 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
972 config := TConfig.CreateMem(cfgdata, cfglen);
973 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
974 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
975 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
977 if g_Texture_Get('FONT_STD', ID) then
978 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
980 config.Free();
981 end;
983 if cfglen <> 0 then FreeMem(cfgdata);
984 end;
986 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
987 var
988 cwdt, chgt: Byte;
989 spc: ShortInt;
990 CharID: DWORD;
991 wad: TWADFile;
992 cfgdata, fntdata: Pointer;
993 cfglen, fntlen: Integer;
994 config: TConfig;
995 chrwidth: Integer;
996 a: Byte;
997 begin
998 cfglen := 0;
999 fntlen := 0;
1001 wad := TWADFile.Create;
1002 if wad.ReadFile(GameWAD) then
1003 begin
1004 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1005 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1006 end;
1007 wad.Free();
1009 if cfglen <> 0 then
1010 begin
1011 config := TConfig.CreateMem(cfgdata, cfglen);
1012 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1013 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1015 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1016 FontID := e_CharFont_Create(spc);
1018 for a := 0 to 255 do
1019 begin
1020 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1021 if chrwidth = 0 then Continue;
1023 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1024 cwdt, chgt) then
1025 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1026 end;
1028 config.Free();
1029 end;
1031 if cfglen <> 0 then FreeMem(cfgdata);
1032 if fntlen <> 0 then FreeMem(fntdata);
1033 end;
1035 procedure MenuLoadData();
1036 begin
1037 e_WriteLog('Loading menu data...', TMsgType.Notify);
1039 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD+':TEXTURES\MAINLOGO');
1040 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1041 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1042 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1043 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1044 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1045 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1046 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1047 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1048 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1049 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1050 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1051 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1052 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1053 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1054 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1055 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1056 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1057 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1058 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1059 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1060 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1061 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1062 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1063 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1065 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1066 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1067 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1068 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1069 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1070 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1071 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1072 end;
1074 procedure MenuFreeData();
1075 begin
1076 e_CharFont_Remove(gMenuFont);
1077 e_CharFont_Remove(gMenuSmallFont);
1079 g_Texture_Delete('MAINMENU_LOGO');
1080 g_Texture_Delete('MAINMENU_MARKER1');
1081 g_Texture_Delete('MAINMENU_MARKER2');
1082 g_Texture_Delete('SCROLL_LEFT');
1083 g_Texture_Delete('SCROLL_RIGHT');
1084 g_Texture_Delete('SCROLL_MIDDLE');
1085 g_Texture_Delete('SCROLL_MARKER');
1086 g_Texture_Delete('EDIT_LEFT');
1087 g_Texture_Delete('EDIT_RIGHT');
1088 g_Texture_Delete('EDIT_MIDDLE');
1089 g_Texture_Delete('BOX1');
1090 g_Texture_Delete('BOX2');
1091 g_Texture_Delete('BOX3');
1092 g_Texture_Delete('BOX4');
1093 g_Texture_Delete('BOX5');
1094 g_Texture_Delete('BOX6');
1095 g_Texture_Delete('BOX7');
1096 g_Texture_Delete('BOX8');
1097 g_Texture_Delete('BOX9');
1098 g_Texture_Delete('BSCROLL_UP_A');
1099 g_Texture_Delete('BSCROLL_UP_U');
1100 g_Texture_Delete('BSCROLL_DOWN_A');
1101 g_Texture_Delete('BSCROLL_DOWN_U');
1102 g_Texture_Delete('BSCROLL_MIDDLE');
1103 g_Texture_Delete('NOPIC');
1105 g_Sound_Delete('MENU_SELECT');
1106 g_Sound_Delete('MENU_OPEN');
1107 g_Sound_Delete('MENU_CLOSE');
1108 g_Sound_Delete('MENU_CHANGE');
1109 g_Sound_Delete('SCROLL_ADD');
1110 g_Sound_Delete('SCROLL_SUB');
1111 g_Sound_Delete('SOUND_PLAYER_FALL');
1112 end;
1114 procedure ProcAuthorsMenu();
1115 begin
1116 gMusic.SetByName('MUSIC_INTERMUS');
1117 gMusic.Play();
1118 end;
1120 procedure ProcExitMenuKeyDown (yes: Boolean);
1121 var
1122 s: ShortString;
1123 snd: TPlayableSound;
1124 res: Boolean;
1125 begin
1126 if yes then
1127 begin
1128 g_Game_StopAllSounds(True);
1129 case (Random(18)) of
1130 0: s := 'SOUND_MONSTER_PAIN';
1131 1: s := 'SOUND_MONSTER_DIE_3';
1132 2: s := 'SOUND_MONSTER_SLOP';
1133 3: s := 'SOUND_MONSTER_DEMON_DIE';
1134 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1135 5: s := 'SOUND_MONSTER_MAN_DIE';
1136 6: s := 'SOUND_MONSTER_BSP_DIE';
1137 7: s := 'SOUND_MONSTER_VILE_DIE';
1138 8: s := 'SOUND_MONSTER_SKEL_DIE';
1139 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1140 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1141 11: s := 'SOUND_MONSTER_BARON_DIE';
1142 12: s := 'SOUND_MONSTER_CACO_DIE';
1143 13: s := 'SOUND_MONSTER_CYBER_DIE';
1144 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1145 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1146 else s := 'SOUND_PLAYER_FALL';
1147 end;
1148 snd := TPlayableSound.Create();
1149 res := snd.SetByName(s);
1150 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1151 if res then
1152 begin
1153 snd.Play(True);
1154 while snd.IsPlaying() do begin end;
1155 end;
1156 g_Game_Quit();
1157 exit;
1158 end;
1159 g_GUI_HideWindow();
1160 end;
1162 procedure ProcLoadMenu();
1163 var
1164 a: Integer;
1165 valid: Boolean;
1166 begin
1167 for a := 1 to 8 do
1168 begin
1169 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1170 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1171 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1172 end;
1173 end;
1175 procedure ProcSaveMenu();
1176 var
1177 a: Integer;
1178 valid: Boolean;
1179 name: AnsiString;
1180 begin
1181 for a := 1 to 8 do
1182 begin
1183 name := g_GetSaveName(a, valid);
1184 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1185 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1186 end;
1187 end;
1189 procedure ProcSaveGame(Sender: TGUIControl);
1190 var
1191 a: Integer;
1192 begin
1193 if g_Game_IsNet then Exit;
1194 if g_Game_IsTestMap then Exit;
1195 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1196 g_Game_PauseAllSounds(True);
1197 g_SaveGame(a, TGUIEdit(Sender).Text);
1199 g_ActiveWindow := nil;
1200 g_Game_Pause(False);
1201 end;
1203 procedure ProcLoadGame(Sender: TGUIControl);
1204 var
1205 a: Integer;
1206 begin
1207 if g_Game_IsNet then Exit;
1208 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1209 if g_LoadGame(a) then
1210 begin
1211 g_Game_PauseAllSounds(False)
1212 end
1213 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1214 begin
1215 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1216 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1217 //g_ActiveWindow := nil;
1218 end;
1219 end;
1221 procedure ProcSinglePlayer (n: Integer);
1222 var wad, map: AnsiString;
1223 begin
1224 assert(n >= 1);
1225 wad := g_ExtractWadName(gDefaultMegawadStart);
1226 map := g_ExtractFilePathName(gDefaultMegawadStart);
1227 if e_FindResource(AllMapDirs, wad) then
1228 begin
1229 wad := ExpandFileName(wad);
1230 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1231 end
1232 end;
1234 procedure ProcSingle1Player;
1235 begin
1236 ProcSinglePlayer(1)
1237 end;
1239 procedure ProcSingle2Players;
1240 begin
1241 ProcSinglePlayer(2)
1242 end;
1244 procedure ProcSelectMapMenu();
1245 var
1246 menu: TGUIMenu;
1247 wad_lb: TGUIFileListBox;
1248 map_lb: TGUIListBox;
1249 map: String;
1250 begin
1251 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1252 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1253 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1255 if wad_lb.SelectedItem() <> '' then
1256 map := map_lb.SelectedItem()
1257 else
1258 map := '';
1260 wad_lb.UpdateFileList();
1261 map_lb.Clear();
1263 if wad_lb.SelectedItem() <> '' then
1264 begin
1265 ProcSelectWAD(nil);
1266 map_lb.SelectItem(map);
1268 if map_lb.SelectedItem() <> '' then
1269 ProcSelectMap(nil);
1270 end;
1272 g_GUI_ShowWindow('SelectMapMenu');
1273 end;
1275 procedure ProcSelectCampaignMenu();
1276 var
1277 menu: TGUIMenu;
1278 wad_lb: TGUIFileListBox;
1279 begin
1280 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1281 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1283 wad_lb.UpdateFileList();
1285 if wad_lb.SelectedItem() <> '' then
1286 ProcSelectCampaignWAD(nil);
1287 end;
1289 procedure ProcSetMap();
1290 var
1291 wad, map, res: String;
1292 begin
1293 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1294 begin
1295 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1296 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1297 end;
1299 if (wad = '') or (map = '') then
1300 Exit;
1302 wad := e_FindWadRel(MapDirs, WAD);
1304 res := wad+':\'+map;
1306 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1307 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1308 end;
1310 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1311 var
1312 menu: TGUIMenu;
1313 begin
1314 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1316 g_Sound_SetupAllVolumes(
1317 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1318 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1319 );
1320 end;
1322 procedure ProcChangeGameSettings(Sender: TGUIControl);
1323 var
1324 menu: TGUIMenu;
1325 begin
1326 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1327 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1328 begin
1329 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1330 g_dbg_scale := TempScale + 1;
1331 end;
1332 end;
1334 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1335 var
1336 menu: TGUIMenu;
1337 begin
1338 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1339 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1340 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1341 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1342 end;
1344 procedure ProcOptionsPlayersMIMenu();
1345 var
1346 s, a: string;
1347 b: TModelInfo;
1348 begin
1349 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1351 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1353 if a = '' then Exit;
1355 b := g_PlayerModel_GetInfo(a);
1357 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1358 begin
1359 TGUILabel(GetControl('lbName')).Text := b.Name;
1360 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1361 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1363 if b.HaveWeapon then
1364 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1365 else
1366 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1367 end;
1369 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1370 end;
1372 procedure ProcOptionsPlayersAnim();
1373 var
1374 s: String;
1375 begin
1376 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1377 s := 'P1'
1378 else
1379 s := 'P2';
1381 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1382 begin
1383 NextAnim();
1384 Model.GetCurrentAnimation.Loop := True;
1385 Model.GetCurrentAnimationMask.Loop := True;
1386 end;
1387 end;
1389 procedure ProcOptionsPlayersWeap();
1390 var
1391 s: String;
1392 begin
1393 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1394 s := 'P1'
1395 else
1396 s := 'P2';
1398 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1399 NextWeapon();
1400 end;
1402 procedure ProcOptionsPlayersRot();
1403 var
1404 s: string;
1405 begin
1406 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1407 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1408 begin
1409 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1410 end;
1411 end;
1413 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1414 begin
1415 if yes then
1416 begin
1417 g_Options_SetDefault();
1418 ReadOptions();
1419 end;
1420 g_GUI_HideWindow();
1421 end;
1423 procedure ProcSavedMenuKeyDown (yes: Boolean);
1424 begin
1425 if yes then ReadOptions();
1426 g_GUI_HideWindow();
1427 end;
1429 procedure ProcAuthorsClose();
1430 begin
1431 gMusic.SetByName('MUSIC_MENU');
1432 gMusic.Play();
1433 gState := STATE_MENU;
1434 end;
1436 procedure ProcGMClose();
1437 begin
1438 g_Game_InGameMenu(False);
1439 end;
1441 procedure ProcGMShow();
1442 var
1443 Enabled: Boolean;
1444 begin
1445 Enabled := True;
1446 if (gGameSettings.GameType = GT_SINGLE) and
1447 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1448 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1449 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1450 if not gGameOn then
1451 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1452 if g_Game_IsTestMap then
1453 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1454 TGUIMainMenu(g_ActiveWindow.GetControl(
1455 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1456 end;
1458 procedure ProcChangePlayers();
1459 var
1460 TeamGame, Spectator, AddTwo: Boolean;
1461 P1Team{, P2Team}: Byte;
1462 bP2: TGUITextButton;
1463 begin
1464 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1465 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1466 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1467 P1Team := TEAM_NONE;
1468 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1469 // TODO
1470 //P2Team := TEAM_NONE;
1471 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1473 TGUIMainMenu(g_ActiveWindow.GetControl(
1474 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1475 TGUIMainMenu(g_ActiveWindow.GetControl(
1476 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1477 TGUIMainMenu(g_ActiveWindow.GetControl(
1478 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1480 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1481 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1482 bP2.Enabled := AddTwo and not Spectator;
1483 if bP2.Enabled then
1484 bP2.Color := MAINMENU_ITEMS_COLOR
1485 else
1486 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1487 if gPlayer2 = nil then
1488 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1489 else
1490 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1492 TGUIMainMenu(g_ActiveWindow.GetControl(
1493 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1494 end;
1496 procedure ProcJoinRed();
1497 begin
1498 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1499 Exit;
1500 if g_Game_IsServer then
1501 begin
1502 if gPlayer1 = nil then
1503 g_Game_AddPlayer(TEAM_RED)
1504 else
1505 begin
1506 if gPlayer1.Team <> TEAM_RED then
1507 begin
1508 gPlayer1.SwitchTeam;
1509 gPlayer1Settings.Team := gPlayer1.Team;
1510 end;
1512 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1513 end;
1514 end
1515 else
1516 begin
1517 gPlayer1Settings.Team := TEAM_RED;
1518 MC_SEND_PlayerSettings;
1519 if gPlayer1 = nil then
1520 g_Game_AddPlayer(TEAM_RED);
1521 end;
1522 g_ActiveWindow := nil;
1523 g_Game_Pause(False);
1524 end;
1526 procedure ProcJoinBlue();
1527 begin
1528 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1529 Exit;
1530 if g_Game_IsServer then
1531 begin
1532 if gPlayer1 = nil then
1533 g_Game_AddPlayer(TEAM_BLUE)
1534 else
1535 begin
1536 if gPlayer1.Team <> TEAM_BLUE then
1537 begin
1538 gPlayer1.SwitchTeam;
1539 gPlayer1Settings.Team := gPlayer1.Team;
1540 end;
1542 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1543 end;
1544 end
1545 else
1546 begin
1547 gPlayer1Settings.Team := TEAM_BLUE;
1548 MC_SEND_PlayerSettings;
1549 if gPlayer1 = nil then
1550 g_Game_AddPlayer(TEAM_BLUE);
1551 end;
1552 g_ActiveWindow := nil;
1553 g_Game_Pause(False);
1554 end;
1556 procedure ProcJoinGame();
1557 begin
1558 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1559 Exit;
1560 if gPlayer1 = nil then
1561 g_Game_AddPlayer();
1562 g_ActiveWindow := nil;
1563 g_Game_Pause(False);
1564 end;
1566 procedure ProcSwitchP2();
1567 begin
1568 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1569 Exit;
1570 if gPlayer1 = nil then
1571 Exit;
1572 if gPlayer2 = nil then
1573 g_Game_AddPlayer()
1574 else
1575 g_Game_RemovePlayer();
1576 g_ActiveWindow := nil;
1577 g_Game_Pause(False);
1578 end;
1580 procedure ProcSpectate();
1581 begin
1582 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1583 Exit;
1584 g_Game_Spectate();
1585 g_ActiveWindow := nil;
1586 g_Game_Pause(False);
1587 end;
1589 procedure ProcRestartMenuKeyDown (yes: Boolean);
1590 begin
1591 if yes then g_Game_Restart() else g_GUI_HideWindow;
1592 end;
1594 procedure ProcEndMenuKeyDown (yes: Boolean);
1595 begin
1596 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1597 end;
1599 procedure ProcSetRussianLanguage;
1600 begin
1601 if gLanguage <> LANGUAGE_RUSSIAN then
1602 begin
1603 gLanguage := LANGUAGE_RUSSIAN;
1604 gLanguageChange := True;
1605 gAskLanguage := False;
1606 ProcApplyOptions();
1607 end;
1608 end;
1610 procedure ProcSetEnglishLanguage;
1611 begin
1612 if gLanguage <> LANGUAGE_ENGLISH then
1613 begin
1614 gLanguage := LANGUAGE_ENGLISH;
1615 gLanguageChange := True;
1616 gAskLanguage := False;
1617 ProcApplyOptions();
1618 end;
1619 end;
1621 procedure ReadGameSettings();
1622 var
1623 menu: TGUIMenu;
1624 begin
1625 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1627 with gGameSettings do
1628 begin
1629 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1630 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1631 ItemIndex := 0
1632 else
1633 ItemIndex := 1;
1634 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1635 if LongBool(Options and GAME_OPTION_DMKEYS) then
1636 ItemIndex := 0
1637 else
1638 ItemIndex := 1;
1640 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1641 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1642 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1644 with TGUISwitch(menu.GetControl('swBotsVS')) do
1645 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1646 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1647 ItemIndex := 2
1648 else
1649 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1650 ItemIndex := 1
1651 else
1652 ItemIndex := 0;
1654 if GameType in [GT_CUSTOM, GT_SERVER] then
1655 begin
1656 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1657 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1658 begin
1659 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1660 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1661 end
1662 else
1663 begin
1664 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1665 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1666 end;
1667 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1668 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1669 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1670 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1671 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1672 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1673 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1674 end
1675 else
1676 begin
1677 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1678 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1679 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1680 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1681 begin
1682 Enabled := False;
1683 Text := '';
1684 end;
1685 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1686 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1687 begin
1688 Enabled := False;
1689 Text := '';
1690 end;
1691 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1692 with TGUIEdit(menu.GetControl('edMaxLives')) do
1693 begin
1694 Enabled := False;
1695 Text := '';
1696 end;
1697 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1698 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1699 end;
1700 end;
1701 end;
1703 procedure ProcApplyGameSet();
1704 var
1705 menu: TGUIMenu;
1706 a, b, n: Integer;
1707 stat: TPlayerStatArray;
1708 begin
1709 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1711 if not g_Game_IsServer then Exit;
1713 with gGameSettings do
1714 begin
1715 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1716 begin
1717 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1718 Options := Options or GAME_OPTION_TEAMDAMAGE
1719 else
1720 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1721 end;
1723 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1724 begin
1725 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1726 Options := Options or GAME_OPTION_DMKEYS
1727 else
1728 Options := Options and (not GAME_OPTION_DMKEYS);
1729 end;
1731 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1732 begin
1733 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1735 if n = 0 then
1736 TimeLimit := 0
1737 else
1738 begin
1739 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1741 TimeLimit := Max(n, b);
1742 end;
1743 end;
1745 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1746 begin
1747 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1749 if n = 0 then
1750 GoalLimit := 0
1751 else
1752 begin
1753 b := 0;
1754 if GameMode = GM_DM then
1755 begin // DM
1756 stat := g_Player_GetStats();
1757 if stat <> nil then
1758 for a := 0 to High(stat) do
1759 if stat[a].Frags > b then
1760 b := stat[a].Frags;
1761 end
1762 else // CTF
1763 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1765 GoalLimit := Max(n, b);
1766 end;
1767 end;
1769 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1770 begin
1771 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1772 if n < 0 then n := 0;
1773 if n > 255 then n := 255;
1774 if n = 0 then
1775 MaxLives := 0
1776 else
1777 begin
1778 b := 0;
1779 stat := g_Player_GetStats();
1780 if stat <> nil then
1781 for a := 0 to High(stat) do
1782 if stat[a].Lives > b then
1783 b := stat[a].Lives;
1785 MaxLives := Max(n, b);
1786 end;
1787 end;
1789 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1790 begin
1791 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1792 1:
1793 begin
1794 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1795 Options := Options or GAME_OPTION_BOTVSMONSTER;
1796 end;
1797 2:
1798 begin
1799 Options := Options or GAME_OPTION_BOTVSPLAYER;
1800 Options := Options or GAME_OPTION_BOTVSMONSTER;
1801 end;
1802 else
1803 begin
1804 Options := Options or GAME_OPTION_BOTVSPLAYER;
1805 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1806 end;
1807 end;
1808 end;
1810 // don't forget to latch this shit
1811 gsGameFlags := Options;
1812 gsMaxLives := MaxLives;
1813 gsGoalLimit := GoalLimit;
1814 gsTimeLimit := TimeLimit;
1815 end;
1817 if g_Game_IsNet then MH_SEND_GameSettings;
1818 end;
1820 procedure ProcVideoOptionsRes();
1821 var
1822 menu: TGUIMenu;
1823 list: SSArray;
1824 begin
1825 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1827 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1828 IntToStr(gWinSizeX) +
1829 ' x ' + IntToStr(gWinSizeY) +
1830 ', ' + IntToStr(gBPP) + ' bpp';
1832 with TGUIListBox(menu.GetControl('lsResolution')) do
1833 begin
1834 list := sys_GetDisplayModes(gBPP);
1835 if list <> nil then
1836 begin
1837 Items := list;
1838 ItemIndex := Length(list)
1839 end
1840 else
1841 begin
1842 Clear
1843 end
1844 end;
1846 with TGUISwitch(menu.GetControl('swFullScreen')) do
1847 if gFullscreen then
1848 ItemIndex := 0
1849 else
1850 ItemIndex := 1;
1852 TempResScale := Round(r_pixel_scale - 1);
1853 TGUIScroll(menu.GetControl('scResFactor')).Value := TempResScale;
1854 end;
1856 procedure ProcApplyVideoOptions();
1857 var
1858 menu: TGUIMenu;
1859 Fullscreen: Boolean;
1860 SWidth, SHeight: Integer;
1861 ScaleChanged: Boolean;
1862 str: String;
1863 begin
1864 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1866 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1867 if str <> '' then
1868 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1869 else
1870 begin
1871 SWidth := gWinSizeX;
1872 SHeight := gWinSizeY;
1873 end;
1875 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1877 ScaleChanged := False;
1878 if TGUIScroll(menu.GetControl('scResFactor')).Value <> TempResScale then
1879 begin
1880 TempResScale := TGUIScroll(menu.GetControl('scResFactor')).Value;
1881 r_pixel_scale := TempResScale + 1;
1882 ScaleChanged := True;
1883 end;
1885 if (SWidth <> gWinSizeX) or
1886 (SHeight <> gWinSizeY) or
1887 (Fullscreen <> gFullscreen) or
1888 ScaleChanged then
1889 begin
1890 gResolutionChange := True;
1891 gRC_Width := SWidth;
1892 gRC_Height := SHeight;
1893 gRC_FullScreen := Fullscreen;
1894 gRC_Maximized := gWinMaximized;
1895 end;
1897 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1898 ProcApplyOptions();
1899 end;
1901 procedure ProcSetFirstRussianLanguage;
1902 begin
1903 gLanguage := LANGUAGE_RUSSIAN;
1904 gLanguageChange := True;
1905 gAskLanguage := False;
1906 end;
1908 procedure ProcSetFirstEnglishLanguage;
1909 begin
1910 gLanguage := LANGUAGE_ENGLISH;
1911 gLanguageChange := True;
1912 gAskLanguage := False;
1913 end;
1915 procedure ProcRecallAddress();
1916 begin
1917 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1918 begin
1919 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1920 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1921 end;
1922 end;
1924 procedure CreateFirstLanguageMenu();
1925 var
1926 Menu: TGUIWindow;
1927 begin
1928 Menu := TGUIWindow.Create('FirstLanguageMenu');
1930 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1931 begin
1932 Name := 'mmFirstLanguageMenu';
1933 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1934 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1935 end;
1937 Menu.DefControl := 'mmFirstLanguageMenu';
1938 Menu.MainWindow := True;
1939 g_GUI_AddWindow(Menu);
1940 end;
1942 procedure g_Menu_AskLanguage();
1943 begin
1944 CreateFirstLanguageMenu();
1945 g_GUI_ShowWindow('FirstLanguageMenu');
1946 end;
1948 procedure CreatePlayerOptionsMenu(s: String);
1949 var
1950 Menu: TGUIWindow;
1951 a: String;
1952 begin
1953 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1954 if s = 'P1' then
1955 a := _lc[I_MENU_PLAYER_1]
1956 else
1957 a := _lc[I_MENU_PLAYER_2];
1958 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1959 begin
1960 Name := 'mOptionsPlayers'+s+'Menu';
1961 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1962 begin
1963 Name := 'ed'+s+'Name';
1964 MaxLength := 12;
1965 Width := 12;
1966 end;
1967 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1968 begin
1969 Name := 'sw'+s+'Team';
1970 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1971 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1972 end ;
1973 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1974 begin
1975 Name := 'ls'+s+'Model';
1976 Sort := True;
1977 Items := g_PlayerModel_GetNames();
1978 OnChange := ProcSelectModel;
1979 end;
1980 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1981 begin
1982 Name := 'sc'+s+'Red';
1983 Max := 16;
1984 OnChange := ProcChangeColor;
1985 end;
1986 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1987 begin
1988 Name := 'sc'+s+'Green';
1989 Max := 16;
1990 OnChange := ProcChangeColor;
1991 end;
1992 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1993 begin
1994 Name := 'sc'+s+'Blue';
1995 Max := 16;
1996 OnChange := ProcChangeColor;
1997 end;
1998 AddSpace();
1999 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2000 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2001 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2002 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2004 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2005 begin
2006 Name := 'mv'+s+'Model';
2007 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2008 Y := GetControl('ls'+s+'Model').Y;
2009 end;
2010 end;
2011 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2012 g_GUI_AddWindow(Menu);
2013 end;
2015 procedure CreateAllMenus();
2016 var
2017 Menu: TGUIWindow;
2018 //SR: TSearchRec;
2019 a, cx, _y, i: Integer;
2020 //list: SSArray;
2021 begin
2022 Menu := TGUIWindow.Create('MainMenu');
2023 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2024 begin
2025 Name := 'mmMainMenu';
2026 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2027 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2028 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2029 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2030 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2031 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2032 end;
2033 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2034 begin
2035 Color := _RGB(255, 255, 255);
2036 X := gScreenWidth-GetWidth-8;
2037 Y := gScreenHeight-GetHeight-8;
2038 end;
2039 Menu.DefControl := 'mmMainMenu';
2040 Menu.MainWindow := True;
2041 g_GUI_AddWindow(Menu);
2043 Menu := TGUIWindow.Create('NewGameMenu');
2044 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2045 begin
2046 Name := 'mmNewGameMenu';
2047 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2048 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2049 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2050 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2051 end;
2052 Menu.DefControl := 'mmNewGameMenu';
2053 g_GUI_AddWindow(Menu);
2055 Menu := TGUIWindow.Create('NetGameMenu');
2056 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2057 begin
2058 Name := 'mmNetGameMenu';
2059 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2060 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2061 end;
2062 Menu.DefControl := 'mmNetGameMenu';
2063 g_GUI_AddWindow(Menu);
2065 Menu := TGUIWindow.Create('NetServerMenu');
2066 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2067 begin
2068 Name := 'mNetServerMenu';
2069 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2070 begin
2071 Name := 'edSrvName';
2072 OnlyDigits := False;
2073 Width := 16;
2074 MaxLength := 64;
2075 Text := NetServerName;
2076 end;
2077 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2078 begin
2079 Name := 'edSrvPassword';
2080 OnlyDigits := False;
2081 Width := 16;
2082 MaxLength := 24;
2083 Text := NetPassword;
2084 end;
2085 with AddEdit(_lc[I_NET_PORT]) do
2086 begin
2087 Name := 'edPort';
2088 OnlyDigits := True;
2089 Width := 4;
2090 MaxLength := 5;
2091 Text := IntToStr(NetPort);
2092 end;
2093 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2094 begin
2095 Name := 'edMaxPlayers';
2096 OnlyDigits := True;
2097 Width := 4;
2098 MaxLength := 2;
2099 Text := IntToStr(NetMaxClients);
2100 end;
2101 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2102 begin
2103 Name := 'swUseMaster';
2104 AddItem(_lc[I_MENU_YES]);
2105 AddItem(_lc[I_MENU_NO]);
2106 if NetUseMaster then
2107 ItemIndex := 0
2108 else
2109 ItemIndex := 1;
2110 end;
2111 AddSpace();
2112 with AddLabel(_lc[I_MENU_MAP]) do
2113 begin
2114 Name := 'lbMap';
2115 FixedLength := 16;
2116 Text := gsMap;
2117 OnClick := @ProcSelectMapMenu;
2118 end;
2119 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2120 begin
2121 Name := 'swGameMode';
2122 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2123 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2124 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2125 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2126 case g_Game_TextToMode(gsGameMode) of
2127 GM_NONE,
2128 GM_DM: ItemIndex := 0;
2129 GM_TDM: ItemIndex := 1;
2130 GM_CTF: ItemIndex := 2;
2131 GM_SINGLE,
2132 GM_COOP: ItemIndex := 3;
2133 end;
2134 OnChange := ProcSwitchMonstersCustom;
2135 end;
2136 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2137 begin
2138 Name := 'edTimeLimit';
2139 OnlyDigits := True;
2140 Width := 4;
2141 MaxLength := 5;
2142 if gsTimeLimit > 0 then
2143 Text := IntToStr(gsTimeLimit);
2144 end;
2145 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2146 begin
2147 Name := 'edGoalLimit';
2148 OnlyDigits := True;
2149 Width := 4;
2150 MaxLength := 5;
2151 if gsGoalLimit > 0 then
2152 Text := IntToStr(gsGoalLimit);
2153 end;
2154 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2155 begin
2156 Name := 'edMaxLives';
2157 OnlyDigits := True;
2158 Width := 4;
2159 MaxLength := 5;
2160 if gsMaxLives > 0 then
2161 Text := IntToStr(gsMaxLives);
2162 end;
2163 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2164 begin
2165 Name := 'edItemRespawnTime';
2166 OnlyDigits := True;
2167 Width := 4;
2168 MaxLength := 5;
2169 if gsItemRespawnTime > 0 then
2170 Text := IntToStr(gsItemRespawnTime);
2171 end;
2172 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2173 begin
2174 Name := 'swPlayers';
2175 AddItem(_lc[I_MENU_COUNT_NONE]);
2176 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2177 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2178 ItemIndex := gsPlayers;
2179 end;
2180 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2181 begin
2182 Name := 'swTeamDamage';
2183 AddItem(_lc[I_MENU_YES]);
2184 AddItem(_lc[I_MENU_NO]);
2185 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2186 ItemIndex := 0
2187 else
2188 ItemIndex := 1;
2189 end;
2190 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2191 begin
2192 Name := 'swDeathmatchKeys';
2193 AddItem(_lc[I_MENU_YES]);
2194 AddItem(_lc[I_MENU_NO]);
2195 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2196 ItemIndex := 0
2197 else
2198 ItemIndex := 1;
2199 end;
2200 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2201 begin
2202 Name := 'swEnableExits';
2203 AddItem(_lc[I_MENU_YES]);
2204 AddItem(_lc[I_MENU_NO]);
2205 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2206 ItemIndex := 0
2207 else
2208 ItemIndex := 1;
2209 end;
2210 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2211 begin
2212 Name := 'swWeaponStay';
2213 AddItem(_lc[I_MENU_YES]);
2214 AddItem(_lc[I_MENU_NO]);
2215 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2216 ItemIndex := 0
2217 else
2218 ItemIndex := 1;
2219 end;
2220 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2221 begin
2222 Name := 'swMonsters';
2223 AddItem(_lc[I_MENU_YES]);
2224 AddItem(_lc[I_MENU_NO]);
2225 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2226 ItemIndex := 0
2227 else
2228 ItemIndex := 1;
2229 end;
2230 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2231 begin
2232 Name := 'swBotsVS';
2233 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2234 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2235 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2236 ItemIndex := 2;
2237 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2238 ItemIndex := 0;
2239 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2240 ItemIndex := 1;
2241 end;
2242 AddSpace();
2243 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2245 ReAlign();
2246 end;
2247 Menu.DefControl := 'mNetServerMenu';
2248 g_GUI_AddWindow(Menu);
2250 Menu := TGUIWindow.Create('NetClientMenu');
2251 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2252 begin
2253 Name := 'mNetClientMenu';
2255 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2256 AddSpace();
2258 with AddEdit(_lc[I_NET_ADDRESS]) do
2259 begin
2260 Name := 'edIP';
2261 OnlyDigits :=False;
2262 Width := 12;
2263 MaxLength := 64;
2264 Text := 'localhost';
2265 end;
2266 with AddEdit(_lc[I_NET_PORT]) do
2267 begin
2268 Name := 'edPort';
2269 OnlyDigits := True;
2270 Width := 4;
2271 MaxLength := 5;
2272 Text := '25666';
2273 end;
2274 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2275 begin
2276 Name := 'edPW';
2277 OnlyDigits := False;
2278 Width := 12;
2279 MaxLength := 32;
2280 Text := '';
2281 end;
2283 AddSpace();
2284 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2286 ReAlign();
2287 end;
2288 Menu.DefControl := 'mNetClientMenu';
2289 g_GUI_AddWindow(Menu);
2291 Menu := TGUIWindow.Create('LoadMenu');
2292 Menu.OnShow := ProcLoadMenu;
2293 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2294 begin
2295 Name := 'mmLoadMenu';
2297 for a := 1 to 8 do
2298 with AddEdit('') do
2299 begin
2300 Name := 'edSlot'+IntToStr(a);
2301 Width := 16;
2302 MaxLength := 16;
2303 OnEnter := ProcLoadGame;
2304 end;
2305 end;
2306 Menu.DefControl := 'mmLoadMenu';
2307 g_GUI_AddWindow(Menu);
2309 Menu := TGUIWindow.Create('SaveMenu');
2310 Menu.OnShow := ProcSaveMenu;
2311 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2312 begin
2313 Name := 'mmSaveMenu';
2315 for a := 1 to 8 do
2316 with AddEdit('') do
2317 begin
2318 Name := 'edSlot'+IntToStr(a);
2319 Width := 16;
2320 MaxLength := 16;
2321 OnChange := ProcSaveGame;
2322 end;
2323 end;
2324 Menu.DefControl := 'mmSaveMenu';
2325 g_GUI_AddWindow(Menu);
2327 Menu := TGUIWindow.Create('CustomGameMenu');
2328 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2329 begin
2330 Name := 'mCustomGameMenu';
2331 with AddLabel(_lc[I_MENU_MAP]) do
2332 begin
2333 Name := 'lbMap';
2334 FixedLength := 16;
2335 Text := gsMap;
2336 OnClick := @ProcSelectMapMenu;
2337 end;
2338 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2339 begin
2340 Name := 'swGameMode';
2341 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2342 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2343 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2344 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2345 case g_Game_TextToMode(gsGameMode) of
2346 GM_NONE,
2347 GM_DM: ItemIndex := 0;
2348 GM_TDM: ItemIndex := 1;
2349 GM_CTF: ItemIndex := 2;
2350 GM_SINGLE,
2351 GM_COOP: ItemIndex := 3;
2352 end;
2353 OnChange := ProcSwitchMonstersCustom;
2354 end;
2355 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2356 begin
2357 Name := 'edTimeLimit';
2358 OnlyDigits := True;
2359 Width := 4;
2360 MaxLength := 5;
2361 if gsTimeLimit > 0 then
2362 Text := IntToStr(gsTimeLimit);
2363 end;
2364 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2365 begin
2366 Name := 'edGoalLimit';
2367 OnlyDigits := True;
2368 Width := 4;
2369 MaxLength := 5;
2370 if gsGoalLimit > 0 then
2371 Text := IntToStr(gsGoalLimit);
2372 end;
2373 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2374 begin
2375 Name := 'edMaxLives';
2376 OnlyDigits := True;
2377 Width := 4;
2378 MaxLength := 5;
2379 if gsMaxLives > 0 then
2380 Text := IntToStr(gsMaxLives);
2381 end;
2382 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2383 begin
2384 Name := 'edItemRespawnTime';
2385 OnlyDigits := True;
2386 Width := 4;
2387 MaxLength := 5;
2388 if gsItemRespawnTime > 0 then
2389 Text := IntToStr(gsItemRespawnTime);
2390 end;
2391 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2392 begin
2393 Name := 'swPlayers';
2394 AddItem(_lc[I_MENU_COUNT_NONE]);
2395 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2396 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2397 ItemIndex := gsPlayers;
2398 end;
2399 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2400 begin
2401 Name := 'swTeamDamage';
2402 AddItem(_lc[I_MENU_YES]);
2403 AddItem(_lc[I_MENU_NO]);
2404 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2405 ItemIndex := 0
2406 else
2407 ItemIndex := 1;
2408 end;
2409 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2410 begin
2411 Name := 'swDeathmatchKeys';
2412 AddItem(_lc[I_MENU_YES]);
2413 AddItem(_lc[I_MENU_NO]);
2414 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2415 ItemIndex := 0
2416 else
2417 ItemIndex := 1;
2418 end;
2419 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2420 begin
2421 Name := 'swEnableExits';
2422 AddItem(_lc[I_MENU_YES]);
2423 AddItem(_lc[I_MENU_NO]);
2424 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2425 ItemIndex := 0
2426 else
2427 ItemIndex := 1;
2428 end;
2429 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2430 begin
2431 Name := 'swWeaponStay';
2432 AddItem(_lc[I_MENU_YES]);
2433 AddItem(_lc[I_MENU_NO]);
2434 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2435 ItemIndex := 0
2436 else
2437 ItemIndex := 1;
2438 end;
2439 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2440 begin
2441 Name := 'swMonsters';
2442 AddItem(_lc[I_MENU_YES]);
2443 AddItem(_lc[I_MENU_NO]);
2444 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2445 ItemIndex := 0
2446 else
2447 ItemIndex := 1;
2448 end;
2449 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2450 begin
2451 Name := 'swBotsVS';
2452 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2453 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2454 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2455 ItemIndex := 2;
2456 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2457 ItemIndex := 0;
2458 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2459 ItemIndex := 1;
2460 end;
2461 AddSpace();
2462 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2464 ReAlign();
2465 end;
2466 Menu.DefControl := 'mCustomGameMenu';
2467 g_GUI_AddWindow(Menu);
2469 Menu := TGUIWindow.Create('CampaignMenu');
2470 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2471 begin
2472 Name := 'mCampaignMenu';
2474 AddSpace();
2475 AddSpace();
2476 AddSpace();
2477 AddSpace();
2478 AddSpace();
2479 AddSpace();
2481 with AddFileList('', 15, 4) do
2482 begin
2483 Name := 'lsWAD';
2484 OnChange := ProcSelectCampaignWAD;
2486 Sort := True;
2487 Dirs := True;
2488 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2489 SetBase(MegawadDirs);
2490 end;
2492 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2493 begin
2494 Name := 'lbWADName';
2495 FixedLength := 8;
2496 Enabled := False;
2497 end;
2498 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2499 begin
2500 Name := 'lbWADAuthor';
2501 FixedLength := 8;
2502 Enabled := False;
2503 end;
2504 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2505 with AddMemo('', 15, 3) do
2506 begin
2507 Name := 'meWADDescription';
2508 Color := MENU_ITEMSCTRL_COLOR;
2509 end;
2510 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2511 begin
2512 Name := 'swPlayers';
2513 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2514 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2515 end;
2516 AddSpace();
2517 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2519 ReAlign();
2521 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2522 begin
2523 Name := 'mpWADImage';
2524 DefaultRes := 'NOPIC';
2525 X := GetControl('lsWAD').X+4;
2526 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2527 end;
2528 end;
2529 Menu.DefControl := 'mCampaignMenu';
2530 g_GUI_AddWindow(Menu);
2532 Menu := TGUIWindow.Create('SelectMapMenu');
2533 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2534 begin
2535 Name := 'mSelectMapMenu';
2536 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2537 begin
2538 Name := 'lsMapWAD';
2539 OnChange := ProcSelectWAD;
2541 Sort := True;
2542 Dirs := True;
2543 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2544 SetBase(MapDirs);
2545 end;
2546 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2547 begin
2548 Name := 'lsMapRes';
2549 Sort := True;
2550 OnChange := ProcSelectMap;
2551 end;
2552 AddSpace();
2553 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2554 begin
2555 Name := 'lbMapName';
2556 FixedLength := 24;
2557 Enabled := False;
2558 end;
2559 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2560 begin
2561 Name := 'lbMapAuthor';
2562 FixedLength := 16;
2563 Enabled := False;
2564 end;
2565 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2566 begin
2567 Name := 'lbMapSize';
2568 FixedLength := 10;
2569 Enabled := False;
2570 end;
2571 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2572 begin
2573 Name := 'meMapDescription';
2574 end;
2576 ReAlign();
2578 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2579 begin
2580 Name := 'mpMapPreview';
2581 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2582 Y := GetControl('lsMapWAD').Y;
2583 end;
2584 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2585 begin
2586 Name := 'lbMapScale';
2587 FixedLength := 8;
2588 Enabled := False;
2589 Color := MENU_ITEMSCTRL_COLOR;
2590 X := GetControl('lsMapWAD').X +
2591 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2592 2 + MAPPREVIEW_WIDTH*4;
2593 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2594 end;
2595 end;
2596 Menu.OnClose := ProcSetMap;
2597 Menu.DefControl := 'mSelectMapMenu';
2598 g_GUI_AddWindow(Menu);
2600 Menu := TGUIWindow.Create('OptionsMenu');
2601 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2602 begin
2603 Name := 'mmOptionsMenu';
2604 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2605 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2606 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2607 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2608 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2609 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2610 AddSpace();
2611 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2612 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2613 end;
2614 Menu.OnClose := ProcApplyOptions;
2615 Menu.DefControl := 'mmOptionsMenu';
2616 g_GUI_AddWindow(Menu);
2618 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2619 gMenuSmallFont, @ProcSavedMenuKeyDown);
2620 g_GUI_AddWindow(Menu);
2622 Menu := TGUIWindow.Create('OptionsVideoMenu');
2623 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2624 begin
2625 Name := 'mOptionsVideoMenu';
2626 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2627 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2628 begin
2629 Name := 'swBPP';
2630 AddItem('16');
2631 AddItem('32');
2632 end;
2633 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2634 begin
2635 Name := 'swVSync';
2636 AddItem(_lc[I_MENU_YES]);
2637 AddItem(_lc[I_MENU_NO]);
2638 end;
2639 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2640 begin
2641 Name := 'swTextureFilter';
2642 AddItem(_lc[I_MENU_YES]);
2643 AddItem(_lc[I_MENU_NO]);
2644 end;
2645 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2646 begin
2647 Name := 'swLegacyNPOT';
2648 AddItem(_lc[I_MENU_NO]);
2649 AddItem(_lc[I_MENU_YES]);
2650 end;
2651 AddSpace();
2652 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2653 ReAlign();
2654 end;
2655 Menu.DefControl := 'mOptionsVideoMenu';
2656 g_GUI_AddWindow(Menu);
2658 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2659 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2660 begin
2661 Name := 'mOptionsVideoResMenu';
2662 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2663 begin
2664 Name := 'lbCurrentRes';
2665 FixedLength := 24;
2666 Enabled := False;
2667 end;
2668 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2669 begin
2670 Name := 'lsResolution';
2671 Sort := False;
2672 end;
2673 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2674 begin
2675 Name := 'swFullScreen';
2676 AddItem(_lc[I_MENU_YES]);
2677 AddItem(_lc[I_MENU_NO]);
2678 end;
2679 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2680 begin
2681 Name := 'scResFactor';
2682 Max := 10;
2683 end;
2684 AddSpace();
2685 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2686 UpdateIndex();
2687 end;
2688 Menu.DefControl := 'mOptionsVideoResMenu';
2689 g_GUI_AddWindow(Menu);
2691 Menu := TGUIWindow.Create('OptionsSoundMenu');
2692 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2693 begin
2694 Name := 'mOptionsSoundMenu';
2695 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2696 begin
2697 Name := 'scMusicLevel';
2698 Max := 16;
2699 OnChange := ProcChangeSoundSettings;
2700 end;
2701 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2702 begin
2703 Name := 'scSoundLevel';
2704 Max := 16;
2705 OnChange := ProcChangeSoundSettings;
2706 end;
2707 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2708 begin
2709 Name := 'scMaxSimSounds';
2710 Max := 16;
2711 end;
2712 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2713 begin;
2714 Name := 'swAnnouncer';
2715 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2716 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2717 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2718 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2719 end;
2720 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2721 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2722 begin;
2723 Name := 'swSoundEffects';
2724 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2725 AddItem(_lc[I_MENU_COMPAT_DF]);
2726 end;
2727 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2728 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2729 begin;
2730 Name := 'swChatSpeech';
2731 AddItem(_lc[I_MENU_YES]);
2732 AddItem(_lc[I_MENU_NO]);
2733 end;
2734 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2735 begin
2736 Name := 'swInactiveSounds';
2737 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2738 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2739 end;
2740 ReAlign();
2741 end;
2742 Menu.DefControl := 'mOptionsSoundMenu';
2743 g_GUI_AddWindow(Menu);
2745 Menu := TGUIWindow.Create('OptionsGameMenu');
2746 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2747 begin
2748 Name := 'mOptionsGameMenu';
2749 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2750 begin
2751 Name := 'scParticlesCount';
2752 Max := 20;
2753 end;
2754 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2755 begin
2756 Name := 'swBloodCount';
2757 AddItem(_lc[I_MENU_COUNT_NONE]);
2758 AddItem(_lc[I_MENU_COUNT_SMALL]);
2759 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2760 AddItem(_lc[I_MENU_COUNT_BIG]);
2761 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2762 end;
2763 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2764 begin
2765 Name := 'scShellsMax';
2766 Max := 20;
2767 end;
2768 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2769 begin
2770 Name := 'scGibsMax';
2771 Max := 20;
2772 end;
2773 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2774 begin
2775 Name := 'scCorpsesMax';
2776 Max := 20;
2777 end;
2778 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2779 begin
2780 Name := 'swGibsCount';
2781 AddItem(_lc[I_MENU_COUNT_NONE]);
2782 AddItem(_lc[I_MENU_COUNT_SMALL]);
2783 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2784 AddItem(_lc[I_MENU_COUNT_BIG]);
2785 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2786 end;
2787 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2788 begin
2789 Name := 'swCorpseType';
2790 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2791 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2792 end;
2793 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2794 begin
2795 Name := 'swGibsType';
2796 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2797 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2798 end;
2799 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2800 begin
2801 Name := 'swBloodType';
2802 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2803 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2804 end;
2805 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2806 begin
2807 Name := 'swScreenFlash';
2808 AddItem(_lc[I_MENU_NO]);
2809 AddItem(_lc[I_MENU_COMPAT_DF]);
2810 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2811 end;
2812 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2813 begin
2814 Name := 'swBackground';
2815 AddItem(_lc[I_MENU_YES]);
2816 AddItem(_lc[I_MENU_NO]);
2817 end;
2818 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2819 begin
2820 Name := 'swMessages';
2821 AddItem(_lc[I_MENU_YES]);
2822 AddItem(_lc[I_MENU_NO]);
2823 end;
2824 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2825 begin
2826 Name := 'swRevertPlayers';
2827 AddItem(_lc[I_MENU_YES]);
2828 AddItem(_lc[I_MENU_NO]);
2829 end;
2830 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2831 begin
2832 Name := 'swChatBubble';
2833 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2834 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2835 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2836 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2837 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2838 end;
2839 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2840 begin
2841 Name := 'swPlayerIndicator';
2842 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2843 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2844 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2845 end;
2846 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2847 begin
2848 Name := 'swPlayerIndicatorStyle';
2849 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2850 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2851 end;
2852 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2853 begin
2854 Name := 'scScaleFactor';
2855 Max := 10;
2856 OnChange := ProcChangeGameSettings;
2857 end;
2858 ReAlign();
2859 end;
2860 Menu.DefControl := 'mOptionsGameMenu';
2861 g_GUI_AddWindow(Menu);
2863 Menu := TGUIWindow.Create('OptionsControlsMenu');
2864 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2865 begin
2866 Name := 'mOptionsControlsMenu';
2867 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2868 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2869 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2870 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2871 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2872 AddSpace();
2873 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2874 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2875 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2876 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2877 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2878 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2879 if e_HasJoysticks then
2880 begin
2881 AddSpace();
2882 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2883 end;
2884 if g_touch_enabled then
2885 begin
2886 AddSpace();
2887 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2888 end;
2889 end;
2890 Menu.DefControl := 'mOptionsControlsMenu';
2891 g_GUI_AddWindow(Menu);
2893 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2894 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2895 begin
2896 Name := 'mOptionsControlsP1Menu';
2897 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2898 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2899 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2900 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2901 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2902 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2903 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2904 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2905 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2906 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2907 end;
2908 Menu.DefControl := 'mOptionsControlsP1Menu';
2909 g_GUI_AddWindow(Menu);
2911 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2912 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2913 begin
2914 Name := 'mOptionsControlsP1MenuWeapons';
2915 for i := WP_FIRST to WP_LAST do
2916 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2917 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2918 end;
2919 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2920 g_GUI_AddWindow(Menu);
2922 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2923 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2924 begin
2925 Name := 'mOptionsControlsP2Menu';
2926 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2927 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2928 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2929 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2930 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2931 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2932 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2933 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2934 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2935 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2936 end;
2937 Menu.DefControl := 'mOptionsControlsP2Menu';
2938 g_GUI_AddWindow(Menu);
2940 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2941 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2942 begin
2943 Name := 'mOptionsControlsP2MenuWeapons';
2944 for i := WP_FIRST to WP_LAST do
2945 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2946 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2947 end;
2948 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2949 g_GUI_AddWindow(Menu);
2951 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2952 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2953 begin
2954 Name := 'mOptionsControlsJoystickMenu';
2955 for i := 0 to e_MaxJoys - 1 do
2956 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2957 begin
2958 Name := 'scDeadzone' + IntToStr(i);
2959 Max := 20
2960 end
2961 end;
2962 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2963 g_GUI_AddWindow(Menu);
2965 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2966 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2967 begin
2968 Name := 'mOptionsControlsTouchMenu';
2969 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2970 begin
2971 Name := 'swTouchAlt';
2972 AddItem(_lc[I_MENU_NO]);
2973 AddItem(_lc[I_MENU_YES]);
2974 OnChange := ProcChangeTouchSettings;
2975 end;
2976 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2977 begin
2978 Name := 'scTouchSize';
2979 Max := 20;
2980 OnChange := ProcChangeTouchSettings;
2981 end;
2982 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2983 begin
2984 Name := 'swTouchFire';
2985 AddItem(_lc[I_MENU_NO]);
2986 AddItem(_lc[I_MENU_YES]);
2987 end;
2988 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2989 begin
2990 Name := 'scTouchOffset';
2991 Max := 20;
2992 OnChange := ProcChangeTouchSettings;
2993 end;
2994 end;
2995 Menu.DefControl := 'mOptionsControlsTouchMenu';
2996 g_GUI_AddWindow(Menu);
2998 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2999 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3000 begin
3001 Name := 'mOptionsPlayersMenu';
3002 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3003 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3004 end;
3005 Menu.DefControl := 'mOptionsPlayersMenu';
3006 g_GUI_AddWindow(Menu);
3008 CreatePlayerOptionsMenu('P1');
3009 CreatePlayerOptionsMenu('P2');
3011 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3012 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3013 begin
3014 Name := 'mOptionsPlayersMIMenu';
3015 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3016 begin
3017 Name := 'lbName';
3018 FixedLength := 16;
3019 end;
3020 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3021 begin
3022 Name := 'lbAuthor';
3023 FixedLength := 16;
3024 end;
3025 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3026 begin
3027 Name := 'meComment';
3028 end;
3029 AddSpace();
3030 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3031 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3032 begin
3033 Name := 'lbWeapon';
3034 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3035 end;
3036 ReAlign();
3037 end;
3038 Menu.DefControl := 'mOptionsPlayersMIMenu';
3039 g_GUI_AddWindow(Menu);
3041 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3042 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3043 begin
3044 Name := 'mOptionsLanguageMenu';
3045 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3046 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3047 ReAlign();
3048 end;
3049 Menu.DefControl := 'mOptionsLanguageMenu';
3050 g_GUI_AddWindow(Menu);
3052 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3053 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3054 g_GUI_AddWindow(Menu);
3056 Menu := TGUIWindow.Create('AuthorsMenu');
3057 Menu.BackTexture := 'INTER';
3058 Menu.OnClose := ProcAuthorsClose;
3060 // Çàãîëîâîê:
3061 _y := 16;
3062 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3063 begin
3064 Color := _RGB(255, 0, 0);
3065 X := (gScreenWidth div 2)-(GetWidth() div 2);
3066 Y := _y;
3067 _y := _y+GetHeight();
3068 end;
3069 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3070 begin
3071 Color := _RGB(255, 0, 0);
3072 X := (gScreenWidth div 2)-(GetWidth() div 2);
3073 Y := _y;
3074 _y := _y+GetHeight()+32;
3075 end;
3076 // ×òî äåëàë: Êòî äåëàë
3077 cx := gScreenWidth div 2 - 320 + 64;
3078 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3079 begin
3080 Color := _RGB(255, 0, 0);
3081 X := cx;
3082 Y := _y;
3083 _y := _y+22;
3084 end;
3085 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3086 begin
3087 Color := _RGB(255, 255, 255);
3088 X := cx+32;
3089 Y := _y;
3090 _y := _y+36;
3091 end;
3092 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3093 begin
3094 Color := _RGB(255, 0, 0);
3095 X := cx;
3096 Y := _y;
3097 _y := _y+22;
3098 end;
3099 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3100 begin
3101 Color := _RGB(255, 255, 255);
3102 X := cx+32;
3103 Y := _y;
3104 _y := _y+22;
3105 end;
3106 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3107 begin
3108 Color := _RGB(255, 255, 255);
3109 X := cx+32;
3110 Y := _y;
3111 _y := _y+36;
3112 end;
3113 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3114 begin
3115 Color := _RGB(255, 0, 0);
3116 X := cx;
3117 Y := _y;
3118 _y := _y+22;
3119 end;
3120 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3121 begin
3122 Color := _RGB(255, 255, 255);
3123 X := cx+32;
3124 Y := _y;
3125 _y := _y+36;
3126 end;
3127 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3128 begin
3129 Color := _RGB(255, 0, 0);
3130 X := cx;
3131 Y := _y;
3132 _y := _y+22;
3133 end;
3134 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3135 begin
3136 Color := _RGB(255, 255, 255);
3137 X := cx+32;
3138 Y := _y;
3139 _y := gScreenHeight - 128;
3140 end;
3141 // Çàêëþ÷åíèå:
3142 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3143 begin
3144 Color := _RGB(255, 0, 0);
3145 X := cx;
3146 Y := _y;
3147 _y := _y+16;
3148 end;
3149 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3150 begin
3151 Color := _RGB(255, 255, 255);
3152 X := cx+32;
3153 Y := _y;
3154 _y := _y+GetHeight();
3155 end;
3156 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3157 begin
3158 Color := _RGB(255, 255, 255);
3159 X := cx+32;
3160 Y := _y;
3161 _y := _y+GetHeight();
3162 end;
3163 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3164 begin
3165 Color := _RGB(255, 255, 255);
3166 X := cx+32;
3167 Y := _y;
3168 _y := gScreenHeight - 32;
3169 end;
3170 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3171 begin
3172 Color := _RGB(255, 0, 0);
3173 X := gScreenWidth div 2 - GetWidth() div 2;
3174 Y := _y;
3175 end;
3176 g_GUI_AddWindow(Menu);
3178 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3179 gMenuSmallFont, @ProcExitMenuKeyDown);
3180 g_GUI_AddWindow(Menu);
3182 Menu := TGUIWindow.Create('GameSingleMenu');
3183 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3184 begin
3185 Name := 'mmGameSingleMenu';
3186 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3187 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3188 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3189 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3190 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3191 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3192 end;
3193 Menu.DefControl := 'mmGameSingleMenu';
3194 Menu.MainWindow := True;
3195 Menu.OnClose := ProcGMClose;
3196 Menu.OnShow := ProcGMShow;
3197 g_GUI_AddWindow(Menu);
3199 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3200 gMenuSmallFont, @ProcEndMenuKeyDown);
3201 g_GUI_AddWindow(Menu);
3203 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3204 gMenuSmallFont, @ProcRestartMenuKeyDown);
3205 g_GUI_AddWindow(Menu);
3207 Menu := TGUIWindow.Create('GameCustomMenu');
3208 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3209 begin
3210 Name := 'mmGameCustomMenu';
3211 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3212 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3213 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3214 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3215 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3216 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3217 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3218 end;
3219 Menu.DefControl := 'mmGameCustomMenu';
3220 Menu.MainWindow := True;
3221 Menu.OnClose := ProcGMClose;
3222 Menu.OnShow := ProcGMShow;
3223 g_GUI_AddWindow(Menu);
3225 Menu := TGUIWindow.Create('GameServerMenu');
3226 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3227 begin
3228 Name := 'mmGameServerMenu';
3229 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3230 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3231 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3232 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3233 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3234 end;
3235 Menu.DefControl := 'mmGameServerMenu';
3236 Menu.MainWindow := True;
3237 Menu.OnClose := ProcGMClose;
3238 Menu.OnShow := ProcGMShow;
3239 g_GUI_AddWindow(Menu);
3241 Menu := TGUIWindow.Create('GameClientMenu');
3242 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3243 begin
3244 Name := 'mmGameClientMenu';
3245 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3246 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3247 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3248 end;
3249 Menu.DefControl := 'mmGameClientMenu';
3250 Menu.MainWindow := True;
3251 Menu.OnClose := ProcGMClose;
3252 Menu.OnShow := ProcGMShow;
3253 g_GUI_AddWindow(Menu);
3255 Menu := TGUIWindow.Create('ClientPasswordMenu');
3256 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3257 begin
3258 Name := 'mClientPasswordMenu';
3259 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3260 begin
3261 Name := 'edPW';
3262 Width := 12;
3263 MaxLength := 32;
3264 end;
3265 AddSpace;
3267 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3268 ReAlign();
3269 end;
3270 Menu.DefControl := 'mClientPasswordMenu';
3271 g_GUI_AddWindow(Menu);
3273 Menu := TGUIWindow.Create('GameSetGameMenu');
3274 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3275 begin
3276 Name := 'mGameSetGameMenu';
3277 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3278 begin
3279 Name := 'swTeamDamage';
3280 AddItem(_lc[I_MENU_YES]);
3281 AddItem(_lc[I_MENU_NO]);
3282 ItemIndex := 1;
3283 end;
3284 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3285 begin
3286 Name := 'swDeathmatchKeys';
3287 AddItem(_lc[I_MENU_YES]);
3288 AddItem(_lc[I_MENU_NO]);
3289 ItemIndex := 1;
3290 end;
3291 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3292 begin
3293 Name := 'edTimeLimit';
3294 OnlyDigits := True;
3295 Width := 4;
3296 MaxLength := 5;
3297 end;
3298 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3299 begin
3300 Name := 'edGoalLimit';
3301 OnlyDigits := True;
3302 Width := 4;
3303 MaxLength := 5;
3304 end;
3305 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3306 begin
3307 Name := 'edMaxLives';
3308 OnlyDigits := True;
3309 Width := 4;
3310 MaxLength := 5;
3311 end;
3312 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3313 begin
3314 Name := 'swBotsVS';
3315 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3316 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3317 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3318 ItemIndex := 2;
3319 end;
3321 ReAlign();
3322 end;
3323 Menu.DefControl := 'mGameSetGameMenu';
3324 Menu.OnClose := ProcApplyGameSet;
3325 g_GUI_AddWindow(Menu);
3327 Menu := TGUIWindow.Create('TeamMenu');
3328 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3329 begin
3330 Name := 'mmTeamMenu';
3331 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3332 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3333 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3334 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3335 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3336 end;
3337 Menu.DefControl := 'mmTeamMenu';
3338 Menu.OnShow := ProcChangePlayers;
3339 g_GUI_AddWindow(Menu);
3340 end;
3342 procedure g_Menu_Show_SaveMenu();
3343 begin
3344 if g_Game_IsTestMap then
3345 Exit;
3346 if gGameSettings.GameType = GT_SINGLE then
3347 g_GUI_ShowWindow('GameSingleMenu')
3348 else
3349 begin
3350 if g_Game_IsClient then
3351 Exit
3352 else
3353 if g_Game_IsNet then
3354 Exit
3355 else
3356 g_GUI_ShowWindow('GameCustomMenu');
3357 end;
3358 g_GUI_ShowWindow('SaveMenu');
3359 g_Sound_PlayEx('MENU_OPEN');
3360 end;
3362 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3363 begin
3364 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3365 if gGameSettings.GameType = GT_SINGLE then
3366 begin
3367 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3368 end
3369 else
3370 begin
3371 if g_Game_IsClient then exit;
3372 if g_Game_IsNet then exit;
3373 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3374 end;
3375 g_GUI_ShowWindow('LoadMenu');
3376 g_Sound_PlayEx('MENU_OPEN');
3377 end;
3379 procedure g_Menu_Show_GameSetGame();
3380 begin
3381 if gGameSettings.GameType = GT_SINGLE then
3382 g_GUI_ShowWindow('GameSingleMenu')
3383 else
3384 begin
3385 if g_Game_IsClient then
3386 Exit
3387 else
3388 if g_Game_IsNet then
3389 g_GUI_ShowWindow('GameServerMenu')
3390 else
3391 g_GUI_ShowWindow('GameCustomMenu');
3392 end;
3393 ReadGameSettings();
3394 g_GUI_ShowWindow('GameSetGameMenu');
3395 g_Sound_PlayEx('MENU_OPEN');
3396 end;
3398 procedure g_Menu_Show_OptionsVideo();
3399 begin
3400 if gGameSettings.GameType = GT_SINGLE then
3401 g_GUI_ShowWindow('GameSingleMenu')
3402 else
3403 begin
3404 if g_Game_IsClient then
3405 g_GUI_ShowWindow('GameClientMenu')
3406 else
3407 if g_Game_IsNet then
3408 g_GUI_ShowWindow('GameServerMenu')
3409 else
3410 g_GUI_ShowWindow('GameCustomMenu');
3411 end;
3412 ReadOptions();
3413 g_GUI_ShowWindow('OptionsMenu');
3414 g_GUI_ShowWindow('OptionsVideoMenu');
3415 g_Sound_PlayEx('MENU_OPEN');
3416 end;
3418 procedure g_Menu_Show_OptionsSound();
3419 begin
3420 if gGameSettings.GameType = GT_SINGLE then
3421 g_GUI_ShowWindow('GameSingleMenu')
3422 else
3423 begin
3424 if g_Game_IsClient then
3425 g_GUI_ShowWindow('GameClientMenu')
3426 else
3427 if g_Game_IsNet then
3428 g_GUI_ShowWindow('GameServerMenu')
3429 else
3430 g_GUI_ShowWindow('GameCustomMenu');
3431 end;
3432 ReadOptions();
3433 g_GUI_ShowWindow('OptionsMenu');
3434 g_GUI_ShowWindow('OptionsSoundMenu');
3435 g_Sound_PlayEx('MENU_OPEN');
3436 end;
3438 procedure g_Menu_Show_EndGameMenu();
3439 begin
3440 g_GUI_ShowWindow('EndGameMenu');
3441 g_Sound_PlayEx('MENU_OPEN');
3442 end;
3444 procedure g_Menu_Show_QuitGameMenu();
3445 begin
3446 g_GUI_ShowWindow('ExitMenu');
3447 g_Sound_PlayEx('MENU_OPEN');
3448 end;
3450 procedure g_Menu_Init();
3451 begin
3452 MenuLoadData();
3453 g_GUI_Init();
3454 CreateAllMenus();
3455 end;
3457 procedure g_Menu_Free();
3458 begin
3459 g_GUI_Destroy();
3461 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3463 MenuFreeData();
3464 end;
3466 procedure g_Menu_Reset();
3467 var
3468 ex: Boolean;
3469 begin
3470 g_GUI_SaveMenuPos();
3471 ex := g_GUI_Destroy();
3473 if ex then
3474 begin
3475 e_WriteLog('Recreating menu...', TMsgType.Notify);
3477 CreateAllMenus();
3479 if gDebugMode then
3480 g_Game_SetDebugMode();
3482 g_GUI_LoadMenuPos();
3483 end;
3484 end;
3486 end.