Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_SimpleKeybindDialogUI.c
Go to the documentation of this file.
1
//---------------------------------------------------------------------------------------------
2
class
SCR_SimpleKeybindDialogUI
: SCR_KeybindDialogBase
3
{
4
protected
ref
InputBinding
m_Binding
;
5
protected
SCR_KeybindActionDisplayRowComponent
m_ActionDisplayRow
;
6
protected
RichTextWidget
m_wActionName
;
7
protected
SizeLayoutWidget
m_wActionRowSize
;
8
protected
Widget
m_wActionRowWrapper
;
9
protected
RichTextWidget
m_wCloseHint
;
10
11
protected
bool
m_bShowOverrideWarning
;
12
13
protected
ref
ScriptInvokerVoid
m_OnKeyCaptured
;
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
//------------------------------------------------------------------------------------------------
23
override
void
OnMenuOpen
(
SCR_ConfigurableDialogUiPreset
preset)
24
{
25
super.OnMenuOpen(preset);
26
27
if
(
m_Binding
)
28
GetGame
().GetInputManager().AddActionListener(
ACTION_MENU_BACK_KEYBIND
,
EActionTrigger
.DOWN,
CancelCapture
);
29
30
m_ActionDisplayRow
=
SCR_KeybindActionDisplayRowComponent
.
FindComponentInHierarchy
(
m_wRoot
);
31
32
m_wActionName
=
RichTextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"ActionName"
));
33
if
(
m_wActionName
)
34
m_wActionName
.SetText(
m_sDisplayName
);
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'/>"
,
47
ACTION_MENU_BACK_KEYBIND
,
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
77
if
(
m_OnKeyCaptured
)
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
//------------------------------------------------------------------------------------------------
94
protected
void
SetupActionDisplayFrameSkip
()
95
{
96
GetGame
().GetCallqueue().Call(
SetupActionDisplay
);
97
}
98
99
//------------------------------------------------------------------------------------------------
100
// Calculate Size allotted to action displays
101
protected
void
SetupActionDisplay
()
102
{
103
if
(!
m_wActionRowSize
|| !
m_wActionName
|| !
m_ActionDisplayRow
|| !
m_wActionRowWrapper
|| !
m_SettingsKeybindModule
)
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));
111
m_ActionDisplayRow
.CreateActionDisplays(
m_Entry
,
m_SettingsKeybindModule
,
m_eDevice
);
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
//------------------------------------------------------------------------------------------------
123
ScriptInvokerVoid
GetOnKeyCaptured
()
124
{
125
if
(!
m_OnKeyCaptured
)
126
m_OnKeyCaptured
=
new
ScriptInvokerVoid
();
127
128
return
m_OnKeyCaptured
;
129
}
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
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
m_eDevice
EInputDeviceType m_eDevice
Definition
SCR_KeybindDialogs.c:77
m_SettingsKeybindModule
SCR_SettingsManagerKeybindModule m_SettingsKeybindModule
Definition
SCR_KeybindDialogs.c:79
m_Entry
class SCR_KeybindDialogs m_Entry
ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition
SCR_ScriptInvokerHelper.c:9
m_sDisplayName
string m_sDisplayName
Definition
SCR_WeaponInfo_MultiWeaponTurret.c:953
Close
proto native void Close()
Definition
SCR_WorkshopDialogs.c:77
Color
Definition
Color.c:13
InputBinding
Manages input key bindings, presets, contexts, and device calibration. Provides functions for creatin...
Definition
InputBinding.c:24
RichTextWidget
Definition
RichTextWidget.c:13
SCR_ConfigurableDialogUiPreset
Configuration for a dialog.
Definition
SCR_ConfigurableDialogUI.c:764
SCR_KeybindActionDisplayRowComponent
Definition
SCR_KeybindActionDisplayRowComponent.c:8
SCR_KeybindActionDisplayRowComponent::FindComponentInHierarchy
static SCR_KeybindActionDisplayRowComponent FindComponentInHierarchy(notnull Widget w)
Definition
SCR_KeybindActionDisplayRowComponent.c:276
SCR_SimpleKeybindDialogUI::CancelCapture
void CancelCapture()
Definition
SCR_SimpleKeybindDialogUI.c:115
SCR_SimpleKeybindDialogUI::SetupActionDisplayFrameSkip
void SetupActionDisplayFrameSkip()
Definition
SCR_SimpleKeybindDialogUI.c:94
SCR_SimpleKeybindDialogUI::CLOSE_HINT
const string CLOSE_HINT
Definition
SCR_SimpleKeybindDialogUI.c:15
SCR_SimpleKeybindDialogUI::GetOnKeyCaptured
ScriptInvokerVoid GetOnKeyCaptured()
Definition
SCR_SimpleKeybindDialogUI.c:123
SCR_SimpleKeybindDialogUI::m_wCloseHint
RichTextWidget m_wCloseHint
Definition
SCR_SimpleKeybindDialogUI.c:9
SCR_SimpleKeybindDialogUI::OnMenuOpen
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
Definition
SCR_SimpleKeybindDialogUI.c:23
SCR_SimpleKeybindDialogUI::ACTION_DISPLAY_ROOT
const string ACTION_DISPLAY_ROOT
Definition
SCR_SimpleKeybindDialogUI.c:18
SCR_SimpleKeybindDialogUI::m_Binding
ref InputBinding m_Binding
Definition
SCR_SimpleKeybindDialogUI.c:4
SCR_SimpleKeybindDialogUI::m_ActionDisplayRow
SCR_KeybindActionDisplayRowComponent m_ActionDisplayRow
Definition
SCR_SimpleKeybindDialogUI.c:5
SCR_SimpleKeybindDialogUI::OnMenuUpdate
override void OnMenuUpdate(float tDelta)
Definition
SCR_SimpleKeybindDialogUI.c:63
SCR_SimpleKeybindDialogUI::m_WasCanceled
bool m_WasCanceled
Definition
SCR_SimpleKeybindDialogUI.c:20
SCR_SimpleKeybindDialogUI::m_wActionName
RichTextWidget m_wActionName
Definition
SCR_SimpleKeybindDialogUI.c:6
SCR_SimpleKeybindDialogUI::m_OnKeyCaptured
ref ScriptInvokerVoid m_OnKeyCaptured
Definition
SCR_SimpleKeybindDialogUI.c:13
SCR_SimpleKeybindDialogUI::m_bShowOverrideWarning
bool m_bShowOverrideWarning
Definition
SCR_SimpleKeybindDialogUI.c:11
SCR_SimpleKeybindDialogUI::m_wActionRowSize
SizeLayoutWidget m_wActionRowSize
Definition
SCR_SimpleKeybindDialogUI.c:7
SCR_SimpleKeybindDialogUI::OnMenuClose
override void OnMenuClose()
Definition
SCR_SimpleKeybindDialogUI.c:85
SCR_SimpleKeybindDialogUI::SCR_SimpleKeybindDialogUI
void SCR_SimpleKeybindDialogUI(SCR_KeyBindingEntry entry, string displayName, string actionName, InputBinding binding, EInputDeviceType device, bool showOverrideWarning)
Definition
SCR_SimpleKeybindDialogUI.c:132
SCR_SimpleKeybindDialogUI::SetupActionDisplay
void SetupActionDisplay()
Definition
SCR_SimpleKeybindDialogUI.c:101
SCR_SimpleKeybindDialogUI::m_wActionRowWrapper
Widget m_wActionRowWrapper
Definition
SCR_SimpleKeybindDialogUI.c:8
SCR_SimpleKeybindDialogUI::ACTION_MENU_BACK_KEYBIND
const string ACTION_MENU_BACK_KEYBIND
Definition
SCR_SimpleKeybindDialogUI.c:17
SizeLayoutWidget
Definition
SizeLayoutWidget.c:16
UIColors
Definition
Constants.c:17
UIConstants
Definition
Constants.c:151
Widget
Definition
Widget.c:13
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
EInputBindingCaptureState
EInputBindingCaptureState
Definition
EInputBindingCaptureState.c:13
Setup
@ Setup
Definition
TestStage.c:15
scripts
Game
UI
Menu
SettingsMenu
SCR_SimpleKeybindDialogUI.c
Generated by
1.17.0