Naming update
This commit is contained in:
parent
a83c4cfb3b
commit
63d3d908e8
@ -10,7 +10,7 @@ using System;
|
|||||||
|
|
||||||
namespace NEG.UI.Area
|
namespace NEG.UI.Area
|
||||||
{
|
{
|
||||||
public class MonoArea : MonoBehaviour, IArea
|
public class MonoArea : MonoBehaviour, IArea, IControllable
|
||||||
{
|
{
|
||||||
public event Action<object> OnOpened;
|
public event Action<object> OnOpened;
|
||||||
public event Action OnClosed;
|
public event Action OnClosed;
|
||||||
@ -31,6 +31,8 @@ namespace NEG.UI.Area
|
|||||||
{
|
{
|
||||||
if (setAsDefaultArea)
|
if (setAsDefaultArea)
|
||||||
UiManager.Instance.CurrentArea = this;
|
UiManager.Instance.CurrentArea = this;
|
||||||
|
else
|
||||||
|
SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnDestroy()
|
protected virtual void OnDestroy()
|
||||||
|
|||||||
29
NEG/UI/UnityUi/MonoController.cs
Normal file
29
NEG/UI/UnityUi/MonoController.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using KBCore.Refs;
|
||||||
|
using NegUtils.NEG.UI;
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NEG.UI.UnityUi
|
||||||
|
{
|
||||||
|
public abstract class MonoController : MonoBehaviour, IController
|
||||||
|
{
|
||||||
|
[SerializeField, Self] protected InterfaceRef<IControllable> controllable;
|
||||||
|
|
||||||
|
public virtual void OnOpened(object data) { }
|
||||||
|
|
||||||
|
public virtual void OnClosed() { }
|
||||||
|
|
||||||
|
protected virtual void Awake()
|
||||||
|
{
|
||||||
|
controllable.Value.OnOpened += OnOpened;
|
||||||
|
controllable.Value.OnClosed += OnClosed;
|
||||||
|
controllable.Value.UseBack += UseBack;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnValidate() => this.ValidateRefs();
|
||||||
|
|
||||||
|
public virtual void UseBack(IControllable.BackUsed obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace NEG.UI.UnityUi.Window
|
namespace NEG.UI.UnityUi.Window
|
||||||
{
|
{
|
||||||
@ -26,7 +27,7 @@ namespace NEG.UI.UnityUi.Window
|
|||||||
private IWindowSlot DefaultWindowSlot => windowSlots[0];
|
private IWindowSlot DefaultWindowSlot => windowSlots[0];
|
||||||
|
|
||||||
[SerializeField] private List<MonoWindowSlot> windowSlots;
|
[SerializeField] private List<MonoWindowSlot> windowSlots;
|
||||||
[SerializeField] private WindowController controller;
|
[SerializeField] private MonoController monoController;
|
||||||
|
|
||||||
[SerializeField] private GameObject defaultSelectedItem;
|
[SerializeField] private GameObject defaultSelectedItem;
|
||||||
|
|
||||||
@ -45,8 +46,8 @@ namespace NEG.UI.UnityUi.Window
|
|||||||
Parent = null;
|
Parent = null;
|
||||||
((ISlotsHolder)this).CloseAllWindows();
|
((ISlotsHolder)this).CloseAllWindows();
|
||||||
UiManager.Instance.OnWindowClosed(this);
|
UiManager.Instance.OnWindowClosed(this);
|
||||||
if(controller != null)
|
if(monoController != null)
|
||||||
controller.OnClosed();
|
monoController.OnClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHiddenState() => gameObject.SetActive(false);
|
public void SetHiddenState() => gameObject.SetActive(false);
|
||||||
@ -57,8 +58,8 @@ namespace NEG.UI.UnityUi.Window
|
|||||||
|
|
||||||
private void OnValidate()
|
private void OnValidate()
|
||||||
{
|
{
|
||||||
if (controller == null)
|
if (monoController == null)
|
||||||
controller = GetComponent<WindowController>();
|
monoController = GetComponent<MonoController>();
|
||||||
#if !NEG_UI_DISABLE_WARNING_DEFAULT_SELECTION
|
#if !NEG_UI_DISABLE_WARNING_DEFAULT_SELECTION
|
||||||
if(defaultSelectedItem == null)
|
if(defaultSelectedItem == null)
|
||||||
Debug.LogWarning($"Window {name} should have default selected item set");
|
Debug.LogWarning($"Window {name} should have default selected item set");
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
using NegUtils.NEG.UI;
|
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace NEG.UI.UnityUi.Window
|
|
||||||
{
|
|
||||||
public abstract class WindowController : MonoBehaviour, IController
|
|
||||||
{
|
|
||||||
protected IControllable controllable;
|
|
||||||
|
|
||||||
public virtual void OnOpened(object data) { }
|
|
||||||
|
|
||||||
public virtual void OnClosed() { }
|
|
||||||
|
|
||||||
protected virtual void Awake()
|
|
||||||
{
|
|
||||||
controllable = GetComponent<IControllable>();
|
|
||||||
controllable.OnOpened += OnOpened;
|
|
||||||
controllable.OnClosed += OnClosed;
|
|
||||||
controllable.UseBack += UseBack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UseBack(IControllable.BackUsed obj)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user