8 protected string m_sSfxStartLayerEditing;
11 protected string m_sSfxStopLayerEditing;
14 protected string m_sSfxGoLayerDeeper;
17 protected string m_sSfxGoLayerBack;
21 protected string m_sLayerElementHolder;
23 protected Widget m_LayerElementHolder;
26 protected string m_sExitLayerButton;
29 protected string m_sLayerEditorOverlayName;
31 protected Widget m_LayerEditorOverlay;
34 protected string m_sParentWidgetName;
36 protected Widget m_parentWidget;
42 protected ref array<SCR_EditableEntityComponent> m_aCurrentSelectedLayers = {};
44 protected InputManager m_InputManager;
50 [
Attribute(defvalue:
"0",
desc:
"Layers shown after WorldRoot but before Dropdown")]
51 protected int m_iLayersShownAfterRoot;
53 [
Attribute(defvalue:
"1",
desc:
"Layers shown before current but after Dropdown")]
54 protected int m_iLayersShownBeforeCurrent;
58 protected ResourceName m_LayerElementPrefab;
61 protected ResourceName m_LayerElementButtonPrefab;
64 protected ResourceName m_LayerWorldPrefab;
67 protected ResourceName m_LayerWorldButtonPrefab;
70 protected ResourceName m_NextLayerIndicatorPrefab;
73 protected ResourceName m_MoreLayersIndicatorPrefab;
76 protected bool m_bUsesGamepad;
78 protected ref map<SCR_ButtonBaseComponent, SCR_EditableEntityComponent> m_mButtonReferences =
new map<SCR_ButtonBaseComponent, SCR_EditableEntityComponent>();
83 protected void OnMenuUpdate(
float tDelta)
86 if (m_InputManager && !mapShown)
95 if (m_mButtonReferences.Find(button, layer))
106 m_SelectedLayer = currentLayer;
117 ClearLayerElements();
121 if (!prevLayer && !currentLayer)
123 else if (!prevLayer && currentLayer)
125 else if (prevLayer && !currentLayer)
127 else if (currentLayer.GetParentEntity() == prevLayer)
136 protected void OnInputDeviceIsGamepad(
bool isGamepad)
138 m_bUsesGamepad = isGamepad;
146 protected void RefreshLayerUI()
148 if (m_SelectedLayer ==
null)
152 m_parentWidget.SetEnabled(
true);
155 ClearLayerElements();
158 CreateWorldRootLayer();
161 m_aCurrentSelectedLayers = {};
162 m_SelectedLayer.GetParentEntities(m_aCurrentSelectedLayers);
163 m_aCurrentSelectedLayers.InsertAt(m_SelectedLayer, 0);
164 int totalLayerCount = m_aCurrentSelectedLayers.Count();
165 bool hasMoreAfterRootIndicator =
false;
168 for (
int i = totalLayerCount -1; i > -1; i--)
171 if (totalLayerCount - i <= m_iLayersShownAfterRoot || i <= m_iLayersShownBeforeCurrent)
174 CreateNextLayerIndicator();
175 CreateLayerElement(m_aCurrentSelectedLayers[i], i == 0);
178 else if (!hasMoreAfterRootIndicator)
180 hasMoreAfterRootIndicator =
true;
181 CreateNextLayerIndicator();
182 CreateMoreLayersIndicator();
202 for (
int i = 0, count = m_aCurrentSelectedLayers.Count(); i < count; i++)
204 if (m_aCurrentSelectedLayers[i] == entity)
221 if (CheckIfSelectedLayerHierarchyChanged(entity))
227 if (CheckIfSelectedLayerHierarchyChanged(parentEntity))
233 if (CheckIfSelectedLayerHierarchyChanged(parentEntityPrev))
243 protected void OnEntityStateChanged(
EEditableEntityState state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
248 for (
int i = 0, count = entitiesInsert.Count(); i < count; i++)
250 if (CheckIfSelectedLayerHierarchyChanged(entitiesInsert[i]))
261 for (
int i = 0, count = entitiesRemove.Count(); i < count; i++)
263 if (CheckIfSelectedLayerHierarchyChanged(entitiesRemove[i]))
278 Widget elementWidget;
281 if (m_bUsesGamepad || isLast)
283 elementWidget =
GetGame().GetWorkspace().CreateWidgets(m_LayerElementPrefab, m_LayerElementHolder);
289 elementWidget =
GetGame().GetWorkspace().CreateWidgets(m_LayerElementButtonPrefab, m_LayerElementHolder);
294 Widget button = elementWidget.FindAnyWidget(
"Button");
301 if (!buttonComponent)
304 m_mButtonReferences.Insert(buttonComponent, layerEntity);
305 buttonComponent.m_OnClicked.Insert(OnLayerButtonPressed);
311 elementWidget.RemoveFromHierarchy();
315 toolbarItem.InitToolbarItem(elementWidget);
319 if (linkedEntityComponent)
320 linkedEntityComponent.SetLinkedEntity(layerEntity);
324 entityItem.SetEntity(layerEntity, elementWidget, m_SlotManager);
330 protected void CreateNextLayerIndicator()
332 Widget nextLayerIndicator =
GetGame().GetWorkspace().CreateWidgets(m_NextLayerIndicatorPrefab, m_LayerElementHolder);
338 protected void CreateMoreLayersIndicator()
340 Widget moreLayersIndicator =
GetGame().GetWorkspace().CreateWidgets(m_MoreLayersIndicatorPrefab, m_LayerElementHolder);
346 protected void CreateWorldRootLayer()
348 Widget elementWidget;
353 elementWidget =
GetGame().GetWorkspace().CreateWidgets(m_LayerWorldPrefab, m_LayerElementHolder);
357 elementWidget =
GetGame().GetWorkspace().CreateWidgets(m_LayerWorldButtonPrefab, m_LayerElementHolder);
361 Widget button = elementWidget.FindAnyWidget(
"Button");
368 if (!buttonComponent)
371 m_mButtonReferences.Insert(buttonComponent,
null);
372 buttonComponent.m_OnClicked.Insert(OnLayerButtonPressed);
381 protected void SetVisible(
bool show)
386 if (m_parentWidget.IsVisible() != show)
388 m_parentWidget.SetVisible(show);
390 if (m_LayerEditorOverlay)
391 m_LayerEditorOverlay.SetVisible(show);
394 ClearLayerElements();
402 protected void ClearLayerElements()
404 Widget child = m_LayerElementHolder.GetChildren();
409 child = child.GetSibling();
410 childtemp.RemoveFromHierarchy();
415 m_mButtonReferences.Clear();
421 protected void OnEditorExitLayerButton()
430 override void HandlerAttachedScripted(Widget w)
434 m_LayerElementHolder = w.FindAnyWidget(m_sLayerElementHolder);
436 m_parentWidget =
GetMenu().GetRootWidget().FindAnyWidget(m_sParentWidgetName);
439 if (m_LayerElementHolder)
443 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
447 if (!m_LayersManager)
451 m_LayersManager.GetOnCurrentLayerChange().Insert(OnCompositionLayerChanged);
459 core.Event_OnParentEntityChanged.Insert(OnParentEntityVisibleChanged);
465 filter.GetOnChanged().Insert(OnEntityStateChanged);
468 Widget widget = w.FindAnyWidget(m_sExitLayerButton);
473 exitLayerButton.GetOnAction().Insert(OnEditorExitLayerButton);
479 if (!entitiesManager)
490 menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
496 Widget parent = w.GetParent();
499 m_LayerEditorOverlay = parent.FindAnyWidget(m_sLayerEditorOverlayName);
501 if (m_LayerEditorOverlay)
502 m_LayerEditorOverlay.SetVisible(
false);
508 override void HandlerDeattached(Widget w)
512 m_LayersManager.GetOnCurrentLayerChange().Remove(OnCompositionLayerChanged);
515 Widget widget = w.FindAnyWidget(m_sExitLayerButton);
520 exitLayerButton.GetOnAction().Remove(OnEditorExitLayerButton);
525 core.Event_OnParentEntityChanged.Remove(OnParentEntityVisibleChanged);
529 filter.GetOnChanged().Remove(OnEntityStateChanged);
531 super.HandlerDeattached(w);
535 menu.GetOnMenuUpdate().Remove(OnMenuUpdate);