public IWindowUT AddChildToActivePanel(IWindowUT newChild) { if (ActivePanel != null) { if (ActivePanel.CanHaveChildren) { return(ActivePanel.AddChild(newChild).Init()); } } return(null); }
public IWindowUT OpenNewPanel(IWindowUT prefab, WindowCloseModes mode = WindowCloseModes.CloseNonSolid) { var newPanel = CreateWindow(mainRoot, prefab, mode); panels.Push(newPanel); allWindows.Add(newPanel); Listen(newPanel); newPanel.Init(); return(newPanel); }
public IWindowUT AddNewFrame(IWindowUT prefab, WindowCloseModes mode = WindowCloseModes.CloseNonSolid) { var newFrame = CreateWindow(auxiliaryRoot, prefab, mode); frames.Push(newFrame); allWindows.Add(newFrame); Listen(newFrame); newFrame.Init(false, false); return(newFrame); }
private IWindowUT CreateWindow(Transform parent, IWindowUT prefab, WindowCloseModes mode = WindowCloseModes.CloseNonSolid, bool isPanel = true) { if (isPanel) { ClosePanels(mode); } else { CloseFrames(mode); } if (ActivePanel != null) { ActivePanel.IsInteractable = false; ActivePanel.IsFocused = false; } return(GameObject.Instantiate(prefab as MonoBehaviour, parent) as IWindowUT); }
private void Window_OnSetFocus(IWindowUT sender, bool value) { if (value) { if (PanelWithFocus != sender) { if (PanelWithFocus != null) { PanelWithFocus.IsFocused = false; } PanelWithFocus = sender; } } else { if (PanelWithFocus == sender) { PanelWithFocus = null; } } }
#pragma warning restore 67 public virtual IWindowUT AddChild(IWindowUT newChild) { Children.Add(newChild); OnChildAdded?.Invoke(this, newChild); return(this); }
private void Window_OnChildAdded(IWindowUT sender, IWindowUT child) { allWindows.Add(child); Listen(child); }
private void Window_OnClosed(IWindowUT sender) { bool shouldSetInteractable = false; if (sender == ActivePanel) { shouldSetInteractable = true; } if (panels.Contains(sender)) { //remove sender from stack even if it's in the middle var temp = new Stack <IWindowUT>(); while (panels.Contains(sender)) { var panel = panels.Pop(); if (panel != sender) { temp.Push(panel); } } while (temp.Count > 0) { panels.Push(temp.Pop()); } } if (frames.Contains(sender)) { //remove sender from stack even if it's in the middle var temp = new Stack <IWindowUT>(); while (frames.Contains(sender)) { var panel = frames.Pop(); if (panel != sender) { temp.Push(panel); } } while (temp.Count > 0) { frames.Push(temp.Pop()); } } allWindows.Remove(sender); //close all children. it's recursive for (int i = sender.Children.Count - 1; i >= 0; i--) { sender.Children[i].Close(); } if (shouldSetInteractable) { if (ActivePanel != null) { ActivePanel.IsInteractable = true; } } if (sender == PanelWithFocus || PanelWithFocus == null) { if (ActivePanel != null) { ActivePanel.IsFocused = true; } } Unlisten(sender); }
protected void Unlisten(IWindowUT window) { window.OnChildAdded -= Window_OnChildAdded; window.OnClosed -= Window_OnClosed; window.OnSetFocus -= Window_OnSetFocus; }
protected void Listen(IWindowUT window) { window.OnChildAdded += Window_OnChildAdded; window.OnClosed += Window_OnClosed; window.OnSetFocus += Window_OnSetFocus; }