DEADSOFTWARE

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