UI/SpawnMenu/Spawnlists/SpawnlistCreatePopup.razor
@using Sandbox;
@using Sandbox.UI;
@inherits Panel
@namespace Sandbox
<root class="popup prompt-popup">
<div class="inner popup-window">
<div class="popup-header">
<h2>#spawnmenu.spawnlist.create_title</h2>
<Button Icon="close" class="popup-close" @onclick=@(() => Delete()) />
</div>
<div class="popup-body">
<h3>#spawnmenu.spawnlist.create_prompt</h3>
<TextEntry class="menu-input" Placeholder="#spawnmenu.spawnlist.name_placeholder" Value:bind=@Name />
</div>
<div class="popup-footer">
<Button Text="#spawnmenu.common.cancel" class="menu-action soft" @onclick=@(() => Delete() ) />
<Button Text="#spawnmenu.spawnlist.create_button" Icon="add" class="menu-action primary popup-confirm" Disabled=@(string.IsNullOrWhiteSpace(Name)) @onclick=@OnCreate />
</div>
</div>
</root>
@code
{
public SpawnlistCreatePopup() { }
public Action OnCreated { get; set; }
public Action<Storage.Entry> OnEntryCreated { get; set; }
public SpawnlistItem InitialItem { get; set; }
public string Name { get; set; } = "";
void OnCreate()
{
if ( string.IsNullOrWhiteSpace( Name ) ) return;
SpawnlistData.Create( Name.Trim(), out var entry );
if ( InitialItem is not null )
SpawnlistData.AddItem( entry, InitialItem );
Notices.AddNotice( "list_alt", Color.Cyan, Game.Language.GetPhrase( "spawnmenu.spawnlist.created_notice", new() { { "name", Name } } ) );
OnCreated?.Invoke();
OnEntryCreated?.Invoke( entry );
Delete();
}
}