DEADSOFTWARE

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