DEADSOFTWARE

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