DEADSOFTWARE

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