DEADSOFTWARE

add 'respawn items' flag
[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;
42 implementation
44 uses
45 {$INCLUDE ../nogl/noGLuses.inc}
46 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
47 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
48 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
49 MAPDEF, Math, g_saveload,
50 e_texture, g_language, e_res,
51 g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
52 utils, wadreader, g_system;
55 type TYNCallback = procedure (yes:Boolean);
57 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
58 begin
59 if win.UserData = nil then exit;
60 case Key of
61 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
62 IK_N: TYNCallback(win.UserData)(false);
63 end;
64 end;
66 procedure YesButtonCB (ctl: TGUITextButton);
67 begin
68 if ctl.UserData = nil then exit;
69 TYNCallback(ctl.UserData)(true);
70 end;
72 procedure NoButtonCB (ctl: TGUITextButton);
73 begin
74 if ctl.UserData = nil then exit;
75 TYNCallback(ctl.UserData)(false);
76 end;
78 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
79 var
80 menu: TGUIMenu;
81 begin
82 //if length(Text) = 0 then exit;
83 Result := TGUIWindow.Create(WinName);
84 with Result do
85 begin
86 //OnKeyDownEx := @YNKeyDownProc;
87 //UserData := @ActionProc;
88 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
89 with menu do
90 begin
91 Name := '__temp_yes_no_menu:'+WinName;
92 YesNo := true;
93 AddText(Text, MaxLen);
94 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
95 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
96 end;
97 DefControl := '__temp_yes_no_menu:'+WinName;
98 SetActive(nil);
99 end;
100 end;
103 procedure ProcChangeColor(Sender: TGUIControl); forward;
104 procedure ProcSelectModel(Sender: TGUIControl); forward;
106 procedure ProcApplyOptions();
107 var
108 menu: TGUIMenu;
109 i: Integer;
110 ovs: Boolean;
111 s: AnsiString;
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 s := e_GetWriteableDir(ConfigDirs);
379 if s <> '' then
380 g_Options_Write(s + '/' + CONFIG_FILENAME);
381 g_Console_WriteGameConfig;
382 end;
384 procedure ReadOptions();
385 var
386 menu: TGUIMenu;
387 i: Integer;
388 begin
389 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
391 with TGUISwitch(menu.GetControl('swBPP')) do
392 if gBPP = 16 then
393 ItemIndex := 0
394 else
395 ItemIndex := 1;
397 with TGUISwitch(menu.GetControl('swTextureFilter')) do
398 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
400 with TGUISwitch(menu.GetControl('swVSync')) do
401 if gVSync then ItemIndex := 0 else ItemIndex := 1;
403 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
404 if not glNPOTOverride then ItemIndex := 0 else ItemIndex := 1;
406 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
408 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
409 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
410 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
412 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
413 if gMuteWhenInactive then
414 ItemIndex := 1
415 else
416 ItemIndex := 0;
418 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
420 with TGUISwitch(menu.GetControl('swSoundEffects')) do
421 if gSoundEffectsDF then
422 ItemIndex := 1
423 else
424 ItemIndex := 0;
426 with TGUISwitch(menu.GetControl('swChatSpeech')) do
427 if gUseChatSounds then
428 ItemIndex := 0
429 else
430 ItemIndex := 1;
432 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
433 with menu do
434 begin
435 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p1_moveright', '-p1_moveright');
436 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft');
437 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p1_lookup', '-p1_lookup');
438 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown');
439 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack', '-p1_attack');
440 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump', '-p1_jump');
441 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext');
442 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev');
443 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate', '-p1_activate');
444 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe', '-p1_strafe');
445 // second set
446 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright', '-p1_moveright');
447 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft');
448 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p1_lookup', '-p1_lookup');
449 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown');
450 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack', '-p1_attack');
451 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump', '-p1_jump');
452 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext');
453 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev');
454 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate', '-p1_activate');
455 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe', '-p1_strafe');
456 end;
458 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
459 with menu do
460 begin
461 for i := WP_FIRST to WP_LAST do
462 begin
463 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1));
464 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1));
465 end;
466 end;
468 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
469 with menu do
470 begin
471 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright', '-p2_moveright');
472 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft');
473 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup', '-p2_lookup');
474 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown');
475 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack', '-p2_attack');
476 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump', '-p2_jump');
477 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext');
478 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev');
479 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate', '-p2_activate');
480 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe', '-p2_strafe');
481 // second set
482 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright', '-p2_moveright');
483 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft');
484 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup', '-p2_lookup');
485 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown');
486 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack', '-p2_attack');
487 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump', '-p2_jump');
488 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext');
489 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev');
490 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate', '-p2_activate');
491 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe', '-p2_strafe');
492 end;
494 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
495 with menu do
496 begin
497 for i := WP_FIRST to WP_LAST do
498 begin
499 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
500 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
501 end;
502 end;
504 if e_HasJoysticks then
505 begin
506 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
507 with menu do
508 begin
509 for i := 0 to e_MaxJoys - 1 do
510 if e_JoystickAvailable[i] then
511 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20)
512 end
513 end;
515 if g_touch_enabled then
516 begin
517 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
518 with TGUISwitch(menu.GetControl('swTouchAlt')) do
519 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
520 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
521 with TGUISwitch(menu.GetControl('swTouchFire')) do
522 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
523 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
524 end;
526 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
527 with menu do
528 begin
529 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
530 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+p1_scores', '-p1_scores');
531 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
532 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
533 end;
535 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
537 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
538 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
539 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
540 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
541 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
543 with TGUISwitch(menu.GetControl('swScreenFlash')) do
544 ItemIndex := gFlash;
546 with TGUISwitch(menu.GetControl('swBloodType')) do
547 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
549 with TGUISwitch(menu.GetControl('swCorpseType')) do
550 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
552 with TGUISwitch(menu.GetControl('swGibsType')) do
553 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
555 with TGUISwitch(menu.GetControl('swGibsCount')) do
556 case gGibsCount of
557 0: ItemIndex := 0;
558 8: ItemIndex := 1;
559 16: ItemIndex := 2;
560 32: ItemIndex := 3;
561 else ItemIndex := 4;
562 end;
564 with TGUISwitch(menu.GetControl('swBackGround')) do
565 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
567 with TGUISwitch(menu.GetControl('swMessages')) do
568 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
570 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
571 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
573 with TGUISwitch(menu.GetControl('swChatBubble')) do
574 ItemIndex := gChatBubble;
576 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
577 ItemIndex := gPlayerIndicator;
579 with TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')) do
580 ItemIndex := gPlayerIndicatorStyle;
582 TempScale := Round(g_dbg_scale - 1);
583 TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
585 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
587 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
588 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
590 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
591 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
593 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
594 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
595 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
597 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
599 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
600 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
602 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
603 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
605 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
606 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
607 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
609 ProcSelectModel(nil);
610 end;
612 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
613 begin
614 // don't turn off monsters in DM
616 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
617 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
618 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
619 else
620 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
623 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
624 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
625 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
626 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
628 end;
630 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
631 begin
632 // don't turn off monsters in DM
634 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
635 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
636 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
637 else
638 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
641 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
642 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
643 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
644 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
646 end;
648 procedure ProcStartCustomGame();
649 var
650 Map: String;
651 GameMode: Byte;
652 Options: LongWord;
653 s: AnsiString;
654 begin
655 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
656 begin
657 Map := TGUILabel(GetControl('lbMap')).Text;
658 if Map = '' then
659 Exit;
660 if not isWadPath(Map) then
661 Exit;
663 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
664 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
665 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
666 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
667 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
669 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
670 gcRespawnItems := TGUISwitch(GetControl('swRespawnItems')).ItemIndex = 0;
671 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
672 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
673 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
674 Options := 0;
675 if gcTeamDamage then
676 Options := Options or GAME_OPTION_TEAMDAMAGE;
677 if gcRespawnItems then
678 Options := Options or GAME_OPTION_RESPAWNITEMS;
679 if gcAllowExit then
680 Options := Options or GAME_OPTION_ALLOWEXIT;
681 if gcWeaponStay then
682 Options := Options or GAME_OPTION_WEAPONSTAY;
683 if gcMonsters then
684 Options := Options or GAME_OPTION_MONSTERS;
685 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
687 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
688 1: begin
689 Options := Options or GAME_OPTION_BOTVSMONSTER;
690 gcBotsVS := 'Monsters';
691 end;
692 2: begin
693 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
694 gcBotsVS := 'Everybody';
695 end;
696 else begin
697 Options := Options or GAME_OPTION_BOTVSPLAYER;
698 gcBotsVS := 'Players';
699 end;
700 end;
702 gcMap := Map;
703 end;
705 s := e_GetWriteableDir(ConfigDirs);
706 if s <> '' then
707 g_Options_Write_Gameplay_Custom(s + '/' + CONFIG_FILENAME);
709 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
710 gcMaxLives, Options, gcPlayers);
711 end;
714 procedure ProcStartNetGame();
715 var
716 Map: String;
717 GameMode: Byte;
718 Options: LongWord;
719 s: AnsiString;
720 begin
721 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
722 begin
723 Map := TGUILabel(GetControl('lbMap')).Text;
724 if Map = '' then
725 Exit;
726 if not isWadPath(Map) then
727 Exit;
729 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
730 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
731 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
732 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
733 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
734 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
736 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
737 gnRespawnItems := TGUISwitch(GetControl('swRespawnItems')).ItemIndex = 0;
738 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
739 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
740 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
741 Options := 0;
742 if gnTeamDamage then
743 Options := Options or GAME_OPTION_TEAMDAMAGE;
744 if gnRespawnItems then
745 Options := Options or GAME_OPTION_RESPAWNITEMS;
746 if gnAllowExit then
747 Options := Options or GAME_OPTION_ALLOWEXIT;
748 if gnWeaponStay then
749 Options := Options or GAME_OPTION_WEAPONSTAY;
750 if gnMonsters then
751 Options := Options or GAME_OPTION_MONSTERS;
752 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
754 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
755 1: begin
756 Options := Options or GAME_OPTION_BOTVSMONSTER;
757 gnBotsVS := 'Monsters';
758 end;
759 2: begin
760 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
761 gnBotsVS := 'Everybody';
762 end;
763 else begin
764 Options := Options or GAME_OPTION_BOTVSPLAYER;
765 gnBotsVS := 'Players';
766 end;
767 end;
769 gnMap := Map;
770 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
771 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
772 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
773 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
774 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
775 end;
777 s := e_GetWriteableDir(ConfigDirs);
778 if s <> '' then
779 begin
780 g_Options_Write_Net_Server(s + '/' + CONFIG_FILENAME);
781 g_Options_Write_Gameplay_Net(s + '/' + CONFIG_FILENAME)
782 end;
784 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
785 Options, gnPlayers, 0, NetPort);
786 end;
788 procedure ProcConnectNetGame();
789 var
790 PW: String;
791 s: AnsiString;
792 begin
793 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
794 begin
795 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
796 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
797 PW := TGUIEdit(GetControl('edPW')).Text;
798 end;
800 s := e_GetWriteableDir(ConfigDirs);
801 if s <> '' then
802 g_Options_Write_Net_Client(s + '/' + CONFIG_FILENAME);
803 g_Game_StartClient(NetClientIP, NetClientPort, PW);
804 end;
806 procedure ProcEnterPassword();
807 var
808 PW: string;
809 s: AnsiString;
810 begin
811 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
812 begin
813 NetClientIP := PromptIP;
814 NetClientPort := PromptPort;
815 PW := TGUIEdit(GetControl('edPW')).Text;
816 end;
818 s := e_GetWriteableDir(ConfigDirs);
819 if s <> '' then
820 g_Options_Write_Net_Client(s + '/' + CONFIG_FILENAME);
821 g_Game_StartClient(NetClientIP, NetClientPort, PW);
822 end;
824 procedure ProcServerlist();
825 begin
826 if not NetInitDone then
827 begin
828 if (not g_Net_Init()) then
829 begin
830 g_Console_Add('NET: ERROR: Failed to init ENet!');
831 Exit;
832 end
833 else
834 NetInitDone := True;
835 end;
837 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
839 gState := STATE_SLIST;
840 g_ActiveWindow := nil;
842 slWaitStr := _lc[I_NET_SLIST_WAIT];
844 g_Game_Draw;
845 sys_Repaint;
847 slReturnPressed := True;
848 if g_Net_Slist_Fetch(slCurrent) then
849 begin
850 if slCurrent = nil then
851 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
852 end
853 else
854 slWaitStr := _lc[I_NET_SLIST_ERROR];
855 g_Serverlist_GenerateTable(slCurrent, slTable);
856 end;
858 procedure ProcStartCampaign();
859 var
860 WAD: String;
861 TwoPlayers: Boolean;
862 n: Byte;
863 begin
864 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
865 begin
866 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
867 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
868 end;
869 WAD := e_FindWadRel(MegawadDirs, WAD);
871 if TwoPlayers then
872 n := 2
873 else
874 n := 1;
875 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
876 end;
878 procedure ProcSelectMap(Sender: TGUIControl);
879 var
880 win: TGUIWindow;
881 a: TMapInfo;
882 wad, map, res: String;
883 begin
884 win := g_GUI_GetWindow('SelectMapMenu');
885 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
886 begin
887 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
888 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
890 if (wad = '') or (map = '') then
891 begin // Ýòî íå êàðòà
892 TGUILabel(GetControl('lbMapName')).Text := '';
893 TGUILabel(GetControl('lbMapAuthor')).Text := '';
894 TGUILabel(GetControl('lbMapSize')).Text := '';
895 TGUIMemo(GetControl('meMapDescription')).SetText('');
896 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
897 TGUILabel(win.GetControl('lbMapScale')).Text := '';
898 end
899 else // Ýòî êàðòà
900 begin
901 res := wad+':\'+map;
903 a := g_Map_GetMapInfo(res);
905 TGUILabel(GetControl('lbMapName')).Text := a.Name;
906 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
907 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
908 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
909 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
910 TGUILabel(win.GetControl('lbMapScale')).Text :=
911 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
912 end;
913 end;
914 end;
916 procedure ProcSelectWAD(Sender: TGUIControl);
917 var
918 wad: String;
919 list: SSArray;
920 begin
921 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
922 begin
923 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
925 with TGUIListBox(GetControl('lsMapRes')) do
926 begin
927 Clear();
929 if wad <> '' then
930 begin
931 list := g_Map_GetMapsList(wad);
933 if list <> nil then
934 begin
935 Items := list;
936 ItemIndex := 0;
937 end
938 end;
939 end;
940 end;
942 ProcSelectMap(nil);
943 end;
945 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
946 var
947 win: TGUIWindow;
948 a: TMegaWADInfo;
949 wad, fn: String;
950 begin
951 win := g_GUI_GetWindow('CampaignMenu');
952 with TGUIMenu(win.GetControl('mCampaignMenu')) do
953 begin
954 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
956 if wad = '' then
957 begin
958 TGUILabel(GetControl('lbWADName')).Text := '';
959 TGUILabel(GetControl('lbWADAuthor')).Text := '';
960 TGUIMemo(GetControl('meWADDescription')).SetText('');
961 end;
963 a := g_Game_GetMegaWADInfo(wad);
965 TGUILabel(GetControl('lbWADName')).Text := a.Name;
966 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
967 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
969 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
971 if a.pic <> '' then
972 begin
973 fn := g_ExtractWadName(a.pic);
974 if fn = '' then
975 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
976 else
977 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
978 end;
979 end;
980 end;
982 procedure ProcChangeColor(Sender: TGUIControl);
983 var
984 window: TGUIWindow;
985 begin
986 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
987 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
988 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
989 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
990 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
991 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
993 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
994 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
995 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
996 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
997 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
998 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
999 end;
1001 procedure ProcSelectModel(Sender: TGUIControl);
1002 var
1003 a: string;
1004 window: TGUIWindow;
1005 begin
1006 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1007 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
1008 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
1010 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1011 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
1012 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
1014 ProcChangeColor(nil);
1015 end;
1017 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
1018 var
1019 cwdt, chgt: Byte;
1020 spc: ShortInt;
1021 ID: DWORD;
1022 wad: TWADFile;
1023 cfgdata: Pointer;
1024 cfglen: Integer;
1025 config: TConfig;
1026 begin
1027 cfglen := 0;
1029 wad := TWADFile.Create;
1030 if wad.ReadFile(GameWAD) then
1031 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
1032 wad.Free();
1034 if cfglen <> 0 then
1035 begin
1036 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
1038 config := TConfig.CreateMem(cfgdata, cfglen);
1039 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1040 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1041 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1043 if g_Texture_Get('FONT_STD', ID) then
1044 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
1046 config.Free();
1047 end;
1049 if cfglen <> 0 then FreeMem(cfgdata);
1050 end;
1052 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
1053 var
1054 cwdt, chgt: Byte;
1055 spc: ShortInt;
1056 CharID: DWORD;
1057 wad: TWADFile;
1058 cfgdata, fntdata: Pointer;
1059 cfglen, fntlen: Integer;
1060 config: TConfig;
1061 chrwidth: Integer;
1062 a: Byte;
1063 begin
1064 cfglen := 0;
1065 fntlen := 0;
1067 wad := TWADFile.Create;
1068 if wad.ReadFile(GameWAD) then
1069 begin
1070 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1071 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1072 end;
1073 wad.Free();
1075 if cfglen <> 0 then
1076 begin
1077 config := TConfig.CreateMem(cfgdata, cfglen);
1078 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1079 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1081 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1082 FontID := e_CharFont_Create(spc);
1084 for a := 0 to 255 do
1085 begin
1086 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1087 if chrwidth = 0 then Continue;
1089 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1090 cwdt, chgt) then
1091 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1092 end;
1094 config.Free();
1095 end;
1097 if cfglen <> 0 then FreeMem(cfgdata);
1098 if fntlen <> 0 then FreeMem(fntdata);
1099 end;
1101 procedure MenuLoadData();
1102 begin
1103 e_WriteLog('Loading menu data...', TMsgType.Notify);
1105 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD+':TEXTURES\MAINLOGO');
1106 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1107 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1108 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1109 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1110 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1111 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1112 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1113 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1114 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1115 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1116 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1117 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1118 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1119 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1120 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1121 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1122 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1123 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1124 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1125 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1126 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1127 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1128 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1129 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1131 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1132 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1133 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1134 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1135 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1136 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1137 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1138 end;
1140 procedure MenuFreeData();
1141 begin
1142 e_CharFont_Remove(gMenuFont);
1143 e_CharFont_Remove(gMenuSmallFont);
1145 g_Texture_Delete('MAINMENU_LOGO');
1146 g_Texture_Delete('MAINMENU_MARKER1');
1147 g_Texture_Delete('MAINMENU_MARKER2');
1148 g_Texture_Delete('SCROLL_LEFT');
1149 g_Texture_Delete('SCROLL_RIGHT');
1150 g_Texture_Delete('SCROLL_MIDDLE');
1151 g_Texture_Delete('SCROLL_MARKER');
1152 g_Texture_Delete('EDIT_LEFT');
1153 g_Texture_Delete('EDIT_RIGHT');
1154 g_Texture_Delete('EDIT_MIDDLE');
1155 g_Texture_Delete('BOX1');
1156 g_Texture_Delete('BOX2');
1157 g_Texture_Delete('BOX3');
1158 g_Texture_Delete('BOX4');
1159 g_Texture_Delete('BOX5');
1160 g_Texture_Delete('BOX6');
1161 g_Texture_Delete('BOX7');
1162 g_Texture_Delete('BOX8');
1163 g_Texture_Delete('BOX9');
1164 g_Texture_Delete('BSCROLL_UP_A');
1165 g_Texture_Delete('BSCROLL_UP_U');
1166 g_Texture_Delete('BSCROLL_DOWN_A');
1167 g_Texture_Delete('BSCROLL_DOWN_U');
1168 g_Texture_Delete('BSCROLL_MIDDLE');
1169 g_Texture_Delete('NOPIC');
1171 g_Sound_Delete('MENU_SELECT');
1172 g_Sound_Delete('MENU_OPEN');
1173 g_Sound_Delete('MENU_CLOSE');
1174 g_Sound_Delete('MENU_CHANGE');
1175 g_Sound_Delete('SCROLL_ADD');
1176 g_Sound_Delete('SCROLL_SUB');
1177 g_Sound_Delete('SOUND_PLAYER_FALL');
1178 end;
1180 procedure ProcAuthorsMenu();
1181 begin
1182 gMusic.SetByName('MUSIC_INTERMUS');
1183 gMusic.Play();
1184 end;
1186 procedure ProcExitMenuKeyDown (yes: Boolean);
1187 var
1188 s: ShortString;
1189 snd: TPlayableSound;
1190 res: Boolean;
1191 begin
1192 if yes then
1193 begin
1194 g_Game_StopAllSounds(True);
1195 case (Random(18)) of
1196 0: s := 'SOUND_MONSTER_PAIN';
1197 1: s := 'SOUND_MONSTER_DIE_3';
1198 2: s := 'SOUND_MONSTER_SLOP';
1199 3: s := 'SOUND_MONSTER_DEMON_DIE';
1200 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1201 5: s := 'SOUND_MONSTER_MAN_DIE';
1202 6: s := 'SOUND_MONSTER_BSP_DIE';
1203 7: s := 'SOUND_MONSTER_VILE_DIE';
1204 8: s := 'SOUND_MONSTER_SKEL_DIE';
1205 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1206 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1207 11: s := 'SOUND_MONSTER_BARON_DIE';
1208 12: s := 'SOUND_MONSTER_CACO_DIE';
1209 13: s := 'SOUND_MONSTER_CYBER_DIE';
1210 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1211 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1212 else s := 'SOUND_PLAYER_FALL';
1213 end;
1214 snd := TPlayableSound.Create();
1215 res := snd.SetByName(s);
1216 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1217 if res then
1218 begin
1219 snd.Play(True);
1220 while snd.IsPlaying() do begin end;
1221 end;
1222 g_Game_Quit();
1223 exit;
1224 end;
1225 g_GUI_HideWindow();
1226 end;
1228 procedure ProcLoadMenu();
1229 var
1230 a: Integer;
1231 valid: Boolean;
1232 begin
1233 for a := 1 to 8 do
1234 begin
1235 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1236 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1237 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1238 end;
1239 end;
1241 procedure ProcSaveMenu();
1242 var
1243 a: Integer;
1244 valid: Boolean;
1245 name: AnsiString;
1246 begin
1247 for a := 1 to 8 do
1248 begin
1249 name := g_GetSaveName(a, valid);
1250 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1251 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1252 end;
1253 end;
1255 procedure ProcSaveGame(Sender: TGUIControl);
1256 var
1257 a: Integer;
1258 begin
1259 if g_Game_IsNet then Exit;
1260 if g_Game_IsTestMap then Exit;
1261 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1262 g_Game_PauseAllSounds(True);
1263 g_SaveGame(a, TGUIEdit(Sender).Text);
1265 g_ActiveWindow := nil;
1266 g_Game_Pause(False);
1267 end;
1269 procedure ProcLoadGame(Sender: TGUIControl);
1270 var
1271 a: Integer;
1272 begin
1273 if g_Game_IsNet then Exit;
1274 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1275 if g_LoadGame(a) then
1276 begin
1277 g_Game_PauseAllSounds(False)
1278 end
1279 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1280 begin
1281 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1282 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1283 //g_ActiveWindow := nil;
1284 end;
1285 end;
1287 procedure ProcSinglePlayer (n: Integer);
1288 var wad, map: AnsiString;
1289 begin
1290 assert(n >= 1);
1291 wad := g_ExtractWadName(gDefaultMegawadStart);
1292 map := g_ExtractFilePathName(gDefaultMegawadStart);
1293 if e_FindResource(AllMapDirs, wad) then
1294 begin
1295 wad := ExpandFileName(wad);
1296 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1297 end
1298 end;
1300 procedure ProcSingle1Player;
1301 begin
1302 ProcSinglePlayer(1)
1303 end;
1305 procedure ProcSingle2Players;
1306 begin
1307 ProcSinglePlayer(2)
1308 end;
1310 procedure ProcSelectMapMenu();
1311 var
1312 menu: TGUIMenu;
1313 wad_lb: TGUIFileListBox;
1314 map_lb: TGUIListBox;
1315 map: String;
1316 begin
1317 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1318 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1319 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1321 if wad_lb.SelectedItem() <> '' then
1322 map := map_lb.SelectedItem()
1323 else
1324 map := '';
1326 wad_lb.UpdateFileList();
1327 map_lb.Clear();
1329 if wad_lb.SelectedItem() <> '' then
1330 begin
1331 ProcSelectWAD(nil);
1332 map_lb.SelectItem(map);
1334 if map_lb.SelectedItem() <> '' then
1335 ProcSelectMap(nil);
1336 end;
1338 g_GUI_ShowWindow('SelectMapMenu');
1339 end;
1341 procedure ProcSelectCampaignMenu();
1342 var
1343 menu: TGUIMenu;
1344 wad_lb: TGUIFileListBox;
1345 begin
1346 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1347 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1349 wad_lb.UpdateFileList();
1351 if wad_lb.SelectedItem() <> '' then
1352 ProcSelectCampaignWAD(nil);
1353 end;
1355 procedure ProcSetMap();
1356 var
1357 wad, map, res: String;
1358 begin
1359 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1360 begin
1361 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1362 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1363 end;
1365 if (wad = '') or (map = '') then
1366 Exit;
1368 wad := e_FindWadRel(MapDirs, WAD);
1370 res := wad+':\'+map;
1372 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1373 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1374 end;
1376 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1377 var
1378 menu: TGUIMenu;
1379 begin
1380 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1382 g_Sound_SetupAllVolumes(
1383 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1384 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1385 );
1386 end;
1388 procedure ProcChangeGameSettings(Sender: TGUIControl);
1389 var
1390 menu: TGUIMenu;
1391 begin
1392 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1393 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1394 begin
1395 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1396 g_dbg_scale := TempScale + 1;
1397 end;
1398 end;
1400 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1401 var
1402 menu: TGUIMenu;
1403 begin
1404 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1405 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1406 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1407 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1408 end;
1410 procedure ProcOptionsPlayersMIMenu();
1411 var
1412 s, a: string;
1413 b: TModelInfo;
1414 begin
1415 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1417 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1419 if a = '' then Exit;
1421 b := g_PlayerModel_GetInfo(a);
1423 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1424 begin
1425 TGUILabel(GetControl('lbName')).Text := b.Name;
1426 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1427 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1429 if b.HaveWeapon then
1430 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1431 else
1432 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1433 end;
1435 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1436 end;
1438 procedure ProcOptionsPlayersAnim();
1439 var
1440 s: String;
1441 begin
1442 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1443 s := 'P1'
1444 else
1445 s := 'P2';
1447 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1448 begin
1449 NextAnim();
1450 Model.GetCurrentAnimation.Loop := True;
1451 Model.GetCurrentAnimationMask.Loop := True;
1452 end;
1453 end;
1455 procedure ProcOptionsPlayersWeap();
1456 var
1457 s: String;
1458 begin
1459 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1460 s := 'P1'
1461 else
1462 s := 'P2';
1464 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1465 NextWeapon();
1466 end;
1468 procedure ProcOptionsPlayersRot();
1469 var
1470 s: string;
1471 begin
1472 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1473 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1474 begin
1475 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1476 end;
1477 end;
1479 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1480 begin
1481 if yes then
1482 begin
1483 g_Options_SetDefault();
1484 ReadOptions();
1485 end;
1486 g_GUI_HideWindow();
1487 end;
1489 procedure ProcSavedMenuKeyDown (yes: Boolean);
1490 begin
1491 if yes then ReadOptions();
1492 g_GUI_HideWindow();
1493 end;
1495 procedure ProcAuthorsClose();
1496 begin
1497 gMusic.SetByName('MUSIC_MENU');
1498 gMusic.Play();
1499 gState := STATE_MENU;
1500 end;
1502 procedure ProcGMClose();
1503 begin
1504 g_Game_InGameMenu(False);
1505 end;
1507 procedure ProcGMShow();
1508 var
1509 Enabled: Boolean;
1510 begin
1511 Enabled := True;
1512 if (gGameSettings.GameType = GT_SINGLE) and
1513 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1514 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1515 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1516 if not gGameOn then
1517 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1518 if g_Game_IsTestMap then
1519 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1520 TGUIMainMenu(g_ActiveWindow.GetControl(
1521 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1522 end;
1524 procedure ProcChangePlayers();
1525 var
1526 TeamGame, Spectator, AddTwo: Boolean;
1527 P1Team{, P2Team}: Byte;
1528 bP2: TGUITextButton;
1529 begin
1530 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1531 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1532 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1533 P1Team := TEAM_NONE;
1534 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1535 // TODO
1536 //P2Team := TEAM_NONE;
1537 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1539 TGUIMainMenu(g_ActiveWindow.GetControl(
1540 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1541 TGUIMainMenu(g_ActiveWindow.GetControl(
1542 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1543 TGUIMainMenu(g_ActiveWindow.GetControl(
1544 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1546 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1547 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1548 bP2.Enabled := AddTwo and not Spectator;
1549 if bP2.Enabled then
1550 bP2.Color := MAINMENU_ITEMS_COLOR
1551 else
1552 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1553 if gPlayer2 = nil then
1554 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1555 else
1556 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1558 TGUIMainMenu(g_ActiveWindow.GetControl(
1559 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1560 end;
1562 procedure ProcJoinRed();
1563 begin
1564 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1565 Exit;
1566 if g_Game_IsServer then
1567 begin
1568 if gPlayer1 = nil then
1569 g_Game_AddPlayer(TEAM_RED)
1570 else
1571 begin
1572 if gPlayer1.Team <> TEAM_RED then
1573 begin
1574 gPlayer1.SwitchTeam;
1575 gPlayer1Settings.Team := gPlayer1.Team;
1576 end;
1578 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1579 end;
1580 end
1581 else
1582 begin
1583 gPlayer1Settings.Team := TEAM_RED;
1584 MC_SEND_PlayerSettings;
1585 if gPlayer1 = nil then
1586 g_Game_AddPlayer(TEAM_RED);
1587 end;
1588 g_ActiveWindow := nil;
1589 g_Game_Pause(False);
1590 end;
1592 procedure ProcJoinBlue();
1593 begin
1594 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1595 Exit;
1596 if g_Game_IsServer then
1597 begin
1598 if gPlayer1 = nil then
1599 g_Game_AddPlayer(TEAM_BLUE)
1600 else
1601 begin
1602 if gPlayer1.Team <> TEAM_BLUE then
1603 begin
1604 gPlayer1.SwitchTeam;
1605 gPlayer1Settings.Team := gPlayer1.Team;
1606 end;
1608 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1609 end;
1610 end
1611 else
1612 begin
1613 gPlayer1Settings.Team := TEAM_BLUE;
1614 MC_SEND_PlayerSettings;
1615 if gPlayer1 = nil then
1616 g_Game_AddPlayer(TEAM_BLUE);
1617 end;
1618 g_ActiveWindow := nil;
1619 g_Game_Pause(False);
1620 end;
1622 procedure ProcJoinGame();
1623 begin
1624 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1625 Exit;
1626 if gPlayer1 = nil then
1627 g_Game_AddPlayer();
1628 g_ActiveWindow := nil;
1629 g_Game_Pause(False);
1630 end;
1632 procedure ProcSwitchP2();
1633 begin
1634 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1635 Exit;
1636 if gPlayer1 = nil then
1637 Exit;
1638 if gPlayer2 = nil then
1639 g_Game_AddPlayer()
1640 else
1641 g_Game_RemovePlayer();
1642 g_ActiveWindow := nil;
1643 g_Game_Pause(False);
1644 end;
1646 procedure ProcSpectate();
1647 begin
1648 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1649 Exit;
1650 g_Game_Spectate();
1651 g_ActiveWindow := nil;
1652 g_Game_Pause(False);
1653 end;
1655 procedure ProcRestartMenuKeyDown (yes: Boolean);
1656 begin
1657 if yes then g_Game_Restart() else g_GUI_HideWindow;
1658 end;
1660 procedure ProcEndMenuKeyDown (yes: Boolean);
1661 begin
1662 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1663 end;
1665 procedure ProcSetRussianLanguage;
1666 begin
1667 if gLanguage <> LANGUAGE_RUSSIAN then
1668 begin
1669 gLanguage := LANGUAGE_RUSSIAN;
1670 gLanguageChange := True;
1671 gAskLanguage := False;
1672 ProcApplyOptions();
1673 end;
1674 end;
1676 procedure ProcSetEnglishLanguage;
1677 begin
1678 if gLanguage <> LANGUAGE_ENGLISH then
1679 begin
1680 gLanguage := LANGUAGE_ENGLISH;
1681 gLanguageChange := True;
1682 gAskLanguage := False;
1683 ProcApplyOptions();
1684 end;
1685 end;
1687 procedure ReadGameSettings();
1688 var
1689 menu: TGUIMenu;
1690 begin
1691 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1693 with gGameSettings do
1694 begin
1695 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1696 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1697 ItemIndex := 0
1698 else
1699 ItemIndex := 1;
1701 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1702 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1703 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1705 with TGUISwitch(menu.GetControl('swBotsVS')) do
1706 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1707 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1708 ItemIndex := 2
1709 else
1710 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1711 ItemIndex := 1
1712 else
1713 ItemIndex := 0;
1715 if GameType in [GT_CUSTOM, GT_SERVER] then
1716 begin
1717 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1718 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1719 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1720 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1721 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1722 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1723 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1724 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1725 end
1726 else
1727 begin
1728 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1729 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1730 begin
1731 Enabled := False;
1732 Text := '';
1733 end;
1734 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1735 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1736 begin
1737 Enabled := False;
1738 Text := '';
1739 end;
1740 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1741 with TGUIEdit(menu.GetControl('edMaxLives')) do
1742 begin
1743 Enabled := False;
1744 Text := '';
1745 end;
1746 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1747 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1748 end;
1749 end;
1750 end;
1752 procedure ProcApplyGameSet();
1753 var
1754 menu: TGUIMenu;
1755 a, b, n: Integer;
1756 stat: TPlayerStatArray;
1757 begin
1758 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1760 if not g_Game_IsServer then Exit;
1762 with gGameSettings do
1763 begin
1764 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1765 begin
1766 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1767 Options := Options or GAME_OPTION_TEAMDAMAGE
1768 else
1769 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1770 end;
1772 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1773 begin
1774 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1776 if n = 0 then
1777 TimeLimit := 0
1778 else
1779 begin
1780 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1782 TimeLimit := Max(n, b);
1783 end;
1784 end;
1786 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1787 begin
1788 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1790 if n = 0 then
1791 GoalLimit := 0
1792 else
1793 begin
1794 b := 0;
1795 if GameMode = GM_DM then
1796 begin // DM
1797 stat := g_Player_GetStats();
1798 if stat <> nil then
1799 for a := 0 to High(stat) do
1800 if stat[a].Frags > b then
1801 b := stat[a].Frags;
1802 end
1803 else // CTF
1804 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1806 GoalLimit := Max(n, b);
1807 end;
1808 end;
1810 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1811 begin
1812 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1813 if n < 0 then n := 0;
1814 if n > 255 then n := 255;
1815 if n = 0 then
1816 MaxLives := 0
1817 else
1818 begin
1819 b := 0;
1820 stat := g_Player_GetStats();
1821 if stat <> nil then
1822 for a := 0 to High(stat) do
1823 if stat[a].Lives > b then
1824 b := stat[a].Lives;
1826 MaxLives := Max(n, b);
1827 end;
1828 end;
1830 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1831 begin
1832 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1833 1:
1834 begin
1835 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1836 Options := Options or GAME_OPTION_BOTVSMONSTER;
1837 end;
1838 2:
1839 begin
1840 Options := Options or GAME_OPTION_BOTVSPLAYER;
1841 Options := Options or GAME_OPTION_BOTVSMONSTER;
1842 end;
1843 else
1844 begin
1845 Options := Options or GAME_OPTION_BOTVSPLAYER;
1846 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1847 end;
1848 end;
1849 end;
1850 end;
1852 if g_Game_IsNet then MH_SEND_GameSettings;
1853 end;
1855 procedure ProcVideoOptionsRes();
1856 var
1857 menu: TGUIMenu;
1858 list: SSArray;
1859 begin
1860 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1862 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1863 IntToStr(gScreenWidth) +
1864 ' x ' + IntToStr(gScreenHeight) +
1865 ', ' + IntToStr(gBPP) + ' bpp';
1867 with TGUIListBox(menu.GetControl('lsResolution')) do
1868 begin
1869 list := sys_GetDisplayModes(gBPP);
1870 if list <> nil then
1871 begin
1872 Items := list;
1873 ItemIndex := Length(list)
1874 end
1875 else
1876 begin
1877 Clear
1878 end
1879 end;
1881 with TGUISwitch(menu.GetControl('swFullScreen')) do
1882 if gFullscreen then
1883 ItemIndex := 0
1884 else
1885 ItemIndex := 1;
1886 end;
1888 procedure ProcApplyVideoOptions();
1889 var
1890 menu: TGUIMenu;
1891 Fullscreen: Boolean;
1892 SWidth, SHeight: Integer;
1893 str: String;
1894 begin
1895 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1897 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1898 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1900 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1902 if (SWidth <> gScreenWidth) or
1903 (SHeight <> gScreenHeight) or
1904 (Fullscreen <> gFullscreen) then
1905 begin
1906 gResolutionChange := True;
1907 gRC_Width := SWidth;
1908 gRC_Height := SHeight;
1909 gRC_FullScreen := Fullscreen;
1910 gRC_Maximized := gWinMaximized;
1911 end;
1913 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1914 ProcApplyOptions();
1915 end;
1917 procedure ProcSetFirstRussianLanguage;
1918 begin
1919 gLanguage := LANGUAGE_RUSSIAN;
1920 gLanguageChange := True;
1921 gAskLanguage := False;
1922 end;
1924 procedure ProcSetFirstEnglishLanguage;
1925 begin
1926 gLanguage := LANGUAGE_ENGLISH;
1927 gLanguageChange := True;
1928 gAskLanguage := False;
1929 end;
1931 procedure ProcRecallAddress();
1932 begin
1933 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1934 begin
1935 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1936 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1937 end;
1938 end;
1940 procedure CreateFirstLanguageMenu();
1941 var
1942 Menu: TGUIWindow;
1943 begin
1944 Menu := TGUIWindow.Create('FirstLanguageMenu');
1946 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1947 begin
1948 Name := 'mmFirstLanguageMenu';
1949 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1950 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1951 end;
1953 Menu.DefControl := 'mmFirstLanguageMenu';
1954 Menu.MainWindow := True;
1955 g_GUI_AddWindow(Menu);
1956 end;
1958 procedure g_Menu_AskLanguage();
1959 begin
1960 CreateFirstLanguageMenu();
1961 g_GUI_ShowWindow('FirstLanguageMenu');
1962 end;
1964 procedure CreatePlayerOptionsMenu(s: String);
1965 var
1966 Menu: TGUIWindow;
1967 a: String;
1968 begin
1969 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1970 if s = 'P1' then
1971 a := _lc[I_MENU_PLAYER_1]
1972 else
1973 a := _lc[I_MENU_PLAYER_2];
1974 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1975 begin
1976 Name := 'mOptionsPlayers'+s+'Menu';
1977 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1978 begin
1979 Name := 'ed'+s+'Name';
1980 MaxLength := 12;
1981 Width := 12;
1982 end;
1983 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1984 begin
1985 Name := 'sw'+s+'Team';
1986 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1987 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1988 end ;
1989 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1990 begin
1991 Name := 'ls'+s+'Model';
1992 Sort := True;
1993 Items := g_PlayerModel_GetNames();
1994 OnChange := ProcSelectModel;
1995 end;
1996 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1997 begin
1998 Name := 'sc'+s+'Red';
1999 Max := 16;
2000 OnChange := ProcChangeColor;
2001 end;
2002 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2003 begin
2004 Name := 'sc'+s+'Green';
2005 Max := 16;
2006 OnChange := ProcChangeColor;
2007 end;
2008 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2009 begin
2010 Name := 'sc'+s+'Blue';
2011 Max := 16;
2012 OnChange := ProcChangeColor;
2013 end;
2014 AddSpace();
2015 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2016 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2017 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2018 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2020 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2021 begin
2022 Name := 'mv'+s+'Model';
2023 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2024 Y := GetControl('ls'+s+'Model').Y;
2025 end;
2026 end;
2027 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2028 g_GUI_AddWindow(Menu);
2029 end;
2031 procedure CreateAllMenus();
2032 var
2033 Menu: TGUIWindow;
2034 //SR: TSearchRec;
2035 a, cx, _y, i: Integer;
2036 //list: SSArray;
2037 begin
2038 Menu := TGUIWindow.Create('MainMenu');
2039 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2040 begin
2041 Name := 'mmMainMenu';
2042 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2043 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2044 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2045 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2046 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2047 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2048 end;
2049 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2050 begin
2051 Color := _RGB(255, 255, 255);
2052 X := gScreenWidth-GetWidth-8;
2053 Y := gScreenHeight-GetHeight-8;
2054 end;
2055 Menu.DefControl := 'mmMainMenu';
2056 Menu.MainWindow := True;
2057 g_GUI_AddWindow(Menu);
2059 Menu := TGUIWindow.Create('NewGameMenu');
2060 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2061 begin
2062 Name := 'mmNewGameMenu';
2063 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2064 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2065 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2066 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2067 end;
2068 Menu.DefControl := 'mmNewGameMenu';
2069 g_GUI_AddWindow(Menu);
2071 Menu := TGUIWindow.Create('NetGameMenu');
2072 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2073 begin
2074 Name := 'mmNetGameMenu';
2075 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2076 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2077 end;
2078 Menu.DefControl := 'mmNetGameMenu';
2079 g_GUI_AddWindow(Menu);
2081 Menu := TGUIWindow.Create('NetServerMenu');
2082 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2083 begin
2084 Name := 'mNetServerMenu';
2085 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2086 begin
2087 Name := 'edSrvName';
2088 OnlyDigits := False;
2089 Width := 16;
2090 MaxLength := 64;
2091 Text := NetServerName;
2092 end;
2093 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2094 begin
2095 Name := 'edSrvPassword';
2096 OnlyDigits := False;
2097 Width := 16;
2098 MaxLength := 24;
2099 Text := NetPassword;
2100 end;
2101 with AddEdit(_lc[I_NET_PORT]) do
2102 begin
2103 Name := 'edPort';
2104 OnlyDigits := True;
2105 Width := 4;
2106 MaxLength := 5;
2107 Text := IntToStr(NetPort);
2108 end;
2109 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2110 begin
2111 Name := 'edMaxPlayers';
2112 OnlyDigits := True;
2113 Width := 4;
2114 MaxLength := 2;
2115 Text := IntToStr(NetMaxClients);
2116 end;
2117 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2118 begin
2119 Name := 'swUseMaster';
2120 AddItem(_lc[I_MENU_YES]);
2121 AddItem(_lc[I_MENU_NO]);
2122 if NetUseMaster then
2123 ItemIndex := 0
2124 else
2125 ItemIndex := 1;
2126 end;
2127 AddSpace();
2128 with AddLabel(_lc[I_MENU_MAP]) do
2129 begin
2130 Name := 'lbMap';
2131 FixedLength := 16;
2132 Text := gnMap;
2133 OnClick := @ProcSelectMapMenu;
2134 end;
2135 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2136 begin
2137 Name := 'swGameMode';
2138 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2139 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2140 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2141 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2142 case g_Game_TextToMode(gnGameMode) of
2143 GM_NONE,
2144 GM_DM: ItemIndex := 0;
2145 GM_TDM: ItemIndex := 1;
2146 GM_CTF: ItemIndex := 2;
2147 GM_SINGLE,
2148 GM_COOP: ItemIndex := 3;
2149 end;
2150 OnChange := ProcSwitchMonstersNet;
2151 end;
2152 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2153 begin
2154 Name := 'edTimeLimit';
2155 OnlyDigits := True;
2156 Width := 4;
2157 MaxLength := 5;
2158 if gnTimeLimit > 0 then
2159 Text := IntToStr(gnTimeLimit);
2160 end;
2161 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2162 begin
2163 Name := 'edGoalLimit';
2164 OnlyDigits := True;
2165 Width := 4;
2166 MaxLength := 5;
2167 if gnGoalLimit > 0 then
2168 Text := IntToStr(gnGoalLimit);
2169 end;
2170 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2171 begin
2172 Name := 'edMaxLives';
2173 OnlyDigits := True;
2174 Width := 4;
2175 MaxLength := 3;
2176 if gnMaxLives > 0 then
2177 Text := IntToStr(gnMaxLives);
2178 end;
2179 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2180 begin
2181 Name := 'swPlayers';
2182 AddItem(_lc[I_MENU_COUNT_NONE]);
2183 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2184 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2185 ItemIndex := gnPlayers;
2186 end;
2187 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2188 begin
2189 Name := 'swTeamDamage';
2190 AddItem(_lc[I_MENU_YES]);
2191 AddItem(_lc[I_MENU_NO]);
2192 if gnTeamDamage then
2193 ItemIndex := 0
2194 else
2195 ItemIndex := 1;
2196 end;
2197 with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do
2198 begin
2199 Name := 'swRespawnItems';
2200 AddItem(_lc[I_MENU_YES]);
2201 AddItem(_lc[I_MENU_NO]);
2202 if gnRespawnItems then
2203 ItemIndex := 0
2204 else
2205 ItemIndex := 1;
2206 end;
2207 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2208 begin
2209 Name := 'swEnableExits';
2210 AddItem(_lc[I_MENU_YES]);
2211 AddItem(_lc[I_MENU_NO]);
2212 if gnAllowExit then
2213 ItemIndex := 0
2214 else
2215 ItemIndex := 1;
2216 end;
2217 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2218 begin
2219 Name := 'swWeaponStay';
2220 AddItem(_lc[I_MENU_YES]);
2221 AddItem(_lc[I_MENU_NO]);
2222 if gnWeaponStay then
2223 ItemIndex := 0
2224 else
2225 ItemIndex := 1;
2226 end;
2227 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2228 begin
2229 Name := 'swMonsters';
2230 AddItem(_lc[I_MENU_YES]);
2231 AddItem(_lc[I_MENU_NO]);
2232 if gnMonsters then
2233 ItemIndex := 0
2234 else
2235 ItemIndex := 1;
2236 end;
2237 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2238 begin
2239 Name := 'swBotsVS';
2240 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2241 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2242 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2243 ItemIndex := 2;
2244 if gnBotsVS = 'Players' then
2245 ItemIndex := 0;
2246 if gnBotsVS = 'Monsters' then
2247 ItemIndex := 1;
2248 end;
2249 AddSpace();
2250 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2252 ReAlign();
2253 end;
2254 Menu.DefControl := 'mNetServerMenu';
2255 g_GUI_AddWindow(Menu);
2257 Menu := TGUIWindow.Create('NetClientMenu');
2258 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2259 begin
2260 Name := 'mNetClientMenu';
2262 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2263 AddSpace();
2265 with AddEdit(_lc[I_NET_ADDRESS]) do
2266 begin
2267 Name := 'edIP';
2268 OnlyDigits :=False;
2269 Width := 12;
2270 MaxLength := 64;
2271 Text := 'localhost';
2272 end;
2273 with AddEdit(_lc[I_NET_PORT]) do
2274 begin
2275 Name := 'edPort';
2276 OnlyDigits := True;
2277 Width := 4;
2278 MaxLength := 5;
2279 Text := '25666';
2280 end;
2281 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2282 begin
2283 Name := 'edPW';
2284 OnlyDigits := False;
2285 Width := 12;
2286 MaxLength := 32;
2287 Text := '';
2288 end;
2290 AddSpace();
2291 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2293 ReAlign();
2294 end;
2295 Menu.DefControl := 'mNetClientMenu';
2296 g_GUI_AddWindow(Menu);
2298 Menu := TGUIWindow.Create('LoadMenu');
2299 Menu.OnShow := ProcLoadMenu;
2300 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2301 begin
2302 Name := 'mmLoadMenu';
2304 for a := 1 to 8 do
2305 with AddEdit('') do
2306 begin
2307 Name := 'edSlot'+IntToStr(a);
2308 Width := 16;
2309 MaxLength := 16;
2310 OnEnter := ProcLoadGame;
2311 end;
2312 end;
2313 Menu.DefControl := 'mmLoadMenu';
2314 g_GUI_AddWindow(Menu);
2316 Menu := TGUIWindow.Create('SaveMenu');
2317 Menu.OnShow := ProcSaveMenu;
2318 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2319 begin
2320 Name := 'mmSaveMenu';
2322 for a := 1 to 8 do
2323 with AddEdit('') do
2324 begin
2325 Name := 'edSlot'+IntToStr(a);
2326 Width := 16;
2327 MaxLength := 16;
2328 OnChange := ProcSaveGame;
2329 end;
2330 end;
2331 Menu.DefControl := 'mmSaveMenu';
2332 g_GUI_AddWindow(Menu);
2334 Menu := TGUIWindow.Create('CustomGameMenu');
2335 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2336 begin
2337 Name := 'mCustomGameMenu';
2338 with AddLabel(_lc[I_MENU_MAP]) do
2339 begin
2340 Name := 'lbMap';
2341 FixedLength := 16;
2342 Text := gcMap;
2343 OnClick := @ProcSelectMapMenu;
2344 end;
2345 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2346 begin
2347 Name := 'swGameMode';
2348 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2349 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2350 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2351 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2352 case g_Game_TextToMode(gcGameMode) of
2353 GM_NONE,
2354 GM_DM: ItemIndex := 0;
2355 GM_TDM: ItemIndex := 1;
2356 GM_CTF: ItemIndex := 2;
2357 GM_SINGLE,
2358 GM_COOP: ItemIndex := 3;
2359 end;
2360 OnChange := ProcSwitchMonstersCustom;
2361 end;
2362 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2363 begin
2364 Name := 'edTimeLimit';
2365 OnlyDigits := True;
2366 Width := 4;
2367 MaxLength := 5;
2368 if gcTimeLimit > 0 then
2369 Text := IntToStr(gcTimeLimit);
2370 end;
2371 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2372 begin
2373 Name := 'edGoalLimit';
2374 OnlyDigits := True;
2375 Width := 4;
2376 MaxLength := 5;
2377 if gcGoalLimit > 0 then
2378 Text := IntToStr(gcGoalLimit);
2379 end;
2380 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2381 begin
2382 Name := 'edMaxLives';
2383 OnlyDigits := True;
2384 Width := 4;
2385 MaxLength := 5;
2386 if gcMaxLives > 0 then
2387 Text := IntToStr(gcMaxLives);
2388 end;
2389 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2390 begin
2391 Name := 'swPlayers';
2392 AddItem(_lc[I_MENU_COUNT_NONE]);
2393 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2394 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2395 ItemIndex := gcPlayers;
2396 end;
2397 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2398 begin
2399 Name := 'swTeamDamage';
2400 AddItem(_lc[I_MENU_YES]);
2401 AddItem(_lc[I_MENU_NO]);
2402 if gcTeamDamage then
2403 ItemIndex := 0
2404 else
2405 ItemIndex := 1;
2406 end;
2407 with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do
2408 begin
2409 Name := 'swRespawnItems';
2410 AddItem(_lc[I_MENU_YES]);
2411 AddItem(_lc[I_MENU_NO]);
2412 if gcRespawnItems then
2413 ItemIndex := 0
2414 else
2415 ItemIndex := 1;
2416 end;
2417 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2418 begin
2419 Name := 'swEnableExits';
2420 AddItem(_lc[I_MENU_YES]);
2421 AddItem(_lc[I_MENU_NO]);
2422 if gcAllowExit then
2423 ItemIndex := 0
2424 else
2425 ItemIndex := 1;
2426 end;
2427 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2428 begin
2429 Name := 'swWeaponStay';
2430 AddItem(_lc[I_MENU_YES]);
2431 AddItem(_lc[I_MENU_NO]);
2432 if gcWeaponStay then
2433 ItemIndex := 0
2434 else
2435 ItemIndex := 1;
2436 end;
2437 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2438 begin
2439 Name := 'swMonsters';
2440 AddItem(_lc[I_MENU_YES]);
2441 AddItem(_lc[I_MENU_NO]);
2442 if gcMonsters then
2443 ItemIndex := 0
2444 else
2445 ItemIndex := 1;
2446 end;
2447 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2448 begin
2449 Name := 'swBotsVS';
2450 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2451 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2452 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2453 ItemIndex := 2;
2454 if gcBotsVS = 'Players' then
2455 ItemIndex := 0;
2456 if gcBotsVS = 'Monsters' then
2457 ItemIndex := 1;
2458 end;
2459 AddSpace();
2460 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2462 ReAlign();
2463 end;
2464 Menu.DefControl := 'mCustomGameMenu';
2465 g_GUI_AddWindow(Menu);
2467 Menu := TGUIWindow.Create('CampaignMenu');
2468 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2469 begin
2470 Name := 'mCampaignMenu';
2472 AddSpace();
2473 AddSpace();
2474 AddSpace();
2475 AddSpace();
2476 AddSpace();
2477 AddSpace();
2479 with AddFileList('', 15, 4) do
2480 begin
2481 Name := 'lsWAD';
2482 OnChange := ProcSelectCampaignWAD;
2484 Sort := True;
2485 Dirs := True;
2486 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2487 SetBase(MegawadDirs);
2488 end;
2490 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2491 begin
2492 Name := 'lbWADName';
2493 FixedLength := 8;
2494 Enabled := False;
2495 end;
2496 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2497 begin
2498 Name := 'lbWADAuthor';
2499 FixedLength := 8;
2500 Enabled := False;
2501 end;
2502 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2503 with AddMemo('', 15, 3) do
2504 begin
2505 Name := 'meWADDescription';
2506 Color := MENU_ITEMSCTRL_COLOR;
2507 end;
2508 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2509 begin
2510 Name := 'swPlayers';
2511 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2512 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2513 end;
2514 AddSpace();
2515 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2517 ReAlign();
2519 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2520 begin
2521 Name := 'mpWADImage';
2522 DefaultRes := 'NOPIC';
2523 X := GetControl('lsWAD').X+4;
2524 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2525 end;
2526 end;
2527 Menu.DefControl := 'mCampaignMenu';
2528 g_GUI_AddWindow(Menu);
2530 Menu := TGUIWindow.Create('SelectMapMenu');
2531 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2532 begin
2533 Name := 'mSelectMapMenu';
2534 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2535 begin
2536 Name := 'lsMapWAD';
2537 OnChange := ProcSelectWAD;
2539 Sort := True;
2540 Dirs := True;
2541 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2542 SetBase(MapDirs);
2543 end;
2544 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2545 begin
2546 Name := 'lsMapRes';
2547 Sort := True;
2548 OnChange := ProcSelectMap;
2549 end;
2550 AddSpace();
2551 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2552 begin
2553 Name := 'lbMapName';
2554 FixedLength := 24;
2555 Enabled := False;
2556 end;
2557 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2558 begin
2559 Name := 'lbMapAuthor';
2560 FixedLength := 16;
2561 Enabled := False;
2562 end;
2563 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2564 begin
2565 Name := 'lbMapSize';
2566 FixedLength := 10;
2567 Enabled := False;
2568 end;
2569 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2570 begin
2571 Name := 'meMapDescription';
2572 end;
2574 ReAlign();
2576 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2577 begin
2578 Name := 'mpMapPreview';
2579 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2580 Y := GetControl('lsMapWAD').Y;
2581 end;
2582 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2583 begin
2584 Name := 'lbMapScale';
2585 FixedLength := 8;
2586 Enabled := False;
2587 Color := MENU_ITEMSCTRL_COLOR;
2588 X := GetControl('lsMapWAD').X +
2589 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2590 2 + MAPPREVIEW_WIDTH*4;
2591 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2592 end;
2593 end;
2594 Menu.OnClose := ProcSetMap;
2595 Menu.DefControl := 'mSelectMapMenu';
2596 g_GUI_AddWindow(Menu);
2598 Menu := TGUIWindow.Create('OptionsMenu');
2599 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2600 begin
2601 Name := 'mmOptionsMenu';
2602 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2603 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2604 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2605 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2606 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2607 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2608 AddSpace();
2609 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2610 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2611 end;
2612 Menu.OnClose := ProcApplyOptions;
2613 Menu.DefControl := 'mmOptionsMenu';
2614 g_GUI_AddWindow(Menu);
2616 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2617 gMenuSmallFont, @ProcSavedMenuKeyDown);
2618 g_GUI_AddWindow(Menu);
2620 Menu := TGUIWindow.Create('OptionsVideoMenu');
2621 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2622 begin
2623 Name := 'mOptionsVideoMenu';
2624 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2625 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2626 begin
2627 Name := 'swBPP';
2628 AddItem('16');
2629 AddItem('32');
2630 end;
2631 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2632 begin
2633 Name := 'swVSync';
2634 AddItem(_lc[I_MENU_YES]);
2635 AddItem(_lc[I_MENU_NO]);
2636 end;
2637 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2638 begin
2639 Name := 'swTextureFilter';
2640 AddItem(_lc[I_MENU_YES]);
2641 AddItem(_lc[I_MENU_NO]);
2642 end;
2643 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2644 begin
2645 Name := 'swLegacyNPOT';
2646 AddItem(_lc[I_MENU_NO]);
2647 AddItem(_lc[I_MENU_YES]);
2648 end;
2649 AddSpace();
2650 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2651 ReAlign();
2652 end;
2653 Menu.DefControl := 'mOptionsVideoMenu';
2654 g_GUI_AddWindow(Menu);
2656 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2657 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2658 begin
2659 Name := 'mOptionsVideoResMenu';
2660 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2661 begin
2662 Name := 'lbCurrentRes';
2663 FixedLength := 24;
2664 Enabled := False;
2665 end;
2666 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2667 begin
2668 Name := 'lsResolution';
2669 Sort := False;
2670 end;
2671 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2672 begin
2673 Name := 'swFullScreen';
2674 AddItem(_lc[I_MENU_YES]);
2675 AddItem(_lc[I_MENU_NO]);
2676 end;
2677 AddSpace();
2678 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2679 UpdateIndex();
2680 end;
2681 Menu.DefControl := 'mOptionsVideoResMenu';
2682 g_GUI_AddWindow(Menu);
2684 Menu := TGUIWindow.Create('OptionsSoundMenu');
2685 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2686 begin
2687 Name := 'mOptionsSoundMenu';
2688 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2689 begin
2690 Name := 'scMusicLevel';
2691 Max := 16;
2692 OnChange := ProcChangeSoundSettings;
2693 end;
2694 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2695 begin
2696 Name := 'scSoundLevel';
2697 Max := 16;
2698 OnChange := ProcChangeSoundSettings;
2699 end;
2700 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2701 begin
2702 Name := 'scMaxSimSounds';
2703 Max := 16;
2704 end;
2705 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2706 begin;
2707 Name := 'swAnnouncer';
2708 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2709 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2710 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2711 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2712 end;
2713 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2714 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2715 begin;
2716 Name := 'swSoundEffects';
2717 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2718 AddItem(_lc[I_MENU_COMPAT_DF]);
2719 end;
2720 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2721 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2722 begin;
2723 Name := 'swChatSpeech';
2724 AddItem(_lc[I_MENU_YES]);
2725 AddItem(_lc[I_MENU_NO]);
2726 end;
2727 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2728 begin
2729 Name := 'swInactiveSounds';
2730 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2731 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2732 end;
2733 ReAlign();
2734 end;
2735 Menu.DefControl := 'mOptionsSoundMenu';
2736 g_GUI_AddWindow(Menu);
2738 Menu := TGUIWindow.Create('OptionsGameMenu');
2739 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2740 begin
2741 Name := 'mOptionsGameMenu';
2742 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2743 begin
2744 Name := 'scParticlesCount';
2745 Max := 20;
2746 end;
2747 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2748 begin
2749 Name := 'swBloodCount';
2750 AddItem(_lc[I_MENU_COUNT_NONE]);
2751 AddItem(_lc[I_MENU_COUNT_SMALL]);
2752 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2753 AddItem(_lc[I_MENU_COUNT_BIG]);
2754 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2755 end;
2756 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2757 begin
2758 Name := 'scShellsMax';
2759 Max := 20;
2760 end;
2761 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2762 begin
2763 Name := 'scGibsMax';
2764 Max := 20;
2765 end;
2766 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2767 begin
2768 Name := 'scCorpsesMax';
2769 Max := 20;
2770 end;
2771 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2772 begin
2773 Name := 'swGibsCount';
2774 AddItem(_lc[I_MENU_COUNT_NONE]);
2775 AddItem(_lc[I_MENU_COUNT_SMALL]);
2776 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2777 AddItem(_lc[I_MENU_COUNT_BIG]);
2778 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2779 end;
2780 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2781 begin
2782 Name := 'swCorpseType';
2783 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2784 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2785 end;
2786 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2787 begin
2788 Name := 'swGibsType';
2789 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2790 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2791 end;
2792 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2793 begin
2794 Name := 'swBloodType';
2795 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2796 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2797 end;
2798 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2799 begin
2800 Name := 'swScreenFlash';
2801 AddItem(_lc[I_MENU_NO]);
2802 AddItem(_lc[I_MENU_COMPAT_DF]);
2803 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2804 end;
2805 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2806 begin
2807 Name := 'swBackground';
2808 AddItem(_lc[I_MENU_YES]);
2809 AddItem(_lc[I_MENU_NO]);
2810 end;
2811 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2812 begin
2813 Name := 'swMessages';
2814 AddItem(_lc[I_MENU_YES]);
2815 AddItem(_lc[I_MENU_NO]);
2816 end;
2817 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2818 begin
2819 Name := 'swRevertPlayers';
2820 AddItem(_lc[I_MENU_YES]);
2821 AddItem(_lc[I_MENU_NO]);
2822 end;
2823 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2824 begin
2825 Name := 'swChatBubble';
2826 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2827 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2828 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2829 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2830 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2831 end;
2832 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2833 begin
2834 Name := 'swPlayerIndicator';
2835 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2836 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2837 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2838 end;
2839 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2840 begin
2841 Name := 'swPlayerIndicatorStyle';
2842 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2843 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2844 end;
2845 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2846 begin
2847 Name := 'scScaleFactor';
2848 Max := 10;
2849 OnChange := ProcChangeGameSettings;
2850 end;
2851 ReAlign();
2852 end;
2853 Menu.DefControl := 'mOptionsGameMenu';
2854 g_GUI_AddWindow(Menu);
2856 Menu := TGUIWindow.Create('OptionsControlsMenu');
2857 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2858 begin
2859 Name := 'mOptionsControlsMenu';
2860 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2861 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2862 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2863 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2864 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2865 AddSpace();
2866 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2867 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2868 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2869 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2870 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2871 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2872 if e_HasJoysticks then
2873 begin
2874 AddSpace();
2875 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2876 end;
2877 if g_touch_enabled then
2878 begin
2879 AddSpace();
2880 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2881 end;
2882 end;
2883 Menu.DefControl := 'mOptionsControlsMenu';
2884 g_GUI_AddWindow(Menu);
2886 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2887 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2888 begin
2889 Name := 'mOptionsControlsP1Menu';
2890 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2891 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2892 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2893 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2894 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2895 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2896 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2897 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2898 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2899 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2900 end;
2901 Menu.DefControl := 'mOptionsControlsP1Menu';
2902 g_GUI_AddWindow(Menu);
2904 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2905 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2906 begin
2907 Name := 'mOptionsControlsP1MenuWeapons';
2908 for i := WP_FIRST to WP_LAST do
2909 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2910 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2911 end;
2912 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2913 g_GUI_AddWindow(Menu);
2915 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2916 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2917 begin
2918 Name := 'mOptionsControlsP2Menu';
2919 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2920 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2921 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2922 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2923 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2924 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2925 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2926 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2927 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2928 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2929 end;
2930 Menu.DefControl := 'mOptionsControlsP2Menu';
2931 g_GUI_AddWindow(Menu);
2933 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2934 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2935 begin
2936 Name := 'mOptionsControlsP2MenuWeapons';
2937 for i := WP_FIRST to WP_LAST do
2938 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2939 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2940 end;
2941 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2942 g_GUI_AddWindow(Menu);
2944 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2945 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2946 begin
2947 Name := 'mOptionsControlsJoystickMenu';
2948 for i := 0 to e_MaxJoys - 1 do
2949 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2950 begin
2951 Name := 'scDeadzone' + IntToStr(i);
2952 Max := 20
2953 end
2954 end;
2955 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2956 g_GUI_AddWindow(Menu);
2958 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2959 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2960 begin
2961 Name := 'mOptionsControlsTouchMenu';
2962 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2963 begin
2964 Name := 'swTouchAlt';
2965 AddItem(_lc[I_MENU_NO]);
2966 AddItem(_lc[I_MENU_YES]);
2967 OnChange := ProcChangeTouchSettings;
2968 end;
2969 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2970 begin
2971 Name := 'scTouchSize';
2972 Max := 20;
2973 OnChange := ProcChangeTouchSettings;
2974 end;
2975 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2976 begin
2977 Name := 'swTouchFire';
2978 AddItem(_lc[I_MENU_NO]);
2979 AddItem(_lc[I_MENU_YES]);
2980 end;
2981 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2982 begin
2983 Name := 'scTouchOffset';
2984 Max := 20;
2985 OnChange := ProcChangeTouchSettings;
2986 end;
2987 end;
2988 Menu.DefControl := 'mOptionsControlsTouchMenu';
2989 g_GUI_AddWindow(Menu);
2991 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2992 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2993 begin
2994 Name := 'mOptionsPlayersMenu';
2995 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2996 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2997 end;
2998 Menu.DefControl := 'mOptionsPlayersMenu';
2999 g_GUI_AddWindow(Menu);
3001 CreatePlayerOptionsMenu('P1');
3002 CreatePlayerOptionsMenu('P2');
3004 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3005 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3006 begin
3007 Name := 'mOptionsPlayersMIMenu';
3008 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3009 begin
3010 Name := 'lbName';
3011 FixedLength := 16;
3012 end;
3013 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3014 begin
3015 Name := 'lbAuthor';
3016 FixedLength := 16;
3017 end;
3018 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3019 begin
3020 Name := 'meComment';
3021 end;
3022 AddSpace();
3023 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3024 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3025 begin
3026 Name := 'lbWeapon';
3027 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3028 end;
3029 ReAlign();
3030 end;
3031 Menu.DefControl := 'mOptionsPlayersMIMenu';
3032 g_GUI_AddWindow(Menu);
3034 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3035 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3036 begin
3037 Name := 'mOptionsLanguageMenu';
3038 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3039 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3040 ReAlign();
3041 end;
3042 Menu.DefControl := 'mOptionsLanguageMenu';
3043 g_GUI_AddWindow(Menu);
3045 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3046 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3047 g_GUI_AddWindow(Menu);
3049 Menu := TGUIWindow.Create('AuthorsMenu');
3050 Menu.BackTexture := 'INTER';
3051 Menu.OnClose := ProcAuthorsClose;
3053 // Çàãîëîâîê:
3054 _y := 16;
3055 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3056 begin
3057 Color := _RGB(255, 0, 0);
3058 X := (gScreenWidth div 2)-(GetWidth() div 2);
3059 Y := _y;
3060 _y := _y+GetHeight();
3061 end;
3062 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3063 begin
3064 Color := _RGB(255, 0, 0);
3065 X := (gScreenWidth div 2)-(GetWidth() div 2);
3066 Y := _y;
3067 _y := _y+GetHeight()+32;
3068 end;
3069 // ×òî äåëàë: Êòî äåëàë
3070 cx := gScreenWidth div 2 - 320 + 64;
3071 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3072 begin
3073 Color := _RGB(255, 0, 0);
3074 X := cx;
3075 Y := _y;
3076 _y := _y+22;
3077 end;
3078 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3079 begin
3080 Color := _RGB(255, 255, 255);
3081 X := cx+32;
3082 Y := _y;
3083 _y := _y+36;
3084 end;
3085 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3086 begin
3087 Color := _RGB(255, 0, 0);
3088 X := cx;
3089 Y := _y;
3090 _y := _y+22;
3091 end;
3092 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3093 begin
3094 Color := _RGB(255, 255, 255);
3095 X := cx+32;
3096 Y := _y;
3097 _y := _y+22;
3098 end;
3099 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3100 begin
3101 Color := _RGB(255, 255, 255);
3102 X := cx+32;
3103 Y := _y;
3104 _y := _y+36;
3105 end;
3106 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3107 begin
3108 Color := _RGB(255, 0, 0);
3109 X := cx;
3110 Y := _y;
3111 _y := _y+22;
3112 end;
3113 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3114 begin
3115 Color := _RGB(255, 255, 255);
3116 X := cx+32;
3117 Y := _y;
3118 _y := _y+36;
3119 end;
3120 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3121 begin
3122 Color := _RGB(255, 0, 0);
3123 X := cx;
3124 Y := _y;
3125 _y := _y+22;
3126 end;
3127 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3128 begin
3129 Color := _RGB(255, 255, 255);
3130 X := cx+32;
3131 Y := _y;
3132 _y := gScreenHeight - 128;
3133 end;
3134 // Çàêëþ÷åíèå:
3135 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3136 begin
3137 Color := _RGB(255, 0, 0);
3138 X := cx;
3139 Y := _y;
3140 _y := _y+16;
3141 end;
3142 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3143 begin
3144 Color := _RGB(255, 255, 255);
3145 X := cx+32;
3146 Y := _y;
3147 _y := _y+GetHeight();
3148 end;
3149 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], 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_3], gMenuSmallFont))) do
3157 begin
3158 Color := _RGB(255, 255, 255);
3159 X := cx+32;
3160 Y := _y;
3161 _y := gScreenHeight - 32;
3162 end;
3163 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3164 begin
3165 Color := _RGB(255, 0, 0);
3166 X := gScreenWidth div 2 - GetWidth() div 2;
3167 Y := _y;
3168 end;
3169 g_GUI_AddWindow(Menu);
3171 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3172 gMenuSmallFont, @ProcExitMenuKeyDown);
3173 g_GUI_AddWindow(Menu);
3175 Menu := TGUIWindow.Create('GameSingleMenu');
3176 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3177 begin
3178 Name := 'mmGameSingleMenu';
3179 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3180 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3181 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3182 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3183 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3184 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3185 end;
3186 Menu.DefControl := 'mmGameSingleMenu';
3187 Menu.MainWindow := True;
3188 Menu.OnClose := ProcGMClose;
3189 Menu.OnShow := ProcGMShow;
3190 g_GUI_AddWindow(Menu);
3192 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3193 gMenuSmallFont, @ProcEndMenuKeyDown);
3194 g_GUI_AddWindow(Menu);
3196 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3197 gMenuSmallFont, @ProcRestartMenuKeyDown);
3198 g_GUI_AddWindow(Menu);
3200 Menu := TGUIWindow.Create('GameCustomMenu');
3201 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3202 begin
3203 Name := 'mmGameCustomMenu';
3204 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3205 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3206 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3207 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3208 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3209 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3210 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3211 end;
3212 Menu.DefControl := 'mmGameCustomMenu';
3213 Menu.MainWindow := True;
3214 Menu.OnClose := ProcGMClose;
3215 Menu.OnShow := ProcGMShow;
3216 g_GUI_AddWindow(Menu);
3218 Menu := TGUIWindow.Create('GameServerMenu');
3219 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3220 begin
3221 Name := 'mmGameServerMenu';
3222 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3223 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3224 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3225 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3226 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3227 end;
3228 Menu.DefControl := 'mmGameServerMenu';
3229 Menu.MainWindow := True;
3230 Menu.OnClose := ProcGMClose;
3231 Menu.OnShow := ProcGMShow;
3232 g_GUI_AddWindow(Menu);
3234 Menu := TGUIWindow.Create('GameClientMenu');
3235 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3236 begin
3237 Name := 'mmGameClientMenu';
3238 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3239 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3240 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3241 end;
3242 Menu.DefControl := 'mmGameClientMenu';
3243 Menu.MainWindow := True;
3244 Menu.OnClose := ProcGMClose;
3245 Menu.OnShow := ProcGMShow;
3246 g_GUI_AddWindow(Menu);
3248 Menu := TGUIWindow.Create('ClientPasswordMenu');
3249 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3250 begin
3251 Name := 'mClientPasswordMenu';
3252 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3253 begin
3254 Name := 'edPW';
3255 Width := 12;
3256 MaxLength := 32;
3257 end;
3258 AddSpace;
3260 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3261 ReAlign();
3262 end;
3263 Menu.DefControl := 'mClientPasswordMenu';
3264 g_GUI_AddWindow(Menu);
3266 Menu := TGUIWindow.Create('GameSetGameMenu');
3267 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3268 begin
3269 Name := 'mGameSetGameMenu';
3270 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3271 begin
3272 Name := 'swTeamDamage';
3273 AddItem(_lc[I_MENU_YES]);
3274 AddItem(_lc[I_MENU_NO]);
3275 ItemIndex := 1;
3276 end;
3277 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3278 begin
3279 Name := 'edTimeLimit';
3280 OnlyDigits := True;
3281 Width := 4;
3282 MaxLength := 5;
3283 end;
3284 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3285 begin
3286 Name := 'edGoalLimit';
3287 OnlyDigits := True;
3288 Width := 4;
3289 MaxLength := 5;
3290 end;
3291 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3292 begin
3293 Name := 'edMaxLives';
3294 OnlyDigits := True;
3295 Width := 4;
3296 MaxLength := 5;
3297 end;
3298 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3299 begin
3300 Name := 'swBotsVS';
3301 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3302 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3303 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3304 ItemIndex := 2;
3305 end;
3307 ReAlign();
3308 end;
3309 Menu.DefControl := 'mGameSetGameMenu';
3310 Menu.OnClose := ProcApplyGameSet;
3311 g_GUI_AddWindow(Menu);
3313 Menu := TGUIWindow.Create('TeamMenu');
3314 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3315 begin
3316 Name := 'mmTeamMenu';
3317 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3318 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3319 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3320 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3321 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3322 end;
3323 Menu.DefControl := 'mmTeamMenu';
3324 Menu.OnShow := ProcChangePlayers;
3325 g_GUI_AddWindow(Menu);
3326 end;
3328 procedure g_Menu_Show_SaveMenu();
3329 begin
3330 if g_Game_IsTestMap then
3331 Exit;
3332 if gGameSettings.GameType = GT_SINGLE then
3333 g_GUI_ShowWindow('GameSingleMenu')
3334 else
3335 begin
3336 if g_Game_IsClient then
3337 Exit
3338 else
3339 if g_Game_IsNet then
3340 Exit
3341 else
3342 g_GUI_ShowWindow('GameCustomMenu');
3343 end;
3344 g_GUI_ShowWindow('SaveMenu');
3345 g_Sound_PlayEx('MENU_OPEN');
3346 end;
3348 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3349 begin
3350 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3351 if gGameSettings.GameType = GT_SINGLE then
3352 begin
3353 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3354 end
3355 else
3356 begin
3357 if g_Game_IsClient then exit;
3358 if g_Game_IsNet then exit;
3359 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3360 end;
3361 g_GUI_ShowWindow('LoadMenu');
3362 g_Sound_PlayEx('MENU_OPEN');
3363 end;
3365 procedure g_Menu_Show_GameSetGame();
3366 begin
3367 if gGameSettings.GameType = GT_SINGLE then
3368 g_GUI_ShowWindow('GameSingleMenu')
3369 else
3370 begin
3371 if g_Game_IsClient then
3372 Exit
3373 else
3374 if g_Game_IsNet then
3375 g_GUI_ShowWindow('GameServerMenu')
3376 else
3377 g_GUI_ShowWindow('GameCustomMenu');
3378 end;
3379 ReadGameSettings();
3380 g_GUI_ShowWindow('GameSetGameMenu');
3381 g_Sound_PlayEx('MENU_OPEN');
3382 end;
3384 procedure g_Menu_Show_OptionsVideo();
3385 begin
3386 if gGameSettings.GameType = GT_SINGLE then
3387 g_GUI_ShowWindow('GameSingleMenu')
3388 else
3389 begin
3390 if g_Game_IsClient then
3391 g_GUI_ShowWindow('GameClientMenu')
3392 else
3393 if g_Game_IsNet then
3394 g_GUI_ShowWindow('GameServerMenu')
3395 else
3396 g_GUI_ShowWindow('GameCustomMenu');
3397 end;
3398 ReadOptions();
3399 g_GUI_ShowWindow('OptionsMenu');
3400 g_GUI_ShowWindow('OptionsVideoMenu');
3401 g_Sound_PlayEx('MENU_OPEN');
3402 end;
3404 procedure g_Menu_Show_OptionsSound();
3405 begin
3406 if gGameSettings.GameType = GT_SINGLE then
3407 g_GUI_ShowWindow('GameSingleMenu')
3408 else
3409 begin
3410 if g_Game_IsClient then
3411 g_GUI_ShowWindow('GameClientMenu')
3412 else
3413 if g_Game_IsNet then
3414 g_GUI_ShowWindow('GameServerMenu')
3415 else
3416 g_GUI_ShowWindow('GameCustomMenu');
3417 end;
3418 ReadOptions();
3419 g_GUI_ShowWindow('OptionsMenu');
3420 g_GUI_ShowWindow('OptionsSoundMenu');
3421 g_Sound_PlayEx('MENU_OPEN');
3422 end;
3424 procedure g_Menu_Show_EndGameMenu();
3425 begin
3426 g_GUI_ShowWindow('EndGameMenu');
3427 g_Sound_PlayEx('MENU_OPEN');
3428 end;
3430 procedure g_Menu_Show_QuitGameMenu();
3431 begin
3432 g_GUI_ShowWindow('ExitMenu');
3433 g_Sound_PlayEx('MENU_OPEN');
3434 end;
3436 procedure g_Menu_Init();
3437 begin
3438 MenuLoadData();
3439 g_GUI_Init();
3440 CreateAllMenus();
3441 end;
3443 procedure g_Menu_Free();
3444 begin
3445 g_GUI_Destroy();
3447 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3449 MenuFreeData();
3450 end;
3452 procedure g_Menu_Reset();
3453 var
3454 ex: Boolean;
3455 begin
3456 g_GUI_SaveMenuPos();
3457 ex := g_GUI_Destroy();
3459 if ex then
3460 begin
3461 e_WriteLog('Recreating menu...', TMsgType.Notify);
3463 CreateAllMenus();
3465 if gDebugMode then
3466 g_Game_SetDebugMode();
3468 g_GUI_LoadMenuPos();
3469 end;
3470 end;
3472 end.