DEADSOFTWARE

aea8b499a6a662a22692eb04d8ec350ea3ed04fc
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_menu;
19 interface
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
25 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
36 var
37 gMenuFont: DWORD;
38 gMenuSmallFont: DWORD;
39 PromptIP: string;
40 PromptPort: Word;
42 implementation
44 uses
45 {$INCLUDE ../nogl/noGLuses.inc}
46 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
47 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
48 e_log, SysUtils, CONFIG, g_playermodel, DateUtils, sdl2,
49 MAPDEF, Math, g_saveload,
50 e_texture, g_language,
51 g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
52 utils, wadreader;
55 type TYNCallback = procedure (yes:Boolean);
57 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
58 begin
59 if win.UserData = nil then exit;
60 case Key of
61 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
62 IK_N: TYNCallback(win.UserData)(false);
63 end;
64 end;
66 procedure YesButtonCB (ctl: TGUITextButton);
67 begin
68 if ctl.UserData = nil then exit;
69 TYNCallback(ctl.UserData)(true);
70 end;
72 procedure NoButtonCB (ctl: TGUITextButton);
73 begin
74 if ctl.UserData = nil then exit;
75 TYNCallback(ctl.UserData)(false);
76 end;
78 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
79 var
80 menu: TGUIMenu;
81 begin
82 //if length(Text) = 0 then exit;
83 Result := TGUIWindow.Create(WinName);
84 with Result do
85 begin
86 //OnKeyDownEx := @YNKeyDownProc;
87 //UserData := @ActionProc;
88 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
89 with menu do
90 begin
91 Name := '__temp_yes_no_menu:'+WinName;
92 YesNo := true;
93 AddText(Text, MaxLen);
94 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
95 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
96 end;
97 DefControl := '__temp_yes_no_menu:'+WinName;
98 SetActive(nil);
99 end;
100 end;
103 procedure ProcChangeColor(Sender: TGUIControl); forward;
104 procedure ProcSelectModel(Sender: TGUIControl); forward;
106 procedure ProcApplyOptions();
107 var
108 menu: TGUIMenu;
109 i: Integer;
110 ovs: Boolean;
111 begin
112 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
114 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
115 gBPP := 16
116 else
117 gBPP := 32;
119 ovs := gVSync;
120 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
121 if (ovs <> gVSync) then g_SetVSync(gVSync);
123 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
124 glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
126 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
128 g_Sound_SetupAllVolumes(
129 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
130 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
131 );
133 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
134 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
135 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
136 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
137 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
139 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
141 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
142 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
143 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
144 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
146 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
147 0: gGibsCount := 0;
148 1: gGibsCount := 8;
149 2: gGibsCount := 16;
150 3: gGibsCount := 32;
151 else gGibsCount := 48;
152 end;
154 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
155 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
156 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
157 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
158 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
159 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
160 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
161 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
162 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
163 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex = 0;
164 g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
166 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
168 with menu do
169 begin
170 g_Console_BindKey(g_Console_FindBind(1, 'screenshot'), '');
171 g_Console_BindKey(g_Console_FindBind(1, '+p1_scores'), '');
172 g_Console_BindKey(g_Console_FindBind(1, 'togglechat'), '');
173 g_Console_BindKey(g_Console_FindBind(1, 'toggleteamchat'), '');
174 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key, 'screenshot');
175 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key, '+p1_scores');
176 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key, 'togglechat');
177 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key, 'toggleteamchat');
178 end;
180 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
181 with menu do
182 begin
183 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveright'), '');
184 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveleft'), '');
185 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookup'), '');
186 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookdown'), '');
187 g_Console_BindKey(g_Console_FindBind(1, '+p1_attack'), '');
188 g_Console_BindKey(g_Console_FindBind(1, '+p1_jump'), '');
189 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapnext'), '');
190 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapprev'), '');
191 g_Console_BindKey(g_Console_FindBind(1, '+p1_activate'), '');
192 g_Console_BindKey(g_Console_FindBind(1, '+p1_strafe'), '');
193 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p1_moveright');
194 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p1_moveleft');
195 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p1_lookup');
196 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p1_lookdown');
197 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p1_attack');
198 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p1_jump');
199 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p1_weapnext');
200 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p1_weapprev');
201 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p1_activate');
202 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p1_strafe');
203 // second set
204 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveright'), '');
205 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveleft'), '');
206 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookup'), '');
207 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookdown'), '');
208 g_Console_BindKey(g_Console_FindBind(2, '+p1_attack'), '');
209 g_Console_BindKey(g_Console_FindBind(2, '+p1_jump'), '');
210 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapnext'), '');
211 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapprev'), '');
212 g_Console_BindKey(g_Console_FindBind(2, '+p1_activate'), '');
213 g_Console_BindKey(g_Console_FindBind(2, '+p1_strafe'), '');
214 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p1_moveright');
215 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p1_moveleft');
216 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p1_lookup');
217 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p1_lookdown');
218 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p1_attack');
219 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p1_jump');
220 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p1_weapnext');
221 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p1_weapprev');
222 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p1_activate');
223 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p1_strafe');
224 end;
226 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
227 with menu do
228 begin
229 for i := WP_FIRST to WP_LAST do
230 begin
231 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1)), '');
232 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p1_weapon ' + IntToStr(i + 1));
233 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1)), '');
234 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p1_weapon ' + IntToStr(i + 1));
235 end;
236 end;
238 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
239 with menu do
240 begin
241 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveright'), '');
242 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveleft'), '');
243 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookup'), '');
244 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown'), '');
245 g_Console_BindKey(g_Console_FindBind(1, '+p2_attack'), '');
246 g_Console_BindKey(g_Console_FindBind(1, '+p2_jump'), '');
247 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapnext'), '');
248 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapprev'), '');
249 g_Console_BindKey(g_Console_FindBind(1, '+p2_activate'), '');
250 g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe'), '');
251 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright');
252 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft');
253 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup');
254 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown');
255 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack');
256 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump');
257 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p2_weapnext');
258 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p2_weapprev');
259 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate');
260 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe');
261 // second set
262 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright'), '');
263 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft'), '');
264 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookup'), '');
265 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown'), '');
266 g_Console_BindKey(g_Console_FindBind(2, '+p2_attack'), '');
267 g_Console_BindKey(g_Console_FindBind(2, '+p2_jump'), '');
268 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapnext'), '');
269 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapprev'), '');
270 g_Console_BindKey(g_Console_FindBind(2, '+p2_activate'), '');
271 g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe'), '');
272 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright');
273 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft');
274 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup');
275 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown');
276 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack');
277 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump');
278 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p2_weapnext');
279 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p2_weapprev');
280 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate');
281 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe');
282 end;
284 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
285 with menu do
286 begin
287 for i := WP_FIRST to WP_LAST do
288 begin
289 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1)), '');
290 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p2_weapon ' + IntToStr(i + 1));
291 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1)), '');
292 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p2_weapon ' + IntToStr(i + 1));
293 end;
294 end;
296 if e_JoysticksAvailable > 0 then
297 begin
298 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
299 with menu do
300 begin
301 for i := 0 to e_JoysticksAvailable-1 do
302 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20);
303 end;
304 end;
306 if g_touch_enabled then
307 begin
308 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
309 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
310 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
311 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
312 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
313 end;
315 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
317 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
318 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
319 TEAM_RED, TEAM_BLUE);
321 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
322 begin
323 gPlayer1Settings.Model := Model.Name;
324 gPlayer1Settings.Color := Model.Color;
325 end;
327 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
329 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
330 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
331 TEAM_RED, TEAM_BLUE);
332 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
333 begin
334 gPlayer2Settings.Model := Model.Name;
335 gPlayer2Settings.Color := Model.Color;
336 end;
338 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
339 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
341 if g_Game_IsServer then
342 begin
343 if gPlayer1 <> nil then
344 begin
345 gPlayer1.SetModel(gPlayer1Settings.Model);
346 gPlayer1.Name := gPlayer1Settings.Name;
347 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
348 gPlayer1.SetColor(gPlayer1Settings.Color)
349 else
350 if gPlayer1.Team <> gPlayer1Settings.Team then
351 gPlayer1.SwitchTeam;
353 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
354 end;
356 if gPlayer2 <> nil then
357 begin
358 gPlayer2.SetModel(gPlayer2Settings.Model);
359 gPlayer2.Name := gPlayer2Settings.Name;
360 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
361 gPlayer2.SetColor(gPlayer2Settings.Color)
362 else
363 if gPlayer2.Team <> gPlayer2Settings.Team then
364 gPlayer2.SwitchTeam;
365 end;
366 end;
368 if g_Game_IsClient then MC_SEND_PlayerSettings;
370 g_Options_Write(GameDir+'/'+CONFIG_FILENAME);
371 g_Console_WriteConfig(GameDir + '/dfconfig.cfg');
372 end;
374 procedure ReadOptions();
375 var
376 menu: TGUIMenu;
377 i: Integer;
378 begin
379 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
381 with TGUISwitch(menu.GetControl('swBPP')) do
382 if gBPP = 16 then
383 ItemIndex := 0
384 else
385 ItemIndex := 1;
387 with TGUISwitch(menu.GetControl('swTextureFilter')) do
388 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
390 with TGUISwitch(menu.GetControl('swVSync')) do
391 if gVSync then ItemIndex := 0 else ItemIndex := 1;
393 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
394 if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1;
396 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
398 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
399 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
400 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
402 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
403 if gMuteWhenInactive then
404 ItemIndex := 1
405 else
406 ItemIndex := 0;
408 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
410 with TGUISwitch(menu.GetControl('swSoundEffects')) do
411 if gSoundEffectsDF then
412 ItemIndex := 1
413 else
414 ItemIndex := 0;
416 with TGUISwitch(menu.GetControl('swChatSpeech')) do
417 if gUseChatSounds then
418 ItemIndex := 0
419 else
420 ItemIndex := 1;
422 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
423 with menu do
424 begin
425 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p1_moveright');
426 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p1_moveleft');
427 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p1_lookup');
428 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown');
429 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack');
430 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump');
431 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapnext');
432 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapprev');
433 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate');
434 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe');
435 // second set
436 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright');
437 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft');
438 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p1_lookup');
439 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown');
440 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack');
441 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump');
442 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2,'+p1_weapnext');
443 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapprev');
444 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate');
445 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe');
446 end;
448 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
449 with menu do
450 begin
451 for i := WP_FIRST to WP_LAST do
452 begin
453 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1));
454 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1));
455 end;
456 end;
458 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
459 with menu do
460 begin
461 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright');
462 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft');
463 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup');
464 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown');
465 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack');
466 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump');
467 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapnext');
468 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapprev');
469 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate');
470 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe');
471 // second set
472 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright');
473 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft');
474 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup');
475 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown');
476 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack');
477 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump');
478 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2,'+p2_weapnext');
479 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapprev');
480 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate');
481 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe');
482 end;
484 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
485 with menu do
486 begin
487 for i := WP_FIRST to WP_LAST do
488 begin
489 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
490 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
491 end;
492 end;
494 if e_JoysticksAvailable > 0 then
495 begin
496 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
497 with menu do
498 begin
499 for i := 0 to e_JoysticksAvailable-1 do
500 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20);
501 end;
502 end;
504 if g_touch_enabled then
505 begin
506 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
507 with TGUISwitch(menu.GetControl('swTouchAlt')) do
508 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
509 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
510 with TGUISwitch(menu.GetControl('swTouchFire')) do
511 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
512 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
513 end;
515 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
516 with menu do
517 begin
518 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
519 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+p1_scores');
520 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
521 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
522 end;
524 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
526 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
527 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
528 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
529 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
530 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
532 with TGUISwitch(menu.GetControl('swScreenFlash')) do
533 ItemIndex := gFlash;
535 with TGUISwitch(menu.GetControl('swBloodType')) do
536 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
538 with TGUISwitch(menu.GetControl('swCorpseType')) do
539 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
541 with TGUISwitch(menu.GetControl('swGibsType')) do
542 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
544 with TGUISwitch(menu.GetControl('swGibsCount')) do
545 case gGibsCount of
546 0: ItemIndex := 0;
547 8: ItemIndex := 1;
548 16: ItemIndex := 2;
549 32: ItemIndex := 3;
550 else ItemIndex := 4;
551 end;
553 with TGUISwitch(menu.GetControl('swBackGround')) do
554 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
556 with TGUISwitch(menu.GetControl('swMessages')) do
557 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
559 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
560 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
562 with TGUISwitch(menu.GetControl('swChatBubble')) do
563 ItemIndex := gChatBubble;
565 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
566 if gPlayerIndicator then ItemIndex := 0 else ItemIndex := 1;
568 TGUIScroll(menu.GetControl('scScaleFactor')).Value := Round(g_dbg_scale - 1);
570 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
572 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
573 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
575 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
576 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
578 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
579 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
580 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
582 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
584 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
585 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
587 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
588 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
590 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
591 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
592 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
594 ProcSelectModel(nil);
595 end;
597 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
598 begin
599 // don't turn off monsters in DM
601 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
602 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
603 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
604 else
605 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
608 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
609 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
610 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
611 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
613 end;
615 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
616 begin
617 // don't turn off monsters in DM
619 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
620 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
621 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
622 else
623 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
626 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
627 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
628 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
629 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
631 end;
633 procedure ProcStartCustomGame();
634 var
635 Map: String;
636 GameMode: Byte;
637 Options: LongWord;
638 begin
639 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
640 begin
641 Map := TGUILabel(GetControl('lbMap')).Text;
642 if Map = '' then
643 Exit;
644 if not isWadPath(Map) then
645 Exit;
647 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
648 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
649 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
650 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
651 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
653 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
654 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
655 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
656 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
657 Options := 0;
658 if gcTeamDamage then
659 Options := Options or GAME_OPTION_TEAMDAMAGE;
660 if gcAllowExit then
661 Options := Options or GAME_OPTION_ALLOWEXIT;
662 if gcWeaponStay then
663 Options := Options or GAME_OPTION_WEAPONSTAY;
664 if gcMonsters then
665 Options := Options or GAME_OPTION_MONSTERS;
666 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
668 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
669 1: begin
670 Options := Options or GAME_OPTION_BOTVSMONSTER;
671 gcBotsVS := 'Monsters';
672 end;
673 2: begin
674 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
675 gcBotsVS := 'Everybody';
676 end;
677 else begin
678 Options := Options or GAME_OPTION_BOTVSPLAYER;
679 gcBotsVS := 'Players';
680 end;
681 end;
683 gcMap := Map;
684 end;
686 g_Options_Write_Gameplay_Custom(GameDir+'/'+CONFIG_FILENAME);
688 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
689 gcMaxLives, Options, gcPlayers);
690 end;
693 procedure ProcStartNetGame();
694 var
695 Map: String;
696 GameMode: Byte;
697 Options: LongWord;
698 begin
699 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
700 begin
701 Map := TGUILabel(GetControl('lbMap')).Text;
702 if Map = '' then
703 Exit;
704 if not isWadPath(Map) then
705 Exit;
707 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
708 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
709 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
710 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
711 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
712 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
714 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
715 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
716 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
717 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
718 Options := 0;
719 if gnTeamDamage then
720 Options := Options or GAME_OPTION_TEAMDAMAGE;
721 if gnAllowExit then
722 Options := Options or GAME_OPTION_ALLOWEXIT;
723 if gnWeaponStay then
724 Options := Options or GAME_OPTION_WEAPONSTAY;
725 if gnMonsters then
726 Options := Options or GAME_OPTION_MONSTERS;
727 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
729 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
730 1: begin
731 Options := Options or GAME_OPTION_BOTVSMONSTER;
732 gnBotsVS := 'Monsters';
733 end;
734 2: begin
735 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
736 gnBotsVS := 'Everybody';
737 end;
738 else begin
739 Options := Options or GAME_OPTION_BOTVSPLAYER;
740 gnBotsVS := 'Players';
741 end;
742 end;
744 gnMap := Map;
745 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
746 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
747 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
748 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
749 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
750 end;
752 g_Options_Write_Net_Server(GameDir+'/'+CONFIG_FILENAME);
753 g_Options_Write_Gameplay_Net(GameDir+'/'+CONFIG_FILENAME);
755 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
756 Options, gnPlayers, 0, NetPort);
757 end;
759 procedure ProcConnectNetGame();
760 var
761 PW: String;
762 begin
763 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
764 begin
765 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
766 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
767 PW := TGUIEdit(GetControl('edPW')).Text;
768 end;
770 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
771 g_Game_StartClient(NetClientIP, NetClientPort, PW);
772 end;
774 procedure ProcEnterPassword();
775 var
776 PW: string;
777 begin
778 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
779 begin
780 NetClientIP := PromptIP;
781 NetClientPort := PromptPort;
782 PW := TGUIEdit(GetControl('edPW')).Text;
783 end;
785 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
786 g_Game_StartClient(NetClientIP, NetClientPort, PW);
787 end;
789 procedure ProcServerlist();
790 begin
791 if not NetInitDone then
792 begin
793 if (not g_Net_Init()) then
794 begin
795 g_Console_Add('NET: ERROR: Failed to init ENet!');
796 Exit;
797 end
798 else
799 NetInitDone := True;
800 end;
802 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
804 gState := STATE_SLIST;
805 g_ActiveWindow := nil;
807 slWaitStr := _lc[I_NET_SLIST_WAIT];
809 g_Game_Draw;
810 ReDrawWindow;
812 slReturnPressed := True;
813 if g_Net_Slist_Fetch(slCurrent) then
814 begin
815 if slCurrent = nil then
816 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
817 end
818 else
819 slWaitStr := _lc[I_NET_SLIST_ERROR];
820 g_Serverlist_GenerateTable(slCurrent, slTable);
821 end;
823 procedure ProcStartCampaign();
824 var
825 WAD: String;
826 TwoPlayers: Boolean;
827 n: Byte;
828 begin
829 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
830 begin
831 WAD := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
832 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
833 end;
835 if TwoPlayers then
836 n := 2
837 else
838 n := 1;
839 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
840 end;
842 procedure ProcSelectMap(Sender: TGUIControl);
843 var
844 win: TGUIWindow;
845 a: TMapInfo;
846 wad, map, res: String;
847 begin
848 win := g_GUI_GetWindow('SelectMapMenu');
849 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
850 begin
851 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
852 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
854 if (wad = '') or (map = '') then
855 begin // Ýòî íå êàðòà
856 TGUILabel(GetControl('lbMapName')).Text := '';
857 TGUILabel(GetControl('lbMapAuthor')).Text := '';
858 TGUILabel(GetControl('lbMapSize')).Text := '';
859 TGUIMemo(GetControl('meMapDescription')).SetText('');
860 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
861 TGUILabel(win.GetControl('lbMapScale')).Text := '';
862 end
863 else // Ýòî êàðòà
864 begin
865 res := wad+':\'+map;
867 a := g_Map_GetMapInfo(res);
869 TGUILabel(GetControl('lbMapName')).Text := a.Name;
870 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
871 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
872 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
873 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
874 TGUILabel(win.GetControl('lbMapScale')).Text :=
875 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
876 end;
877 end;
878 end;
880 procedure ProcSelectWAD(Sender: TGUIControl);
881 var
882 wad: String;
883 list: SSArray;
884 begin
885 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
886 begin
887 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
889 with TGUIListBox(GetControl('lsMapRes')) do
890 begin
891 Clear();
893 if wad <> '' then
894 begin
895 list := g_Map_GetMapsList(wad);
897 if list <> nil then
898 begin
899 Items := list;
900 ItemIndex := 0;
901 end
902 end;
903 end;
904 end;
906 ProcSelectMap(nil);
907 end;
909 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
910 var
911 win: TGUIWindow;
912 a: TMegaWADInfo;
913 wad, fn: String;
914 begin
915 win := g_GUI_GetWindow('CampaignMenu');
916 with TGUIMenu(win.GetControl('mCampaignMenu')) do
917 begin
918 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
920 if wad = '' then
921 begin
922 TGUILabel(GetControl('lbWADName')).Text := '';
923 TGUILabel(GetControl('lbWADAuthor')).Text := '';
924 TGUIMemo(GetControl('meWADDescription')).SetText('');
925 end;
927 a := g_Game_GetMegaWADInfo(wad);
929 TGUILabel(GetControl('lbWADName')).Text := a.Name;
930 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
931 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
933 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
935 if a.pic <> '' then
936 begin
937 fn := g_ExtractWadName(a.pic);
938 if fn = '' then
939 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
940 else
941 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
942 end;
943 end;
944 end;
946 procedure ProcChangeColor(Sender: TGUIControl);
947 var
948 window: TGUIWindow;
949 begin
950 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
951 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
952 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
953 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
954 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
955 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
957 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
958 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
959 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
960 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
961 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
962 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
963 end;
965 procedure ProcSelectModel(Sender: TGUIControl);
966 var
967 a: string;
968 window: TGUIWindow;
969 begin
970 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
971 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
972 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
974 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
975 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
976 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
978 ProcChangeColor(nil);
979 end;
981 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
982 var
983 cwdt, chgt: Byte;
984 spc: ShortInt;
985 ID: DWORD;
986 wad: TWADFile;
987 cfgdata: Pointer;
988 cfglen: Integer;
989 config: TConfig;
990 begin
991 cfglen := 0;
993 wad := TWADFile.Create;
994 if wad.ReadFile(GameWAD) then
995 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
996 wad.Free();
998 if cfglen <> 0 then
999 begin
1000 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
1002 config := TConfig.CreateMem(cfgdata, cfglen);
1003 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1004 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1005 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1007 if g_Texture_Get('FONT_STD', ID) then
1008 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
1010 config.Free();
1011 end;
1013 if cfglen <> 0 then FreeMem(cfgdata);
1014 end;
1016 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
1017 var
1018 cwdt, chgt: Byte;
1019 spc: ShortInt;
1020 CharID: DWORD;
1021 wad: TWADFile;
1022 cfgdata, fntdata: Pointer;
1023 cfglen, fntlen: Integer;
1024 config: TConfig;
1025 chrwidth: Integer;
1026 a: Byte;
1027 begin
1028 cfglen := 0;
1029 fntlen := 0;
1031 wad := TWADFile.Create;
1032 if wad.ReadFile(GameWAD) then
1033 begin
1034 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1035 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1036 end;
1037 wad.Free();
1039 if cfglen <> 0 then
1040 begin
1041 config := TConfig.CreateMem(cfgdata, cfglen);
1042 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1043 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1045 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1046 FontID := e_CharFont_Create(spc);
1048 for a := 0 to 255 do
1049 begin
1050 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1051 if chrwidth = 0 then Continue;
1053 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1054 cwdt, chgt) then
1055 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1056 end;
1058 config.Free();
1059 end;
1061 if cfglen <> 0 then FreeMem(cfgdata);
1062 if fntlen <> 0 then FreeMem(fntdata);
1063 end;
1065 procedure MenuLoadData();
1066 begin
1067 e_WriteLog('Loading menu data...', TMsgType.Notify);
1069 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1070 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1071 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1072 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1073 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1074 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1075 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1076 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1077 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1078 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1079 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1080 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1081 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1082 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1083 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1084 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1085 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1086 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1087 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1088 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1089 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1090 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1091 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1092 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1094 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1095 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1096 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1097 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1098 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1099 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1100 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1101 end;
1103 procedure MenuFreeData();
1104 begin
1105 e_CharFont_Remove(gMenuFont);
1106 e_CharFont_Remove(gMenuSmallFont);
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 ProcSingle1Player();
1250 begin
1251 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1252 end;
1254 procedure ProcSingle2Players();
1255 begin
1256 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1257 end;
1259 procedure ProcSelectMapMenu();
1260 var
1261 menu: TGUIMenu;
1262 wad_lb: TGUIFileListBox;
1263 map_lb: TGUIListBox;
1264 map: String;
1265 begin
1266 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1267 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1268 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1270 if wad_lb.SelectedItem() <> '' then
1271 map := map_lb.SelectedItem()
1272 else
1273 map := '';
1275 wad_lb.UpdateFileList();
1276 map_lb.Clear();
1278 if wad_lb.SelectedItem() <> '' then
1279 begin
1280 ProcSelectWAD(nil);
1281 map_lb.SelectItem(map);
1283 if map_lb.SelectedItem() <> '' then
1284 ProcSelectMap(nil);
1285 end;
1287 g_GUI_ShowWindow('SelectMapMenu');
1288 end;
1290 procedure ProcSelectCampaignMenu();
1291 var
1292 menu: TGUIMenu;
1293 wad_lb: TGUIFileListBox;
1294 begin
1295 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1296 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1298 wad_lb.UpdateFileList();
1300 if wad_lb.SelectedItem() <> '' then
1301 ProcSelectCampaignWAD(nil);
1302 end;
1304 procedure ProcSetMap();
1305 var
1306 wad, map, res: String;
1307 begin
1308 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1309 begin
1310 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1311 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1312 end;
1314 if (wad = '') or (map = '') then
1315 Exit;
1317 res := wad+':\'+map;
1319 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1320 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1321 end;
1323 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1324 var
1325 menu: TGUIMenu;
1326 begin
1327 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1329 g_Sound_SetupAllVolumes(
1330 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1331 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1332 );
1333 end;
1335 procedure ProcChangeGameSettings(Sender: TGUIControl);
1336 var
1337 menu: TGUIMenu;
1338 begin
1339 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1340 g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
1341 end;
1343 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1344 var
1345 menu: TGUIMenu;
1346 begin
1347 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1348 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1349 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1350 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1351 end;
1353 procedure ProcOptionsPlayersMIMenu();
1354 var
1355 s, a: string;
1356 b: TModelInfo;
1357 begin
1358 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1360 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1362 if a = '' then Exit;
1364 b := g_PlayerModel_GetInfo(a);
1366 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1367 begin
1368 TGUILabel(GetControl('lbName')).Text := b.Name;
1369 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1370 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1372 if b.HaveWeapon then
1373 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1374 else
1375 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1376 end;
1378 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1379 end;
1381 procedure ProcOptionsPlayersAnim();
1382 var
1383 s: String;
1384 begin
1385 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1386 s := 'P1'
1387 else
1388 s := 'P2';
1390 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1391 begin
1392 NextAnim();
1393 Model.GetCurrentAnimation.Loop := True;
1394 Model.GetCurrentAnimationMask.Loop := True;
1395 end;
1396 end;
1398 procedure ProcOptionsPlayersWeap();
1399 var
1400 s: String;
1401 begin
1402 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1403 s := 'P1'
1404 else
1405 s := 'P2';
1407 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1408 NextWeapon();
1409 end;
1411 procedure ProcOptionsPlayersRot();
1412 var
1413 s: string;
1414 begin
1415 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1416 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1417 begin
1418 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1419 end;
1420 end;
1422 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1423 begin
1424 if yes then
1425 begin
1426 g_Options_SetDefault();
1427 ReadOptions();
1428 end;
1429 g_GUI_HideWindow();
1430 end;
1432 procedure ProcSavedMenuKeyDown (yes: Boolean);
1433 begin
1434 if yes then ReadOptions();
1435 g_GUI_HideWindow();
1436 end;
1438 procedure ProcAuthorsClose();
1439 begin
1440 gMusic.SetByName('MUSIC_MENU');
1441 gMusic.Play();
1442 gState := STATE_MENU;
1443 end;
1445 procedure ProcGMClose();
1446 begin
1447 g_Game_InGameMenu(False);
1448 end;
1450 procedure ProcGMShow();
1451 var
1452 Enabled: Boolean;
1453 begin
1454 Enabled := True;
1455 if (gGameSettings.GameType = GT_SINGLE) and
1456 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1457 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1458 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1459 if not gGameOn then
1460 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1461 if g_Game_IsTestMap then
1462 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1463 TGUIMainMenu(g_ActiveWindow.GetControl(
1464 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1465 end;
1467 procedure ProcChangePlayers();
1468 var
1469 TeamGame, Spectator, AddTwo: Boolean;
1470 P1Team{, P2Team}: Byte;
1471 bP2: TGUITextButton;
1472 begin
1473 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1474 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1475 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1476 P1Team := TEAM_NONE;
1477 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1478 // TODO
1479 //P2Team := TEAM_NONE;
1480 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1482 TGUIMainMenu(g_ActiveWindow.GetControl(
1483 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1484 TGUIMainMenu(g_ActiveWindow.GetControl(
1485 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1486 TGUIMainMenu(g_ActiveWindow.GetControl(
1487 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1489 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1490 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1491 bP2.Enabled := AddTwo and not Spectator;
1492 if bP2.Enabled then
1493 bP2.Color := MAINMENU_ITEMS_COLOR
1494 else
1495 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1496 if gPlayer2 = nil then
1497 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1498 else
1499 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1501 TGUIMainMenu(g_ActiveWindow.GetControl(
1502 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1503 end;
1505 procedure ProcJoinRed();
1506 begin
1507 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1508 Exit;
1509 if g_Game_IsServer then
1510 begin
1511 if gPlayer1 = nil then
1512 g_Game_AddPlayer(TEAM_RED)
1513 else
1514 begin
1515 if gPlayer1.Team <> TEAM_RED then
1516 begin
1517 gPlayer1.SwitchTeam;
1518 gPlayer1Settings.Team := gPlayer1.Team;
1519 end;
1521 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1522 end;
1523 end
1524 else
1525 begin
1526 gPlayer1Settings.Team := TEAM_RED;
1527 MC_SEND_PlayerSettings;
1528 if gPlayer1 = nil then
1529 g_Game_AddPlayer(TEAM_RED);
1530 end;
1531 g_ActiveWindow := nil;
1532 g_Game_Pause(False);
1533 end;
1535 procedure ProcJoinBlue();
1536 begin
1537 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1538 Exit;
1539 if g_Game_IsServer then
1540 begin
1541 if gPlayer1 = nil then
1542 g_Game_AddPlayer(TEAM_BLUE)
1543 else
1544 begin
1545 if gPlayer1.Team <> TEAM_BLUE then
1546 begin
1547 gPlayer1.SwitchTeam;
1548 gPlayer1Settings.Team := gPlayer1.Team;
1549 end;
1551 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1552 end;
1553 end
1554 else
1555 begin
1556 gPlayer1Settings.Team := TEAM_BLUE;
1557 MC_SEND_PlayerSettings;
1558 if gPlayer1 = nil then
1559 g_Game_AddPlayer(TEAM_BLUE);
1560 end;
1561 g_ActiveWindow := nil;
1562 g_Game_Pause(False);
1563 end;
1565 procedure ProcJoinGame();
1566 begin
1567 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1568 Exit;
1569 if gPlayer1 = nil then
1570 g_Game_AddPlayer();
1571 g_ActiveWindow := nil;
1572 g_Game_Pause(False);
1573 end;
1575 procedure ProcSwitchP2();
1576 begin
1577 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1578 Exit;
1579 if gPlayer1 = nil then
1580 Exit;
1581 if gPlayer2 = nil then
1582 g_Game_AddPlayer()
1583 else
1584 g_Game_RemovePlayer();
1585 g_ActiveWindow := nil;
1586 g_Game_Pause(False);
1587 end;
1589 procedure ProcSpectate();
1590 begin
1591 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1592 Exit;
1593 g_Game_Spectate();
1594 g_ActiveWindow := nil;
1595 g_Game_Pause(False);
1596 end;
1598 procedure ProcRestartMenuKeyDown (yes: Boolean);
1599 begin
1600 if yes then g_Game_Restart() else g_GUI_HideWindow;
1601 end;
1603 procedure ProcEndMenuKeyDown (yes: Boolean);
1604 begin
1605 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1606 end;
1608 procedure ProcSetRussianLanguage();
1609 begin
1610 if gLanguage <> LANGUAGE_RUSSIAN then
1611 begin
1612 gLanguage := LANGUAGE_RUSSIAN;
1613 gLanguageChange := True;
1614 gAskLanguage := False;
1616 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1618 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1619 ProcApplyOptions();
1620 end;
1621 end;
1623 procedure ProcSetEnglishLanguage();
1624 begin
1625 if gLanguage <> LANGUAGE_ENGLISH then
1626 begin
1627 gLanguage := LANGUAGE_ENGLISH;
1628 gLanguageChange := True;
1629 gAskLanguage := False;
1631 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1633 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1634 ProcApplyOptions();
1635 end;
1636 end;
1638 procedure ReadGameSettings();
1639 var
1640 menu: TGUIMenu;
1641 begin
1642 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1644 with gGameSettings do
1645 begin
1646 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1647 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1648 ItemIndex := 0
1649 else
1650 ItemIndex := 1;
1652 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1653 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1654 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1656 with TGUISwitch(menu.GetControl('swBotsVS')) do
1657 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1658 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1659 ItemIndex := 2
1660 else
1661 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1662 ItemIndex := 1
1663 else
1664 ItemIndex := 0;
1666 if GameType in [GT_CUSTOM, GT_SERVER] then
1667 begin
1668 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1669 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1670 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1671 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1672 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1673 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1674 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1675 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1676 end
1677 else
1678 begin
1679 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1680 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1681 begin
1682 Enabled := False;
1683 Text := '';
1684 end;
1685 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1686 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1687 begin
1688 Enabled := False;
1689 Text := '';
1690 end;
1691 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1692 with TGUIEdit(menu.GetControl('edMaxLives')) do
1693 begin
1694 Enabled := False;
1695 Text := '';
1696 end;
1697 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1698 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1699 end;
1700 end;
1701 end;
1703 procedure ProcApplyGameSet();
1704 var
1705 menu: TGUIMenu;
1706 a, b, n: Integer;
1707 stat: TPlayerStatArray;
1708 begin
1709 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1711 if not g_Game_IsServer then Exit;
1713 with gGameSettings do
1714 begin
1715 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1716 begin
1717 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1718 Options := Options or GAME_OPTION_TEAMDAMAGE
1719 else
1720 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1721 end;
1723 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1724 begin
1725 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1727 if n = 0 then
1728 TimeLimit := 0
1729 else
1730 begin
1731 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1733 TimeLimit := Max(n, b);
1734 end;
1735 end;
1737 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1738 begin
1739 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1741 if n = 0 then
1742 GoalLimit := 0
1743 else
1744 begin
1745 b := 0;
1746 if GameMode = GM_DM then
1747 begin // DM
1748 stat := g_Player_GetStats();
1749 if stat <> nil then
1750 for a := 0 to High(stat) do
1751 if stat[a].Frags > b then
1752 b := stat[a].Frags;
1753 end
1754 else // CTF
1755 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1757 GoalLimit := Max(n, b);
1758 end;
1759 end;
1761 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1762 begin
1763 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1764 if n < 0 then n := 0;
1765 if n > 255 then n := 255;
1766 if n = 0 then
1767 MaxLives := 0
1768 else
1769 begin
1770 b := 0;
1771 stat := g_Player_GetStats();
1772 if stat <> nil then
1773 for a := 0 to High(stat) do
1774 if stat[a].Lives > b then
1775 b := stat[a].Lives;
1777 MaxLives := Max(n, b);
1778 end;
1779 end;
1781 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1782 begin
1783 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1784 1:
1785 begin
1786 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1787 Options := Options or GAME_OPTION_BOTVSMONSTER;
1788 end;
1789 2:
1790 begin
1791 Options := Options or GAME_OPTION_BOTVSPLAYER;
1792 Options := Options or GAME_OPTION_BOTVSMONSTER;
1793 end;
1794 else
1795 begin
1796 Options := Options or GAME_OPTION_BOTVSPLAYER;
1797 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1798 end;
1799 end;
1800 end;
1801 end;
1803 if g_Game_IsNet then MH_SEND_GameSettings;
1804 end;
1806 procedure ProcVideoOptionsRes();
1807 var
1808 menu: TGUIMenu;
1809 list: SSArray;
1810 SR: DWORD;
1811 begin
1812 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1814 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1815 IntToStr(gScreenWidth) +
1816 ' x ' + IntToStr(gScreenHeight) +
1817 ', ' + IntToStr(gBPP) + ' bpp';
1819 with TGUIListBox(menu.GetControl('lsResolution')) do
1820 begin
1821 list := GetDisplayModes(gBPP, SR);
1823 if list <> nil then
1824 begin
1825 Items := list;
1826 ItemIndex := SR;
1827 end
1828 else
1829 Clear();
1830 end;
1832 with TGUISwitch(menu.GetControl('swFullScreen')) do
1833 if gFullscreen then
1834 ItemIndex := 0
1835 else
1836 ItemIndex := 1;
1837 end;
1839 procedure ProcApplyVideoOptions();
1840 var
1841 menu: TGUIMenu;
1842 Fullscreen: Boolean;
1843 SWidth, SHeight: Integer;
1844 str: String;
1845 begin
1846 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1848 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1849 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1851 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1853 if (SWidth <> gScreenWidth) or
1854 (SHeight <> gScreenHeight) or
1855 (Fullscreen <> gFullscreen) then
1856 begin
1857 gResolutionChange := True;
1858 gRC_Width := SWidth;
1859 gRC_Height := SHeight;
1860 gRC_FullScreen := Fullscreen;
1861 gRC_Maximized := gWinMaximized;
1862 end;
1864 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1865 ProcApplyOptions();
1866 end;
1868 procedure ProcSetFirstRussianLanguage();
1869 begin
1870 gLanguage := LANGUAGE_RUSSIAN;
1871 gLanguageChange := True;
1872 gAskLanguage := False;
1874 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1875 end;
1877 procedure ProcSetFirstEnglishLanguage();
1878 begin
1879 gLanguage := LANGUAGE_ENGLISH;
1880 gLanguageChange := True;
1881 gAskLanguage := False;
1883 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1884 end;
1886 procedure ProcRecallAddress();
1887 begin
1888 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1889 begin
1890 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1891 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1892 end;
1893 end;
1895 procedure CreateFirstLanguageMenu();
1896 var
1897 Menu: TGUIWindow;
1898 begin
1899 Menu := TGUIWindow.Create('FirstLanguageMenu');
1901 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1902 begin
1903 Name := 'mmFirstLanguageMenu';
1904 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1905 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1906 end;
1908 Menu.DefControl := 'mmFirstLanguageMenu';
1909 Menu.MainWindow := True;
1910 g_GUI_AddWindow(Menu);
1911 end;
1913 procedure g_Menu_AskLanguage();
1914 begin
1915 CreateFirstLanguageMenu();
1916 g_GUI_ShowWindow('FirstLanguageMenu');
1917 end;
1919 procedure CreatePlayerOptionsMenu(s: String);
1920 var
1921 Menu: TGUIWindow;
1922 a: String;
1923 begin
1924 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1925 if s = 'P1' then
1926 a := _lc[I_MENU_PLAYER_1]
1927 else
1928 a := _lc[I_MENU_PLAYER_2];
1929 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1930 begin
1931 Name := 'mOptionsPlayers'+s+'Menu';
1932 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1933 begin
1934 Name := 'ed'+s+'Name';
1935 MaxLength := 12;
1936 Width := 12;
1937 end;
1938 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1939 begin
1940 Name := 'sw'+s+'Team';
1941 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1942 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1943 end ;
1944 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1945 begin
1946 Name := 'ls'+s+'Model';
1947 Sort := True;
1948 Items := g_PlayerModel_GetNames();
1949 OnChange := ProcSelectModel;
1950 end;
1951 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1952 begin
1953 Name := 'sc'+s+'Red';
1954 Max := 16;
1955 OnChange := ProcChangeColor;
1956 end;
1957 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1958 begin
1959 Name := 'sc'+s+'Green';
1960 Max := 16;
1961 OnChange := ProcChangeColor;
1962 end;
1963 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1964 begin
1965 Name := 'sc'+s+'Blue';
1966 Max := 16;
1967 OnChange := ProcChangeColor;
1968 end;
1969 AddSpace();
1970 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1971 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1972 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1973 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1975 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1976 begin
1977 Name := 'mv'+s+'Model';
1978 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1979 Y := GetControl('ls'+s+'Model').Y;
1980 end;
1981 end;
1982 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1983 g_GUI_AddWindow(Menu);
1984 end;
1986 procedure CreateAllMenus();
1987 var
1988 Menu: TGUIWindow;
1989 //SR: TSearchRec;
1990 a, cx, _y, i: Integer;
1991 //list: SSArray;
1992 begin
1993 Menu := TGUIWindow.Create('MainMenu');
1994 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1995 begin
1996 Name := 'mmMainMenu';
1997 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1998 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1999 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2000 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2001 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2002 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2003 end;
2004 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2005 begin
2006 Color := _RGB(255, 255, 255);
2007 X := gScreenWidth-GetWidth-8;
2008 Y := gScreenHeight-GetHeight-8;
2009 end;
2010 Menu.DefControl := 'mmMainMenu';
2011 Menu.MainWindow := True;
2012 g_GUI_AddWindow(Menu);
2014 Menu := TGUIWindow.Create('NewGameMenu');
2015 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
2016 begin
2017 Name := 'mmNewGameMenu';
2018 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2019 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2020 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2021 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2022 end;
2023 Menu.DefControl := 'mmNewGameMenu';
2024 g_GUI_AddWindow(Menu);
2026 Menu := TGUIWindow.Create('NetGameMenu');
2027 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
2028 begin
2029 Name := 'mmNetGameMenu';
2030 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2031 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2032 end;
2033 Menu.DefControl := 'mmNetGameMenu';
2034 g_GUI_AddWindow(Menu);
2036 Menu := TGUIWindow.Create('NetServerMenu');
2037 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2038 begin
2039 Name := 'mNetServerMenu';
2040 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2041 begin
2042 Name := 'edSrvName';
2043 OnlyDigits := False;
2044 Width := 16;
2045 MaxLength := 64;
2046 Text := NetServerName;
2047 end;
2048 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2049 begin
2050 Name := 'edSrvPassword';
2051 OnlyDigits := False;
2052 Width := 16;
2053 MaxLength := 24;
2054 Text := NetPassword;
2055 end;
2056 with AddEdit(_lc[I_NET_PORT]) do
2057 begin
2058 Name := 'edPort';
2059 OnlyDigits := True;
2060 Width := 4;
2061 MaxLength := 5;
2062 Text := IntToStr(NetPort);
2063 end;
2064 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2065 begin
2066 Name := 'edMaxPlayers';
2067 OnlyDigits := True;
2068 Width := 4;
2069 MaxLength := 2;
2070 Text := IntToStr(NetMaxClients);
2071 end;
2072 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2073 begin
2074 Name := 'swUseMaster';
2075 AddItem(_lc[I_MENU_YES]);
2076 AddItem(_lc[I_MENU_NO]);
2077 if NetUseMaster then
2078 ItemIndex := 0
2079 else
2080 ItemIndex := 1;
2081 end;
2082 AddSpace();
2083 with AddLabel(_lc[I_MENU_MAP]) do
2084 begin
2085 Name := 'lbMap';
2086 FixedLength := 16;
2087 Text := gnMap;
2088 OnClick := @ProcSelectMapMenu;
2089 end;
2090 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2091 begin
2092 Name := 'swGameMode';
2093 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2094 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2095 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2096 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2097 case g_Game_TextToMode(gnGameMode) of
2098 GM_NONE,
2099 GM_DM: ItemIndex := 0;
2100 GM_TDM: ItemIndex := 1;
2101 GM_CTF: ItemIndex := 2;
2102 GM_SINGLE,
2103 GM_COOP: ItemIndex := 3;
2104 end;
2105 OnChange := ProcSwitchMonstersNet;
2106 end;
2107 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2108 begin
2109 Name := 'edTimeLimit';
2110 OnlyDigits := True;
2111 Width := 4;
2112 MaxLength := 5;
2113 if gnTimeLimit > 0 then
2114 Text := IntToStr(gnTimeLimit);
2115 end;
2116 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2117 begin
2118 Name := 'edGoalLimit';
2119 OnlyDigits := True;
2120 Width := 4;
2121 MaxLength := 5;
2122 if gnGoalLimit > 0 then
2123 Text := IntToStr(gnGoalLimit);
2124 end;
2125 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2126 begin
2127 Name := 'edMaxLives';
2128 OnlyDigits := True;
2129 Width := 4;
2130 MaxLength := 3;
2131 if gnMaxLives > 0 then
2132 Text := IntToStr(gnMaxLives);
2133 end;
2134 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2135 begin
2136 Name := 'swPlayers';
2137 AddItem(_lc[I_MENU_COUNT_NONE]);
2138 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2139 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2140 ItemIndex := gnPlayers;
2141 end;
2142 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2143 begin
2144 Name := 'swTeamDamage';
2145 AddItem(_lc[I_MENU_YES]);
2146 AddItem(_lc[I_MENU_NO]);
2147 if gnTeamDamage then
2148 ItemIndex := 0
2149 else
2150 ItemIndex := 1;
2151 end;
2152 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2153 begin
2154 Name := 'swEnableExits';
2155 AddItem(_lc[I_MENU_YES]);
2156 AddItem(_lc[I_MENU_NO]);
2157 if gnAllowExit then
2158 ItemIndex := 0
2159 else
2160 ItemIndex := 1;
2161 end;
2162 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2163 begin
2164 Name := 'swWeaponStay';
2165 AddItem(_lc[I_MENU_YES]);
2166 AddItem(_lc[I_MENU_NO]);
2167 if gnWeaponStay then
2168 ItemIndex := 0
2169 else
2170 ItemIndex := 1;
2171 end;
2172 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2173 begin
2174 Name := 'swMonsters';
2175 AddItem(_lc[I_MENU_YES]);
2176 AddItem(_lc[I_MENU_NO]);
2177 if gnMonsters then
2178 ItemIndex := 0
2179 else
2180 ItemIndex := 1;
2181 end;
2182 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2183 begin
2184 Name := 'swBotsVS';
2185 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2186 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2187 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2188 ItemIndex := 2;
2189 if gnBotsVS = 'Players' then
2190 ItemIndex := 0;
2191 if gnBotsVS = 'Monsters' then
2192 ItemIndex := 1;
2193 end;
2194 AddSpace();
2195 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2197 ReAlign();
2198 end;
2199 Menu.DefControl := 'mNetServerMenu';
2200 g_GUI_AddWindow(Menu);
2202 Menu := TGUIWindow.Create('NetClientMenu');
2203 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2204 begin
2205 Name := 'mNetClientMenu';
2207 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2208 AddSpace();
2210 with AddEdit(_lc[I_NET_ADDRESS]) do
2211 begin
2212 Name := 'edIP';
2213 OnlyDigits :=False;
2214 Width := 12;
2215 MaxLength := 64;
2216 Text := 'localhost';
2217 end;
2218 with AddEdit(_lc[I_NET_PORT]) do
2219 begin
2220 Name := 'edPort';
2221 OnlyDigits := True;
2222 Width := 4;
2223 MaxLength := 5;
2224 Text := '25666';
2225 end;
2226 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2227 begin
2228 Name := 'edPW';
2229 OnlyDigits := False;
2230 Width := 12;
2231 MaxLength := 32;
2232 Text := '';
2233 end;
2235 AddSpace();
2236 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2238 ReAlign();
2239 end;
2240 Menu.DefControl := 'mNetClientMenu';
2241 g_GUI_AddWindow(Menu);
2243 Menu := TGUIWindow.Create('LoadMenu');
2244 Menu.OnShow := ProcLoadMenu;
2245 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2246 begin
2247 Name := 'mmLoadMenu';
2249 for a := 1 to 8 do
2250 with AddEdit('') do
2251 begin
2252 Name := 'edSlot'+IntToStr(a);
2253 Width := 16;
2254 MaxLength := 16;
2255 OnEnter := ProcLoadGame;
2256 end;
2257 end;
2258 Menu.DefControl := 'mmLoadMenu';
2259 g_GUI_AddWindow(Menu);
2261 Menu := TGUIWindow.Create('SaveMenu');
2262 Menu.OnShow := ProcSaveMenu;
2263 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2264 begin
2265 Name := 'mmSaveMenu';
2267 for a := 1 to 8 do
2268 with AddEdit('') do
2269 begin
2270 Name := 'edSlot'+IntToStr(a);
2271 Width := 16;
2272 MaxLength := 16;
2273 OnChange := ProcSaveGame;
2274 end;
2275 end;
2276 Menu.DefControl := 'mmSaveMenu';
2277 g_GUI_AddWindow(Menu);
2279 Menu := TGUIWindow.Create('CustomGameMenu');
2280 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2281 begin
2282 Name := 'mCustomGameMenu';
2283 with AddLabel(_lc[I_MENU_MAP]) do
2284 begin
2285 Name := 'lbMap';
2286 FixedLength := 16;
2287 Text := gcMap;
2288 OnClick := @ProcSelectMapMenu;
2289 end;
2290 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2291 begin
2292 Name := 'swGameMode';
2293 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2294 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2295 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2296 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2297 case g_Game_TextToMode(gcGameMode) of
2298 GM_NONE,
2299 GM_DM: ItemIndex := 0;
2300 GM_TDM: ItemIndex := 1;
2301 GM_CTF: ItemIndex := 2;
2302 GM_SINGLE,
2303 GM_COOP: ItemIndex := 3;
2304 end;
2305 OnChange := ProcSwitchMonstersCustom;
2306 end;
2307 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2308 begin
2309 Name := 'edTimeLimit';
2310 OnlyDigits := True;
2311 Width := 4;
2312 MaxLength := 5;
2313 if gcTimeLimit > 0 then
2314 Text := IntToStr(gcTimeLimit);
2315 end;
2316 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2317 begin
2318 Name := 'edGoalLimit';
2319 OnlyDigits := True;
2320 Width := 4;
2321 MaxLength := 5;
2322 if gcGoalLimit > 0 then
2323 Text := IntToStr(gcGoalLimit);
2324 end;
2325 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2326 begin
2327 Name := 'edMaxLives';
2328 OnlyDigits := True;
2329 Width := 4;
2330 MaxLength := 5;
2331 if gcMaxLives > 0 then
2332 Text := IntToStr(gcMaxLives);
2333 end;
2334 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2335 begin
2336 Name := 'swPlayers';
2337 AddItem(_lc[I_MENU_COUNT_NONE]);
2338 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2339 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2340 ItemIndex := gcPlayers;
2341 end;
2342 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2343 begin
2344 Name := 'swTeamDamage';
2345 AddItem(_lc[I_MENU_YES]);
2346 AddItem(_lc[I_MENU_NO]);
2347 if gcTeamDamage then
2348 ItemIndex := 0
2349 else
2350 ItemIndex := 1;
2351 end;
2352 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2353 begin
2354 Name := 'swEnableExits';
2355 AddItem(_lc[I_MENU_YES]);
2356 AddItem(_lc[I_MENU_NO]);
2357 if gcAllowExit then
2358 ItemIndex := 0
2359 else
2360 ItemIndex := 1;
2361 end;
2362 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2363 begin
2364 Name := 'swWeaponStay';
2365 AddItem(_lc[I_MENU_YES]);
2366 AddItem(_lc[I_MENU_NO]);
2367 if gcWeaponStay then
2368 ItemIndex := 0
2369 else
2370 ItemIndex := 1;
2371 end;
2372 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2373 begin
2374 Name := 'swMonsters';
2375 AddItem(_lc[I_MENU_YES]);
2376 AddItem(_lc[I_MENU_NO]);
2377 if gcMonsters then
2378 ItemIndex := 0
2379 else
2380 ItemIndex := 1;
2381 end;
2382 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2383 begin
2384 Name := 'swBotsVS';
2385 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2386 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2387 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2388 ItemIndex := 2;
2389 if gcBotsVS = 'Players' then
2390 ItemIndex := 0;
2391 if gcBotsVS = 'Monsters' then
2392 ItemIndex := 1;
2393 end;
2394 AddSpace();
2395 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2397 ReAlign();
2398 end;
2399 Menu.DefControl := 'mCustomGameMenu';
2400 g_GUI_AddWindow(Menu);
2402 Menu := TGUIWindow.Create('CampaignMenu');
2403 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2404 begin
2405 Name := 'mCampaignMenu';
2407 AddSpace();
2408 AddSpace();
2409 AddSpace();
2410 AddSpace();
2411 AddSpace();
2412 AddSpace();
2414 with AddFileList('', 15, 4) do
2415 begin
2416 Name := 'lsWAD';
2417 OnChange := ProcSelectCampaignWAD;
2419 Sort := True;
2420 Dirs := True;
2421 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2422 SetBase(MapsDir+'megawads/');
2423 end;
2425 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2426 begin
2427 Name := 'lbWADName';
2428 FixedLength := 8;
2429 Enabled := False;
2430 end;
2431 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2432 begin
2433 Name := 'lbWADAuthor';
2434 FixedLength := 8;
2435 Enabled := False;
2436 end;
2437 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2438 with AddMemo('', 15, 3) do
2439 begin
2440 Name := 'meWADDescription';
2441 Color := MENU_ITEMSCTRL_COLOR;
2442 end;
2443 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2444 begin
2445 Name := 'swPlayers';
2446 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2447 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2448 end;
2449 AddSpace();
2450 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2452 ReAlign();
2454 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2455 begin
2456 Name := 'mpWADImage';
2457 DefaultRes := 'NOPIC';
2458 X := GetControl('lsWAD').X+4;
2459 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2460 end;
2461 end;
2462 Menu.DefControl := 'mCampaignMenu';
2463 g_GUI_AddWindow(Menu);
2465 Menu := TGUIWindow.Create('SelectMapMenu');
2466 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2467 begin
2468 Name := 'mSelectMapMenu';
2469 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2470 begin
2471 Name := 'lsMapWAD';
2472 OnChange := ProcSelectWAD;
2474 Sort := True;
2475 Dirs := True;
2476 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2477 SetBase(MapsDir);
2478 end;
2479 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2480 begin
2481 Name := 'lsMapRes';
2482 Sort := True;
2483 OnChange := ProcSelectMap;
2484 end;
2485 AddSpace();
2486 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2487 begin
2488 Name := 'lbMapName';
2489 FixedLength := 24;
2490 Enabled := False;
2491 end;
2492 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2493 begin
2494 Name := 'lbMapAuthor';
2495 FixedLength := 16;
2496 Enabled := False;
2497 end;
2498 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2499 begin
2500 Name := 'lbMapSize';
2501 FixedLength := 10;
2502 Enabled := False;
2503 end;
2504 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2505 begin
2506 Name := 'meMapDescription';
2507 end;
2509 ReAlign();
2511 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2512 begin
2513 Name := 'mpMapPreview';
2514 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2515 Y := GetControl('lsMapWAD').Y;
2516 end;
2517 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2518 begin
2519 Name := 'lbMapScale';
2520 FixedLength := 8;
2521 Enabled := False;
2522 Color := MENU_ITEMSCTRL_COLOR;
2523 X := GetControl('lsMapWAD').X +
2524 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2525 2 + MAPPREVIEW_WIDTH*4;
2526 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2527 end;
2528 end;
2529 Menu.OnClose := ProcSetMap;
2530 Menu.DefControl := 'mSelectMapMenu';
2531 g_GUI_AddWindow(Menu);
2533 Menu := TGUIWindow.Create('OptionsMenu');
2534 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2535 begin
2536 Name := 'mmOptionsMenu';
2537 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2538 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2539 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2540 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2541 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2542 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2543 AddSpace();
2544 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2545 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2546 end;
2547 Menu.OnClose := ProcApplyOptions;
2548 Menu.DefControl := 'mmOptionsMenu';
2549 g_GUI_AddWindow(Menu);
2551 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2552 gMenuSmallFont, @ProcSavedMenuKeyDown);
2553 g_GUI_AddWindow(Menu);
2555 Menu := TGUIWindow.Create('OptionsVideoMenu');
2556 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2557 begin
2558 Name := 'mOptionsVideoMenu';
2559 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2560 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2561 begin
2562 Name := 'swBPP';
2563 AddItem('16');
2564 AddItem('32');
2565 end;
2566 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2567 begin
2568 Name := 'swVSync';
2569 AddItem(_lc[I_MENU_YES]);
2570 AddItem(_lc[I_MENU_NO]);
2571 end;
2572 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2573 begin
2574 Name := 'swTextureFilter';
2575 AddItem(_lc[I_MENU_YES]);
2576 AddItem(_lc[I_MENU_NO]);
2577 end;
2578 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2579 begin
2580 Name := 'swLegacyNPOT';
2581 AddItem(_lc[I_MENU_NO]);
2582 AddItem(_lc[I_MENU_YES]);
2583 end;
2584 AddSpace();
2585 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2586 ReAlign();
2587 end;
2588 Menu.DefControl := 'mOptionsVideoMenu';
2589 g_GUI_AddWindow(Menu);
2591 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2592 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2593 begin
2594 Name := 'mOptionsVideoResMenu';
2595 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2596 begin
2597 Name := 'lbCurrentRes';
2598 FixedLength := 24;
2599 Enabled := False;
2600 end;
2601 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2602 begin
2603 Name := 'lsResolution';
2604 Sort := False;
2605 end;
2606 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2607 begin
2608 Name := 'swFullScreen';
2609 AddItem(_lc[I_MENU_YES]);
2610 AddItem(_lc[I_MENU_NO]);
2611 end;
2612 AddSpace();
2613 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2614 UpdateIndex();
2615 end;
2616 Menu.DefControl := 'mOptionsVideoResMenu';
2617 g_GUI_AddWindow(Menu);
2619 Menu := TGUIWindow.Create('OptionsSoundMenu');
2620 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2621 begin
2622 Name := 'mOptionsSoundMenu';
2623 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2624 begin
2625 Name := 'scMusicLevel';
2626 Max := 16;
2627 OnChange := ProcChangeSoundSettings;
2628 end;
2629 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2630 begin
2631 Name := 'scSoundLevel';
2632 Max := 16;
2633 OnChange := ProcChangeSoundSettings;
2634 end;
2635 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2636 begin
2637 Name := 'scMaxSimSounds';
2638 Max := 16;
2639 end;
2640 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2641 begin;
2642 Name := 'swAnnouncer';
2643 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2644 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2645 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2646 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2647 end;
2648 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2649 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2650 begin;
2651 Name := 'swSoundEffects';
2652 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2653 AddItem(_lc[I_MENU_COMPAT_DF]);
2654 end;
2655 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2656 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2657 begin;
2658 Name := 'swChatSpeech';
2659 AddItem(_lc[I_MENU_YES]);
2660 AddItem(_lc[I_MENU_NO]);
2661 end;
2662 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2663 begin
2664 Name := 'swInactiveSounds';
2665 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2666 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2667 end;
2668 ReAlign();
2669 end;
2670 Menu.DefControl := 'mOptionsSoundMenu';
2671 g_GUI_AddWindow(Menu);
2673 Menu := TGUIWindow.Create('OptionsGameMenu');
2674 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2675 begin
2676 Name := 'mOptionsGameMenu';
2677 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2678 begin
2679 Name := 'scParticlesCount';
2680 Max := 20;
2681 end;
2682 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2683 begin
2684 Name := 'swBloodCount';
2685 AddItem(_lc[I_MENU_COUNT_NONE]);
2686 AddItem(_lc[I_MENU_COUNT_SMALL]);
2687 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2688 AddItem(_lc[I_MENU_COUNT_BIG]);
2689 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2690 end;
2691 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2692 begin
2693 Name := 'scShellsMax';
2694 Max := 20;
2695 end;
2696 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2697 begin
2698 Name := 'scGibsMax';
2699 Max := 20;
2700 end;
2701 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2702 begin
2703 Name := 'scCorpsesMax';
2704 Max := 20;
2705 end;
2706 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2707 begin
2708 Name := 'swGibsCount';
2709 AddItem(_lc[I_MENU_COUNT_NONE]);
2710 AddItem(_lc[I_MENU_COUNT_SMALL]);
2711 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2712 AddItem(_lc[I_MENU_COUNT_BIG]);
2713 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2714 end;
2715 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2716 begin
2717 Name := 'swCorpseType';
2718 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2719 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2720 end;
2721 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2722 begin
2723 Name := 'swGibsType';
2724 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2725 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2726 end;
2727 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2728 begin
2729 Name := 'swBloodType';
2730 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2731 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2732 end;
2733 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2734 begin
2735 Name := 'swScreenFlash';
2736 AddItem(_lc[I_MENU_NO]);
2737 AddItem(_lc[I_MENU_COMPAT_DF]);
2738 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2739 end;
2740 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2741 begin
2742 Name := 'swBackground';
2743 AddItem(_lc[I_MENU_YES]);
2744 AddItem(_lc[I_MENU_NO]);
2745 end;
2746 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2747 begin
2748 Name := 'swMessages';
2749 AddItem(_lc[I_MENU_YES]);
2750 AddItem(_lc[I_MENU_NO]);
2751 end;
2752 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2753 begin
2754 Name := 'swRevertPlayers';
2755 AddItem(_lc[I_MENU_YES]);
2756 AddItem(_lc[I_MENU_NO]);
2757 end;
2758 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2759 begin
2760 Name := 'swChatBubble';
2761 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2762 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2763 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2764 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2765 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2766 end;
2767 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2768 begin
2769 Name := 'swPlayerIndicator';
2770 AddItem(_lc[I_MENU_YES]);
2771 AddItem(_lc[I_MENU_NO]);
2772 end;
2773 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2774 begin
2775 Name := 'scScaleFactor';
2776 Max := 10;
2777 OnChange := ProcChangeGameSettings;
2778 end;
2779 ReAlign();
2780 end;
2781 Menu.DefControl := 'mOptionsGameMenu';
2782 g_GUI_AddWindow(Menu);
2784 Menu := TGUIWindow.Create('OptionsControlsMenu');
2785 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2786 begin
2787 Name := 'mOptionsControlsMenu';
2788 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2789 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2790 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2791 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2792 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2793 AddSpace();
2794 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2795 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2796 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2797 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2798 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2799 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2800 if e_JoysticksAvailable <> 0 then
2801 begin
2802 AddSpace();
2803 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2804 end;
2805 if g_touch_enabled then
2806 begin
2807 AddSpace();
2808 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2809 end;
2810 end;
2811 Menu.DefControl := 'mOptionsControlsMenu';
2812 g_GUI_AddWindow(Menu);
2814 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2815 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2816 begin
2817 Name := 'mOptionsControlsP1Menu';
2818 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2819 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2820 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2821 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2822 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2823 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2824 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2825 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2826 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2827 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2828 end;
2829 Menu.DefControl := 'mOptionsControlsP1Menu';
2830 g_GUI_AddWindow(Menu);
2832 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2833 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2834 begin
2835 Name := 'mOptionsControlsP1MenuWeapons';
2836 for i := WP_FIRST to WP_LAST do
2837 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2838 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2839 end;
2840 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2841 g_GUI_AddWindow(Menu);
2843 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2844 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2845 begin
2846 Name := 'mOptionsControlsP2Menu';
2847 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2848 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2849 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2850 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2851 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2852 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2853 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2854 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2855 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2856 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2857 end;
2858 Menu.DefControl := 'mOptionsControlsP2Menu';
2859 g_GUI_AddWindow(Menu);
2861 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2862 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2863 begin
2864 Name := 'mOptionsControlsP2MenuWeapons';
2865 for i := WP_FIRST to WP_LAST do
2866 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2867 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2868 end;
2869 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2870 g_GUI_AddWindow(Menu);
2872 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2873 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2874 begin
2875 Name := 'mOptionsControlsJoystickMenu';
2876 for i := 0 to e_JoysticksAvailable-1 do
2877 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2878 begin
2879 Name := 'scDeadzone' + IntToStr(i);
2880 Max := 20;
2881 end;
2882 end;
2883 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2884 g_GUI_AddWindow(Menu);
2886 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2887 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2888 begin
2889 Name := 'mOptionsControlsTouchMenu';
2890 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2891 begin
2892 Name := 'swTouchAlt';
2893 AddItem(_lc[I_MENU_NO]);
2894 AddItem(_lc[I_MENU_YES]);
2895 OnChange := ProcChangeTouchSettings;
2896 end;
2897 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2898 begin
2899 Name := 'scTouchSize';
2900 Max := 20;
2901 OnChange := ProcChangeTouchSettings;
2902 end;
2903 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2904 begin
2905 Name := 'swTouchFire';
2906 AddItem(_lc[I_MENU_NO]);
2907 AddItem(_lc[I_MENU_YES]);
2908 end;
2909 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2910 begin
2911 Name := 'scTouchOffset';
2912 Max := 20;
2913 OnChange := ProcChangeTouchSettings;
2914 end;
2915 end;
2916 Menu.DefControl := 'mOptionsControlsTouchMenu';
2917 g_GUI_AddWindow(Menu);
2919 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2920 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2921 begin
2922 Name := 'mOptionsPlayersMenu';
2923 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2924 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2925 end;
2926 Menu.DefControl := 'mOptionsPlayersMenu';
2927 g_GUI_AddWindow(Menu);
2929 CreatePlayerOptionsMenu('P1');
2930 CreatePlayerOptionsMenu('P2');
2932 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2933 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2934 begin
2935 Name := 'mOptionsPlayersMIMenu';
2936 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2937 begin
2938 Name := 'lbName';
2939 FixedLength := 16;
2940 end;
2941 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2942 begin
2943 Name := 'lbAuthor';
2944 FixedLength := 16;
2945 end;
2946 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2947 begin
2948 Name := 'meComment';
2949 end;
2950 AddSpace();
2951 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2952 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2953 begin
2954 Name := 'lbWeapon';
2955 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2956 end;
2957 ReAlign();
2958 end;
2959 Menu.DefControl := 'mOptionsPlayersMIMenu';
2960 g_GUI_AddWindow(Menu);
2962 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2963 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2964 begin
2965 Name := 'mOptionsLanguageMenu';
2966 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2967 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2968 ReAlign();
2969 end;
2970 Menu.DefControl := 'mOptionsLanguageMenu';
2971 g_GUI_AddWindow(Menu);
2973 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2974 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2975 g_GUI_AddWindow(Menu);
2977 Menu := TGUIWindow.Create('AuthorsMenu');
2978 Menu.BackTexture := 'INTER';
2979 Menu.OnClose := ProcAuthorsClose;
2981 // Çàãîëîâîê:
2982 _y := 16;
2983 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2984 begin
2985 Color := _RGB(255, 0, 0);
2986 X := (gScreenWidth div 2)-(GetWidth() div 2);
2987 Y := _y;
2988 _y := _y+GetHeight();
2989 end;
2990 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2991 begin
2992 Color := _RGB(255, 0, 0);
2993 X := (gScreenWidth div 2)-(GetWidth() div 2);
2994 Y := _y;
2995 _y := _y+GetHeight()+32;
2996 end;
2997 // ×òî äåëàë: Êòî äåëàë
2998 cx := gScreenWidth div 2 - 320 + 64;
2999 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3000 begin
3001 Color := _RGB(255, 0, 0);
3002 X := cx;
3003 Y := _y;
3004 _y := _y+22;
3005 end;
3006 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3007 begin
3008 Color := _RGB(255, 255, 255);
3009 X := cx+32;
3010 Y := _y;
3011 _y := _y+36;
3012 end;
3013 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3014 begin
3015 Color := _RGB(255, 0, 0);
3016 X := cx;
3017 Y := _y;
3018 _y := _y+22;
3019 end;
3020 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3021 begin
3022 Color := _RGB(255, 255, 255);
3023 X := cx+32;
3024 Y := _y;
3025 _y := _y+22;
3026 end;
3027 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3028 begin
3029 Color := _RGB(255, 255, 255);
3030 X := cx+32;
3031 Y := _y;
3032 _y := _y+36;
3033 end;
3034 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3035 begin
3036 Color := _RGB(255, 0, 0);
3037 X := cx;
3038 Y := _y;
3039 _y := _y+22;
3040 end;
3041 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3042 begin
3043 Color := _RGB(255, 255, 255);
3044 X := cx+32;
3045 Y := _y;
3046 _y := _y+36;
3047 end;
3048 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3049 begin
3050 Color := _RGB(255, 0, 0);
3051 X := cx;
3052 Y := _y;
3053 _y := _y+22;
3054 end;
3055 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3056 begin
3057 Color := _RGB(255, 255, 255);
3058 X := cx+32;
3059 Y := _y;
3060 _y := gScreenHeight - 128;
3061 end;
3062 // Çàêëþ÷åíèå:
3063 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3064 begin
3065 Color := _RGB(255, 0, 0);
3066 X := cx;
3067 Y := _y;
3068 _y := _y+16;
3069 end;
3070 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3071 begin
3072 Color := _RGB(255, 255, 255);
3073 X := cx+32;
3074 Y := _y;
3075 _y := _y+GetHeight();
3076 end;
3077 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3078 begin
3079 Color := _RGB(255, 255, 255);
3080 X := cx+32;
3081 Y := _y;
3082 _y := _y+GetHeight();
3083 end;
3084 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3085 begin
3086 Color := _RGB(255, 255, 255);
3087 X := cx+32;
3088 Y := _y;
3089 _y := gScreenHeight - 32;
3090 end;
3091 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3092 begin
3093 Color := _RGB(255, 0, 0);
3094 X := gScreenWidth div 2 - GetWidth() div 2;
3095 Y := _y;
3096 end;
3097 g_GUI_AddWindow(Menu);
3099 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3100 gMenuSmallFont, @ProcExitMenuKeyDown);
3101 g_GUI_AddWindow(Menu);
3103 Menu := TGUIWindow.Create('GameSingleMenu');
3104 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3105 begin
3106 Name := 'mmGameSingleMenu';
3107 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3108 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3109 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3110 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3111 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3112 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3113 end;
3114 Menu.DefControl := 'mmGameSingleMenu';
3115 Menu.MainWindow := True;
3116 Menu.OnClose := ProcGMClose;
3117 Menu.OnShow := ProcGMShow;
3118 g_GUI_AddWindow(Menu);
3120 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3121 gMenuSmallFont, @ProcEndMenuKeyDown);
3122 g_GUI_AddWindow(Menu);
3124 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3125 gMenuSmallFont, @ProcRestartMenuKeyDown);
3126 g_GUI_AddWindow(Menu);
3128 Menu := TGUIWindow.Create('GameCustomMenu');
3129 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3130 begin
3131 Name := 'mmGameCustomMenu';
3132 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3133 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3134 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3135 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3136 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3137 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3138 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3139 end;
3140 Menu.DefControl := 'mmGameCustomMenu';
3141 Menu.MainWindow := True;
3142 Menu.OnClose := ProcGMClose;
3143 Menu.OnShow := ProcGMShow;
3144 g_GUI_AddWindow(Menu);
3146 Menu := TGUIWindow.Create('GameServerMenu');
3147 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3148 begin
3149 Name := 'mmGameServerMenu';
3150 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3151 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3152 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3153 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3154 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3155 end;
3156 Menu.DefControl := 'mmGameServerMenu';
3157 Menu.MainWindow := True;
3158 Menu.OnClose := ProcGMClose;
3159 Menu.OnShow := ProcGMShow;
3160 g_GUI_AddWindow(Menu);
3162 Menu := TGUIWindow.Create('GameClientMenu');
3163 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3164 begin
3165 Name := 'mmGameClientMenu';
3166 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3167 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3168 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3169 end;
3170 Menu.DefControl := 'mmGameClientMenu';
3171 Menu.MainWindow := True;
3172 Menu.OnClose := ProcGMClose;
3173 Menu.OnShow := ProcGMShow;
3174 g_GUI_AddWindow(Menu);
3176 Menu := TGUIWindow.Create('ClientPasswordMenu');
3177 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3178 begin
3179 Name := 'mClientPasswordMenu';
3180 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3181 begin
3182 Name := 'edPW';
3183 Width := 12;
3184 MaxLength := 32;
3185 end;
3186 AddSpace;
3188 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3189 ReAlign();
3190 end;
3191 Menu.DefControl := 'mClientPasswordMenu';
3192 g_GUI_AddWindow(Menu);
3194 Menu := TGUIWindow.Create('GameSetGameMenu');
3195 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3196 begin
3197 Name := 'mGameSetGameMenu';
3198 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3199 begin
3200 Name := 'swTeamDamage';
3201 AddItem(_lc[I_MENU_YES]);
3202 AddItem(_lc[I_MENU_NO]);
3203 ItemIndex := 1;
3204 end;
3205 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3206 begin
3207 Name := 'edTimeLimit';
3208 OnlyDigits := True;
3209 Width := 4;
3210 MaxLength := 5;
3211 end;
3212 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3213 begin
3214 Name := 'edGoalLimit';
3215 OnlyDigits := True;
3216 Width := 4;
3217 MaxLength := 5;
3218 end;
3219 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3220 begin
3221 Name := 'edMaxLives';
3222 OnlyDigits := True;
3223 Width := 4;
3224 MaxLength := 5;
3225 end;
3226 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3227 begin
3228 Name := 'swBotsVS';
3229 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3230 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3231 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3232 ItemIndex := 2;
3233 end;
3235 ReAlign();
3236 end;
3237 Menu.DefControl := 'mGameSetGameMenu';
3238 Menu.OnClose := ProcApplyGameSet;
3239 g_GUI_AddWindow(Menu);
3241 Menu := TGUIWindow.Create('TeamMenu');
3242 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3243 begin
3244 Name := 'mmTeamMenu';
3245 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3246 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3247 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3248 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3249 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3250 end;
3251 Menu.DefControl := 'mmTeamMenu';
3252 Menu.OnShow := ProcChangePlayers;
3253 g_GUI_AddWindow(Menu);
3254 end;
3256 procedure g_Menu_Show_SaveMenu();
3257 begin
3258 if g_Game_IsTestMap then
3259 Exit;
3260 if gGameSettings.GameType = GT_SINGLE then
3261 g_GUI_ShowWindow('GameSingleMenu')
3262 else
3263 begin
3264 if g_Game_IsClient then
3265 Exit
3266 else
3267 if g_Game_IsNet then
3268 Exit
3269 else
3270 g_GUI_ShowWindow('GameCustomMenu');
3271 end;
3272 g_GUI_ShowWindow('SaveMenu');
3273 g_Sound_PlayEx('MENU_OPEN');
3274 end;
3276 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3277 begin
3278 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3279 if gGameSettings.GameType = GT_SINGLE then
3280 begin
3281 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3282 end
3283 else
3284 begin
3285 if g_Game_IsClient then exit;
3286 if g_Game_IsNet then exit;
3287 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3288 end;
3289 g_GUI_ShowWindow('LoadMenu');
3290 g_Sound_PlayEx('MENU_OPEN');
3291 end;
3293 procedure g_Menu_Show_GameSetGame();
3294 begin
3295 if gGameSettings.GameType = GT_SINGLE then
3296 g_GUI_ShowWindow('GameSingleMenu')
3297 else
3298 begin
3299 if g_Game_IsClient then
3300 Exit
3301 else
3302 if g_Game_IsNet then
3303 g_GUI_ShowWindow('GameServerMenu')
3304 else
3305 g_GUI_ShowWindow('GameCustomMenu');
3306 end;
3307 ReadGameSettings();
3308 g_GUI_ShowWindow('GameSetGameMenu');
3309 g_Sound_PlayEx('MENU_OPEN');
3310 end;
3312 procedure g_Menu_Show_OptionsVideo();
3313 begin
3314 if gGameSettings.GameType = GT_SINGLE then
3315 g_GUI_ShowWindow('GameSingleMenu')
3316 else
3317 begin
3318 if g_Game_IsClient then
3319 g_GUI_ShowWindow('GameClientMenu')
3320 else
3321 if g_Game_IsNet then
3322 g_GUI_ShowWindow('GameServerMenu')
3323 else
3324 g_GUI_ShowWindow('GameCustomMenu');
3325 end;
3326 ReadOptions();
3327 g_GUI_ShowWindow('OptionsMenu');
3328 g_GUI_ShowWindow('OptionsVideoMenu');
3329 g_Sound_PlayEx('MENU_OPEN');
3330 end;
3332 procedure g_Menu_Show_OptionsSound();
3333 begin
3334 if gGameSettings.GameType = GT_SINGLE then
3335 g_GUI_ShowWindow('GameSingleMenu')
3336 else
3337 begin
3338 if g_Game_IsClient then
3339 g_GUI_ShowWindow('GameClientMenu')
3340 else
3341 if g_Game_IsNet then
3342 g_GUI_ShowWindow('GameServerMenu')
3343 else
3344 g_GUI_ShowWindow('GameCustomMenu');
3345 end;
3346 ReadOptions();
3347 g_GUI_ShowWindow('OptionsMenu');
3348 g_GUI_ShowWindow('OptionsSoundMenu');
3349 g_Sound_PlayEx('MENU_OPEN');
3350 end;
3352 procedure g_Menu_Show_EndGameMenu();
3353 begin
3354 g_GUI_ShowWindow('EndGameMenu');
3355 g_Sound_PlayEx('MENU_OPEN');
3356 end;
3358 procedure g_Menu_Show_QuitGameMenu();
3359 begin
3360 g_GUI_ShowWindow('ExitMenu');
3361 g_Sound_PlayEx('MENU_OPEN');
3362 end;
3364 procedure g_Menu_Init();
3365 begin
3366 MenuLoadData();
3367 g_GUI_Init();
3368 CreateAllMenus();
3369 end;
3371 procedure g_Menu_Free();
3372 begin
3373 g_GUI_Destroy();
3375 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3377 MenuFreeData();
3378 end;
3380 procedure g_Menu_Reset();
3381 var
3382 ex: Boolean;
3383 begin
3384 g_GUI_SaveMenuPos();
3385 ex := g_GUI_Destroy();
3387 if ex then
3388 begin
3389 e_WriteLog('Recreating menu...', TMsgType.Notify);
3391 CreateAllMenus();
3393 if gDebugMode then
3394 g_Game_SetDebugMode();
3396 g_GUI_LoadMenuPos();
3397 end;
3398 end;
3400 end.