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
|
public class DefaultPopupData : PopupData
|
||||||
{
|
{
|
||||||
private readonly IDefaultPopup defaultPopup;
|
private IDefaultPopup defaultPopup;
|
||||||
|
|
||||||
private readonly string title;
|
private readonly string title;
|
||||||
private readonly string content;
|
private readonly string content;
|
||||||
@ -24,5 +24,12 @@ namespace NEG.UI.Popup
|
|||||||
defaultPopup.SetContent(title, content, options);
|
defaultPopup.SetContent(title, content, options);
|
||||||
base.Show();
|
base.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdatePopup(IDefaultPopup newPopup)
|
||||||
|
{
|
||||||
|
defaultPopup = newPopup;
|
||||||
|
popup = newPopup;
|
||||||
|
Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using System;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NEG.UI.Popup
|
namespace NEG.UI.Popup
|
||||||
{
|
{
|
||||||
@ -19,8 +20,10 @@ namespace NEG.UI.Popup
|
|||||||
/// Is this data is still valid. If set to false, popup will not show.
|
/// Is this data is still valid. If set to false, popup will not show.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsValid { get; protected set; }
|
public bool IsValid { get; protected set; }
|
||||||
|
|
||||||
|
public IPopup Popup => popup;
|
||||||
|
|
||||||
private readonly IPopup popup;
|
protected IPopup popup;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PopupData constructor.
|
/// PopupData constructor.
|
||||||
@ -40,7 +43,12 @@ namespace NEG.UI.Popup
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hide popup. Close visuals without firing events;
|
/// Hide popup. Close visuals without firing events;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Hide() => popup.Close(true);
|
public virtual void Hide()
|
||||||
|
{
|
||||||
|
if(popup is MonoBehaviour behaviour && behaviour == null)
|
||||||
|
return;
|
||||||
|
popup.Close(true);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invalidate popup, <see cref="UiManager"/> will automatically skip this popup
|
/// Invalidate popup, <see cref="UiManager"/> will automatically skip this popup
|
||||||
|
|||||||
@ -37,6 +37,8 @@ namespace NEG.UI
|
|||||||
public IWindow CurrentMainWindow { get; protected set; }
|
public IWindow CurrentMainWindow { get; protected set; }
|
||||||
|
|
||||||
public PopupData CurrentPopup => currentShownPopup.data;
|
public PopupData CurrentPopup => currentShownPopup.data;
|
||||||
|
|
||||||
|
public IDefaultPopup CurrentDefaultPopup => currentDefaultPopup;
|
||||||
|
|
||||||
private IArea currentArea;
|
private IArea currentArea;
|
||||||
private (PopupData data, int priority) currentShownPopup;
|
private (PopupData data, int priority) currentShownPopup;
|
||||||
@ -74,7 +76,7 @@ namespace NEG.UI
|
|||||||
{
|
{
|
||||||
var data = new DefaultPopupData(currentDefaultPopup, title, content,
|
var data = new DefaultPopupData(currentDefaultPopup, title, content,
|
||||||
new List<(string, Action)>() { (okText ?? localizedOk, okPressed) });
|
new List<(string, Action)>() { (okText ?? localizedOk, okPressed) });
|
||||||
ShowPopup(data, priority, forceShow);
|
ShowPopup(data, priority, forceShow);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,13 @@ namespace NEG.UI
|
|||||||
UpdatePopupsState(false);
|
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)
|
private void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null)
|
||||||
@ -176,7 +184,8 @@ namespace NEG.UI
|
|||||||
if(currentShownPopup.data != null && currentShownPopup.priority >= priority)
|
if(currentShownPopup.data != null && currentShownPopup.priority >= priority)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
popupsToShow.Enqueue(currentShownPopup.data, currentShownPopup.priority);
|
if(currentShownPopup.data != null)
|
||||||
|
popupsToShow.Enqueue(currentShownPopup.data, currentShownPopup.priority);
|
||||||
ShowPopup(data, priority);
|
ShowPopup(data, priority);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace NEG.UI.Area
|
|||||||
|
|
||||||
public void OpenWindow(IWindow window, object data = null) => DefaultWindowSlot.AttachWindow(window, data);
|
public void OpenWindow(IWindow window, object data = null) => DefaultWindowSlot.AttachWindow(window, data);
|
||||||
|
|
||||||
private void Awake()
|
protected virtual void Awake()
|
||||||
{
|
{
|
||||||
if (setAsDefaultArea)
|
if (setAsDefaultArea)
|
||||||
UiManager.Instance.CurrentArea = this;
|
UiManager.Instance.CurrentArea = this;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using KBCore.Refs;
|
using KBCore.Refs;
|
||||||
|
using NEG.UI.UnityUi.Window;
|
||||||
using NegUtils.NEG.UI;
|
using NegUtils.NEG.UI;
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -10,6 +11,8 @@ namespace NEG.UI.UnityUi
|
|||||||
public IControllable Controllable => controllable.Value;
|
public IControllable Controllable => controllable.Value;
|
||||||
|
|
||||||
[SerializeField, Self] protected InterfaceRef<IControllable> controllable;
|
[SerializeField, Self] protected InterfaceRef<IControllable> controllable;
|
||||||
|
|
||||||
|
protected MonoWindow ControllableAsWindow => (MonoWindow)controllable.Value;
|
||||||
|
|
||||||
protected virtual void Awake()
|
protected virtual void Awake()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user