UI component for the spawnlist footer in the Spawn Menu. It renders a footer panel, decides if creation is allowed, opens a create popup, and triggers the parent SpawnlistsPage to refresh the list.
using Sandbox.UI;
namespace Sandbox;
public partial class SpawnlistFooter : Panel
{
protected override int BuildHash() => HashCode.Combine( CanCreate() );
bool CanCreate()
{
return true;
}
void CreatePopup()
{
var popup = new SpawnlistCreatePopup();
popup.Parent = FindPopupPanel();
popup.OnCreated = () => Ancestors.OfType<SpawnlistsPage>().FirstOrDefault()?.RefreshList();
}
void Refresh()
{
Ancestors.OfType<SpawnlistsPage>().FirstOrDefault()?.RefreshList();
}
}