Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_KeybindActionDisplayComponent.c
Go to the documentation of this file.
1 /*
2 Component that takes care of displaying action bindings
3 Additional text will display the number of extra bindings associated with the action
4 */
5 
7 {
8  [Attribute(UIConstants.ACTION_DISPLAY_ICON_SCALE_BIG)]
9  float m_fActionIconScale;
10 
11  protected RichTextWidget m_wText;
12 
13  //TODO: cleanup: move the separator to the ActionDisplayRow
14  protected Widget m_wSeparator;
15  protected ref SCR_KeybindActionDisplayData m_ActionDisplayData;
16 
17  //------------------------------------------------------------------------------------------------
18  override void HandlerAttached(Widget w)
19  {
20  super.HandlerAttached(w);
21 
22  m_wText = RichTextWidget.Cast(m_wRoot.FindAnyWidget("Text"));
23  m_wSeparator = m_wRoot.FindAnyWidget("Separator");
24  }
25 
26  //------------------------------------------------------------------------------------------------
27  void UpdateActionDisplay(SCR_KeybindActionDisplayData data)
28  {
29  if (!data || !data.m_Entry || !data.m_SettingsKeybindModule)
30  return;
31 
32  SCR_KeyBindingEntry entry = data.m_Entry;
33 
34  string finalPreset;
35  string deviceString;
36  string actionName;
37  string preset;
38 
39  // Devices
40  if (data.m_eDevice == EInputDeviceType.GAMEPAD) // Gamepad setup
41  {
42  if (!entry.m_sActionNameGamepadOptional.IsEmpty())
43  actionName = entry.m_sActionNameGamepadOptional;
44  else
45  actionName = entry.m_sActionName;
46 
47  if (!entry.m_sPresetGamepadOptional.IsEmpty())
48  preset = entry.m_sPresetGamepadOptional;
49  else
50  preset = entry.m_sPreset;
51 
52  deviceString = data.m_SettingsKeybindModule.GetGamepadDeviceString();
53 
54  if (!preset.IsEmpty())
55  finalPreset = data.m_SettingsKeybindModule.GetGamepadPresetPrefix()+preset;
56  }
57  else if (data.m_eDevice == EInputDeviceType.KEYBOARD) // Keyboard & mouse setup
58  {
59  actionName = entry.m_sActionName;
60  preset = entry.m_sPreset;
61  deviceString = data.m_SettingsKeybindModule.GetKeyboardDeviceString();
62 
63  if (!preset.IsEmpty())
64  finalPreset = data.m_SettingsKeybindModule.GetPrimaryPresetPrefix()+preset;
65  }
66 
67  // Set Action text
68  if (m_wText)
69  {
70  string binding = string.Format(
71  "<action name='%1' preset='%2' device='%3' scale='%4' index='%5' state='%6'/>",
72  actionName,
73  finalPreset,
74  deviceString,
75  m_fActionIconScale.ToString(),
76  data.m_iIndex.ToString(),
77  UIConstants.GetActionDisplayStateAttribute(data.m_eState)
78  );
79 
80  m_wText.SetText(binding);
81  }
82 
83  // Store data, should we need to modify only one of them
84  m_ActionDisplayData = data;
85 
86  if (m_wSeparator)
87  m_wSeparator.SetVisible(data.m_iIndex < data.m_iLastIndex);
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  SCR_KeybindActionDisplayData GetActionDisplayData()
92  {
93  return m_ActionDisplayData;
94  }
95 
96  //------------------------------------------------------------------------------------------------
97  static SCR_KeybindActionDisplayComponent FindComponent(Widget w)
98  {
100  }
101 }
102 
104 {
105  SCR_KeyBindingEntry m_Entry;
107  EInputDeviceType m_eDevice;
108  SCR_EActionDisplayState m_eState;
109  int m_iIndex;
111 
112  //------------------------------------------------------------------------------------------------
113  void SCR_KeybindActionDisplayData(SCR_KeyBindingEntry entry, SCR_SettingsManagerKeybindModule settingsKeybindModule, EInputDeviceType device, SCR_EActionDisplayState state, int index = 0, int lastIndex = 0)
114  {
115  m_Entry = entry;
116  m_SettingsKeybindModule = settingsKeybindModule;
117  m_eDevice = device;
118  m_eState = state;
119  m_iIndex = index;
120  m_iLastIndex = lastIndex;
121  }
122 }
m_Entry
SCR_KeybindActionDisplayComponent m_Entry
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_KeybindActionDisplayComponent
Definition: SCR_KeybindActionDisplayComponent.c:6
UIConstants
Definition: Constants.c:130
SCR_SettingsManagerKeybindModule
Definition: SCR_SettingsManagerKeybindModule.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_iLastIndex
int m_iLastIndex
Definition: SCR_KeybindActionDisplayComponent.c:110
m_eState
SCR_EActionDisplayState m_eState
Definition: SCR_KeybindActionDisplayComponent.c:108
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_KeybindActionDisplayData
void SCR_KeybindActionDisplayData(SCR_KeyBindingEntry entry, SCR_SettingsManagerKeybindModule settingsKeybindModule, EInputDeviceType device, SCR_EActionDisplayState state, int index=0, int lastIndex=0)
Definition: SCR_KeybindActionDisplayComponent.c:113
m_SettingsKeybindModule
SCR_SettingsManagerKeybindModule m_SettingsKeybindModule
Definition: SCR_KeybindActionDisplayComponent.c:106
m_eDevice
EInputDeviceType m_eDevice
Definition: SCR_KeybindActionDisplayComponent.c:107
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
m_iIndex
int m_iIndex
Definition: SCR_KeybindActionDisplayComponent.c:109