DEADSOFTWARE

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