disable create file dialog create button if asset can't be created
This commit is contained in:
@@ -13,6 +13,11 @@ namespace FlaxEditor.Content.Create
|
||||
/// <inheritdoc />
|
||||
public string ResultUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets wether a file can be created based on the current settings.
|
||||
/// </summary>
|
||||
public abstract bool CanBeCreated { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this entry has settings to modify.
|
||||
/// </summary>
|
||||
|
||||
@@ -60,7 +60,8 @@ namespace FlaxEditor.Content.Create
|
||||
Text = "Create",
|
||||
AnchorPreset = AnchorPresets.BottomRight,
|
||||
Offsets = new Margin(-ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight),
|
||||
Parent = this
|
||||
Parent = this,
|
||||
Enabled = entry.CanBeCreated,
|
||||
};
|
||||
createButton.Clicked += OnSubmit;
|
||||
var cancelButton = new Button
|
||||
@@ -68,7 +69,7 @@ namespace FlaxEditor.Content.Create
|
||||
Text = "Cancel",
|
||||
AnchorPreset = AnchorPresets.BottomRight,
|
||||
Offsets = new Margin(-ButtonsWidth - ButtonsMargin - ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight),
|
||||
Parent = this
|
||||
Parent = this,
|
||||
};
|
||||
cancelButton.Clicked += OnCancel;
|
||||
|
||||
@@ -77,7 +78,7 @@ namespace FlaxEditor.Content.Create
|
||||
{
|
||||
AnchorPreset = AnchorPresets.HorizontalStretchTop,
|
||||
Offsets = new Margin(2, 2, infoLabel.Bottom + 2, EditorHeight),
|
||||
Parent = this
|
||||
Parent = this,
|
||||
};
|
||||
|
||||
// Settings editor
|
||||
@@ -87,6 +88,7 @@ namespace FlaxEditor.Content.Create
|
||||
_dialogSize = new Float2(TotalWidth, panel.Bottom);
|
||||
|
||||
_settingsEditor.Select(_entry.Settings);
|
||||
_settingsEditor.Modified += () => createButton.Enabled = _entry.CanBeCreated;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace FlaxEditor.Content.Create
|
||||
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
|
||||
public class ParticleEmitterCreateEntry : CreateFileEntry
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool CanBeCreated => true;
|
||||
|
||||
/// <summary>
|
||||
/// Types of the emitter templates that can be created.
|
||||
/// </summary>
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace FlaxEditor.Content.Create
|
||||
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
|
||||
public class PrefabCreateEntry : CreateFileEntry
|
||||
{
|
||||
public override bool CanBeCreated => _options.RootActorType != null;
|
||||
|
||||
/// <summary>
|
||||
/// The create options.
|
||||
/// </summary>
|
||||
@@ -73,6 +75,9 @@ namespace FlaxEditor.Content.Create
|
||||
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
|
||||
public class WidgetCreateEntry : CreateFileEntry
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool CanBeCreated => _options.RootControlType != null;
|
||||
|
||||
/// <summary>
|
||||
/// The create options.
|
||||
/// </summary>
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace FlaxEditor.Content.Create
|
||||
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
|
||||
internal class SettingsCreateEntry : CreateFileEntry
|
||||
{
|
||||
public override bool CanBeCreated => _options.Type != null;
|
||||
|
||||
internal class Options
|
||||
{
|
||||
[Tooltip("The settings type.")]
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace FlaxEditor.Content.Create
|
||||
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
|
||||
public class VisualScriptCreateEntry : CreateFileEntry
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool CanBeCreated => _options.BaseClass != null;
|
||||
|
||||
/// <summary>
|
||||
/// The create options.
|
||||
/// </summary>
|
||||
|
||||
@@ -65,6 +65,9 @@ namespace FlaxEditor.Content
|
||||
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
|
||||
public class GenericJsonCreateEntry : CreateFileEntry
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool CanBeCreated => _options.Type != null;
|
||||
|
||||
/// <summary>
|
||||
/// The create options.
|
||||
/// </summary>
|
||||
|
||||
@@ -102,6 +102,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
private class CookData : CreateFileEntry
|
||||
{
|
||||
public override bool CanBeCreated => true;
|
||||
|
||||
public PropertiesProxy Proxy;
|
||||
public CollisionDataType Type;
|
||||
public ModelBase Model;
|
||||
|
||||
Reference in New Issue
Block a user