Merge branch 'xxSeys1-DisableCreateButton'

This commit is contained in:
Wojtek Figat
2025-05-08 14:32:54 +02:00
8 changed files with 28 additions and 3 deletions

View File

@@ -13,6 +13,11 @@ namespace FlaxEditor.Content.Create
/// <inheritdoc /> /// <inheritdoc />
public string ResultUrl { get; } public string ResultUrl { get; }
/// <summary>
/// Gets a value indicating wether a file can be created based on the current settings.
/// </summary>
public abstract bool CanBeCreated { get; }
/// <summary> /// <summary>
/// Gets a value indicating whether this entry has settings to modify. /// Gets a value indicating whether this entry has settings to modify.
/// </summary> /// </summary>

View File

@@ -60,7 +60,8 @@ namespace FlaxEditor.Content.Create
Text = "Create", Text = "Create",
AnchorPreset = AnchorPresets.BottomRight, AnchorPreset = AnchorPresets.BottomRight,
Offsets = new Margin(-ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight), Offsets = new Margin(-ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight),
Parent = this Parent = this,
Enabled = entry.CanBeCreated,
}; };
createButton.Clicked += OnSubmit; createButton.Clicked += OnSubmit;
var cancelButton = new Button var cancelButton = new Button
@@ -68,7 +69,7 @@ namespace FlaxEditor.Content.Create
Text = "Cancel", Text = "Cancel",
AnchorPreset = AnchorPresets.BottomRight, AnchorPreset = AnchorPresets.BottomRight,
Offsets = new Margin(-ButtonsWidth - ButtonsMargin - ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight), Offsets = new Margin(-ButtonsWidth - ButtonsMargin - ButtonsWidth - ButtonsMargin, ButtonsWidth, -ButtonsHeight - ButtonsMargin, ButtonsHeight),
Parent = this Parent = this,
}; };
cancelButton.Clicked += OnCancel; cancelButton.Clicked += OnCancel;
@@ -77,7 +78,7 @@ namespace FlaxEditor.Content.Create
{ {
AnchorPreset = AnchorPresets.HorizontalStretchTop, AnchorPreset = AnchorPresets.HorizontalStretchTop,
Offsets = new Margin(2, 2, infoLabel.Bottom + 2, EditorHeight), Offsets = new Margin(2, 2, infoLabel.Bottom + 2, EditorHeight),
Parent = this Parent = this,
}; };
// Settings editor // Settings editor
@@ -87,6 +88,7 @@ namespace FlaxEditor.Content.Create
_dialogSize = new Float2(TotalWidth, panel.Bottom); _dialogSize = new Float2(TotalWidth, panel.Bottom);
_settingsEditor.Select(_entry.Settings); _settingsEditor.Select(_entry.Settings);
_settingsEditor.Modified += () => createButton.Enabled = _entry.CanBeCreated;
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -12,6 +12,9 @@ namespace FlaxEditor.Content.Create
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" /> /// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
public class ParticleEmitterCreateEntry : CreateFileEntry public class ParticleEmitterCreateEntry : CreateFileEntry
{ {
/// <inheritdoc/>
public override bool CanBeCreated => true;
/// <summary> /// <summary>
/// Types of the emitter templates that can be created. /// Types of the emitter templates that can be created.
/// </summary> /// </summary>

View File

@@ -14,6 +14,8 @@ namespace FlaxEditor.Content.Create
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" /> /// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
public class PrefabCreateEntry : CreateFileEntry public class PrefabCreateEntry : CreateFileEntry
{ {
public override bool CanBeCreated => _options.RootActorType != null;
/// <summary> /// <summary>
/// The create options. /// The create options.
/// </summary> /// </summary>
@@ -73,6 +75,9 @@ namespace FlaxEditor.Content.Create
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" /> /// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
public class WidgetCreateEntry : CreateFileEntry public class WidgetCreateEntry : CreateFileEntry
{ {
/// <inheritdoc/>
public override bool CanBeCreated => _options.RootControlType != null;
/// <summary> /// <summary>
/// The create options. /// The create options.
/// </summary> /// </summary>

View File

@@ -17,6 +17,8 @@ namespace FlaxEditor.Content.Create
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" /> /// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
internal class SettingsCreateEntry : CreateFileEntry internal class SettingsCreateEntry : CreateFileEntry
{ {
public override bool CanBeCreated => _options.Type != null;
internal class Options internal class Options
{ {
[Tooltip("The settings type.")] [Tooltip("The settings type.")]

View File

@@ -11,6 +11,9 @@ namespace FlaxEditor.Content.Create
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" /> /// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
public class VisualScriptCreateEntry : CreateFileEntry public class VisualScriptCreateEntry : CreateFileEntry
{ {
/// <inheritdoc/>
public override bool CanBeCreated => _options.BaseClass != null;
/// <summary> /// <summary>
/// The create options. /// The create options.
/// </summary> /// </summary>

View File

@@ -65,6 +65,9 @@ namespace FlaxEditor.Content
/// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" /> /// <seealso cref="FlaxEditor.Content.Create.CreateFileEntry" />
public class GenericJsonCreateEntry : CreateFileEntry public class GenericJsonCreateEntry : CreateFileEntry
{ {
/// <inheritdoc/>
public override bool CanBeCreated => _options.Type != null;
/// <summary> /// <summary>
/// The create options. /// The create options.
/// </summary> /// </summary>

View File

@@ -102,6 +102,8 @@ namespace FlaxEditor.Windows.Assets
private class CookData : CreateFileEntry private class CookData : CreateFileEntry
{ {
public override bool CanBeCreated => true;
public PropertiesProxy Proxy; public PropertiesProxy Proxy;
public CollisionDataType Type; public CollisionDataType Type;
public ModelBase Model; public ModelBase Model;