DEADSOFTWARE

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