mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Scripts - Properly register script with its owner
Scripts UI - Save on close Scripts UI - Dispose script on removal
This commit is contained in:
parent
5367027471
commit
a5c13bb543
@ -11,6 +11,10 @@ namespace Artemis.Core.ScriptingProviders
|
|||||||
protected LayerScript(Layer layer, ScriptConfiguration configuration) : base(configuration)
|
protected LayerScript(Layer layer, ScriptConfiguration configuration) : base(configuration)
|
||||||
{
|
{
|
||||||
Layer = layer;
|
Layer = layer;
|
||||||
|
lock (Layer.Scripts)
|
||||||
|
{
|
||||||
|
Layer.Scripts.Add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -11,6 +11,10 @@ namespace Artemis.Core.ScriptingProviders
|
|||||||
protected ProfileScript(Profile profile, ScriptConfiguration configuration) : base(configuration)
|
protected ProfileScript(Profile profile, ScriptConfiguration configuration) : base(configuration)
|
||||||
{
|
{
|
||||||
Profile = profile;
|
Profile = profile;
|
||||||
|
lock (Profile.Scripts)
|
||||||
|
{
|
||||||
|
Profile.Scripts.Add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -10,6 +10,10 @@
|
|||||||
protected PropertyScript(ILayerProperty layerProperty, ScriptConfiguration configuration) : base(configuration)
|
protected PropertyScript(ILayerProperty layerProperty, ScriptConfiguration configuration) : base(configuration)
|
||||||
{
|
{
|
||||||
LayerProperty = layerProperty;
|
LayerProperty = layerProperty;
|
||||||
|
lock (LayerProperty.Scripts)
|
||||||
|
{
|
||||||
|
LayerProperty.Scripts.Add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -68,6 +68,7 @@ namespace Artemis.UI.Screens.Scripting
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScriptConfiguration.DiscardPendingChanges();
|
ScriptConfiguration.DiscardPendingChanges();
|
||||||
|
ScriptConfiguration.Script?.Dispose();
|
||||||
RequestClose();
|
RequestClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,15 +15,17 @@ namespace Artemis.UI.Screens.Scripting
|
|||||||
{
|
{
|
||||||
private readonly IScriptingService _scriptingService;
|
private readonly IScriptingService _scriptingService;
|
||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private readonly IScriptVmFactory _scriptVmFactory;
|
private readonly IScriptVmFactory _scriptVmFactory;
|
||||||
public Profile Profile { get; }
|
public Profile Profile { get; }
|
||||||
public Layer Layer { get; }
|
public Layer Layer { get; }
|
||||||
public ILayerProperty LayerProperty { get; }
|
public ILayerProperty LayerProperty { get; }
|
||||||
|
|
||||||
public ScriptsDialogViewModel(Profile profile, IScriptingService scriptingService, IDialogService dialogService, IScriptVmFactory scriptVmFactory)
|
public ScriptsDialogViewModel(Profile profile, IScriptingService scriptingService, IDialogService dialogService, IProfileEditorService profileEditorService, IScriptVmFactory scriptVmFactory)
|
||||||
{
|
{
|
||||||
_scriptingService = scriptingService;
|
_scriptingService = scriptingService;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
|
_profileEditorService = profileEditorService;
|
||||||
_scriptVmFactory = scriptVmFactory;
|
_scriptVmFactory = scriptVmFactory;
|
||||||
|
|
||||||
DisplayName = "Artemis | Profile Scripts";
|
DisplayName = "Artemis | Profile Scripts";
|
||||||
@ -74,5 +76,17 @@ namespace Artemis.UI.Screens.Scripting
|
|||||||
|
|
||||||
Items.Add(_scriptVmFactory.ScriptConfigurationViewModel(scriptConfiguration));
|
Items.Add(_scriptVmFactory.ScriptConfigurationViewModel(scriptConfiguration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Overrides of OneActive
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnClose()
|
||||||
|
{
|
||||||
|
_profileEditorService.SaveSelectedProfileConfiguration();
|
||||||
|
|
||||||
|
base.OnClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user