Storage - Added migration to clear the DB

Profile - Don't store empty visual scripts
Profile tree - Improved drag & drop
This commit is contained in:
Robert committed 2022-08-04 23:01:27 +02:00
1 parent 73a80ef476
commit e9566ca689
22 files changed
+73 -515

No files matched your search

@@ -140,6 +140,7 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
valueChangedNode.UpdateOutputPins(EventPath);
}
Script.Save();
}
private void ReplaceStartNode(IEventConditionNode newStartNode)
@@ -270,7 +271,7 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
Script = _entity.Script != null
? new NodeScript<bool>($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", _entity.Script, ProfileElement.Profile)
: new NodeScript<bool>($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", ProfileElement.Profile);
: new NodeScript<bool>($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", ProfileElement.Profile);
UpdateEventNode();
}
@@ -281,8 +282,17 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
_entity.OverlapMode = (int) OverlapMode;
_entity.ToggleOffMode = (int) ToggleOffMode;
Script.Save();
_entity.Script = Script?.Entity;
// If the exit node isn't connected and there are only the start- and exit node, don't save the script
if (!Script.ExitNodeConnected && Script.Nodes.Count() <= 2)
{
_entity.Script = null;
}
else
{
Script.Save();
_entity.Script = Script.Entity;
}
EventPath?.Save();
_entity.EventPath = EventPath?.Entity;
}
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
@@ -123,7 +124,9 @@ namespace Artemis.Core
PlayMode = (StaticPlayMode) _entity.PlayMode;
StopMode = (StaticStopMode) _entity.StopMode;
Script = new NodeScript<bool>($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", _entity.Script, ProfileElement.Profile);
Script = _entity.Script != null
? new NodeScript<bool>($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", _entity.Script, ProfileElement.Profile)
: new NodeScript<bool>($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", ProfileElement.Profile);
}
/// <inheritdoc />
@@ -132,8 +135,16 @@ namespace Artemis.Core
_entity.PlayMode = (int) PlayMode;
_entity.StopMode = (int) StopMode;
Script.Save();
_entity.Script = Script.Entity;
// If the exit node isn't connected and there is only the exit node, don't save the script
if (!Script.ExitNodeConnected && Script.Nodes.Count() == 1)
{
_entity.Script = null;
}
else
{
Script.Save();
_entity.Script = Script.Entity;
}
}
/// <inheritdoc />
@@ -39,7 +39,7 @@ namespace Artemis.Core
/// Gets the layer property this data binding targets
/// </summary>
public LayerProperty<TLayerProperty> LayerProperty { get; }
/// <inheritdoc />
public INodeScript Script => _script;
@@ -204,7 +204,6 @@ namespace Artemis.Core
/// <inheritdoc />
public event EventHandler<DataBindingEventArgs>? DataBindingDisabled;
#region Storage
/// <inheritdoc />
@@ -231,9 +230,14 @@ namespace Artemis.Core
if (_disposed)
throw new ObjectDisposedException("DataBinding");
_script.Save();
Entity.IsEnabled = IsEnabled;
Entity.NodeScript = _script.Entity.Nodes.Any() ? _script.Entity : null;
if (_script.ExitNodeConnected || _script.Nodes.Count() > 1)
{
_script.Save();
Entity.NodeScript = _script.Entity;
}
else
Entity.NodeScript = null;
}
#endregion