DEADSOFTWARE

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