mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 05:48:07 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
113 lines
2.4 KiB
C#
113 lines
2.4 KiB
C#
namespace Editor;
|
|
|
|
public class BatchMarkPublishedWidget : Widget
|
|
{
|
|
public Label MessageLabel { get; set; }
|
|
|
|
public Layout ButtonLayout { get; private set; }
|
|
|
|
Asset[] assets;
|
|
|
|
string _org;
|
|
Button continueButton;
|
|
|
|
[Editor( "organisation" )]
|
|
public string TargetOrg
|
|
{
|
|
get => _org;
|
|
set
|
|
{
|
|
if ( _org == value ) return;
|
|
|
|
if ( continueButton.IsValid() )
|
|
{
|
|
continueButton.Enabled = !string.IsNullOrWhiteSpace( _org ) && _org != "local";
|
|
}
|
|
|
|
_org = value;
|
|
}
|
|
}
|
|
|
|
public BatchMarkPublishedWidget( Asset[] assets ) : base( null, true )
|
|
{
|
|
this.assets = assets;
|
|
WindowFlags = WindowFlags.Window | WindowFlags.Customized | WindowFlags.WindowTitle | WindowFlags.MSWindowsFixedSizeDialogHint;
|
|
WindowTitle = "Publishing Unpublished Assets";
|
|
SetWindowIcon( "check_circle" );
|
|
|
|
FixedWidth = 450;
|
|
|
|
Layout = Layout.Row();
|
|
Layout.Margin = 16;
|
|
|
|
var iconColumn = Layout.AddColumn();
|
|
|
|
iconColumn.Margin = 0;
|
|
iconColumn.Add( new IconButton( "🌥️" ) { IconSize = 48, FixedHeight = 64, FixedWidth = 64, Background = Color.Transparent, TransparentForMouseEvents = true } );
|
|
iconColumn.AddStretchCell();
|
|
|
|
Layout.Spacing = 32;
|
|
|
|
var column = Layout.AddColumn();
|
|
|
|
column.AddSpacingCell( 16 );
|
|
column.Spacing = 16;
|
|
|
|
MessageLabel = column.Add( new Label() );
|
|
MessageLabel.WordWrap = true;
|
|
MessageLabel.MinimumWidth = 600;
|
|
MessageLabel.TextSelectable = true;
|
|
MessageLabel.Text = "Please select an org to publish these assets to:";
|
|
|
|
column.Add( ControlWidget.Create( this.GetSerialized().GetProperty( "TargetOrg" ) ) );
|
|
|
|
column.AddSpacingCell( 16 );
|
|
|
|
column.AddStretchCell();
|
|
|
|
ButtonLayout = column.AddRow();
|
|
ButtonLayout.Spacing = 8;
|
|
|
|
ButtonLayout.AddStretchCell();
|
|
|
|
continueButton = ButtonLayout.Add( new Button.Primary( "Continue" ) );
|
|
continueButton.Clicked = () => Proceed();
|
|
|
|
var cancel = ButtonLayout.Add( new Button( "Cancel" ) );
|
|
cancel.Clicked = () => Close();
|
|
|
|
TargetOrg = Project.Current.Config.Org;
|
|
}
|
|
|
|
void Proceed()
|
|
{
|
|
foreach ( var a in assets )
|
|
{
|
|
a.Publishing.Enabled = true;
|
|
|
|
if ( string.IsNullOrWhiteSpace( a.Publishing.ProjectConfig.Org ) )
|
|
{
|
|
a.Publishing.ProjectConfig.Org = TargetOrg;
|
|
}
|
|
|
|
a.Publishing.Save();
|
|
}
|
|
|
|
BatchPublisher.FromAssets( assets );
|
|
Close();
|
|
}
|
|
|
|
protected override bool OnClose()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected override void OnPaint()
|
|
{
|
|
base.OnPaint();
|
|
|
|
Paint.SetBrushAndPen( Theme.WidgetBackground );
|
|
Paint.DrawRect( LocalRect );
|
|
}
|
|
}
|