Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
ingamemenu.c
Go to the documentation of this file.
1class InGameMenu extends UIScriptedMenu
2{
3 string m_ServerInfoText;
4
5 protected Widget m_ContinueButton;
6 protected Widget m_SeparatorPanel;
7 protected Widget m_ExitButton;
8 protected Widget m_RestartButton;
9 protected Widget m_RespawnButton;
10 protected Widget m_RestartDeadRandomButton;
11 protected Widget m_RestartDeadCustomButton;
12 protected Widget m_OptionsButton;
13 protected Widget m_ServerInfoPanel;
14 protected Widget m_FavoriteButton;
15 protected Widget m_FavoriteImage;
16 protected Widget m_UnfavoriteImage;
17 protected Widget m_CopyInfoButton;
18 protected Widget m_FeedbackButton;
19
20 protected ref TextWidget m_ModdedWarning;
21 protected ref TextWidget m_ServerIP;
22 protected ref TextWidget m_ServerPort;
23 protected ref TextWidget m_ServerName;
24
25 protected ref UiHintPanel m_HintPanel;
26
28 {
29 HudShow(true);
30
31 Mission mission = g_Game.GetMission();
32 if (mission)
33 mission.Continue();
34 }
35
36 override Widget Init()
37 {
38 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_ingamemenu.layout");
39
40 m_ContinueButton = layoutRoot.FindAnyWidget("continuebtn");
41 m_SeparatorPanel = layoutRoot.FindAnyWidget("separator_red");
42 m_ExitButton = layoutRoot.FindAnyWidget("exitbtn");
43 m_RestartButton = layoutRoot.FindAnyWidget("restartbtn");
44 m_RespawnButton = layoutRoot.FindAnyWidget("respawn_button");
45 m_RestartDeadRandomButton = layoutRoot.FindAnyWidget("respawn_button_random");
46 m_RestartDeadCustomButton = layoutRoot.FindAnyWidget("respawn_button_custom");
47 m_OptionsButton = layoutRoot.FindAnyWidget("optionsbtn");
48 m_ModdedWarning = TextWidget.Cast(layoutRoot.FindAnyWidget("ModdedWarning"));
49 m_HintPanel = new UiHintPanel(layoutRoot.FindAnyWidget("hint_frame"));
50 m_ServerInfoPanel = layoutRoot.FindAnyWidget("server_info");
51 m_ServerIP = TextWidget.Cast(layoutRoot.FindAnyWidget("server_ip"));
52 m_ServerPort = TextWidget.Cast(layoutRoot.FindAnyWidget("server_port"));
53 m_ServerName = TextWidget.Cast(layoutRoot.FindAnyWidget("server_name"));
54 m_FavoriteImage = layoutRoot.FindAnyWidget("favorite_image");
55 m_UnfavoriteImage = layoutRoot.FindAnyWidget("unfavorite_image");
56 m_CopyInfoButton = layoutRoot.FindAnyWidget("copy_button");
57 m_FeedbackButton = layoutRoot.FindAnyWidget("feedbackbtn");
58
59 if (GetGame().IsMultiplayer())
60 {
61 ButtonSetText(m_RestartButton, "#main_menu_respawn");
62 }
63 else
64 {
65 ButtonSetText(m_RestartButton, "#main_menu_restart");
66 }
67
68 HudShow(false);
70 SetServerInfoVisibility(SetServerInfo() && g_Game.GetProfileOption(EDayZProfilesOptions.SERVERINFO_DISPLAY));
71 m_ModdedWarning.Show(g_Game.ReportModded());
72
73 Mission mission = g_Game.GetMission();
74 if (mission)
75 mission.Pause();
76
77 return layoutRoot;
78 }
79
80 protected void SetGameVersion()
81 {
82 TextWidget version_widget = TextWidget.Cast(layoutRoot.FindAnyWidget("version"));
83 string version;
84 GetGame().GetVersion(version);
85 version_widget.SetText("#main_menu_version" + " " + version);
86
87 #ifdef PREVIEW_BUILD
88 version_widget.SetText("THIS IS PREVIEW");
89 #endif
90 }
91
92 protected bool SetServerInfo()
93 {
94 if (GetGame().IsMultiplayer())
95 {
96 MenuData menu_data = g_Game.GetMenuData();
98
99 if (info)
100 {
101 m_ServerPort.SetText(info.m_HostPort.ToString());
102 m_ServerIP.SetText(info.m_HostIp);
103 m_ServerName.SetText(info.m_Name);
104 m_UnfavoriteImage.Show(info.m_Favorite);
105 m_FavoriteImage.Show(!info.m_Favorite);
106 m_ServerInfoText = "" + info.GetIpPort();
107
108 return true;
109 }
110 //temporary, incomplete solution, OnlineServices.GetCurrentServerInfo() should be working!
111 else if (menu_data && menu_data.GetLastPlayedCharacter() != GameConstants.DEFAULT_CHARACTER_MENU_ID)
112 {
113 int char_id = menu_data.GetLastPlayedCharacter();
114 int port;
115 string address,name;
116
117 menu_data.GetLastServerAddress(char_id,address);
118 port = menu_data.GetLastServerPort(char_id);
119 menu_data.GetLastServerName(char_id,name);
120 m_ServerPort.SetText(port.ToString());
121 m_ServerIP.SetText(address);
122 m_ServerName.SetText(name);
123 m_ServerInfoText = "" + address + ":" + port;
124
125 return true;
126 }
127 else
128 {
129 g_Game.RefreshCurrentServerInfo();
130 }
131 }
132 return false;
133 }
134
135 protected void HudShow(bool show)
136 {
137 Mission mission = GetGame().GetMission();
138 if (mission)
139 {
140 IngameHud hud = IngameHud.Cast(mission.GetHud());
141 if (hud)
142 {
143 hud.ShowHudUI(g_Game.GetProfileOption(EDayZProfilesOptions.HUD) && show);
144 hud.ShowQuickbarUI(g_Game.GetProfileOption(EDayZProfilesOptions.QUICKBAR) && show);
145 }
146 }
147 }
148
149 override bool OnMouseEnter(Widget w, int x, int y)
150 {
152 return true;
153 }
154
155 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
156 {
157 ColorNormal(w);
158 return true;
159 }
160
161 override bool OnClick(Widget w, int x, int y, int button)
162 {
163 super.OnClick(w, x, y, button);
164
165 if (w == m_ContinueButton)
166 {
168 return true;
169 }
170 else if (w == m_RestartButton)
171 {
172 #ifdef DEVELOPER
173 if (GetGame().IsMultiplayer() || (GetGame().GetPlayer() && GetGame().GetPlayer().IsUnconscious()))
175 else
176 {
177 PluginDeveloper plugin = PluginDeveloper.GetInstance();
178 if (plugin)
179 plugin.ToggleMissionLoader();
180 }
181 #else
183 #endif
184 return true;
185 }
186 else if (w == m_RespawnButton)
187 {
189 return true;
190 }
191 else if (w == m_OptionsButton)
192 {
194 return true;
195 }
196 else if (w == m_ExitButton)
197 {
198 OnClick_Exit();
199 return true;
200 }
201 else if (w == m_CopyInfoButton)
202 {
203 GetGame().CopyToClipboard(m_ServerInfoText);
204 }
205 else if (w == m_FeedbackButton)
206 {
207 OpenFeedback();
208 }
209
210 return false;
211 }
212
213 protected void OnClick_Continue()
214 {
215 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().Continue);
216 }
217
218 protected void OnClick_Restart()
219 {
220 if (!GetGame().IsMultiplayer())
221 {
222 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().RestartMission);
223 }
224 else
225 {
227 }
228 }
229
230 protected void OnClick_Respawn()
231 {
232 Man player = GetGame().GetPlayer();
233
234 if (player && player.IsUnconscious() && !player.IsDamageDestroyed())
235 {
236 GetGame().GetUIManager().ShowDialog("#main_menu_respawn", "#main_menu_respawn_question", IDC_INT_RETRY, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
237 }
238 else
239 {
240 if (GetGame().GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
241 {
242 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_RESPAWN_DIALOGUE,this);
243 }
244 else
245 {
246 GameRespawn(true);
247 }
248 }
249 }
250
251 protected void OnClick_Options()
252 {
253 EnterScriptedMenu(MENU_OPTIONS);
254 }
255
256 protected void OnClick_Exit()
257 {
259 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().CreateLogoutMenu, this);
260 }
261
262 override bool OnModalResult(Widget w, int x, int y, int code, int result)
263 {
264 super.OnModalResult(w, x, y, code, result);
265 if (code == IDC_INT_EXIT && result == DBB_YES)
266 {
267 if (GetGame().IsMultiplayer())
268 {
270 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().CreateLogoutMenu, this);
271 }
272 else
273 {
274 // skip logout screen in singleplayer
275 GetGame().GetMission().AbortMission();
276 }
277 g_Game.CancelLoginTimeCountdown();
278 return true;
279 }
280 else if (code == IDC_INT_EXIT && result == DBB_NO)
281 {
282 g_Game.CancelLoginTimeCountdown();
283 }
284 else if (code == IDC_INT_RETRY && result == DBB_YES && GetGame().IsMultiplayer())
285 {
286 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
288 if (player && player.IsAlive() && !player.IsUnconscious())
289 {
290 return true;
291 }
292
293 if (GetGame().GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
294 {
295 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_RESPAWN_DIALOGUE,this);
296 }
297 else
298 {
299 GameRespawn(true);
300 }
301 return true;
302 }
303
304 return false;
305 }
306
307 override void Update(float timeslice)
308 {
309 super.Update(timeslice);
310
311 UpdateGUI();
312 }
313
314 protected void UpdateGUI()
315 {
316 #ifdef BULDOZER
317 m_RestartButton.Show(false);
318 m_RespawnButton.Show(false);
319 #else
320 Man player = GetGame().GetPlayer();
321 bool playerAlive = player && player.GetPlayerState() == EPlayerStates.ALIVE;
322
323 if (GetGame().IsMultiplayer())
324 {
325 m_RestartButton.Show(playerAlive && player.IsUnconscious() && !CfgGameplayHandler.GetDisableRespawnInUnconsciousness());
326 m_RespawnButton.Show(!playerAlive);
327 }
328 else
329 {
330 m_RestartButton.Show(true);
331 m_RespawnButton.Show(false);
332 m_SeparatorPanel.Show(playerAlive);
333 }
334
335 m_ContinueButton.Show(playerAlive);
336 #endif
337 }
338
339 void MenuRequestRespawn(UIScriptedMenu menu, bool random)
340 {
341 if (RespawnDialogue.Cast(menu))
342 GameRespawn(random);
343 }
344
345 protected void GameRespawn(bool random)
346 {
347 GetGame().GetMenuDefaultCharacterData(false).SetRandomCharacterForced(random);
349
350 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
351 if (player)
352 {
353 player.SimulateDeath(true);
354 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(player.ShowDeadScreen, true, 0);
355 }
356
357 MissionGameplay missionGP = MissionGameplay.Cast(GetGame().GetMission());
358 missionGP.DestroyAllMenus();
359 missionGP.SetPlayerRespawning(true);
360 missionGP.Continue();
361
362 Close();
363 }
364
365 protected void ColorHighlight(Widget w)
366 {
367 if (!w)
368 return;
369
370 ButtonSetColor(w, ARGB(255, 0, 0, 0));
371 ButtonSetTextColor(w, ARGB(255, 255, 0, 0));
372 }
373
374 protected void ColorNormal(Widget w)
375 {
376 if (!w)
377 return;
378
379 ButtonSetColor(w, ARGB(0, 0, 0, 0));
380 ButtonSetTextColor(w, ARGB(255, 255, 255, 255));
381 }
382
383 protected void ColorDisable(Widget w)
384 {
385 if (!w)
386 return;
387
388 ButtonSetColor(w, ARGB(0, 0, 0, 0));
389 ButtonSetTextColor(w, ColorManager.COLOR_DISABLED_TEXT);
390 }
391
392 protected void ButtonSetText(Widget w, string text)
393 {
394 if (!w)
395 return;
396
397 TextWidget label = TextWidget.Cast(w.FindWidget(w.GetName() + "_label"));
398 if (label)
399 label.SetText(text);
400
401 }
402
403 protected void ButtonSetColor(Widget w, int color)
404 {
405 Widget panel = w.FindWidget(w.GetName() + "_panel");
406 if (panel)
407 panel.SetColor(color);
408 }
409
410 protected void ButtonSetTextColor(Widget w, int color)
411 {
412 TextWidget label = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
413 if (label)
414 label.SetColor(color);
415 }
416
418 {
419 m_ServerInfoPanel.Show(show);
420 }
421
422 protected void OpenFeedback()
423 {
424 GetGame().OpenURL("https://feedback.bistudio.com/project/view/2/");
425 }
426
429}
void UiHintPanel(Widget parent_widget)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
proto native void LogoutRequestTime()
Logout methods.
proto native void RespawnPlayer()
proto native void OpenURL(string url)
MenuDefaultCharacterData GetMenuDefaultCharacterData(bool fill_data=true)
Definition game.c:1548
GetServersResultRow the output structure of the GetServers operation that represents one game server.
Mission class.
Definition gameplay.c:687
static void GetCurrentServerInfo(string ip, int port)
void MenuRequestRespawn(UIScriptedMenu menu, bool random)
Definition ingamemenu.c:339
override bool OnMouseEnter(Widget w, int x, int y)
Definition ingamemenu.c:149
Widget m_ExitButton
Definition ingamemenu.c:7
ref TextWidget m_ServerIP
Definition ingamemenu.c:21
void ToggleFavoriteServer()
DEPRECATED.
void ColorDisable(Widget w)
Definition ingamemenu.c:383
void OnClick_Restart()
Definition ingamemenu.c:218
bool SetServerInfo()
Definition ingamemenu.c:92
void SetServerInfoVisibility(bool show)
Definition ingamemenu.c:417
override void Update(float timeslice)
Definition ingamemenu.c:307
Widget m_RespawnButton
Definition ingamemenu.c:9
Widget m_ContinueButton
Definition ingamemenu.c:5
void ColorHighlight(Widget w)
Widget m_FavoriteImage
Definition ingamemenu.c:15
Widget m_SeparatorPanel
Definition ingamemenu.c:6
void OnClick_Exit()
Definition ingamemenu.c:256
Widget m_RestartButton
Definition ingamemenu.c:8
void ButtonSetText(Widget w, string text)
ref TextWidget m_ServerPort
Definition ingamemenu.c:22
Widget m_RestartDeadCustomButton
Definition ingamemenu.c:11
void SetGameVersion()
Definition ingamemenu.c:80
ref TextWidget m_ModdedWarning
Definition ingamemenu.c:20
Widget m_OptionsButton
Definition ingamemenu.c:12
ref TextWidget m_ServerName
Definition ingamemenu.c:23
void ~InGameMenu()
Definition ingamemenu.c:27
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition ingamemenu.c:155
void GameRespawn(bool random)
Definition ingamemenu.c:345
Widget m_ServerInfoPanel
Definition ingamemenu.c:13
Widget m_FeedbackButton
Definition ingamemenu.c:18
void OnClick_Continue()
Definition ingamemenu.c:213
Widget m_UnfavoriteImage
Definition ingamemenu.c:16
Widget m_FavoriteButton
Definition ingamemenu.c:14
void ButtonSetTextColor(Widget w, int color)
ref UiHintPanel m_HintPanel
Definition ingamemenu.c:25
override Widget Init()
Definition ingamemenu.c:36
void OpenFeedback()
Definition ingamemenu.c:422
override bool OnClick(Widget w, int x, int y, int button)
Definition ingamemenu.c:161
void ButtonSetColor(Widget w, int color)
void HudShow(bool show)
Definition ingamemenu.c:135
override bool OnModalResult(Widget w, int x, int y, int code, int result)
Definition ingamemenu.c:262
void OnClick_Respawn()
Definition ingamemenu.c:230
void ColorNormal(Widget w)
Widget m_RestartDeadRandomButton
Definition ingamemenu.c:10
Widget m_CopyInfoButton
Definition ingamemenu.c:17
void OnClick_Options()
Definition ingamemenu.c:251
ref UiHintPanelLoading m_HintPanel
Definition dayzgame.c:706
DayZGame g_Game
Definition dayzgame.c:3868
TextWidget m_ModdedWarning
Definition dayzgame.c:691
Mission mission
EDayZProfilesOptions
EPlayerStates
proto native CGame GetGame()
const int MENU_RESPAWN_DIALOGUE
Definition constants.c:209
const int MENU_OPTIONS
Definition constants.c:183
void Continue()
Timer continue when it was paused.
Definition tools.c:247
const int CALL_CATEGORY_GUI
Definition tools.c:9
const int IDC_INT_EXIT
Definition constants.c:160
const int IDC_INT_RETRY
ingame menu
Definition constants.c:158
Icon x
Icon y
void Close()
PlayerBase GetPlayer()
int ARGB(int a, int r, int g, int b)
Definition proto.c:322