Compare commits

...

3 Commits

Author SHA1 Message Date
b29bd22db0 Translation 2023-11-21 01:20:27 +01:00
858bfaa0ae WIP 2023-11-20 12:29:56 +01:00
7131c14d99 update 2023-11-11 17:04:30 +01:00
5 changed files with 34 additions and 7 deletions

View File

@ -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();
}
}
}

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;