3 string m_ServerInfoText;
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;
37 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/day_z_ingamemenu.layout");
39 m_ContinueButton = layoutRoot.FindAnyWidget(
"continuebtn");
40 m_SeparatorPanel = layoutRoot.FindAnyWidget(
"separator_red");
41 m_ExitButton = layoutRoot.FindAnyWidget(
"exitbtn");
42 m_RestartButton = layoutRoot.FindAnyWidget(
"restartbtn");
43 m_RespawnButton = layoutRoot.FindAnyWidget(
"respawn_button");
44 m_RestartDeadRandomButton = layoutRoot.FindAnyWidget(
"respawn_button_random");
45 m_RestartDeadCustomButton = layoutRoot.FindAnyWidget(
"respawn_button_custom");
46 m_OptionsButton = layoutRoot.FindAnyWidget(
"optionsbtn");
49 m_ServerInfoPanel = layoutRoot.FindAnyWidget(
"server_info");
50 m_ServerIP =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"server_ip"));
51 m_ServerPort =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"server_port"));
52 m_ServerName =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"server_name"));
53 m_FavoriteImage = layoutRoot.FindAnyWidget(
"favorite_image");
54 m_UnfavoriteImage = layoutRoot.FindAnyWidget(
"unfavorite_image");
55 m_CopyInfoButton = layoutRoot.FindAnyWidget(
"copy_button");
59 ButtonSetText(m_RestartButton,
"#main_menu_respawn");
63 ButtonSetText(m_RestartButton,
"#main_menu_restart");
78 protected void SetGameVersion()
83 version_widget.SetText(
"#main_menu_version" +
" " + version);
86 version_widget.SetText(
"THIS IS PREVIEW");
90 protected bool SetServerInfo()
99 m_ServerPort.SetText(info.m_HostPort.ToString());
100 m_ServerIP.SetText(info.m_HostIp);
101 m_ServerName.SetText(info.m_Name);
102 m_UnfavoriteImage.Show(info.m_Favorite);
103 m_FavoriteImage.Show(!info.m_Favorite);
104 m_ServerInfoText =
"" + info.GetIpPort();
109 else if (menu_data && menu_data.GetLastPlayedCharacter() !=
GameConstants.DEFAULT_CHARACTER_MENU_ID)
111 int char_id = menu_data.GetLastPlayedCharacter();
115 menu_data.GetLastServerAddress(char_id,address);
116 port = menu_data.GetLastServerPort(char_id);
117 menu_data.GetLastServerName(char_id,
name);
118 m_ServerPort.SetText(port.ToString());
119 m_ServerIP.SetText(address);
120 m_ServerName.SetText(
name);
121 m_ServerInfoText =
"" + address +
":" + port;
127 g_Game.RefreshCurrentServerInfo();
133 protected void HudShow(
bool show)
138 IngameHud hud = IngameHud.Cast(
mission.GetHud());
161 super.OnClick(w,
x,
y, button);
163 if (w == m_ContinueButton)
168 else if (w == m_RestartButton)
175 PluginDeveloper plugin = PluginDeveloper.GetInstance();
177 plugin.ToggleMissionLoader();
184 else if (w == m_RespawnButton)
189 else if (w == m_OptionsButton)
194 else if (w == m_ExitButton)
199 else if (w == m_CopyInfoButton)
201 GetGame().CopyToClipboard(m_ServerInfoText);
207 protected void OnClick_Continue()
212 protected void OnClick_Restart()
214 if (!
GetGame().IsMultiplayer())
224 protected void OnClick_Respawn()
226 Man player =
GetGame().GetPlayer();
228 if (player && player.IsUnconscious() && !player.IsDamageDestroyed())
230 GetGame().GetUIManager().ShowDialog(
"#main_menu_respawn",
"#main_menu_respawn_question",
IDC_INT_RETRY, DBT_YESNO, DBB_YES, DMT_QUESTION,
this);
245 protected void OnClick_Options()
250 protected void OnClick_Exit()
256 override bool OnModalResult(
Widget w,
int x,
int y,
int code,
int result)
258 super.OnModalResult(w,
x,
y, code, result);
269 GetGame().GetMission().AbortMission();
271 g_Game.CancelLoginTimeCountdown();
276 g_Game.CancelLoginTimeCountdown();
294 override void Update(
float timeslice)
296 super.Update(timeslice);
301 protected void UpdateGUI()
304 m_RestartButton.Show(
false);
305 m_RespawnButton.Show(
false);
307 Man player =
GetGame().GetPlayer();
308 bool playerAlive = player && player.GetPlayerState() ==
EPlayerStates.ALIVE;
312 m_RestartButton.Show(playerAlive && player.IsUnconscious() && !
CfgGameplayHandler.GetDisableRespawnInUnconsciousness());
313 m_RespawnButton.Show(!playerAlive);
317 m_RestartButton.Show(
true);
318 m_RespawnButton.Show(
false);
319 m_SeparatorPanel.Show(playerAlive);
322 m_ContinueButton.Show(playerAlive);
328 if (RespawnDialogue.Cast(menu))
332 protected void GameRespawn(
bool random)
334 GetGame().GetMenuDefaultCharacterData(
false).SetRandomCharacterForced(random);
340 player.SimulateDeath(
true);
344 MissionGameplay missionGP = MissionGameplay.Cast(
GetGame().GetMission());
345 missionGP.DestroyAllMenus();
346 missionGP.SetPlayerRespawning(
true);
347 missionGP.Continue();
357 ButtonSetColor(w,
ARGB(255, 0, 0, 0));
358 ButtonSetTextColor(w,
ARGB(255, 255, 0, 0));
366 ButtonSetColor(w,
ARGB(0, 0, 0, 0));
367 ButtonSetTextColor(w,
ARGB(255, 255, 255, 255));
375 ButtonSetColor(w,
ARGB(0, 0, 0, 0));
376 ButtonSetTextColor(w,
ColorManager.COLOR_DISABLED_TEXT);
379 protected void ButtonSetText(
Widget w,
string text)
390 protected void ButtonSetColor(
Widget w,
int color)
392 Widget panel = w.FindWidget(w.GetName() +
"_panel");
394 panel.SetColor(color);
397 protected void ButtonSetTextColor(
Widget w,
int color)
401 label.SetColor(color);
404 void SetServerInfoVisibility(
bool show)
406 m_ServerInfoPanel.Show(show);
410 void ToggleFavoriteServer();