UI/Window/PinnableWindow.cs
using HC3.UI;
namespace HC3
{
public abstract class PinnableWindow<T> : Window where T : PinnableWindow<T>, new()
{
[SkipHotload]
public static List<T> Instances { get; private set; } = new();
public override bool IsPinnable => true;
public static T Show()
{
// Remove all unpinned instances
foreach ( var w in Instances.ToList() )
{
if ( !w.Pinned )
{
WindowManager.Instance.Close( w );
Instances.Remove( w );
}
}
// Create and register a new one
var instance = new T();
Instances.Add( instance );
WindowManager.Instance.Open( instance );
return instance;
}
public override void OnClose()
{
base.OnClose();
Instances.Remove( this as T );
}
}
}