DEADSOFTWARE

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