UI/SpawnMenu/Dupes/LocalDupeIcon.razor
@using Sandbox;
@using Sandbox.UI;
@using Sandbox.Mounting;
@inherits Panel
@namespace Sandbox
<root>
<div class="name">@(Content.GetMeta<string>( "name" ) ?? "Dupe")</div>
</root>
@code
{
public Storage.Entry Content;
protected override void OnParametersSet()
{
Style.SetBackgroundImage( Content.Thumbnail );
}
protected override void OnMouseDown( MousePanelEvent e )
{
if ( e.MouseButton == MouseButtons.Right )
{
var menu = MenuPanel.Open( this );
menu.AddOption( "delete", "#spawnmenu.common.delete", () => Content.Delete() );
menu.AddOption( "publish", "#spawnmenu.common.publish", Publish );
SpawnlistData.PopulateContextMenu( menu, new SpawnlistItem
{
Ident = SpawnlistItem.MakeIdent( "dupe", Content.Id.ToString(), "local" ),
Title = Content.GetMeta<string>( "name" ) ?? "Dupe",
Icon = null,
} );
return;
}
base.OnMouseDown( e );
}
void Publish()
{
var options = new Modals.WorkshopPublishOptions();
options.Title = "My Dupe";
options.AddCategory<DupeCategory>( "Category" );
options.AddCategory<DupeMovement>( "Movement" );
Content.Publish(options);
}
}