DEADSOFTWARE

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