Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
MenuRootSubComponent.c
Go to the documentation of this file.
1 
5 class MenuRootSubComponent: ScriptedWidgetComponent
6 {
7  private Widget m_Widget;
8  private MenuRootComponent m_Root;
9 
14  Widget GetWidget()
15  {
16  return m_Widget;
17  }
22  MenuRootBase GetMenu()
23  {
24  if (!m_Root) return null;
25  return m_Root.GetMenu();
26  }
31  MenuRootComponent GetRootComponent()
32  {
33  return m_Root;
34  }
35 
41  protected bool IsUnique()
42  {
43  return true;
44  }
45 
52  void HandlerAttachedScripted(Widget w);
53 
54  override void HandlerAttached(Widget w)
55  {
56  if (SCR_Global.IsEditMode()) return; //--- Run-time only
57  m_Widget = w;
58 
59  m_Root = MenuRootComponent.GetRootOf(m_Widget);
60  if (IsUnique())
61  {
62  if (!m_Root.FindComponent(Type()))
63  {
64  m_Root.AddComponent(this);
65  }
66  else
67  {
68  Print(string.Format("Duplicate instance of UI component %1 found on widget '%2'! The component is marked as unique, only one instance is allowed.", Type(), w.GetName()), LogLevel.WARNING);
69  return;
70  }
71  }
72 
73  if (m_Root.GetMenu())
74  {
75  //--- Execute after delay to make sure all new components are registered first
76  GetGame().GetCallqueue().CallLater(HandlerAttachedScripted, 0, false, w);
77  }
78  }
79  override void HandlerDeattached(Widget w)
80  {
81  if (m_Root) m_Root.RemoveComponent(this);
82  }
83 };
m_Root
SCR_ServerHostingModSubMenu m_Root
MenuRootSubComponent
Definition: MenuRootSubComponent.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
MenuRootBase
Definition: MenuRootBase.c:6
MenuRootComponent
Definition: MenuRootComponent.c:6
SCR_Global
Definition: Functions.c:6
HandlerAttachedScripted
override void HandlerAttachedScripted(Widget w)
Definition: SCR_CursorEditorUIComponent.c:459