DEADSOFTWARE

render: move textures loaders to render
[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.Name;
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.Name;
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 b: TModelInfo;
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 b := g_PlayerModel_GetInfo(a);
1362 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1363 begin
1364 TGUILabel(GetControl('lbName')).Text := b.Name;
1365 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1366 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1368 if b.HaveWeapon then
1369 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1370 else
1371 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1372 end;
1374 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1375 end;
1377 procedure ProcOptionsPlayersAnim();
1378 var
1379 s: String;
1380 begin
1381 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1382 s := 'P1'
1383 else
1384 s := 'P2';
1386 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1387 begin
1388 NextAnim();
1389 Model.GetCurrentAnimation.Loop := True;
1390 Model.GetCurrentAnimationMask.Loop := True;
1391 end;
1392 end;
1394 procedure ProcOptionsPlayersWeap();
1395 var
1396 s: String;
1397 begin
1398 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1399 s := 'P1'
1400 else
1401 s := 'P2';
1403 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1404 NextWeapon();
1405 end;
1407 procedure ProcOptionsPlayersRot();
1408 var
1409 s: string;
1410 begin
1411 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1412 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1413 begin
1414 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1415 end;
1416 end;
1418 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1419 begin
1420 if yes then
1421 begin
1422 g_Options_SetDefault();
1423 ReadOptions();
1424 end;
1425 g_GUI_HideWindow();
1426 end;
1428 procedure ProcSavedMenuKeyDown (yes: Boolean);
1429 begin
1430 if yes then ReadOptions();
1431 g_GUI_HideWindow();
1432 end;
1434 procedure ProcAuthorsClose();
1435 begin
1436 gMusic.SetByName('MUSIC_MENU');
1437 gMusic.Play();
1438 gState := STATE_MENU;
1439 end;
1441 procedure ProcGMClose();
1442 begin
1443 g_Game_InGameMenu(False);
1444 end;
1446 procedure ProcGMShow();
1447 var
1448 Enabled: Boolean;
1449 begin
1450 Enabled := True;
1451 if (gGameSettings.GameType = GT_SINGLE) and
1452 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1453 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1454 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1455 if not gGameOn then
1456 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1457 if g_Game_IsTestMap then
1458 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1459 TGUIMainMenu(g_ActiveWindow.GetControl(
1460 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1461 end;
1463 procedure ProcChangePlayers();
1464 var
1465 TeamGame, Spectator, AddTwo: Boolean;
1466 P1Team{, P2Team}: Byte;
1467 bP2: TGUITextButton;
1468 begin
1469 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1470 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1471 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1472 P1Team := TEAM_NONE;
1473 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1474 // TODO
1475 //P2Team := TEAM_NONE;
1476 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1478 TGUIMainMenu(g_ActiveWindow.GetControl(
1479 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1480 TGUIMainMenu(g_ActiveWindow.GetControl(
1481 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1482 TGUIMainMenu(g_ActiveWindow.GetControl(
1483 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1485 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1486 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1487 bP2.Enabled := AddTwo and not Spectator;
1488 if bP2.Enabled then
1489 bP2.Color := MAINMENU_ITEMS_COLOR
1490 else
1491 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1492 if gPlayer2 = nil then
1493 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1494 else
1495 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1497 TGUIMainMenu(g_ActiveWindow.GetControl(
1498 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1499 end;
1501 procedure ProcJoinRed();
1502 begin
1503 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1504 Exit;
1505 if g_Game_IsServer then
1506 begin
1507 if gPlayer1 = nil then
1508 g_Game_AddPlayer(TEAM_RED)
1509 else
1510 begin
1511 if gPlayer1.Team <> TEAM_RED then
1512 begin
1513 gPlayer1.SwitchTeam;
1514 gPlayer1Settings.Team := gPlayer1.Team;
1515 end;
1517 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1518 end;
1519 end
1520 else
1521 begin
1522 gPlayer1Settings.Team := TEAM_RED;
1523 MC_SEND_PlayerSettings;
1524 if gPlayer1 = nil then
1525 g_Game_AddPlayer(TEAM_RED);
1526 end;
1527 g_ActiveWindow := nil;
1528 g_Game_Pause(False);
1529 end;
1531 procedure ProcJoinBlue();
1532 begin
1533 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1534 Exit;
1535 if g_Game_IsServer then
1536 begin
1537 if gPlayer1 = nil then
1538 g_Game_AddPlayer(TEAM_BLUE)
1539 else
1540 begin
1541 if gPlayer1.Team <> TEAM_BLUE then
1542 begin
1543 gPlayer1.SwitchTeam;
1544 gPlayer1Settings.Team := gPlayer1.Team;
1545 end;
1547 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1548 end;
1549 end
1550 else
1551 begin
1552 gPlayer1Settings.Team := TEAM_BLUE;
1553 MC_SEND_PlayerSettings;
1554 if gPlayer1 = nil then
1555 g_Game_AddPlayer(TEAM_BLUE);
1556 end;
1557 g_ActiveWindow := nil;
1558 g_Game_Pause(False);
1559 end;
1561 procedure ProcJoinGame();
1562 begin
1563 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1564 Exit;
1565 if gPlayer1 = nil then
1566 g_Game_AddPlayer();
1567 g_ActiveWindow := nil;
1568 g_Game_Pause(False);
1569 end;
1571 procedure ProcSwitchP2();
1572 begin
1573 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1574 Exit;
1575 if gPlayer1 = nil then
1576 Exit;
1577 if gPlayer2 = nil then
1578 g_Game_AddPlayer()
1579 else
1580 g_Game_RemovePlayer();
1581 g_ActiveWindow := nil;
1582 g_Game_Pause(False);
1583 end;
1585 procedure ProcSpectate();
1586 begin
1587 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1588 Exit;
1589 g_Game_Spectate();
1590 g_ActiveWindow := nil;
1591 g_Game_Pause(False);
1592 end;
1594 procedure ProcRestartMenuKeyDown (yes: Boolean);
1595 begin
1596 if yes then g_Game_Restart() else g_GUI_HideWindow;
1597 end;
1599 procedure ProcEndMenuKeyDown (yes: Boolean);
1600 begin
1601 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1602 end;
1604 procedure ProcSetRussianLanguage;
1605 begin
1606 if gLanguage <> LANGUAGE_RUSSIAN then
1607 begin
1608 gLanguage := LANGUAGE_RUSSIAN;
1609 gLanguageChange := True;
1610 gAskLanguage := False;
1611 ProcApplyOptions();
1612 end;
1613 end;
1615 procedure ProcSetEnglishLanguage;
1616 begin
1617 if gLanguage <> LANGUAGE_ENGLISH then
1618 begin
1619 gLanguage := LANGUAGE_ENGLISH;
1620 gLanguageChange := True;
1621 gAskLanguage := False;
1622 ProcApplyOptions();
1623 end;
1624 end;
1626 procedure ReadGameSettings();
1627 var
1628 menu: TGUIMenu;
1629 begin
1630 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1632 with gGameSettings do
1633 begin
1634 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1635 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1636 ItemIndex := 0
1637 else
1638 ItemIndex := 1;
1639 with TGUISwitch(menu.GetControl('swTeamHit')) do
1640 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1641 ItemIndex := 0
1642 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1643 ItemIndex := 1
1644 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1645 ItemIndex := 2
1646 else
1647 ItemIndex := 3;
1648 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1649 if LongBool(Options and GAME_OPTION_DMKEYS) then
1650 ItemIndex := 0
1651 else
1652 ItemIndex := 1;
1654 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1655 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1656 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1658 with TGUISwitch(menu.GetControl('swBotsVS')) do
1659 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1660 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1661 ItemIndex := 2
1662 else
1663 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1664 ItemIndex := 1
1665 else
1666 ItemIndex := 0;
1668 if GameType in [GT_CUSTOM, GT_SERVER] then
1669 begin
1670 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1671 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1672 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1673 begin
1674 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1675 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1676 end
1677 else
1678 begin
1679 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1680 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1681 end;
1682 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1683 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1684 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1685 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1686 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1687 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1688 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1689 end
1690 else
1691 begin
1692 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1693 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1694 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1695 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1696 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1697 begin
1698 Enabled := False;
1699 Text := '';
1700 end;
1701 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1702 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1703 begin
1704 Enabled := False;
1705 Text := '';
1706 end;
1707 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1708 with TGUIEdit(menu.GetControl('edMaxLives')) do
1709 begin
1710 Enabled := False;
1711 Text := '';
1712 end;
1713 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1714 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1715 end;
1716 end;
1717 end;
1719 procedure ProcApplyGameSet();
1720 var
1721 menu: TGUIMenu;
1722 a, b, n: Integer;
1723 stat: TPlayerStatArray;
1724 begin
1725 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1727 if not g_Game_IsServer then Exit;
1729 with gGameSettings do
1730 begin
1731 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1732 begin
1733 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1734 Options := Options or GAME_OPTION_TEAMDAMAGE
1735 else
1736 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1737 end;
1739 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1740 begin
1741 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1742 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1743 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1744 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1745 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1746 end;
1747 end;
1749 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1750 begin
1751 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1752 Options := Options or GAME_OPTION_DMKEYS
1753 else
1754 Options := Options and (not GAME_OPTION_DMKEYS);
1755 end;
1757 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1758 begin
1759 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1761 if n = 0 then
1762 TimeLimit := 0
1763 else
1764 begin
1765 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1767 TimeLimit := Max(n, b);
1768 end;
1769 end;
1771 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1772 begin
1773 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1775 if n = 0 then
1776 GoalLimit := 0
1777 else
1778 begin
1779 b := 0;
1780 if GameMode = GM_DM then
1781 begin // DM
1782 stat := g_Player_GetStats();
1783 if stat <> nil then
1784 for a := 0 to High(stat) do
1785 if stat[a].Frags > b then
1786 b := stat[a].Frags;
1787 end
1788 else // CTF
1789 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1791 GoalLimit := Max(n, b);
1792 end;
1793 end;
1795 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1796 begin
1797 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1798 if n < 0 then n := 0;
1799 if n > 255 then n := 255;
1800 if n = 0 then
1801 MaxLives := 0
1802 else
1803 begin
1804 b := 0;
1805 stat := g_Player_GetStats();
1806 if stat <> nil then
1807 for a := 0 to High(stat) do
1808 if stat[a].Lives > b then
1809 b := stat[a].Lives;
1811 MaxLives := Max(n, b);
1812 end;
1813 end;
1815 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1816 begin
1817 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1818 1:
1819 begin
1820 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1821 Options := Options or GAME_OPTION_BOTVSMONSTER;
1822 end;
1823 2:
1824 begin
1825 Options := Options or GAME_OPTION_BOTVSPLAYER;
1826 Options := Options or GAME_OPTION_BOTVSMONSTER;
1827 end;
1828 else
1829 begin
1830 Options := Options or GAME_OPTION_BOTVSPLAYER;
1831 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1832 end;
1833 end;
1834 end;
1836 // don't forget to latch this shit
1837 gsGameFlags := Options;
1838 gsMaxLives := MaxLives;
1839 gsGoalLimit := GoalLimit;
1840 gsTimeLimit := TimeLimit;
1841 end;
1843 if g_Game_IsNet then MH_SEND_GameSettings;
1844 end;
1846 procedure ProcVideoOptionsRes();
1847 var
1848 menu: TGUIMenu;
1849 list: SSArray;
1850 begin
1851 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1853 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1854 IntToStr(gWinSizeX) +
1855 ' x ' + IntToStr(gWinSizeY) +
1856 ', ' + IntToStr(gBPP) + ' bpp';
1858 with TGUIListBox(menu.GetControl('lsResolution')) do
1859 begin
1860 list := sys_GetDisplayModes(gBPP);
1861 if list <> nil then
1862 begin
1863 Items := list;
1864 ItemIndex := Length(list)
1865 end
1866 else
1867 begin
1868 Clear
1869 end
1870 end;
1872 with TGUISwitch(menu.GetControl('swFullScreen')) do
1873 if gFullscreen then
1874 ItemIndex := 0
1875 else
1876 ItemIndex := 1;
1878 TempResScale := Round(r_pixel_scale - 1);
1879 with TGUISwitch(menu.GetControl('swResFactor')) do
1880 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1881 end;
1883 procedure ProcApplyVideoOptions();
1884 var
1885 menu: TGUIMenu;
1886 Fullscreen: Boolean;
1887 SWidth, SHeight: Integer;
1888 ScaleChanged: Boolean;
1889 str: String;
1890 begin
1891 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1893 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1894 if str <> '' then
1895 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1896 else
1897 begin
1898 SWidth := gWinSizeX;
1899 SHeight := gWinSizeY;
1900 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1901 end;
1903 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1905 ScaleChanged := False;
1906 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1907 begin
1908 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1909 r_pixel_scale := TempResScale + 1;
1910 ScaleChanged := True;
1911 end;
1913 if (SWidth <> gWinSizeX) or
1914 (SHeight <> gWinSizeY) or
1915 (Fullscreen <> gFullscreen) or
1916 ScaleChanged then
1917 begin
1918 gResolutionChange := True;
1919 gRC_Width := SWidth;
1920 gRC_Height := SHeight;
1921 gRC_FullScreen := Fullscreen;
1922 gRC_Maximized := gWinMaximized;
1923 end;
1925 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1926 ProcApplyOptions();
1927 end;
1929 procedure ProcSetFirstRussianLanguage;
1930 begin
1931 gLanguage := LANGUAGE_RUSSIAN;
1932 gLanguageChange := True;
1933 gAskLanguage := False;
1934 end;
1936 procedure ProcSetFirstEnglishLanguage;
1937 begin
1938 gLanguage := LANGUAGE_ENGLISH;
1939 gLanguageChange := True;
1940 gAskLanguage := False;
1941 end;
1943 procedure ProcRecallAddress();
1944 begin
1945 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1946 begin
1947 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1948 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1949 end;
1950 end;
1952 procedure CreateFirstLanguageMenu();
1953 var
1954 Menu: TGUIWindow;
1955 begin
1956 Menu := TGUIWindow.Create('FirstLanguageMenu');
1958 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1959 begin
1960 Name := 'mmFirstLanguageMenu';
1961 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1962 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1963 end;
1965 Menu.DefControl := 'mmFirstLanguageMenu';
1966 Menu.MainWindow := True;
1967 g_GUI_AddWindow(Menu);
1968 end;
1970 procedure g_Menu_AskLanguage();
1971 begin
1972 CreateFirstLanguageMenu();
1973 g_GUI_ShowWindow('FirstLanguageMenu');
1974 end;
1976 procedure CreatePlayerOptionsMenu(s: String);
1977 var
1978 Menu: TGUIWindow;
1979 a: String;
1980 begin
1981 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1982 if s = 'P1' then
1983 a := _lc[I_MENU_PLAYER_1]
1984 else
1985 a := _lc[I_MENU_PLAYER_2];
1986 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1987 begin
1988 Name := 'mOptionsPlayers'+s+'Menu';
1989 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1990 begin
1991 Name := 'ed'+s+'Name';
1992 MaxLength := 12;
1993 Width := 12;
1994 end;
1995 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1996 begin
1997 Name := 'sw'+s+'Team';
1998 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1999 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2000 end ;
2001 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2002 begin
2003 Name := 'ls'+s+'Model';
2004 Sort := True;
2005 Items := g_PlayerModel_GetNames();
2006 OnChange := ProcSelectModel;
2007 end;
2008 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2009 begin
2010 Name := 'sc'+s+'Red';
2011 Max := 16;
2012 OnChange := ProcChangeColor;
2013 end;
2014 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2015 begin
2016 Name := 'sc'+s+'Green';
2017 Max := 16;
2018 OnChange := ProcChangeColor;
2019 end;
2020 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2021 begin
2022 Name := 'sc'+s+'Blue';
2023 Max := 16;
2024 OnChange := ProcChangeColor;
2025 end;
2026 AddSpace();
2027 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2028 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2029 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2030 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2032 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2033 begin
2034 Name := 'mv'+s+'Model';
2035 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2036 Y := GetControl('ls'+s+'Model').Y;
2037 end;
2038 end;
2039 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2040 g_GUI_AddWindow(Menu);
2041 end;
2043 procedure CreateAllMenus();
2044 var
2045 Menu: TGUIWindow;
2046 //SR: TSearchRec;
2047 a, cx, _y, i: Integer;
2048 //list: SSArray;
2049 begin
2050 Menu := TGUIWindow.Create('MainMenu');
2051 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2052 begin
2053 Name := 'mmMainMenu';
2054 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2055 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2056 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2057 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2058 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2059 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2060 end;
2061 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2062 begin
2063 Color := _RGB(255, 255, 255);
2064 X := gScreenWidth-GetWidth-8;
2065 Y := gScreenHeight-GetHeight-8;
2066 end;
2067 Menu.DefControl := 'mmMainMenu';
2068 Menu.MainWindow := True;
2069 g_GUI_AddWindow(Menu);
2071 Menu := TGUIWindow.Create('NewGameMenu');
2072 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2073 begin
2074 Name := 'mmNewGameMenu';
2075 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2076 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2077 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2078 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2079 end;
2080 Menu.DefControl := 'mmNewGameMenu';
2081 g_GUI_AddWindow(Menu);
2083 Menu := TGUIWindow.Create('NetGameMenu');
2084 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2085 begin
2086 Name := 'mmNetGameMenu';
2087 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2088 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2089 end;
2090 Menu.DefControl := 'mmNetGameMenu';
2091 g_GUI_AddWindow(Menu);
2093 Menu := TGUIWindow.Create('NetServerMenu');
2094 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2095 begin
2096 Name := 'mNetServerMenu';
2097 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2098 begin
2099 Name := 'edSrvName';
2100 OnlyDigits := False;
2101 Width := 16;
2102 MaxLength := 64;
2103 Text := NetServerName;
2104 end;
2105 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2106 begin
2107 Name := 'edSrvPassword';
2108 OnlyDigits := False;
2109 Width := 16;
2110 MaxLength := 24;
2111 Text := NetPassword;
2112 end;
2113 with AddEdit(_lc[I_NET_PORT]) do
2114 begin
2115 Name := 'edPort';
2116 OnlyDigits := True;
2117 Width := 4;
2118 MaxLength := 5;
2119 Text := IntToStr(NetPort);
2120 end;
2121 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2122 begin
2123 Name := 'edMaxPlayers';
2124 OnlyDigits := True;
2125 Width := 4;
2126 MaxLength := 2;
2127 Text := IntToStr(NetMaxClients);
2128 end;
2129 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2130 begin
2131 Name := 'swUseMaster';
2132 AddItem(_lc[I_MENU_YES]);
2133 AddItem(_lc[I_MENU_NO]);
2134 if NetUseMaster then
2135 ItemIndex := 0
2136 else
2137 ItemIndex := 1;
2138 end;
2139 AddSpace();
2140 with AddLabel(_lc[I_MENU_MAP]) do
2141 begin
2142 Name := 'lbMap';
2143 FixedLength := 16;
2144 Text := gsMap;
2145 OnClick := @ProcSelectMapMenu;
2146 end;
2147 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2148 begin
2149 Name := 'swGameMode';
2150 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2151 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2152 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2153 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2154 case g_Game_TextToMode(gsGameMode) of
2155 GM_NONE,
2156 GM_DM: ItemIndex := 0;
2157 GM_TDM: ItemIndex := 1;
2158 GM_CTF: ItemIndex := 2;
2159 GM_SINGLE,
2160 GM_COOP: ItemIndex := 3;
2161 end;
2162 OnChange := ProcSwitchMonstersCustom;
2163 end;
2164 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2165 begin
2166 Name := 'edTimeLimit';
2167 OnlyDigits := True;
2168 Width := 4;
2169 MaxLength := 5;
2170 if gsTimeLimit > 0 then
2171 Text := IntToStr(gsTimeLimit);
2172 end;
2173 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2174 begin
2175 Name := 'edGoalLimit';
2176 OnlyDigits := True;
2177 Width := 4;
2178 MaxLength := 5;
2179 if gsGoalLimit > 0 then
2180 Text := IntToStr(gsGoalLimit);
2181 end;
2182 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2183 begin
2184 Name := 'edMaxLives';
2185 OnlyDigits := True;
2186 Width := 4;
2187 MaxLength := 5;
2188 if gsMaxLives > 0 then
2189 Text := IntToStr(gsMaxLives);
2190 end;
2191 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2192 begin
2193 Name := 'edItemRespawnTime';
2194 OnlyDigits := True;
2195 Width := 4;
2196 MaxLength := 5;
2197 if gsItemRespawnTime > 0 then
2198 Text := IntToStr(gsItemRespawnTime);
2199 end;
2200 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2201 begin
2202 Name := 'swPlayers';
2203 AddItem(_lc[I_MENU_COUNT_NONE]);
2204 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2205 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2206 ItemIndex := gsPlayers;
2207 end;
2208 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2209 begin
2210 Name := 'swTeamDamage';
2211 AddItem(_lc[I_MENU_YES]);
2212 AddItem(_lc[I_MENU_NO]);
2213 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2214 ItemIndex := 0
2215 else
2216 ItemIndex := 1;
2217 end;
2218 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2219 begin
2220 Name := 'swTeamHit';
2221 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2222 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2223 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2224 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2225 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2226 ItemIndex := 0
2227 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2228 ItemIndex := 1
2229 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2230 ItemIndex := 2
2231 else
2232 ItemIndex := 3;
2233 end;
2234 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2235 begin
2236 Name := 'swDeathmatchKeys';
2237 AddItem(_lc[I_MENU_YES]);
2238 AddItem(_lc[I_MENU_NO]);
2239 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2240 ItemIndex := 0
2241 else
2242 ItemIndex := 1;
2243 end;
2244 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2245 begin
2246 Name := 'swEnableExits';
2247 AddItem(_lc[I_MENU_YES]);
2248 AddItem(_lc[I_MENU_NO]);
2249 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2250 ItemIndex := 0
2251 else
2252 ItemIndex := 1;
2253 end;
2254 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2255 begin
2256 Name := 'swWeaponStay';
2257 AddItem(_lc[I_MENU_YES]);
2258 AddItem(_lc[I_MENU_NO]);
2259 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2260 ItemIndex := 0
2261 else
2262 ItemIndex := 1;
2263 end;
2264 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2265 begin
2266 Name := 'swMonsters';
2267 AddItem(_lc[I_MENU_YES]);
2268 AddItem(_lc[I_MENU_NO]);
2269 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2270 ItemIndex := 0
2271 else
2272 ItemIndex := 1;
2273 end;
2274 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2275 begin
2276 Name := 'swBotsVS';
2277 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2278 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2279 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2280 ItemIndex := 2;
2281 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2282 ItemIndex := 0;
2283 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2284 ItemIndex := 1;
2285 end;
2286 AddSpace();
2287 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2289 ReAlign();
2290 end;
2291 Menu.DefControl := 'mNetServerMenu';
2292 g_GUI_AddWindow(Menu);
2294 Menu := TGUIWindow.Create('NetClientMenu');
2295 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2296 begin
2297 Name := 'mNetClientMenu';
2299 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2300 AddSpace();
2302 with AddEdit(_lc[I_NET_ADDRESS]) do
2303 begin
2304 Name := 'edIP';
2305 OnlyDigits :=False;
2306 Width := 12;
2307 MaxLength := 64;
2308 Text := 'localhost';
2309 end;
2310 with AddEdit(_lc[I_NET_PORT]) do
2311 begin
2312 Name := 'edPort';
2313 OnlyDigits := True;
2314 Width := 4;
2315 MaxLength := 5;
2316 Text := '25666';
2317 end;
2318 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2319 begin
2320 Name := 'edPW';
2321 OnlyDigits := False;
2322 Width := 12;
2323 MaxLength := 32;
2324 Text := '';
2325 end;
2327 AddSpace();
2328 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2330 ReAlign();
2331 end;
2332 Menu.DefControl := 'mNetClientMenu';
2333 g_GUI_AddWindow(Menu);
2335 Menu := TGUIWindow.Create('LoadMenu');
2336 Menu.OnShow := ProcLoadMenu;
2337 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2338 begin
2339 Name := 'mmLoadMenu';
2341 for a := 1 to 8 do
2342 with AddEdit('') do
2343 begin
2344 Name := 'edSlot'+IntToStr(a);
2345 Width := 16;
2346 MaxLength := 16;
2347 OnEnter := ProcLoadGame;
2348 end;
2349 end;
2350 Menu.DefControl := 'mmLoadMenu';
2351 g_GUI_AddWindow(Menu);
2353 Menu := TGUIWindow.Create('SaveMenu');
2354 Menu.OnShow := ProcSaveMenu;
2355 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2356 begin
2357 Name := 'mmSaveMenu';
2359 for a := 1 to 8 do
2360 with AddEdit('') do
2361 begin
2362 Name := 'edSlot'+IntToStr(a);
2363 Width := 16;
2364 MaxLength := 16;
2365 OnChange := ProcSaveGame;
2366 end;
2367 end;
2368 Menu.DefControl := 'mmSaveMenu';
2369 g_GUI_AddWindow(Menu);
2371 Menu := TGUIWindow.Create('CustomGameMenu');
2372 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2373 begin
2374 Name := 'mCustomGameMenu';
2375 with AddLabel(_lc[I_MENU_MAP]) do
2376 begin
2377 Name := 'lbMap';
2378 FixedLength := 16;
2379 Text := gsMap;
2380 OnClick := @ProcSelectMapMenu;
2381 end;
2382 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2383 begin
2384 Name := 'swGameMode';
2385 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2386 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2387 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2388 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2389 case g_Game_TextToMode(gsGameMode) of
2390 GM_NONE,
2391 GM_DM: ItemIndex := 0;
2392 GM_TDM: ItemIndex := 1;
2393 GM_CTF: ItemIndex := 2;
2394 GM_SINGLE,
2395 GM_COOP: ItemIndex := 3;
2396 end;
2397 OnChange := ProcSwitchMonstersCustom;
2398 end;
2399 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2400 begin
2401 Name := 'edTimeLimit';
2402 OnlyDigits := True;
2403 Width := 4;
2404 MaxLength := 5;
2405 if gsTimeLimit > 0 then
2406 Text := IntToStr(gsTimeLimit);
2407 end;
2408 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2409 begin
2410 Name := 'edGoalLimit';
2411 OnlyDigits := True;
2412 Width := 4;
2413 MaxLength := 5;
2414 if gsGoalLimit > 0 then
2415 Text := IntToStr(gsGoalLimit);
2416 end;
2417 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2418 begin
2419 Name := 'edMaxLives';
2420 OnlyDigits := True;
2421 Width := 4;
2422 MaxLength := 5;
2423 if gsMaxLives > 0 then
2424 Text := IntToStr(gsMaxLives);
2425 end;
2426 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2427 begin
2428 Name := 'edItemRespawnTime';
2429 OnlyDigits := True;
2430 Width := 4;
2431 MaxLength := 5;
2432 if gsItemRespawnTime > 0 then
2433 Text := IntToStr(gsItemRespawnTime);
2434 end;
2435 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2436 begin
2437 Name := 'swPlayers';
2438 AddItem(_lc[I_MENU_COUNT_NONE]);
2439 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2440 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2441 ItemIndex := gsPlayers;
2442 end;
2443 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2444 begin
2445 Name := 'swTeamDamage';
2446 AddItem(_lc[I_MENU_YES]);
2447 AddItem(_lc[I_MENU_NO]);
2448 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2449 ItemIndex := 0
2450 else
2451 ItemIndex := 1;
2452 end;
2453 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2454 begin
2455 Name := 'swTeamHit';
2456 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2457 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2458 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2459 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2460 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2461 ItemIndex := 0
2462 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2463 ItemIndex := 1
2464 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2465 ItemIndex := 2
2466 else
2467 ItemIndex := 3;
2468 end;
2469 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2470 begin
2471 Name := 'swDeathmatchKeys';
2472 AddItem(_lc[I_MENU_YES]);
2473 AddItem(_lc[I_MENU_NO]);
2474 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2475 ItemIndex := 0
2476 else
2477 ItemIndex := 1;
2478 end;
2479 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2480 begin
2481 Name := 'swEnableExits';
2482 AddItem(_lc[I_MENU_YES]);
2483 AddItem(_lc[I_MENU_NO]);
2484 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2485 ItemIndex := 0
2486 else
2487 ItemIndex := 1;
2488 end;
2489 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2490 begin
2491 Name := 'swWeaponStay';
2492 AddItem(_lc[I_MENU_YES]);
2493 AddItem(_lc[I_MENU_NO]);
2494 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2495 ItemIndex := 0
2496 else
2497 ItemIndex := 1;
2498 end;
2499 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2500 begin
2501 Name := 'swMonsters';
2502 AddItem(_lc[I_MENU_YES]);
2503 AddItem(_lc[I_MENU_NO]);
2504 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2505 ItemIndex := 0
2506 else
2507 ItemIndex := 1;
2508 end;
2509 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2510 begin
2511 Name := 'swBotsVS';
2512 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2513 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2514 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2515 ItemIndex := 2;
2516 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2517 ItemIndex := 0;
2518 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2519 ItemIndex := 1;
2520 end;
2521 AddSpace();
2522 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2524 ReAlign();
2525 end;
2526 Menu.DefControl := 'mCustomGameMenu';
2527 g_GUI_AddWindow(Menu);
2529 Menu := TGUIWindow.Create('CampaignMenu');
2530 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2531 begin
2532 Name := 'mCampaignMenu';
2534 AddSpace();
2535 AddSpace();
2536 AddSpace();
2537 AddSpace();
2538 AddSpace();
2539 AddSpace();
2541 with AddFileList('', 15, 4) do
2542 begin
2543 Name := 'lsWAD';
2544 OnChange := ProcSelectCampaignWAD;
2546 Sort := True;
2547 Dirs := True;
2548 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2549 SetBase(MegawadDirs);
2550 end;
2552 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2553 begin
2554 Name := 'lbWADName';
2555 FixedLength := 8;
2556 Enabled := False;
2557 end;
2558 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2559 begin
2560 Name := 'lbWADAuthor';
2561 FixedLength := 8;
2562 Enabled := False;
2563 end;
2564 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2565 with AddMemo('', 15, 3) do
2566 begin
2567 Name := 'meWADDescription';
2568 Color := MENU_ITEMSCTRL_COLOR;
2569 end;
2570 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2571 begin
2572 Name := 'swPlayers';
2573 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2574 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2575 end;
2576 AddSpace();
2577 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2579 ReAlign();
2581 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2582 begin
2583 Name := 'mpWADImage';
2584 DefaultRes := 'NOPIC';
2585 X := GetControl('lsWAD').X+4;
2586 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2587 end;
2588 end;
2589 Menu.DefControl := 'mCampaignMenu';
2590 g_GUI_AddWindow(Menu);
2592 Menu := TGUIWindow.Create('SelectMapMenu');
2593 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2594 begin
2595 Name := 'mSelectMapMenu';
2596 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2597 begin
2598 Name := 'lsMapWAD';
2599 OnChange := ProcSelectWAD;
2601 Sort := True;
2602 Dirs := True;
2603 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2604 SetBase(MapDirs);
2605 end;
2606 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2607 begin
2608 Name := 'lsMapRes';
2609 Sort := True;
2610 OnChange := ProcSelectMap;
2611 end;
2612 AddSpace();
2613 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2614 begin
2615 Name := 'lbMapName';
2616 FixedLength := 24;
2617 Enabled := False;
2618 end;
2619 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2620 begin
2621 Name := 'lbMapAuthor';
2622 FixedLength := 16;
2623 Enabled := False;
2624 end;
2625 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2626 begin
2627 Name := 'lbMapSize';
2628 FixedLength := 10;
2629 Enabled := False;
2630 end;
2631 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2632 begin
2633 Name := 'meMapDescription';
2634 end;
2636 ReAlign();
2638 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2639 begin
2640 Name := 'mpMapPreview';
2641 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2642 Y := GetControl('lsMapWAD').Y;
2643 end;
2644 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2645 begin
2646 Name := 'lbMapScale';
2647 FixedLength := 8;
2648 Enabled := False;
2649 Color := MENU_ITEMSCTRL_COLOR;
2650 X := GetControl('lsMapWAD').X +
2651 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2652 2 + MAPPREVIEW_WIDTH*4;
2653 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2654 end;
2655 end;
2656 Menu.OnClose := ProcSetMap;
2657 Menu.DefControl := 'mSelectMapMenu';
2658 g_GUI_AddWindow(Menu);
2660 Menu := TGUIWindow.Create('OptionsMenu');
2661 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2662 begin
2663 Name := 'mmOptionsMenu';
2664 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2665 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2666 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2667 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2668 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2669 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2670 AddSpace();
2671 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2672 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2673 end;
2674 Menu.OnClose := ProcApplyOptions;
2675 Menu.DefControl := 'mmOptionsMenu';
2676 g_GUI_AddWindow(Menu);
2678 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2679 gMenuSmallFont, @ProcSavedMenuKeyDown);
2680 g_GUI_AddWindow(Menu);
2682 Menu := TGUIWindow.Create('OptionsVideoMenu');
2683 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2684 begin
2685 Name := 'mOptionsVideoMenu';
2686 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2687 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2688 begin
2689 Name := 'swBPP';
2690 AddItem('16');
2691 AddItem('32');
2692 end;
2693 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2694 begin
2695 Name := 'swVSync';
2696 AddItem(_lc[I_MENU_YES]);
2697 AddItem(_lc[I_MENU_NO]);
2698 end;
2699 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2700 begin
2701 Name := 'swTextureFilter';
2702 AddItem(_lc[I_MENU_YES]);
2703 AddItem(_lc[I_MENU_NO]);
2704 end;
2705 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2706 begin
2707 Name := 'swInterp';
2708 AddItem(_lc[I_MENU_YES]);
2709 AddItem(_lc[I_MENU_NO]);
2710 end;
2711 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2712 begin
2713 Name := 'swLegacyNPOT';
2714 AddItem(_lc[I_MENU_NO]);
2715 AddItem(_lc[I_MENU_YES]);
2716 end;
2717 AddSpace();
2718 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2719 ReAlign();
2720 end;
2721 Menu.DefControl := 'mOptionsVideoMenu';
2722 g_GUI_AddWindow(Menu);
2724 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2725 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2726 begin
2727 Name := 'mOptionsVideoResMenu';
2728 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2729 begin
2730 Name := 'lbCurrentRes';
2731 FixedLength := 24;
2732 Enabled := False;
2733 end;
2734 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2735 begin
2736 Name := 'lsResolution';
2737 Sort := False;
2738 end;
2739 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2740 begin
2741 Name := 'swFullScreen';
2742 AddItem(_lc[I_MENU_YES]);
2743 AddItem(_lc[I_MENU_NO]);
2744 end;
2745 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2746 begin
2747 Name := 'swResFactor';
2748 AddItem('1x');
2749 for i := 2 to gRC_Width div 640 do
2750 AddItem(IntToStr(i) + 'x');
2751 end;
2752 AddSpace();
2753 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2754 UpdateIndex();
2755 end;
2756 Menu.DefControl := 'mOptionsVideoResMenu';
2757 g_GUI_AddWindow(Menu);
2759 Menu := TGUIWindow.Create('OptionsSoundMenu');
2760 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2761 begin
2762 Name := 'mOptionsSoundMenu';
2763 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2764 begin
2765 Name := 'scMusicLevel';
2766 Max := 16;
2767 OnChange := ProcChangeSoundSettings;
2768 end;
2769 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2770 begin
2771 Name := 'scSoundLevel';
2772 Max := 16;
2773 OnChange := ProcChangeSoundSettings;
2774 end;
2775 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2776 begin
2777 Name := 'scMaxSimSounds';
2778 Max := 16;
2779 end;
2780 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2781 begin;
2782 Name := 'swAnnouncer';
2783 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2784 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2785 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2786 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2787 end;
2788 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2789 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2790 begin;
2791 Name := 'swSoundEffects';
2792 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2793 AddItem(_lc[I_MENU_COMPAT_DF]);
2794 end;
2795 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2796 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2797 begin;
2798 Name := 'swChatSpeech';
2799 AddItem(_lc[I_MENU_YES]);
2800 AddItem(_lc[I_MENU_NO]);
2801 end;
2802 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2803 begin
2804 Name := 'swInactiveSounds';
2805 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2806 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2807 end;
2808 ReAlign();
2809 end;
2810 Menu.DefControl := 'mOptionsSoundMenu';
2811 g_GUI_AddWindow(Menu);
2813 Menu := TGUIWindow.Create('OptionsGameMenu');
2814 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2815 begin
2816 Name := 'mOptionsGameMenu';
2817 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2818 begin
2819 Name := 'scParticlesCount';
2820 Max := 20;
2821 end;
2822 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2823 begin
2824 Name := 'swBloodCount';
2825 AddItem(_lc[I_MENU_COUNT_NONE]);
2826 AddItem(_lc[I_MENU_COUNT_SMALL]);
2827 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2828 AddItem(_lc[I_MENU_COUNT_BIG]);
2829 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2830 end;
2831 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2832 begin
2833 Name := 'scShellsMax';
2834 Max := 20;
2835 end;
2836 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2837 begin
2838 Name := 'scGibsMax';
2839 Max := 20;
2840 end;
2841 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2842 begin
2843 Name := 'scCorpsesMax';
2844 Max := 20;
2845 end;
2846 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2847 begin
2848 Name := 'swGibsCount';
2849 AddItem(_lc[I_MENU_COUNT_NONE]);
2850 AddItem(_lc[I_MENU_COUNT_SMALL]);
2851 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2852 AddItem(_lc[I_MENU_COUNT_BIG]);
2853 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2854 end;
2855 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2856 begin
2857 Name := 'swCorpseType';
2858 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2859 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2860 end;
2861 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2862 begin
2863 Name := 'swGibsType';
2864 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2865 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2866 end;
2867 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2868 begin
2869 Name := 'swBloodType';
2870 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2871 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2872 end;
2873 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2874 begin
2875 Name := 'swScreenFlash';
2876 AddItem(_lc[I_MENU_NO]);
2877 AddItem(_lc[I_MENU_COMPAT_DF]);
2878 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2879 end;
2880 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2881 begin
2882 Name := 'swBackground';
2883 AddItem(_lc[I_MENU_YES]);
2884 AddItem(_lc[I_MENU_NO]);
2885 end;
2886 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2887 begin
2888 Name := 'swMessages';
2889 AddItem(_lc[I_MENU_YES]);
2890 AddItem(_lc[I_MENU_NO]);
2891 end;
2892 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2893 begin
2894 Name := 'swRevertPlayers';
2895 AddItem(_lc[I_MENU_YES]);
2896 AddItem(_lc[I_MENU_NO]);
2897 end;
2898 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2899 begin
2900 Name := 'swChatBubble';
2901 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2902 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2903 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2904 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2905 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2906 end;
2907 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2908 begin
2909 Name := 'swPlayerIndicator';
2910 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2911 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2912 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2913 end;
2914 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2915 begin
2916 Name := 'swPlayerIndicatorStyle';
2917 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2918 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2919 end;
2920 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2921 begin
2922 Name := 'scScaleFactor';
2923 Max := 10;
2924 OnChange := ProcChangeGameSettings;
2925 end;
2926 ReAlign();
2927 end;
2928 Menu.DefControl := 'mOptionsGameMenu';
2929 g_GUI_AddWindow(Menu);
2931 Menu := TGUIWindow.Create('OptionsControlsMenu');
2932 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2933 begin
2934 Name := 'mOptionsControlsMenu';
2935 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2936 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2937 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2938 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2939 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2940 AddSpace();
2941 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2942 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2943 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2944 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2945 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2946 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2947 if e_HasJoysticks then
2948 begin
2949 AddSpace();
2950 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2951 end;
2952 if g_touch_enabled then
2953 begin
2954 AddSpace();
2955 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2956 end;
2957 end;
2958 Menu.DefControl := 'mOptionsControlsMenu';
2959 g_GUI_AddWindow(Menu);
2961 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2962 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2963 begin
2964 Name := 'mOptionsControlsP1Menu';
2965 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2966 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2967 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2968 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2969 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2970 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2971 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2972 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2973 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2974 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2975 end;
2976 Menu.DefControl := 'mOptionsControlsP1Menu';
2977 g_GUI_AddWindow(Menu);
2979 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2980 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2981 begin
2982 Name := 'mOptionsControlsP1MenuWeapons';
2983 for i := WP_FIRST to WP_LAST do
2984 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2985 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2986 end;
2987 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2988 g_GUI_AddWindow(Menu);
2990 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2991 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2992 begin
2993 Name := 'mOptionsControlsP2Menu';
2994 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2995 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2996 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2997 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2998 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2999 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3000 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3001 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3002 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3003 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3004 end;
3005 Menu.DefControl := 'mOptionsControlsP2Menu';
3006 g_GUI_AddWindow(Menu);
3008 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3009 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3010 begin
3011 Name := 'mOptionsControlsP2MenuWeapons';
3012 for i := WP_FIRST to WP_LAST do
3013 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3014 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3015 end;
3016 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3017 g_GUI_AddWindow(Menu);
3019 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3020 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3021 begin
3022 Name := 'mOptionsControlsJoystickMenu';
3023 for i := 0 to e_MaxJoys - 1 do
3024 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3025 begin
3026 Name := 'scDeadzone' + IntToStr(i);
3027 Max := 20
3028 end
3029 end;
3030 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3031 g_GUI_AddWindow(Menu);
3033 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3034 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
3035 begin
3036 Name := 'mOptionsControlsTouchMenu';
3037 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3038 begin
3039 Name := 'swTouchAlt';
3040 AddItem(_lc[I_MENU_NO]);
3041 AddItem(_lc[I_MENU_YES]);
3042 OnChange := ProcChangeTouchSettings;
3043 end;
3044 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3045 begin
3046 Name := 'scTouchSize';
3047 Max := 20;
3048 OnChange := ProcChangeTouchSettings;
3049 end;
3050 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3051 begin
3052 Name := 'swTouchFire';
3053 AddItem(_lc[I_MENU_NO]);
3054 AddItem(_lc[I_MENU_YES]);
3055 end;
3056 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3057 begin
3058 Name := 'scTouchOffset';
3059 Max := 20;
3060 OnChange := ProcChangeTouchSettings;
3061 end;
3062 end;
3063 Menu.DefControl := 'mOptionsControlsTouchMenu';
3064 g_GUI_AddWindow(Menu);
3066 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3067 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3068 begin
3069 Name := 'mOptionsPlayersMenu';
3070 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3071 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3072 end;
3073 Menu.DefControl := 'mOptionsPlayersMenu';
3074 g_GUI_AddWindow(Menu);
3076 CreatePlayerOptionsMenu('P1');
3077 CreatePlayerOptionsMenu('P2');
3079 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3080 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3081 begin
3082 Name := 'mOptionsPlayersMIMenu';
3083 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3084 begin
3085 Name := 'lbName';
3086 FixedLength := 16;
3087 end;
3088 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3089 begin
3090 Name := 'lbAuthor';
3091 FixedLength := 16;
3092 end;
3093 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3094 begin
3095 Name := 'meComment';
3096 end;
3097 AddSpace();
3098 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3099 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3100 begin
3101 Name := 'lbWeapon';
3102 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3103 end;
3104 ReAlign();
3105 end;
3106 Menu.DefControl := 'mOptionsPlayersMIMenu';
3107 g_GUI_AddWindow(Menu);
3109 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3110 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3111 begin
3112 Name := 'mOptionsLanguageMenu';
3113 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3114 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3115 ReAlign();
3116 end;
3117 Menu.DefControl := 'mOptionsLanguageMenu';
3118 g_GUI_AddWindow(Menu);
3120 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3121 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3122 g_GUI_AddWindow(Menu);
3124 Menu := TGUIWindow.Create('AuthorsMenu');
3125 Menu.BackTexture := 'INTER';
3126 Menu.OnClose := ProcAuthorsClose;
3128 // Çàãîëîâîê:
3129 _y := 16;
3130 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3131 begin
3132 Color := _RGB(255, 0, 0);
3133 X := (gScreenWidth div 2)-(GetWidth() div 2);
3134 Y := _y;
3135 _y := _y+GetHeight();
3136 end;
3137 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3138 begin
3139 Color := _RGB(255, 0, 0);
3140 X := (gScreenWidth div 2)-(GetWidth() div 2);
3141 Y := _y;
3142 _y := _y+GetHeight()+32;
3143 end;
3144 // ×òî äåëàë: Êòî äåëàë
3145 cx := gScreenWidth div 2 - 320 + 64;
3146 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3147 begin
3148 Color := _RGB(255, 0, 0);
3149 X := cx;
3150 Y := _y;
3151 _y := _y+22;
3152 end;
3153 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3154 begin
3155 Color := _RGB(255, 255, 255);
3156 X := cx+32;
3157 Y := _y;
3158 _y := _y+36;
3159 end;
3160 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3161 begin
3162 Color := _RGB(255, 0, 0);
3163 X := cx;
3164 Y := _y;
3165 _y := _y+22;
3166 end;
3167 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3168 begin
3169 Color := _RGB(255, 255, 255);
3170 X := cx+32;
3171 Y := _y;
3172 _y := _y+22;
3173 end;
3174 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3175 begin
3176 Color := _RGB(255, 255, 255);
3177 X := cx+32;
3178 Y := _y;
3179 _y := _y+36;
3180 end;
3181 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3182 begin
3183 Color := _RGB(255, 0, 0);
3184 X := cx;
3185 Y := _y;
3186 _y := _y+22;
3187 end;
3188 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3189 begin
3190 Color := _RGB(255, 255, 255);
3191 X := cx+32;
3192 Y := _y;
3193 _y := _y+36;
3194 end;
3195 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3196 begin
3197 Color := _RGB(255, 0, 0);
3198 X := cx;
3199 Y := _y;
3200 _y := _y+22;
3201 end;
3202 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3203 begin
3204 Color := _RGB(255, 255, 255);
3205 X := cx+32;
3206 Y := _y;
3207 _y := gScreenHeight - 128;
3208 end;
3209 // Çàêëþ÷åíèå:
3210 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3211 begin
3212 Color := _RGB(255, 0, 0);
3213 X := cx;
3214 Y := _y;
3215 _y := _y+16;
3216 end;
3217 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3218 begin
3219 Color := _RGB(255, 255, 255);
3220 X := cx+32;
3221 Y := _y;
3222 _y := _y+GetHeight();
3223 end;
3224 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3225 begin
3226 Color := _RGB(255, 255, 255);
3227 X := cx+32;
3228 Y := _y;
3229 _y := _y+GetHeight();
3230 end;
3231 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3232 begin
3233 Color := _RGB(255, 255, 255);
3234 X := cx+32;
3235 Y := _y;
3236 _y := gScreenHeight - 32;
3237 end;
3238 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3239 begin
3240 Color := _RGB(255, 0, 0);
3241 X := gScreenWidth div 2 - GetWidth() div 2;
3242 Y := _y;
3243 end;
3244 g_GUI_AddWindow(Menu);
3246 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3247 gMenuSmallFont, @ProcExitMenuKeyDown);
3248 g_GUI_AddWindow(Menu);
3250 Menu := TGUIWindow.Create('GameSingleMenu');
3251 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3252 begin
3253 Name := 'mmGameSingleMenu';
3254 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3255 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3256 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3257 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3258 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3259 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3260 end;
3261 Menu.DefControl := 'mmGameSingleMenu';
3262 Menu.MainWindow := True;
3263 Menu.OnClose := ProcGMClose;
3264 Menu.OnShow := ProcGMShow;
3265 g_GUI_AddWindow(Menu);
3267 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3268 gMenuSmallFont, @ProcEndMenuKeyDown);
3269 g_GUI_AddWindow(Menu);
3271 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3272 gMenuSmallFont, @ProcRestartMenuKeyDown);
3273 g_GUI_AddWindow(Menu);
3275 Menu := TGUIWindow.Create('GameCustomMenu');
3276 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3277 begin
3278 Name := 'mmGameCustomMenu';
3279 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3280 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3281 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3282 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3283 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3284 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3285 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3286 end;
3287 Menu.DefControl := 'mmGameCustomMenu';
3288 Menu.MainWindow := True;
3289 Menu.OnClose := ProcGMClose;
3290 Menu.OnShow := ProcGMShow;
3291 g_GUI_AddWindow(Menu);
3293 Menu := TGUIWindow.Create('GameServerMenu');
3294 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3295 begin
3296 Name := 'mmGameServerMenu';
3297 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3298 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3299 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3300 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3301 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3302 end;
3303 Menu.DefControl := 'mmGameServerMenu';
3304 Menu.MainWindow := True;
3305 Menu.OnClose := ProcGMClose;
3306 Menu.OnShow := ProcGMShow;
3307 g_GUI_AddWindow(Menu);
3309 Menu := TGUIWindow.Create('GameClientMenu');
3310 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3311 begin
3312 Name := 'mmGameClientMenu';
3313 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3314 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3315 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3316 end;
3317 Menu.DefControl := 'mmGameClientMenu';
3318 Menu.MainWindow := True;
3319 Menu.OnClose := ProcGMClose;
3320 Menu.OnShow := ProcGMShow;
3321 g_GUI_AddWindow(Menu);
3323 Menu := TGUIWindow.Create('ClientPasswordMenu');
3324 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3325 begin
3326 Name := 'mClientPasswordMenu';
3327 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3328 begin
3329 Name := 'edPW';
3330 Width := 12;
3331 MaxLength := 32;
3332 end;
3333 AddSpace;
3335 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3336 ReAlign();
3337 end;
3338 Menu.DefControl := 'mClientPasswordMenu';
3339 g_GUI_AddWindow(Menu);
3341 Menu := TGUIWindow.Create('GameSetGameMenu');
3342 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3343 begin
3344 Name := 'mGameSetGameMenu';
3345 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3346 begin
3347 Name := 'swTeamDamage';
3348 AddItem(_lc[I_MENU_YES]);
3349 AddItem(_lc[I_MENU_NO]);
3350 ItemIndex := 1;
3351 end;
3352 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3353 begin
3354 Name := 'swTeamHit';
3355 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3356 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3357 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3358 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3359 ItemIndex := 0
3360 end;
3361 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3362 begin
3363 Name := 'swDeathmatchKeys';
3364 AddItem(_lc[I_MENU_YES]);
3365 AddItem(_lc[I_MENU_NO]);
3366 ItemIndex := 1;
3367 end;
3368 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3369 begin
3370 Name := 'edTimeLimit';
3371 OnlyDigits := True;
3372 Width := 4;
3373 MaxLength := 5;
3374 end;
3375 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3376 begin
3377 Name := 'edGoalLimit';
3378 OnlyDigits := True;
3379 Width := 4;
3380 MaxLength := 5;
3381 end;
3382 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3383 begin
3384 Name := 'edMaxLives';
3385 OnlyDigits := True;
3386 Width := 4;
3387 MaxLength := 5;
3388 end;
3389 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3390 begin
3391 Name := 'swBotsVS';
3392 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3393 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3394 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3395 ItemIndex := 2;
3396 end;
3398 ReAlign();
3399 end;
3400 Menu.DefControl := 'mGameSetGameMenu';
3401 Menu.OnClose := ProcApplyGameSet;
3402 g_GUI_AddWindow(Menu);
3404 Menu := TGUIWindow.Create('TeamMenu');
3405 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3406 begin
3407 Name := 'mmTeamMenu';
3408 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3409 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3410 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3411 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3412 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3413 end;
3414 Menu.DefControl := 'mmTeamMenu';
3415 Menu.OnShow := ProcChangePlayers;
3416 g_GUI_AddWindow(Menu);
3417 end;
3419 procedure g_Menu_Show_SaveMenu();
3420 begin
3421 if g_Game_IsTestMap then
3422 Exit;
3423 if gGameSettings.GameType = GT_SINGLE then
3424 g_GUI_ShowWindow('GameSingleMenu')
3425 else
3426 begin
3427 if g_Game_IsClient then
3428 Exit
3429 else
3430 if g_Game_IsNet then
3431 Exit
3432 else
3433 g_GUI_ShowWindow('GameCustomMenu');
3434 end;
3435 g_GUI_ShowWindow('SaveMenu');
3436 g_Sound_PlayEx('MENU_OPEN');
3437 end;
3439 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3440 begin
3441 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3442 if gGameSettings.GameType = GT_SINGLE then
3443 begin
3444 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3445 end
3446 else
3447 begin
3448 if g_Game_IsClient then exit;
3449 if g_Game_IsNet then exit;
3450 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3451 end;
3452 g_GUI_ShowWindow('LoadMenu');
3453 g_Sound_PlayEx('MENU_OPEN');
3454 end;
3456 procedure g_Menu_Show_GameSetGame();
3457 begin
3458 if gGameSettings.GameType = GT_SINGLE then
3459 g_GUI_ShowWindow('GameSingleMenu')
3460 else
3461 begin
3462 if g_Game_IsClient then
3463 Exit
3464 else
3465 if g_Game_IsNet then
3466 g_GUI_ShowWindow('GameServerMenu')
3467 else
3468 g_GUI_ShowWindow('GameCustomMenu');
3469 end;
3470 ReadGameSettings();
3471 g_GUI_ShowWindow('GameSetGameMenu');
3472 g_Sound_PlayEx('MENU_OPEN');
3473 end;
3475 procedure g_Menu_Show_OptionsVideo();
3476 begin
3477 if gGameSettings.GameType = GT_SINGLE then
3478 g_GUI_ShowWindow('GameSingleMenu')
3479 else
3480 begin
3481 if g_Game_IsClient then
3482 g_GUI_ShowWindow('GameClientMenu')
3483 else
3484 if g_Game_IsNet then
3485 g_GUI_ShowWindow('GameServerMenu')
3486 else
3487 g_GUI_ShowWindow('GameCustomMenu');
3488 end;
3489 ReadOptions();
3490 g_GUI_ShowWindow('OptionsMenu');
3491 g_GUI_ShowWindow('OptionsVideoMenu');
3492 g_Sound_PlayEx('MENU_OPEN');
3493 end;
3495 procedure g_Menu_Show_OptionsSound();
3496 begin
3497 if gGameSettings.GameType = GT_SINGLE then
3498 g_GUI_ShowWindow('GameSingleMenu')
3499 else
3500 begin
3501 if g_Game_IsClient then
3502 g_GUI_ShowWindow('GameClientMenu')
3503 else
3504 if g_Game_IsNet then
3505 g_GUI_ShowWindow('GameServerMenu')
3506 else
3507 g_GUI_ShowWindow('GameCustomMenu');
3508 end;
3509 ReadOptions();
3510 g_GUI_ShowWindow('OptionsMenu');
3511 g_GUI_ShowWindow('OptionsSoundMenu');
3512 g_Sound_PlayEx('MENU_OPEN');
3513 end;
3515 procedure g_Menu_Show_EndGameMenu();
3516 begin
3517 g_GUI_ShowWindow('EndGameMenu');
3518 g_Sound_PlayEx('MENU_OPEN');
3519 end;
3521 procedure g_Menu_Show_QuitGameMenu();
3522 begin
3523 g_GUI_ShowWindow('ExitMenu');
3524 g_Sound_PlayEx('MENU_OPEN');
3525 end;
3527 procedure g_Menu_Init();
3528 begin
3529 MenuLoadData();
3530 CreateAllMenus();
3531 end;
3533 procedure g_Menu_Free();
3534 begin
3535 MenuFreeData();
3536 end;
3538 procedure g_Menu_Reset();
3539 var
3540 ex: Boolean;
3541 begin
3542 g_GUI_SaveMenuPos();
3543 ex := g_GUI_Destroy();
3545 if ex then
3546 begin
3547 e_WriteLog('Recreating menu...', TMsgType.Notify);
3549 CreateAllMenus();
3551 if gDebugMode then
3552 g_Game_SetDebugMode();
3554 g_GUI_LoadMenuPos();
3555 end;
3556 end;
3558 end.