Naming update

This commit is contained in:
Kamila Stawarska 2023-08-20 14:07:45 +02:00
parent a83c4cfb3b
commit 63d3d908e8
5 changed files with 38 additions and 33 deletions

View File

@ -10,7 +10,7 @@ using System;
namespace NEG.UI.Area
{
public class MonoArea : MonoBehaviour, IArea
public class MonoArea : MonoBehaviour, IArea, IControllable
{
public event Action<object> OnOpened;
public event Action OnClosed;
@ -31,6 +31,8 @@ namespace NEG.UI.Area
{
if (setAsDefaultArea)
UiManager.Instance.CurrentArea = this;
else
SetEnabled(false);
}
protected virtual void OnDestroy()

View 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)
{
}
}
}

View File

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
namespace NEG.UI.UnityUi.Window
{
@ -26,7 +27,7 @@ namespace NEG.UI.UnityUi.Window
private IWindowSlot DefaultWindowSlot => windowSlots[0];
[SerializeField] private List<MonoWindowSlot> windowSlots;
[SerializeField] private WindowController controller;
[SerializeField] private MonoController monoController;
[SerializeField] private GameObject defaultSelectedItem;
@ -45,8 +46,8 @@ namespace NEG.UI.UnityUi.Window
Parent = null;
((ISlotsHolder)this).CloseAllWindows();
UiManager.Instance.OnWindowClosed(this);
if(controller != null)
controller.OnClosed();
if(monoController != null)
monoController.OnClosed();
}
public void SetHiddenState() => gameObject.SetActive(false);
@ -57,8 +58,8 @@ namespace NEG.UI.UnityUi.Window
private void OnValidate()
{
if (controller == null)
controller = GetComponent<WindowController>();
if (monoController == null)
monoController = GetComponent<MonoController>();
#if !NEG_UI_DISABLE_WARNING_DEFAULT_SELECTION
if(defaultSelectedItem == null)
Debug.LogWarning($"Window {name} should have default selected item set");

View File

@ -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)
{
}
}
}