Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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")]
8  protected ResourceName m_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 = {};
50  foreach (SCR_FieldManualPiece_Keybind keybind : m_aKeybinds)
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 }
SCR_BaseContainerStaticTitleField
Attribute to manually set a static title.
Definition: Attributes.c:10
SCR_FieldManualPiece
Definition: SCR_FieldManualPiece.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_FieldManualPiece_Keybind
Definition: SCR_FieldManualPiece_Keybind.c:2
m_Layout
ResourceName m_Layout
Definition: SCR_ActionsToolbarEditorUIComponent.c:6
SCR_WidgetHelper
Definition: SCR_WidgetHelper.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_EInputTypeCondition
SCR_EInputTypeCondition
Definition: SCR_EInputTypeCondition.c:1
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
SCR_FieldManualPiece_KeybindList
Definition: SCR_FieldManualPiece_KeybindList.c:2
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
OnInputDeviceIsGamepadInvoker
ScriptInvoker OnInputDeviceIsGamepadInvoker()
Definition: game.c:246
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468