Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SimpleKeybindDialogUI.c
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------------
2class SCR_SimpleKeybindDialogUI : SCR_KeybindDialogBase
3{
4 protected ref InputBinding m_Binding;
10
11 protected bool m_bShowOverrideWarning;
12
14
15 protected const string CLOSE_HINT = "#AR-Settings_KeybindSimple_CloseHint";
16
17 protected const string ACTION_MENU_BACK_KEYBIND = "MenuBackKeybind";
18 protected const string ACTION_DISPLAY_ROOT = "KeybindActionDisplayRow";
19
20 protected bool m_WasCanceled = false;
21
22 //------------------------------------------------------------------------------------------------
24 {
25 super.OnMenuOpen(preset);
26
27 if (m_Binding)
28 GetGame().GetInputManager().AddActionListener(ACTION_MENU_BACK_KEYBIND, EActionTrigger.DOWN, CancelCapture);
29
31
32 m_wActionName = RichTextWidget.Cast(m_wRoot.FindAnyWidget("ActionName"));
33 if (m_wActionName)
35
36 m_wActionRowSize = SizeLayoutWidget.Cast(m_wRoot.FindAnyWidget("ActionDisplayRowSize"));
37 m_wActionRowWrapper = m_wRoot.FindAnyWidget("ActionMainHorizontalLayout");
38 m_wCloseHint = RichTextWidget.Cast(m_wRoot.FindAnyWidget("CloseHintText"));
39 if (m_wCloseHint)
40 {
41 string device = UIConstants.DEVICE_KEYBOARD;
42 if (m_eDevice == EInputDeviceType.GAMEPAD)
43 device = UIConstants.DEVICE_GAMEPAD;
44
45 string actionText = string.Format(
46 "<action name='%1' scale='%2' state='%3'/>",
48 UIConstants.ACTION_DISPLAY_ICON_SCALE_VERY_BIG,
49 UIConstants.GetActionDisplayStateAttribute(SCR_EActionDisplayState.NON_INTERACTABLE_HINT)
50 );
51
52 m_wCloseHint.SetTextFormat(CLOSE_HINT, actionText);
53 }
54
55 SetMessageColor(Color.FromInt(UIColors.NEUTRAL_ACTIVE_STANDBY.PackToInt()));
56 GetMessageWidget().SetVisible(m_bShowOverrideWarning);
57
58 // Wait a frame for the action name text to be initialized, we need it's screen size
59 GetGame().GetCallqueue().Call(SetupActionDisplayFrameSkip);
60 }
61
62 //------------------------------------------------------------------------------------------------
63 override void OnMenuUpdate(float tDelta)
64 {
65 super.OnMenuUpdate(tDelta);
66
67 if (!m_Binding)
68 return;
69
70 if (m_Binding.GetCaptureState() == EInputBindingCaptureState.IDLE)
71 {
72 m_Binding.Save();
73
74 //if (!m_WasCanceled)
75 // SCR_AnalyticsApplication.GetInstance().ChangeKeybind(m_sActionName, m_Entry.m_sPreset);
76
78 m_OnKeyCaptured.Invoke(); //TODO: there is no "capturing cancelled" state nor check. This will be called upon closing the dialog as well. FIX
79
80 Close();
81 }
82 }
83
84 //------------------------------------------------------------------------------------------------
85 override void OnMenuClose()
86 {
87 super.OnMenuClose();
88
89 if (m_Binding && m_Binding.GetCaptureState() == EInputBindingCaptureState.CAPTURING)
90 m_Binding.CancelCapture();
91 }
92
93 //------------------------------------------------------------------------------------------------
95 {
96 GetGame().GetCallqueue().Call(SetupActionDisplay);
97 }
98
99 //------------------------------------------------------------------------------------------------
100 // Calculate Size allotted to action displays
101 protected void SetupActionDisplay()
102 {
104 return;
105
106 float textX, textY, wrapperX, wrapperY;
107 m_wActionName.GetScreenSize(textX, textY);
108 m_wActionRowWrapper.GetScreenSize(wrapperX, wrapperY);
109
110 m_wActionRowSize.SetWidthOverride(GetGame().GetWorkspace().DPIUnscale(wrapperX - textX));
112 }
113
114 //------------------------------------------------------------------------------------------------
115 protected void CancelCapture()
116 {
117 GetGame().GetInputManager().RemoveActionListener(ACTION_MENU_BACK_KEYBIND, EActionTrigger.DOWN, CancelCapture);
118 m_Binding.CancelCapture(); //TODO: capture is started by the row component but ended by the dialog. FIX
119 m_WasCanceled = true;
120 }
121
122 //------------------------------------------------------------------------------------------------
130
131 //------------------------------------------------------------------------------------------------
132 void SCR_SimpleKeybindDialogUI(SCR_KeyBindingEntry entry, string displayName, string actionName, InputBinding binding, EInputDeviceType device, bool showOverrideWarning)
133 {
134 Setup(entry, displayName, actionName, device);
135 m_Binding = binding;
136 m_bShowOverrideWarning = showOverrideWarning;
137 }
138}
ArmaReforgerScripted GetGame()
Definition game.c:1398
Widget m_wRoot
EInputDeviceType m_eDevice
SCR_SettingsManagerKeybindModule m_SettingsKeybindModule
class SCR_KeybindDialogs m_Entry
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
proto native void Close()
Definition Color.c:13
Manages input key bindings, presets, contexts, and device calibration. Provides functions for creatin...
static SCR_KeybindActionDisplayRowComponent FindComponentInHierarchy(notnull Widget w)
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
SCR_KeybindActionDisplayRowComponent m_ActionDisplayRow
override void OnMenuUpdate(float tDelta)
ref ScriptInvokerVoid m_OnKeyCaptured
void SCR_SimpleKeybindDialogUI(SCR_KeyBindingEntry entry, string displayName, string actionName, InputBinding binding, EInputDeviceType device, bool showOverrideWarning)
EActionTrigger
@ Setup
Definition TestStage.c:15