6 protected string m_sActionPreset;
7 protected SCR_EActionPrefixType m_eActionPrefixType;
8 protected int m_iSelectedKeybind;
10 protected SCR_ModularButtonComponent m_FocusedBindRowButton;
11 protected ref array<SCR_ModularButtonComponent> m_aBindRowButtons = {};
13 protected Widget m_wPrefixesCombo;
15 protected const ResourceName KEYBIND_ROW_LAYOUT_PATH =
"{25888355688EE402}UI/layouts/Menus/SettingsMenu/BindingMenu/AdvancedKeybindActionRow.layout";
20 super.OnMenuOpen(preset);
27 m_Select.m_OnActivated.Insert(OnSelectButton);
28 m_Select.SetVisible(
false,
false);
33 button.m_OnActivated.Insert(ResetBindings);
37 button.m_OnActivated.Insert(DeleteSelectedBind);
41 button.m_OnActivated.Insert(UnbindAction);
46 SetupCombinationCombo();
53 override void OnMenuShow()
62 override void OnMenuFocusGained()
64 super.OnMenuFocusGained();
71 protected void ReselectRow()
73 if (!m_aBindRowButtons.IsIndexValid(m_iSelectedKeybind))
76 m_FocusedBindRowButton = m_aBindRowButtons[m_iSelectedKeybind];
77 GetGame().GetWorkspace().SetFocusedWidget(m_FocusedBindRowButton.GetRootWidget());
78 SetSelectedKeybind(m_aBindRowButtons[m_iSelectedKeybind]);
82 protected void ShowBindsForAction()
84 Widget contentWidget =
m_wRoot.FindAnyWidget(
"ScrollContent");
89 Widget children = contentWidget.GetChildren();
92 contentWidget.RemoveChild(children);
93 children = contentWidget.GetChildren();
102 m_aBindRowButtons.Clear();
104 SCR_ModularButtonComponent rowModularButtonComponent;
106 for (
int i = 0; i < bindCount; i++)
108 rowWidget =
GetGame().GetWorkspace().CreateWidgets(KEYBIND_ROW_LAYOUT_PATH, contentWidget);
118 rowModularButtonComponent = SCR_ModularButtonComponent.FindComponent(rowWidget);
119 if (!rowModularButtonComponent)
122 m_aBindRowButtons.Insert(rowModularButtonComponent);
123 rowModularButtonComponent.m_OnClicked.Insert(OnKeybindRowClick);
124 rowModularButtonComponent.m_OnFocus.Insert(OnKeybindRowFocus);
125 rowModularButtonComponent.m_OnFocusLost.Insert(OnKeybindRowFocusLost);
130 protected void ShowBindsForCurrentAction()
132 ShowBindsForAction();
135 m_iSelectedKeybind = m_aBindRowButtons.Count() - 1;
140 protected void SetSelectedKeybind(notnull SCR_ModularButtonComponent modularButtonComp)
142 Widget root = modularButtonComp.GetRootWidget();
147 if (!advancedKeybindComponent)
150 m_iSelectedKeybind = advancedKeybindComponent.GetKeybindIndex();
153 foreach (SCR_ModularButtonComponent comp : m_aBindRowButtons)
155 comp.SetToggled(comp == modularButtonComp,
false);
160 protected void ResetBindings()
164 ShowBindsForAction();
166 m_iSelectedKeybind = 0;
171 protected void DeleteSelectedBind()
175 ShowBindsForAction();
178 m_iSelectedKeybind = Math.Clamp(m_iSelectedKeybind - 1, 0, m_aBindRowButtons.Count() - 1);
183 protected void StartCapturingKeybind()
192 EInputDeviceType.KEYBOARD,
199 dialog.GetOnKeyCaptured().Insert(ShowBindsForCurrentAction);
203 protected void UnbindAction()
207 ShowBindsForAction();
209 m_iSelectedKeybind = 0;
214 protected void SetupCaptureButton()
216 ButtonWidget buttonWidget = ButtonWidget.Cast(
m_wRoot.FindAnyWidget(
"AddKeybind"));
224 buttonComp.SetEnabled(!m_sActionPreset.IsEmpty());
225 buttonComp.m_OnClicked.Insert(StartCapturingKeybind);
229 protected void SetupPrefixesCombo()
231 m_wPrefixesCombo =
m_wRoot.FindAnyWidget(
"ActionPrefixCombo");
232 if (!m_wPrefixesCombo)
234 Print(
"SCR_AdvancedKeybindDialogUI: Action prefix combo widget was not found", LogLevel.WARNING);
239 if (!comboBoxComponent)
246 comboBoxComponent.AddItem(filter.m_sFilterDisplayName);
249 comboBoxComponent.m_OnChanged.Insert(OnPrefixesComboChanged);
253 protected void SetupBindsCombo()
255 Widget systemBindCombo =
m_wRoot.FindAnyWidget(
"SystemKeyCombo");
256 if (!systemBindCombo)
258 Print(
"SCR_AdvancedKeybindDialogUI: System key combo widget was not found", LogLevel.WARNING);
262 if (!comboBoxComponent)
266 foreach (SCR_KeyBindingBind bind : binds)
268 comboBoxComponent.AddItem(bind.m_sBindDisplayName);
271 comboBoxComponent.m_OnChanged.Insert(OnBindsComboChanged);
275 protected void SetupCombinationCombo()
277 Widget combinationBindCombo =
m_wRoot.FindAnyWidget(
"ComboKeyCombo");
278 if (!combinationBindCombo)
280 Print(
"SCR_AdvancedKeybindDialogUI: Combination key combo widget was not found", LogLevel.WARNING);
285 if (!comboBoxComponent)
291 comboBoxComponent.AddItem(combo.m_sComboDisplayName);
294 comboBoxComponent.m_OnChanged.Insert(OnCombinationComboChanged);
302 ShowBindsForAction();
312 ShowBindsForAction();
315 m_iSelectedKeybind = m_aBindRowButtons.Count() - 1;
324 ShowBindsForAction();
332 if (m_FocusedBindRowButton)
333 SetSelectedKeybind(m_FocusedBindRowButton);
335 m_Select.SetVisible(
false,
false);
339 protected void OnKeybindRowClick(notnull SCR_ModularButtonComponent modularButtonComp)
341 if (m_FocusedBindRowButton &&
GetGame().
GetInputManager().GetLastUsedInputDevice() == EInputDeviceType.MOUSE)
342 SetSelectedKeybind(m_FocusedBindRowButton);
346 protected void OnKeybindRowFocus(SCR_ModularButtonComponent comp)
348 m_FocusedBindRowButton = comp;
350 Widget root = comp.GetRootWidget();
355 if (advancedKeybindComponent)
356 advancedKeybindComponent.StartScrolling();
358 if (m_Select && m_iSelectedKeybind != advancedKeybindComponent.GetKeybindIndex())
359 m_Select.SetVisible(
true,
false);
363 protected void OnKeybindRowFocusLost(SCR_ModularButtonComponent comp)
365 m_FocusedBindRowButton =
null;
368 m_Select.SetVisible(
false,
false);
370 Widget root = comp.GetRootWidget();
375 if (advancedKeybindComponent)
376 advancedKeybindComponent.StopScrolling();
380 void SCR_AdvancedKeybindDialogUI(SCR_KeyBindingEntry entry,
string displayName,
string actionName,
string actionPreset, SCR_EActionPrefixType prefixType)
382 Setup(entry, displayName, actionName, EInputDeviceType.KEYBOARD);
383 m_sActionPreset = actionPreset;
384 m_eActionPrefixType = prefixType;