ingamemenuxbox.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. class InGameMenuXbox extends UIScriptedMenu
  2. {
  3. // Widgets texts id
  4. protected string m_MuteButtonTextID;
  5. protected string m_UnmuteButtonTextID;
  6. protected string m_BackButtonTextID;
  7. protected string m_SelectButtonTextID;
  8. protected string m_OpenGameCardButtonTextID;
  9. protected string m_CurrentMuteButtonText;
  10. protected bool m_SelectAvailable;
  11. protected bool m_MuteAvailable;
  12. protected bool m_BackAvailable;
  13. protected bool m_GamercardAvailable;
  14. protected bool m_PlayerAlive;
  15. protected ref PlayerListScriptedWidget m_ServerInfoPanel;
  16. protected Widget m_OnlineMenu;
  17. protected ButtonWidget m_ContinueButton;
  18. protected ButtonWidget m_ExitButton;
  19. protected ButtonWidget m_RestartDeadButton;
  20. protected ButtonWidget m_RestartButton;
  21. protected ButtonWidget m_OptionsButton;
  22. protected ButtonWidget m_ControlsButton;
  23. protected ButtonWidget m_OnlineButton;
  24. protected ButtonWidget m_TutorialsButton;
  25. protected TextWidget m_Version;
  26. const int BUTTON_XBOX_CONTROLS = 201;
  27. void InGameMenuXbox()
  28. {
  29. GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
  30. GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
  31. }
  32. void ~InGameMenuXbox()
  33. {
  34. ClientData.SyncEvent_OnPlayerListUpdate.Remove(SyncEvent_OnRecievedPlayerList);
  35. OnlineServices.m_PermissionsAsyncInvoker.Remove(OnPermissionsUpdate);
  36. Mission mission = GetGame().GetMission();
  37. if (mission)
  38. {
  39. IngameHud hud = IngameHud.Cast(mission.GetHud());
  40. if (hud)
  41. {
  42. hud.ShowHudUI(true);
  43. hud.ShowQuickbarUI(true);
  44. }
  45. mission.Continue();
  46. }
  47. PPERequesterBank.GetRequester(PPERequester_MenuEffects).Stop();
  48. }
  49. protected void OnInputPresetChanged()
  50. {
  51. #ifdef PLATFORM_CONSOLE
  52. UpdateControlsElements();
  53. #endif
  54. }
  55. protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
  56. {
  57. UpdateControlsElements();
  58. }
  59. override Widget Init()
  60. {
  61. layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/xbox/day_z_ingamemenu_xbox.layout");
  62. m_OnlineMenu = GetGame().GetWorkspace().CreateWidgets("gui/layouts/xbox/ingamemenu_xbox/online_info_menu.layout", layoutRoot);
  63. m_OnlineMenu.Show(false);
  64. m_ContinueButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("continuebtn"));
  65. m_RestartDeadButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("restartbtn_dead"));
  66. m_ExitButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("exitbtn"));
  67. m_RestartButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("restartbtn"));
  68. m_OptionsButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("optionsbtn"));
  69. m_ControlsButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("controlsbtn"));
  70. m_OnlineButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("onlinebtn"));
  71. m_TutorialsButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("tutorialsbtn"));
  72. m_Version = TextWidget.Cast(layoutRoot.FindAnyWidget("version"));
  73. m_SelectAvailable = true;
  74. m_MuteAvailable = false;
  75. m_GamercardAvailable = false;
  76. m_BackAvailable = true;
  77. PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
  78. if (player)
  79. {
  80. m_PlayerAlive = player.GetPlayerState() == EPlayerStates.ALIVE;
  81. if (!m_PlayerAlive)
  82. m_BackAvailable = false;
  83. player.GetOnUnconsciousStart().Insert(UpdateGUI);
  84. player.GetOnUnconsciousStart().Insert(UpdateMenuFocus);
  85. player.GetOnUnconsciousStop().Insert(UpdateGUI);
  86. player.GetOnUnconsciousStop().Insert(UpdateMenuFocus);
  87. player.GetOnDeathStart().Insert(UpdateGUI);
  88. player.GetOnDeathStart().Insert(UpdateMenuFocus);
  89. }
  90. string version;
  91. GetGame().GetVersion(version);
  92. #ifdef PLATFORM_CONSOLE
  93. version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
  94. #else
  95. version = "#main_menu_version" + " " + version;
  96. #endif
  97. m_Version.SetText(version);
  98. if (GetGame().IsMultiplayer())
  99. {
  100. m_OnlineButton.Show(true);
  101. TextWidget w_text = TextWidget.Cast(m_OnlineMenu.FindAnyWidget("OnlineTextWidget"));
  102. w_text.SetText(g_Game.GetHostName());
  103. m_ServerInfoPanel = new PlayerListScriptedWidget(m_OnlineMenu.FindAnyWidget("ServerInfoPanel"));
  104. OnlineServices.m_PermissionsAsyncInvoker.Insert(OnPermissionsUpdate);
  105. ClientData.SyncEvent_OnPlayerListUpdate.Insert(SyncEvent_OnRecievedPlayerList);
  106. m_ServerInfoPanel.Reload(ClientData.m_PlayerList);
  107. m_ServerInfoPanel.ReloadLocal(OnlineServices.GetMuteList());
  108. string uid = m_ServerInfoPanel.FindPlayerByWidget(GetFocus());
  109. if (uid != "")
  110. {
  111. if (IsLocalPlayer(uid) || m_ServerInfoPanel.IsEmpty())
  112. {
  113. m_MuteAvailable = false;
  114. m_GamercardAvailable = false;
  115. }
  116. else
  117. {
  118. m_MuteAvailable = !GetGame().GetWorld().IsDisabledReceivingVoN();
  119. #ifndef PLATFORM_PS4
  120. m_GamercardAvailable = true;
  121. #endif
  122. SetMuteButtonText(OnlineServices.IsPlayerMuted(uid));
  123. }
  124. if (m_ServerInfoPanel.IsGloballyMuted(uid))
  125. {
  126. m_MuteAvailable = false;
  127. }
  128. }
  129. }
  130. else
  131. {
  132. layoutRoot.FindAnyWidget("onlinebtn").Show(false);
  133. layoutRoot.FindAnyWidget("invitebtn").Show(false);
  134. }
  135. //RESPAWN & RESTART
  136. if (GetGame().IsMultiplayer())
  137. {
  138. m_RestartButton.SetText("#main_menu_respawn");
  139. }
  140. else
  141. {
  142. m_RestartButton.SetText("#main_menu_restart");
  143. }
  144. if (!ShouldRestartBeVisible(player))
  145. {
  146. //m_RestartButton.Enable(false);
  147. m_RestartButton.Show(false);
  148. }
  149. Mission mission = GetGame().GetMission();
  150. if (mission)
  151. {
  152. IngameHud hud = IngameHud.Cast(mission.GetHud());
  153. if (hud)
  154. {
  155. hud.ShowHudUI(false);
  156. hud.ShowQuickbarUI(false);
  157. }
  158. mission.Pause();
  159. }
  160. PPERequester_MenuEffects requester;
  161. Class.CastTo(requester,PPERequesterBank.GetRequester(PPERequester_MenuEffects));
  162. requester.SetVignetteIntensity(0.6);
  163. UpdateControlsElements();
  164. LoadTextStrings();
  165. LoadFooterButtonTexts();
  166. OnInputDeviceChanged(GetGame().GetInput().GetCurrentInputDevice());
  167. return layoutRoot;
  168. }
  169. override bool OnClick(Widget w, int x, int y, int button)
  170. {
  171. super.OnClick(w, x, y, button);
  172. switch (w.GetUserID())
  173. {
  174. case IDC_MAIN_CONTINUE:
  175. {
  176. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().Continue);
  177. return true;
  178. }
  179. case IDC_MAIN_OPTIONS:
  180. {
  181. EnterScriptedMenu(MENU_OPTIONS);
  182. return true;
  183. }
  184. case BUTTON_XBOX_CONTROLS:
  185. {
  186. EnterScriptedMenu(MENU_XBOX_CONTROLS);
  187. return true;
  188. }
  189. case IDC_MAIN_QUIT:
  190. {
  191. GetGame().GetUIManager().ShowDialog("#main_menu_exit", "#main_menu_exit_desc", IDC_INT_EXIT, DBT_YESNO, DBB_YES, DMT_QUESTION, NULL);
  192. return true;
  193. }
  194. case IDC_INT_RETRY:
  195. {
  196. if (!GetGame().IsMultiplayer())
  197. {
  198. GetGame().GetUIManager().ShowDialog("#main_menu_restart", "Are you sure you want to restart?", IDC_INT_RETRY, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
  199. }
  200. else
  201. {
  202. GetGame().GetUIManager().ShowDialog("#main_menu_respawn", "#main_menu_respawn_question", IDC_INT_RETRY, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
  203. }
  204. return true;
  205. }
  206. case IDC_MAIN_ONLINE:
  207. {
  208. m_OnlineMenu.Show(true);
  209. m_SelectAvailable = false;
  210. UpdateControlsElements();
  211. m_ServerInfoPanel.FocusFirst();
  212. return true;
  213. }
  214. case 117:
  215. {
  216. EnterScriptedMenu(MENU_TUTORIAL);
  217. return true;
  218. }
  219. case IDC_MULTI_INVITE:
  220. {
  221. OnlineServices.ShowInviteScreen();
  222. return true;
  223. }
  224. }
  225. if (w == layoutRoot.FindAnyWidget("backbtn"))
  226. {
  227. CloseOnline();
  228. }
  229. else if (w == m_RestartDeadButton)
  230. {
  231. if (GetGame().GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
  232. {
  233. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_RESPAWN_DIALOGUE,this);
  234. }
  235. else
  236. {
  237. GameRetry(true);
  238. }
  239. return true;
  240. }
  241. return false;
  242. }
  243. override bool OnModalResult(Widget w, int x, int y, int code, int result)
  244. {
  245. super.OnModalResult(w, x, y, code, result);
  246. if (code == IDC_INT_EXIT && result == DBB_YES)
  247. {
  248. if (GetGame().IsMultiplayer())
  249. {
  250. GetGame().LogoutRequestTime();
  251. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().CreateLogoutMenu, this);
  252. }
  253. else
  254. {
  255. // skip logout screen in singleplayer
  256. GetGame().GetMission().AbortMission();
  257. }
  258. g_Game.CancelLoginTimeCountdown();
  259. return true;
  260. }
  261. else if (code == IDC_INT_EXIT && result == DBB_NO)
  262. {
  263. g_Game.CancelLoginTimeCountdown();
  264. }
  265. else if (code == IDC_INT_RETRY)
  266. {
  267. if (result == DBB_YES)
  268. {
  269. if (GetGame().GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
  270. {
  271. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_RESPAWN_DIALOGUE,this);
  272. }
  273. else
  274. {
  275. GameRetry(true);
  276. return true;
  277. }
  278. }
  279. else
  280. {
  281. UpdateMenuFocus();
  282. }
  283. }
  284. return false;
  285. }
  286. void GameRetry(bool random)
  287. {
  288. if (GetGame().IsMultiplayer())
  289. {
  290. //GetGame().GetUIManager().CloseAll();
  291. GetGame().GetMenuDefaultCharacterData(false).SetRandomCharacterForced(random);
  292. GetGame().RespawnPlayer();
  293. PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
  294. if (player)
  295. {
  296. player.SimulateDeath(true);
  297. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(player.ShowDeadScreen, true, 0);
  298. }
  299. MissionGameplay missionGP = MissionGameplay.Cast(GetGame().GetMission());
  300. missionGP.DestroyAllMenus();
  301. missionGP.SetPlayerRespawning(true);
  302. missionGP.Continue();
  303. Close();
  304. }
  305. else
  306. GetGame().RestartMission();
  307. }
  308. void MenuRequestRespawn(UIScriptedMenu menu, bool random)
  309. {
  310. if (RespawnDialogue.Cast(menu))
  311. GameRetry(random);
  312. }
  313. bool IsLocalPlayer(string uid)
  314. {
  315. PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
  316. string local_uid;
  317. if (GetGame().GetUserManager())
  318. local_uid = GetGame().GetUserManager().GetSelectedUser().GetUid();
  319. return (uid == local_uid);
  320. }
  321. SyncPlayerList CreateFakePlayerList(int player_count)
  322. {
  323. SyncPlayerList player_list = new SyncPlayerList;
  324. player_list.m_PlayerList = new array<ref SyncPlayer>;
  325. for (int i = 0; i < player_count; i++)
  326. {
  327. SyncPlayer sync_player = new SyncPlayer;
  328. sync_player.m_UID = "uid" + i;
  329. sync_player.m_PlayerName = "Player " + i;
  330. player_list.m_PlayerList.Insert(sync_player);
  331. }
  332. return player_list;
  333. }
  334. override void Update(float timeslice)
  335. {
  336. if (GetGame().IsMultiplayer() && layoutRoot.FindAnyWidget("OnlineInfo").IsVisible())
  337. {
  338. PlayerListEntryScriptedWidget selected;
  339. if (m_ServerInfoPanel)
  340. selected = m_ServerInfoPanel.GetSelectedPlayer();
  341. if (GetUApi().GetInputByID(UAUICtrlX).LocalPress())
  342. {
  343. if (selected)
  344. m_ServerInfoPanel.ToggleMute(selected.GetUID());
  345. Refresh();
  346. }
  347. #ifndef PLATFORM_PS4
  348. if (GetUApi().GetInputByID(UAUICtrlY).LocalPress())
  349. {
  350. if (selected)
  351. OnlineServices.ShowUserProfile(selected.GetUID());
  352. }
  353. #endif
  354. }
  355. }
  356. bool ShouldRestartBeVisible(Man player)
  357. {
  358. PlayerBase p = PlayerBase.Cast(player);
  359. return p && p.IsUnconsciousStateOnly() && !CfgGameplayHandler.GetDisableRespawnInUnconsciousness();
  360. }
  361. void UpdateGUI()
  362. {
  363. bool shouldUpdateMenuFocus = false;
  364. Man player = GetGame().GetPlayer();
  365. if (player)
  366. m_PlayerAlive = player.GetPlayerState() == EPlayerStates.ALIVE;
  367. if (m_PlayerAlive)
  368. {
  369. bool showRestartBtn = ShouldRestartBeVisible(player);
  370. m_RestartButton.Show(showRestartBtn);
  371. }
  372. else
  373. {
  374. m_RestartButton.Show(false);
  375. m_BackAvailable = false;
  376. }
  377. m_ContinueButton.Show(m_PlayerAlive);
  378. m_RestartDeadButton.Show(!m_PlayerAlive);
  379. UpdateMenuFocus();
  380. }
  381. bool IsOnlineOpen()
  382. {
  383. return m_OnlineMenu.IsVisible();
  384. }
  385. void CloseOnline()
  386. {
  387. m_OnlineMenu.Show(false);
  388. m_SelectAvailable = true;
  389. m_MuteAvailable = false;
  390. m_GamercardAvailable = false;
  391. UpdateControlsElements();
  392. SetFocus(m_OnlineButton);
  393. }
  394. void SelectServer()
  395. {
  396. if (m_ServerInfoPanel)
  397. {
  398. m_ServerInfoPanel.FocusFirst();
  399. Refresh();
  400. }
  401. }
  402. override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
  403. {
  404. return false;
  405. }
  406. void SyncEvent_OnRecievedPlayerList(SyncPlayerList player_list)
  407. {
  408. m_ServerInfoPanel.Reload(player_list);
  409. Refresh();
  410. }
  411. void OnPermissionsUpdate(BiosPrivacyUidResultArray result_list)
  412. {
  413. m_ServerInfoPanel.Reload(result_list);
  414. Refresh();
  415. }
  416. override void OnShow()
  417. {
  418. super.OnShow();
  419. #ifdef PLATFORM_CONSOLE
  420. bool mk = GetGame().GetInput().IsEnabledMouseAndKeyboard();
  421. bool mk_server = GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
  422. TextWidget warning = TextWidget.Cast(layoutRoot.FindAnyWidget("MouseAndKeyboardWarning"));
  423. if (mk)
  424. {
  425. if (mk_server)
  426. {
  427. warning.SetText("#str_mouse_and_keyboard_server_warning");
  428. }
  429. else
  430. {
  431. warning.SetText("#str_controller_server_warning");
  432. }
  433. }
  434. warning.Show(mk);
  435. #endif
  436. UpdateGUI();
  437. UpdateMenuFocus();
  438. UpdateControlsElements();
  439. }
  440. override bool OnMouseEnter(Widget w, int x, int y)
  441. {
  442. if (IsFocusable(w))
  443. {
  444. ColorHighlight(w);
  445. return true;
  446. }
  447. return false;
  448. }
  449. override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
  450. {
  451. if (IsFocusable(w))
  452. {
  453. ColorNormal(w);
  454. return true;
  455. }
  456. return false;
  457. }
  458. override bool OnFocus(Widget w, int x, int y)
  459. {
  460. if (IsFocusable(w))
  461. {
  462. ColorHighlight(w);
  463. return true;
  464. }
  465. return false;
  466. }
  467. override bool OnFocusLost(Widget w, int x, int y)
  468. {
  469. if (IsFocusable(w))
  470. {
  471. ColorNormal(w);
  472. return true;
  473. }
  474. return false;
  475. }
  476. bool IsFocusable(Widget w)
  477. {
  478. if (w)
  479. {
  480. if (w == m_ContinueButton || w == m_ExitButton || w == m_RestartButton || w == m_OptionsButton || w == m_ControlsButton || w == m_OnlineButton || w == m_TutorialsButton);
  481. return true;
  482. }
  483. return false;
  484. }
  485. override void Refresh()
  486. {
  487. string version;
  488. GetGame().GetVersion(version);
  489. #ifdef PLATFORM_CONSOLE
  490. version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
  491. #else
  492. version = "#main_menu_version" + " " + version;
  493. #endif
  494. m_Version.SetText(version);
  495. m_MuteAvailable = false;
  496. m_GamercardAvailable = false;
  497. if (GetGame().IsMultiplayer() && layoutRoot.FindAnyWidget("OnlineInfo").IsVisible() && m_ServerInfoPanel)
  498. {
  499. PlayerListEntryScriptedWidget selected = m_ServerInfoPanel.GetSelectedPlayer();
  500. if (selected && !selected.IsLocalPlayer())
  501. {
  502. m_MuteAvailable = !GetGame().GetWorld().IsDisabledReceivingVoN() && !selected.IsGloballyMuted();
  503. #ifndef PLATFORM_PS4
  504. m_GamercardAvailable = true;
  505. #endif
  506. SetMuteButtonText(selected.IsMuted());
  507. }
  508. }
  509. UpdateControlsElements();
  510. }
  511. void ColorDisable(Widget w)
  512. {
  513. #ifdef PLATFORM_WINDOWS
  514. SetFocus(null);
  515. #endif
  516. ButtonWidget button = ButtonWidget.Cast(w);
  517. if (button && button != m_ContinueButton)
  518. {
  519. button.SetTextColor(ARGB(255, 255, 255, 255));
  520. }
  521. ButtonSetColor(w, ARGB(0, 0, 0, 0));
  522. ButtonSetTextColor(w, ARGB(60, 0, 0, 0));
  523. }
  524. void ColorHighlight(Widget w)
  525. {
  526. if (!w)
  527. return;
  528. int color_pnl = ARGB(255, 0, 0, 0);
  529. int color_lbl = ARGB(255, 255, 0, 0);
  530. #ifdef PLATFORM_CONSOLE
  531. color_pnl = ARGB(255, 200, 0, 0);
  532. color_lbl = ARGB(255, 255, 255, 255);
  533. #endif
  534. ButtonSetColor(w, color_pnl);
  535. ButtonSetTextColor(w, color_lbl);
  536. }
  537. void ColorNormal(Widget w)
  538. {
  539. if (!w)
  540. return;
  541. int color_pnl = ARGB(0, 0, 0, 0);
  542. int color_lbl = ARGB(255, 255, 255, 255);
  543. ButtonSetColor(w, color_pnl);
  544. ButtonSetTextColor(w, color_lbl);
  545. }
  546. void ButtonSetText(Widget w, string text)
  547. {
  548. if (!w)
  549. return;
  550. TextWidget label = TextWidget.Cast(w.FindWidget(w.GetName() + "_label"));
  551. if (label)
  552. {
  553. label.SetText(text);
  554. }
  555. }
  556. void ButtonSetColor(Widget w, int color)
  557. {
  558. if (!w)
  559. return;
  560. Widget panel = w.FindWidget(w.GetName() + "_panel");
  561. if (panel)
  562. {
  563. panel.SetColor(color);
  564. }
  565. }
  566. void ButtonSetTextColor(Widget w, int color)
  567. {
  568. if (!w)
  569. return;
  570. TextWidget label = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
  571. TextWidget text = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
  572. TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
  573. if (label)
  574. {
  575. label.SetColor(color);
  576. }
  577. if (text)
  578. {
  579. text.SetColor(color);
  580. }
  581. if (text2)
  582. {
  583. text2.SetColor(color);
  584. }
  585. }
  586. /// Set mute text button text (mute / unmute)
  587. protected void SetMuteButtonText(bool isMuted)
  588. {
  589. if (isMuted)
  590. {
  591. m_CurrentMuteButtonText = m_UnmuteButtonTextID;
  592. }
  593. else
  594. {
  595. m_CurrentMuteButtonText = m_MuteButtonTextID;
  596. }
  597. }
  598. /// Set correct bottom button texts based on platform (ps4 vs xbox texts)
  599. protected void LoadTextStrings()
  600. {
  601. #ifdef PLATFORM_PS4
  602. m_MuteButtonTextID = "#ps4_ingame_menu_mute";
  603. m_UnmuteButtonTextID = "#ps4_ingame_menu_unmute";
  604. m_BackButtonTextID = "#ps4_ingame_menu_back";
  605. m_SelectButtonTextID = "#ps4_ingame_menu_select";
  606. m_OpenGameCardButtonTextID = "#ps4_ingame_menu_opencard";
  607. #else
  608. m_MuteButtonTextID = "#xbox_ingame_menu_mute";
  609. m_UnmuteButtonTextID = "#xbox_ingame_menu_unmute";
  610. m_BackButtonTextID = "#STR_rootFrame_toolbar_bg_ConsoleToolbar_Back_BackText0";
  611. m_SelectButtonTextID = "#layout_xbox_ingame_menu_select";
  612. m_OpenGameCardButtonTextID = "#layout_xbox_ingame_menu_gamecard";
  613. #endif
  614. }
  615. /// Initial texts load for the footer buttons
  616. protected void LoadFooterButtonTexts()
  617. {
  618. TextWidget uiGamecardText = TextWidget.Cast(layoutRoot.FindAnyWidget("GamercardText"));
  619. TextWidget uiBackText = TextWidget.Cast(layoutRoot.FindAnyWidget("BackText"));
  620. TextWidget uiSelectText = TextWidget.Cast(layoutRoot.FindAnyWidget("SelectText"));
  621. if (uiGamecardText)
  622. {
  623. uiGamecardText.SetText(m_OpenGameCardButtonTextID);
  624. }
  625. if (uiBackText)
  626. {
  627. uiBackText.SetText(m_BackButtonTextID);
  628. }
  629. if (uiSelectText)
  630. {
  631. uiSelectText.SetText(m_SelectButtonTextID);
  632. }
  633. }
  634. void UpdateMenuFocus()
  635. {
  636. Man player = GetGame().GetPlayer();
  637. if (m_PlayerAlive)
  638. {
  639. if (ShouldRestartBeVisible(player))
  640. SetFocus(m_RestartButton);
  641. else
  642. SetFocus(m_ContinueButton);
  643. }
  644. else
  645. {
  646. SetFocus(m_RestartDeadButton);
  647. }
  648. }
  649. protected void UpdateControlsElements()
  650. {
  651. bool toolbarShow = false;
  652. #ifdef PLATFORM_CONSOLE
  653. toolbarShow = !GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER;
  654. #endif
  655. if (toolbarShow)
  656. {
  657. RichTextWidget toolbar_text = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ContextToolbarText"));
  658. string text = "";
  659. if (m_SelectAvailable)
  660. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUISelect", m_SelectButtonTextID, EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  661. if (m_MuteAvailable)
  662. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlX", m_CurrentMuteButtonText, EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  663. if (m_BackAvailable)
  664. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", m_BackButtonTextID, EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  665. if (m_GamercardAvailable)
  666. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlY", m_OpenGameCardButtonTextID, EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  667. toolbar_text.SetText(text);
  668. }
  669. RichTextWidget toolbar_b2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon0"));
  670. toolbar_b2.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER));
  671. bool onlineOpen = IsOnlineOpen();
  672. layoutRoot.FindAnyWidget("toolbar_bg").Show(toolbarShow);
  673. layoutRoot.FindAnyWidget("play_panel_root").Show(!onlineOpen);
  674. layoutRoot.FindAnyWidget("play_panel_root2").Show(onlineOpen && !toolbarShow);
  675. layoutRoot.FindAnyWidget("dayz_logo").Show(!onlineOpen);
  676. }
  677. }