DEADSOFTWARE

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