DEADSOFTWARE

game: do not use absolute path in wad selection widgets (it looks ugly, and [almost...
[d2df-sdl.git] / src / game / g_menu.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_menu;
18 interface
20 procedure g_Menu_Init();
21 procedure g_Menu_Free();
22 procedure g_Menu_Reset();
23 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
24 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
25 procedure g_Menu_AskLanguage();
27 procedure g_Menu_Show_SaveMenu();
28 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
29 procedure g_Menu_Show_GameSetGame();
30 procedure g_Menu_Show_OptionsVideo();
31 procedure g_Menu_Show_OptionsSound();
32 procedure g_Menu_Show_EndGameMenu();
33 procedure g_Menu_Show_QuitGameMenu();
35 var
36 gMenuFont: DWORD;
37 gMenuSmallFont: DWORD;
38 PromptIP: string;
39 PromptPort: Word;
40 TempScale: Integer = -1;
42 implementation
44 uses
45 {$INCLUDE ../nogl/noGLuses.inc}
46 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
47 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
48 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
49 MAPDEF, Math, g_saveload,
50 e_texture, g_language, e_res,
51 g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
52 utils, wadreader, g_system;
55 type TYNCallback = procedure (yes:Boolean);
57 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
58 begin
59 if win.UserData = nil then exit;
60 case Key of
61 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
62 IK_N: TYNCallback(win.UserData)(false);
63 end;
64 end;
66 procedure YesButtonCB (ctl: TGUITextButton);
67 begin
68 if ctl.UserData = nil then exit;
69 TYNCallback(ctl.UserData)(true);
70 end;
72 procedure NoButtonCB (ctl: TGUITextButton);
73 begin
74 if ctl.UserData = nil then exit;
75 TYNCallback(ctl.UserData)(false);
76 end;
78 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
79 var
80 menu: TGUIMenu;
81 begin
82 //if length(Text) = 0 then exit;
83 Result := TGUIWindow.Create(WinName);
84 with Result do
85 begin
86 //OnKeyDownEx := @YNKeyDownProc;
87 //UserData := @ActionProc;
88 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
89 with menu do
90 begin
91 Name := '__temp_yes_no_menu:'+WinName;
92 YesNo := true;
93 AddText(Text, MaxLen);
94 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
95 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
96 end;
97 DefControl := '__temp_yes_no_menu:'+WinName;
98 SetActive(nil);
99 end;
100 end;
103 procedure ProcChangeColor(Sender: TGUIControl); forward;
104 procedure ProcSelectModel(Sender: TGUIControl); forward;
106 procedure ProcApplyOptions();
107 var
108 menu: TGUIMenu;
109 i: Integer;
110 ovs: Boolean;
111 s: AnsiString;
112 begin
113 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
115 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
116 gBPP := 16
117 else
118 gBPP := 32;
120 ovs := gVSync;
121 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
122 if (ovs <> gVSync) then
123 sys_EnableVSync(gVSync);
125 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
126 glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
128 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
130 g_Sound_SetupAllVolumes(
131 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
132 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
133 );
135 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
136 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
137 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
138 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
139 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
141 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
143 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
144 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
145 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
146 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
148 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
149 0: gGibsCount := 0;
150 1: gGibsCount := 8;
151 2: gGibsCount := 16;
152 3: gGibsCount := 32;
153 else gGibsCount := 48;
154 end;
156 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
157 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
158 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
159 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
160 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
161 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
162 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
163 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
164 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
165 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex;
166 gPlayerIndicatorStyle := TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')).ItemIndex;
167 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
168 begin
169 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
170 g_dbg_scale := TempScale + 1;
171 end;
173 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
175 with menu do
176 begin
177 g_Console_BindKey(g_Console_FindBind(1, 'screenshot'), '');
178 g_Console_BindKey(g_Console_FindBind(1, '+p1_scores', '-p1_scores'), '');
179 g_Console_BindKey(g_Console_FindBind(1, 'togglechat'), '');
180 g_Console_BindKey(g_Console_FindBind(1, 'toggleteamchat'), '');
181 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key, 'screenshot');
182 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key, '+p1_scores', '-p1_scores');
183 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key, 'togglechat');
184 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key, 'toggleteamchat');
185 end;
187 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
188 with menu do
189 begin
190 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveright', '-p1_moveright'), '');
191 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft'), '');
192 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookup', '-p1_lookup'), '');
193 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown'), '');
194 g_Console_BindKey(g_Console_FindBind(1, '+p1_attack', '-p1_attack'), '');
195 g_Console_BindKey(g_Console_FindBind(1, '+p1_jump', '-p1_jump'), '');
196 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext'), '');
197 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev'), '');
198 g_Console_BindKey(g_Console_FindBind(1, '+p1_activate', '-p1_activate'), '');
199 g_Console_BindKey(g_Console_FindBind(1, '+p1_strafe', '-p1_strafe'), '');
200 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p1_moveright', '-p1_moveright');
201 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p1_moveleft', '-p1_moveleft');
202 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p1_lookup', '-p1_lookup');
203 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p1_lookdown', '-p1_lookdown');
204 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p1_attack', '-p1_attack');
205 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p1_jump', '-p1_jump');
206 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p1_weapnext', '-p1_weapnext');
207 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p1_weapprev', '-p1_weapprev');
208 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p1_activate', '-p1_activate');
209 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p1_strafe', '-p1_strafe');
210 // second set
211 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveright', '-p1_moveright'), '');
212 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft'), '');
213 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookup', '-p1_lookup'), '');
214 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown'), '');
215 g_Console_BindKey(g_Console_FindBind(2, '+p1_attack', '-p1_attack'), '');
216 g_Console_BindKey(g_Console_FindBind(2, '+p1_jump', '-p1_jump'), '');
217 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext'), '');
218 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev'), '');
219 g_Console_BindKey(g_Console_FindBind(2, '+p1_activate', '-p1_activate'), '');
220 g_Console_BindKey(g_Console_FindBind(2, '+p1_strafe', '-p1_strafe'), '');
221 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p1_moveright', '-p1_moveright');
222 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p1_moveleft', '-p1_moveleft');
223 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p1_lookup', '-p1_lookup');
224 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p1_lookdown', '-p1_lookdown');
225 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p1_attack', '-p1_attack');
226 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p1_jump', '-p1_jump');
227 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p1_weapnext', '-p1_weapnext');
228 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p1_weapprev', '-p1_weapprev');
229 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p1_activate', '-p1_activate');
230 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p1_strafe', '-p1_strafe');
231 end;
233 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
234 with menu do
235 begin
236 for i := WP_FIRST to WP_LAST do
237 begin
238 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1)), '');
239 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p1_weapon ' + IntToStr(i + 1));
240 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1)), '');
241 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p1_weapon ' + IntToStr(i + 1));
242 end;
243 end;
245 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
246 with menu do
247 begin
248 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveright', '-p2_moveright'), '');
249 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft'), '');
250 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookup', '-p2_lookup'), '');
251 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown'), '');
252 g_Console_BindKey(g_Console_FindBind(1, '+p2_attack', '-p2_attack'), '');
253 g_Console_BindKey(g_Console_FindBind(1, '+p2_jump', '-p2_jump'), '');
254 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext'), '');
255 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev'), '');
256 g_Console_BindKey(g_Console_FindBind(1, '+p2_activate', '-p2_activate'), '');
257 g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe', '-p2_strafe'), '');
258 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright', '-p2_moveright');
259 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft', '-p2_moveleft');
260 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup', '-p2_lookup');
261 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown', '-p2_lookdown');
262 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack', '-p2_attack');
263 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump', '-p2_jump');
264 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p2_weapnext', '-p2_weapnext');
265 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p2_weapprev', '-p2_weapprev');
266 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate', '-p2_activate');
267 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe', '-p2_strafe');
268 // second set
269 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright', '-p2_moveright'), '');
270 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft'), '');
271 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookup', '-p2_lookup'), '');
272 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown'), '');
273 g_Console_BindKey(g_Console_FindBind(2, '+p2_attack', '-p2_attack'), '');
274 g_Console_BindKey(g_Console_FindBind(2, '+p2_jump', '-p2_jump'), '');
275 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext'), '');
276 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev'), '');
277 g_Console_BindKey(g_Console_FindBind(2, '+p2_activate', '-p2_activate'), '');
278 g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe', '-p2_strafe'), '');
279 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright', '-p2_moveright');
280 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft', '-p2_moveleft');
281 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup', '-p2_lookup');
282 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown', '-p2_lookdown');
283 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack', '-p2_attack');
284 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump', '-p2_jump');
285 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p2_weapnext', '-p2_weapnext');
286 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p2_weapprev', '-p2_weapprev');
287 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate', '-p2_activate');
288 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe', '-p2_strafe');
289 end;
291 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
292 with menu do
293 begin
294 for i := WP_FIRST to WP_LAST do
295 begin
296 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1)), '');
297 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p2_weapon ' + IntToStr(i + 1));
298 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1)), '');
299 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p2_weapon ' + IntToStr(i + 1));
300 end;
301 end;
303 if e_HasJoysticks then
304 begin
305 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
306 with menu do
307 begin
308 for i := 0 to e_MaxJoys - 1 do
309 if e_JoystickAvailable[i] then
310 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20)
311 end
312 end;
314 if g_touch_enabled then
315 begin
316 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
317 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
318 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
319 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
320 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
321 end;
323 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
325 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
326 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
327 TEAM_RED, TEAM_BLUE);
329 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
330 begin
331 gPlayer1Settings.Model := Model.Name;
332 gPlayer1Settings.Color := Model.Color;
333 end;
335 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
337 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
338 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
339 TEAM_RED, TEAM_BLUE);
340 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
341 begin
342 gPlayer2Settings.Model := Model.Name;
343 gPlayer2Settings.Color := Model.Color;
344 end;
346 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
347 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
349 if g_Game_IsServer then
350 begin
351 if gPlayer1 <> nil then
352 begin
353 gPlayer1.SetModel(gPlayer1Settings.Model);
354 gPlayer1.Name := gPlayer1Settings.Name;
355 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
356 gPlayer1.SetColor(gPlayer1Settings.Color)
357 else
358 if gPlayer1.Team <> gPlayer1Settings.Team then
359 gPlayer1.SwitchTeam;
361 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
362 end;
364 if gPlayer2 <> nil then
365 begin
366 gPlayer2.SetModel(gPlayer2Settings.Model);
367 gPlayer2.Name := gPlayer2Settings.Name;
368 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
369 gPlayer2.SetColor(gPlayer2Settings.Color)
370 else
371 if gPlayer2.Team <> gPlayer2Settings.Team then
372 gPlayer2.SwitchTeam;
373 end;
374 end;
376 if g_Game_IsClient then MC_SEND_PlayerSettings;
378 s := e_GetWriteableDir(ConfigDirs);
379 if s <> '' then
380 g_Options_Write(s + '/' + CONFIG_FILENAME);
381 g_Console_WriteGameConfig;
382 end;
384 procedure ReadOptions();
385 var
386 menu: TGUIMenu;
387 i: Integer;
388 begin
389 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
391 with TGUISwitch(menu.GetControl('swBPP')) do
392 if gBPP = 16 then
393 ItemIndex := 0
394 else
395 ItemIndex := 1;
397 with TGUISwitch(menu.GetControl('swTextureFilter')) do
398 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
400 with TGUISwitch(menu.GetControl('swVSync')) do
401 if gVSync then ItemIndex := 0 else ItemIndex := 1;
403 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
404 if not glNPOTOverride then ItemIndex := 0 else ItemIndex := 1;
406 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
408 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
409 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
410 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
412 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
413 if gMuteWhenInactive then
414 ItemIndex := 1
415 else
416 ItemIndex := 0;
418 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
420 with TGUISwitch(menu.GetControl('swSoundEffects')) do
421 if gSoundEffectsDF then
422 ItemIndex := 1
423 else
424 ItemIndex := 0;
426 with TGUISwitch(menu.GetControl('swChatSpeech')) do
427 if gUseChatSounds then
428 ItemIndex := 0
429 else
430 ItemIndex := 1;
432 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
433 with menu do
434 begin
435 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p1_moveright', '-p1_moveright');
436 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft');
437 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p1_lookup', '-p1_lookup');
438 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown');
439 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack', '-p1_attack');
440 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump', '-p1_jump');
441 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext');
442 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev');
443 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate', '-p1_activate');
444 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe', '-p1_strafe');
445 // second set
446 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright', '-p1_moveright');
447 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft');
448 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p1_lookup', '-p1_lookup');
449 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown');
450 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack', '-p1_attack');
451 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump', '-p1_jump');
452 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext');
453 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev');
454 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate', '-p1_activate');
455 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe', '-p1_strafe');
456 end;
458 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
459 with menu do
460 begin
461 for i := WP_FIRST to WP_LAST do
462 begin
463 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1));
464 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1));
465 end;
466 end;
468 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
469 with menu do
470 begin
471 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright', '-p2_moveright');
472 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft');
473 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup', '-p2_lookup');
474 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown');
475 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack', '-p2_attack');
476 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump', '-p2_jump');
477 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext');
478 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev');
479 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate', '-p2_activate');
480 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe', '-p2_strafe');
481 // second set
482 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright', '-p2_moveright');
483 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft');
484 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup', '-p2_lookup');
485 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown');
486 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack', '-p2_attack');
487 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump', '-p2_jump');
488 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext');
489 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev');
490 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate', '-p2_activate');
491 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe', '-p2_strafe');
492 end;
494 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
495 with menu do
496 begin
497 for i := WP_FIRST to WP_LAST do
498 begin
499 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
500 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
501 end;
502 end;
504 if e_HasJoysticks then
505 begin
506 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
507 with menu do
508 begin
509 for i := 0 to e_MaxJoys - 1 do
510 if e_JoystickAvailable[i] then
511 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20)
512 end
513 end;
515 if g_touch_enabled then
516 begin
517 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
518 with TGUISwitch(menu.GetControl('swTouchAlt')) do
519 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
520 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
521 with TGUISwitch(menu.GetControl('swTouchFire')) do
522 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
523 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
524 end;
526 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
527 with menu do
528 begin
529 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
530 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+p1_scores', '-p1_scores');
531 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
532 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
533 end;
535 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
537 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
538 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
539 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
540 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
541 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
543 with TGUISwitch(menu.GetControl('swScreenFlash')) do
544 ItemIndex := gFlash;
546 with TGUISwitch(menu.GetControl('swBloodType')) do
547 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
549 with TGUISwitch(menu.GetControl('swCorpseType')) do
550 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
552 with TGUISwitch(menu.GetControl('swGibsType')) do
553 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
555 with TGUISwitch(menu.GetControl('swGibsCount')) do
556 case gGibsCount of
557 0: ItemIndex := 0;
558 8: ItemIndex := 1;
559 16: ItemIndex := 2;
560 32: ItemIndex := 3;
561 else ItemIndex := 4;
562 end;
564 with TGUISwitch(menu.GetControl('swBackGround')) do
565 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
567 with TGUISwitch(menu.GetControl('swMessages')) do
568 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
570 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
571 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
573 with TGUISwitch(menu.GetControl('swChatBubble')) do
574 ItemIndex := gChatBubble;
576 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
577 ItemIndex := gPlayerIndicator;
579 with TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')) do
580 ItemIndex := gPlayerIndicatorStyle;
582 TempScale := Round(g_dbg_scale - 1);
583 TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
585 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
587 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
588 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
590 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
591 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
593 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
594 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
595 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
597 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
599 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
600 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
602 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
603 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
605 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
606 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
607 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
609 ProcSelectModel(nil);
610 end;
612 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
613 begin
614 // don't turn off monsters in DM
616 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
617 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
618 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
619 else
620 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
623 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
624 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
625 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
626 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
628 end;
630 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
631 begin
632 // don't turn off monsters in DM
634 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
635 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
636 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
637 else
638 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
641 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
642 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
643 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
644 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
646 end;
648 procedure ProcStartCustomGame();
649 var
650 Map: String;
651 GameMode: Byte;
652 Options: LongWord;
653 s: AnsiString;
654 begin
655 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
656 begin
657 Map := TGUILabel(GetControl('lbMap')).Text;
658 if Map = '' then
659 Exit;
660 if not isWadPath(Map) then
661 Exit;
663 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
664 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
665 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
666 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
667 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
669 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
670 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 wad := g_ExtractWadName(gDefaultMegawadStart);
1285 map := g_ExtractFilePathName(gDefaultMegawadStart);
1286 if e_FindResource(AllMapDirs, wad) then
1287 begin
1288 wad := ExpandFileName(wad);
1289 g_Game_StartSingle(wad + ':\' + map, False, n);
1290 end;
1291 end;
1293 procedure ProcSingle1Player;
1294 begin
1295 ProcSinglePlayer(1)
1296 end;
1298 procedure ProcSingle2Players;
1299 begin
1300 ProcSinglePlayer(2)
1301 end;
1303 procedure ProcSelectMapMenu();
1304 var
1305 menu: TGUIMenu;
1306 wad_lb: TGUIFileListBox;
1307 map_lb: TGUIListBox;
1308 map: String;
1309 begin
1310 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1311 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1312 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1314 if wad_lb.SelectedItem() <> '' then
1315 map := map_lb.SelectedItem()
1316 else
1317 map := '';
1319 wad_lb.UpdateFileList();
1320 map_lb.Clear();
1322 if wad_lb.SelectedItem() <> '' then
1323 begin
1324 ProcSelectWAD(nil);
1325 map_lb.SelectItem(map);
1327 if map_lb.SelectedItem() <> '' then
1328 ProcSelectMap(nil);
1329 end;
1331 g_GUI_ShowWindow('SelectMapMenu');
1332 end;
1334 procedure ProcSelectCampaignMenu();
1335 var
1336 menu: TGUIMenu;
1337 wad_lb: TGUIFileListBox;
1338 begin
1339 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1340 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1342 wad_lb.UpdateFileList();
1344 if wad_lb.SelectedItem() <> '' then
1345 ProcSelectCampaignWAD(nil);
1346 end;
1348 procedure ProcSetMap();
1349 var
1350 wad, map, res: String;
1351 begin
1352 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1353 begin
1354 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1355 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1356 end;
1358 if (wad = '') or (map = '') then
1359 Exit;
1361 wad := e_FindWadRel(MapDirs, WAD);
1363 res := wad+':\'+map;
1365 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1366 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1367 end;
1369 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1370 var
1371 menu: TGUIMenu;
1372 begin
1373 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1375 g_Sound_SetupAllVolumes(
1376 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1377 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1378 );
1379 end;
1381 procedure ProcChangeGameSettings(Sender: TGUIControl);
1382 var
1383 menu: TGUIMenu;
1384 begin
1385 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1386 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1387 begin
1388 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1389 g_dbg_scale := TempScale + 1;
1390 end;
1391 end;
1393 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1394 var
1395 menu: TGUIMenu;
1396 begin
1397 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1398 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1399 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1400 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1401 end;
1403 procedure ProcOptionsPlayersMIMenu();
1404 var
1405 s, a: string;
1406 b: TModelInfo;
1407 begin
1408 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1410 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1412 if a = '' then Exit;
1414 b := g_PlayerModel_GetInfo(a);
1416 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1417 begin
1418 TGUILabel(GetControl('lbName')).Text := b.Name;
1419 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1420 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1422 if b.HaveWeapon then
1423 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1424 else
1425 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1426 end;
1428 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1429 end;
1431 procedure ProcOptionsPlayersAnim();
1432 var
1433 s: String;
1434 begin
1435 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1436 s := 'P1'
1437 else
1438 s := 'P2';
1440 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1441 begin
1442 NextAnim();
1443 Model.GetCurrentAnimation.Loop := True;
1444 Model.GetCurrentAnimationMask.Loop := True;
1445 end;
1446 end;
1448 procedure ProcOptionsPlayersWeap();
1449 var
1450 s: String;
1451 begin
1452 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1453 s := 'P1'
1454 else
1455 s := 'P2';
1457 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1458 NextWeapon();
1459 end;
1461 procedure ProcOptionsPlayersRot();
1462 var
1463 s: string;
1464 begin
1465 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1466 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1467 begin
1468 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1469 end;
1470 end;
1472 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1473 begin
1474 if yes then
1475 begin
1476 g_Options_SetDefault();
1477 ReadOptions();
1478 end;
1479 g_GUI_HideWindow();
1480 end;
1482 procedure ProcSavedMenuKeyDown (yes: Boolean);
1483 begin
1484 if yes then ReadOptions();
1485 g_GUI_HideWindow();
1486 end;
1488 procedure ProcAuthorsClose();
1489 begin
1490 gMusic.SetByName('MUSIC_MENU');
1491 gMusic.Play();
1492 gState := STATE_MENU;
1493 end;
1495 procedure ProcGMClose();
1496 begin
1497 g_Game_InGameMenu(False);
1498 end;
1500 procedure ProcGMShow();
1501 var
1502 Enabled: Boolean;
1503 begin
1504 Enabled := True;
1505 if (gGameSettings.GameType = GT_SINGLE) and
1506 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1507 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1508 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1509 if not gGameOn then
1510 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1511 if g_Game_IsTestMap then
1512 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1513 TGUIMainMenu(g_ActiveWindow.GetControl(
1514 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1515 end;
1517 procedure ProcChangePlayers();
1518 var
1519 TeamGame, Spectator, AddTwo: Boolean;
1520 P1Team{, P2Team}: Byte;
1521 bP2: TGUITextButton;
1522 begin
1523 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1524 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1525 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1526 P1Team := TEAM_NONE;
1527 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1528 // TODO
1529 //P2Team := TEAM_NONE;
1530 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1532 TGUIMainMenu(g_ActiveWindow.GetControl(
1533 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1534 TGUIMainMenu(g_ActiveWindow.GetControl(
1535 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1536 TGUIMainMenu(g_ActiveWindow.GetControl(
1537 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1539 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1540 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1541 bP2.Enabled := AddTwo and not Spectator;
1542 if bP2.Enabled then
1543 bP2.Color := MAINMENU_ITEMS_COLOR
1544 else
1545 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1546 if gPlayer2 = nil then
1547 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1548 else
1549 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1551 TGUIMainMenu(g_ActiveWindow.GetControl(
1552 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1553 end;
1555 procedure ProcJoinRed();
1556 begin
1557 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1558 Exit;
1559 if g_Game_IsServer then
1560 begin
1561 if gPlayer1 = nil then
1562 g_Game_AddPlayer(TEAM_RED)
1563 else
1564 begin
1565 if gPlayer1.Team <> TEAM_RED then
1566 begin
1567 gPlayer1.SwitchTeam;
1568 gPlayer1Settings.Team := gPlayer1.Team;
1569 end;
1571 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1572 end;
1573 end
1574 else
1575 begin
1576 gPlayer1Settings.Team := TEAM_RED;
1577 MC_SEND_PlayerSettings;
1578 if gPlayer1 = nil then
1579 g_Game_AddPlayer(TEAM_RED);
1580 end;
1581 g_ActiveWindow := nil;
1582 g_Game_Pause(False);
1583 end;
1585 procedure ProcJoinBlue();
1586 begin
1587 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1588 Exit;
1589 if g_Game_IsServer then
1590 begin
1591 if gPlayer1 = nil then
1592 g_Game_AddPlayer(TEAM_BLUE)
1593 else
1594 begin
1595 if gPlayer1.Team <> TEAM_BLUE then
1596 begin
1597 gPlayer1.SwitchTeam;
1598 gPlayer1Settings.Team := gPlayer1.Team;
1599 end;
1601 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1602 end;
1603 end
1604 else
1605 begin
1606 gPlayer1Settings.Team := TEAM_BLUE;
1607 MC_SEND_PlayerSettings;
1608 if gPlayer1 = nil then
1609 g_Game_AddPlayer(TEAM_BLUE);
1610 end;
1611 g_ActiveWindow := nil;
1612 g_Game_Pause(False);
1613 end;
1615 procedure ProcJoinGame();
1616 begin
1617 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1618 Exit;
1619 if gPlayer1 = nil then
1620 g_Game_AddPlayer();
1621 g_ActiveWindow := nil;
1622 g_Game_Pause(False);
1623 end;
1625 procedure ProcSwitchP2();
1626 begin
1627 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1628 Exit;
1629 if gPlayer1 = nil then
1630 Exit;
1631 if gPlayer2 = nil then
1632 g_Game_AddPlayer()
1633 else
1634 g_Game_RemovePlayer();
1635 g_ActiveWindow := nil;
1636 g_Game_Pause(False);
1637 end;
1639 procedure ProcSpectate();
1640 begin
1641 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1642 Exit;
1643 g_Game_Spectate();
1644 g_ActiveWindow := nil;
1645 g_Game_Pause(False);
1646 end;
1648 procedure ProcRestartMenuKeyDown (yes: Boolean);
1649 begin
1650 if yes then g_Game_Restart() else g_GUI_HideWindow;
1651 end;
1653 procedure ProcEndMenuKeyDown (yes: Boolean);
1654 begin
1655 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1656 end;
1658 procedure ProcSetRussianLanguage;
1659 var s: AnsiString;
1660 begin
1661 if gLanguage <> LANGUAGE_RUSSIAN then
1662 begin
1663 gLanguage := LANGUAGE_RUSSIAN;
1664 gLanguageChange := True;
1665 gAskLanguage := False;
1667 s := e_GetWriteableDir(ConfigDirs);
1668 if s <> '' then
1669 g_Options_Write_Language(s + '/' + CONFIG_FILENAME);
1671 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1672 ProcApplyOptions();
1673 end;
1674 end;
1676 procedure ProcSetEnglishLanguage;
1677 var s: AnsiString;
1678 begin
1679 if gLanguage <> LANGUAGE_ENGLISH then
1680 begin
1681 gLanguage := LANGUAGE_ENGLISH;
1682 gLanguageChange := True;
1683 gAskLanguage := False;
1685 s := e_GetWriteableDir(ConfigDirs);
1686 if s <> '' then
1687 g_Options_Write_Language(s + '/' + CONFIG_FILENAME);
1689 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1690 ProcApplyOptions();
1691 end;
1692 end;
1694 procedure ReadGameSettings();
1695 var
1696 menu: TGUIMenu;
1697 begin
1698 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1700 with gGameSettings do
1701 begin
1702 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1703 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1704 ItemIndex := 0
1705 else
1706 ItemIndex := 1;
1708 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1709 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1710 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1712 with TGUISwitch(menu.GetControl('swBotsVS')) do
1713 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1714 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1715 ItemIndex := 2
1716 else
1717 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1718 ItemIndex := 1
1719 else
1720 ItemIndex := 0;
1722 if GameType in [GT_CUSTOM, GT_SERVER] then
1723 begin
1724 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1725 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1726 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1727 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1728 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1729 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1730 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1731 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1732 end
1733 else
1734 begin
1735 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1736 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1737 begin
1738 Enabled := False;
1739 Text := '';
1740 end;
1741 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1742 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1743 begin
1744 Enabled := False;
1745 Text := '';
1746 end;
1747 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1748 with TGUIEdit(menu.GetControl('edMaxLives')) do
1749 begin
1750 Enabled := False;
1751 Text := '';
1752 end;
1753 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1754 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1755 end;
1756 end;
1757 end;
1759 procedure ProcApplyGameSet();
1760 var
1761 menu: TGUIMenu;
1762 a, b, n: Integer;
1763 stat: TPlayerStatArray;
1764 begin
1765 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1767 if not g_Game_IsServer then Exit;
1769 with gGameSettings do
1770 begin
1771 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1772 begin
1773 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1774 Options := Options or GAME_OPTION_TEAMDAMAGE
1775 else
1776 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1777 end;
1779 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1780 begin
1781 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1783 if n = 0 then
1784 TimeLimit := 0
1785 else
1786 begin
1787 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1789 TimeLimit := Max(n, b);
1790 end;
1791 end;
1793 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1794 begin
1795 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1797 if n = 0 then
1798 GoalLimit := 0
1799 else
1800 begin
1801 b := 0;
1802 if GameMode = GM_DM then
1803 begin // DM
1804 stat := g_Player_GetStats();
1805 if stat <> nil then
1806 for a := 0 to High(stat) do
1807 if stat[a].Frags > b then
1808 b := stat[a].Frags;
1809 end
1810 else // CTF
1811 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1813 GoalLimit := Max(n, b);
1814 end;
1815 end;
1817 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1818 begin
1819 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1820 if n < 0 then n := 0;
1821 if n > 255 then n := 255;
1822 if n = 0 then
1823 MaxLives := 0
1824 else
1825 begin
1826 b := 0;
1827 stat := g_Player_GetStats();
1828 if stat <> nil then
1829 for a := 0 to High(stat) do
1830 if stat[a].Lives > b then
1831 b := stat[a].Lives;
1833 MaxLives := Max(n, b);
1834 end;
1835 end;
1837 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1838 begin
1839 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1840 1:
1841 begin
1842 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1843 Options := Options or GAME_OPTION_BOTVSMONSTER;
1844 end;
1845 2:
1846 begin
1847 Options := Options or GAME_OPTION_BOTVSPLAYER;
1848 Options := Options or GAME_OPTION_BOTVSMONSTER;
1849 end;
1850 else
1851 begin
1852 Options := Options or GAME_OPTION_BOTVSPLAYER;
1853 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1854 end;
1855 end;
1856 end;
1857 end;
1859 if g_Game_IsNet then MH_SEND_GameSettings;
1860 end;
1862 procedure ProcVideoOptionsRes();
1863 var
1864 menu: TGUIMenu;
1865 list: SSArray;
1866 begin
1867 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1869 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1870 IntToStr(gScreenWidth) +
1871 ' x ' + IntToStr(gScreenHeight) +
1872 ', ' + IntToStr(gBPP) + ' bpp';
1874 with TGUIListBox(menu.GetControl('lsResolution')) do
1875 begin
1876 list := sys_GetDispalyModes(gBPP);
1877 if list <> nil then
1878 begin
1879 Items := list;
1880 ItemIndex := Length(list)
1881 end
1882 else
1883 begin
1884 Clear
1885 end
1886 end;
1888 with TGUISwitch(menu.GetControl('swFullScreen')) do
1889 if gFullscreen then
1890 ItemIndex := 0
1891 else
1892 ItemIndex := 1;
1893 end;
1895 procedure ProcApplyVideoOptions();
1896 var
1897 menu: TGUIMenu;
1898 Fullscreen: Boolean;
1899 SWidth, SHeight: Integer;
1900 str: String;
1901 begin
1902 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1904 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1905 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1907 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1909 if (SWidth <> gScreenWidth) or
1910 (SHeight <> gScreenHeight) or
1911 (Fullscreen <> gFullscreen) then
1912 begin
1913 gResolutionChange := True;
1914 gRC_Width := SWidth;
1915 gRC_Height := SHeight;
1916 gRC_FullScreen := Fullscreen;
1917 gRC_Maximized := gWinMaximized;
1918 end;
1920 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1921 ProcApplyOptions();
1922 end;
1924 procedure ProcSetFirstRussianLanguage;
1925 var s: AnsiString;
1926 begin
1927 gLanguage := LANGUAGE_RUSSIAN;
1928 gLanguageChange := True;
1929 gAskLanguage := False;
1931 s := e_GetWriteableDir(ConfigDirs);
1932 if s <> '' then
1933 g_Options_Write_Language(s + '/' + CONFIG_FILENAME)
1934 end;
1936 procedure ProcSetFirstEnglishLanguage;
1937 var s: AnsiString;
1938 begin
1939 gLanguage := LANGUAGE_ENGLISH;
1940 gLanguageChange := True;
1941 gAskLanguage := False;
1943 s := e_GetWriteableDir(ConfigDirs);
1944 if s <> '' then
1945 g_Options_Write_Language(s + '/' + CONFIG_FILENAME)
1946 end;
1948 procedure ProcRecallAddress();
1949 begin
1950 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1951 begin
1952 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1953 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1954 end;
1955 end;
1957 procedure CreateFirstLanguageMenu();
1958 var
1959 Menu: TGUIWindow;
1960 begin
1961 Menu := TGUIWindow.Create('FirstLanguageMenu');
1963 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1964 begin
1965 Name := 'mmFirstLanguageMenu';
1966 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1967 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1968 end;
1970 Menu.DefControl := 'mmFirstLanguageMenu';
1971 Menu.MainWindow := True;
1972 g_GUI_AddWindow(Menu);
1973 end;
1975 procedure g_Menu_AskLanguage();
1976 begin
1977 CreateFirstLanguageMenu();
1978 g_GUI_ShowWindow('FirstLanguageMenu');
1979 end;
1981 procedure CreatePlayerOptionsMenu(s: String);
1982 var
1983 Menu: TGUIWindow;
1984 a: String;
1985 begin
1986 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1987 if s = 'P1' then
1988 a := _lc[I_MENU_PLAYER_1]
1989 else
1990 a := _lc[I_MENU_PLAYER_2];
1991 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1992 begin
1993 Name := 'mOptionsPlayers'+s+'Menu';
1994 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1995 begin
1996 Name := 'ed'+s+'Name';
1997 MaxLength := 12;
1998 Width := 12;
1999 end;
2000 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2001 begin
2002 Name := 'sw'+s+'Team';
2003 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2004 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2005 end ;
2006 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2007 begin
2008 Name := 'ls'+s+'Model';
2009 Sort := True;
2010 Items := g_PlayerModel_GetNames();
2011 OnChange := ProcSelectModel;
2012 end;
2013 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2014 begin
2015 Name := 'sc'+s+'Red';
2016 Max := 16;
2017 OnChange := ProcChangeColor;
2018 end;
2019 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2020 begin
2021 Name := 'sc'+s+'Green';
2022 Max := 16;
2023 OnChange := ProcChangeColor;
2024 end;
2025 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2026 begin
2027 Name := 'sc'+s+'Blue';
2028 Max := 16;
2029 OnChange := ProcChangeColor;
2030 end;
2031 AddSpace();
2032 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2033 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2034 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2035 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2037 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2038 begin
2039 Name := 'mv'+s+'Model';
2040 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2041 Y := GetControl('ls'+s+'Model').Y;
2042 end;
2043 end;
2044 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2045 g_GUI_AddWindow(Menu);
2046 end;
2048 procedure CreateAllMenus();
2049 var
2050 Menu: TGUIWindow;
2051 //SR: TSearchRec;
2052 a, cx, _y, i: Integer;
2053 //list: SSArray;
2054 begin
2055 Menu := TGUIWindow.Create('MainMenu');
2056 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2057 begin
2058 Name := 'mmMainMenu';
2059 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2060 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2061 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2062 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2063 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2064 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2065 end;
2066 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2067 begin
2068 Color := _RGB(255, 255, 255);
2069 X := gScreenWidth-GetWidth-8;
2070 Y := gScreenHeight-GetHeight-8;
2071 end;
2072 Menu.DefControl := 'mmMainMenu';
2073 Menu.MainWindow := True;
2074 g_GUI_AddWindow(Menu);
2076 Menu := TGUIWindow.Create('NewGameMenu');
2077 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2078 begin
2079 Name := 'mmNewGameMenu';
2080 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2081 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2082 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2083 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2084 end;
2085 Menu.DefControl := 'mmNewGameMenu';
2086 g_GUI_AddWindow(Menu);
2088 Menu := TGUIWindow.Create('NetGameMenu');
2089 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2090 begin
2091 Name := 'mmNetGameMenu';
2092 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2093 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2094 end;
2095 Menu.DefControl := 'mmNetGameMenu';
2096 g_GUI_AddWindow(Menu);
2098 Menu := TGUIWindow.Create('NetServerMenu');
2099 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2100 begin
2101 Name := 'mNetServerMenu';
2102 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2103 begin
2104 Name := 'edSrvName';
2105 OnlyDigits := False;
2106 Width := 16;
2107 MaxLength := 64;
2108 Text := NetServerName;
2109 end;
2110 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2111 begin
2112 Name := 'edSrvPassword';
2113 OnlyDigits := False;
2114 Width := 16;
2115 MaxLength := 24;
2116 Text := NetPassword;
2117 end;
2118 with AddEdit(_lc[I_NET_PORT]) do
2119 begin
2120 Name := 'edPort';
2121 OnlyDigits := True;
2122 Width := 4;
2123 MaxLength := 5;
2124 Text := IntToStr(NetPort);
2125 end;
2126 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2127 begin
2128 Name := 'edMaxPlayers';
2129 OnlyDigits := True;
2130 Width := 4;
2131 MaxLength := 2;
2132 Text := IntToStr(NetMaxClients);
2133 end;
2134 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2135 begin
2136 Name := 'swUseMaster';
2137 AddItem(_lc[I_MENU_YES]);
2138 AddItem(_lc[I_MENU_NO]);
2139 if NetUseMaster then
2140 ItemIndex := 0
2141 else
2142 ItemIndex := 1;
2143 end;
2144 AddSpace();
2145 with AddLabel(_lc[I_MENU_MAP]) do
2146 begin
2147 Name := 'lbMap';
2148 FixedLength := 16;
2149 Text := gnMap;
2150 OnClick := @ProcSelectMapMenu;
2151 end;
2152 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2153 begin
2154 Name := 'swGameMode';
2155 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2156 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2157 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2158 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2159 case g_Game_TextToMode(gnGameMode) of
2160 GM_NONE,
2161 GM_DM: ItemIndex := 0;
2162 GM_TDM: ItemIndex := 1;
2163 GM_CTF: ItemIndex := 2;
2164 GM_SINGLE,
2165 GM_COOP: ItemIndex := 3;
2166 end;
2167 OnChange := ProcSwitchMonstersNet;
2168 end;
2169 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2170 begin
2171 Name := 'edTimeLimit';
2172 OnlyDigits := True;
2173 Width := 4;
2174 MaxLength := 5;
2175 if gnTimeLimit > 0 then
2176 Text := IntToStr(gnTimeLimit);
2177 end;
2178 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2179 begin
2180 Name := 'edGoalLimit';
2181 OnlyDigits := True;
2182 Width := 4;
2183 MaxLength := 5;
2184 if gnGoalLimit > 0 then
2185 Text := IntToStr(gnGoalLimit);
2186 end;
2187 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2188 begin
2189 Name := 'edMaxLives';
2190 OnlyDigits := True;
2191 Width := 4;
2192 MaxLength := 3;
2193 if gnMaxLives > 0 then
2194 Text := IntToStr(gnMaxLives);
2195 end;
2196 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2197 begin
2198 Name := 'swPlayers';
2199 AddItem(_lc[I_MENU_COUNT_NONE]);
2200 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2201 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2202 ItemIndex := gnPlayers;
2203 end;
2204 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2205 begin
2206 Name := 'swTeamDamage';
2207 AddItem(_lc[I_MENU_YES]);
2208 AddItem(_lc[I_MENU_NO]);
2209 if gnTeamDamage then
2210 ItemIndex := 0
2211 else
2212 ItemIndex := 1;
2213 end;
2214 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2215 begin
2216 Name := 'swEnableExits';
2217 AddItem(_lc[I_MENU_YES]);
2218 AddItem(_lc[I_MENU_NO]);
2219 if gnAllowExit then
2220 ItemIndex := 0
2221 else
2222 ItemIndex := 1;
2223 end;
2224 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2225 begin
2226 Name := 'swWeaponStay';
2227 AddItem(_lc[I_MENU_YES]);
2228 AddItem(_lc[I_MENU_NO]);
2229 if gnWeaponStay then
2230 ItemIndex := 0
2231 else
2232 ItemIndex := 1;
2233 end;
2234 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2235 begin
2236 Name := 'swMonsters';
2237 AddItem(_lc[I_MENU_YES]);
2238 AddItem(_lc[I_MENU_NO]);
2239 if gnMonsters then
2240 ItemIndex := 0
2241 else
2242 ItemIndex := 1;
2243 end;
2244 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2245 begin
2246 Name := 'swBotsVS';
2247 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2248 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2249 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2250 ItemIndex := 2;
2251 if gnBotsVS = 'Players' then
2252 ItemIndex := 0;
2253 if gnBotsVS = 'Monsters' then
2254 ItemIndex := 1;
2255 end;
2256 AddSpace();
2257 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2259 ReAlign();
2260 end;
2261 Menu.DefControl := 'mNetServerMenu';
2262 g_GUI_AddWindow(Menu);
2264 Menu := TGUIWindow.Create('NetClientMenu');
2265 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2266 begin
2267 Name := 'mNetClientMenu';
2269 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2270 AddSpace();
2272 with AddEdit(_lc[I_NET_ADDRESS]) do
2273 begin
2274 Name := 'edIP';
2275 OnlyDigits :=False;
2276 Width := 12;
2277 MaxLength := 64;
2278 Text := 'localhost';
2279 end;
2280 with AddEdit(_lc[I_NET_PORT]) do
2281 begin
2282 Name := 'edPort';
2283 OnlyDigits := True;
2284 Width := 4;
2285 MaxLength := 5;
2286 Text := '25666';
2287 end;
2288 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2289 begin
2290 Name := 'edPW';
2291 OnlyDigits := False;
2292 Width := 12;
2293 MaxLength := 32;
2294 Text := '';
2295 end;
2297 AddSpace();
2298 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2300 ReAlign();
2301 end;
2302 Menu.DefControl := 'mNetClientMenu';
2303 g_GUI_AddWindow(Menu);
2305 Menu := TGUIWindow.Create('LoadMenu');
2306 Menu.OnShow := ProcLoadMenu;
2307 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2308 begin
2309 Name := 'mmLoadMenu';
2311 for a := 1 to 8 do
2312 with AddEdit('') do
2313 begin
2314 Name := 'edSlot'+IntToStr(a);
2315 Width := 16;
2316 MaxLength := 16;
2317 OnEnter := ProcLoadGame;
2318 end;
2319 end;
2320 Menu.DefControl := 'mmLoadMenu';
2321 g_GUI_AddWindow(Menu);
2323 Menu := TGUIWindow.Create('SaveMenu');
2324 Menu.OnShow := ProcSaveMenu;
2325 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2326 begin
2327 Name := 'mmSaveMenu';
2329 for a := 1 to 8 do
2330 with AddEdit('') do
2331 begin
2332 Name := 'edSlot'+IntToStr(a);
2333 Width := 16;
2334 MaxLength := 16;
2335 OnChange := ProcSaveGame;
2336 end;
2337 end;
2338 Menu.DefControl := 'mmSaveMenu';
2339 g_GUI_AddWindow(Menu);
2341 Menu := TGUIWindow.Create('CustomGameMenu');
2342 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2343 begin
2344 Name := 'mCustomGameMenu';
2345 with AddLabel(_lc[I_MENU_MAP]) do
2346 begin
2347 Name := 'lbMap';
2348 FixedLength := 16;
2349 Text := gcMap;
2350 OnClick := @ProcSelectMapMenu;
2351 end;
2352 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2353 begin
2354 Name := 'swGameMode';
2355 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2356 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2357 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2358 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2359 case g_Game_TextToMode(gcGameMode) of
2360 GM_NONE,
2361 GM_DM: ItemIndex := 0;
2362 GM_TDM: ItemIndex := 1;
2363 GM_CTF: ItemIndex := 2;
2364 GM_SINGLE,
2365 GM_COOP: ItemIndex := 3;
2366 end;
2367 OnChange := ProcSwitchMonstersCustom;
2368 end;
2369 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2370 begin
2371 Name := 'edTimeLimit';
2372 OnlyDigits := True;
2373 Width := 4;
2374 MaxLength := 5;
2375 if gcTimeLimit > 0 then
2376 Text := IntToStr(gcTimeLimit);
2377 end;
2378 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2379 begin
2380 Name := 'edGoalLimit';
2381 OnlyDigits := True;
2382 Width := 4;
2383 MaxLength := 5;
2384 if gcGoalLimit > 0 then
2385 Text := IntToStr(gcGoalLimit);
2386 end;
2387 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2388 begin
2389 Name := 'edMaxLives';
2390 OnlyDigits := True;
2391 Width := 4;
2392 MaxLength := 5;
2393 if gcMaxLives > 0 then
2394 Text := IntToStr(gcMaxLives);
2395 end;
2396 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2397 begin
2398 Name := 'swPlayers';
2399 AddItem(_lc[I_MENU_COUNT_NONE]);
2400 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2401 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2402 ItemIndex := gcPlayers;
2403 end;
2404 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2405 begin
2406 Name := 'swTeamDamage';
2407 AddItem(_lc[I_MENU_YES]);
2408 AddItem(_lc[I_MENU_NO]);
2409 if gcTeamDamage then
2410 ItemIndex := 0
2411 else
2412 ItemIndex := 1;
2413 end;
2414 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2415 begin
2416 Name := 'swEnableExits';
2417 AddItem(_lc[I_MENU_YES]);
2418 AddItem(_lc[I_MENU_NO]);
2419 if gcAllowExit then
2420 ItemIndex := 0
2421 else
2422 ItemIndex := 1;
2423 end;
2424 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2425 begin
2426 Name := 'swWeaponStay';
2427 AddItem(_lc[I_MENU_YES]);
2428 AddItem(_lc[I_MENU_NO]);
2429 if gcWeaponStay then
2430 ItemIndex := 0
2431 else
2432 ItemIndex := 1;
2433 end;
2434 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2435 begin
2436 Name := 'swMonsters';
2437 AddItem(_lc[I_MENU_YES]);
2438 AddItem(_lc[I_MENU_NO]);
2439 if gcMonsters then
2440 ItemIndex := 0
2441 else
2442 ItemIndex := 1;
2443 end;
2444 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2445 begin
2446 Name := 'swBotsVS';
2447 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2448 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2449 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2450 ItemIndex := 2;
2451 if gcBotsVS = 'Players' then
2452 ItemIndex := 0;
2453 if gcBotsVS = 'Monsters' then
2454 ItemIndex := 1;
2455 end;
2456 AddSpace();
2457 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2459 ReAlign();
2460 end;
2461 Menu.DefControl := 'mCustomGameMenu';
2462 g_GUI_AddWindow(Menu);
2464 Menu := TGUIWindow.Create('CampaignMenu');
2465 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2466 begin
2467 Name := 'mCampaignMenu';
2469 AddSpace();
2470 AddSpace();
2471 AddSpace();
2472 AddSpace();
2473 AddSpace();
2474 AddSpace();
2476 with AddFileList('', 15, 4) do
2477 begin
2478 Name := 'lsWAD';
2479 OnChange := ProcSelectCampaignWAD;
2481 Sort := True;
2482 Dirs := True;
2483 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2484 SetBase(MegawadDirs);
2485 end;
2487 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2488 begin
2489 Name := 'lbWADName';
2490 FixedLength := 8;
2491 Enabled := False;
2492 end;
2493 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2494 begin
2495 Name := 'lbWADAuthor';
2496 FixedLength := 8;
2497 Enabled := False;
2498 end;
2499 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2500 with AddMemo('', 15, 3) do
2501 begin
2502 Name := 'meWADDescription';
2503 Color := MENU_ITEMSCTRL_COLOR;
2504 end;
2505 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2506 begin
2507 Name := 'swPlayers';
2508 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2509 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2510 end;
2511 AddSpace();
2512 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2514 ReAlign();
2516 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2517 begin
2518 Name := 'mpWADImage';
2519 DefaultRes := 'NOPIC';
2520 X := GetControl('lsWAD').X+4;
2521 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2522 end;
2523 end;
2524 Menu.DefControl := 'mCampaignMenu';
2525 g_GUI_AddWindow(Menu);
2527 Menu := TGUIWindow.Create('SelectMapMenu');
2528 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2529 begin
2530 Name := 'mSelectMapMenu';
2531 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2532 begin
2533 Name := 'lsMapWAD';
2534 OnChange := ProcSelectWAD;
2536 Sort := True;
2537 Dirs := True;
2538 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2539 SetBase(MapDirs);
2540 end;
2541 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2542 begin
2543 Name := 'lsMapRes';
2544 Sort := True;
2545 OnChange := ProcSelectMap;
2546 end;
2547 AddSpace();
2548 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2549 begin
2550 Name := 'lbMapName';
2551 FixedLength := 24;
2552 Enabled := False;
2553 end;
2554 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2555 begin
2556 Name := 'lbMapAuthor';
2557 FixedLength := 16;
2558 Enabled := False;
2559 end;
2560 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2561 begin
2562 Name := 'lbMapSize';
2563 FixedLength := 10;
2564 Enabled := False;
2565 end;
2566 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2567 begin
2568 Name := 'meMapDescription';
2569 end;
2571 ReAlign();
2573 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2574 begin
2575 Name := 'mpMapPreview';
2576 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2577 Y := GetControl('lsMapWAD').Y;
2578 end;
2579 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2580 begin
2581 Name := 'lbMapScale';
2582 FixedLength := 8;
2583 Enabled := False;
2584 Color := MENU_ITEMSCTRL_COLOR;
2585 X := GetControl('lsMapWAD').X +
2586 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2587 2 + MAPPREVIEW_WIDTH*4;
2588 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2589 end;
2590 end;
2591 Menu.OnClose := ProcSetMap;
2592 Menu.DefControl := 'mSelectMapMenu';
2593 g_GUI_AddWindow(Menu);
2595 Menu := TGUIWindow.Create('OptionsMenu');
2596 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2597 begin
2598 Name := 'mmOptionsMenu';
2599 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2600 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2601 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2602 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2603 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2604 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2605 AddSpace();
2606 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2607 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2608 end;
2609 Menu.OnClose := ProcApplyOptions;
2610 Menu.DefControl := 'mmOptionsMenu';
2611 g_GUI_AddWindow(Menu);
2613 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2614 gMenuSmallFont, @ProcSavedMenuKeyDown);
2615 g_GUI_AddWindow(Menu);
2617 Menu := TGUIWindow.Create('OptionsVideoMenu');
2618 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2619 begin
2620 Name := 'mOptionsVideoMenu';
2621 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2622 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2623 begin
2624 Name := 'swBPP';
2625 AddItem('16');
2626 AddItem('32');
2627 end;
2628 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2629 begin
2630 Name := 'swVSync';
2631 AddItem(_lc[I_MENU_YES]);
2632 AddItem(_lc[I_MENU_NO]);
2633 end;
2634 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2635 begin
2636 Name := 'swTextureFilter';
2637 AddItem(_lc[I_MENU_YES]);
2638 AddItem(_lc[I_MENU_NO]);
2639 end;
2640 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2641 begin
2642 Name := 'swLegacyNPOT';
2643 AddItem(_lc[I_MENU_NO]);
2644 AddItem(_lc[I_MENU_YES]);
2645 end;
2646 AddSpace();
2647 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2648 ReAlign();
2649 end;
2650 Menu.DefControl := 'mOptionsVideoMenu';
2651 g_GUI_AddWindow(Menu);
2653 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2654 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2655 begin
2656 Name := 'mOptionsVideoResMenu';
2657 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2658 begin
2659 Name := 'lbCurrentRes';
2660 FixedLength := 24;
2661 Enabled := False;
2662 end;
2663 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2664 begin
2665 Name := 'lsResolution';
2666 Sort := False;
2667 end;
2668 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2669 begin
2670 Name := 'swFullScreen';
2671 AddItem(_lc[I_MENU_YES]);
2672 AddItem(_lc[I_MENU_NO]);
2673 end;
2674 AddSpace();
2675 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2676 UpdateIndex();
2677 end;
2678 Menu.DefControl := 'mOptionsVideoResMenu';
2679 g_GUI_AddWindow(Menu);
2681 Menu := TGUIWindow.Create('OptionsSoundMenu');
2682 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2683 begin
2684 Name := 'mOptionsSoundMenu';
2685 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2686 begin
2687 Name := 'scMusicLevel';
2688 Max := 16;
2689 OnChange := ProcChangeSoundSettings;
2690 end;
2691 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2692 begin
2693 Name := 'scSoundLevel';
2694 Max := 16;
2695 OnChange := ProcChangeSoundSettings;
2696 end;
2697 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2698 begin
2699 Name := 'scMaxSimSounds';
2700 Max := 16;
2701 end;
2702 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2703 begin;
2704 Name := 'swAnnouncer';
2705 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2706 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2707 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2708 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2709 end;
2710 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2711 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2712 begin;
2713 Name := 'swSoundEffects';
2714 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2715 AddItem(_lc[I_MENU_COMPAT_DF]);
2716 end;
2717 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2718 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2719 begin;
2720 Name := 'swChatSpeech';
2721 AddItem(_lc[I_MENU_YES]);
2722 AddItem(_lc[I_MENU_NO]);
2723 end;
2724 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2725 begin
2726 Name := 'swInactiveSounds';
2727 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2728 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2729 end;
2730 ReAlign();
2731 end;
2732 Menu.DefControl := 'mOptionsSoundMenu';
2733 g_GUI_AddWindow(Menu);
2735 Menu := TGUIWindow.Create('OptionsGameMenu');
2736 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2737 begin
2738 Name := 'mOptionsGameMenu';
2739 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2740 begin
2741 Name := 'scParticlesCount';
2742 Max := 20;
2743 end;
2744 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2745 begin
2746 Name := 'swBloodCount';
2747 AddItem(_lc[I_MENU_COUNT_NONE]);
2748 AddItem(_lc[I_MENU_COUNT_SMALL]);
2749 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2750 AddItem(_lc[I_MENU_COUNT_BIG]);
2751 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2752 end;
2753 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2754 begin
2755 Name := 'scShellsMax';
2756 Max := 20;
2757 end;
2758 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2759 begin
2760 Name := 'scGibsMax';
2761 Max := 20;
2762 end;
2763 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2764 begin
2765 Name := 'scCorpsesMax';
2766 Max := 20;
2767 end;
2768 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2769 begin
2770 Name := 'swGibsCount';
2771 AddItem(_lc[I_MENU_COUNT_NONE]);
2772 AddItem(_lc[I_MENU_COUNT_SMALL]);
2773 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2774 AddItem(_lc[I_MENU_COUNT_BIG]);
2775 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2776 end;
2777 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2778 begin
2779 Name := 'swCorpseType';
2780 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2781 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2782 end;
2783 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2784 begin
2785 Name := 'swGibsType';
2786 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2787 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2788 end;
2789 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2790 begin
2791 Name := 'swBloodType';
2792 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2793 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2794 end;
2795 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2796 begin
2797 Name := 'swScreenFlash';
2798 AddItem(_lc[I_MENU_NO]);
2799 AddItem(_lc[I_MENU_COMPAT_DF]);
2800 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2801 end;
2802 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2803 begin
2804 Name := 'swBackground';
2805 AddItem(_lc[I_MENU_YES]);
2806 AddItem(_lc[I_MENU_NO]);
2807 end;
2808 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2809 begin
2810 Name := 'swMessages';
2811 AddItem(_lc[I_MENU_YES]);
2812 AddItem(_lc[I_MENU_NO]);
2813 end;
2814 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2815 begin
2816 Name := 'swRevertPlayers';
2817 AddItem(_lc[I_MENU_YES]);
2818 AddItem(_lc[I_MENU_NO]);
2819 end;
2820 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2821 begin
2822 Name := 'swChatBubble';
2823 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2824 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2825 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2826 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2827 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2828 end;
2829 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2830 begin
2831 Name := 'swPlayerIndicator';
2832 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2833 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2834 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2835 end;
2836 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2837 begin
2838 Name := 'swPlayerIndicatorStyle';
2839 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2840 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2841 end;
2842 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2843 begin
2844 Name := 'scScaleFactor';
2845 Max := 10;
2846 OnChange := ProcChangeGameSettings;
2847 end;
2848 ReAlign();
2849 end;
2850 Menu.DefControl := 'mOptionsGameMenu';
2851 g_GUI_AddWindow(Menu);
2853 Menu := TGUIWindow.Create('OptionsControlsMenu');
2854 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2855 begin
2856 Name := 'mOptionsControlsMenu';
2857 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2858 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2859 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2860 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2861 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2862 AddSpace();
2863 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2864 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2865 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2866 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2867 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2868 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2869 if e_HasJoysticks then
2870 begin
2871 AddSpace();
2872 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2873 end;
2874 if g_touch_enabled then
2875 begin
2876 AddSpace();
2877 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2878 end;
2879 end;
2880 Menu.DefControl := 'mOptionsControlsMenu';
2881 g_GUI_AddWindow(Menu);
2883 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2884 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2885 begin
2886 Name := 'mOptionsControlsP1Menu';
2887 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2888 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2889 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2890 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2891 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2892 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2893 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2894 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2895 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2896 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2897 end;
2898 Menu.DefControl := 'mOptionsControlsP1Menu';
2899 g_GUI_AddWindow(Menu);
2901 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2902 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2903 begin
2904 Name := 'mOptionsControlsP1MenuWeapons';
2905 for i := WP_FIRST to WP_LAST do
2906 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2907 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2908 end;
2909 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2910 g_GUI_AddWindow(Menu);
2912 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2913 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2914 begin
2915 Name := 'mOptionsControlsP2Menu';
2916 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2917 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2918 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2919 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2920 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2921 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2922 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2923 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2924 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2925 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2926 end;
2927 Menu.DefControl := 'mOptionsControlsP2Menu';
2928 g_GUI_AddWindow(Menu);
2930 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2931 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2932 begin
2933 Name := 'mOptionsControlsP2MenuWeapons';
2934 for i := WP_FIRST to WP_LAST do
2935 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2936 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2937 end;
2938 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2939 g_GUI_AddWindow(Menu);
2941 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2942 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2943 begin
2944 Name := 'mOptionsControlsJoystickMenu';
2945 for i := 0 to e_MaxJoys - 1 do
2946 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2947 begin
2948 Name := 'scDeadzone' + IntToStr(i);
2949 Max := 20
2950 end
2951 end;
2952 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2953 g_GUI_AddWindow(Menu);
2955 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2956 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2957 begin
2958 Name := 'mOptionsControlsTouchMenu';
2959 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2960 begin
2961 Name := 'swTouchAlt';
2962 AddItem(_lc[I_MENU_NO]);
2963 AddItem(_lc[I_MENU_YES]);
2964 OnChange := ProcChangeTouchSettings;
2965 end;
2966 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2967 begin
2968 Name := 'scTouchSize';
2969 Max := 20;
2970 OnChange := ProcChangeTouchSettings;
2971 end;
2972 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2973 begin
2974 Name := 'swTouchFire';
2975 AddItem(_lc[I_MENU_NO]);
2976 AddItem(_lc[I_MENU_YES]);
2977 end;
2978 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2979 begin
2980 Name := 'scTouchOffset';
2981 Max := 20;
2982 OnChange := ProcChangeTouchSettings;
2983 end;
2984 end;
2985 Menu.DefControl := 'mOptionsControlsTouchMenu';
2986 g_GUI_AddWindow(Menu);
2988 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2989 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2990 begin
2991 Name := 'mOptionsPlayersMenu';
2992 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2993 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2994 end;
2995 Menu.DefControl := 'mOptionsPlayersMenu';
2996 g_GUI_AddWindow(Menu);
2998 CreatePlayerOptionsMenu('P1');
2999 CreatePlayerOptionsMenu('P2');
3001 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3002 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3003 begin
3004 Name := 'mOptionsPlayersMIMenu';
3005 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3006 begin
3007 Name := 'lbName';
3008 FixedLength := 16;
3009 end;
3010 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3011 begin
3012 Name := 'lbAuthor';
3013 FixedLength := 16;
3014 end;
3015 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3016 begin
3017 Name := 'meComment';
3018 end;
3019 AddSpace();
3020 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3021 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3022 begin
3023 Name := 'lbWeapon';
3024 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3025 end;
3026 ReAlign();
3027 end;
3028 Menu.DefControl := 'mOptionsPlayersMIMenu';
3029 g_GUI_AddWindow(Menu);
3031 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3032 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3033 begin
3034 Name := 'mOptionsLanguageMenu';
3035 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3036 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3037 ReAlign();
3038 end;
3039 Menu.DefControl := 'mOptionsLanguageMenu';
3040 g_GUI_AddWindow(Menu);
3042 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3043 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3044 g_GUI_AddWindow(Menu);
3046 Menu := TGUIWindow.Create('AuthorsMenu');
3047 Menu.BackTexture := 'INTER';
3048 Menu.OnClose := ProcAuthorsClose;
3050 // Çàãîëîâîê:
3051 _y := 16;
3052 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3053 begin
3054 Color := _RGB(255, 0, 0);
3055 X := (gScreenWidth div 2)-(GetWidth() div 2);
3056 Y := _y;
3057 _y := _y+GetHeight();
3058 end;
3059 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3060 begin
3061 Color := _RGB(255, 0, 0);
3062 X := (gScreenWidth div 2)-(GetWidth() div 2);
3063 Y := _y;
3064 _y := _y+GetHeight()+32;
3065 end;
3066 // ×òî äåëàë: Êòî äåëàë
3067 cx := gScreenWidth div 2 - 320 + 64;
3068 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3069 begin
3070 Color := _RGB(255, 0, 0);
3071 X := cx;
3072 Y := _y;
3073 _y := _y+22;
3074 end;
3075 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3076 begin
3077 Color := _RGB(255, 255, 255);
3078 X := cx+32;
3079 Y := _y;
3080 _y := _y+36;
3081 end;
3082 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3083 begin
3084 Color := _RGB(255, 0, 0);
3085 X := cx;
3086 Y := _y;
3087 _y := _y+22;
3088 end;
3089 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3090 begin
3091 Color := _RGB(255, 255, 255);
3092 X := cx+32;
3093 Y := _y;
3094 _y := _y+22;
3095 end;
3096 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3097 begin
3098 Color := _RGB(255, 255, 255);
3099 X := cx+32;
3100 Y := _y;
3101 _y := _y+36;
3102 end;
3103 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3104 begin
3105 Color := _RGB(255, 0, 0);
3106 X := cx;
3107 Y := _y;
3108 _y := _y+22;
3109 end;
3110 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3111 begin
3112 Color := _RGB(255, 255, 255);
3113 X := cx+32;
3114 Y := _y;
3115 _y := _y+36;
3116 end;
3117 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3118 begin
3119 Color := _RGB(255, 0, 0);
3120 X := cx;
3121 Y := _y;
3122 _y := _y+22;
3123 end;
3124 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3125 begin
3126 Color := _RGB(255, 255, 255);
3127 X := cx+32;
3128 Y := _y;
3129 _y := gScreenHeight - 128;
3130 end;
3131 // Çàêëþ÷åíèå:
3132 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3133 begin
3134 Color := _RGB(255, 0, 0);
3135 X := cx;
3136 Y := _y;
3137 _y := _y+16;
3138 end;
3139 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3140 begin
3141 Color := _RGB(255, 255, 255);
3142 X := cx+32;
3143 Y := _y;
3144 _y := _y+GetHeight();
3145 end;
3146 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3147 begin
3148 Color := _RGB(255, 255, 255);
3149 X := cx+32;
3150 Y := _y;
3151 _y := _y+GetHeight();
3152 end;
3153 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3154 begin
3155 Color := _RGB(255, 255, 255);
3156 X := cx+32;
3157 Y := _y;
3158 _y := gScreenHeight - 32;
3159 end;
3160 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3161 begin
3162 Color := _RGB(255, 0, 0);
3163 X := gScreenWidth div 2 - GetWidth() div 2;
3164 Y := _y;
3165 end;
3166 g_GUI_AddWindow(Menu);
3168 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3169 gMenuSmallFont, @ProcExitMenuKeyDown);
3170 g_GUI_AddWindow(Menu);
3172 Menu := TGUIWindow.Create('GameSingleMenu');
3173 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3174 begin
3175 Name := 'mmGameSingleMenu';
3176 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3177 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3178 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3179 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3180 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3181 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3182 end;
3183 Menu.DefControl := 'mmGameSingleMenu';
3184 Menu.MainWindow := True;
3185 Menu.OnClose := ProcGMClose;
3186 Menu.OnShow := ProcGMShow;
3187 g_GUI_AddWindow(Menu);
3189 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3190 gMenuSmallFont, @ProcEndMenuKeyDown);
3191 g_GUI_AddWindow(Menu);
3193 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3194 gMenuSmallFont, @ProcRestartMenuKeyDown);
3195 g_GUI_AddWindow(Menu);
3197 Menu := TGUIWindow.Create('GameCustomMenu');
3198 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3199 begin
3200 Name := 'mmGameCustomMenu';
3201 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3202 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3203 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3204 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3205 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3206 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3207 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3208 end;
3209 Menu.DefControl := 'mmGameCustomMenu';
3210 Menu.MainWindow := True;
3211 Menu.OnClose := ProcGMClose;
3212 Menu.OnShow := ProcGMShow;
3213 g_GUI_AddWindow(Menu);
3215 Menu := TGUIWindow.Create('GameServerMenu');
3216 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3217 begin
3218 Name := 'mmGameServerMenu';
3219 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3220 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3221 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3222 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3223 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3224 end;
3225 Menu.DefControl := 'mmGameServerMenu';
3226 Menu.MainWindow := True;
3227 Menu.OnClose := ProcGMClose;
3228 Menu.OnShow := ProcGMShow;
3229 g_GUI_AddWindow(Menu);
3231 Menu := TGUIWindow.Create('GameClientMenu');
3232 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3233 begin
3234 Name := 'mmGameClientMenu';
3235 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3236 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3237 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3238 end;
3239 Menu.DefControl := 'mmGameClientMenu';
3240 Menu.MainWindow := True;
3241 Menu.OnClose := ProcGMClose;
3242 Menu.OnShow := ProcGMShow;
3243 g_GUI_AddWindow(Menu);
3245 Menu := TGUIWindow.Create('ClientPasswordMenu');
3246 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3247 begin
3248 Name := 'mClientPasswordMenu';
3249 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3250 begin
3251 Name := 'edPW';
3252 Width := 12;
3253 MaxLength := 32;
3254 end;
3255 AddSpace;
3257 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3258 ReAlign();
3259 end;
3260 Menu.DefControl := 'mClientPasswordMenu';
3261 g_GUI_AddWindow(Menu);
3263 Menu := TGUIWindow.Create('GameSetGameMenu');
3264 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3265 begin
3266 Name := 'mGameSetGameMenu';
3267 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3268 begin
3269 Name := 'swTeamDamage';
3270 AddItem(_lc[I_MENU_YES]);
3271 AddItem(_lc[I_MENU_NO]);
3272 ItemIndex := 1;
3273 end;
3274 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3275 begin
3276 Name := 'edTimeLimit';
3277 OnlyDigits := True;
3278 Width := 4;
3279 MaxLength := 5;
3280 end;
3281 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3282 begin
3283 Name := 'edGoalLimit';
3284 OnlyDigits := True;
3285 Width := 4;
3286 MaxLength := 5;
3287 end;
3288 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3289 begin
3290 Name := 'edMaxLives';
3291 OnlyDigits := True;
3292 Width := 4;
3293 MaxLength := 5;
3294 end;
3295 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3296 begin
3297 Name := 'swBotsVS';
3298 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3299 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3300 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3301 ItemIndex := 2;
3302 end;
3304 ReAlign();
3305 end;
3306 Menu.DefControl := 'mGameSetGameMenu';
3307 Menu.OnClose := ProcApplyGameSet;
3308 g_GUI_AddWindow(Menu);
3310 Menu := TGUIWindow.Create('TeamMenu');
3311 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3312 begin
3313 Name := 'mmTeamMenu';
3314 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3315 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3316 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3317 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3318 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3319 end;
3320 Menu.DefControl := 'mmTeamMenu';
3321 Menu.OnShow := ProcChangePlayers;
3322 g_GUI_AddWindow(Menu);
3323 end;
3325 procedure g_Menu_Show_SaveMenu();
3326 begin
3327 if g_Game_IsTestMap then
3328 Exit;
3329 if gGameSettings.GameType = GT_SINGLE then
3330 g_GUI_ShowWindow('GameSingleMenu')
3331 else
3332 begin
3333 if g_Game_IsClient then
3334 Exit
3335 else
3336 if g_Game_IsNet then
3337 Exit
3338 else
3339 g_GUI_ShowWindow('GameCustomMenu');
3340 end;
3341 g_GUI_ShowWindow('SaveMenu');
3342 g_Sound_PlayEx('MENU_OPEN');
3343 end;
3345 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3346 begin
3347 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3348 if gGameSettings.GameType = GT_SINGLE then
3349 begin
3350 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3351 end
3352 else
3353 begin
3354 if g_Game_IsClient then exit;
3355 if g_Game_IsNet then exit;
3356 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3357 end;
3358 g_GUI_ShowWindow('LoadMenu');
3359 g_Sound_PlayEx('MENU_OPEN');
3360 end;
3362 procedure g_Menu_Show_GameSetGame();
3363 begin
3364 if gGameSettings.GameType = GT_SINGLE then
3365 g_GUI_ShowWindow('GameSingleMenu')
3366 else
3367 begin
3368 if g_Game_IsClient then
3369 Exit
3370 else
3371 if g_Game_IsNet then
3372 g_GUI_ShowWindow('GameServerMenu')
3373 else
3374 g_GUI_ShowWindow('GameCustomMenu');
3375 end;
3376 ReadGameSettings();
3377 g_GUI_ShowWindow('GameSetGameMenu');
3378 g_Sound_PlayEx('MENU_OPEN');
3379 end;
3381 procedure g_Menu_Show_OptionsVideo();
3382 begin
3383 if gGameSettings.GameType = GT_SINGLE then
3384 g_GUI_ShowWindow('GameSingleMenu')
3385 else
3386 begin
3387 if g_Game_IsClient then
3388 g_GUI_ShowWindow('GameClientMenu')
3389 else
3390 if g_Game_IsNet then
3391 g_GUI_ShowWindow('GameServerMenu')
3392 else
3393 g_GUI_ShowWindow('GameCustomMenu');
3394 end;
3395 ReadOptions();
3396 g_GUI_ShowWindow('OptionsMenu');
3397 g_GUI_ShowWindow('OptionsVideoMenu');
3398 g_Sound_PlayEx('MENU_OPEN');
3399 end;
3401 procedure g_Menu_Show_OptionsSound();
3402 begin
3403 if gGameSettings.GameType = GT_SINGLE then
3404 g_GUI_ShowWindow('GameSingleMenu')
3405 else
3406 begin
3407 if g_Game_IsClient then
3408 g_GUI_ShowWindow('GameClientMenu')
3409 else
3410 if g_Game_IsNet then
3411 g_GUI_ShowWindow('GameServerMenu')
3412 else
3413 g_GUI_ShowWindow('GameCustomMenu');
3414 end;
3415 ReadOptions();
3416 g_GUI_ShowWindow('OptionsMenu');
3417 g_GUI_ShowWindow('OptionsSoundMenu');
3418 g_Sound_PlayEx('MENU_OPEN');
3419 end;
3421 procedure g_Menu_Show_EndGameMenu();
3422 begin
3423 g_GUI_ShowWindow('EndGameMenu');
3424 g_Sound_PlayEx('MENU_OPEN');
3425 end;
3427 procedure g_Menu_Show_QuitGameMenu();
3428 begin
3429 g_GUI_ShowWindow('ExitMenu');
3430 g_Sound_PlayEx('MENU_OPEN');
3431 end;
3433 procedure g_Menu_Init();
3434 begin
3435 MenuLoadData();
3436 g_GUI_Init();
3437 CreateAllMenus();
3438 end;
3440 procedure g_Menu_Free();
3441 begin
3442 g_GUI_Destroy();
3444 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3446 MenuFreeData();
3447 end;
3449 procedure g_Menu_Reset();
3450 var
3451 ex: Boolean;
3452 begin
3453 g_GUI_SaveMenuPos();
3454 ex := g_GUI_Destroy();
3456 if ex then
3457 begin
3458 e_WriteLog('Recreating menu...', TMsgType.Notify);
3460 CreateAllMenus();
3462 if gDebugMode then
3463 g_Game_SetDebugMode();
3465 g_GUI_LoadMenuPos();
3466 end;
3467 end;
3469 end.