using NEG.UI.Area; using NEG.UI.WindowSlot; using UnityEngine; namespace NEG.UI.Window { public interface IWindow { IWindowSlot Parent { get; } IArea ChildWindowArea { get; } /// /// Call internally by slot to open window /// /// Slot that opens window internal void Open(IWindowSlot parentSlot); /// /// Call internally to close window by slot /// internal void Close(); } public static class WindowInterfaceExtensions { //Open public static void Open(this IWindow window, IWindowSlot slot = null) { if(slot != null) slot.AttachWindow(window); else UiManager.Instance.CurrentArea.OpenWindow(window); } public static void Open(this IWindow window, IArea area) => area.OpenWindow(window); public static void OpenChildWindow(this IWindow window, IWindow windowToOpen, IWindowSlot slot = null) { if (window.ChildWindowArea == null) { Debug.LogError("This window doesn't contain area for child windows"); return; } //TODO: DO it //window.ChildWindowArea.OpenWindow(windowToOpen, slot); } public static void Close(this IWindow window) => window.Parent.DetachWindow(window); } }