update
This commit is contained in:
parent
15ea7f7328
commit
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
|
||||
{
|
||||
@ -19,8 +20,10 @@ namespace NEG.UI.Popup
|
||||
/// Is this data is still valid. If set to false, popup will not show.
|
||||
/// </summary>
|
||||
public bool IsValid { get; protected set; }
|
||||
|
||||
public IPopup Popup => popup;
|
||||
|
||||
private readonly IPopup 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
|
||||
|
||||
@ -37,6 +37,8 @@ namespace NEG.UI
|
||||
public IWindow CurrentMainWindow { get; protected set; }
|
||||
|
||||
public PopupData CurrentPopup => currentShownPopup.data;
|
||||
|
||||
public IDefaultPopup CurrentDefaultPopup => currentDefaultPopup;
|
||||
|
||||
private IArea currentArea;
|
||||
private (PopupData data, int priority) currentShownPopup;
|
||||
@ -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,7 +184,8 @@ namespace NEG.UI
|
||||
if(currentShownPopup.data != null && currentShownPopup.priority >= priority)
|
||||
return;
|
||||
|
||||
popupsToShow.Enqueue(currentShownPopup.data, currentShownPopup.priority);
|
||||
if(currentShownPopup.data != null)
|
||||
popupsToShow.Enqueue(currentShownPopup.data, currentShownPopup.priority);
|
||||
ShowPopup(data, priority);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,8 +50,10 @@ namespace NEG.UI.Area
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
#if !SERVER
|
||||
if (ReferenceEquals(UiManager.Instance.CurrentArea, this))
|
||||
UiManager.Instance.CurrentArea = null;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void TryUseBack(ref IControllable.BackUsed backUsed) => OnBackUsed?.Invoke(backUsed);
|
||||
|
||||
@ -77,11 +77,13 @@ namespace NEG.UI.UnityUi.Buttons
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if !SERVER
|
||||
button.onClick.AddListener(OnClicked);
|
||||
if (groupButtonSettings == null)
|
||||
MonoUiManager.Instance.DefaultUiSettings.Apply(this);
|
||||
else
|
||||
groupButtonSettings.Apply(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Start() => OnDeselect(null);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user