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 = new Sandbox.UI.Menu();
menu.AddOption( "#spawnmenu.common.delete", "delete", () => Content.Delete() );
menu.AddOption( "#spawnmenu.common.publish", "publish", Publish );
SpawnlistData.PopulateContextMenu( menu, this, new SpawnlistItem
{
Ident = SpawnlistItem.MakeIdent( "dupe", Content.Id.ToString(), "local" ),
Title = Content.GetMeta<string>( "name" ) ?? "Dupe",
Icon = null,
} );
menu.Open( this, Popup.PositionMode.UnderMouse );
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);
}
}