4 protected ref InputBinding m_Binding;
6 protected RichTextWidget m_wActionName;
7 protected SizeLayoutWidget m_wActionRowSize;
8 protected Widget m_wActionRowWrapper;
9 protected RichTextWidget m_wCloseHint;
11 protected bool m_bShowOverrideWarning;
15 protected const string CLOSE_HINT =
"#AR-Settings_KeybindSimple_CloseHint";
17 protected const string ACTION_MENU_BACK_KEYBIND =
"MenuBackKeybind";
18 protected const string ACTION_DISPLAY_ROOT =
"KeybindActionDisplayRow";
23 super.OnMenuOpen(preset);
26 GetGame().GetInputManager().AddActionListener(ACTION_MENU_BACK_KEYBIND, EActionTrigger.DOWN, CancelCapture);
30 m_wActionName = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"ActionName"));
34 m_wActionRowSize = SizeLayoutWidget.Cast(
m_wRoot.FindAnyWidget(
"ActionDisplayRowSize"));
35 m_wActionRowWrapper =
m_wRoot.FindAnyWidget(
"ActionMainHorizontalLayout");
36 m_wCloseHint = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"CloseHintText"));
40 if (
m_eDevice == EInputDeviceType.GAMEPAD)
43 string actionText =
string.Format(
44 "<action name='%1' scale='%2' state='%3'/>",
45 ACTION_MENU_BACK_KEYBIND,
47 UIConstants.GetActionDisplayStateAttribute(SCR_EActionDisplayState.NON_INTERACTABLE_HINT)
50 m_wCloseHint.SetText(WidgetManager.Translate(CLOSE_HINT, actionText));
54 GetMessageWidget().SetVisible(m_bShowOverrideWarning);
57 GetGame().GetCallqueue().Call(SetupActionDisplayFrameSkip);
61 override void OnMenuUpdate(
float tDelta)
63 super.OnMenuUpdate(tDelta);
68 if (m_Binding.GetCaptureState() == EInputBindingCaptureState.IDLE)
73 m_OnKeyCaptured.Invoke();
80 protected void SetupActionDisplayFrameSkip()
82 GetGame().GetCallqueue().Call(SetupActionDisplay);
87 protected void SetupActionDisplay()
89 if (!m_wActionRowSize || !m_wActionName || !m_ActionDisplayRow || !m_wActionRowWrapper || !
m_SettingsKeybindModule)
92 float textX, textY, wrapperX, wrapperY;
93 m_wActionName.GetScreenSize(textX, textY);
94 m_wActionRowWrapper.GetScreenSize(wrapperX, wrapperY);
96 m_wActionRowSize.SetWidthOverride(
GetGame().GetWorkspace().DPIUnscale(wrapperX - textX));
101 protected void CancelCapture()
103 GetGame().GetInputManager().RemoveActionListener(ACTION_MENU_BACK_KEYBIND, EActionTrigger.DOWN, CancelCapture);
104 m_Binding.CancelCapture();
110 if (!m_OnKeyCaptured)
113 return m_OnKeyCaptured;
117 void SCR_SimpleKeybindDialogUI(SCR_KeyBindingEntry entry,
string displayName,
string actionName, InputBinding binding, EInputDeviceType device,
bool showOverrideWarning)
119 Setup(entry, displayName, actionName, device);
121 m_bShowOverrideWarning = showOverrideWarning;