45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using JetBrains.Annotations;
|
|
using NEG.UI.Area;
|
|
using System;
|
|
|
|
namespace NEG.UI.Popup
|
|
{
|
|
[PublicAPI]
|
|
public interface IPopup : IUiElement
|
|
{
|
|
/// <summary>
|
|
/// Call when popup is not forcly closed
|
|
/// </summary>
|
|
event Action<IPopup> OnPopupClosed;
|
|
|
|
/// <summary>
|
|
/// Is popup still valid to show
|
|
/// </summary>
|
|
bool IsValid { get; }
|
|
|
|
/// <summary>
|
|
/// Mark popup as ready to show.
|
|
/// </summary>
|
|
internal void Show();
|
|
|
|
/// <summary>
|
|
/// Close popup or mark as closed if not visible
|
|
/// </summary>
|
|
/// <param name="isForced">Is closing by forced by system, ex. close area</param>
|
|
void Close(bool isForced = false);
|
|
}
|
|
|
|
public static class PopupExtensions
|
|
{
|
|
public static void Show(this IPopup popup, IArea area = null)
|
|
{
|
|
if (area != null)
|
|
{
|
|
area.OpenPopup(popup);
|
|
return;
|
|
}
|
|
|
|
UiManager.Instance.CurrentArea.OpenPopup(popup);
|
|
}
|
|
}
|
|
} |