10 protected ref array<ref SCR_HUDLayout> m_aHUDLayouts;
13 protected string m_sMainLayout;
23 m_aHUDLayouts.Insert(
layout);
29 if (m_aHUDLayouts.Contains(
layout))
30 m_aHUDLayouts.RemoveItem(
layout);
34 array<ref SCR_HUDLayout> GetAllHUDLayouts()
36 ref array<ref SCR_HUDLayout> allLayouts = {};
49 if (!m_OnLayoutChange)
52 return m_OnLayoutChange;
58 return m_ActiveLayout;
62 int GetAllHudElements(notnull out array<SCR_HUDElement> hudElements)
68 hudLayout.GetHUDElements(hudElements);
71 return hudElements.Count();
75 array<string> GetAllIdentifiers()
77 array<string> allIdentifiers = {};
80 allIdentifiers.Insert(hudLayout.GetIdentifier());
83 return allIdentifiers;
91 Widget GetGroupByName(
string groupName)
96 return m_ActiveLayout.GetGroupWidgetByName(groupName);
109 return m_ActiveLayout.GetGroupComponent(groupName);
122 return m_ActiveLayout.FindSlotComponent(slotName);
133 slotToReturn =
layout.FindSlotComponent(slotName);
142 foundLayout = m_ActiveLayout;
151 Widget FindWidgetByName(
string widgetName)
156 return m_ActiveLayout.FindWidgetByName(widgetName);
160 Widget FindWidgetByNameFromAnyLayout(
string widgetName, out
SCR_HUDLayout foundLayout =
null)
162 Widget foundWidget = FindWidgetByName(widgetName);
165 foundLayout = m_ActiveLayout;
171 foundWidget = hudLayout.FindWidgetByName(widgetName);
174 foundLayout = hudLayout;
187 if (hudLayout.GetIdentifier() == layoutIdentifier)
195 protected void InitializeHUDLayouts()
197 WorkspaceWidget workspace =
GetGame().GetWorkspace();
201 Widget layoutWidget = workspace.CreateWidgets(hudLayout.GetLayout(),
null);
205 hudLayout.SetRootWidget(layoutWidget);
207 if (hudLayout.GetIdentifier() == m_sMainLayout)
209 m_ActiveLayout = hudLayout;
213 layoutWidget.SetVisible(
false);
214 layoutWidget.SetEnabled(
false);
219 void ChangeActiveHUDLayout(
string layoutIdentifier =
string.Empty)
221 if (layoutIdentifier.IsEmpty())
222 layoutIdentifier = m_sMainLayout;
225 if (!newLayout || newLayout == m_ActiveLayout)
229 SetLayoutEnabled(m_ActiveLayout.GetIdentifier(),
false);
233 m_ActiveLayout = newLayout;
234 SetLayoutEnabled(m_ActiveLayout.GetIdentifier(),
true);
236 array<SCR_HUDElement> allHudElements = {};
237 GetAllHudElements(allHudElements);
241 Widget elementWidget = element.GetWidget();
245 Widget oldParentWidget = elementWidget.GetParent();
246 Widget newParentWidget = newLayout.FindWidgetByName(element.GetParentWidgetName());
249 if (newLayout.GetIdentifier() != m_sMainLayout)
253 oldLayout.RemoveHudElement(element,
true);
255 elementWidget.SetVisible(
false);
256 elementWidget.SetEnabled(
false);
259 mainLayout.AddHudElement(element,
true);
262 if (!newParentWidget)
265 elementWidget.SetVisible(
true);
266 elementWidget.SetEnabled(
true);
270 oldLayout.RemoveHudElement(element,
true);
272 newLayout.AddHudElement(element,
true);
275 if (m_OnLayoutChange)
276 m_OnLayoutChange.Invoke(newLayout, oldActiveLayout,
m_HUDManager);
279 GetGame().GetCallqueue().Call(newLayout.ResizeLayout);
283 void SetLayoutEnabled(
string layoutIdentifier,
bool isEnabled)
289 Widget hudWidget = hudLayout.GetRootWidget();
293 hudWidget.SetVisible(isEnabled);
294 hudWidget.SetEnabled(isEnabled);
298 protected void StartMainLayout()
303 ChangeActiveHUDLayout(m_sMainLayout);
306 if (m_OnMainLayoutInitialize)
307 m_OnMainLayoutInitialize.Invoke();
315 InitializeHUDLayouts();
327 if (!m_OnMainLayoutInitialize)
330 return m_OnMainLayoutInitialize;