DEADSOFTWARE

scale option is now a capped switch
[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 with TGUISwitch(menu.GetControl('swResFactor')) do
1858 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1859 end;
1861 procedure ProcApplyVideoOptions();
1862 var
1863 menu: TGUIMenu;
1864 Fullscreen: Boolean;
1865 SWidth, SHeight: Integer;
1866 ScaleChanged: Boolean;
1867 str: String;
1868 begin
1869 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1871 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1872 if str <> '' then
1873 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1874 else
1875 begin
1876 SWidth := gWinSizeX;
1877 SHeight := gWinSizeY;
1878 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1879 end;
1881 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1883 ScaleChanged := False;
1884 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1885 begin
1886 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1887 r_pixel_scale := TempResScale + 1;
1888 ScaleChanged := True;
1889 end;
1891 if (SWidth <> gWinSizeX) or
1892 (SHeight <> gWinSizeY) or
1893 (Fullscreen <> gFullscreen) or
1894 ScaleChanged then
1895 begin
1896 gResolutionChange := True;
1897 gRC_Width := SWidth;
1898 gRC_Height := SHeight;
1899 gRC_FullScreen := Fullscreen;
1900 gRC_Maximized := gWinMaximized;
1901 end;
1903 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1904 ProcApplyOptions();
1905 end;
1907 procedure ProcSetFirstRussianLanguage;
1908 begin
1909 gLanguage := LANGUAGE_RUSSIAN;
1910 gLanguageChange := True;
1911 gAskLanguage := False;
1912 end;
1914 procedure ProcSetFirstEnglishLanguage;
1915 begin
1916 gLanguage := LANGUAGE_ENGLISH;
1917 gLanguageChange := True;
1918 gAskLanguage := False;
1919 end;
1921 procedure ProcRecallAddress();
1922 begin
1923 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1924 begin
1925 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1926 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1927 end;
1928 end;
1930 procedure CreateFirstLanguageMenu();
1931 var
1932 Menu: TGUIWindow;
1933 begin
1934 Menu := TGUIWindow.Create('FirstLanguageMenu');
1936 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1937 begin
1938 Name := 'mmFirstLanguageMenu';
1939 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1940 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1941 end;
1943 Menu.DefControl := 'mmFirstLanguageMenu';
1944 Menu.MainWindow := True;
1945 g_GUI_AddWindow(Menu);
1946 end;
1948 procedure g_Menu_AskLanguage();
1949 begin
1950 CreateFirstLanguageMenu();
1951 g_GUI_ShowWindow('FirstLanguageMenu');
1952 end;
1954 procedure CreatePlayerOptionsMenu(s: String);
1955 var
1956 Menu: TGUIWindow;
1957 a: String;
1958 begin
1959 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1960 if s = 'P1' then
1961 a := _lc[I_MENU_PLAYER_1]
1962 else
1963 a := _lc[I_MENU_PLAYER_2];
1964 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1965 begin
1966 Name := 'mOptionsPlayers'+s+'Menu';
1967 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1968 begin
1969 Name := 'ed'+s+'Name';
1970 MaxLength := 12;
1971 Width := 12;
1972 end;
1973 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1974 begin
1975 Name := 'sw'+s+'Team';
1976 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1977 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1978 end ;
1979 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1980 begin
1981 Name := 'ls'+s+'Model';
1982 Sort := True;
1983 Items := g_PlayerModel_GetNames();
1984 OnChange := ProcSelectModel;
1985 end;
1986 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1987 begin
1988 Name := 'sc'+s+'Red';
1989 Max := 16;
1990 OnChange := ProcChangeColor;
1991 end;
1992 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1993 begin
1994 Name := 'sc'+s+'Green';
1995 Max := 16;
1996 OnChange := ProcChangeColor;
1997 end;
1998 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1999 begin
2000 Name := 'sc'+s+'Blue';
2001 Max := 16;
2002 OnChange := ProcChangeColor;
2003 end;
2004 AddSpace();
2005 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2006 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2007 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2008 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2010 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2011 begin
2012 Name := 'mv'+s+'Model';
2013 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2014 Y := GetControl('ls'+s+'Model').Y;
2015 end;
2016 end;
2017 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2018 g_GUI_AddWindow(Menu);
2019 end;
2021 procedure CreateAllMenus();
2022 var
2023 Menu: TGUIWindow;
2024 //SR: TSearchRec;
2025 a, cx, _y, i: Integer;
2026 //list: SSArray;
2027 begin
2028 Menu := TGUIWindow.Create('MainMenu');
2029 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2030 begin
2031 Name := 'mmMainMenu';
2032 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2033 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2034 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2035 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2036 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2037 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2038 end;
2039 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2040 begin
2041 Color := _RGB(255, 255, 255);
2042 X := gScreenWidth-GetWidth-8;
2043 Y := gScreenHeight-GetHeight-8;
2044 end;
2045 Menu.DefControl := 'mmMainMenu';
2046 Menu.MainWindow := True;
2047 g_GUI_AddWindow(Menu);
2049 Menu := TGUIWindow.Create('NewGameMenu');
2050 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2051 begin
2052 Name := 'mmNewGameMenu';
2053 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2054 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2055 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2056 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2057 end;
2058 Menu.DefControl := 'mmNewGameMenu';
2059 g_GUI_AddWindow(Menu);
2061 Menu := TGUIWindow.Create('NetGameMenu');
2062 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2063 begin
2064 Name := 'mmNetGameMenu';
2065 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2066 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2067 end;
2068 Menu.DefControl := 'mmNetGameMenu';
2069 g_GUI_AddWindow(Menu);
2071 Menu := TGUIWindow.Create('NetServerMenu');
2072 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2073 begin
2074 Name := 'mNetServerMenu';
2075 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2076 begin
2077 Name := 'edSrvName';
2078 OnlyDigits := False;
2079 Width := 16;
2080 MaxLength := 64;
2081 Text := NetServerName;
2082 end;
2083 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2084 begin
2085 Name := 'edSrvPassword';
2086 OnlyDigits := False;
2087 Width := 16;
2088 MaxLength := 24;
2089 Text := NetPassword;
2090 end;
2091 with AddEdit(_lc[I_NET_PORT]) do
2092 begin
2093 Name := 'edPort';
2094 OnlyDigits := True;
2095 Width := 4;
2096 MaxLength := 5;
2097 Text := IntToStr(NetPort);
2098 end;
2099 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2100 begin
2101 Name := 'edMaxPlayers';
2102 OnlyDigits := True;
2103 Width := 4;
2104 MaxLength := 2;
2105 Text := IntToStr(NetMaxClients);
2106 end;
2107 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2108 begin
2109 Name := 'swUseMaster';
2110 AddItem(_lc[I_MENU_YES]);
2111 AddItem(_lc[I_MENU_NO]);
2112 if NetUseMaster then
2113 ItemIndex := 0
2114 else
2115 ItemIndex := 1;
2116 end;
2117 AddSpace();
2118 with AddLabel(_lc[I_MENU_MAP]) do
2119 begin
2120 Name := 'lbMap';
2121 FixedLength := 16;
2122 Text := gsMap;
2123 OnClick := @ProcSelectMapMenu;
2124 end;
2125 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2126 begin
2127 Name := 'swGameMode';
2128 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2129 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2130 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2131 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2132 case g_Game_TextToMode(gsGameMode) of
2133 GM_NONE,
2134 GM_DM: ItemIndex := 0;
2135 GM_TDM: ItemIndex := 1;
2136 GM_CTF: ItemIndex := 2;
2137 GM_SINGLE,
2138 GM_COOP: ItemIndex := 3;
2139 end;
2140 OnChange := ProcSwitchMonstersCustom;
2141 end;
2142 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2143 begin
2144 Name := 'edTimeLimit';
2145 OnlyDigits := True;
2146 Width := 4;
2147 MaxLength := 5;
2148 if gsTimeLimit > 0 then
2149 Text := IntToStr(gsTimeLimit);
2150 end;
2151 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2152 begin
2153 Name := 'edGoalLimit';
2154 OnlyDigits := True;
2155 Width := 4;
2156 MaxLength := 5;
2157 if gsGoalLimit > 0 then
2158 Text := IntToStr(gsGoalLimit);
2159 end;
2160 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2161 begin
2162 Name := 'edMaxLives';
2163 OnlyDigits := True;
2164 Width := 4;
2165 MaxLength := 5;
2166 if gsMaxLives > 0 then
2167 Text := IntToStr(gsMaxLives);
2168 end;
2169 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2170 begin
2171 Name := 'edItemRespawnTime';
2172 OnlyDigits := True;
2173 Width := 4;
2174 MaxLength := 5;
2175 if gsItemRespawnTime > 0 then
2176 Text := IntToStr(gsItemRespawnTime);
2177 end;
2178 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2179 begin
2180 Name := 'swPlayers';
2181 AddItem(_lc[I_MENU_COUNT_NONE]);
2182 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2183 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2184 ItemIndex := gsPlayers;
2185 end;
2186 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2187 begin
2188 Name := 'swTeamDamage';
2189 AddItem(_lc[I_MENU_YES]);
2190 AddItem(_lc[I_MENU_NO]);
2191 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2192 ItemIndex := 0
2193 else
2194 ItemIndex := 1;
2195 end;
2196 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2197 begin
2198 Name := 'swDeathmatchKeys';
2199 AddItem(_lc[I_MENU_YES]);
2200 AddItem(_lc[I_MENU_NO]);
2201 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2202 ItemIndex := 0
2203 else
2204 ItemIndex := 1;
2205 end;
2206 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2207 begin
2208 Name := 'swEnableExits';
2209 AddItem(_lc[I_MENU_YES]);
2210 AddItem(_lc[I_MENU_NO]);
2211 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2212 ItemIndex := 0
2213 else
2214 ItemIndex := 1;
2215 end;
2216 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2217 begin
2218 Name := 'swWeaponStay';
2219 AddItem(_lc[I_MENU_YES]);
2220 AddItem(_lc[I_MENU_NO]);
2221 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2222 ItemIndex := 0
2223 else
2224 ItemIndex := 1;
2225 end;
2226 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2227 begin
2228 Name := 'swMonsters';
2229 AddItem(_lc[I_MENU_YES]);
2230 AddItem(_lc[I_MENU_NO]);
2231 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2232 ItemIndex := 0
2233 else
2234 ItemIndex := 1;
2235 end;
2236 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2237 begin
2238 Name := 'swBotsVS';
2239 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2240 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2241 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2242 ItemIndex := 2;
2243 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2244 ItemIndex := 0;
2245 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2246 ItemIndex := 1;
2247 end;
2248 AddSpace();
2249 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2251 ReAlign();
2252 end;
2253 Menu.DefControl := 'mNetServerMenu';
2254 g_GUI_AddWindow(Menu);
2256 Menu := TGUIWindow.Create('NetClientMenu');
2257 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2258 begin
2259 Name := 'mNetClientMenu';
2261 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2262 AddSpace();
2264 with AddEdit(_lc[I_NET_ADDRESS]) do
2265 begin
2266 Name := 'edIP';
2267 OnlyDigits :=False;
2268 Width := 12;
2269 MaxLength := 64;
2270 Text := 'localhost';
2271 end;
2272 with AddEdit(_lc[I_NET_PORT]) do
2273 begin
2274 Name := 'edPort';
2275 OnlyDigits := True;
2276 Width := 4;
2277 MaxLength := 5;
2278 Text := '25666';
2279 end;
2280 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2281 begin
2282 Name := 'edPW';
2283 OnlyDigits := False;
2284 Width := 12;
2285 MaxLength := 32;
2286 Text := '';
2287 end;
2289 AddSpace();
2290 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2292 ReAlign();
2293 end;
2294 Menu.DefControl := 'mNetClientMenu';
2295 g_GUI_AddWindow(Menu);
2297 Menu := TGUIWindow.Create('LoadMenu');
2298 Menu.OnShow := ProcLoadMenu;
2299 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2300 begin
2301 Name := 'mmLoadMenu';
2303 for a := 1 to 8 do
2304 with AddEdit('') do
2305 begin
2306 Name := 'edSlot'+IntToStr(a);
2307 Width := 16;
2308 MaxLength := 16;
2309 OnEnter := ProcLoadGame;
2310 end;
2311 end;
2312 Menu.DefControl := 'mmLoadMenu';
2313 g_GUI_AddWindow(Menu);
2315 Menu := TGUIWindow.Create('SaveMenu');
2316 Menu.OnShow := ProcSaveMenu;
2317 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2318 begin
2319 Name := 'mmSaveMenu';
2321 for a := 1 to 8 do
2322 with AddEdit('') do
2323 begin
2324 Name := 'edSlot'+IntToStr(a);
2325 Width := 16;
2326 MaxLength := 16;
2327 OnChange := ProcSaveGame;
2328 end;
2329 end;
2330 Menu.DefControl := 'mmSaveMenu';
2331 g_GUI_AddWindow(Menu);
2333 Menu := TGUIWindow.Create('CustomGameMenu');
2334 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2335 begin
2336 Name := 'mCustomGameMenu';
2337 with AddLabel(_lc[I_MENU_MAP]) do
2338 begin
2339 Name := 'lbMap';
2340 FixedLength := 16;
2341 Text := gsMap;
2342 OnClick := @ProcSelectMapMenu;
2343 end;
2344 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2345 begin
2346 Name := 'swGameMode';
2347 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2348 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2349 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2350 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2351 case g_Game_TextToMode(gsGameMode) of
2352 GM_NONE,
2353 GM_DM: ItemIndex := 0;
2354 GM_TDM: ItemIndex := 1;
2355 GM_CTF: ItemIndex := 2;
2356 GM_SINGLE,
2357 GM_COOP: ItemIndex := 3;
2358 end;
2359 OnChange := ProcSwitchMonstersCustom;
2360 end;
2361 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2362 begin
2363 Name := 'edTimeLimit';
2364 OnlyDigits := True;
2365 Width := 4;
2366 MaxLength := 5;
2367 if gsTimeLimit > 0 then
2368 Text := IntToStr(gsTimeLimit);
2369 end;
2370 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2371 begin
2372 Name := 'edGoalLimit';
2373 OnlyDigits := True;
2374 Width := 4;
2375 MaxLength := 5;
2376 if gsGoalLimit > 0 then
2377 Text := IntToStr(gsGoalLimit);
2378 end;
2379 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2380 begin
2381 Name := 'edMaxLives';
2382 OnlyDigits := True;
2383 Width := 4;
2384 MaxLength := 5;
2385 if gsMaxLives > 0 then
2386 Text := IntToStr(gsMaxLives);
2387 end;
2388 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2389 begin
2390 Name := 'edItemRespawnTime';
2391 OnlyDigits := True;
2392 Width := 4;
2393 MaxLength := 5;
2394 if gsItemRespawnTime > 0 then
2395 Text := IntToStr(gsItemRespawnTime);
2396 end;
2397 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2398 begin
2399 Name := 'swPlayers';
2400 AddItem(_lc[I_MENU_COUNT_NONE]);
2401 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2402 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2403 ItemIndex := gsPlayers;
2404 end;
2405 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2406 begin
2407 Name := 'swTeamDamage';
2408 AddItem(_lc[I_MENU_YES]);
2409 AddItem(_lc[I_MENU_NO]);
2410 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2411 ItemIndex := 0
2412 else
2413 ItemIndex := 1;
2414 end;
2415 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2416 begin
2417 Name := 'swDeathmatchKeys';
2418 AddItem(_lc[I_MENU_YES]);
2419 AddItem(_lc[I_MENU_NO]);
2420 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2421 ItemIndex := 0
2422 else
2423 ItemIndex := 1;
2424 end;
2425 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2426 begin
2427 Name := 'swEnableExits';
2428 AddItem(_lc[I_MENU_YES]);
2429 AddItem(_lc[I_MENU_NO]);
2430 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2431 ItemIndex := 0
2432 else
2433 ItemIndex := 1;
2434 end;
2435 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2436 begin
2437 Name := 'swWeaponStay';
2438 AddItem(_lc[I_MENU_YES]);
2439 AddItem(_lc[I_MENU_NO]);
2440 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2441 ItemIndex := 0
2442 else
2443 ItemIndex := 1;
2444 end;
2445 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2446 begin
2447 Name := 'swMonsters';
2448 AddItem(_lc[I_MENU_YES]);
2449 AddItem(_lc[I_MENU_NO]);
2450 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2451 ItemIndex := 0
2452 else
2453 ItemIndex := 1;
2454 end;
2455 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2456 begin
2457 Name := 'swBotsVS';
2458 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2459 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2460 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2461 ItemIndex := 2;
2462 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2463 ItemIndex := 0;
2464 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2465 ItemIndex := 1;
2466 end;
2467 AddSpace();
2468 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2470 ReAlign();
2471 end;
2472 Menu.DefControl := 'mCustomGameMenu';
2473 g_GUI_AddWindow(Menu);
2475 Menu := TGUIWindow.Create('CampaignMenu');
2476 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2477 begin
2478 Name := 'mCampaignMenu';
2480 AddSpace();
2481 AddSpace();
2482 AddSpace();
2483 AddSpace();
2484 AddSpace();
2485 AddSpace();
2487 with AddFileList('', 15, 4) do
2488 begin
2489 Name := 'lsWAD';
2490 OnChange := ProcSelectCampaignWAD;
2492 Sort := True;
2493 Dirs := True;
2494 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2495 SetBase(MegawadDirs);
2496 end;
2498 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2499 begin
2500 Name := 'lbWADName';
2501 FixedLength := 8;
2502 Enabled := False;
2503 end;
2504 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2505 begin
2506 Name := 'lbWADAuthor';
2507 FixedLength := 8;
2508 Enabled := False;
2509 end;
2510 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2511 with AddMemo('', 15, 3) do
2512 begin
2513 Name := 'meWADDescription';
2514 Color := MENU_ITEMSCTRL_COLOR;
2515 end;
2516 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2517 begin
2518 Name := 'swPlayers';
2519 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2520 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2521 end;
2522 AddSpace();
2523 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2525 ReAlign();
2527 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2528 begin
2529 Name := 'mpWADImage';
2530 DefaultRes := 'NOPIC';
2531 X := GetControl('lsWAD').X+4;
2532 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2533 end;
2534 end;
2535 Menu.DefControl := 'mCampaignMenu';
2536 g_GUI_AddWindow(Menu);
2538 Menu := TGUIWindow.Create('SelectMapMenu');
2539 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2540 begin
2541 Name := 'mSelectMapMenu';
2542 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2543 begin
2544 Name := 'lsMapWAD';
2545 OnChange := ProcSelectWAD;
2547 Sort := True;
2548 Dirs := True;
2549 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2550 SetBase(MapDirs);
2551 end;
2552 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2553 begin
2554 Name := 'lsMapRes';
2555 Sort := True;
2556 OnChange := ProcSelectMap;
2557 end;
2558 AddSpace();
2559 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2560 begin
2561 Name := 'lbMapName';
2562 FixedLength := 24;
2563 Enabled := False;
2564 end;
2565 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2566 begin
2567 Name := 'lbMapAuthor';
2568 FixedLength := 16;
2569 Enabled := False;
2570 end;
2571 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2572 begin
2573 Name := 'lbMapSize';
2574 FixedLength := 10;
2575 Enabled := False;
2576 end;
2577 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2578 begin
2579 Name := 'meMapDescription';
2580 end;
2582 ReAlign();
2584 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2585 begin
2586 Name := 'mpMapPreview';
2587 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2588 Y := GetControl('lsMapWAD').Y;
2589 end;
2590 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2591 begin
2592 Name := 'lbMapScale';
2593 FixedLength := 8;
2594 Enabled := False;
2595 Color := MENU_ITEMSCTRL_COLOR;
2596 X := GetControl('lsMapWAD').X +
2597 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2598 2 + MAPPREVIEW_WIDTH*4;
2599 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2600 end;
2601 end;
2602 Menu.OnClose := ProcSetMap;
2603 Menu.DefControl := 'mSelectMapMenu';
2604 g_GUI_AddWindow(Menu);
2606 Menu := TGUIWindow.Create('OptionsMenu');
2607 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2608 begin
2609 Name := 'mmOptionsMenu';
2610 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2611 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2612 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2613 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2614 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2615 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2616 AddSpace();
2617 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2618 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2619 end;
2620 Menu.OnClose := ProcApplyOptions;
2621 Menu.DefControl := 'mmOptionsMenu';
2622 g_GUI_AddWindow(Menu);
2624 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2625 gMenuSmallFont, @ProcSavedMenuKeyDown);
2626 g_GUI_AddWindow(Menu);
2628 Menu := TGUIWindow.Create('OptionsVideoMenu');
2629 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2630 begin
2631 Name := 'mOptionsVideoMenu';
2632 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2633 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2634 begin
2635 Name := 'swBPP';
2636 AddItem('16');
2637 AddItem('32');
2638 end;
2639 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2640 begin
2641 Name := 'swVSync';
2642 AddItem(_lc[I_MENU_YES]);
2643 AddItem(_lc[I_MENU_NO]);
2644 end;
2645 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2646 begin
2647 Name := 'swTextureFilter';
2648 AddItem(_lc[I_MENU_YES]);
2649 AddItem(_lc[I_MENU_NO]);
2650 end;
2651 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2652 begin
2653 Name := 'swInterp';
2654 AddItem(_lc[I_MENU_YES]);
2655 AddItem(_lc[I_MENU_NO]);
2656 end;
2657 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2658 begin
2659 Name := 'swLegacyNPOT';
2660 AddItem(_lc[I_MENU_NO]);
2661 AddItem(_lc[I_MENU_YES]);
2662 end;
2663 AddSpace();
2664 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2665 ReAlign();
2666 end;
2667 Menu.DefControl := 'mOptionsVideoMenu';
2668 g_GUI_AddWindow(Menu);
2670 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2671 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2672 begin
2673 Name := 'mOptionsVideoResMenu';
2674 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2675 begin
2676 Name := 'lbCurrentRes';
2677 FixedLength := 24;
2678 Enabled := False;
2679 end;
2680 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2681 begin
2682 Name := 'lsResolution';
2683 Sort := False;
2684 end;
2685 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2686 begin
2687 Name := 'swFullScreen';
2688 AddItem(_lc[I_MENU_YES]);
2689 AddItem(_lc[I_MENU_NO]);
2690 end;
2691 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2692 begin
2693 Name := 'swResFactor';
2694 AddItem('1x');
2695 for i := 2 to gRC_Width div 640 do
2696 AddItem(IntToStr(i) + 'x');
2697 end;
2698 AddSpace();
2699 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2700 UpdateIndex();
2701 end;
2702 Menu.DefControl := 'mOptionsVideoResMenu';
2703 g_GUI_AddWindow(Menu);
2705 Menu := TGUIWindow.Create('OptionsSoundMenu');
2706 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2707 begin
2708 Name := 'mOptionsSoundMenu';
2709 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2710 begin
2711 Name := 'scMusicLevel';
2712 Max := 16;
2713 OnChange := ProcChangeSoundSettings;
2714 end;
2715 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2716 begin
2717 Name := 'scSoundLevel';
2718 Max := 16;
2719 OnChange := ProcChangeSoundSettings;
2720 end;
2721 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2722 begin
2723 Name := 'scMaxSimSounds';
2724 Max := 16;
2725 end;
2726 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2727 begin;
2728 Name := 'swAnnouncer';
2729 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2730 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2731 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2732 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2733 end;
2734 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2735 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2736 begin;
2737 Name := 'swSoundEffects';
2738 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2739 AddItem(_lc[I_MENU_COMPAT_DF]);
2740 end;
2741 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2742 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2743 begin;
2744 Name := 'swChatSpeech';
2745 AddItem(_lc[I_MENU_YES]);
2746 AddItem(_lc[I_MENU_NO]);
2747 end;
2748 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2749 begin
2750 Name := 'swInactiveSounds';
2751 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2752 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2753 end;
2754 ReAlign();
2755 end;
2756 Menu.DefControl := 'mOptionsSoundMenu';
2757 g_GUI_AddWindow(Menu);
2759 Menu := TGUIWindow.Create('OptionsGameMenu');
2760 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2761 begin
2762 Name := 'mOptionsGameMenu';
2763 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2764 begin
2765 Name := 'scParticlesCount';
2766 Max := 20;
2767 end;
2768 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2769 begin
2770 Name := 'swBloodCount';
2771 AddItem(_lc[I_MENU_COUNT_NONE]);
2772 AddItem(_lc[I_MENU_COUNT_SMALL]);
2773 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2774 AddItem(_lc[I_MENU_COUNT_BIG]);
2775 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2776 end;
2777 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2778 begin
2779 Name := 'scShellsMax';
2780 Max := 20;
2781 end;
2782 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2783 begin
2784 Name := 'scGibsMax';
2785 Max := 20;
2786 end;
2787 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2788 begin
2789 Name := 'scCorpsesMax';
2790 Max := 20;
2791 end;
2792 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2793 begin
2794 Name := 'swGibsCount';
2795 AddItem(_lc[I_MENU_COUNT_NONE]);
2796 AddItem(_lc[I_MENU_COUNT_SMALL]);
2797 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2798 AddItem(_lc[I_MENU_COUNT_BIG]);
2799 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2800 end;
2801 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2802 begin
2803 Name := 'swCorpseType';
2804 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2805 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2806 end;
2807 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2808 begin
2809 Name := 'swGibsType';
2810 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2811 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2812 end;
2813 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2814 begin
2815 Name := 'swBloodType';
2816 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2817 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2818 end;
2819 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2820 begin
2821 Name := 'swScreenFlash';
2822 AddItem(_lc[I_MENU_NO]);
2823 AddItem(_lc[I_MENU_COMPAT_DF]);
2824 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2825 end;
2826 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2827 begin
2828 Name := 'swBackground';
2829 AddItem(_lc[I_MENU_YES]);
2830 AddItem(_lc[I_MENU_NO]);
2831 end;
2832 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2833 begin
2834 Name := 'swMessages';
2835 AddItem(_lc[I_MENU_YES]);
2836 AddItem(_lc[I_MENU_NO]);
2837 end;
2838 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2839 begin
2840 Name := 'swRevertPlayers';
2841 AddItem(_lc[I_MENU_YES]);
2842 AddItem(_lc[I_MENU_NO]);
2843 end;
2844 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2845 begin
2846 Name := 'swChatBubble';
2847 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2848 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2849 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2850 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2851 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2852 end;
2853 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2854 begin
2855 Name := 'swPlayerIndicator';
2856 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2857 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2858 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2859 end;
2860 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2861 begin
2862 Name := 'swPlayerIndicatorStyle';
2863 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2864 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2865 end;
2866 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2867 begin
2868 Name := 'scScaleFactor';
2869 Max := 10;
2870 OnChange := ProcChangeGameSettings;
2871 end;
2872 ReAlign();
2873 end;
2874 Menu.DefControl := 'mOptionsGameMenu';
2875 g_GUI_AddWindow(Menu);
2877 Menu := TGUIWindow.Create('OptionsControlsMenu');
2878 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2879 begin
2880 Name := 'mOptionsControlsMenu';
2881 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2882 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2883 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2884 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2885 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2886 AddSpace();
2887 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2888 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2889 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2890 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2891 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2892 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2893 if e_HasJoysticks then
2894 begin
2895 AddSpace();
2896 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2897 end;
2898 if g_touch_enabled then
2899 begin
2900 AddSpace();
2901 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2902 end;
2903 end;
2904 Menu.DefControl := 'mOptionsControlsMenu';
2905 g_GUI_AddWindow(Menu);
2907 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2908 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2909 begin
2910 Name := 'mOptionsControlsP1Menu';
2911 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2912 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2913 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2914 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2915 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2916 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2917 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2918 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2919 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2920 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2921 end;
2922 Menu.DefControl := 'mOptionsControlsP1Menu';
2923 g_GUI_AddWindow(Menu);
2925 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2926 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2927 begin
2928 Name := 'mOptionsControlsP1MenuWeapons';
2929 for i := WP_FIRST to WP_LAST do
2930 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2931 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2932 end;
2933 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2934 g_GUI_AddWindow(Menu);
2936 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2937 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2938 begin
2939 Name := 'mOptionsControlsP2Menu';
2940 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2941 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2942 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2943 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2944 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2945 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2946 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2947 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2948 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2949 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2950 end;
2951 Menu.DefControl := 'mOptionsControlsP2Menu';
2952 g_GUI_AddWindow(Menu);
2954 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2955 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2956 begin
2957 Name := 'mOptionsControlsP2MenuWeapons';
2958 for i := WP_FIRST to WP_LAST do
2959 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2960 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2961 end;
2962 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2963 g_GUI_AddWindow(Menu);
2965 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2966 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2967 begin
2968 Name := 'mOptionsControlsJoystickMenu';
2969 for i := 0 to e_MaxJoys - 1 do
2970 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2971 begin
2972 Name := 'scDeadzone' + IntToStr(i);
2973 Max := 20
2974 end
2975 end;
2976 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2977 g_GUI_AddWindow(Menu);
2979 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2980 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2981 begin
2982 Name := 'mOptionsControlsTouchMenu';
2983 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2984 begin
2985 Name := 'swTouchAlt';
2986 AddItem(_lc[I_MENU_NO]);
2987 AddItem(_lc[I_MENU_YES]);
2988 OnChange := ProcChangeTouchSettings;
2989 end;
2990 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2991 begin
2992 Name := 'scTouchSize';
2993 Max := 20;
2994 OnChange := ProcChangeTouchSettings;
2995 end;
2996 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2997 begin
2998 Name := 'swTouchFire';
2999 AddItem(_lc[I_MENU_NO]);
3000 AddItem(_lc[I_MENU_YES]);
3001 end;
3002 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3003 begin
3004 Name := 'scTouchOffset';
3005 Max := 20;
3006 OnChange := ProcChangeTouchSettings;
3007 end;
3008 end;
3009 Menu.DefControl := 'mOptionsControlsTouchMenu';
3010 g_GUI_AddWindow(Menu);
3012 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3013 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3014 begin
3015 Name := 'mOptionsPlayersMenu';
3016 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3017 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3018 end;
3019 Menu.DefControl := 'mOptionsPlayersMenu';
3020 g_GUI_AddWindow(Menu);
3022 CreatePlayerOptionsMenu('P1');
3023 CreatePlayerOptionsMenu('P2');
3025 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3026 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3027 begin
3028 Name := 'mOptionsPlayersMIMenu';
3029 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3030 begin
3031 Name := 'lbName';
3032 FixedLength := 16;
3033 end;
3034 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3035 begin
3036 Name := 'lbAuthor';
3037 FixedLength := 16;
3038 end;
3039 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3040 begin
3041 Name := 'meComment';
3042 end;
3043 AddSpace();
3044 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3045 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3046 begin
3047 Name := 'lbWeapon';
3048 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3049 end;
3050 ReAlign();
3051 end;
3052 Menu.DefControl := 'mOptionsPlayersMIMenu';
3053 g_GUI_AddWindow(Menu);
3055 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3056 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3057 begin
3058 Name := 'mOptionsLanguageMenu';
3059 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3060 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3061 ReAlign();
3062 end;
3063 Menu.DefControl := 'mOptionsLanguageMenu';
3064 g_GUI_AddWindow(Menu);
3066 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3067 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3068 g_GUI_AddWindow(Menu);
3070 Menu := TGUIWindow.Create('AuthorsMenu');
3071 Menu.BackTexture := 'INTER';
3072 Menu.OnClose := ProcAuthorsClose;
3074 // Çàãîëîâîê:
3075 _y := 16;
3076 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3077 begin
3078 Color := _RGB(255, 0, 0);
3079 X := (gScreenWidth div 2)-(GetWidth() div 2);
3080 Y := _y;
3081 _y := _y+GetHeight();
3082 end;
3083 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3084 begin
3085 Color := _RGB(255, 0, 0);
3086 X := (gScreenWidth div 2)-(GetWidth() div 2);
3087 Y := _y;
3088 _y := _y+GetHeight()+32;
3089 end;
3090 // ×òî äåëàë: Êòî äåëàë
3091 cx := gScreenWidth div 2 - 320 + 64;
3092 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3093 begin
3094 Color := _RGB(255, 0, 0);
3095 X := cx;
3096 Y := _y;
3097 _y := _y+22;
3098 end;
3099 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3100 begin
3101 Color := _RGB(255, 255, 255);
3102 X := cx+32;
3103 Y := _y;
3104 _y := _y+36;
3105 end;
3106 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3107 begin
3108 Color := _RGB(255, 0, 0);
3109 X := cx;
3110 Y := _y;
3111 _y := _y+22;
3112 end;
3113 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3114 begin
3115 Color := _RGB(255, 255, 255);
3116 X := cx+32;
3117 Y := _y;
3118 _y := _y+22;
3119 end;
3120 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3121 begin
3122 Color := _RGB(255, 255, 255);
3123 X := cx+32;
3124 Y := _y;
3125 _y := _y+36;
3126 end;
3127 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3128 begin
3129 Color := _RGB(255, 0, 0);
3130 X := cx;
3131 Y := _y;
3132 _y := _y+22;
3133 end;
3134 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3135 begin
3136 Color := _RGB(255, 255, 255);
3137 X := cx+32;
3138 Y := _y;
3139 _y := _y+36;
3140 end;
3141 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3142 begin
3143 Color := _RGB(255, 0, 0);
3144 X := cx;
3145 Y := _y;
3146 _y := _y+22;
3147 end;
3148 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3149 begin
3150 Color := _RGB(255, 255, 255);
3151 X := cx+32;
3152 Y := _y;
3153 _y := gScreenHeight - 128;
3154 end;
3155 // Çàêëþ÷åíèå:
3156 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3157 begin
3158 Color := _RGB(255, 0, 0);
3159 X := cx;
3160 Y := _y;
3161 _y := _y+16;
3162 end;
3163 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3164 begin
3165 Color := _RGB(255, 255, 255);
3166 X := cx+32;
3167 Y := _y;
3168 _y := _y+GetHeight();
3169 end;
3170 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3171 begin
3172 Color := _RGB(255, 255, 255);
3173 X := cx+32;
3174 Y := _y;
3175 _y := _y+GetHeight();
3176 end;
3177 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3178 begin
3179 Color := _RGB(255, 255, 255);
3180 X := cx+32;
3181 Y := _y;
3182 _y := gScreenHeight - 32;
3183 end;
3184 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3185 begin
3186 Color := _RGB(255, 0, 0);
3187 X := gScreenWidth div 2 - GetWidth() div 2;
3188 Y := _y;
3189 end;
3190 g_GUI_AddWindow(Menu);
3192 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3193 gMenuSmallFont, @ProcExitMenuKeyDown);
3194 g_GUI_AddWindow(Menu);
3196 Menu := TGUIWindow.Create('GameSingleMenu');
3197 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3198 begin
3199 Name := 'mmGameSingleMenu';
3200 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3201 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3202 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3203 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3204 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3205 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3206 end;
3207 Menu.DefControl := 'mmGameSingleMenu';
3208 Menu.MainWindow := True;
3209 Menu.OnClose := ProcGMClose;
3210 Menu.OnShow := ProcGMShow;
3211 g_GUI_AddWindow(Menu);
3213 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3214 gMenuSmallFont, @ProcEndMenuKeyDown);
3215 g_GUI_AddWindow(Menu);
3217 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3218 gMenuSmallFont, @ProcRestartMenuKeyDown);
3219 g_GUI_AddWindow(Menu);
3221 Menu := TGUIWindow.Create('GameCustomMenu');
3222 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3223 begin
3224 Name := 'mmGameCustomMenu';
3225 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3226 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3227 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3228 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3229 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3230 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3231 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3232 end;
3233 Menu.DefControl := 'mmGameCustomMenu';
3234 Menu.MainWindow := True;
3235 Menu.OnClose := ProcGMClose;
3236 Menu.OnShow := ProcGMShow;
3237 g_GUI_AddWindow(Menu);
3239 Menu := TGUIWindow.Create('GameServerMenu');
3240 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3241 begin
3242 Name := 'mmGameServerMenu';
3243 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3244 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3245 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3246 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3247 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3248 end;
3249 Menu.DefControl := 'mmGameServerMenu';
3250 Menu.MainWindow := True;
3251 Menu.OnClose := ProcGMClose;
3252 Menu.OnShow := ProcGMShow;
3253 g_GUI_AddWindow(Menu);
3255 Menu := TGUIWindow.Create('GameClientMenu');
3256 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3257 begin
3258 Name := 'mmGameClientMenu';
3259 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3260 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3261 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3262 end;
3263 Menu.DefControl := 'mmGameClientMenu';
3264 Menu.MainWindow := True;
3265 Menu.OnClose := ProcGMClose;
3266 Menu.OnShow := ProcGMShow;
3267 g_GUI_AddWindow(Menu);
3269 Menu := TGUIWindow.Create('ClientPasswordMenu');
3270 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3271 begin
3272 Name := 'mClientPasswordMenu';
3273 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3274 begin
3275 Name := 'edPW';
3276 Width := 12;
3277 MaxLength := 32;
3278 end;
3279 AddSpace;
3281 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3282 ReAlign();
3283 end;
3284 Menu.DefControl := 'mClientPasswordMenu';
3285 g_GUI_AddWindow(Menu);
3287 Menu := TGUIWindow.Create('GameSetGameMenu');
3288 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3289 begin
3290 Name := 'mGameSetGameMenu';
3291 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3292 begin
3293 Name := 'swTeamDamage';
3294 AddItem(_lc[I_MENU_YES]);
3295 AddItem(_lc[I_MENU_NO]);
3296 ItemIndex := 1;
3297 end;
3298 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3299 begin
3300 Name := 'swDeathmatchKeys';
3301 AddItem(_lc[I_MENU_YES]);
3302 AddItem(_lc[I_MENU_NO]);
3303 ItemIndex := 1;
3304 end;
3305 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3306 begin
3307 Name := 'edTimeLimit';
3308 OnlyDigits := True;
3309 Width := 4;
3310 MaxLength := 5;
3311 end;
3312 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3313 begin
3314 Name := 'edGoalLimit';
3315 OnlyDigits := True;
3316 Width := 4;
3317 MaxLength := 5;
3318 end;
3319 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3320 begin
3321 Name := 'edMaxLives';
3322 OnlyDigits := True;
3323 Width := 4;
3324 MaxLength := 5;
3325 end;
3326 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3327 begin
3328 Name := 'swBotsVS';
3329 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3330 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3331 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3332 ItemIndex := 2;
3333 end;
3335 ReAlign();
3336 end;
3337 Menu.DefControl := 'mGameSetGameMenu';
3338 Menu.OnClose := ProcApplyGameSet;
3339 g_GUI_AddWindow(Menu);
3341 Menu := TGUIWindow.Create('TeamMenu');
3342 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3343 begin
3344 Name := 'mmTeamMenu';
3345 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3346 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3347 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3348 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3349 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3350 end;
3351 Menu.DefControl := 'mmTeamMenu';
3352 Menu.OnShow := ProcChangePlayers;
3353 g_GUI_AddWindow(Menu);
3354 end;
3356 procedure g_Menu_Show_SaveMenu();
3357 begin
3358 if g_Game_IsTestMap then
3359 Exit;
3360 if gGameSettings.GameType = GT_SINGLE then
3361 g_GUI_ShowWindow('GameSingleMenu')
3362 else
3363 begin
3364 if g_Game_IsClient then
3365 Exit
3366 else
3367 if g_Game_IsNet then
3368 Exit
3369 else
3370 g_GUI_ShowWindow('GameCustomMenu');
3371 end;
3372 g_GUI_ShowWindow('SaveMenu');
3373 g_Sound_PlayEx('MENU_OPEN');
3374 end;
3376 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3377 begin
3378 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3379 if gGameSettings.GameType = GT_SINGLE then
3380 begin
3381 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3382 end
3383 else
3384 begin
3385 if g_Game_IsClient then exit;
3386 if g_Game_IsNet then exit;
3387 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3388 end;
3389 g_GUI_ShowWindow('LoadMenu');
3390 g_Sound_PlayEx('MENU_OPEN');
3391 end;
3393 procedure g_Menu_Show_GameSetGame();
3394 begin
3395 if gGameSettings.GameType = GT_SINGLE then
3396 g_GUI_ShowWindow('GameSingleMenu')
3397 else
3398 begin
3399 if g_Game_IsClient then
3400 Exit
3401 else
3402 if g_Game_IsNet then
3403 g_GUI_ShowWindow('GameServerMenu')
3404 else
3405 g_GUI_ShowWindow('GameCustomMenu');
3406 end;
3407 ReadGameSettings();
3408 g_GUI_ShowWindow('GameSetGameMenu');
3409 g_Sound_PlayEx('MENU_OPEN');
3410 end;
3412 procedure g_Menu_Show_OptionsVideo();
3413 begin
3414 if gGameSettings.GameType = GT_SINGLE then
3415 g_GUI_ShowWindow('GameSingleMenu')
3416 else
3417 begin
3418 if g_Game_IsClient then
3419 g_GUI_ShowWindow('GameClientMenu')
3420 else
3421 if g_Game_IsNet then
3422 g_GUI_ShowWindow('GameServerMenu')
3423 else
3424 g_GUI_ShowWindow('GameCustomMenu');
3425 end;
3426 ReadOptions();
3427 g_GUI_ShowWindow('OptionsMenu');
3428 g_GUI_ShowWindow('OptionsVideoMenu');
3429 g_Sound_PlayEx('MENU_OPEN');
3430 end;
3432 procedure g_Menu_Show_OptionsSound();
3433 begin
3434 if gGameSettings.GameType = GT_SINGLE then
3435 g_GUI_ShowWindow('GameSingleMenu')
3436 else
3437 begin
3438 if g_Game_IsClient then
3439 g_GUI_ShowWindow('GameClientMenu')
3440 else
3441 if g_Game_IsNet then
3442 g_GUI_ShowWindow('GameServerMenu')
3443 else
3444 g_GUI_ShowWindow('GameCustomMenu');
3445 end;
3446 ReadOptions();
3447 g_GUI_ShowWindow('OptionsMenu');
3448 g_GUI_ShowWindow('OptionsSoundMenu');
3449 g_Sound_PlayEx('MENU_OPEN');
3450 end;
3452 procedure g_Menu_Show_EndGameMenu();
3453 begin
3454 g_GUI_ShowWindow('EndGameMenu');
3455 g_Sound_PlayEx('MENU_OPEN');
3456 end;
3458 procedure g_Menu_Show_QuitGameMenu();
3459 begin
3460 g_GUI_ShowWindow('ExitMenu');
3461 g_Sound_PlayEx('MENU_OPEN');
3462 end;
3464 procedure g_Menu_Init();
3465 begin
3466 MenuLoadData();
3467 g_GUI_Init();
3468 CreateAllMenus();
3469 end;
3471 procedure g_Menu_Free();
3472 begin
3473 g_GUI_Destroy();
3475 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3477 MenuFreeData();
3478 end;
3480 procedure g_Menu_Reset();
3481 var
3482 ex: Boolean;
3483 begin
3484 g_GUI_SaveMenuPos();
3485 ex := g_GUI_Destroy();
3487 if ex then
3488 begin
3489 e_WriteLog('Recreating menu...', TMsgType.Notify);
3491 CreateAllMenus();
3493 if gDebugMode then
3494 g_Game_SetDebugMode();
3496 g_GUI_LoadMenuPos();
3497 end;
3498 end;
3500 end.