Compare commits
3 Commits
main
...
better-ui-
| Author | SHA1 | Date | |
|---|---|---|---|
| b29bd22db0 | |||
| 858bfaa0ae | |||
| 7131c14d99 |
@ -5,7 +5,7 @@ namespace NEG.UI.Popup
|
||||
{
|
||||
public class DefaultPopupData : PopupData
|
||||
{
|
||||
private readonly IDefaultPopup defaultPopup;
|
||||
private IDefaultPopup defaultPopup;
|
||||
|
||||
private readonly string title;
|
||||
private readonly string content;
|
||||
@ -24,5 +24,12 @@ namespace NEG.UI.Popup
|
||||
defaultPopup.SetContent(title, content, options);
|
||||
base.Show();
|
||||
}
|
||||
|
||||
public void UpdatePopup(IDefaultPopup newPopup)
|
||||
{
|
||||
defaultPopup = newPopup;
|
||||
popup = newPopup;
|
||||
Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using JetBrains.Annotations;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NEG.UI.Popup
|
||||
{
|
||||
@ -20,7 +21,9 @@ namespace NEG.UI.Popup
|
||||
/// </summary>
|
||||
public bool IsValid { get; protected set; }
|
||||
|
||||
private readonly IPopup popup;
|
||||
public IPopup Popup => popup;
|
||||
|
||||
protected IPopup popup;
|
||||
|
||||
/// <summary>
|
||||
/// PopupData constructor.
|
||||
@ -40,7 +43,12 @@ namespace NEG.UI.Popup
|
||||
/// <summary>
|
||||
/// Hide popup. Close visuals without firing events;
|
||||
/// </summary>
|
||||
public virtual void Hide() => popup.Close(true);
|
||||
public virtual void Hide()
|
||||
{
|
||||
if(popup is MonoBehaviour behaviour && behaviour == null)
|
||||
return;
|
||||
popup.Close(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalidate popup, <see cref="UiManager"/> will automatically skip this popup
|
||||
|
||||
@ -38,6 +38,8 @@ namespace NEG.UI
|
||||
|
||||
public PopupData CurrentPopup => currentShownPopup.data;
|
||||
|
||||
public IDefaultPopup CurrentDefaultPopup => currentDefaultPopup;
|
||||
|
||||
private IArea currentArea;
|
||||
private (PopupData data, int priority) currentShownPopup;
|
||||
protected IDefaultPopup currentDefaultPopup;
|
||||
@ -166,7 +168,13 @@ namespace NEG.UI
|
||||
UpdatePopupsState(false);
|
||||
}
|
||||
|
||||
protected void SetDefaultPopup(IDefaultPopup popup) => currentDefaultPopup = popup;
|
||||
protected void SetDefaultPopup(IDefaultPopup popup)
|
||||
{
|
||||
if(currentShownPopup.data != null && currentShownPopup.data is DefaultPopupData defaultData && currentShownPopup.data.Popup == currentDefaultPopup)
|
||||
defaultData.UpdatePopup(popup);
|
||||
|
||||
currentDefaultPopup = popup;
|
||||
}
|
||||
|
||||
|
||||
private void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null)
|
||||
@ -176,6 +184,7 @@ namespace NEG.UI
|
||||
if(currentShownPopup.data != null && currentShownPopup.priority >= priority)
|
||||
return;
|
||||
|
||||
if(currentShownPopup.data != null)
|
||||
popupsToShow.Enqueue(currentShownPopup.data, currentShownPopup.priority);
|
||||
ShowPopup(data, priority);
|
||||
return;
|
||||
|
||||
@ -36,7 +36,7 @@ namespace NEG.UI.Area
|
||||
|
||||
public void OpenWindow(IWindow window, object data = null) => DefaultWindowSlot.AttachWindow(window, data);
|
||||
|
||||
private void Awake()
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (setAsDefaultArea)
|
||||
UiManager.Instance.CurrentArea = this;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using KBCore.Refs;
|
||||
using NEG.UI.UnityUi.Window;
|
||||
using NegUtils.NEG.UI;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@ -11,6 +12,8 @@ namespace NEG.UI.UnityUi
|
||||
|
||||
[SerializeField, Self] protected InterfaceRef<IControllable> controllable;
|
||||
|
||||
protected MonoWindow ControllableAsWindow => (MonoWindow)controllable.Value;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
controllable.Value.OnOpened += OnOpened;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user