Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FieldManualPiece_KeybindList.c
Go to the documentation of this file.
1[BaseContainerProps(), SCR_BaseContainerStaticTitleField(customTitle: "Keybind List")]
3{
4 [Attribute()]
5 protected ref array<ref SCR_FieldManualPiece_Keybind> m_aKeybinds;
6
7 [Attribute(defvalue: "{3D06849921063735}UI/layouts/Menus/FieldManual/Pieces/FieldManual_Piece_KeybindList.layout", uiwidget: UIWidgets.EditBoxWithButton, params: "layout")]
9
10 protected ref Widget m_KeybindsLayout;
11
12 //------------------------------------------------------------------------------------------------
13 override void CreateWidget(notnull Widget parent)
14 {
15 WorkspaceWidget workspace = GetGame().GetWorkspace();
16
17 Widget createdWidget = workspace.CreateWidgets(m_Layout, parent);
18 if (!createdWidget)
19 {
20 Print("could not create Keybind List widget | " + FilePath.StripPath(__FILE__) + ":" + __LINE__, LogLevel.WARNING);
21 return;
22 }
23
24 Widget keybindsLayout = SCR_WidgetHelper.GetWidgetOrChild(createdWidget, "KeybindsLayout");
25 if (!keybindsLayout)
26 return;
27
28 m_KeybindsLayout = keybindsLayout;
29
30 CreateKeybinds(!GetGame().GetInputManager().IsUsingMouseAndKeyboard());
31 GetGame().OnInputDeviceIsGamepadInvoker().Insert(CreateKeybinds);
32 }
33
34 //------------------------------------------------------------------------------------------------
35 protected void CreateKeybinds(bool isGamepad)
36 {
37 SCR_WidgetHelper.RemoveAllChildren(m_KeybindsLayout);
38
39 if (!m_aKeybinds || m_aKeybinds.IsEmpty())
40 return;
41
42 array<SCR_EInputTypeCondition> conditions = { SCR_EInputTypeCondition.ALL_INPUTS };
43
44 if (isGamepad)
45 conditions.Insert(SCR_EInputTypeCondition.GAMEPAD_ONLY);
46 else
47 conditions.Insert(SCR_EInputTypeCondition.KEYBOARD_ONLY);
48
49 array<ref SCR_FieldManualPiece_Keybind> arrayCopy = {};
51 {
52 if (conditions.Contains(keybind.m_eInputDisplayCondition))
53 arrayCopy.Insert(keybind);
54 }
55
56 if (arrayCopy.IsEmpty())
57 return;
58
59 int countMinus1 = arrayCopy.Count() - 1;
60 for (int i; i < countMinus1; i++)
61 {
62 arrayCopy[i].CreateWidget(m_KeybindsLayout, false);
63 }
64 arrayCopy[countMinus1].CreateWidget(m_KeybindsLayout, true);
65 }
66
67 //------------------------------------------------------------------------------------------------
68 // constructor
70 {
71 if (!m_aKeybinds) // can be config-provided
72 m_aKeybinds = {};
73 }
74
75 //------------------------------------------------------------------------------------------------
76 // destructor
78 {
80 GetGame().OnInputDeviceIsGamepadInvoker().Remove(CreateKeybinds);
81 }
82}
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptInvoker OnInputDeviceIsGamepadInvoker()
Definition game.c:238
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
InputManager GetInputManager()
SCR_EInputTypeCondition
Attribute to manually set a static title.
Definition Attributes.c:11
ref array< ref SCR_FieldManualPiece_Keybind > m_aKeybinds
override void CreateWidget(notnull Widget parent)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute