DEADSOFTWARE

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