add editor option to toggle warning
This commit is contained in:
@@ -396,6 +396,13 @@ namespace FlaxEditor.Options
|
|||||||
[EditorDisplay("Visject", "Grid Snapping Size"), EditorOrder(551), Tooltip("Defines the size of the grid for nodes snapping."), VisibleIf(nameof(SurfaceGridSnapping))]
|
[EditorDisplay("Visject", "Grid Snapping Size"), EditorOrder(551), Tooltip("Defines the size of the grid for nodes snapping."), VisibleIf(nameof(SurfaceGridSnapping))]
|
||||||
public float SurfaceGridSnappingSize { get; set; } = 20.0f;
|
public float SurfaceGridSnappingSize { get; set; } = 20.0f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value that indicates if a warning should be displayed when deleting a Visject parameter that is used in a graph.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)]
|
||||||
|
[EditorDisplay("Visject", "Warn when deleting used parameter"), EditorOrder(552)]
|
||||||
|
public bool WarnOnDeletingUsedVisjectParameter { get; set; } = true;
|
||||||
|
|
||||||
private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);
|
private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);
|
||||||
private static FontAsset ConsoleFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.InconsolataRegularFont);
|
private static FontAsset ConsoleFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.InconsolataRegularFont);
|
||||||
|
|
||||||
|
|||||||
@@ -775,6 +775,8 @@ namespace FlaxEditor.Surface
|
|||||||
|
|
||||||
private void DeleteParameter(int index)
|
private void DeleteParameter(int index)
|
||||||
{
|
{
|
||||||
|
bool displayWarning = Editor.Instance.Options.Options.Interface.WarnOnDeletingUsedVisjectParameter;
|
||||||
|
|
||||||
var window = (IVisjectSurfaceWindow)Values[0];
|
var window = (IVisjectSurfaceWindow)Values[0];
|
||||||
SurfaceParameter param = window.VisjectSurface.Parameters[index];
|
SurfaceParameter param = window.VisjectSurface.Parameters[index];
|
||||||
|
|
||||||
@@ -786,18 +788,20 @@ namespace FlaxEditor.Surface
|
|||||||
{
|
{
|
||||||
if (nodes[i] is IParametersDependantNode node)
|
if (nodes[i] is IParametersDependantNode node)
|
||||||
{
|
{
|
||||||
if ((Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0))
|
if (displayWarning && (Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0))
|
||||||
connectedParameterNodeCount++;
|
connectedParameterNodeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string singularPlural = connectedParameterNodeCount > 1 ? "s" : "";
|
if (displayWarning)
|
||||||
|
{
|
||||||
|
string singularPlural = connectedParameterNodeCount > 1 ? "s" : "";
|
||||||
|
string msg = $"Delete parameter {param.Name}?\nParameter is being used in a graph {connectedParameterNodeCount} time{singularPlural}.\n\nYou can disable this warning in the editor settings.";
|
||||||
|
|
||||||
string msg = $"Delete parameter {param.Name}?\nParameter is being used in a graph {connectedParameterNodeCount} time{singularPlural}.\n\nYou can disable this warning in the editor settings.";
|
if (connectedParameterNodeCount > 0)
|
||||||
|
if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||||||
if (connectedParameterNodeCount > 0)
|
return;
|
||||||
if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
var action = new AddRemoveParamAction
|
var action = new AddRemoveParamAction
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user