DEADSOFTWARE

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