update
This commit is contained in:
parent
15ea7f7328
commit
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;
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,8 +50,10 @@ namespace NEG.UI.Area
|
|||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
|
#if !SERVER
|
||||||
if (ReferenceEquals(UiManager.Instance.CurrentArea, this))
|
if (ReferenceEquals(UiManager.Instance.CurrentArea, this))
|
||||||
UiManager.Instance.CurrentArea = null;
|
UiManager.Instance.CurrentArea = null;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryUseBack(ref IControllable.BackUsed backUsed) => OnBackUsed?.Invoke(backUsed);
|
public void TryUseBack(ref IControllable.BackUsed backUsed) => OnBackUsed?.Invoke(backUsed);
|
||||||
|
|||||||
@ -77,11 +77,13 @@ namespace NEG.UI.UnityUi.Buttons
|
|||||||
|
|
||||||
protected virtual void Awake()
|
protected virtual void Awake()
|
||||||
{
|
{
|
||||||
|
#if !SERVER
|
||||||
button.onClick.AddListener(OnClicked);
|
button.onClick.AddListener(OnClicked);
|
||||||
if (groupButtonSettings == null)
|
if (groupButtonSettings == null)
|
||||||
MonoUiManager.Instance.DefaultUiSettings.Apply(this);
|
MonoUiManager.Instance.DefaultUiSettings.Apply(this);
|
||||||
else
|
else
|
||||||
groupButtonSettings.Apply(this);
|
groupButtonSettings.Apply(this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start() => OnDeselect(null);
|
private void Start() => OnDeselect(null);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user