54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using JetBrains.Annotations;
|
|
using System;
|
|
|
|
namespace NEG.UI.Popup
|
|
{
|
|
[PublicAPI]
|
|
public class PopupData
|
|
{
|
|
private readonly IPopup popup;
|
|
|
|
/// <summary>
|
|
/// PopupData constructor.
|
|
/// </summary>
|
|
/// <param name="popup">attached to this data, can be used by different data instances</param>
|
|
public PopupData(IPopup popup)
|
|
{
|
|
this.popup = popup;
|
|
IsValid = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Is this data is still valid. If set to false, popup will not show.
|
|
/// </summary>
|
|
public bool IsValid { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Event that is fired on closing popup.
|
|
/// </summary>
|
|
public event Action<PopupData> PopupClosedEvent
|
|
{
|
|
add => popup.OnPopupClosed += value;
|
|
remove => popup.OnPopupClosed -= value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show popup and pass needed data.
|
|
/// </summary>
|
|
public virtual void Show() => popup.Show(this);
|
|
|
|
/// <summary>
|
|
/// Hide popup. Close visuals without firing events;
|
|
/// </summary>
|
|
public virtual void Hide() => popup.Close(true);
|
|
|
|
/// <summary>
|
|
/// Invalidate popup, <see cref="UiManager" /> will automatically skip this popup
|
|
/// </summary>
|
|
public virtual void Invalidate()
|
|
{
|
|
IsValid = false;
|
|
UiManager.Instance.RefreshPopups();
|
|
}
|
|
}
|
|
} |