DEADSOFTWARE

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