DEADSOFTWARE

properly grey out the dmkeys menu option
[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 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1731 begin
1732 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1733 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1734 end
1735 else
1736 begin
1737 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1738 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1739 end;
1740 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1741 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1742 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1743 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1744 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1745 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1746 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1747 end
1748 else
1749 begin
1750 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1751 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1752 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1753 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1754 begin
1755 Enabled := False;
1756 Text := '';
1757 end;
1758 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1759 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1760 begin
1761 Enabled := False;
1762 Text := '';
1763 end;
1764 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1765 with TGUIEdit(menu.GetControl('edMaxLives')) do
1766 begin
1767 Enabled := False;
1768 Text := '';
1769 end;
1770 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1771 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1772 end;
1773 end;
1774 end;
1776 procedure ProcApplyGameSet();
1777 var
1778 menu: TGUIMenu;
1779 a, b, n: Integer;
1780 stat: TPlayerStatArray;
1781 begin
1782 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1784 if not g_Game_IsServer then Exit;
1786 with gGameSettings do
1787 begin
1788 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1789 begin
1790 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1791 Options := Options or GAME_OPTION_TEAMDAMAGE
1792 else
1793 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1794 end;
1796 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1797 begin
1798 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1799 Options := Options or GAME_OPTION_DMKEYS
1800 else
1801 Options := Options and (not GAME_OPTION_DMKEYS);
1802 end;
1804 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1805 begin
1806 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1808 if n = 0 then
1809 TimeLimit := 0
1810 else
1811 begin
1812 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1814 TimeLimit := Max(n, b);
1815 end;
1816 end;
1818 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1819 begin
1820 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1822 if n = 0 then
1823 GoalLimit := 0
1824 else
1825 begin
1826 b := 0;
1827 if GameMode = GM_DM then
1828 begin // DM
1829 stat := g_Player_GetStats();
1830 if stat <> nil then
1831 for a := 0 to High(stat) do
1832 if stat[a].Frags > b then
1833 b := stat[a].Frags;
1834 end
1835 else // CTF
1836 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1838 GoalLimit := Max(n, b);
1839 end;
1840 end;
1842 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1843 begin
1844 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1845 if n < 0 then n := 0;
1846 if n > 255 then n := 255;
1847 if n = 0 then
1848 MaxLives := 0
1849 else
1850 begin
1851 b := 0;
1852 stat := g_Player_GetStats();
1853 if stat <> nil then
1854 for a := 0 to High(stat) do
1855 if stat[a].Lives > b then
1856 b := stat[a].Lives;
1858 MaxLives := Max(n, b);
1859 end;
1860 end;
1862 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1863 begin
1864 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1865 1:
1866 begin
1867 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1868 Options := Options or GAME_OPTION_BOTVSMONSTER;
1869 end;
1870 2:
1871 begin
1872 Options := Options or GAME_OPTION_BOTVSPLAYER;
1873 Options := Options or GAME_OPTION_BOTVSMONSTER;
1874 end;
1875 else
1876 begin
1877 Options := Options or GAME_OPTION_BOTVSPLAYER;
1878 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1879 end;
1880 end;
1881 end;
1882 end;
1884 if g_Game_IsNet then MH_SEND_GameSettings;
1885 end;
1887 procedure ProcVideoOptionsRes();
1888 var
1889 menu: TGUIMenu;
1890 list: SSArray;
1891 begin
1892 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1894 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1895 IntToStr(gWinSizeX) +
1896 ' x ' + IntToStr(gWinSizeY) +
1897 ', ' + IntToStr(gBPP) + ' bpp';
1899 with TGUIListBox(menu.GetControl('lsResolution')) do
1900 begin
1901 list := sys_GetDisplayModes(gBPP);
1902 if list <> nil then
1903 begin
1904 Items := list;
1905 ItemIndex := Length(list)
1906 end
1907 else
1908 begin
1909 Clear
1910 end
1911 end;
1913 with TGUISwitch(menu.GetControl('swFullScreen')) do
1914 if gFullscreen then
1915 ItemIndex := 0
1916 else
1917 ItemIndex := 1;
1919 TempResScale := Round(r_pixel_scale - 1);
1920 TGUIScroll(menu.GetControl('scResFactor')).Value := TempResScale;
1921 end;
1923 procedure ProcApplyVideoOptions();
1924 var
1925 menu: TGUIMenu;
1926 Fullscreen: Boolean;
1927 SWidth, SHeight: Integer;
1928 ScaleChanged: Boolean;
1929 str: String;
1930 begin
1931 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1933 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1934 if str <> '' then
1935 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1936 else
1937 begin
1938 SWidth := gWinSizeX;
1939 SHeight := gWinSizeY;
1940 end;
1942 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1944 ScaleChanged := False;
1945 if TGUIScroll(menu.GetControl('scResFactor')).Value <> TempResScale then
1946 begin
1947 TempResScale := TGUIScroll(menu.GetControl('scResFactor')).Value;
1948 r_pixel_scale := TempResScale + 1;
1949 ScaleChanged := True;
1950 end;
1952 if (SWidth <> gWinSizeX) or
1953 (SHeight <> gWinSizeY) or
1954 (Fullscreen <> gFullscreen) or
1955 ScaleChanged then
1956 begin
1957 gResolutionChange := True;
1958 gRC_Width := SWidth;
1959 gRC_Height := SHeight;
1960 gRC_FullScreen := Fullscreen;
1961 gRC_Maximized := gWinMaximized;
1962 end;
1964 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1965 ProcApplyOptions();
1966 end;
1968 procedure ProcSetFirstRussianLanguage;
1969 begin
1970 gLanguage := LANGUAGE_RUSSIAN;
1971 gLanguageChange := True;
1972 gAskLanguage := False;
1973 end;
1975 procedure ProcSetFirstEnglishLanguage;
1976 begin
1977 gLanguage := LANGUAGE_ENGLISH;
1978 gLanguageChange := True;
1979 gAskLanguage := False;
1980 end;
1982 procedure ProcRecallAddress();
1983 begin
1984 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1985 begin
1986 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1987 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1988 end;
1989 end;
1991 procedure CreateFirstLanguageMenu();
1992 var
1993 Menu: TGUIWindow;
1994 begin
1995 Menu := TGUIWindow.Create('FirstLanguageMenu');
1997 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1998 begin
1999 Name := 'mmFirstLanguageMenu';
2000 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
2001 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
2002 end;
2004 Menu.DefControl := 'mmFirstLanguageMenu';
2005 Menu.MainWindow := True;
2006 g_GUI_AddWindow(Menu);
2007 end;
2009 procedure g_Menu_AskLanguage();
2010 begin
2011 CreateFirstLanguageMenu();
2012 g_GUI_ShowWindow('FirstLanguageMenu');
2013 end;
2015 procedure CreatePlayerOptionsMenu(s: String);
2016 var
2017 Menu: TGUIWindow;
2018 a: String;
2019 begin
2020 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2021 if s = 'P1' then
2022 a := _lc[I_MENU_PLAYER_1]
2023 else
2024 a := _lc[I_MENU_PLAYER_2];
2025 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
2026 begin
2027 Name := 'mOptionsPlayers'+s+'Menu';
2028 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2029 begin
2030 Name := 'ed'+s+'Name';
2031 MaxLength := 12;
2032 Width := 12;
2033 end;
2034 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2035 begin
2036 Name := 'sw'+s+'Team';
2037 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2038 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2039 end ;
2040 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2041 begin
2042 Name := 'ls'+s+'Model';
2043 Sort := True;
2044 Items := g_PlayerModel_GetNames();
2045 OnChange := ProcSelectModel;
2046 end;
2047 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2048 begin
2049 Name := 'sc'+s+'Red';
2050 Max := 16;
2051 OnChange := ProcChangeColor;
2052 end;
2053 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2054 begin
2055 Name := 'sc'+s+'Green';
2056 Max := 16;
2057 OnChange := ProcChangeColor;
2058 end;
2059 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2060 begin
2061 Name := 'sc'+s+'Blue';
2062 Max := 16;
2063 OnChange := ProcChangeColor;
2064 end;
2065 AddSpace();
2066 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2067 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2068 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2069 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2071 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2072 begin
2073 Name := 'mv'+s+'Model';
2074 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2075 Y := GetControl('ls'+s+'Model').Y;
2076 end;
2077 end;
2078 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2079 g_GUI_AddWindow(Menu);
2080 end;
2082 procedure CreateAllMenus();
2083 var
2084 Menu: TGUIWindow;
2085 //SR: TSearchRec;
2086 a, cx, _y, i: Integer;
2087 //list: SSArray;
2088 begin
2089 Menu := TGUIWindow.Create('MainMenu');
2090 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2091 begin
2092 Name := 'mmMainMenu';
2093 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2094 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2095 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2096 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2097 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2098 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2099 end;
2100 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2101 begin
2102 Color := _RGB(255, 255, 255);
2103 X := gScreenWidth-GetWidth-8;
2104 Y := gScreenHeight-GetHeight-8;
2105 end;
2106 Menu.DefControl := 'mmMainMenu';
2107 Menu.MainWindow := True;
2108 g_GUI_AddWindow(Menu);
2110 Menu := TGUIWindow.Create('NewGameMenu');
2111 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2112 begin
2113 Name := 'mmNewGameMenu';
2114 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2115 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2116 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2117 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2118 end;
2119 Menu.DefControl := 'mmNewGameMenu';
2120 g_GUI_AddWindow(Menu);
2122 Menu := TGUIWindow.Create('NetGameMenu');
2123 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2124 begin
2125 Name := 'mmNetGameMenu';
2126 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2127 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2128 end;
2129 Menu.DefControl := 'mmNetGameMenu';
2130 g_GUI_AddWindow(Menu);
2132 Menu := TGUIWindow.Create('NetServerMenu');
2133 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2134 begin
2135 Name := 'mNetServerMenu';
2136 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2137 begin
2138 Name := 'edSrvName';
2139 OnlyDigits := False;
2140 Width := 16;
2141 MaxLength := 64;
2142 Text := NetServerName;
2143 end;
2144 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2145 begin
2146 Name := 'edSrvPassword';
2147 OnlyDigits := False;
2148 Width := 16;
2149 MaxLength := 24;
2150 Text := NetPassword;
2151 end;
2152 with AddEdit(_lc[I_NET_PORT]) do
2153 begin
2154 Name := 'edPort';
2155 OnlyDigits := True;
2156 Width := 4;
2157 MaxLength := 5;
2158 Text := IntToStr(NetPort);
2159 end;
2160 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2161 begin
2162 Name := 'edMaxPlayers';
2163 OnlyDigits := True;
2164 Width := 4;
2165 MaxLength := 2;
2166 Text := IntToStr(NetMaxClients);
2167 end;
2168 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2169 begin
2170 Name := 'swUseMaster';
2171 AddItem(_lc[I_MENU_YES]);
2172 AddItem(_lc[I_MENU_NO]);
2173 if NetUseMaster then
2174 ItemIndex := 0
2175 else
2176 ItemIndex := 1;
2177 end;
2178 AddSpace();
2179 with AddLabel(_lc[I_MENU_MAP]) do
2180 begin
2181 Name := 'lbMap';
2182 FixedLength := 16;
2183 Text := gnMap;
2184 OnClick := @ProcSelectMapMenu;
2185 end;
2186 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2187 begin
2188 Name := 'swGameMode';
2189 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2190 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2191 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2192 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2193 case g_Game_TextToMode(gnGameMode) of
2194 GM_NONE,
2195 GM_DM: ItemIndex := 0;
2196 GM_TDM: ItemIndex := 1;
2197 GM_CTF: ItemIndex := 2;
2198 GM_SINGLE,
2199 GM_COOP: ItemIndex := 3;
2200 end;
2201 OnChange := ProcSwitchMonstersNet;
2202 end;
2203 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2204 begin
2205 Name := 'edTimeLimit';
2206 OnlyDigits := True;
2207 Width := 4;
2208 MaxLength := 5;
2209 if gnTimeLimit > 0 then
2210 Text := IntToStr(gnTimeLimit);
2211 end;
2212 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2213 begin
2214 Name := 'edGoalLimit';
2215 OnlyDigits := True;
2216 Width := 4;
2217 MaxLength := 5;
2218 if gnGoalLimit > 0 then
2219 Text := IntToStr(gnGoalLimit);
2220 end;
2221 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2222 begin
2223 Name := 'edMaxLives';
2224 OnlyDigits := True;
2225 Width := 4;
2226 MaxLength := 3;
2227 if gnMaxLives > 0 then
2228 Text := IntToStr(gnMaxLives);
2229 end;
2230 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2231 begin
2232 Name := 'swPlayers';
2233 AddItem(_lc[I_MENU_COUNT_NONE]);
2234 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2235 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2236 ItemIndex := gnPlayers;
2237 end;
2238 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2239 begin
2240 Name := 'swTeamDamage';
2241 AddItem(_lc[I_MENU_YES]);
2242 AddItem(_lc[I_MENU_NO]);
2243 if gnTeamDamage then
2244 ItemIndex := 0
2245 else
2246 ItemIndex := 1;
2247 end;
2248 with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do
2249 begin
2250 Name := 'swRespawnItems';
2251 AddItem(_lc[I_MENU_YES]);
2252 AddItem(_lc[I_MENU_NO]);
2253 if gnRespawnItems then
2254 ItemIndex := 0
2255 else
2256 ItemIndex := 1;
2257 end;
2258 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2259 begin
2260 Name := 'swDeathmatchKeys';
2261 AddItem(_lc[I_MENU_YES]);
2262 AddItem(_lc[I_MENU_NO]);
2263 if gnDeathmatchKeys then
2264 ItemIndex := 0
2265 else
2266 ItemIndex := 1;
2267 end;
2268 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2269 begin
2270 Name := 'swEnableExits';
2271 AddItem(_lc[I_MENU_YES]);
2272 AddItem(_lc[I_MENU_NO]);
2273 if gnAllowExit then
2274 ItemIndex := 0
2275 else
2276 ItemIndex := 1;
2277 end;
2278 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2279 begin
2280 Name := 'swWeaponStay';
2281 AddItem(_lc[I_MENU_YES]);
2282 AddItem(_lc[I_MENU_NO]);
2283 if gnWeaponStay then
2284 ItemIndex := 0
2285 else
2286 ItemIndex := 1;
2287 end;
2288 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2289 begin
2290 Name := 'swMonsters';
2291 AddItem(_lc[I_MENU_YES]);
2292 AddItem(_lc[I_MENU_NO]);
2293 if gnMonsters then
2294 ItemIndex := 0
2295 else
2296 ItemIndex := 1;
2297 end;
2298 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2299 begin
2300 Name := 'swBotsVS';
2301 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2302 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2303 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2304 ItemIndex := 2;
2305 if gnBotsVS = 'Players' then
2306 ItemIndex := 0;
2307 if gnBotsVS = 'Monsters' then
2308 ItemIndex := 1;
2309 end;
2310 AddSpace();
2311 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2313 ReAlign();
2314 end;
2315 Menu.DefControl := 'mNetServerMenu';
2316 g_GUI_AddWindow(Menu);
2318 Menu := TGUIWindow.Create('NetClientMenu');
2319 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2320 begin
2321 Name := 'mNetClientMenu';
2323 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2324 AddSpace();
2326 with AddEdit(_lc[I_NET_ADDRESS]) do
2327 begin
2328 Name := 'edIP';
2329 OnlyDigits :=False;
2330 Width := 12;
2331 MaxLength := 64;
2332 Text := 'localhost';
2333 end;
2334 with AddEdit(_lc[I_NET_PORT]) do
2335 begin
2336 Name := 'edPort';
2337 OnlyDigits := True;
2338 Width := 4;
2339 MaxLength := 5;
2340 Text := '25666';
2341 end;
2342 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2343 begin
2344 Name := 'edPW';
2345 OnlyDigits := False;
2346 Width := 12;
2347 MaxLength := 32;
2348 Text := '';
2349 end;
2351 AddSpace();
2352 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2354 ReAlign();
2355 end;
2356 Menu.DefControl := 'mNetClientMenu';
2357 g_GUI_AddWindow(Menu);
2359 Menu := TGUIWindow.Create('LoadMenu');
2360 Menu.OnShow := ProcLoadMenu;
2361 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2362 begin
2363 Name := 'mmLoadMenu';
2365 for a := 1 to 8 do
2366 with AddEdit('') do
2367 begin
2368 Name := 'edSlot'+IntToStr(a);
2369 Width := 16;
2370 MaxLength := 16;
2371 OnEnter := ProcLoadGame;
2372 end;
2373 end;
2374 Menu.DefControl := 'mmLoadMenu';
2375 g_GUI_AddWindow(Menu);
2377 Menu := TGUIWindow.Create('SaveMenu');
2378 Menu.OnShow := ProcSaveMenu;
2379 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2380 begin
2381 Name := 'mmSaveMenu';
2383 for a := 1 to 8 do
2384 with AddEdit('') do
2385 begin
2386 Name := 'edSlot'+IntToStr(a);
2387 Width := 16;
2388 MaxLength := 16;
2389 OnChange := ProcSaveGame;
2390 end;
2391 end;
2392 Menu.DefControl := 'mmSaveMenu';
2393 g_GUI_AddWindow(Menu);
2395 Menu := TGUIWindow.Create('CustomGameMenu');
2396 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2397 begin
2398 Name := 'mCustomGameMenu';
2399 with AddLabel(_lc[I_MENU_MAP]) do
2400 begin
2401 Name := 'lbMap';
2402 FixedLength := 16;
2403 Text := gcMap;
2404 OnClick := @ProcSelectMapMenu;
2405 end;
2406 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2407 begin
2408 Name := 'swGameMode';
2409 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2410 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2411 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2412 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2413 case g_Game_TextToMode(gcGameMode) of
2414 GM_NONE,
2415 GM_DM: ItemIndex := 0;
2416 GM_TDM: ItemIndex := 1;
2417 GM_CTF: ItemIndex := 2;
2418 GM_SINGLE,
2419 GM_COOP: ItemIndex := 3;
2420 end;
2421 OnChange := ProcSwitchMonstersCustom;
2422 end;
2423 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2424 begin
2425 Name := 'edTimeLimit';
2426 OnlyDigits := True;
2427 Width := 4;
2428 MaxLength := 5;
2429 if gcTimeLimit > 0 then
2430 Text := IntToStr(gcTimeLimit);
2431 end;
2432 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2433 begin
2434 Name := 'edGoalLimit';
2435 OnlyDigits := True;
2436 Width := 4;
2437 MaxLength := 5;
2438 if gcGoalLimit > 0 then
2439 Text := IntToStr(gcGoalLimit);
2440 end;
2441 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2442 begin
2443 Name := 'edMaxLives';
2444 OnlyDigits := True;
2445 Width := 4;
2446 MaxLength := 5;
2447 if gcMaxLives > 0 then
2448 Text := IntToStr(gcMaxLives);
2449 end;
2450 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2451 begin
2452 Name := 'swPlayers';
2453 AddItem(_lc[I_MENU_COUNT_NONE]);
2454 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2455 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2456 ItemIndex := gcPlayers;
2457 end;
2458 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2459 begin
2460 Name := 'swTeamDamage';
2461 AddItem(_lc[I_MENU_YES]);
2462 AddItem(_lc[I_MENU_NO]);
2463 if gcTeamDamage then
2464 ItemIndex := 0
2465 else
2466 ItemIndex := 1;
2467 end;
2468 with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do
2469 begin
2470 Name := 'swRespawnItems';
2471 AddItem(_lc[I_MENU_YES]);
2472 AddItem(_lc[I_MENU_NO]);
2473 if gcRespawnItems then
2474 ItemIndex := 0
2475 else
2476 ItemIndex := 1;
2477 end;
2478 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2479 begin
2480 Name := 'swDeathmatchKeys';
2481 AddItem(_lc[I_MENU_YES]);
2482 AddItem(_lc[I_MENU_NO]);
2483 if gcDeathmatchKeys then
2484 ItemIndex := 0
2485 else
2486 ItemIndex := 1;
2487 end;
2488 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2489 begin
2490 Name := 'swEnableExits';
2491 AddItem(_lc[I_MENU_YES]);
2492 AddItem(_lc[I_MENU_NO]);
2493 if gcAllowExit then
2494 ItemIndex := 0
2495 else
2496 ItemIndex := 1;
2497 end;
2498 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2499 begin
2500 Name := 'swWeaponStay';
2501 AddItem(_lc[I_MENU_YES]);
2502 AddItem(_lc[I_MENU_NO]);
2503 if gcWeaponStay then
2504 ItemIndex := 0
2505 else
2506 ItemIndex := 1;
2507 end;
2508 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2509 begin
2510 Name := 'swMonsters';
2511 AddItem(_lc[I_MENU_YES]);
2512 AddItem(_lc[I_MENU_NO]);
2513 if gcMonsters then
2514 ItemIndex := 0
2515 else
2516 ItemIndex := 1;
2517 end;
2518 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2519 begin
2520 Name := 'swBotsVS';
2521 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2522 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2523 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2524 ItemIndex := 2;
2525 if gcBotsVS = 'Players' then
2526 ItemIndex := 0;
2527 if gcBotsVS = 'Monsters' then
2528 ItemIndex := 1;
2529 end;
2530 AddSpace();
2531 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2533 ReAlign();
2534 end;
2535 Menu.DefControl := 'mCustomGameMenu';
2536 g_GUI_AddWindow(Menu);
2538 Menu := TGUIWindow.Create('CampaignMenu');
2539 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2540 begin
2541 Name := 'mCampaignMenu';
2543 AddSpace();
2544 AddSpace();
2545 AddSpace();
2546 AddSpace();
2547 AddSpace();
2548 AddSpace();
2550 with AddFileList('', 15, 4) do
2551 begin
2552 Name := 'lsWAD';
2553 OnChange := ProcSelectCampaignWAD;
2555 Sort := True;
2556 Dirs := True;
2557 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2558 SetBase(MegawadDirs);
2559 end;
2561 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2562 begin
2563 Name := 'lbWADName';
2564 FixedLength := 8;
2565 Enabled := False;
2566 end;
2567 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2568 begin
2569 Name := 'lbWADAuthor';
2570 FixedLength := 8;
2571 Enabled := False;
2572 end;
2573 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2574 with AddMemo('', 15, 3) do
2575 begin
2576 Name := 'meWADDescription';
2577 Color := MENU_ITEMSCTRL_COLOR;
2578 end;
2579 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2580 begin
2581 Name := 'swPlayers';
2582 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2583 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2584 end;
2585 AddSpace();
2586 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2588 ReAlign();
2590 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2591 begin
2592 Name := 'mpWADImage';
2593 DefaultRes := 'NOPIC';
2594 X := GetControl('lsWAD').X+4;
2595 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2596 end;
2597 end;
2598 Menu.DefControl := 'mCampaignMenu';
2599 g_GUI_AddWindow(Menu);
2601 Menu := TGUIWindow.Create('SelectMapMenu');
2602 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2603 begin
2604 Name := 'mSelectMapMenu';
2605 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2606 begin
2607 Name := 'lsMapWAD';
2608 OnChange := ProcSelectWAD;
2610 Sort := True;
2611 Dirs := True;
2612 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2613 SetBase(MapDirs);
2614 end;
2615 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2616 begin
2617 Name := 'lsMapRes';
2618 Sort := True;
2619 OnChange := ProcSelectMap;
2620 end;
2621 AddSpace();
2622 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2623 begin
2624 Name := 'lbMapName';
2625 FixedLength := 24;
2626 Enabled := False;
2627 end;
2628 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2629 begin
2630 Name := 'lbMapAuthor';
2631 FixedLength := 16;
2632 Enabled := False;
2633 end;
2634 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2635 begin
2636 Name := 'lbMapSize';
2637 FixedLength := 10;
2638 Enabled := False;
2639 end;
2640 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2641 begin
2642 Name := 'meMapDescription';
2643 end;
2645 ReAlign();
2647 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2648 begin
2649 Name := 'mpMapPreview';
2650 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2651 Y := GetControl('lsMapWAD').Y;
2652 end;
2653 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2654 begin
2655 Name := 'lbMapScale';
2656 FixedLength := 8;
2657 Enabled := False;
2658 Color := MENU_ITEMSCTRL_COLOR;
2659 X := GetControl('lsMapWAD').X +
2660 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2661 2 + MAPPREVIEW_WIDTH*4;
2662 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2663 end;
2664 end;
2665 Menu.OnClose := ProcSetMap;
2666 Menu.DefControl := 'mSelectMapMenu';
2667 g_GUI_AddWindow(Menu);
2669 Menu := TGUIWindow.Create('OptionsMenu');
2670 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2671 begin
2672 Name := 'mmOptionsMenu';
2673 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2674 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2675 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2676 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2677 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2678 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2679 AddSpace();
2680 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2681 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2682 end;
2683 Menu.OnClose := ProcApplyOptions;
2684 Menu.DefControl := 'mmOptionsMenu';
2685 g_GUI_AddWindow(Menu);
2687 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2688 gMenuSmallFont, @ProcSavedMenuKeyDown);
2689 g_GUI_AddWindow(Menu);
2691 Menu := TGUIWindow.Create('OptionsVideoMenu');
2692 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2693 begin
2694 Name := 'mOptionsVideoMenu';
2695 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2696 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2697 begin
2698 Name := 'swBPP';
2699 AddItem('16');
2700 AddItem('32');
2701 end;
2702 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2703 begin
2704 Name := 'swVSync';
2705 AddItem(_lc[I_MENU_YES]);
2706 AddItem(_lc[I_MENU_NO]);
2707 end;
2708 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2709 begin
2710 Name := 'swTextureFilter';
2711 AddItem(_lc[I_MENU_YES]);
2712 AddItem(_lc[I_MENU_NO]);
2713 end;
2714 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2715 begin
2716 Name := 'swLegacyNPOT';
2717 AddItem(_lc[I_MENU_NO]);
2718 AddItem(_lc[I_MENU_YES]);
2719 end;
2720 AddSpace();
2721 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2722 ReAlign();
2723 end;
2724 Menu.DefControl := 'mOptionsVideoMenu';
2725 g_GUI_AddWindow(Menu);
2727 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2728 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2729 begin
2730 Name := 'mOptionsVideoResMenu';
2731 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2732 begin
2733 Name := 'lbCurrentRes';
2734 FixedLength := 24;
2735 Enabled := False;
2736 end;
2737 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2738 begin
2739 Name := 'lsResolution';
2740 Sort := False;
2741 end;
2742 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2743 begin
2744 Name := 'swFullScreen';
2745 AddItem(_lc[I_MENU_YES]);
2746 AddItem(_lc[I_MENU_NO]);
2747 end;
2748 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2749 begin
2750 Name := 'scResFactor';
2751 Max := 10;
2752 end;
2753 AddSpace();
2754 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2755 UpdateIndex();
2756 end;
2757 Menu.DefControl := 'mOptionsVideoResMenu';
2758 g_GUI_AddWindow(Menu);
2760 Menu := TGUIWindow.Create('OptionsSoundMenu');
2761 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2762 begin
2763 Name := 'mOptionsSoundMenu';
2764 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2765 begin
2766 Name := 'scMusicLevel';
2767 Max := 16;
2768 OnChange := ProcChangeSoundSettings;
2769 end;
2770 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2771 begin
2772 Name := 'scSoundLevel';
2773 Max := 16;
2774 OnChange := ProcChangeSoundSettings;
2775 end;
2776 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2777 begin
2778 Name := 'scMaxSimSounds';
2779 Max := 16;
2780 end;
2781 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2782 begin;
2783 Name := 'swAnnouncer';
2784 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2785 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2786 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2787 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2788 end;
2789 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2790 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2791 begin;
2792 Name := 'swSoundEffects';
2793 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2794 AddItem(_lc[I_MENU_COMPAT_DF]);
2795 end;
2796 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2797 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2798 begin;
2799 Name := 'swChatSpeech';
2800 AddItem(_lc[I_MENU_YES]);
2801 AddItem(_lc[I_MENU_NO]);
2802 end;
2803 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2804 begin
2805 Name := 'swInactiveSounds';
2806 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2807 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2808 end;
2809 ReAlign();
2810 end;
2811 Menu.DefControl := 'mOptionsSoundMenu';
2812 g_GUI_AddWindow(Menu);
2814 Menu := TGUIWindow.Create('OptionsGameMenu');
2815 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2816 begin
2817 Name := 'mOptionsGameMenu';
2818 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2819 begin
2820 Name := 'scParticlesCount';
2821 Max := 20;
2822 end;
2823 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2824 begin
2825 Name := 'swBloodCount';
2826 AddItem(_lc[I_MENU_COUNT_NONE]);
2827 AddItem(_lc[I_MENU_COUNT_SMALL]);
2828 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2829 AddItem(_lc[I_MENU_COUNT_BIG]);
2830 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2831 end;
2832 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2833 begin
2834 Name := 'scShellsMax';
2835 Max := 20;
2836 end;
2837 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2838 begin
2839 Name := 'scGibsMax';
2840 Max := 20;
2841 end;
2842 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2843 begin
2844 Name := 'scCorpsesMax';
2845 Max := 20;
2846 end;
2847 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2848 begin
2849 Name := 'swGibsCount';
2850 AddItem(_lc[I_MENU_COUNT_NONE]);
2851 AddItem(_lc[I_MENU_COUNT_SMALL]);
2852 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2853 AddItem(_lc[I_MENU_COUNT_BIG]);
2854 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2855 end;
2856 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2857 begin
2858 Name := 'swCorpseType';
2859 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2860 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2861 end;
2862 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2863 begin
2864 Name := 'swGibsType';
2865 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2866 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2867 end;
2868 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2869 begin
2870 Name := 'swBloodType';
2871 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2872 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2873 end;
2874 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2875 begin
2876 Name := 'swScreenFlash';
2877 AddItem(_lc[I_MENU_NO]);
2878 AddItem(_lc[I_MENU_COMPAT_DF]);
2879 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2880 end;
2881 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2882 begin
2883 Name := 'swBackground';
2884 AddItem(_lc[I_MENU_YES]);
2885 AddItem(_lc[I_MENU_NO]);
2886 end;
2887 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2888 begin
2889 Name := 'swMessages';
2890 AddItem(_lc[I_MENU_YES]);
2891 AddItem(_lc[I_MENU_NO]);
2892 end;
2893 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2894 begin
2895 Name := 'swRevertPlayers';
2896 AddItem(_lc[I_MENU_YES]);
2897 AddItem(_lc[I_MENU_NO]);
2898 end;
2899 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2900 begin
2901 Name := 'swChatBubble';
2902 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2903 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2904 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2905 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2906 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2907 end;
2908 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2909 begin
2910 Name := 'swPlayerIndicator';
2911 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2912 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2913 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2914 end;
2915 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2916 begin
2917 Name := 'swPlayerIndicatorStyle';
2918 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2919 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2920 end;
2921 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2922 begin
2923 Name := 'scScaleFactor';
2924 Max := 10;
2925 OnChange := ProcChangeGameSettings;
2926 end;
2927 ReAlign();
2928 end;
2929 Menu.DefControl := 'mOptionsGameMenu';
2930 g_GUI_AddWindow(Menu);
2932 Menu := TGUIWindow.Create('OptionsControlsMenu');
2933 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2934 begin
2935 Name := 'mOptionsControlsMenu';
2936 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2937 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2938 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2939 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2940 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2941 AddSpace();
2942 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2943 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2944 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2945 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2946 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2947 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2948 if e_HasJoysticks then
2949 begin
2950 AddSpace();
2951 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2952 end;
2953 if g_touch_enabled then
2954 begin
2955 AddSpace();
2956 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2957 end;
2958 end;
2959 Menu.DefControl := 'mOptionsControlsMenu';
2960 g_GUI_AddWindow(Menu);
2962 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2963 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2964 begin
2965 Name := 'mOptionsControlsP1Menu';
2966 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2967 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2968 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2969 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2970 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2971 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2972 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2973 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2974 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2975 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2976 end;
2977 Menu.DefControl := 'mOptionsControlsP1Menu';
2978 g_GUI_AddWindow(Menu);
2980 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2981 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2982 begin
2983 Name := 'mOptionsControlsP1MenuWeapons';
2984 for i := WP_FIRST to WP_LAST do
2985 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2986 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2987 end;
2988 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2989 g_GUI_AddWindow(Menu);
2991 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2992 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2993 begin
2994 Name := 'mOptionsControlsP2Menu';
2995 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2996 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2997 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2998 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2999 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3000 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3001 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3002 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3003 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3004 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3005 end;
3006 Menu.DefControl := 'mOptionsControlsP2Menu';
3007 g_GUI_AddWindow(Menu);
3009 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3010 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3011 begin
3012 Name := 'mOptionsControlsP2MenuWeapons';
3013 for i := WP_FIRST to WP_LAST do
3014 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3015 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3016 end;
3017 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3018 g_GUI_AddWindow(Menu);
3020 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3021 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3022 begin
3023 Name := 'mOptionsControlsJoystickMenu';
3024 for i := 0 to e_MaxJoys - 1 do
3025 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3026 begin
3027 Name := 'scDeadzone' + IntToStr(i);
3028 Max := 20
3029 end
3030 end;
3031 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3032 g_GUI_AddWindow(Menu);
3034 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3035 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
3036 begin
3037 Name := 'mOptionsControlsTouchMenu';
3038 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3039 begin
3040 Name := 'swTouchAlt';
3041 AddItem(_lc[I_MENU_NO]);
3042 AddItem(_lc[I_MENU_YES]);
3043 OnChange := ProcChangeTouchSettings;
3044 end;
3045 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3046 begin
3047 Name := 'scTouchSize';
3048 Max := 20;
3049 OnChange := ProcChangeTouchSettings;
3050 end;
3051 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3052 begin
3053 Name := 'swTouchFire';
3054 AddItem(_lc[I_MENU_NO]);
3055 AddItem(_lc[I_MENU_YES]);
3056 end;
3057 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3058 begin
3059 Name := 'scTouchOffset';
3060 Max := 20;
3061 OnChange := ProcChangeTouchSettings;
3062 end;
3063 end;
3064 Menu.DefControl := 'mOptionsControlsTouchMenu';
3065 g_GUI_AddWindow(Menu);
3067 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3068 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3069 begin
3070 Name := 'mOptionsPlayersMenu';
3071 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3072 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3073 end;
3074 Menu.DefControl := 'mOptionsPlayersMenu';
3075 g_GUI_AddWindow(Menu);
3077 CreatePlayerOptionsMenu('P1');
3078 CreatePlayerOptionsMenu('P2');
3080 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3081 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3082 begin
3083 Name := 'mOptionsPlayersMIMenu';
3084 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3085 begin
3086 Name := 'lbName';
3087 FixedLength := 16;
3088 end;
3089 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3090 begin
3091 Name := 'lbAuthor';
3092 FixedLength := 16;
3093 end;
3094 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3095 begin
3096 Name := 'meComment';
3097 end;
3098 AddSpace();
3099 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3100 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3101 begin
3102 Name := 'lbWeapon';
3103 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3104 end;
3105 ReAlign();
3106 end;
3107 Menu.DefControl := 'mOptionsPlayersMIMenu';
3108 g_GUI_AddWindow(Menu);
3110 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3111 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3112 begin
3113 Name := 'mOptionsLanguageMenu';
3114 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3115 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3116 ReAlign();
3117 end;
3118 Menu.DefControl := 'mOptionsLanguageMenu';
3119 g_GUI_AddWindow(Menu);
3121 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3122 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3123 g_GUI_AddWindow(Menu);
3125 Menu := TGUIWindow.Create('AuthorsMenu');
3126 Menu.BackTexture := 'INTER';
3127 Menu.OnClose := ProcAuthorsClose;
3129 // Çàãîëîâîê:
3130 _y := 16;
3131 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3132 begin
3133 Color := _RGB(255, 0, 0);
3134 X := (gScreenWidth div 2)-(GetWidth() div 2);
3135 Y := _y;
3136 _y := _y+GetHeight();
3137 end;
3138 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3139 begin
3140 Color := _RGB(255, 0, 0);
3141 X := (gScreenWidth div 2)-(GetWidth() div 2);
3142 Y := _y;
3143 _y := _y+GetHeight()+32;
3144 end;
3145 // ×òî äåëàë: Êòî äåëàë
3146 cx := gScreenWidth div 2 - 320 + 64;
3147 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3148 begin
3149 Color := _RGB(255, 0, 0);
3150 X := cx;
3151 Y := _y;
3152 _y := _y+22;
3153 end;
3154 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3155 begin
3156 Color := _RGB(255, 255, 255);
3157 X := cx+32;
3158 Y := _y;
3159 _y := _y+36;
3160 end;
3161 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3162 begin
3163 Color := _RGB(255, 0, 0);
3164 X := cx;
3165 Y := _y;
3166 _y := _y+22;
3167 end;
3168 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3169 begin
3170 Color := _RGB(255, 255, 255);
3171 X := cx+32;
3172 Y := _y;
3173 _y := _y+22;
3174 end;
3175 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3176 begin
3177 Color := _RGB(255, 255, 255);
3178 X := cx+32;
3179 Y := _y;
3180 _y := _y+36;
3181 end;
3182 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3183 begin
3184 Color := _RGB(255, 0, 0);
3185 X := cx;
3186 Y := _y;
3187 _y := _y+22;
3188 end;
3189 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3190 begin
3191 Color := _RGB(255, 255, 255);
3192 X := cx+32;
3193 Y := _y;
3194 _y := _y+36;
3195 end;
3196 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3197 begin
3198 Color := _RGB(255, 0, 0);
3199 X := cx;
3200 Y := _y;
3201 _y := _y+22;
3202 end;
3203 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3204 begin
3205 Color := _RGB(255, 255, 255);
3206 X := cx+32;
3207 Y := _y;
3208 _y := gScreenHeight - 128;
3209 end;
3210 // Çàêëþ÷åíèå:
3211 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3212 begin
3213 Color := _RGB(255, 0, 0);
3214 X := cx;
3215 Y := _y;
3216 _y := _y+16;
3217 end;
3218 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3219 begin
3220 Color := _RGB(255, 255, 255);
3221 X := cx+32;
3222 Y := _y;
3223 _y := _y+GetHeight();
3224 end;
3225 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3226 begin
3227 Color := _RGB(255, 255, 255);
3228 X := cx+32;
3229 Y := _y;
3230 _y := _y+GetHeight();
3231 end;
3232 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3233 begin
3234 Color := _RGB(255, 255, 255);
3235 X := cx+32;
3236 Y := _y;
3237 _y := gScreenHeight - 32;
3238 end;
3239 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3240 begin
3241 Color := _RGB(255, 0, 0);
3242 X := gScreenWidth div 2 - GetWidth() div 2;
3243 Y := _y;
3244 end;
3245 g_GUI_AddWindow(Menu);
3247 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3248 gMenuSmallFont, @ProcExitMenuKeyDown);
3249 g_GUI_AddWindow(Menu);
3251 Menu := TGUIWindow.Create('GameSingleMenu');
3252 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3253 begin
3254 Name := 'mmGameSingleMenu';
3255 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3256 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3257 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3258 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3259 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3260 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3261 end;
3262 Menu.DefControl := 'mmGameSingleMenu';
3263 Menu.MainWindow := True;
3264 Menu.OnClose := ProcGMClose;
3265 Menu.OnShow := ProcGMShow;
3266 g_GUI_AddWindow(Menu);
3268 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3269 gMenuSmallFont, @ProcEndMenuKeyDown);
3270 g_GUI_AddWindow(Menu);
3272 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3273 gMenuSmallFont, @ProcRestartMenuKeyDown);
3274 g_GUI_AddWindow(Menu);
3276 Menu := TGUIWindow.Create('GameCustomMenu');
3277 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3278 begin
3279 Name := 'mmGameCustomMenu';
3280 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3281 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3282 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3283 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3284 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3285 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3286 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3287 end;
3288 Menu.DefControl := 'mmGameCustomMenu';
3289 Menu.MainWindow := True;
3290 Menu.OnClose := ProcGMClose;
3291 Menu.OnShow := ProcGMShow;
3292 g_GUI_AddWindow(Menu);
3294 Menu := TGUIWindow.Create('GameServerMenu');
3295 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3296 begin
3297 Name := 'mmGameServerMenu';
3298 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3299 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3300 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3301 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3302 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3303 end;
3304 Menu.DefControl := 'mmGameServerMenu';
3305 Menu.MainWindow := True;
3306 Menu.OnClose := ProcGMClose;
3307 Menu.OnShow := ProcGMShow;
3308 g_GUI_AddWindow(Menu);
3310 Menu := TGUIWindow.Create('GameClientMenu');
3311 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3312 begin
3313 Name := 'mmGameClientMenu';
3314 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3315 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3316 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3317 end;
3318 Menu.DefControl := 'mmGameClientMenu';
3319 Menu.MainWindow := True;
3320 Menu.OnClose := ProcGMClose;
3321 Menu.OnShow := ProcGMShow;
3322 g_GUI_AddWindow(Menu);
3324 Menu := TGUIWindow.Create('ClientPasswordMenu');
3325 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3326 begin
3327 Name := 'mClientPasswordMenu';
3328 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3329 begin
3330 Name := 'edPW';
3331 Width := 12;
3332 MaxLength := 32;
3333 end;
3334 AddSpace;
3336 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3337 ReAlign();
3338 end;
3339 Menu.DefControl := 'mClientPasswordMenu';
3340 g_GUI_AddWindow(Menu);
3342 Menu := TGUIWindow.Create('GameSetGameMenu');
3343 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3344 begin
3345 Name := 'mGameSetGameMenu';
3346 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3347 begin
3348 Name := 'swTeamDamage';
3349 AddItem(_lc[I_MENU_YES]);
3350 AddItem(_lc[I_MENU_NO]);
3351 ItemIndex := 1;
3352 end;
3353 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3354 begin
3355 Name := 'swDeathmatchKeys';
3356 AddItem(_lc[I_MENU_YES]);
3357 AddItem(_lc[I_MENU_NO]);
3358 ItemIndex := 1;
3359 end;
3360 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3361 begin
3362 Name := 'edTimeLimit';
3363 OnlyDigits := True;
3364 Width := 4;
3365 MaxLength := 5;
3366 end;
3367 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3368 begin
3369 Name := 'edGoalLimit';
3370 OnlyDigits := True;
3371 Width := 4;
3372 MaxLength := 5;
3373 end;
3374 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3375 begin
3376 Name := 'edMaxLives';
3377 OnlyDigits := True;
3378 Width := 4;
3379 MaxLength := 5;
3380 end;
3381 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3382 begin
3383 Name := 'swBotsVS';
3384 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3385 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3386 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3387 ItemIndex := 2;
3388 end;
3390 ReAlign();
3391 end;
3392 Menu.DefControl := 'mGameSetGameMenu';
3393 Menu.OnClose := ProcApplyGameSet;
3394 g_GUI_AddWindow(Menu);
3396 Menu := TGUIWindow.Create('TeamMenu');
3397 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3398 begin
3399 Name := 'mmTeamMenu';
3400 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3401 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3402 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3403 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3404 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3405 end;
3406 Menu.DefControl := 'mmTeamMenu';
3407 Menu.OnShow := ProcChangePlayers;
3408 g_GUI_AddWindow(Menu);
3409 end;
3411 procedure g_Menu_Show_SaveMenu();
3412 begin
3413 if g_Game_IsTestMap then
3414 Exit;
3415 if gGameSettings.GameType = GT_SINGLE then
3416 g_GUI_ShowWindow('GameSingleMenu')
3417 else
3418 begin
3419 if g_Game_IsClient then
3420 Exit
3421 else
3422 if g_Game_IsNet then
3423 Exit
3424 else
3425 g_GUI_ShowWindow('GameCustomMenu');
3426 end;
3427 g_GUI_ShowWindow('SaveMenu');
3428 g_Sound_PlayEx('MENU_OPEN');
3429 end;
3431 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3432 begin
3433 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3434 if gGameSettings.GameType = GT_SINGLE then
3435 begin
3436 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3437 end
3438 else
3439 begin
3440 if g_Game_IsClient then exit;
3441 if g_Game_IsNet then exit;
3442 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3443 end;
3444 g_GUI_ShowWindow('LoadMenu');
3445 g_Sound_PlayEx('MENU_OPEN');
3446 end;
3448 procedure g_Menu_Show_GameSetGame();
3449 begin
3450 if gGameSettings.GameType = GT_SINGLE then
3451 g_GUI_ShowWindow('GameSingleMenu')
3452 else
3453 begin
3454 if g_Game_IsClient then
3455 Exit
3456 else
3457 if g_Game_IsNet then
3458 g_GUI_ShowWindow('GameServerMenu')
3459 else
3460 g_GUI_ShowWindow('GameCustomMenu');
3461 end;
3462 ReadGameSettings();
3463 g_GUI_ShowWindow('GameSetGameMenu');
3464 g_Sound_PlayEx('MENU_OPEN');
3465 end;
3467 procedure g_Menu_Show_OptionsVideo();
3468 begin
3469 if gGameSettings.GameType = GT_SINGLE then
3470 g_GUI_ShowWindow('GameSingleMenu')
3471 else
3472 begin
3473 if g_Game_IsClient then
3474 g_GUI_ShowWindow('GameClientMenu')
3475 else
3476 if g_Game_IsNet then
3477 g_GUI_ShowWindow('GameServerMenu')
3478 else
3479 g_GUI_ShowWindow('GameCustomMenu');
3480 end;
3481 ReadOptions();
3482 g_GUI_ShowWindow('OptionsMenu');
3483 g_GUI_ShowWindow('OptionsVideoMenu');
3484 g_Sound_PlayEx('MENU_OPEN');
3485 end;
3487 procedure g_Menu_Show_OptionsSound();
3488 begin
3489 if gGameSettings.GameType = GT_SINGLE then
3490 g_GUI_ShowWindow('GameSingleMenu')
3491 else
3492 begin
3493 if g_Game_IsClient then
3494 g_GUI_ShowWindow('GameClientMenu')
3495 else
3496 if g_Game_IsNet then
3497 g_GUI_ShowWindow('GameServerMenu')
3498 else
3499 g_GUI_ShowWindow('GameCustomMenu');
3500 end;
3501 ReadOptions();
3502 g_GUI_ShowWindow('OptionsMenu');
3503 g_GUI_ShowWindow('OptionsSoundMenu');
3504 g_Sound_PlayEx('MENU_OPEN');
3505 end;
3507 procedure g_Menu_Show_EndGameMenu();
3508 begin
3509 g_GUI_ShowWindow('EndGameMenu');
3510 g_Sound_PlayEx('MENU_OPEN');
3511 end;
3513 procedure g_Menu_Show_QuitGameMenu();
3514 begin
3515 g_GUI_ShowWindow('ExitMenu');
3516 g_Sound_PlayEx('MENU_OPEN');
3517 end;
3519 procedure g_Menu_Init();
3520 begin
3521 MenuLoadData();
3522 g_GUI_Init();
3523 CreateAllMenus();
3524 end;
3526 procedure g_Menu_Free();
3527 begin
3528 g_GUI_Destroy();
3530 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3532 MenuFreeData();
3533 end;
3535 procedure g_Menu_Reset();
3536 var
3537 ex: Boolean;
3538 begin
3539 g_GUI_SaveMenuPos();
3540 ex := g_GUI_Destroy();
3542 if ex then
3543 begin
3544 e_WriteLog('Recreating menu...', TMsgType.Notify);
3546 CreateAllMenus();
3548 if gDebugMode then
3549 g_Game_SetDebugMode();
3551 g_GUI_LoadMenuPos();
3552 end;
3553 end;
3555 end.