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