8 protected Widget m_Widget;
10 protected ref array<MenuRootSubComponent> m_aComponents = {};
23 WorkspaceWidget workspace =
GetGame().GetWorkspace();
24 Widget widgetRoot = widget;
27 Widget widgetRootParent = widgetRoot.GetParent();
28 if (!widgetRootParent || widgetRootParent == workspace)
30 widgetRoot = widgetRootParent;
37 widgetRoot.AddHandler(rootComponent);
50 Widget widgetRoot = menu.GetRootWidget();
51 return GetRootOf(widgetRoot);
81 if (m_aComponents.Find(component) == -1)
82 m_aComponents.InsertAt(component, 0);
92 m_aComponents.RemoveItem(component);
105 if (component && component.Type() ==
type)
110 Print(
string.Format(
"Cannot find UI component '%1'!",
type), LogLevel.ERROR);
122 int FindComponents(
typename type, notnull out array<MenuRootSubComponent> outComponents)
124 outComponents.Clear();
125 foreach (
auto component: m_aComponents)
127 if (component && component.Type() ==
type)
128 outComponents.Insert(component);
130 return outComponents.Count();
141 int count = m_aComponents.Count();
142 foreach (
auto component : m_aComponents)
144 component.HandlerAttachedScripted(component.GetWidget());
147 if (count != m_aComponents.Count())
149 Print(
string.Format(
"Error when initializing MenuRootComponent - new components were added during init of %1! The menu will not function correctly!", component.Type()), LogLevel.ERROR);
156 protected void InitNotRoot()
162 protected void ExecInit(Widget w)
165 Widget child = w.GetChildren();
169 child = child.GetSibling();
173 int subComponentsCount = w.GetNumHandlers();
174 for (
int i; i < subComponentsCount; i++)
178 subComponent.HandlerAttachedScripted(w);
183 override void HandlerAttached(Widget w)
186 super.HandlerAttached(w);
187 GetGame().GetCallqueue().CallLater(InitNotRoot, 1,
false);