3 const int MODAL_ID_DEFAULT = 100;
4 const int DIALOG_TAB_OFFSET = 1400;
6 protected TabberUI m_Tabber;
7 protected ref OptionsMenuGame m_GameTab;
8 protected ref OptionsMenuSounds m_SoundsTab;
9 protected ref OptionsMenuVideo m_VideoTab;
10 protected ref OptionsMenuControls m_ControlsTab;
14 protected ButtonWidget m_Apply;
15 protected ButtonWidget
m_Back;
16 protected ButtonWidget m_Reset;
17 protected ButtonWidget m_Defaults;
19 protected Widget m_Details;
22 protected int m_ActiveTabIdx = 0;
23 protected bool m_ModalLock;
24 protected bool m_CanApplyOrReset;
25 protected bool m_CanToggle;
37 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/xbox/options_menu.layout",
null);
40 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/ps/options_menu.layout",
null);
42 #ifdef PLATFORM_WINDOWS
43 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/pc/options_menu.layout",
null);
48 layoutRoot.FindAnyWidget(
"Tabber").GetScript(m_Tabber);
50 m_Details = layoutRoot.FindAnyWidget(
"settings_details");
51 m_Version =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"version"));
53 m_GameTab =
new OptionsMenuGame(layoutRoot.FindAnyWidget(
"Tab_0"), m_Details, m_Options,
this);
54 m_SoundsTab =
new OptionsMenuSounds(layoutRoot.FindAnyWidget(
"Tab_1"), m_Details, m_Options,
this);
57 m_ControlsTab =
new OptionsMenuControls(layoutRoot.FindAnyWidget(
"Tab_2"), m_Details, m_Options,
this);
59 m_VideoTab =
new OptionsMenuVideo(layoutRoot.FindAnyWidget(
"Tab_2"), m_Details, m_Options,
this);
60 m_ControlsTab =
new OptionsMenuControls(layoutRoot.FindAnyWidget(
"Tab_3"), m_Details, m_Options,
this);
63 m_Apply = ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"apply"));
64 m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"back"));
65 m_Reset = ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"reset"));
66 m_Defaults = ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"defaults"));
69 m_CanApplyOrReset =
false;
74 #ifdef PLATFORM_CONSOLE
75 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
77 version =
"#main_menu_version" +
" " + version;
79 m_Version.SetText(version);
81 #ifdef PLATFORM_WINDOWS
87 m_Tabber.m_OnTabSwitch.Insert(OnTabSwitch);
88 m_Tabber.m_OnAttemptTabSwitch.Insert(OnAttemptTabSwitch);
103 #ifdef PLATFORM_CONSOLE
110 #ifdef PLATFORM_CONSOLE
139 PerformSetToDefaults();
147 void OnTabSwitch(
int tab)
164 m_ControlsTab.Focus();
172 #ifndef PLATFORM_XBOX
173 m_ControlsTab.Focus();
179 m_ActiveTabIdx = tab;
184 m_ControlsTab.Apply();
186 if (m_GameTab.IsChanged())
191 if (m_Options.IsChanged() || m_GameTab.IsChanged())
208 m_CanApplyOrReset =
false;
209 #ifdef PLATFORM_CONSOLE
216 hud.ShowQuickBar(
GetGame().
GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
220 if (m_Options.NeedRestart())
221 g_Game.GetUIManager().ShowDialog(
"#main_menu_configure",
"#menu_restart_needed", 117, DBT_YESNO, DBB_YES, DMT_QUESTION,
this);
226 if (!
g_Game.GetUIManager().IsDialogVisible() && !
g_Game.GetUIManager().IsModalVisible())
228 if (IsAnyTabChanged())
230 g_Game.GetUIManager().ShowDialog(
"#main_menu_configure",
"#main_menu_configure_desc", 1337, DBT_YESNO, DBB_YES, DMT_QUESTION,
this);
231 #ifdef PLATFORM_CONSOLE
239 GetGame().GetUIManager().Back();
244 void OnAttemptTabSwitch(
int source,
int target)
246 bool changed = IsAnyTabChanged();
249 if (!
g_Game.GetUIManager().IsDialogVisible() && !
g_Game.GetUIManager().IsModalVisible())
251 int id = target + DIALOG_TAB_OFFSET;
252 g_Game.GetUIManager().ShowDialog(
"#main_menu_configure",
"#main_menu_configure_desc",
id, DBT_YESNO, DBB_YES, DMT_QUESTION,
this);
253 #ifdef PLATFORM_CONSOLE
263 m_Tabber.SetCanSwitch(!changed);
266 bool IsAnyTabChanged()
268 bool changed = (m_Options.IsChanged() || m_GameTab.IsChanged() || m_SoundsTab.IsChanged() || m_ControlsTab.IsChanged());
269 #ifndef PLATFORM_XBOX
270 changed |= m_VideoTab.IsChanged();
278 bool changed = IsAnyTabChanged();
298 m_CanApplyOrReset = changed;
299 #ifdef PLATFORM_CONSOLE
304 m_Tabber.AlignTabbers();
312 m_SoundsTab.Revert();
313 m_ControlsTab.Revert();
314 #ifndef PLATFORM_XBOX
318 if (m_Options.IsChanged())
329 m_CanApplyOrReset =
false;
330 #ifdef PLATFORM_CONSOLE
336 void ResetCurrentTab()
338 if (m_Options.IsChanged())
343 switch (m_ActiveTabIdx)
352 m_SoundsTab.Revert();
358 m_ControlsTab.Revert();
366 #ifndef PLATFORM_XBOX
367 m_ControlsTab.Revert();
373 if (m_Options.IsChanged())
386 m_CanApplyOrReset =
false;
387 #ifdef PLATFORM_CONSOLE
392 m_Tabber.AlignTabbers();
397 if (!
g_Game.GetUIManager().IsDialogVisible() && !
g_Game.GetUIManager().IsModalVisible())
399 g_Game.GetUIManager().ShowDialog(
"#menu_default_cap",
"TODO - reset options to default", MODAL_ID_DEFAULT, DBT_YESNO, DBB_YES, DMT_QUESTION,
this);
403 void PerformSetToDefaults()
405 switch (m_ActiveTabIdx)
408 m_GameTab.SetToDefaults();
412 m_SoundsTab.SetToDefaults();
417 m_ControlsTab.SetToDefaults();
419 m_VideoTab.SetToDefaults();
424 #ifndef PLATFORM_XBOX
425 m_ControlsTab.SetToDefaults();
438 m_CanApplyOrReset =
true;
439 #ifdef PLATFORM_CONSOLE
447 #ifdef PLATFORM_CONSOLE
455 #ifdef PLATFORM_CONSOLE
462 void ToggleDependentOptions(
int mode,
bool state)
464 m_GameTab.ToggleDependentOptions(mode,state);
465 m_SoundsTab.ToggleDependentOptions(mode,state);
466 m_ControlsTab.ToggleDependentOptions(mode,state);
467 #ifndef PLATFORM_XBOX
468 m_VideoTab.ToggleDependentOptions(mode,state);
477 m_GameTab.SetOptions(m_Options);
479 m_SoundsTab.SetOptions(m_Options);
481 m_ControlsTab.SetOptions(m_Options);
483 #ifndef PLATFORM_XBOX
485 m_VideoTab.SetOptions(m_Options);
489 void ReloadVideoOptions()
491 #ifndef PLATFORM_XBOX
493 m_VideoTab.SetOptions(m_Options);
497 override bool OnModalResult(
Widget w,
int x,
int y,
int code,
int result)
507 GetGame().GetUIManager().Back();
511 else if (code == 117)
515 else if (code == MODAL_ID_DEFAULT)
519 PerformSetToDefaults();
522 else if (code >= DIALOG_TAB_OFFSET)
526 int id = code - DIALOG_TAB_OFFSET;
529 m_Tabber.PerformSwitchTab(
id);
591 return (w == m_Apply || w ==
m_Back || w == m_Reset || w == m_Defaults);
600 #ifdef PLATFORM_CONSOLE
601 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
603 version =
"#main_menu_version" +
" " + version;
606 m_Version.SetText(version);
608 #ifdef PLATFORM_CONSOLE
621 override void Update(
float timeslice)
623 super.Update(timeslice);
628 #ifdef PLATFORM_CONSOLE
634 if (
g_Game.GetUIManager().IsDialogVisible())
639 if (
GetUApi().GetInputByID(UAUITabLeft).LocalPress())
641 m_Tabber.PreviousTab();
643 else if (
GetUApi().GetInputByID(UAUITabRight).LocalPress())
647 else if (
GetUApi().GetInputByID(UAUICtrlX).LocalPress())
649 if (m_CanApplyOrReset)
654 else if (
GetUApi().GetInputByID(UAUICredits).LocalPress())
656 if (m_CanApplyOrReset)
662 else if (
GetUApi().GetInputByID(UAUICtrlY).LocalPress())
664 PerformSetToDefaults();
666 else if (
GetUApi().GetInputByID(UAUIBack).LocalPress())
680 if (w.IsInherited(ButtonWidget))
682 ButtonWidget button = ButtonWidget.Cast(w);
683 button.SetTextColor(
ARGB(255, 200, 0, 0));
686 w.SetColor(
ARGB(255, 0, 0, 0));
691 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() +
"_image"));
692 Widget option =
Widget.Cast(w.FindAnyWidget(w.GetName() +
"_option_wrapper"));
693 Widget option_label = w.FindAnyWidget(
"option_label");
697 text1.SetColor(
ARGB(255, 255, 0, 0));
702 text2.SetColor(
ARGB(255, 255, 0, 0));
707 text3.SetColor(
ARGB(255, 255, 0, 0));
713 image.SetColor(
ARGB(255, 200, 0, 0));
718 option.SetColor(
ARGB(255, 255, 0, 0));
723 option_label.SetColor(
ARGB(255, 255, 0, 0));
734 if (w.IsInherited(ButtonWidget))
736 ButtonWidget button = ButtonWidget.Cast(w);
737 button.SetTextColor(
ARGB(255, 255, 255, 255));
743 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() +
"_image"));
744 Widget option = w.FindAnyWidget(w.GetName() +
"_option_wrapper");
745 Widget option_label = w.FindAnyWidget(
"option_label");
749 text1.SetColor(
ARGB(255, 255, 255, 255));
754 text2.SetColor(
ARGB(255, 255, 255, 255));
759 text3.SetColor(
ARGB(255, 255, 255, 255));
765 image.SetColor(
ARGB(255, 255, 255, 255));
770 option.SetColor(
ARGB(150, 255, 255, 255));
775 option_label.SetColor(
ARGB(255, 255, 255, 255));
781 #ifdef PLATFORM_WINDOWS
787 ButtonWidget button = ButtonWidget.Cast(w);
797 #ifdef PLATFORM_CONSOLE
800 if (
g_Game.GetUIManager().IsDialogVisible() ||
g_Game.GetUIManager().IsDialogQueued())
802 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUISelect",
"#dialog_confirm", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
809 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUISelect",
"#dialog_change", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
811 if (m_CanApplyOrReset)
813 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlX",
"#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Apply_ApplyText0", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
815 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlY",
"#menu_default", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
816 if (m_CanApplyOrReset)
818 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICredits",
"#menu_undo", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
821 text +=
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIBack",
"#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Back_BackText0", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
822 toolbar_text.SetText(text);
828 toolbar_b2.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIBack",
"", EUAINPUT_DEVICE_CONTROLLER));
829 toolbar_x2.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlX",
"", EUAINPUT_DEVICE_CONTROLLER));
830 toolbar_y2.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICredits",
"", EUAINPUT_DEVICE_CONTROLLER));
831 toolbar_def2.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlY",
"", EUAINPUT_DEVICE_CONTROLLER));
837 bool toolbarShow =
false;
838 #ifdef PLATFORM_CONSOLE
839 toolbarShow = !
GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() ||
GetGame().GetInput().GetCurrentInputDevice() ==
EInputDeviceType.CONTROLLER;
842 layoutRoot.FindAnyWidget(
"toolbar_bg").Show(toolbarShow);
843 layoutRoot.FindAnyWidget(
"play_panel_root").Show(!toolbarShow);