Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MenuEditorComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor", description: "GUI for in-game editor. Works only with SCR_EditorBaseEntity!", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3 {
4 };
5 
9 {
10  [Attribute(desc: "Menu created when the editor is opened.", defvalue: "-1", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(ChimeraMenuPreset))]
11  private ChimeraMenuPreset m_EditorMenuPreset;
12 
13  [Attribute(desc: "Visibility status when the editor is opened.", defvalue: "1")]
14  private bool m_bVisible;
15 
16  [Attribute(desc: "Is visibility of the menu preserved whent editor is closed and opened again?", defvalue: "1")]
17  private bool m_bVisiblePersistent;
18 
19  private bool m_bVisibleDefault;
20  private EditorMenuBase m_EditorMenu;
21  protected SCR_MenuEditorUIComponent m_EditorMenuComponent;
22  private InputManager m_InputManager;
23 
24  private ref ScriptInvoker Event_OnVisibilityChange = new ScriptInvoker;
25 
31  void SetVisible(bool visible, bool instant = false)
32  {
33  if (visible == m_bVisible) return;
34  m_bVisible = visible;
35 
36  SCR_HideEditorUIComponent hideComponent = SCR_HideEditorUIComponent.Cast(m_EditorMenuComponent.GetHideableWidget().FindHandler(SCR_HideEditorUIComponent));
37  if (hideComponent)
38  hideComponent.SetVisible(m_bVisible, instant);
39 
40  SCR_HUDManagerComponent hudManager = GetGame().GetHUDManager();
41  if (hudManager)
42  hudManager.SetVisible(m_bVisible);
43 
44  Event_OnVisibilityChange.Invoke(m_bVisible);
45  }
49  void ToggleVisible()
50  {
51  SetVisible(!m_bVisible);
52  }
57  bool IsVisible()
58  {
59  return m_bVisible;
60  }
65  EditorMenuBase GetMenu()
66  {
67  return m_EditorMenu;
68  }
73  SCR_MenuEditorUIComponent GetMenuComponent()
74  {
75  return m_EditorMenuComponent;
76  }
81  ScriptInvoker GetOnVisibilityChange()
82  {
83  return Event_OnVisibilityChange;
84  }
85 
86  protected void OnModeChange()
87  {
88  SetVisible(true, true);
89  }
90 
91  //--- EOnAfterEditorOpen() is used instead of EOnEditorOpen() to make sure GUI follows all other components
92  override protected void EOnEditorPostActivate()
93  {
94  //--- Reset visibility when presistence is disabled
95  if (!m_bVisiblePersistent) m_bVisible = m_bVisibleDefault;
96 
97  //--- Use the concept menu or the final one?
98  ChimeraMenuPreset menuPreset = m_EditorMenuPreset;
99 
100  if (menuPreset < 0) menuPreset = ChimeraMenuPreset.EditorMenu;
101  MenuBase baseMenu = GetGame().GetMenuManager().OpenMenu(menuPreset);
102  m_EditorMenu = EditorMenuBase.Cast(baseMenu);
103  if (!m_EditorMenu)
104  {
105  GetGame().GetMenuManager().CloseMenu(baseMenu);
106  Print("Editor menu is not type EditorMenuBase!", LogLevel.ERROR);
107  }
108 
109  m_EditorMenuComponent = SCR_MenuEditorUIComponent.Cast(m_EditorMenu.GetRootWidget().FindHandler(SCR_MenuEditorUIComponent));
110  if (!m_EditorMenu)
111  {
112  GetGame().GetMenuManager().CloseMenu(baseMenu);
113  Print("Editor menu root widget is missing SCR_MenuEditorUIComponent!", LogLevel.ERROR);
114  }
115 
116  //--- Reveal GUI when switching modes
118  if (editorManager)
119  editorManager.GetOnModeChange().Insert(OnModeChange);
120  }
121  override protected void EOnEditorDeactivate()
122  {
124  if (editorManager)
125  editorManager.GetOnModeChange().Remove(OnModeChange);
126  }
127  override protected void EOnEditorClose()
128  {
129  if (m_EditorMenu) GetGame().GetMenuManager().CloseMenu(m_EditorMenu);
130 
131  SCR_HUDManagerComponent hudManager = GetGame().GetHUDManager();
132  if (hudManager) hudManager.SetVisible(true);
133  }
134  override protected void EOnEditorActivate()
135  {
136  m_InputManager = GetGame().GetInputManager();
137  }
138  override protected void EOnEditorInit()
139  {
140  m_bVisibleDefault = m_bVisible;
141  DiagMenu.RegisterMenu(SCR_DebugMenuID.DEBUGUI_EDITOR_GUI, "Editor GUI", "Editor");
142  }
143 };
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_HUDManagerComponent
Definition: SCR_HUDManagerComponent.c:23
m_InputManager
protected InputManager m_InputManager
Definition: SCR_BaseManualCameraComponent.c:15
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_MenuEditorUIComponent
Definition: SCR_MenuEditorUIComponent.c:1
SCR_HideEditorUIComponent
Definition: SCR_HideEditorUIComponent.c:3
SCR_BaseEditorComponent
Definition: SCR_BaseEditorComponent.c:119
Attribute
typedef Attribute
Post-process effect of scripted camera.
EditorMenuBase
Definition: EditorMenuBase.c:7
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_BaseEditorComponentClass
Definition: SCR_BaseEditorComponent.c:2
SCR_MenuEditorComponentClass
Definition: SCR_MenuEditorComponent.c:2
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_MenuEditorComponent
Definition: SCR_MenuEditorComponent.c:8
m_bVisible
protected bool m_bVisible
Definition: SCR_UITaskManagerComponent.c:28
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26