Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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")]
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
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
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 //------------------------------------------------------------------------------------------------
57 {
58 return m_sIdentifier;
59 }
60
61 //------------------------------------------------------------------------------------------------
63 {
64 return m_sLayout;
65 }
66
67 //------------------------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------------------------
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}
AddonBuildInfoTool id
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void RemoveHudElement(notnull SCR_HUDElement element, bool replaceParent=false)
void AddHudElement(notnull SCR_HUDElement element, bool replaceParent=false)
ref array< ref Widget > m_aAllGroups
SCR_HUDGroupUIComponent GetGroupComponent(string groupName)
string m_sIdentifier
ref array< ref SCR_HUDElement > m_aElements
int GetAllGroupComponents(notnull out array< SCR_HUDGroupUIComponent > groupComponents)
ResourceName GetLayout()
void SetIdentifier(string id)
int GetHUDElements(notnull out array< SCR_HUDElement > hudElements)
Widget GetRootWidget()
Widget FindWidgetByName(string widgetName)
string GetIdentifier()
ResourceName m_sLayout
void SetRootWidget(notnull Widget widget)
Widget GetGroupWidgetByName(string groupName)
int GetAllSlotComponents(notnull out array< SCR_HUDSlotUIComponent > slotComponents)
SCR_HUDSlotUIComponent FindSlotComponent(string slotName)
SCR_HUDManagerHandler FindHandler(typename handlerType)
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