DEADSOFTWARE

added optional framebuffer and resolution scaling
[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 s: AnsiString;
113 begin
114 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
116 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
117 gBPP := 16
118 else
119 gBPP := 32;
121 ovs := gVSync;
122 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
123 if (ovs <> gVSync) then
124 sys_EnableVSync(gVSync);
126 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
127 glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).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 s := e_GetWriteableDir(ConfigDirs);
380 if s <> '' then
381 g_Options_Write(s + '/' + CONFIG_FILENAME);
382 g_Console_WriteGameConfig;
383 end;
385 procedure ReadOptions();
386 var
387 menu: TGUIMenu;
388 i: Integer;
389 begin
390 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
392 with TGUISwitch(menu.GetControl('swBPP')) do
393 if gBPP = 16 then
394 ItemIndex := 0
395 else
396 ItemIndex := 1;
398 with TGUISwitch(menu.GetControl('swTextureFilter')) do
399 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
401 with TGUISwitch(menu.GetControl('swVSync')) do
402 if gVSync then ItemIndex := 0 else ItemIndex := 1;
404 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
405 if not glNPOTOverride 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 procedure ProcStartCustomGame();
650 var
651 Map: String;
652 GameMode: Byte;
653 Options: LongWord;
654 s: AnsiString;
655 begin
656 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
657 begin
658 Map := TGUILabel(GetControl('lbMap')).Text;
659 if Map = '' then
660 Exit;
661 if not isWadPath(Map) then
662 Exit;
664 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
665 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
666 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
667 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
668 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
670 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
671 gcRespawnItems := TGUISwitch(GetControl('swRespawnItems')).ItemIndex = 0;
672 gcDeathmatchKeys := TGUISwitch(GetControl('swDeathmatchKeys')).ItemIndex = 0;
673 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
674 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
675 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
676 Options := 0;
677 if gcTeamDamage then
678 Options := Options or GAME_OPTION_TEAMDAMAGE;
679 if gcRespawnItems then
680 Options := Options or GAME_OPTION_RESPAWNITEMS;
681 if gcDeathmatchKeys then
682 Options := Options or GAME_OPTION_DMKEYS;
683 if gcAllowExit then
684 Options := Options or GAME_OPTION_ALLOWEXIT;
685 if gcWeaponStay then
686 Options := Options or GAME_OPTION_WEAPONSTAY;
687 if gcMonsters then
688 Options := Options or GAME_OPTION_MONSTERS;
689 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
691 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
692 1: begin
693 Options := Options or GAME_OPTION_BOTVSMONSTER;
694 gcBotsVS := 'Monsters';
695 end;
696 2: begin
697 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
698 gcBotsVS := 'Everybody';
699 end;
700 else begin
701 Options := Options or GAME_OPTION_BOTVSPLAYER;
702 gcBotsVS := 'Players';
703 end;
704 end;
706 gcMap := Map;
707 end;
709 s := e_GetWriteableDir(ConfigDirs);
710 if s <> '' then
711 g_Options_Write_Gameplay_Custom(s + '/' + CONFIG_FILENAME);
713 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
714 gcMaxLives, Options, gcPlayers);
715 end;
718 procedure ProcStartNetGame();
719 var
720 Map: String;
721 GameMode: Byte;
722 Options: LongWord;
723 s: AnsiString;
724 begin
725 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
726 begin
727 Map := TGUILabel(GetControl('lbMap')).Text;
728 if Map = '' then
729 Exit;
730 if not isWadPath(Map) then
731 Exit;
733 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
734 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
735 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
736 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
737 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
738 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
740 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
741 gnRespawnItems := TGUISwitch(GetControl('swRespawnItems')).ItemIndex = 0;
742 gnDeathmatchKeys := TGUISwitch(GetControl('swDeathmatchKeys')).ItemIndex = 0;
743 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
744 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
745 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
746 Options := 0;
747 if gnTeamDamage then
748 Options := Options or GAME_OPTION_TEAMDAMAGE;
749 if gnRespawnItems then
750 Options := Options or GAME_OPTION_RESPAWNITEMS;
751 if gnDeathmatchKeys then
752 Options := Options or GAME_OPTION_DMKEYS;
753 if gnAllowExit then
754 Options := Options or GAME_OPTION_ALLOWEXIT;
755 if gnWeaponStay then
756 Options := Options or GAME_OPTION_WEAPONSTAY;
757 if gnMonsters then
758 Options := Options or GAME_OPTION_MONSTERS;
759 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
761 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
762 1: begin
763 Options := Options or GAME_OPTION_BOTVSMONSTER;
764 gnBotsVS := 'Monsters';
765 end;
766 2: begin
767 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
768 gnBotsVS := 'Everybody';
769 end;
770 else begin
771 Options := Options or GAME_OPTION_BOTVSPLAYER;
772 gnBotsVS := 'Players';
773 end;
774 end;
776 gnMap := Map;
777 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
778 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
779 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
780 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
781 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
782 end;
784 s := e_GetWriteableDir(ConfigDirs);
785 if s <> '' then
786 begin
787 g_Options_Write_Net_Server(s + '/' + CONFIG_FILENAME);
788 g_Options_Write_Gameplay_Net(s + '/' + CONFIG_FILENAME)
789 end;
791 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
792 Options, gnPlayers, 0, NetPort);
793 end;
795 procedure ProcConnectNetGame();
796 var
797 PW: String;
798 s: AnsiString;
799 begin
800 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
801 begin
802 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
803 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
804 PW := TGUIEdit(GetControl('edPW')).Text;
805 end;
807 s := e_GetWriteableDir(ConfigDirs);
808 if s <> '' then
809 g_Options_Write_Net_Client(s + '/' + CONFIG_FILENAME);
810 g_Game_StartClient(NetClientIP, NetClientPort, PW);
811 end;
813 procedure ProcEnterPassword();
814 var
815 PW: string;
816 s: AnsiString;
817 begin
818 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
819 begin
820 NetClientIP := PromptIP;
821 NetClientPort := PromptPort;
822 PW := TGUIEdit(GetControl('edPW')).Text;
823 end;
825 s := e_GetWriteableDir(ConfigDirs);
826 if s <> '' then
827 g_Options_Write_Net_Client(s + '/' + CONFIG_FILENAME);
828 g_Game_StartClient(NetClientIP, NetClientPort, PW);
829 end;
831 procedure ProcServerlist();
832 begin
833 if not NetInitDone then
834 begin
835 if (not g_Net_Init()) then
836 begin
837 g_Console_Add('NET: ERROR: Failed to init ENet!');
838 Exit;
839 end
840 else
841 NetInitDone := True;
842 end;
844 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
846 gState := STATE_SLIST;
847 g_ActiveWindow := nil;
849 slWaitStr := _lc[I_NET_SLIST_WAIT];
851 g_Game_Draw;
852 sys_Repaint;
854 slReturnPressed := True;
855 if g_Net_Slist_Fetch(slCurrent) then
856 begin
857 if slCurrent = nil then
858 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
859 end
860 else
861 slWaitStr := _lc[I_NET_SLIST_ERROR];
862 g_Serverlist_GenerateTable(slCurrent, slTable);
863 end;
865 procedure ProcStartCampaign();
866 var
867 WAD: String;
868 TwoPlayers: Boolean;
869 n: Byte;
870 begin
871 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
872 begin
873 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
874 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
875 end;
876 WAD := e_FindWadRel(MegawadDirs, WAD);
878 if TwoPlayers then
879 n := 2
880 else
881 n := 1;
882 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
883 end;
885 procedure ProcSelectMap(Sender: TGUIControl);
886 var
887 win: TGUIWindow;
888 a: TMapInfo;
889 wad, map, res: String;
890 begin
891 win := g_GUI_GetWindow('SelectMapMenu');
892 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
893 begin
894 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
895 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
897 if (wad = '') or (map = '') then
898 begin // Ýòî íå êàðòà
899 TGUILabel(GetControl('lbMapName')).Text := '';
900 TGUILabel(GetControl('lbMapAuthor')).Text := '';
901 TGUILabel(GetControl('lbMapSize')).Text := '';
902 TGUIMemo(GetControl('meMapDescription')).SetText('');
903 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
904 TGUILabel(win.GetControl('lbMapScale')).Text := '';
905 end
906 else // Ýòî êàðòà
907 begin
908 res := wad+':\'+map;
910 a := g_Map_GetMapInfo(res);
912 TGUILabel(GetControl('lbMapName')).Text := a.Name;
913 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
914 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
915 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
916 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
917 TGUILabel(win.GetControl('lbMapScale')).Text :=
918 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
919 end;
920 end;
921 end;
923 procedure ProcSelectWAD(Sender: TGUIControl);
924 var
925 wad: String;
926 list: SSArray;
927 begin
928 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
929 begin
930 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
932 with TGUIListBox(GetControl('lsMapRes')) do
933 begin
934 Clear();
936 if wad <> '' then
937 begin
938 list := g_Map_GetMapsList(wad);
940 if list <> nil then
941 begin
942 Items := list;
943 ItemIndex := 0;
944 end
945 end;
946 end;
947 end;
949 ProcSelectMap(nil);
950 end;
952 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
953 var
954 win: TGUIWindow;
955 a: TMegaWADInfo;
956 wad, fn: String;
957 begin
958 win := g_GUI_GetWindow('CampaignMenu');
959 with TGUIMenu(win.GetControl('mCampaignMenu')) do
960 begin
961 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
963 if wad = '' then
964 begin
965 TGUILabel(GetControl('lbWADName')).Text := '';
966 TGUILabel(GetControl('lbWADAuthor')).Text := '';
967 TGUIMemo(GetControl('meWADDescription')).SetText('');
968 end;
970 a := g_Game_GetMegaWADInfo(wad);
972 TGUILabel(GetControl('lbWADName')).Text := a.Name;
973 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
974 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
976 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
978 if a.pic <> '' then
979 begin
980 fn := g_ExtractWadName(a.pic);
981 if fn = '' then
982 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
983 else
984 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
985 end;
986 end;
987 end;
989 procedure ProcChangeColor(Sender: TGUIControl);
990 var
991 window: TGUIWindow;
992 begin
993 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
994 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
995 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
996 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
997 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
998 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
1000 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1001 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
1002 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
1003 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
1004 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
1005 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
1006 end;
1008 procedure ProcSelectModel(Sender: TGUIControl);
1009 var
1010 a: string;
1011 window: TGUIWindow;
1012 begin
1013 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1014 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
1015 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
1017 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1018 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
1019 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
1021 ProcChangeColor(nil);
1022 end;
1024 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
1025 var
1026 cwdt, chgt: Byte;
1027 spc: ShortInt;
1028 ID: DWORD;
1029 wad: TWADFile;
1030 cfgdata: Pointer;
1031 cfglen: Integer;
1032 config: TConfig;
1033 begin
1034 cfglen := 0;
1036 wad := TWADFile.Create;
1037 if wad.ReadFile(GameWAD) then
1038 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
1039 wad.Free();
1041 if cfglen <> 0 then
1042 begin
1043 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
1045 config := TConfig.CreateMem(cfgdata, cfglen);
1046 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1047 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1048 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1050 if g_Texture_Get('FONT_STD', ID) then
1051 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
1053 config.Free();
1054 end;
1056 if cfglen <> 0 then FreeMem(cfgdata);
1057 end;
1059 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
1060 var
1061 cwdt, chgt: Byte;
1062 spc: ShortInt;
1063 CharID: DWORD;
1064 wad: TWADFile;
1065 cfgdata, fntdata: Pointer;
1066 cfglen, fntlen: Integer;
1067 config: TConfig;
1068 chrwidth: Integer;
1069 a: Byte;
1070 begin
1071 cfglen := 0;
1072 fntlen := 0;
1074 wad := TWADFile.Create;
1075 if wad.ReadFile(GameWAD) then
1076 begin
1077 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1078 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1079 end;
1080 wad.Free();
1082 if cfglen <> 0 then
1083 begin
1084 config := TConfig.CreateMem(cfgdata, cfglen);
1085 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1086 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1088 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1089 FontID := e_CharFont_Create(spc);
1091 for a := 0 to 255 do
1092 begin
1093 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1094 if chrwidth = 0 then Continue;
1096 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1097 cwdt, chgt) then
1098 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1099 end;
1101 config.Free();
1102 end;
1104 if cfglen <> 0 then FreeMem(cfgdata);
1105 if fntlen <> 0 then FreeMem(fntdata);
1106 end;
1108 procedure MenuLoadData();
1109 begin
1110 e_WriteLog('Loading menu data...', TMsgType.Notify);
1112 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD+':TEXTURES\MAINLOGO');
1113 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1114 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1115 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1116 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1117 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1118 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1119 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1120 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1121 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1122 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1123 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1124 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1125 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1126 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1127 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1128 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1129 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1130 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1131 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1132 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1133 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1134 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1135 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1136 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1138 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1139 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1140 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1141 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1142 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1143 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1144 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1145 end;
1147 procedure MenuFreeData();
1148 begin
1149 e_CharFont_Remove(gMenuFont);
1150 e_CharFont_Remove(gMenuSmallFont);
1152 g_Texture_Delete('MAINMENU_LOGO');
1153 g_Texture_Delete('MAINMENU_MARKER1');
1154 g_Texture_Delete('MAINMENU_MARKER2');
1155 g_Texture_Delete('SCROLL_LEFT');
1156 g_Texture_Delete('SCROLL_RIGHT');
1157 g_Texture_Delete('SCROLL_MIDDLE');
1158 g_Texture_Delete('SCROLL_MARKER');
1159 g_Texture_Delete('EDIT_LEFT');
1160 g_Texture_Delete('EDIT_RIGHT');
1161 g_Texture_Delete('EDIT_MIDDLE');
1162 g_Texture_Delete('BOX1');
1163 g_Texture_Delete('BOX2');
1164 g_Texture_Delete('BOX3');
1165 g_Texture_Delete('BOX4');
1166 g_Texture_Delete('BOX5');
1167 g_Texture_Delete('BOX6');
1168 g_Texture_Delete('BOX7');
1169 g_Texture_Delete('BOX8');
1170 g_Texture_Delete('BOX9');
1171 g_Texture_Delete('BSCROLL_UP_A');
1172 g_Texture_Delete('BSCROLL_UP_U');
1173 g_Texture_Delete('BSCROLL_DOWN_A');
1174 g_Texture_Delete('BSCROLL_DOWN_U');
1175 g_Texture_Delete('BSCROLL_MIDDLE');
1176 g_Texture_Delete('NOPIC');
1178 g_Sound_Delete('MENU_SELECT');
1179 g_Sound_Delete('MENU_OPEN');
1180 g_Sound_Delete('MENU_CLOSE');
1181 g_Sound_Delete('MENU_CHANGE');
1182 g_Sound_Delete('SCROLL_ADD');
1183 g_Sound_Delete('SCROLL_SUB');
1184 g_Sound_Delete('SOUND_PLAYER_FALL');
1185 end;
1187 procedure ProcAuthorsMenu();
1188 begin
1189 gMusic.SetByName('MUSIC_INTERMUS');
1190 gMusic.Play();
1191 end;
1193 procedure ProcExitMenuKeyDown (yes: Boolean);
1194 var
1195 s: ShortString;
1196 snd: TPlayableSound;
1197 res: Boolean;
1198 begin
1199 if yes then
1200 begin
1201 g_Game_StopAllSounds(True);
1202 case (Random(18)) of
1203 0: s := 'SOUND_MONSTER_PAIN';
1204 1: s := 'SOUND_MONSTER_DIE_3';
1205 2: s := 'SOUND_MONSTER_SLOP';
1206 3: s := 'SOUND_MONSTER_DEMON_DIE';
1207 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1208 5: s := 'SOUND_MONSTER_MAN_DIE';
1209 6: s := 'SOUND_MONSTER_BSP_DIE';
1210 7: s := 'SOUND_MONSTER_VILE_DIE';
1211 8: s := 'SOUND_MONSTER_SKEL_DIE';
1212 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1213 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1214 11: s := 'SOUND_MONSTER_BARON_DIE';
1215 12: s := 'SOUND_MONSTER_CACO_DIE';
1216 13: s := 'SOUND_MONSTER_CYBER_DIE';
1217 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1218 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1219 else s := 'SOUND_PLAYER_FALL';
1220 end;
1221 snd := TPlayableSound.Create();
1222 res := snd.SetByName(s);
1223 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1224 if res then
1225 begin
1226 snd.Play(True);
1227 while snd.IsPlaying() do begin end;
1228 end;
1229 g_Game_Quit();
1230 exit;
1231 end;
1232 g_GUI_HideWindow();
1233 end;
1235 procedure ProcLoadMenu();
1236 var
1237 a: Integer;
1238 valid: Boolean;
1239 begin
1240 for a := 1 to 8 do
1241 begin
1242 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1243 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1244 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1245 end;
1246 end;
1248 procedure ProcSaveMenu();
1249 var
1250 a: Integer;
1251 valid: Boolean;
1252 name: AnsiString;
1253 begin
1254 for a := 1 to 8 do
1255 begin
1256 name := g_GetSaveName(a, valid);
1257 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1258 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1259 end;
1260 end;
1262 procedure ProcSaveGame(Sender: TGUIControl);
1263 var
1264 a: Integer;
1265 begin
1266 if g_Game_IsNet then Exit;
1267 if g_Game_IsTestMap then Exit;
1268 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1269 g_Game_PauseAllSounds(True);
1270 g_SaveGame(a, TGUIEdit(Sender).Text);
1272 g_ActiveWindow := nil;
1273 g_Game_Pause(False);
1274 end;
1276 procedure ProcLoadGame(Sender: TGUIControl);
1277 var
1278 a: Integer;
1279 begin
1280 if g_Game_IsNet then Exit;
1281 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1282 if g_LoadGame(a) then
1283 begin
1284 g_Game_PauseAllSounds(False)
1285 end
1286 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1287 begin
1288 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1289 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1290 //g_ActiveWindow := nil;
1291 end;
1292 end;
1294 procedure ProcSinglePlayer (n: Integer);
1295 var wad, map: AnsiString;
1296 begin
1297 assert(n >= 1);
1298 wad := g_ExtractWadName(gDefaultMegawadStart);
1299 map := g_ExtractFilePathName(gDefaultMegawadStart);
1300 if e_FindResource(AllMapDirs, wad) then
1301 begin
1302 wad := ExpandFileName(wad);
1303 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1304 end
1305 end;
1307 procedure ProcSingle1Player;
1308 begin
1309 ProcSinglePlayer(1)
1310 end;
1312 procedure ProcSingle2Players;
1313 begin
1314 ProcSinglePlayer(2)
1315 end;
1317 procedure ProcSelectMapMenu();
1318 var
1319 menu: TGUIMenu;
1320 wad_lb: TGUIFileListBox;
1321 map_lb: TGUIListBox;
1322 map: String;
1323 begin
1324 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1325 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1326 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1328 if wad_lb.SelectedItem() <> '' then
1329 map := map_lb.SelectedItem()
1330 else
1331 map := '';
1333 wad_lb.UpdateFileList();
1334 map_lb.Clear();
1336 if wad_lb.SelectedItem() <> '' then
1337 begin
1338 ProcSelectWAD(nil);
1339 map_lb.SelectItem(map);
1341 if map_lb.SelectedItem() <> '' then
1342 ProcSelectMap(nil);
1343 end;
1345 g_GUI_ShowWindow('SelectMapMenu');
1346 end;
1348 procedure ProcSelectCampaignMenu();
1349 var
1350 menu: TGUIMenu;
1351 wad_lb: TGUIFileListBox;
1352 begin
1353 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1354 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1356 wad_lb.UpdateFileList();
1358 if wad_lb.SelectedItem() <> '' then
1359 ProcSelectCampaignWAD(nil);
1360 end;
1362 procedure ProcSetMap();
1363 var
1364 wad, map, res: String;
1365 begin
1366 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1367 begin
1368 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1369 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1370 end;
1372 if (wad = '') or (map = '') then
1373 Exit;
1375 wad := e_FindWadRel(MapDirs, WAD);
1377 res := wad+':\'+map;
1379 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1380 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1381 end;
1383 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1384 var
1385 menu: TGUIMenu;
1386 begin
1387 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1389 g_Sound_SetupAllVolumes(
1390 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1391 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1392 );
1393 end;
1395 procedure ProcChangeGameSettings(Sender: TGUIControl);
1396 var
1397 menu: TGUIMenu;
1398 begin
1399 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1400 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1401 begin
1402 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1403 g_dbg_scale := TempScale + 1;
1404 end;
1405 end;
1407 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1408 var
1409 menu: TGUIMenu;
1410 begin
1411 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1412 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1413 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1414 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1415 end;
1417 procedure ProcOptionsPlayersMIMenu();
1418 var
1419 s, a: string;
1420 b: TModelInfo;
1421 begin
1422 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1424 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1426 if a = '' then Exit;
1428 b := g_PlayerModel_GetInfo(a);
1430 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1431 begin
1432 TGUILabel(GetControl('lbName')).Text := b.Name;
1433 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1434 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1436 if b.HaveWeapon then
1437 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1438 else
1439 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1440 end;
1442 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1443 end;
1445 procedure ProcOptionsPlayersAnim();
1446 var
1447 s: String;
1448 begin
1449 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1450 s := 'P1'
1451 else
1452 s := 'P2';
1454 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1455 begin
1456 NextAnim();
1457 Model.GetCurrentAnimation.Loop := True;
1458 Model.GetCurrentAnimationMask.Loop := True;
1459 end;
1460 end;
1462 procedure ProcOptionsPlayersWeap();
1463 var
1464 s: String;
1465 begin
1466 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1467 s := 'P1'
1468 else
1469 s := 'P2';
1471 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1472 NextWeapon();
1473 end;
1475 procedure ProcOptionsPlayersRot();
1476 var
1477 s: string;
1478 begin
1479 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1480 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1481 begin
1482 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1483 end;
1484 end;
1486 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1487 begin
1488 if yes then
1489 begin
1490 g_Options_SetDefault();
1491 ReadOptions();
1492 end;
1493 g_GUI_HideWindow();
1494 end;
1496 procedure ProcSavedMenuKeyDown (yes: Boolean);
1497 begin
1498 if yes then ReadOptions();
1499 g_GUI_HideWindow();
1500 end;
1502 procedure ProcAuthorsClose();
1503 begin
1504 gMusic.SetByName('MUSIC_MENU');
1505 gMusic.Play();
1506 gState := STATE_MENU;
1507 end;
1509 procedure ProcGMClose();
1510 begin
1511 g_Game_InGameMenu(False);
1512 end;
1514 procedure ProcGMShow();
1515 var
1516 Enabled: Boolean;
1517 begin
1518 Enabled := True;
1519 if (gGameSettings.GameType = GT_SINGLE) and
1520 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1521 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1522 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1523 if not gGameOn then
1524 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1525 if g_Game_IsTestMap then
1526 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1527 TGUIMainMenu(g_ActiveWindow.GetControl(
1528 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1529 end;
1531 procedure ProcChangePlayers();
1532 var
1533 TeamGame, Spectator, AddTwo: Boolean;
1534 P1Team{, P2Team}: Byte;
1535 bP2: TGUITextButton;
1536 begin
1537 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1538 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1539 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1540 P1Team := TEAM_NONE;
1541 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1542 // TODO
1543 //P2Team := TEAM_NONE;
1544 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1546 TGUIMainMenu(g_ActiveWindow.GetControl(
1547 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1548 TGUIMainMenu(g_ActiveWindow.GetControl(
1549 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1550 TGUIMainMenu(g_ActiveWindow.GetControl(
1551 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1553 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1554 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1555 bP2.Enabled := AddTwo and not Spectator;
1556 if bP2.Enabled then
1557 bP2.Color := MAINMENU_ITEMS_COLOR
1558 else
1559 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1560 if gPlayer2 = nil then
1561 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1562 else
1563 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1565 TGUIMainMenu(g_ActiveWindow.GetControl(
1566 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1567 end;
1569 procedure ProcJoinRed();
1570 begin
1571 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1572 Exit;
1573 if g_Game_IsServer then
1574 begin
1575 if gPlayer1 = nil then
1576 g_Game_AddPlayer(TEAM_RED)
1577 else
1578 begin
1579 if gPlayer1.Team <> TEAM_RED then
1580 begin
1581 gPlayer1.SwitchTeam;
1582 gPlayer1Settings.Team := gPlayer1.Team;
1583 end;
1585 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1586 end;
1587 end
1588 else
1589 begin
1590 gPlayer1Settings.Team := TEAM_RED;
1591 MC_SEND_PlayerSettings;
1592 if gPlayer1 = nil then
1593 g_Game_AddPlayer(TEAM_RED);
1594 end;
1595 g_ActiveWindow := nil;
1596 g_Game_Pause(False);
1597 end;
1599 procedure ProcJoinBlue();
1600 begin
1601 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1602 Exit;
1603 if g_Game_IsServer then
1604 begin
1605 if gPlayer1 = nil then
1606 g_Game_AddPlayer(TEAM_BLUE)
1607 else
1608 begin
1609 if gPlayer1.Team <> TEAM_BLUE then
1610 begin
1611 gPlayer1.SwitchTeam;
1612 gPlayer1Settings.Team := gPlayer1.Team;
1613 end;
1615 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1616 end;
1617 end
1618 else
1619 begin
1620 gPlayer1Settings.Team := TEAM_BLUE;
1621 MC_SEND_PlayerSettings;
1622 if gPlayer1 = nil then
1623 g_Game_AddPlayer(TEAM_BLUE);
1624 end;
1625 g_ActiveWindow := nil;
1626 g_Game_Pause(False);
1627 end;
1629 procedure ProcJoinGame();
1630 begin
1631 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1632 Exit;
1633 if gPlayer1 = nil then
1634 g_Game_AddPlayer();
1635 g_ActiveWindow := nil;
1636 g_Game_Pause(False);
1637 end;
1639 procedure ProcSwitchP2();
1640 begin
1641 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1642 Exit;
1643 if gPlayer1 = nil then
1644 Exit;
1645 if gPlayer2 = nil then
1646 g_Game_AddPlayer()
1647 else
1648 g_Game_RemovePlayer();
1649 g_ActiveWindow := nil;
1650 g_Game_Pause(False);
1651 end;
1653 procedure ProcSpectate();
1654 begin
1655 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1656 Exit;
1657 g_Game_Spectate();
1658 g_ActiveWindow := nil;
1659 g_Game_Pause(False);
1660 end;
1662 procedure ProcRestartMenuKeyDown (yes: Boolean);
1663 begin
1664 if yes then g_Game_Restart() else g_GUI_HideWindow;
1665 end;
1667 procedure ProcEndMenuKeyDown (yes: Boolean);
1668 begin
1669 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1670 end;
1672 procedure ProcSetRussianLanguage;
1673 begin
1674 if gLanguage <> LANGUAGE_RUSSIAN then
1675 begin
1676 gLanguage := LANGUAGE_RUSSIAN;
1677 gLanguageChange := True;
1678 gAskLanguage := False;
1679 ProcApplyOptions();
1680 end;
1681 end;
1683 procedure ProcSetEnglishLanguage;
1684 begin
1685 if gLanguage <> LANGUAGE_ENGLISH then
1686 begin
1687 gLanguage := LANGUAGE_ENGLISH;
1688 gLanguageChange := True;
1689 gAskLanguage := False;
1690 ProcApplyOptions();
1691 end;
1692 end;
1694 procedure ReadGameSettings();
1695 var
1696 menu: TGUIMenu;
1697 begin
1698 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1700 with gGameSettings do
1701 begin
1702 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1703 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1704 ItemIndex := 0
1705 else
1706 ItemIndex := 1;
1707 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1708 if LongBool(Options and GAME_OPTION_DMKEYS) then
1709 ItemIndex := 0
1710 else
1711 ItemIndex := 1;
1713 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1714 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1715 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1717 with TGUISwitch(menu.GetControl('swBotsVS')) do
1718 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1719 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1720 ItemIndex := 2
1721 else
1722 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1723 ItemIndex := 1
1724 else
1725 ItemIndex := 0;
1727 if GameType in [GT_CUSTOM, GT_SERVER] then
1728 begin
1729 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1730 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := (GameMode in [GM_DM, GM_TDM, GM_CTF]);
1731 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1732 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1733 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1734 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1735 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1736 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1737 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1738 end
1739 else
1740 begin
1741 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1742 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1743 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1744 begin
1745 Enabled := False;
1746 Text := '';
1747 end;
1748 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1749 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1750 begin
1751 Enabled := False;
1752 Text := '';
1753 end;
1754 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1755 with TGUIEdit(menu.GetControl('edMaxLives')) do
1756 begin
1757 Enabled := False;
1758 Text := '';
1759 end;
1760 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1761 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1762 end;
1763 end;
1764 end;
1766 procedure ProcApplyGameSet();
1767 var
1768 menu: TGUIMenu;
1769 a, b, n: Integer;
1770 stat: TPlayerStatArray;
1771 begin
1772 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1774 if not g_Game_IsServer then Exit;
1776 with gGameSettings do
1777 begin
1778 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1779 begin
1780 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1781 Options := Options or GAME_OPTION_TEAMDAMAGE
1782 else
1783 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1784 end;
1786 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1787 begin
1788 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1789 Options := Options or GAME_OPTION_DMKEYS
1790 else
1791 Options := Options and (not GAME_OPTION_DMKEYS);
1792 end;
1794 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1795 begin
1796 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1798 if n = 0 then
1799 TimeLimit := 0
1800 else
1801 begin
1802 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1804 TimeLimit := Max(n, b);
1805 end;
1806 end;
1808 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1809 begin
1810 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1812 if n = 0 then
1813 GoalLimit := 0
1814 else
1815 begin
1816 b := 0;
1817 if GameMode = GM_DM then
1818 begin // DM
1819 stat := g_Player_GetStats();
1820 if stat <> nil then
1821 for a := 0 to High(stat) do
1822 if stat[a].Frags > b then
1823 b := stat[a].Frags;
1824 end
1825 else // CTF
1826 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1828 GoalLimit := Max(n, b);
1829 end;
1830 end;
1832 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1833 begin
1834 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1835 if n < 0 then n := 0;
1836 if n > 255 then n := 255;
1837 if n = 0 then
1838 MaxLives := 0
1839 else
1840 begin
1841 b := 0;
1842 stat := g_Player_GetStats();
1843 if stat <> nil then
1844 for a := 0 to High(stat) do
1845 if stat[a].Lives > b then
1846 b := stat[a].Lives;
1848 MaxLives := Max(n, b);
1849 end;
1850 end;
1852 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1853 begin
1854 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1855 1:
1856 begin
1857 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1858 Options := Options or GAME_OPTION_BOTVSMONSTER;
1859 end;
1860 2:
1861 begin
1862 Options := Options or GAME_OPTION_BOTVSPLAYER;
1863 Options := Options or GAME_OPTION_BOTVSMONSTER;
1864 end;
1865 else
1866 begin
1867 Options := Options or GAME_OPTION_BOTVSPLAYER;
1868 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1869 end;
1870 end;
1871 end;
1872 end;
1874 if g_Game_IsNet then MH_SEND_GameSettings;
1875 end;
1877 procedure ProcVideoOptionsRes();
1878 var
1879 menu: TGUIMenu;
1880 list: SSArray;
1881 begin
1882 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1884 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1885 IntToStr(gWinSizeX) +
1886 ' x ' + IntToStr(gWinSizeY) +
1887 ', ' + IntToStr(gBPP) + ' bpp';
1889 with TGUIListBox(menu.GetControl('lsResolution')) do
1890 begin
1891 list := sys_GetDisplayModes(gBPP);
1892 if list <> nil then
1893 begin
1894 Items := list;
1895 ItemIndex := Length(list)
1896 end
1897 else
1898 begin
1899 Clear
1900 end
1901 end;
1903 with TGUISwitch(menu.GetControl('swFullScreen')) do
1904 if gFullscreen then
1905 ItemIndex := 0
1906 else
1907 ItemIndex := 1;
1909 TempResScale := Round(r_pixel_scale - 1);
1910 TGUIScroll(menu.GetControl('scResFactor')).Value := TempResScale;
1911 end;
1913 procedure ProcApplyVideoOptions();
1914 var
1915 menu: TGUIMenu;
1916 Fullscreen: Boolean;
1917 SWidth, SHeight: Integer;
1918 ScaleChanged: Boolean;
1919 str: String;
1920 begin
1921 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1923 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1924 if str <> '' then
1925 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1926 else
1927 begin
1928 SWidth := gWinSizeX;
1929 SHeight := gWinSizeY;
1930 end;
1932 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1934 ScaleChanged := False;
1935 if TGUIScroll(menu.GetControl('scResFactor')).Value <> TempResScale then
1936 begin
1937 TempResScale := TGUIScroll(menu.GetControl('scResFactor')).Value;
1938 r_pixel_scale := TempResScale + 1;
1939 ScaleChanged := True;
1940 end;
1942 if (SWidth <> gWinSizeX) or
1943 (SHeight <> gWinSizeY) or
1944 (Fullscreen <> gFullscreen) or
1945 ScaleChanged then
1946 begin
1947 gResolutionChange := True;
1948 gRC_Width := SWidth;
1949 gRC_Height := SHeight;
1950 gRC_FullScreen := Fullscreen;
1951 gRC_Maximized := gWinMaximized;
1952 end;
1954 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1955 ProcApplyOptions();
1956 end;
1958 procedure ProcSetFirstRussianLanguage;
1959 begin
1960 gLanguage := LANGUAGE_RUSSIAN;
1961 gLanguageChange := True;
1962 gAskLanguage := False;
1963 end;
1965 procedure ProcSetFirstEnglishLanguage;
1966 begin
1967 gLanguage := LANGUAGE_ENGLISH;
1968 gLanguageChange := True;
1969 gAskLanguage := False;
1970 end;
1972 procedure ProcRecallAddress();
1973 begin
1974 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1975 begin
1976 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1977 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1978 end;
1979 end;
1981 procedure CreateFirstLanguageMenu();
1982 var
1983 Menu: TGUIWindow;
1984 begin
1985 Menu := TGUIWindow.Create('FirstLanguageMenu');
1987 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1988 begin
1989 Name := 'mmFirstLanguageMenu';
1990 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1991 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1992 end;
1994 Menu.DefControl := 'mmFirstLanguageMenu';
1995 Menu.MainWindow := True;
1996 g_GUI_AddWindow(Menu);
1997 end;
1999 procedure g_Menu_AskLanguage();
2000 begin
2001 CreateFirstLanguageMenu();
2002 g_GUI_ShowWindow('FirstLanguageMenu');
2003 end;
2005 procedure CreatePlayerOptionsMenu(s: String);
2006 var
2007 Menu: TGUIWindow;
2008 a: String;
2009 begin
2010 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2011 if s = 'P1' then
2012 a := _lc[I_MENU_PLAYER_1]
2013 else
2014 a := _lc[I_MENU_PLAYER_2];
2015 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
2016 begin
2017 Name := 'mOptionsPlayers'+s+'Menu';
2018 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2019 begin
2020 Name := 'ed'+s+'Name';
2021 MaxLength := 12;
2022 Width := 12;
2023 end;
2024 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2025 begin
2026 Name := 'sw'+s+'Team';
2027 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2028 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2029 end ;
2030 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2031 begin
2032 Name := 'ls'+s+'Model';
2033 Sort := True;
2034 Items := g_PlayerModel_GetNames();
2035 OnChange := ProcSelectModel;
2036 end;
2037 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2038 begin
2039 Name := 'sc'+s+'Red';
2040 Max := 16;
2041 OnChange := ProcChangeColor;
2042 end;
2043 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2044 begin
2045 Name := 'sc'+s+'Green';
2046 Max := 16;
2047 OnChange := ProcChangeColor;
2048 end;
2049 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2050 begin
2051 Name := 'sc'+s+'Blue';
2052 Max := 16;
2053 OnChange := ProcChangeColor;
2054 end;
2055 AddSpace();
2056 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2057 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2058 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2059 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2061 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2062 begin
2063 Name := 'mv'+s+'Model';
2064 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2065 Y := GetControl('ls'+s+'Model').Y;
2066 end;
2067 end;
2068 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2069 g_GUI_AddWindow(Menu);
2070 end;
2072 procedure CreateAllMenus();
2073 var
2074 Menu: TGUIWindow;
2075 //SR: TSearchRec;
2076 a, cx, _y, i: Integer;
2077 //list: SSArray;
2078 begin
2079 Menu := TGUIWindow.Create('MainMenu');
2080 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2081 begin
2082 Name := 'mmMainMenu';
2083 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2084 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2085 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2086 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2087 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2088 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2089 end;
2090 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2091 begin
2092 Color := _RGB(255, 255, 255);
2093 X := gScreenWidth-GetWidth-8;
2094 Y := gScreenHeight-GetHeight-8;
2095 end;
2096 Menu.DefControl := 'mmMainMenu';
2097 Menu.MainWindow := True;
2098 g_GUI_AddWindow(Menu);
2100 Menu := TGUIWindow.Create('NewGameMenu');
2101 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2102 begin
2103 Name := 'mmNewGameMenu';
2104 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2105 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2106 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2107 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2108 end;
2109 Menu.DefControl := 'mmNewGameMenu';
2110 g_GUI_AddWindow(Menu);
2112 Menu := TGUIWindow.Create('NetGameMenu');
2113 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2114 begin
2115 Name := 'mmNetGameMenu';
2116 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2117 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2118 end;
2119 Menu.DefControl := 'mmNetGameMenu';
2120 g_GUI_AddWindow(Menu);
2122 Menu := TGUIWindow.Create('NetServerMenu');
2123 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2124 begin
2125 Name := 'mNetServerMenu';
2126 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2127 begin
2128 Name := 'edSrvName';
2129 OnlyDigits := False;
2130 Width := 16;
2131 MaxLength := 64;
2132 Text := NetServerName;
2133 end;
2134 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2135 begin
2136 Name := 'edSrvPassword';
2137 OnlyDigits := False;
2138 Width := 16;
2139 MaxLength := 24;
2140 Text := NetPassword;
2141 end;
2142 with AddEdit(_lc[I_NET_PORT]) do
2143 begin
2144 Name := 'edPort';
2145 OnlyDigits := True;
2146 Width := 4;
2147 MaxLength := 5;
2148 Text := IntToStr(NetPort);
2149 end;
2150 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2151 begin
2152 Name := 'edMaxPlayers';
2153 OnlyDigits := True;
2154 Width := 4;
2155 MaxLength := 2;
2156 Text := IntToStr(NetMaxClients);
2157 end;
2158 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2159 begin
2160 Name := 'swUseMaster';
2161 AddItem(_lc[I_MENU_YES]);
2162 AddItem(_lc[I_MENU_NO]);
2163 if NetUseMaster then
2164 ItemIndex := 0
2165 else
2166 ItemIndex := 1;
2167 end;
2168 AddSpace();
2169 with AddLabel(_lc[I_MENU_MAP]) do
2170 begin
2171 Name := 'lbMap';
2172 FixedLength := 16;
2173 Text := gnMap;
2174 OnClick := @ProcSelectMapMenu;
2175 end;
2176 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2177 begin
2178 Name := 'swGameMode';
2179 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2180 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2181 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2182 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2183 case g_Game_TextToMode(gnGameMode) of
2184 GM_NONE,
2185 GM_DM: ItemIndex := 0;
2186 GM_TDM: ItemIndex := 1;
2187 GM_CTF: ItemIndex := 2;
2188 GM_SINGLE,
2189 GM_COOP: ItemIndex := 3;
2190 end;
2191 OnChange := ProcSwitchMonstersNet;
2192 end;
2193 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2194 begin
2195 Name := 'edTimeLimit';
2196 OnlyDigits := True;
2197 Width := 4;
2198 MaxLength := 5;
2199 if gnTimeLimit > 0 then
2200 Text := IntToStr(gnTimeLimit);
2201 end;
2202 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2203 begin
2204 Name := 'edGoalLimit';
2205 OnlyDigits := True;
2206 Width := 4;
2207 MaxLength := 5;
2208 if gnGoalLimit > 0 then
2209 Text := IntToStr(gnGoalLimit);
2210 end;
2211 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2212 begin
2213 Name := 'edMaxLives';
2214 OnlyDigits := True;
2215 Width := 4;
2216 MaxLength := 3;
2217 if gnMaxLives > 0 then
2218 Text := IntToStr(gnMaxLives);
2219 end;
2220 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2221 begin
2222 Name := 'swPlayers';
2223 AddItem(_lc[I_MENU_COUNT_NONE]);
2224 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2225 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2226 ItemIndex := gnPlayers;
2227 end;
2228 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2229 begin
2230 Name := 'swTeamDamage';
2231 AddItem(_lc[I_MENU_YES]);
2232 AddItem(_lc[I_MENU_NO]);
2233 if gnTeamDamage then
2234 ItemIndex := 0
2235 else
2236 ItemIndex := 1;
2237 end;
2238 with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do
2239 begin
2240 Name := 'swRespawnItems';
2241 AddItem(_lc[I_MENU_YES]);
2242 AddItem(_lc[I_MENU_NO]);
2243 if gnRespawnItems then
2244 ItemIndex := 0
2245 else
2246 ItemIndex := 1;
2247 end;
2248 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2249 begin
2250 Name := 'swDeathmatchKeys';
2251 AddItem(_lc[I_MENU_YES]);
2252 AddItem(_lc[I_MENU_NO]);
2253 if gnDeathmatchKeys then
2254 ItemIndex := 0
2255 else
2256 ItemIndex := 1;
2257 end;
2258 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2259 begin
2260 Name := 'swEnableExits';
2261 AddItem(_lc[I_MENU_YES]);
2262 AddItem(_lc[I_MENU_NO]);
2263 if gnAllowExit then
2264 ItemIndex := 0
2265 else
2266 ItemIndex := 1;
2267 end;
2268 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2269 begin
2270 Name := 'swWeaponStay';
2271 AddItem(_lc[I_MENU_YES]);
2272 AddItem(_lc[I_MENU_NO]);
2273 if gnWeaponStay then
2274 ItemIndex := 0
2275 else
2276 ItemIndex := 1;
2277 end;
2278 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2279 begin
2280 Name := 'swMonsters';
2281 AddItem(_lc[I_MENU_YES]);
2282 AddItem(_lc[I_MENU_NO]);
2283 if gnMonsters then
2284 ItemIndex := 0
2285 else
2286 ItemIndex := 1;
2287 end;
2288 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2289 begin
2290 Name := 'swBotsVS';
2291 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2292 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2293 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2294 ItemIndex := 2;
2295 if gnBotsVS = 'Players' then
2296 ItemIndex := 0;
2297 if gnBotsVS = 'Monsters' then
2298 ItemIndex := 1;
2299 end;
2300 AddSpace();
2301 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2303 ReAlign();
2304 end;
2305 Menu.DefControl := 'mNetServerMenu';
2306 g_GUI_AddWindow(Menu);
2308 Menu := TGUIWindow.Create('NetClientMenu');
2309 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2310 begin
2311 Name := 'mNetClientMenu';
2313 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2314 AddSpace();
2316 with AddEdit(_lc[I_NET_ADDRESS]) do
2317 begin
2318 Name := 'edIP';
2319 OnlyDigits :=False;
2320 Width := 12;
2321 MaxLength := 64;
2322 Text := 'localhost';
2323 end;
2324 with AddEdit(_lc[I_NET_PORT]) do
2325 begin
2326 Name := 'edPort';
2327 OnlyDigits := True;
2328 Width := 4;
2329 MaxLength := 5;
2330 Text := '25666';
2331 end;
2332 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2333 begin
2334 Name := 'edPW';
2335 OnlyDigits := False;
2336 Width := 12;
2337 MaxLength := 32;
2338 Text := '';
2339 end;
2341 AddSpace();
2342 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2344 ReAlign();
2345 end;
2346 Menu.DefControl := 'mNetClientMenu';
2347 g_GUI_AddWindow(Menu);
2349 Menu := TGUIWindow.Create('LoadMenu');
2350 Menu.OnShow := ProcLoadMenu;
2351 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2352 begin
2353 Name := 'mmLoadMenu';
2355 for a := 1 to 8 do
2356 with AddEdit('') do
2357 begin
2358 Name := 'edSlot'+IntToStr(a);
2359 Width := 16;
2360 MaxLength := 16;
2361 OnEnter := ProcLoadGame;
2362 end;
2363 end;
2364 Menu.DefControl := 'mmLoadMenu';
2365 g_GUI_AddWindow(Menu);
2367 Menu := TGUIWindow.Create('SaveMenu');
2368 Menu.OnShow := ProcSaveMenu;
2369 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2370 begin
2371 Name := 'mmSaveMenu';
2373 for a := 1 to 8 do
2374 with AddEdit('') do
2375 begin
2376 Name := 'edSlot'+IntToStr(a);
2377 Width := 16;
2378 MaxLength := 16;
2379 OnChange := ProcSaveGame;
2380 end;
2381 end;
2382 Menu.DefControl := 'mmSaveMenu';
2383 g_GUI_AddWindow(Menu);
2385 Menu := TGUIWindow.Create('CustomGameMenu');
2386 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2387 begin
2388 Name := 'mCustomGameMenu';
2389 with AddLabel(_lc[I_MENU_MAP]) do
2390 begin
2391 Name := 'lbMap';
2392 FixedLength := 16;
2393 Text := gcMap;
2394 OnClick := @ProcSelectMapMenu;
2395 end;
2396 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2397 begin
2398 Name := 'swGameMode';
2399 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2400 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2401 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2402 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2403 case g_Game_TextToMode(gcGameMode) of
2404 GM_NONE,
2405 GM_DM: ItemIndex := 0;
2406 GM_TDM: ItemIndex := 1;
2407 GM_CTF: ItemIndex := 2;
2408 GM_SINGLE,
2409 GM_COOP: ItemIndex := 3;
2410 end;
2411 OnChange := ProcSwitchMonstersCustom;
2412 end;
2413 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2414 begin
2415 Name := 'edTimeLimit';
2416 OnlyDigits := True;
2417 Width := 4;
2418 MaxLength := 5;
2419 if gcTimeLimit > 0 then
2420 Text := IntToStr(gcTimeLimit);
2421 end;
2422 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2423 begin
2424 Name := 'edGoalLimit';
2425 OnlyDigits := True;
2426 Width := 4;
2427 MaxLength := 5;
2428 if gcGoalLimit > 0 then
2429 Text := IntToStr(gcGoalLimit);
2430 end;
2431 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2432 begin
2433 Name := 'edMaxLives';
2434 OnlyDigits := True;
2435 Width := 4;
2436 MaxLength := 5;
2437 if gcMaxLives > 0 then
2438 Text := IntToStr(gcMaxLives);
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 := gcPlayers;
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 gcTeamDamage then
2454 ItemIndex := 0
2455 else
2456 ItemIndex := 1;
2457 end;
2458 with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do
2459 begin
2460 Name := 'swRespawnItems';
2461 AddItem(_lc[I_MENU_YES]);
2462 AddItem(_lc[I_MENU_NO]);
2463 if gcRespawnItems then
2464 ItemIndex := 0
2465 else
2466 ItemIndex := 1;
2467 end;
2468 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2469 begin
2470 Name := 'swDeathmatchKeys';
2471 AddItem(_lc[I_MENU_YES]);
2472 AddItem(_lc[I_MENU_NO]);
2473 if gcDeathmatchKeys then
2474 ItemIndex := 0
2475 else
2476 ItemIndex := 1;
2477 end;
2478 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2479 begin
2480 Name := 'swEnableExits';
2481 AddItem(_lc[I_MENU_YES]);
2482 AddItem(_lc[I_MENU_NO]);
2483 if gcAllowExit then
2484 ItemIndex := 0
2485 else
2486 ItemIndex := 1;
2487 end;
2488 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2489 begin
2490 Name := 'swWeaponStay';
2491 AddItem(_lc[I_MENU_YES]);
2492 AddItem(_lc[I_MENU_NO]);
2493 if gcWeaponStay then
2494 ItemIndex := 0
2495 else
2496 ItemIndex := 1;
2497 end;
2498 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2499 begin
2500 Name := 'swMonsters';
2501 AddItem(_lc[I_MENU_YES]);
2502 AddItem(_lc[I_MENU_NO]);
2503 if gcMonsters then
2504 ItemIndex := 0
2505 else
2506 ItemIndex := 1;
2507 end;
2508 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2509 begin
2510 Name := 'swBotsVS';
2511 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2512 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2513 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2514 ItemIndex := 2;
2515 if gcBotsVS = 'Players' then
2516 ItemIndex := 0;
2517 if gcBotsVS = 'Monsters' then
2518 ItemIndex := 1;
2519 end;
2520 AddSpace();
2521 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2523 ReAlign();
2524 end;
2525 Menu.DefControl := 'mCustomGameMenu';
2526 g_GUI_AddWindow(Menu);
2528 Menu := TGUIWindow.Create('CampaignMenu');
2529 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2530 begin
2531 Name := 'mCampaignMenu';
2533 AddSpace();
2534 AddSpace();
2535 AddSpace();
2536 AddSpace();
2537 AddSpace();
2538 AddSpace();
2540 with AddFileList('', 15, 4) do
2541 begin
2542 Name := 'lsWAD';
2543 OnChange := ProcSelectCampaignWAD;
2545 Sort := True;
2546 Dirs := True;
2547 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2548 SetBase(MegawadDirs);
2549 end;
2551 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2552 begin
2553 Name := 'lbWADName';
2554 FixedLength := 8;
2555 Enabled := False;
2556 end;
2557 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2558 begin
2559 Name := 'lbWADAuthor';
2560 FixedLength := 8;
2561 Enabled := False;
2562 end;
2563 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2564 with AddMemo('', 15, 3) do
2565 begin
2566 Name := 'meWADDescription';
2567 Color := MENU_ITEMSCTRL_COLOR;
2568 end;
2569 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2570 begin
2571 Name := 'swPlayers';
2572 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2573 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2574 end;
2575 AddSpace();
2576 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2578 ReAlign();
2580 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2581 begin
2582 Name := 'mpWADImage';
2583 DefaultRes := 'NOPIC';
2584 X := GetControl('lsWAD').X+4;
2585 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2586 end;
2587 end;
2588 Menu.DefControl := 'mCampaignMenu';
2589 g_GUI_AddWindow(Menu);
2591 Menu := TGUIWindow.Create('SelectMapMenu');
2592 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2593 begin
2594 Name := 'mSelectMapMenu';
2595 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2596 begin
2597 Name := 'lsMapWAD';
2598 OnChange := ProcSelectWAD;
2600 Sort := True;
2601 Dirs := True;
2602 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2603 SetBase(MapDirs);
2604 end;
2605 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2606 begin
2607 Name := 'lsMapRes';
2608 Sort := True;
2609 OnChange := ProcSelectMap;
2610 end;
2611 AddSpace();
2612 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2613 begin
2614 Name := 'lbMapName';
2615 FixedLength := 24;
2616 Enabled := False;
2617 end;
2618 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2619 begin
2620 Name := 'lbMapAuthor';
2621 FixedLength := 16;
2622 Enabled := False;
2623 end;
2624 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2625 begin
2626 Name := 'lbMapSize';
2627 FixedLength := 10;
2628 Enabled := False;
2629 end;
2630 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2631 begin
2632 Name := 'meMapDescription';
2633 end;
2635 ReAlign();
2637 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2638 begin
2639 Name := 'mpMapPreview';
2640 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2641 Y := GetControl('lsMapWAD').Y;
2642 end;
2643 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2644 begin
2645 Name := 'lbMapScale';
2646 FixedLength := 8;
2647 Enabled := False;
2648 Color := MENU_ITEMSCTRL_COLOR;
2649 X := GetControl('lsMapWAD').X +
2650 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2651 2 + MAPPREVIEW_WIDTH*4;
2652 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2653 end;
2654 end;
2655 Menu.OnClose := ProcSetMap;
2656 Menu.DefControl := 'mSelectMapMenu';
2657 g_GUI_AddWindow(Menu);
2659 Menu := TGUIWindow.Create('OptionsMenu');
2660 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2661 begin
2662 Name := 'mmOptionsMenu';
2663 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2664 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2665 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2666 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2667 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2668 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2669 AddSpace();
2670 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2671 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2672 end;
2673 Menu.OnClose := ProcApplyOptions;
2674 Menu.DefControl := 'mmOptionsMenu';
2675 g_GUI_AddWindow(Menu);
2677 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2678 gMenuSmallFont, @ProcSavedMenuKeyDown);
2679 g_GUI_AddWindow(Menu);
2681 Menu := TGUIWindow.Create('OptionsVideoMenu');
2682 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2683 begin
2684 Name := 'mOptionsVideoMenu';
2685 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2686 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2687 begin
2688 Name := 'swBPP';
2689 AddItem('16');
2690 AddItem('32');
2691 end;
2692 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2693 begin
2694 Name := 'swVSync';
2695 AddItem(_lc[I_MENU_YES]);
2696 AddItem(_lc[I_MENU_NO]);
2697 end;
2698 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2699 begin
2700 Name := 'swTextureFilter';
2701 AddItem(_lc[I_MENU_YES]);
2702 AddItem(_lc[I_MENU_NO]);
2703 end;
2704 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2705 begin
2706 Name := 'swLegacyNPOT';
2707 AddItem(_lc[I_MENU_NO]);
2708 AddItem(_lc[I_MENU_YES]);
2709 end;
2710 AddSpace();
2711 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2712 ReAlign();
2713 end;
2714 Menu.DefControl := 'mOptionsVideoMenu';
2715 g_GUI_AddWindow(Menu);
2717 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2718 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2719 begin
2720 Name := 'mOptionsVideoResMenu';
2721 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2722 begin
2723 Name := 'lbCurrentRes';
2724 FixedLength := 24;
2725 Enabled := False;
2726 end;
2727 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2728 begin
2729 Name := 'lsResolution';
2730 Sort := False;
2731 end;
2732 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2733 begin
2734 Name := 'swFullScreen';
2735 AddItem(_lc[I_MENU_YES]);
2736 AddItem(_lc[I_MENU_NO]);
2737 end;
2738 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2739 begin
2740 Name := 'scResFactor';
2741 Max := 10;
2742 end;
2743 AddSpace();
2744 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2745 UpdateIndex();
2746 end;
2747 Menu.DefControl := 'mOptionsVideoResMenu';
2748 g_GUI_AddWindow(Menu);
2750 Menu := TGUIWindow.Create('OptionsSoundMenu');
2751 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2752 begin
2753 Name := 'mOptionsSoundMenu';
2754 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2755 begin
2756 Name := 'scMusicLevel';
2757 Max := 16;
2758 OnChange := ProcChangeSoundSettings;
2759 end;
2760 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2761 begin
2762 Name := 'scSoundLevel';
2763 Max := 16;
2764 OnChange := ProcChangeSoundSettings;
2765 end;
2766 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2767 begin
2768 Name := 'scMaxSimSounds';
2769 Max := 16;
2770 end;
2771 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2772 begin;
2773 Name := 'swAnnouncer';
2774 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2775 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2776 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2777 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2778 end;
2779 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2780 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2781 begin;
2782 Name := 'swSoundEffects';
2783 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2784 AddItem(_lc[I_MENU_COMPAT_DF]);
2785 end;
2786 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2787 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2788 begin;
2789 Name := 'swChatSpeech';
2790 AddItem(_lc[I_MENU_YES]);
2791 AddItem(_lc[I_MENU_NO]);
2792 end;
2793 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2794 begin
2795 Name := 'swInactiveSounds';
2796 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2797 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2798 end;
2799 ReAlign();
2800 end;
2801 Menu.DefControl := 'mOptionsSoundMenu';
2802 g_GUI_AddWindow(Menu);
2804 Menu := TGUIWindow.Create('OptionsGameMenu');
2805 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2806 begin
2807 Name := 'mOptionsGameMenu';
2808 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2809 begin
2810 Name := 'scParticlesCount';
2811 Max := 20;
2812 end;
2813 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2814 begin
2815 Name := 'swBloodCount';
2816 AddItem(_lc[I_MENU_COUNT_NONE]);
2817 AddItem(_lc[I_MENU_COUNT_SMALL]);
2818 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2819 AddItem(_lc[I_MENU_COUNT_BIG]);
2820 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2821 end;
2822 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2823 begin
2824 Name := 'scShellsMax';
2825 Max := 20;
2826 end;
2827 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2828 begin
2829 Name := 'scGibsMax';
2830 Max := 20;
2831 end;
2832 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2833 begin
2834 Name := 'scCorpsesMax';
2835 Max := 20;
2836 end;
2837 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2838 begin
2839 Name := 'swGibsCount';
2840 AddItem(_lc[I_MENU_COUNT_NONE]);
2841 AddItem(_lc[I_MENU_COUNT_SMALL]);
2842 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2843 AddItem(_lc[I_MENU_COUNT_BIG]);
2844 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2845 end;
2846 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2847 begin
2848 Name := 'swCorpseType';
2849 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2850 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2851 end;
2852 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2853 begin
2854 Name := 'swGibsType';
2855 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2856 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2857 end;
2858 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2859 begin
2860 Name := 'swBloodType';
2861 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2862 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2863 end;
2864 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2865 begin
2866 Name := 'swScreenFlash';
2867 AddItem(_lc[I_MENU_NO]);
2868 AddItem(_lc[I_MENU_COMPAT_DF]);
2869 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2870 end;
2871 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2872 begin
2873 Name := 'swBackground';
2874 AddItem(_lc[I_MENU_YES]);
2875 AddItem(_lc[I_MENU_NO]);
2876 end;
2877 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2878 begin
2879 Name := 'swMessages';
2880 AddItem(_lc[I_MENU_YES]);
2881 AddItem(_lc[I_MENU_NO]);
2882 end;
2883 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2884 begin
2885 Name := 'swRevertPlayers';
2886 AddItem(_lc[I_MENU_YES]);
2887 AddItem(_lc[I_MENU_NO]);
2888 end;
2889 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2890 begin
2891 Name := 'swChatBubble';
2892 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2893 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2894 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2895 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2896 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2897 end;
2898 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2899 begin
2900 Name := 'swPlayerIndicator';
2901 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2902 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2903 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2904 end;
2905 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2906 begin
2907 Name := 'swPlayerIndicatorStyle';
2908 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2909 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2910 end;
2911 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2912 begin
2913 Name := 'scScaleFactor';
2914 Max := 10;
2915 OnChange := ProcChangeGameSettings;
2916 end;
2917 ReAlign();
2918 end;
2919 Menu.DefControl := 'mOptionsGameMenu';
2920 g_GUI_AddWindow(Menu);
2922 Menu := TGUIWindow.Create('OptionsControlsMenu');
2923 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2924 begin
2925 Name := 'mOptionsControlsMenu';
2926 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2927 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2928 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2929 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2930 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2931 AddSpace();
2932 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2933 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2934 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2935 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2936 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2937 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2938 if e_HasJoysticks then
2939 begin
2940 AddSpace();
2941 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2942 end;
2943 if g_touch_enabled then
2944 begin
2945 AddSpace();
2946 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2947 end;
2948 end;
2949 Menu.DefControl := 'mOptionsControlsMenu';
2950 g_GUI_AddWindow(Menu);
2952 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2953 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2954 begin
2955 Name := 'mOptionsControlsP1Menu';
2956 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2957 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2958 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2959 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2960 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2961 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2962 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2963 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2964 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2965 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2966 end;
2967 Menu.DefControl := 'mOptionsControlsP1Menu';
2968 g_GUI_AddWindow(Menu);
2970 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2971 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2972 begin
2973 Name := 'mOptionsControlsP1MenuWeapons';
2974 for i := WP_FIRST to WP_LAST do
2975 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2976 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2977 end;
2978 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2979 g_GUI_AddWindow(Menu);
2981 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2982 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2983 begin
2984 Name := 'mOptionsControlsP2Menu';
2985 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2986 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2987 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2988 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2989 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2990 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2991 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2992 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2993 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2994 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2995 end;
2996 Menu.DefControl := 'mOptionsControlsP2Menu';
2997 g_GUI_AddWindow(Menu);
2999 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3000 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3001 begin
3002 Name := 'mOptionsControlsP2MenuWeapons';
3003 for i := WP_FIRST to WP_LAST do
3004 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3005 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3006 end;
3007 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3008 g_GUI_AddWindow(Menu);
3010 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3011 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3012 begin
3013 Name := 'mOptionsControlsJoystickMenu';
3014 for i := 0 to e_MaxJoys - 1 do
3015 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3016 begin
3017 Name := 'scDeadzone' + IntToStr(i);
3018 Max := 20
3019 end
3020 end;
3021 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3022 g_GUI_AddWindow(Menu);
3024 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3025 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
3026 begin
3027 Name := 'mOptionsControlsTouchMenu';
3028 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3029 begin
3030 Name := 'swTouchAlt';
3031 AddItem(_lc[I_MENU_NO]);
3032 AddItem(_lc[I_MENU_YES]);
3033 OnChange := ProcChangeTouchSettings;
3034 end;
3035 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3036 begin
3037 Name := 'scTouchSize';
3038 Max := 20;
3039 OnChange := ProcChangeTouchSettings;
3040 end;
3041 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3042 begin
3043 Name := 'swTouchFire';
3044 AddItem(_lc[I_MENU_NO]);
3045 AddItem(_lc[I_MENU_YES]);
3046 end;
3047 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3048 begin
3049 Name := 'scTouchOffset';
3050 Max := 20;
3051 OnChange := ProcChangeTouchSettings;
3052 end;
3053 end;
3054 Menu.DefControl := 'mOptionsControlsTouchMenu';
3055 g_GUI_AddWindow(Menu);
3057 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3058 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3059 begin
3060 Name := 'mOptionsPlayersMenu';
3061 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3062 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3063 end;
3064 Menu.DefControl := 'mOptionsPlayersMenu';
3065 g_GUI_AddWindow(Menu);
3067 CreatePlayerOptionsMenu('P1');
3068 CreatePlayerOptionsMenu('P2');
3070 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3071 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3072 begin
3073 Name := 'mOptionsPlayersMIMenu';
3074 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3075 begin
3076 Name := 'lbName';
3077 FixedLength := 16;
3078 end;
3079 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3080 begin
3081 Name := 'lbAuthor';
3082 FixedLength := 16;
3083 end;
3084 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3085 begin
3086 Name := 'meComment';
3087 end;
3088 AddSpace();
3089 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3090 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3091 begin
3092 Name := 'lbWeapon';
3093 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3094 end;
3095 ReAlign();
3096 end;
3097 Menu.DefControl := 'mOptionsPlayersMIMenu';
3098 g_GUI_AddWindow(Menu);
3100 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3101 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3102 begin
3103 Name := 'mOptionsLanguageMenu';
3104 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3105 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3106 ReAlign();
3107 end;
3108 Menu.DefControl := 'mOptionsLanguageMenu';
3109 g_GUI_AddWindow(Menu);
3111 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3112 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3113 g_GUI_AddWindow(Menu);
3115 Menu := TGUIWindow.Create('AuthorsMenu');
3116 Menu.BackTexture := 'INTER';
3117 Menu.OnClose := ProcAuthorsClose;
3119 // Çàãîëîâîê:
3120 _y := 16;
3121 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3122 begin
3123 Color := _RGB(255, 0, 0);
3124 X := (gScreenWidth div 2)-(GetWidth() div 2);
3125 Y := _y;
3126 _y := _y+GetHeight();
3127 end;
3128 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3129 begin
3130 Color := _RGB(255, 0, 0);
3131 X := (gScreenWidth div 2)-(GetWidth() div 2);
3132 Y := _y;
3133 _y := _y+GetHeight()+32;
3134 end;
3135 // ×òî äåëàë: Êòî äåëàë
3136 cx := gScreenWidth div 2 - 320 + 64;
3137 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3138 begin
3139 Color := _RGB(255, 0, 0);
3140 X := cx;
3141 Y := _y;
3142 _y := _y+22;
3143 end;
3144 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3145 begin
3146 Color := _RGB(255, 255, 255);
3147 X := cx+32;
3148 Y := _y;
3149 _y := _y+36;
3150 end;
3151 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], 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_2_1], gMenuSmallFont))) do
3159 begin
3160 Color := _RGB(255, 255, 255);
3161 X := cx+32;
3162 Y := _y;
3163 _y := _y+22;
3164 end;
3165 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3166 begin
3167 Color := _RGB(255, 255, 255);
3168 X := cx+32;
3169 Y := _y;
3170 _y := _y+36;
3171 end;
3172 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3173 begin
3174 Color := _RGB(255, 0, 0);
3175 X := cx;
3176 Y := _y;
3177 _y := _y+22;
3178 end;
3179 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], 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_4], 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_4_1], gMenuSmallFont))) do
3194 begin
3195 Color := _RGB(255, 255, 255);
3196 X := cx+32;
3197 Y := _y;
3198 _y := gScreenHeight - 128;
3199 end;
3200 // Çàêëþ÷åíèå:
3201 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3202 begin
3203 Color := _RGB(255, 0, 0);
3204 X := cx;
3205 Y := _y;
3206 _y := _y+16;
3207 end;
3208 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3209 begin
3210 Color := _RGB(255, 255, 255);
3211 X := cx+32;
3212 Y := _y;
3213 _y := _y+GetHeight();
3214 end;
3215 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3216 begin
3217 Color := _RGB(255, 255, 255);
3218 X := cx+32;
3219 Y := _y;
3220 _y := _y+GetHeight();
3221 end;
3222 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3223 begin
3224 Color := _RGB(255, 255, 255);
3225 X := cx+32;
3226 Y := _y;
3227 _y := gScreenHeight - 32;
3228 end;
3229 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3230 begin
3231 Color := _RGB(255, 0, 0);
3232 X := gScreenWidth div 2 - GetWidth() div 2;
3233 Y := _y;
3234 end;
3235 g_GUI_AddWindow(Menu);
3237 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3238 gMenuSmallFont, @ProcExitMenuKeyDown);
3239 g_GUI_AddWindow(Menu);
3241 Menu := TGUIWindow.Create('GameSingleMenu');
3242 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3243 begin
3244 Name := 'mmGameSingleMenu';
3245 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3246 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3247 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3248 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3249 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3250 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3251 end;
3252 Menu.DefControl := 'mmGameSingleMenu';
3253 Menu.MainWindow := True;
3254 Menu.OnClose := ProcGMClose;
3255 Menu.OnShow := ProcGMShow;
3256 g_GUI_AddWindow(Menu);
3258 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3259 gMenuSmallFont, @ProcEndMenuKeyDown);
3260 g_GUI_AddWindow(Menu);
3262 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3263 gMenuSmallFont, @ProcRestartMenuKeyDown);
3264 g_GUI_AddWindow(Menu);
3266 Menu := TGUIWindow.Create('GameCustomMenu');
3267 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3268 begin
3269 Name := 'mmGameCustomMenu';
3270 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3271 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3272 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3273 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3274 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3275 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3276 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3277 end;
3278 Menu.DefControl := 'mmGameCustomMenu';
3279 Menu.MainWindow := True;
3280 Menu.OnClose := ProcGMClose;
3281 Menu.OnShow := ProcGMShow;
3282 g_GUI_AddWindow(Menu);
3284 Menu := TGUIWindow.Create('GameServerMenu');
3285 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3286 begin
3287 Name := 'mmGameServerMenu';
3288 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3289 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3290 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3291 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3292 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3293 end;
3294 Menu.DefControl := 'mmGameServerMenu';
3295 Menu.MainWindow := True;
3296 Menu.OnClose := ProcGMClose;
3297 Menu.OnShow := ProcGMShow;
3298 g_GUI_AddWindow(Menu);
3300 Menu := TGUIWindow.Create('GameClientMenu');
3301 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3302 begin
3303 Name := 'mmGameClientMenu';
3304 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3305 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3306 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3307 end;
3308 Menu.DefControl := 'mmGameClientMenu';
3309 Menu.MainWindow := True;
3310 Menu.OnClose := ProcGMClose;
3311 Menu.OnShow := ProcGMShow;
3312 g_GUI_AddWindow(Menu);
3314 Menu := TGUIWindow.Create('ClientPasswordMenu');
3315 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3316 begin
3317 Name := 'mClientPasswordMenu';
3318 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3319 begin
3320 Name := 'edPW';
3321 Width := 12;
3322 MaxLength := 32;
3323 end;
3324 AddSpace;
3326 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3327 ReAlign();
3328 end;
3329 Menu.DefControl := 'mClientPasswordMenu';
3330 g_GUI_AddWindow(Menu);
3332 Menu := TGUIWindow.Create('GameSetGameMenu');
3333 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3334 begin
3335 Name := 'mGameSetGameMenu';
3336 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3337 begin
3338 Name := 'swTeamDamage';
3339 AddItem(_lc[I_MENU_YES]);
3340 AddItem(_lc[I_MENU_NO]);
3341 ItemIndex := 1;
3342 end;
3343 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3344 begin
3345 Name := 'swDeathmatchKeys';
3346 AddItem(_lc[I_MENU_YES]);
3347 AddItem(_lc[I_MENU_NO]);
3348 ItemIndex := 1;
3349 end;
3350 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3351 begin
3352 Name := 'edTimeLimit';
3353 OnlyDigits := True;
3354 Width := 4;
3355 MaxLength := 5;
3356 end;
3357 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3358 begin
3359 Name := 'edGoalLimit';
3360 OnlyDigits := True;
3361 Width := 4;
3362 MaxLength := 5;
3363 end;
3364 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3365 begin
3366 Name := 'edMaxLives';
3367 OnlyDigits := True;
3368 Width := 4;
3369 MaxLength := 5;
3370 end;
3371 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3372 begin
3373 Name := 'swBotsVS';
3374 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3375 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3376 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3377 ItemIndex := 2;
3378 end;
3380 ReAlign();
3381 end;
3382 Menu.DefControl := 'mGameSetGameMenu';
3383 Menu.OnClose := ProcApplyGameSet;
3384 g_GUI_AddWindow(Menu);
3386 Menu := TGUIWindow.Create('TeamMenu');
3387 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3388 begin
3389 Name := 'mmTeamMenu';
3390 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3391 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3392 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3393 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3394 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3395 end;
3396 Menu.DefControl := 'mmTeamMenu';
3397 Menu.OnShow := ProcChangePlayers;
3398 g_GUI_AddWindow(Menu);
3399 end;
3401 procedure g_Menu_Show_SaveMenu();
3402 begin
3403 if g_Game_IsTestMap then
3404 Exit;
3405 if gGameSettings.GameType = GT_SINGLE then
3406 g_GUI_ShowWindow('GameSingleMenu')
3407 else
3408 begin
3409 if g_Game_IsClient then
3410 Exit
3411 else
3412 if g_Game_IsNet then
3413 Exit
3414 else
3415 g_GUI_ShowWindow('GameCustomMenu');
3416 end;
3417 g_GUI_ShowWindow('SaveMenu');
3418 g_Sound_PlayEx('MENU_OPEN');
3419 end;
3421 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3422 begin
3423 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3424 if gGameSettings.GameType = GT_SINGLE then
3425 begin
3426 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3427 end
3428 else
3429 begin
3430 if g_Game_IsClient then exit;
3431 if g_Game_IsNet then exit;
3432 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3433 end;
3434 g_GUI_ShowWindow('LoadMenu');
3435 g_Sound_PlayEx('MENU_OPEN');
3436 end;
3438 procedure g_Menu_Show_GameSetGame();
3439 begin
3440 if gGameSettings.GameType = GT_SINGLE then
3441 g_GUI_ShowWindow('GameSingleMenu')
3442 else
3443 begin
3444 if g_Game_IsClient then
3445 Exit
3446 else
3447 if g_Game_IsNet then
3448 g_GUI_ShowWindow('GameServerMenu')
3449 else
3450 g_GUI_ShowWindow('GameCustomMenu');
3451 end;
3452 ReadGameSettings();
3453 g_GUI_ShowWindow('GameSetGameMenu');
3454 g_Sound_PlayEx('MENU_OPEN');
3455 end;
3457 procedure g_Menu_Show_OptionsVideo();
3458 begin
3459 if gGameSettings.GameType = GT_SINGLE then
3460 g_GUI_ShowWindow('GameSingleMenu')
3461 else
3462 begin
3463 if g_Game_IsClient then
3464 g_GUI_ShowWindow('GameClientMenu')
3465 else
3466 if g_Game_IsNet then
3467 g_GUI_ShowWindow('GameServerMenu')
3468 else
3469 g_GUI_ShowWindow('GameCustomMenu');
3470 end;
3471 ReadOptions();
3472 g_GUI_ShowWindow('OptionsMenu');
3473 g_GUI_ShowWindow('OptionsVideoMenu');
3474 g_Sound_PlayEx('MENU_OPEN');
3475 end;
3477 procedure g_Menu_Show_OptionsSound();
3478 begin
3479 if gGameSettings.GameType = GT_SINGLE then
3480 g_GUI_ShowWindow('GameSingleMenu')
3481 else
3482 begin
3483 if g_Game_IsClient then
3484 g_GUI_ShowWindow('GameClientMenu')
3485 else
3486 if g_Game_IsNet then
3487 g_GUI_ShowWindow('GameServerMenu')
3488 else
3489 g_GUI_ShowWindow('GameCustomMenu');
3490 end;
3491 ReadOptions();
3492 g_GUI_ShowWindow('OptionsMenu');
3493 g_GUI_ShowWindow('OptionsSoundMenu');
3494 g_Sound_PlayEx('MENU_OPEN');
3495 end;
3497 procedure g_Menu_Show_EndGameMenu();
3498 begin
3499 g_GUI_ShowWindow('EndGameMenu');
3500 g_Sound_PlayEx('MENU_OPEN');
3501 end;
3503 procedure g_Menu_Show_QuitGameMenu();
3504 begin
3505 g_GUI_ShowWindow('ExitMenu');
3506 g_Sound_PlayEx('MENU_OPEN');
3507 end;
3509 procedure g_Menu_Init();
3510 begin
3511 MenuLoadData();
3512 g_GUI_Init();
3513 CreateAllMenus();
3514 end;
3516 procedure g_Menu_Free();
3517 begin
3518 g_GUI_Destroy();
3520 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3522 MenuFreeData();
3523 end;
3525 procedure g_Menu_Reset();
3526 var
3527 ex: Boolean;
3528 begin
3529 g_GUI_SaveMenuPos();
3530 ex := g_GUI_Destroy();
3532 if ex then
3533 begin
3534 e_WriteLog('Recreating menu...', TMsgType.Notify);
3536 CreateAllMenus();
3538 if gDebugMode then
3539 g_Game_SetDebugMode();
3541 g_GUI_LoadMenuPos();
3542 end;
3543 end;
3545 end.