Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AdvancedActionRowComponent.c
Go to the documentation of this file.
2 {
3  [Attribute(UIColors.GetColorAttribute(UIColors.NEUTRAL_ACTIVE_STANDBY))]
4  protected ref Color m_ActionColor;
5 
6  [Attribute("1")]
7  protected bool m_bShowConflictsList;
8 
9  [Attribute(UIConstants.ACTION_DISPLAY_ICON_SCALE_BIG)]
10  protected float m_fActionIconScale;
11 
12  [Attribute("0", UIWidgets.ComboBox, "Determines the colors of the rich text action icons", "", ParamEnumArray.FromEnum(SCR_EActionDisplayState))]
13  protected SCR_EActionDisplayState m_eActionIconState;
14 
15  protected int m_iKeybindIndex;
16 
17  protected RichTextWidget m_wActionBindRichText;
18  protected RichTextWidget m_wIndexRichText;
19  protected RichTextWidget m_wWarningRichText;
20  protected RichTextWidget m_wActionsRichText;
21 
22  protected SCR_HorizontalScrollAnimationComponent m_HorizontalScrollComponent;
23 
24  protected const string ROOT_NAME = "AdvancedKeybindActionDisplay";
25 
26  //------------------------------------------------------------------------------------------------
27  override void HandlerAttached(Widget w)
28  {
29  super.HandlerAttached(w);
30 
31  m_wActionBindRichText = RichTextWidget.Cast(m_wRoot.FindAnyWidget("ActionRichText"));
32  m_wIndexRichText = RichTextWidget.Cast(m_wRoot.FindAnyWidget("IndexRichText"));
33  m_wWarningRichText = RichTextWidget.Cast(m_wRoot.FindAnyWidget("WarningText"));
34  m_wActionsRichText = RichTextWidget.Cast(m_wRoot.FindAnyWidget("WarningActions"));
35 
36  Widget frame = m_wRoot.FindAnyWidget("HorizontalScrollFrame");
37  if (frame)
38  m_HorizontalScrollComponent = SCR_HorizontalScrollAnimationComponent.FindComponent(frame);
39 
40  if (m_HorizontalScrollComponent)
41  StopScrolling();
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  // Displays the action's specified bind for the chosen device and conflicting occurrances
46  void Init(string actionName, string actionPreset, int index, SCR_SettingsManagerKeybindModule settingsKeybindModule, EInputDeviceType device)
47  {
48  m_iKeybindIndex = index;
49 
50  string deviceString = settingsKeybindModule.GetKeyboardDeviceString();
51  if (device == EInputDeviceType.GAMEPAD)
52  deviceString = settingsKeybindModule.GetGamepadDeviceString();
53 
54  if (m_wActionBindRichText)
55  m_wActionBindRichText.SetText(string.Format(
56  "<action name='%1' preset='%2' index='%3' device='%4' scale='%5' state ='%6'/>",
57  actionName,
58  actionPreset,
59  index,
60  deviceString,
61  m_fActionIconScale.ToString(),
62  UIConstants.GetActionDisplayStateAttribute(m_eActionIconState)
63  ));
64 
65  if (!m_wIndexRichText)
66  return;
67 
68  //offset index by 1 so it's comfortable for humans
69  int order = m_iKeybindIndex + 1;
70 
71  //todo: check how localization deals with the dot: Updated with Wlib - removing "."
72  if (m_wIndexRichText)
73  m_wIndexRichText.SetText(order.ToString() + ".");
74 
75  //check for conflicts and deal with them if they exist
76  array<SCR_KeyBindingEntry> conflictedActions = {};
77  bool conflicted = m_bShowConflictsList && settingsKeybindModule.IsActionConflicted(actionName, conflictedActions, m_iKeybindIndex, actionPreset);
78 
79  if (m_wWarningRichText)
80  m_wWarningRichText.SetVisible(conflicted);
81 
82  if (m_wActionsRichText)
83  m_wActionsRichText.SetVisible(conflicted);
84 
85  if (!conflicted || !m_wActionsRichText)
86  return;
87 
88  string actionNames = conflictedActions.Get(0).m_sDisplayName;
89 
90  for (int i = 1, count = conflictedActions.Count(); i < count; i++)
91  {
92  actionNames = actionNames + ", " + conflictedActions.Get(i).m_sDisplayName;
93  }
94 
95  m_wActionsRichText.SetText(actionNames);
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  int GetKeybindIndex()
100  {
101  return m_iKeybindIndex;
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  void StartScrolling()
106  {
107  if (!m_HorizontalScrollComponent)
108  return;
109 
110  m_HorizontalScrollComponent.AnimationStart();
111  }
112 
113  //------------------------------------------------------------------------------------------------
114  void StopScrolling()
115  {
116  if (!m_HorizontalScrollComponent)
117  return;
118 
119  m_HorizontalScrollComponent.AnimationStop();
120  m_HorizontalScrollComponent.ResetPosition();
121  }
122 
123  //------------------------------------------------------------------------------------------------
124  static SCR_AdvancedActionRowComponent FindComponent(notnull Widget w)
125  {
127  }
128 
129  //------------------------------------------------------------------------------------------------
130  static SCR_AdvancedActionRowComponent FindComponentInHierarchy(notnull Widget w)
131  {
132  Widget actionRoot = w.FindAnyWidget(ROOT_NAME);
133  if (!actionRoot)
134  return null;
135 
136  return SCR_AdvancedActionRowComponent.FindComponent(actionRoot);
137  }
138 }
SCR_HorizontalScrollAnimationComponent
Definition: SCR_HorizontalScrollAnimationComponent.c:14
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
UIConstants
Definition: Constants.c:130
SCR_SettingsManagerKeybindModule
Definition: SCR_SettingsManagerKeybindModule.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
UIColors
Definition: Constants.c:16
SCR_AdvancedActionRowComponent
Definition: SCR_AdvancedActionRowComponent.c:1
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7