Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ShowHideInEditorComponent.c
Go to the documentation of this file.
1
4[ComponentEditorProps(category: "GameScripted/Editor", description: "")]
8
10{
11 [Attribute("1", desc: "Set when the entity is visible. If false will hide itself in editor and show outside of editor. This component is ignored if attached to an EditableEntity or if parent is editable entity", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EShowHideInEditor))]
13
14 [Attribute("0", desc: "If true will also Show/Hide children when entity is hidden")]
15 protected bool m_bShowHideChildren;
16
17 [Attribute("1", desc: "If true will also Show/Hide when editor UI is hidden")]
19
20 //~ Always true if m_bHideWhenEditorUiHidden is false
21 protected bool m_bEditorMenuVisible = true;
22
23 //~ If true make sure to remove the on editor create scriptinvoker Subscription
25
26 //------------------------------------------------------------------------------------------------
27 protected void OnEditorOpen()
28 {
29 ShowHideEntity(true, SCR_EditorModeEntity.GetInstance());
30 }
31
32 //------------------------------------------------------------------------------------------------
33 protected void OnEditorClosed()
34 {
35 ShowHideEntity(false, SCR_EditorModeEntity.GetInstance());
36 }
37
38 //------------------------------------------------------------------------------------------------
40 {
41 ShowHideEntity(SCR_EditorManagerEntity.IsOpenedInstance(), currentMode);
42 }
43
44 //------------------------------------------------------------------------------------------------
45 protected void OnEditorMenuVisibilityChanged(bool isVisible)
46 {
47 m_bEditorMenuVisible = isVisible;
48
50 {
52 }
53 else
54 {
55 SCR_EditorManagerEntity editorManagerEntity = SCR_EditorManagerEntity.GetInstance();
56 if (!editorManagerEntity)
57 {
59 return;
60 }
61
62 ShowHideEntity(editorManagerEntity.IsOpened(), SCR_EditorModeEntity.GetInstance());
63 }
64 }
65
66 //------------------------------------------------------------------------------------------------
67 protected void ShowHideEntity(bool editorIsOpen, SCR_EditorModeEntity mode)
68 {
69 //~ UI not visible so no need to set visible again
70 if (!m_bEditorMenuVisible || !editorIsOpen)
71 {
73 return;
74 }
75
76 bool isLimited = !mode || mode.IsLimited();
77
78 if (isLimited)
79 {
80 if (SCR_Enum.HasFlag(m_eShowHideInEditor, EShowHideInEditor.SHOW_IN_LIMITED_EDITOR))
82 else
84 }
85 else
86 {
87 if (SCR_Enum.HasFlag(m_eShowHideInEditor, EShowHideInEditor.SHOW_IN_UNLIMITED_EDITOR))
89 else
91 }
92 }
93
94 //------------------------------------------------------------------------------------------------
95 override void EOnInit(IEntity owner)
96 {
97 //~ Use editor logic if attached to editable entity
99 return;
100
101 //~ Use editor logic if attached to parent that is an editable entity
102 IEntity parent = owner.GetParent();
103 if (parent && parent.FindComponent(SCR_EditableEntityComponent))
104 return;
105
106 //~ Set invisible on init
108
109 if (m_eShowHideInEditor <= 0)
110 return;
111
112 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
113 if (editorManager)
114 {
115 Init(editorManager);
116 return;
117 }
118
119 //~ No editor manager found wait until it is created
121 if (editorManagerCore)
122 editorManagerCore.Event_OnEditorManagerInitOwner.Insert(Init);
123 }
124
125 //------------------------------------------------------------------------------------------------
126 protected void Init(SCR_EditorManagerEntity editorManagerEntity)
127 {
129 {
131 if (editorManagerCore)
132 {
134 editorManagerCore.Event_OnEditorManagerInitOwner.Remove(Init);
135 }
136 }
137
138 editorManagerEntity.GetOnOpened().Insert(OnEditorOpen);
139 editorManagerEntity.GetOnClosed().Insert(OnEditorClosed);
140 editorManagerEntity.GetOnModeChange().Insert(OnEditorModeChanged);
141
143 {
145 if (menuManager)
146 {
147 menuManager.GetOnVisibilityChange().Insert(OnEditorMenuVisibilityChanged);
148
149 m_bEditorMenuVisible = menuManager.IsVisible();
152 }
153 }
154
155 if (editorManagerEntity.IsOpened())
156 OnEditorOpen();
157 else
159 }
160
161 //------------------------------------------------------------------------------------------------
162 override void OnDelete(IEntity owner)
163 {
164 //~ Hide in workbench
166 return;
167
168 //~ Use editor logic if attached to editable entity
170 return;
171
172 //~ Use editor logic if attached to parent that is an editable entity
173 IEntity parent = owner.GetParent();
174 if (parent && parent.FindComponent(SCR_EditableEntityComponent))
175 return;
176
177 if (m_eShowHideInEditor <= 0)
178 return;
179
180 //~ Remove on editor creation event
182 {
184 if (editorManagerCore)
185 editorManagerCore.Event_OnEditorManagerInitOwner.Remove(Init);
186 }
187
188 SCR_EditorManagerEntity editorManagerEntity = SCR_EditorManagerEntity.GetInstance();
189 if (!editorManagerEntity)
190 return;
191
192 editorManagerEntity.GetOnOpened().Remove(OnEditorOpen);
193 editorManagerEntity.GetOnClosed().Remove(OnEditorClosed);
194 editorManagerEntity.GetOnModeChange().Remove(OnEditorModeChanged);
195 }
196
197 //------------------------------------------------------------------------------------------------
198 override void OnPostInit(IEntity owner)
199 {
200 //~ Hide in workbench
202 return;
203
204 SetEventMask(owner, EntityEvent.INIT);
205 }
206};
207
208//------------------------------------------------------------------------------------------------
override void Init()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external Managed FindComponent(typename typeName)
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external IEntity GetParent()
proto external EntityFlags ClearFlags(EntityFlags flags, bool recursively=false)
Core component to manage SCR_EditorManagerEntity.
static bool IsEditMode()
Definition Functions.c:1566
void Init(SCR_EditorManagerEntity editorManagerEntity)
void OnEditorModeChanged(SCR_EditorModeEntity currentMode, SCR_EditorModeEntity prevMode)
void ShowHideEntity(bool editorIsOpen, SCR_EditorModeEntity mode)
proto external GenericEntity GetOwner()
Get owner entity.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EntityFlags
Various entity flags.
Definition EntityFlags.c:14