Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_HUDLayout.c
Go to the documentation of this file.
1 [BaseContainerProps(configRoot: true)]
3 {
4  protected ref array<ref Widget> m_aAllGroups = {};
5  protected ref array<ref SCR_HUDElement> m_aElements = {};
6 
7  [Attribute()]
8  protected string m_sIdentifier;
9 
10  [Attribute(params: "layout")]
11  protected ResourceName m_sLayout;
12 
13  protected Widget m_wRoot;
14 
15  //------------------------------------------------------------------------------------------------
16  void SetIdentifier(string id)
17  {
18  if (id == string.Empty)
19  return;
20 
21  PlayerController pController = GetGame().GetPlayerController();
22  if (!pController)
23  return;
24 
25  SCR_HUDManagerComponent hudManager = SCR_HUDManagerComponent.Cast(pController.FindComponent(SCR_HUDManagerComponent));
26  if (!hudManager)
27  return;
28 
29  SCR_HUDManagerLayoutHandler layoutHandler = SCR_HUDManagerLayoutHandler.Cast(hudManager.FindHandler(SCR_HUDManagerLayoutHandler));
30  if (!layoutHandler)
31  return;
32 
33  array <string> allIdentifiers = layoutHandler.GetAllIdentifiers();
34 
35  if (allIdentifiers.Contains(id))
36  {
37  Print("HUDManager: Identifier: " + id + " is already used! Check if your Identifier is Unique!", LogLevel.ERROR);
38  return;
39  }
40 
41  m_sIdentifier = id;
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  int GetHUDElements(notnull out array<SCR_HUDElement> hudElements)
46  {
47  foreach (SCR_HUDElement element : m_aElements)
48  {
49  hudElements.Insert(element);
50  }
51 
52  return hudElements.Count();
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  string GetIdentifier()
57  {
58  return m_sIdentifier;
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  ResourceName GetLayout()
63  {
64  return m_sLayout;
65  }
66 
67  //------------------------------------------------------------------------------------------------
68  Widget GetRootWidget()
69  {
70  return m_wRoot;
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  void SetRootWidget(notnull Widget widget)
75  {
76  m_wRoot = widget;
77 
78  Widget iteratedWidget = m_wRoot.GetChildren();
79  while (iteratedWidget)
80  {
81  Widget iteratedChildWidget = iteratedWidget.GetChildren();
82  while (iteratedChildWidget)
83  {
84  SCR_HUDGroupUIComponent groupComponent = SCR_HUDGroupUIComponent.Cast(iteratedChildWidget.FindHandler(SCR_HUDGroupUIComponent));
85  if (!groupComponent)
86  {
87  iteratedChildWidget = iteratedChildWidget.GetSibling();
88  continue;
89  }
90 
91  m_aAllGroups.Insert(iteratedChildWidget);
92  iteratedChildWidget = iteratedChildWidget.GetSibling();
93  }
94 
95  iteratedWidget = iteratedWidget.GetSibling();
96  }
97  }
98 
99  //------------------------------------------------------------------------------------------------
100  void ResizeLayout()
101  {
102  array<SCR_HUDGroupUIComponent> groupsInLayout = {};
103  GetAllGroupComponents(groupsInLayout);
104 
105  foreach (SCR_HUDGroupUIComponent groupComponent : groupsInLayout)
106  {
107  groupComponent.ResizeGroup();
108  }
109  }
110 
111  //------------------------------------------------------------------------------------------------
112  void AddHudElement(notnull SCR_HUDElement element, bool replaceParent = false)
113  {
114  if (!m_wRoot)
115  return;
116 
117  Widget slotWidget = element.GetWidget();
118  if (!slotWidget)
119  return;
120 
121  Widget parentWidget = m_wRoot.FindAnyWidget(element.GetParentWidgetName());
122  if (!parentWidget)
123  return;
124 
125  if (replaceParent)
126  parentWidget.AddChild(slotWidget);
127 
128  m_aElements.Insert(element);
129  element.SetParentLayout(this);
130  }
131 
132  //------------------------------------------------------------------------------------------------
133  void RemoveHudElement(notnull SCR_HUDElement element, bool replaceParent = false)
134  {
135  Widget elementWidget = element.GetWidget();
136  if (!elementWidget)
137  return;
138 
139  Widget parentWidget = elementWidget.GetParent();
140  if (replaceParent && parentWidget)
141  parentWidget.RemoveChild(elementWidget);
142 
143  m_aElements.RemoveItem(element);
144  }
145 
146  //------------------------------------------------------------------------------------------------
151  Widget GetGroupWidgetByName(string groupName)
152  {
153  if (!m_wRoot)
154  return null;
155 
156  return m_wRoot.FindAnyWidget(groupName);
157  }
158 
159  //------------------------------------------------------------------------------------------------
164  SCR_HUDGroupUIComponent GetGroupComponent(string groupName)
165  {
166  Widget group = GetGroupWidgetByName(groupName);
167  if (!group)
168  return null;
169  return SCR_HUDGroupUIComponent.Cast(group.FindHandler(SCR_HUDGroupUIComponent));
170  }
171 
172  //------------------------------------------------------------------------------------------------
177  int GetAllGroupComponents(notnull out array<SCR_HUDGroupUIComponent> groupComponents)
178  {
179  groupComponents.Clear();
180  foreach (Widget groupWidget : m_aAllGroups)
181  {
182  SCR_HUDGroupUIComponent groupComponent = SCR_HUDGroupUIComponent.Cast(groupWidget.FindHandler(SCR_HUDGroupUIComponent));
183  if (groupComponent)
184  groupComponents.Insert(groupComponent);
185  }
186 
187  return groupComponents.Count();
188  }
189 
190  //------------------------------------------------------------------------------------------------
195  int GetAllSlotComponents(notnull out array<SCR_HUDSlotUIComponent> slotComponents)
196  {
197  slotComponents.Clear();
198 
199  foreach (Widget groupWidget : m_aAllGroups)
200  {
201  Widget childWidget = groupWidget.GetChildren();
202  while (childWidget)
203  {
204  SCR_HUDSlotUIComponent slotComponent = SCR_HUDSlotUIComponent.Cast(childWidget.FindHandler(SCR_HUDSlotUIComponent));
205  if (!slotComponent)
206  {
207  childWidget = childWidget.GetSibling();
208  continue;
209  }
210 
211  slotComponents.Insert(slotComponent);
212  childWidget = childWidget.GetSibling();
213  }
214  }
215 
216  return slotComponents.Count();
217  }
218 
219  //------------------------------------------------------------------------------------------------
220  SCR_HUDSlotUIComponent FindSlotComponent(string slotName)
221  {
222  Widget slotWidget = m_wRoot.FindAnyWidget(slotName);
223  if (!slotWidget)
224  return null;
225 
226  return SCR_HUDSlotUIComponent.Cast(slotWidget.FindHandler(SCR_HUDSlotUIComponent));
227  }
228 
229  //------------------------------------------------------------------------------------------------
230  Widget FindWidgetByName(string widgetName)
231  {
232  return m_wRoot.FindAnyWidget(widgetName);
233  }
234 }
SCR_HUDManagerComponent
Definition: SCR_HUDManagerComponent.c:23
SCR_HUDGroupUIComponent
Definition: SCR_HUDGroupUIComponent.c:1
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_HUDLayout
Definition: SCR_HUDLayout.c:2
m_sIdentifier
string m_sIdentifier
Definition: SCR_MapMarkerEntryPlaced.c:3
m_aElements
protected ref array< ref SCR_TabViewContent > m_aElements
Definition: SCR_TabViewComponent.c:13
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_sLayout
SCR_GMMenuEntry m_sLayout
SCR_HUDManagerLayoutHandler
Definition: SCR_HUDManagerLayoutHandler.c:7
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_HUDElement
Definition: SCR_HUDFreeSlot.c:1
SCR_HUDSlotUIComponent
Definition: SCR_HUDSlotUIComponent.c:5
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