16 protected int m_CurrentSettingKeyIndex = -1;
17 protected int m_CurrentSettingAlternateKeyIndex = -1;
22 const int MODAL_ID_BACK = 1337;
23 const int MODAL_ID_DEFAULT = 100;
24 const int MODAL_ID_DEFAULT_ALL = 101;
25 const int MODAL_ID_PRESET_CHANGE = 200;
26 const int MODAL_RESULT_DEFAULT_CURRENT = 0;
27 const int MODAL_RESULT_DEFAULT_ALL = 1;
32 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/pc/keybinding_menu.layout",
null);
34 m_Version =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"version"));
35 m_Apply =
ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"apply"));
37 m_Undo =
ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"undo"));
38 m_Defaults =
ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"reset"));
39 m_HardReset =
ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"reset_all"));
41 layoutRoot.FindAnyWidget(
"Tabber").GetScript(m_Tabber);
45#ifdef PLATFORM_CONSOLE
46 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
48 version =
"#main_menu_version" +
" " + version;
50 m_Version.SetText(version);
53 string back =
"circle";
58 toolbar_b.LoadImageFile(0,
"set:playstation_buttons image:" +
back);
61 InitInputSortingMap();
63 CreateGroupContainer();
65 InitPresets(-1, layoutRoot.FindAnyWidget(
"group_header"),
input);
66 m_Tabber.m_OnTabSwitch.Insert(UpdateTabContent);
67 m_Tabber.SelectTabControl(0);
68 m_Tabber.SelectTabPanel(0);
69 g_Game.SetKeyboardHandle(
this);
70 m_Tabber.RefreshTab(
true);
72 ColorDisabled(m_Apply);
74 ColorDisabled(m_Undo);
76 ColorWhite(m_Defaults,
null);
96 m_Tabber.AddTab(
Widget.TranslateString(
"#layout_pc_keybinding_unsorted"));
97 m_Tabber.DisableTabs(
true);
102 m_GroupsContainer =
new KeybindingsContainer(-1,
GetGame().
GetInput(), layoutRoot.FindAnyWidget(
"TabContentsHolder"),
this);
107 m_GroupsContainer.SwitchSubgroup(
tab_index);
112 ColorWhite(m_Apply,
null);
114 ColorWhite(m_Undo,
null);
120 ColorWhite(m_Apply,
null);
122 ColorWhite(m_Undo,
null);
128 m_CurrentSettingAlternateKeyIndex = -1;
134 m_GroupsContainer.CancelEnteringKeybind();
135 m_CurrentSettingKeyIndex = -1;
140 m_CurrentSettingKeyIndex = -1;
141 m_CurrentSettingAlternateKeyIndex =
key_index;
146 m_GroupsContainer.CancelEnteringAlternateKeybind();
147 m_CurrentSettingAlternateKeyIndex = -1;
152 m_CurrentSettingKeyIndex = -1;
153 ColorWhite(m_Apply,
null);
155 ColorWhite(m_Undo,
null);
161 m_CurrentSettingAlternateKeyIndex = -1;
162 ColorWhite(m_Apply,
null);
164 ColorWhite(m_Undo,
null);
173 if (m_GroupsContainer)
191 else if (
w == m_Undo)
196 else if (
w == m_Defaults)
201 else if (
w == m_HardReset)
212 ColorDisabled(m_Apply);
214 ColorDisabled(m_Undo);
216 ColorWhite(m_Defaults,
null);
219 m_GroupsContainer.Apply();
227 if (m_CurrentSettingKeyIndex != -1)
229 CancelEnteringKeybind();
233 if (m_CurrentSettingAlternateKeyIndex != -1)
235 CancelEnteringAlternateKeybind();
239 bool changed = m_GroupsContainer.IsChanged();
244 GetGame().GetUIManager().Back();
250 ColorDisabled(m_Apply);
252 ColorDisabled(m_Undo);
255 m_GroupsContainer.Reset();
272 case MODAL_RESULT_DEFAULT_CURRENT:
276 case MODAL_RESULT_DEFAULT_ALL:
281 ColorDisabled(m_Apply);
283 ColorDisabled(m_Undo);
286 m_GroupsContainer.Reset(
true);
291 if (
code == MODAL_ID_BACK)
296 GetGame().GetUIManager().Back();
300 else if (
code == MODAL_ID_DEFAULT)
303 PerformSetToDefaultsExt(MODAL_RESULT_DEFAULT_CURRENT);
306 else if (
code == MODAL_ID_DEFAULT_ALL)
309 PerformSetToDefaultsExt(MODAL_RESULT_DEFAULT_ALL);
311 else if (
code == MODAL_ID_PRESET_CHANGE)
316 m_PresetSelector.PerformSetOption(m_TargetPresetIndex);
328#ifdef PLATFORM_CONSOLE
329 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
331 version =
"#main_menu_version" +
" " + version;
333 m_Version.SetText(version);
390 return (
w == m_Apply ||
w ==
m_Back ||
w == m_Undo ||
w == m_Defaults ||
w == m_HardReset);
406#ifdef PLATFORM_WINDOWS
422#ifdef PLATFORM_WINDOWS
445 for (
int i = 0;
i <
input.GetProfilesCount();
i++)
453 m_PresetSelector =
new OptionSelectorMultistate(layoutRoot.FindAnyWidget(
"profile_setting_option"),
current_idx,
null,
false,
opt1);
454 m_PresetSelector.m_AttemptOptionChange.Insert(OnAttemptSelectPreset);
455 m_PresetSelector.m_OptionChanged.Insert(OnSelectKBPreset);
460 bool changed = m_GroupsContainer.IsChanged() && m_OriginalPresetIndex !=
index;
461 m_TargetPresetIndex =
index;
466 m_PresetSelector.SetCanSwitch(!
changed);
471 m_OriginalPresetIndex =
index;
472 m_GroupsContainer.OnSelectKBPreset(
index);
476 GetGame().GetMission().GetOnInputPresetChanged().Invoke();
484 return m_GroupsContainer;
494 PerformSetToDefaultsExt(MODAL_RESULT_DEFAULT_ALL);
bool IsFocusable(Widget w)
static int COLOR_NORMAL_TEXT
static int COLOR_DISABLED_TEXT
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
int ARGB(int a, int r, int g, int b)