optionsmenu.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. class OptionsMenu extends UIScriptedMenu
  2. {
  3. const int MODAL_ID_DEFAULT = 100;
  4. const int DIALOG_TAB_OFFSET = 1400;
  5. protected TabberUI m_Tabber;
  6. protected ref OptionsMenuGame m_GameTab;
  7. protected ref OptionsMenuSounds m_SoundsTab;
  8. protected ref OptionsMenuVideo m_VideoTab;
  9. protected ref OptionsMenuControls m_ControlsTab;
  10. protected ref GameOptions m_Options;
  11. protected ButtonWidget m_Apply;
  12. protected ButtonWidget m_Back;
  13. protected ButtonWidget m_Reset; //undo
  14. protected ButtonWidget m_Defaults; //defaults
  15. protected Widget m_Details;
  16. protected TextWidget m_Version;
  17. protected int m_ActiveTabIdx = 0;
  18. protected bool m_ModalLock;
  19. protected bool m_CanApplyOrReset;
  20. protected bool m_CanToggle;
  21. void OptionsMenu()
  22. {
  23. }
  24. override Widget Init()
  25. {
  26. m_Options = new GameOptions();
  27. #ifdef PLATFORM_XBOX
  28. layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/options/xbox/options_menu.layout", null);
  29. #else
  30. #ifdef PLATFORM_PS4
  31. layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/options/ps/options_menu.layout", null);
  32. #else
  33. #ifdef PLATFORM_WINDOWS
  34. layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/options/pc/options_menu.layout", null);
  35. #endif
  36. #endif
  37. #endif
  38. layoutRoot.FindAnyWidget("Tabber").GetScript(m_Tabber);
  39. m_Details = layoutRoot.FindAnyWidget("settings_details");
  40. m_Version = TextWidget.Cast(layoutRoot.FindAnyWidget("version"));
  41. m_GameTab = new OptionsMenuGame(layoutRoot.FindAnyWidget("Tab_0"), m_Details, m_Options, this);
  42. m_SoundsTab = new OptionsMenuSounds(layoutRoot.FindAnyWidget("Tab_1"), m_Details, m_Options, this);
  43. #ifdef PLATFORM_XBOX
  44. m_ControlsTab = new OptionsMenuControls(layoutRoot.FindAnyWidget("Tab_2"), m_Details, m_Options, this);
  45. #else
  46. m_VideoTab = new OptionsMenuVideo(layoutRoot.FindAnyWidget("Tab_2"), m_Details, m_Options, this);
  47. m_ControlsTab = new OptionsMenuControls(layoutRoot.FindAnyWidget("Tab_3"), m_Details, m_Options, this);
  48. #endif
  49. m_Apply = ButtonWidget.Cast(layoutRoot.FindAnyWidget("apply"));
  50. m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget("back"));
  51. m_Reset = ButtonWidget.Cast(layoutRoot.FindAnyWidget("reset"));
  52. m_Defaults = ButtonWidget.Cast(layoutRoot.FindAnyWidget("defaults"));
  53. m_ModalLock = false;
  54. m_CanApplyOrReset = false;
  55. m_CanToggle = false;
  56. string version;
  57. GetGame().GetVersion(version);
  58. #ifdef PLATFORM_CONSOLE
  59. version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
  60. #else
  61. version = "#main_menu_version" + " " + version;
  62. #endif
  63. m_Version.SetText(version);
  64. #ifdef PLATFORM_WINDOWS
  65. SetFocus(layoutRoot);
  66. #else
  67. ToggleFocus();
  68. #endif
  69. m_Tabber.m_OnTabSwitch.Insert(OnTabSwitch);
  70. m_Tabber.m_OnAttemptTabSwitch.Insert(OnAttemptTabSwitch);
  71. GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
  72. GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
  73. OnChanged();
  74. return layoutRoot;
  75. }
  76. void ~OptionsMenu()
  77. {
  78. }
  79. protected void OnInputPresetChanged()
  80. {
  81. #ifdef PLATFORM_CONSOLE
  82. UpdateControlsElementVisibility();
  83. #endif
  84. }
  85. protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
  86. {
  87. #ifdef PLATFORM_CONSOLE
  88. UpdateControlsElementVisibility();
  89. #endif
  90. }
  91. override bool OnClick(Widget w, int x, int y, int button)
  92. {
  93. if (button == MouseState.LEFT)
  94. {
  95. switch (w)
  96. {
  97. case m_Apply:
  98. {
  99. Apply();
  100. return true;
  101. }
  102. case m_Back:
  103. {
  104. Back();
  105. return true;
  106. }
  107. case m_Reset:
  108. {
  109. ResetCurrentTab();
  110. return true;
  111. }
  112. case m_Defaults:
  113. {
  114. //SetToDefaults();
  115. PerformSetToDefaults();
  116. return true;
  117. }
  118. }
  119. }
  120. return false;
  121. }
  122. void OnTabSwitch(int tab)
  123. {
  124. switch (tab)
  125. {
  126. case 0:
  127. {
  128. m_GameTab.Focus();
  129. break;
  130. }
  131. case 1:
  132. {
  133. m_SoundsTab.Focus();
  134. break;
  135. }
  136. case 2:
  137. {
  138. #ifdef PLATFORM_XBOX
  139. m_ControlsTab.Focus();
  140. #else
  141. m_VideoTab.Focus();
  142. #endif
  143. break;
  144. }
  145. case 3:
  146. {
  147. #ifndef PLATFORM_XBOX
  148. m_ControlsTab.Focus();
  149. #endif
  150. break;
  151. }
  152. }
  153. m_ActiveTabIdx = tab;
  154. }
  155. void Apply()
  156. {
  157. if (m_ControlsTab.IsChanged())
  158. m_ControlsTab.Apply();
  159. if (m_SoundsTab.IsChanged())
  160. m_SoundsTab.Apply();
  161. if (m_GameTab.IsChanged())
  162. m_GameTab.Apply();
  163. if (m_Options.IsChanged() || m_GameTab.IsChanged())
  164. {
  165. m_Options.Test();
  166. m_Options.Apply();
  167. }
  168. // save input configuration
  169. GetUApi().Export();
  170. if (GetGame().GetInput().IsEnabledMouseAndKeyboard()) //useless on consoles
  171. {
  172. m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
  173. ColorDisable(m_Apply);
  174. m_Reset.SetFlags(WidgetFlags.IGNOREPOINTER);
  175. ColorDisable(m_Reset);
  176. }
  177. m_CanApplyOrReset = false;
  178. #ifdef PLATFORM_CONSOLE
  179. UpdateControlsElements();
  180. UpdateControlsElementVisibility();
  181. IngameHud hud;
  182. if (GetGame().GetMission() && Class.CastTo(hud,GetGame().GetMission().GetHud()))
  183. {
  184. hud.ShowQuickBar(GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
  185. }
  186. #endif
  187. if (m_Options.NeedRestart())
  188. g_Game.GetUIManager().ShowDialog("#main_menu_configure", "#menu_restart_needed", 117, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
  189. }
  190. void Back()
  191. {
  192. if (!g_Game.GetUIManager().IsDialogVisible() && !g_Game.GetUIManager().IsModalVisible())
  193. {
  194. if (IsAnyTabChanged())
  195. {
  196. g_Game.GetUIManager().ShowDialog("#main_menu_configure", "#main_menu_configure_desc", 1337, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
  197. #ifdef PLATFORM_CONSOLE
  198. UpdateControlsElements();
  199. #endif
  200. }
  201. else
  202. {
  203. m_Options.Revert();
  204. GetGame().EndOptionsVideo();
  205. GetGame().GetUIManager().Back();
  206. }
  207. }
  208. }
  209. void OnAttemptTabSwitch(int source, int target)
  210. {
  211. bool changed = IsAnyTabChanged();
  212. if (changed)
  213. {
  214. if (!g_Game.GetUIManager().IsDialogVisible() && !g_Game.GetUIManager().IsModalVisible())
  215. {
  216. int id = target + DIALOG_TAB_OFFSET;
  217. g_Game.GetUIManager().ShowDialog("#main_menu_configure", "#main_menu_configure_desc", id, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
  218. #ifdef PLATFORM_CONSOLE
  219. UpdateControlsElements();
  220. #endif
  221. }
  222. }
  223. else
  224. {
  225. ResetCurrentTab();
  226. }
  227. m_Tabber.SetCanSwitch(!changed);
  228. }
  229. bool IsAnyTabChanged()
  230. {
  231. bool changed = (m_Options.IsChanged() || m_GameTab.IsChanged() || m_SoundsTab.IsChanged() || m_ControlsTab.IsChanged());
  232. #ifndef PLATFORM_XBOX
  233. changed |= m_VideoTab.IsChanged();
  234. #endif
  235. return changed;
  236. }
  237. void OnChanged()
  238. {
  239. bool changed = IsAnyTabChanged();
  240. if (GetGame().GetInput().IsEnabledMouseAndKeyboard())
  241. {
  242. if (changed)
  243. {
  244. m_Reset.ClearFlags(WidgetFlags.IGNOREPOINTER);
  245. ColorNormal(m_Reset);
  246. m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
  247. ColorNormal(m_Apply);
  248. }
  249. else
  250. {
  251. m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
  252. ColorDisable(m_Apply);
  253. m_Reset.SetFlags(WidgetFlags.IGNOREPOINTER);
  254. ColorDisable(m_Reset);
  255. }
  256. }
  257. m_CanApplyOrReset = changed;
  258. #ifdef PLATFORM_CONSOLE
  259. UpdateControlsElements();
  260. UpdateControlsElementVisibility();
  261. #endif
  262. m_Tabber.AlignTabbers();
  263. }
  264. //resets it all
  265. void Reset()
  266. {
  267. m_Options.Revert();
  268. m_GameTab.Revert();
  269. m_SoundsTab.Revert();
  270. m_ControlsTab.Revert();
  271. #ifndef PLATFORM_XBOX
  272. m_VideoTab.Revert();
  273. #endif
  274. if (m_Options.IsChanged())
  275. m_Options.Revert();
  276. if (GetGame().GetInput().IsEnabledMouseAndKeyboard())
  277. {
  278. m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
  279. ColorDisable(m_Apply);
  280. m_Reset.SetFlags(WidgetFlags.IGNOREPOINTER);
  281. ColorDisable(m_Reset);
  282. }
  283. m_CanApplyOrReset = false;
  284. #ifdef PLATFORM_CONSOLE
  285. UpdateControlsElements();
  286. UpdateControlsElementVisibility();
  287. #endif
  288. }
  289. void ResetCurrentTab()
  290. {
  291. if (m_Options.IsChanged())
  292. {
  293. m_Options.Revert();
  294. }
  295. switch (m_ActiveTabIdx)
  296. {
  297. case 0:
  298. {
  299. m_GameTab.Revert();
  300. break;
  301. }
  302. case 1:
  303. {
  304. m_SoundsTab.Revert();
  305. break;
  306. }
  307. case 2:
  308. {
  309. #ifdef PLATFORM_XBOX
  310. m_ControlsTab.Revert();
  311. #else
  312. m_VideoTab.Revert();
  313. #endif
  314. break;
  315. }
  316. case 3:
  317. {
  318. #ifndef PLATFORM_XBOX
  319. m_ControlsTab.Revert();
  320. #endif
  321. break;
  322. }
  323. }
  324. if (m_Options.IsChanged())
  325. {
  326. m_Options.Revert();
  327. }
  328. if (GetGame().GetInput().IsEnabledMouseAndKeyboard())
  329. {
  330. m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
  331. ColorDisable(m_Apply);
  332. m_Reset.SetFlags(WidgetFlags.IGNOREPOINTER);
  333. ColorDisable(m_Reset);
  334. }
  335. m_CanApplyOrReset = false;
  336. #ifdef PLATFORM_CONSOLE
  337. UpdateControlsElements();
  338. UpdateControlsElementVisibility();
  339. #endif
  340. m_Tabber.AlignTabbers();
  341. }
  342. void SetToDefaults()
  343. {
  344. if (!g_Game.GetUIManager().IsDialogVisible() && !g_Game.GetUIManager().IsModalVisible())
  345. {
  346. g_Game.GetUIManager().ShowDialog("#menu_default_cap", "TODO - reset options to default", MODAL_ID_DEFAULT, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
  347. }
  348. }
  349. void PerformSetToDefaults()
  350. {
  351. switch (m_ActiveTabIdx)
  352. {
  353. case 0:
  354. m_GameTab.SetToDefaults();
  355. break;
  356. case 1:
  357. m_SoundsTab.SetToDefaults();
  358. break;
  359. case 2:
  360. #ifdef PLATFORM_XBOX
  361. m_ControlsTab.SetToDefaults();
  362. #else
  363. m_VideoTab.SetToDefaults();
  364. #endif
  365. break;
  366. case 3:
  367. #ifndef PLATFORM_XBOX
  368. m_ControlsTab.SetToDefaults();
  369. #endif
  370. break;
  371. }
  372. if (GetGame().GetInput().IsEnabledMouseAndKeyboard())
  373. {
  374. m_Reset.ClearFlags(WidgetFlags.IGNOREPOINTER);
  375. ColorNormal(m_Reset);
  376. m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
  377. ColorNormal(m_Apply);
  378. }
  379. m_CanApplyOrReset = true;
  380. #ifdef PLATFORM_CONSOLE
  381. UpdateControlsElements();
  382. UpdateControlsElementVisibility();
  383. #endif
  384. }
  385. void SliderFocus()
  386. {
  387. #ifdef PLATFORM_CONSOLE
  388. m_CanToggle = false;
  389. UpdateControlsElements();
  390. #endif
  391. }
  392. void ToggleFocus()
  393. {
  394. #ifdef PLATFORM_CONSOLE
  395. m_CanToggle = true;
  396. UpdateControlsElements();
  397. #endif
  398. }
  399. //! Controls visibility and sometimes even state of specific, dependent options across sub-menus
  400. void ToggleDependentOptions(int mode, bool state)
  401. {
  402. m_GameTab.ToggleDependentOptions(mode,state);
  403. m_SoundsTab.ToggleDependentOptions(mode,state);
  404. m_ControlsTab.ToggleDependentOptions(mode,state);
  405. #ifndef PLATFORM_XBOX
  406. m_VideoTab.ToggleDependentOptions(mode,state);
  407. #endif
  408. }
  409. void ReloadOptions()
  410. {
  411. m_Options = new GameOptions();
  412. if (m_GameTab)
  413. m_GameTab.SetOptions(m_Options);
  414. if (m_SoundsTab)
  415. m_SoundsTab.SetOptions(m_Options);
  416. if (m_ControlsTab)
  417. m_ControlsTab.SetOptions(m_Options);
  418. #ifndef PLATFORM_XBOX
  419. if (m_VideoTab)
  420. m_VideoTab.SetOptions(m_Options);
  421. #endif
  422. }
  423. void ReloadVideoOptions()
  424. {
  425. #ifndef PLATFORM_XBOX
  426. if (m_VideoTab)
  427. m_VideoTab.SetOptions(m_Options);
  428. #endif
  429. }
  430. override bool OnModalResult(Widget w, int x, int y, int code, int result)
  431. {
  432. bool ret = false;
  433. if (code == 1337)
  434. {
  435. if (result == 2)
  436. {
  437. m_Options.Revert();
  438. GetGame().EndOptionsVideo();
  439. GetGame().GetUIManager().Back();
  440. }
  441. ret = true;
  442. }
  443. else if (code == 117)
  444. {
  445. g_Game.RequestRestart(IDC_MAIN_QUIT);
  446. }
  447. else if (code == MODAL_ID_DEFAULT)
  448. {
  449. if (result == 2)
  450. {
  451. PerformSetToDefaults();
  452. }
  453. }
  454. else if (code >= DIALOG_TAB_OFFSET)
  455. {
  456. if (result == 2)
  457. {
  458. int id = code - DIALOG_TAB_OFFSET;
  459. //m_Options.Revert();
  460. ResetCurrentTab();
  461. m_Tabber.PerformSwitchTab(id);
  462. }
  463. ret = true;
  464. }
  465. m_ModalLock = ret; //prevents dialog being shown on the next update
  466. return ret;
  467. }
  468. override bool OnMouseEnter(Widget w, int x, int y)
  469. {
  470. if (w && IsFocusable(w))
  471. {
  472. ColorHighlight(w);
  473. return true;
  474. }
  475. return false;
  476. }
  477. override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
  478. {
  479. if (w && IsFocusable(w))
  480. {
  481. ColorNormal(w);
  482. return true;
  483. }
  484. return false;
  485. }
  486. override bool OnFocus(Widget w, int x, int y)
  487. {
  488. if (w && IsFocusable(w))
  489. {
  490. ColorHighlight(w);
  491. return true;
  492. }
  493. else if (y == 1)
  494. {
  495. SliderFocus();
  496. }
  497. else
  498. {
  499. ToggleFocus();
  500. }
  501. return false;
  502. }
  503. override bool OnFocusLost(Widget w, int x, int y)
  504. {
  505. if (w && IsFocusable(w))
  506. {
  507. ColorNormal(w);
  508. return true;
  509. }
  510. return false;
  511. }
  512. bool IsFocusable(Widget w)
  513. {
  514. if (w)
  515. {
  516. return (w == m_Apply || w == m_Back || w == m_Reset || w == m_Defaults);
  517. }
  518. return false;
  519. }
  520. override void Refresh()
  521. {
  522. string version;
  523. GetGame().GetVersion(version);
  524. #ifdef PLATFORM_CONSOLE
  525. version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
  526. #else
  527. version = "#main_menu_version" + " " + version;
  528. #endif
  529. m_Version.SetText(version);
  530. #ifdef PLATFORM_CONSOLE
  531. UpdateControlsElements();
  532. UpdateControlsElementVisibility();
  533. #endif
  534. }
  535. override void OnShow()
  536. {
  537. super.OnShow();
  538. m_GameTab.Focus();
  539. Refresh();
  540. }
  541. override void Update(float timeslice)
  542. {
  543. super.Update(timeslice);
  544. if (m_ModalLock)
  545. {
  546. m_ModalLock = false;
  547. #ifdef PLATFORM_CONSOLE
  548. UpdateControlsElements();
  549. #endif
  550. return;
  551. }
  552. if (g_Game.GetUIManager().IsDialogVisible())
  553. {
  554. return;
  555. }
  556. if (GetUApi().GetInputByID(UAUITabLeft).LocalPress())
  557. {
  558. m_Tabber.PreviousTab();
  559. }
  560. else if (GetUApi().GetInputByID(UAUITabRight).LocalPress())
  561. {
  562. m_Tabber.NextTab();
  563. }
  564. else if (GetUApi().GetInputByID(UAUICtrlX).LocalPress())
  565. {
  566. if (m_CanApplyOrReset)
  567. {
  568. Apply();
  569. }
  570. }
  571. else if (GetUApi().GetInputByID(UAUICredits).LocalPress())
  572. {
  573. if (m_CanApplyOrReset)
  574. {
  575. ResetCurrentTab();
  576. }
  577. }
  578. else if (GetUApi().GetInputByID(UAUICtrlY).LocalPress())
  579. {
  580. PerformSetToDefaults();
  581. }
  582. else if (GetUApi().GetInputByID(UAUIBack).LocalPress())
  583. {
  584. Back();
  585. }
  586. }
  587. //Coloring functions (Until WidgetStyles are useful)
  588. void ColorHighlight(Widget w)
  589. {
  590. if ((w.GetFlags() & WidgetFlags.IGNOREPOINTER) == WidgetFlags.IGNOREPOINTER)
  591. {
  592. return;
  593. }
  594. if (w.IsInherited(ButtonWidget))
  595. {
  596. ButtonWidget button = ButtonWidget.Cast(w);
  597. button.SetTextColor(ARGB(255, 200, 0, 0));
  598. }
  599. w.SetColor(ARGB(255, 0, 0, 0));
  600. TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
  601. TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
  602. TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
  603. ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() + "_image"));
  604. Widget option = Widget.Cast(w.FindAnyWidget(w.GetName() + "_option_wrapper"));
  605. Widget option_label = w.FindAnyWidget("option_label");
  606. if (text1)
  607. {
  608. text1.SetColor(ARGB(255, 255, 0, 0));
  609. }
  610. if (text2)
  611. {
  612. text2.SetColor(ARGB(255, 255, 0, 0));
  613. }
  614. if (text3)
  615. {
  616. text3.SetColor(ARGB(255, 255, 0, 0));
  617. w.SetAlpha(1);
  618. }
  619. if (image)
  620. {
  621. image.SetColor(ARGB(255, 200, 0, 0));
  622. }
  623. if (option)
  624. {
  625. option.SetColor(ARGB(255, 255, 0, 0));
  626. }
  627. if (option_label)
  628. {
  629. option_label.SetColor(ARGB(255, 255, 0, 0));
  630. }
  631. }
  632. void ColorNormal(Widget w)
  633. {
  634. if ((w.GetFlags() & WidgetFlags.IGNOREPOINTER) == WidgetFlags.IGNOREPOINTER)
  635. {
  636. return;
  637. }
  638. if (w.IsInherited(ButtonWidget))
  639. {
  640. ButtonWidget button = ButtonWidget.Cast(w);
  641. button.SetTextColor(ARGB(255, 255, 255, 255));
  642. }
  643. TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
  644. TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
  645. TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
  646. ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() + "_image"));
  647. Widget option = w.FindAnyWidget(w.GetName() + "_option_wrapper");
  648. Widget option_label = w.FindAnyWidget("option_label");
  649. if (text1)
  650. {
  651. text1.SetColor(ARGB(255, 255, 255, 255));
  652. }
  653. if (text2)
  654. {
  655. text2.SetColor(ARGB(255, 255, 255, 255));
  656. }
  657. if (text3)
  658. {
  659. text3.SetColor(ARGB(255, 255, 255, 255));
  660. w.SetAlpha(0);
  661. }
  662. if (image)
  663. {
  664. image.SetColor(ARGB(255, 255, 255, 255));
  665. }
  666. if (option)
  667. {
  668. option.SetColor(ARGB(150, 255, 255, 255));
  669. }
  670. if (option_label)
  671. {
  672. option_label.SetColor(ARGB(255, 255, 255, 255));
  673. }
  674. }
  675. void ColorDisable(Widget w)
  676. {
  677. #ifdef PLATFORM_WINDOWS
  678. SetFocus(null);
  679. #endif
  680. if (w)
  681. {
  682. ButtonWidget button = ButtonWidget.Cast(w);
  683. if (button)
  684. {
  685. button.SetTextColor(ColorManager.COLOR_DISABLED_TEXT);
  686. }
  687. }
  688. }
  689. protected void UpdateControlsElements()
  690. {
  691. #ifdef PLATFORM_CONSOLE
  692. RichTextWidget toolbar_text = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ContextToolbarText"));
  693. string text = "";
  694. if (g_Game.GetUIManager().IsDialogVisible() || g_Game.GetUIManager().IsDialogQueued())
  695. {
  696. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUISelect", "#dialog_confirm", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  697. }
  698. else
  699. {
  700. if (m_CanToggle)
  701. {
  702. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUISelect", "#dialog_change", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  703. }
  704. if (m_CanApplyOrReset)
  705. {
  706. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlX", "#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Apply_ApplyText0", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  707. }
  708. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlY", "#menu_default", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  709. if (m_CanApplyOrReset)
  710. {
  711. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICredits", "#menu_undo", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  712. }
  713. }
  714. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Back_BackText0", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  715. toolbar_text.SetText(text);
  716. RichTextWidget toolbar_b2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon0"));
  717. RichTextWidget toolbar_x2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ApplyIcon0"));
  718. RichTextWidget toolbar_y2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ResetIcon0"));
  719. RichTextWidget toolbar_def2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("DefaultIcon0"));
  720. toolbar_b2.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER));
  721. toolbar_x2.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlX", "", EUAINPUT_DEVICE_CONTROLLER));
  722. toolbar_y2.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUICredits", "", EUAINPUT_DEVICE_CONTROLLER));
  723. toolbar_def2.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlY", "", EUAINPUT_DEVICE_CONTROLLER));
  724. #endif
  725. }
  726. protected void UpdateControlsElementVisibility()
  727. {
  728. bool toolbarShow = false;
  729. #ifdef PLATFORM_CONSOLE
  730. toolbarShow = !GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER;
  731. #endif
  732. layoutRoot.FindAnyWidget("toolbar_bg").Show(toolbarShow);
  733. layoutRoot.FindAnyWidget("play_panel_root").Show(!toolbarShow);
  734. }
  735. }