Add SurfaceNodeActions for more contextual surface nodes scripting
This commit is contained in:
@@ -542,9 +542,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
@@ -174,17 +174,17 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
// Ensure to have unique name
|
||||
var title = StateMachineTitle;
|
||||
@@ -741,9 +741,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
LoadTransitions();
|
||||
|
||||
@@ -1432,9 +1432,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
public override int TransitionsDataIndex => 2;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
// Ensure to have unique name
|
||||
var title = StateTitle;
|
||||
@@ -1452,9 +1452,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
UpdateTitle();
|
||||
@@ -162,9 +162,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
// Peek deserialized boxes
|
||||
_blendPoses.Clear();
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
// Restore saved input boxes layout
|
||||
if (Values[0] is byte[] data)
|
||||
@@ -62,9 +62,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateBoxes();
|
||||
GetBox(0).CurrentTypeChanged += box => UpdateBoxes();
|
||||
|
||||
@@ -43,9 +43,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
box.CurrentType = new ScriptType(Values[0].GetType());
|
||||
}
|
||||
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
var box = (OutputBox)GetBox(0);
|
||||
if (Values[0] == null)
|
||||
@@ -100,9 +100,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
base.OnValuesChanged();
|
||||
}
|
||||
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
_output = (OutputBox)Elements[0];
|
||||
_typePicker = new TypePickerControl
|
||||
@@ -238,9 +238,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
base.OnValuesChanged();
|
||||
}
|
||||
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
_output = (OutputBox)Elements[0];
|
||||
_keyTypePicker = new TypePickerControl
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
// Restore saved output boxes layout
|
||||
var count = (int)Values[0];
|
||||
@@ -35,9 +35,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
AddBox(true, i + 1, i, string.Empty, new ScriptType(typeof(void)), true);
|
||||
}
|
||||
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
_removeButton = new Button(0, 0, 20, 20)
|
||||
{
|
||||
@@ -107,9 +107,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
// Restore saved output boxes layout
|
||||
if (Values[0] is byte[] data)
|
||||
@@ -119,9 +119,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateBoxes();
|
||||
GetBox(1).CurrentTypeChanged += box => UpdateBoxes();
|
||||
|
||||
@@ -54,9 +54,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
protected abstract Asset LoadSignature(Guid id, out string[] types, out string[] names);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
FlaxEngine.Content.AssetReloading += OnAssetReloading;
|
||||
FlaxEngine.Content.AssetDisposing += OnContentAssetDisposing;
|
||||
@@ -275,17 +275,17 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
_nameField.Text = SignatureName;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
// Ensure to have unique name
|
||||
var name = SignatureName;
|
||||
@@ -397,9 +397,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
_outputBox = GetBox(0);
|
||||
_outputBox.CurrentType = SignatureType;
|
||||
@@ -466,9 +466,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
_inputBox = GetBox(0);
|
||||
_inputBox.CurrentType = SignatureType;
|
||||
@@ -634,18 +634,18 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
protected override Color FooterColor => new Color(200, 11, 112);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
Title = SurfaceUtils.GetMethodDisplayName((string)Values[0]);
|
||||
UpdateSignature();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
// Update the boxes connection types to match the signature
|
||||
// Do it after surface load so connections can receive update on type changes of the method parameter
|
||||
@@ -663,9 +663,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
var method = GetMethod();
|
||||
_parameters = null;
|
||||
@@ -999,9 +999,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
var method = GetMethod(out _, out _, out var parameters);
|
||||
if (method && parameters != null)
|
||||
@@ -1028,18 +1028,18 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
Title = SurfaceUtils.GetMethodDisplayName((string)Values[1]);
|
||||
UpdateSignature();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
// Update the boxes connection types to match the signature
|
||||
// Do it after surface load so connections can receive update on type changes of the method parameter
|
||||
@@ -1182,9 +1182,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
UpdateSignature();
|
||||
}
|
||||
@@ -1700,9 +1700,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
LoadSignature();
|
||||
|
||||
@@ -1715,9 +1715,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
// Setup initial signature
|
||||
var defaultSignature = _signature.Node == null;
|
||||
@@ -1743,7 +1743,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnDeleted()
|
||||
public override void OnDeleted(SurfaceNodeActions action)
|
||||
{
|
||||
// Send event
|
||||
for (int i = 0; i < Surface.Nodes.Count; i++)
|
||||
@@ -1752,7 +1752,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
node.OnFunctionDeleted(this);
|
||||
}
|
||||
|
||||
base.OnDeleted();
|
||||
base.OnDeleted(action);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1906,9 +1906,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
Title = "Get " + SurfaceUtils.GetMethodDisplayName((string)Values[1]);
|
||||
UpdateSignature();
|
||||
@@ -1959,9 +1959,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
Title = "Set " + SurfaceUtils.GetMethodDisplayName((string)Values[1]);
|
||||
UpdateSignature();
|
||||
@@ -2135,9 +2135,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
// Find reflection information about event
|
||||
_signature = null;
|
||||
@@ -2193,11 +2193,11 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
Title = "Bind " + (string)Values[1];
|
||||
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2208,11 +2208,11 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
Title = "Unbind " + (string)Values[1];
|
||||
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,9 +197,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
// Fix emissive box (it's a strange error)
|
||||
GetBox(3).CurrentType = new ScriptType(typeof(Float3));
|
||||
|
||||
@@ -30,9 +30,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
_in0 = (InputBox)GetBox(0);
|
||||
_in1 = (InputBox)GetBox(1);
|
||||
@@ -111,9 +111,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
// Update title and the tooltip
|
||||
var typeName = (string)Values[0];
|
||||
|
||||
@@ -426,9 +426,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
{
|
||||
@@ -438,9 +438,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateTitle();
|
||||
}
|
||||
@@ -832,9 +832,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
UpdateCombo();
|
||||
@@ -842,9 +842,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
{
|
||||
|
||||
@@ -268,20 +268,20 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
_enabled.Checked = ModuleEnabled;
|
||||
_enabled.StateChanged += OnEnabledStateChanged;
|
||||
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
ParticleSurface?.ArrangeModulesNodes();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
ParticleSurface.ArrangeModulesNodes();
|
||||
}
|
||||
@@ -295,11 +295,11 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnDeleted()
|
||||
public override void OnDeleted(SurfaceNodeActions action)
|
||||
{
|
||||
ParticleSurface.ArrangeModulesNodes();
|
||||
|
||||
base.OnDeleted();
|
||||
base.OnDeleted(action);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -324,9 +324,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateOutputBoxType();
|
||||
}
|
||||
@@ -381,9 +381,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateInputBox();
|
||||
}
|
||||
@@ -416,9 +416,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateTextBox();
|
||||
}
|
||||
|
||||
@@ -214,9 +214,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
if (Surface == null)
|
||||
return;
|
||||
@@ -265,9 +265,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateOutputBoxType();
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
@@ -193,9 +193,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
var upperLeft = GetBox(0).BottomLeft;
|
||||
var upperRight = GetBox(1).BottomRight;
|
||||
@@ -477,9 +477,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
var upperLeft = GetBox(0).BottomLeft;
|
||||
var upperRight = GetBox(1).BottomRight;
|
||||
@@ -657,9 +657,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
UpdateCombo();
|
||||
}
|
||||
@@ -682,9 +682,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
var type = ScriptType.Null;
|
||||
if (Context.Surface is VisualScriptSurface visjectSurface)
|
||||
@@ -710,9 +710,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
UpdateOutputBox();
|
||||
}
|
||||
@@ -763,9 +763,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
UpdateOutputBox();
|
||||
}
|
||||
@@ -822,9 +822,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
_picker.ValueTypeName = (string)Values[0];
|
||||
@@ -881,9 +881,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
_picker.ValueTypeName = (string)Values[0];
|
||||
@@ -932,9 +932,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
_picker.ValueTypeName = (string)Values[0];
|
||||
@@ -984,9 +984,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded()
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnLoaded();
|
||||
base.OnLoaded(action);
|
||||
|
||||
if (Surface != null)
|
||||
_picker.ValueTypeName = (string)Values[0];
|
||||
@@ -1047,9 +1047,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
_input = (InputBox)GetBox(0);
|
||||
_output = (OutputBox)GetBox(1);
|
||||
|
||||
@@ -59,9 +59,9 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
// Read node data
|
||||
Title = TitleValue;
|
||||
@@ -70,9 +70,9 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSpawned()
|
||||
public override void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSpawned();
|
||||
base.OnSpawned(action);
|
||||
|
||||
// Randomize color
|
||||
Color = ColorValue = Color.FromHSV(new Random().NextFloat(0, 360), 0.7f, 0.25f, 0.8f);
|
||||
|
||||
@@ -122,14 +122,14 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// Called when control gets loaded and added to surface.
|
||||
/// </summary>
|
||||
public virtual void OnLoaded()
|
||||
public virtual void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when surface gets loaded and nodes boxes are connected.
|
||||
/// </summary>
|
||||
public virtual void OnSurfaceLoaded()
|
||||
public virtual void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
UpdateRectangles();
|
||||
}
|
||||
@@ -137,14 +137,14 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// Called after adding the control to the surface after user spawn (eg. add comment, add new node, etc.).
|
||||
/// </summary>
|
||||
public virtual void OnSpawned()
|
||||
public virtual void OnSpawned(SurfaceNodeActions action)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on removing the control from the surface after user delete/cut operation (eg. delete comment, cut node, etc.).
|
||||
/// </summary>
|
||||
public virtual void OnDeleted()
|
||||
public virtual void OnDeleted(SurfaceNodeActions action)
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
@@ -884,9 +884,9 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded()
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
base.OnSurfaceLoaded();
|
||||
base.OnSurfaceLoaded(action);
|
||||
|
||||
UpdateBoxesTypes();
|
||||
|
||||
@@ -898,11 +898,11 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnDeleted()
|
||||
public override void OnDeleted(SurfaceNodeActions action)
|
||||
{
|
||||
RemoveConnections();
|
||||
|
||||
base.OnDeleted();
|
||||
base.OnDeleted(action);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -67,8 +67,8 @@ namespace FlaxEditor.Surface.Undo
|
||||
else if (_nodeValues != null && _nodeValues.Length != 0)
|
||||
throw new InvalidOperationException("Invalid node values.");
|
||||
node.Location = _nodeLocation;
|
||||
context.OnControlLoaded(node);
|
||||
node.OnSurfaceLoaded();
|
||||
context.OnControlLoaded(node, SurfaceNodeActions.Undo);
|
||||
node.OnSurfaceLoaded(SurfaceNodeActions.Undo);
|
||||
|
||||
context.MarkAsModified();
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace FlaxEditor.Surface.Undo
|
||||
|
||||
// Remove node
|
||||
context.Nodes.Remove(node);
|
||||
context.OnControlDeleted(node);
|
||||
context.OnControlDeleted(node, SurfaceNodeActions.Undo);
|
||||
|
||||
context.MarkAsModified();
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
}
|
||||
|
||||
Context.OnControlLoaded(node);
|
||||
Context.OnControlLoaded(node, SurfaceNodeActions.Paste);
|
||||
}
|
||||
|
||||
// Setup connections
|
||||
@@ -413,11 +413,11 @@ namespace FlaxEditor.Surface
|
||||
// Post load
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
node.Value.OnSurfaceLoaded();
|
||||
node.Value.OnSurfaceLoaded(SurfaceNodeActions.Paste);
|
||||
}
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
node.Value.OnSpawned();
|
||||
node.Value.OnSpawned(SurfaceNodeActions.Paste);
|
||||
}
|
||||
|
||||
// Add undo action
|
||||
|
||||
@@ -772,7 +772,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.OnControlDeleted(control);
|
||||
Context.OnControlDeleted(control, SurfaceNodeActions.User);
|
||||
}
|
||||
}
|
||||
if (selectionChanged)
|
||||
@@ -787,7 +787,7 @@ namespace FlaxEditor.Surface
|
||||
{
|
||||
node.RemoveConnections();
|
||||
Nodes.Remove(node);
|
||||
Context.OnControlDeleted(node);
|
||||
Context.OnControlDeleted(node, SurfaceNodeActions.User);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -13,6 +13,32 @@ using Utils = FlaxEditor.Utilities.Utils;
|
||||
|
||||
namespace FlaxEditor.Surface
|
||||
{
|
||||
/// <summary>
|
||||
/// Types of surface actions.
|
||||
/// </summary>
|
||||
public enum SurfaceNodeActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Node has been created by surface load.
|
||||
/// </summary>
|
||||
Load,
|
||||
|
||||
/// <summary>
|
||||
/// Node has been created/deleted by user action.
|
||||
/// </summary>
|
||||
User,
|
||||
|
||||
/// <summary>
|
||||
/// Node has been created/deleted via undo.
|
||||
/// </summary>
|
||||
Undo,
|
||||
|
||||
/// <summary>
|
||||
/// Node has been pasted.
|
||||
/// </summary>
|
||||
Paste,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The missing node. Cached the node group, type and stored values information.
|
||||
/// </summary>
|
||||
@@ -135,7 +161,7 @@ namespace FlaxEditor.Surface
|
||||
if (comment == null)
|
||||
throw new InvalidOperationException("Failed to create comment.");
|
||||
|
||||
OnControlLoaded(comment);
|
||||
OnControlLoaded(comment, SurfaceNodeActions.Load);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,7 +170,7 @@ namespace FlaxEditor.Surface
|
||||
for (int i = 0; i < RootControl.Children.Count; i++)
|
||||
{
|
||||
if (RootControl.Children[i] is SurfaceControl control)
|
||||
control.OnSurfaceLoaded();
|
||||
control.OnSurfaceLoaded(SurfaceNodeActions.Load);
|
||||
}
|
||||
|
||||
RootControl.UnlockChildrenRecursive();
|
||||
@@ -650,7 +676,7 @@ namespace FlaxEditor.Surface
|
||||
// Meta
|
||||
node.Meta.Load(stream);
|
||||
|
||||
OnControlLoaded(node);
|
||||
OnControlLoaded(node, SurfaceNodeActions.Load);
|
||||
}
|
||||
}
|
||||
else if (version == 7000)
|
||||
@@ -813,7 +839,7 @@ namespace FlaxEditor.Surface
|
||||
// Meta
|
||||
node.Meta.Load(stream);
|
||||
|
||||
OnControlLoaded(node);
|
||||
OnControlLoaded(node, SurfaceNodeActions.Load);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -856,9 +882,10 @@ namespace FlaxEditor.Surface
|
||||
/// Called when control gets added to the surface as spawn operation (eg. add new comment or add new node).
|
||||
/// </summary>
|
||||
/// <param name="control">The control.</param>
|
||||
public virtual void OnControlSpawned(SurfaceControl control)
|
||||
/// <param name="action">The action node.</param>
|
||||
public virtual void OnControlSpawned(SurfaceControl control, SurfaceNodeActions action)
|
||||
{
|
||||
control.OnSpawned();
|
||||
control.OnSpawned(action);
|
||||
ControlSpawned?.Invoke(control);
|
||||
if (Surface != null && control is SurfaceNode node)
|
||||
Surface.OnNodeSpawned(node);
|
||||
@@ -868,10 +895,11 @@ namespace FlaxEditor.Surface
|
||||
/// Called when control gets removed from the surface as delete/cut operation (eg. remove comment or cut node).
|
||||
/// </summary>
|
||||
/// <param name="control">The control.</param>
|
||||
public virtual void OnControlDeleted(SurfaceControl control)
|
||||
/// <param name="action">The action node.</param>
|
||||
public virtual void OnControlDeleted(SurfaceControl control, SurfaceNodeActions action)
|
||||
{
|
||||
ControlDeleted?.Invoke(control);
|
||||
control.OnDeleted();
|
||||
control.OnDeleted(action);
|
||||
if (control is SurfaceNode node)
|
||||
Surface.OnNodeDeleted(node);
|
||||
}
|
||||
@@ -880,16 +908,17 @@ namespace FlaxEditor.Surface
|
||||
/// Called when control gets loaded and should be added to the surface. Handles surface nodes initialization.
|
||||
/// </summary>
|
||||
/// <param name="control">The control.</param>
|
||||
public virtual void OnControlLoaded(SurfaceControl control)
|
||||
/// <param name="action">The action node.</param>
|
||||
public virtual void OnControlLoaded(SurfaceControl control, SurfaceNodeActions action)
|
||||
{
|
||||
if (control is SurfaceNode node)
|
||||
{
|
||||
// Initialize node
|
||||
OnNodeLoaded(node);
|
||||
OnNodeLoaded(node, action);
|
||||
}
|
||||
|
||||
// Link control
|
||||
control.OnLoaded();
|
||||
control.OnLoaded(action);
|
||||
control.Parent = RootControl;
|
||||
|
||||
if (control is SurfaceComment)
|
||||
@@ -903,7 +932,8 @@ namespace FlaxEditor.Surface
|
||||
/// Called when node gets loaded and should be added to the surface. Creates node elements from the archetype.
|
||||
/// </summary>
|
||||
/// <param name="node">The node.</param>
|
||||
public virtual void OnNodeLoaded(SurfaceNode node)
|
||||
/// <param name="action">The action node.</param>
|
||||
public virtual void OnNodeLoaded(SurfaceNode node, SurfaceNodeActions action)
|
||||
{
|
||||
// Create child elements of the node based on it's archetype
|
||||
int elementsCount = node.Archetype.Elements?.Length ?? 0;
|
||||
|
||||
@@ -315,9 +315,9 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
// Initialize
|
||||
OnControlLoaded(comment);
|
||||
comment.OnSurfaceLoaded();
|
||||
OnControlSpawned(comment);
|
||||
OnControlLoaded(comment, SurfaceNodeActions.User);
|
||||
comment.OnSurfaceLoaded(SurfaceNodeActions.User);
|
||||
OnControlSpawned(comment, SurfaceNodeActions.User);
|
||||
|
||||
MarkAsModified();
|
||||
|
||||
@@ -389,10 +389,10 @@ namespace FlaxEditor.Surface
|
||||
throw new InvalidOperationException("Invalid node custom values.");
|
||||
}
|
||||
node.Location = location;
|
||||
OnControlLoaded(node);
|
||||
OnControlLoaded(node, SurfaceNodeActions.User);
|
||||
beforeSpawned?.Invoke(node);
|
||||
node.OnSurfaceLoaded();
|
||||
OnControlSpawned(node);
|
||||
node.OnSurfaceLoaded(SurfaceNodeActions.User);
|
||||
OnControlSpawned(node, SurfaceNodeActions.User);
|
||||
|
||||
// Undo action
|
||||
if (Surface != null)
|
||||
|
||||
@@ -127,9 +127,9 @@ namespace FlaxEditor.Windows
|
||||
Nodes.AddRange(nodes);
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
Context.OnControlLoaded(node);
|
||||
node.OnSurfaceLoaded();
|
||||
Context.OnControlSpawned(node);
|
||||
Context.OnControlLoaded(node, SurfaceNodeActions.Load);
|
||||
node.OnSurfaceLoaded(SurfaceNodeActions.Load);
|
||||
Context.OnControlSpawned(node, SurfaceNodeActions.Load);
|
||||
}
|
||||
ShowWholeGraph();
|
||||
UnlockChildrenRecursive();
|
||||
|
||||
Reference in New Issue
Block a user