mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Added undo/redo to profile editor
Added shape anchor point display and movement
This commit is contained in:
1 parent
e9677f2070
commit
c97b479779
25 files changed
+386
-68
No files matched your search
@@ -19,5 +19,19 @@ namespace Artemis.Core.Services.Storage.Interfaces
|
||||
/// <param name="module">The module to activate the profile for</param>
|
||||
/// <param name="profile">The profile to activate</param>
|
||||
void ActivateProfile(ProfileModule module, Profile profile);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to restore the profile to the state it had before the last <see cref="UpdateProfile" /> call.
|
||||
/// </summary>
|
||||
/// <param name="selectedProfile"></param>
|
||||
/// <param name="module"></param>
|
||||
void UndoUpdateProfile(Profile selectedProfile, ProfileModule module);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to restore the profile to the state it had before the last <see cref="UndoUpdateProfile" /> call.
|
||||
/// </summary>
|
||||
/// <param name="selectedProfile"></param>
|
||||
/// <param name="module"></param>
|
||||
void RedoUpdateProfile(Profile selectedProfile, ProfileModule module);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,9 @@ using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core.Services.Storage
|
||||
{
|
||||
@@ -92,6 +94,10 @@ namespace Artemis.Core.Services.Storage
|
||||
|
||||
public void UpdateProfile(Profile profile, bool includeChildren)
|
||||
{
|
||||
var memento = JsonConvert.SerializeObject(profile.ProfileEntity);
|
||||
profile.RedoStack.Clear();
|
||||
profile.UndoStack.Push(memento);
|
||||
|
||||
profile.ApplyToEntity();
|
||||
if (includeChildren)
|
||||
{
|
||||
@@ -104,6 +110,34 @@ namespace Artemis.Core.Services.Storage
|
||||
_profileRepository.Save(profile.ProfileEntity);
|
||||
}
|
||||
|
||||
public void UndoUpdateProfile(Profile profile, ProfileModule module)
|
||||
{
|
||||
if (!profile.UndoStack.Any())
|
||||
return;
|
||||
|
||||
ActivateProfile(module, null);
|
||||
var top = profile.UndoStack.Pop();
|
||||
var memento = JsonConvert.SerializeObject(profile.ProfileEntity);
|
||||
profile.RedoStack.Push(memento);
|
||||
profile.ProfileEntity = JsonConvert.DeserializeObject<ProfileEntity>(top);
|
||||
profile.ApplyToProfile();
|
||||
ActivateProfile(module, profile);
|
||||
}
|
||||
|
||||
public void RedoUpdateProfile(Profile profile, ProfileModule module)
|
||||
{
|
||||
if (!profile.RedoStack.Any())
|
||||
return;
|
||||
|
||||
ActivateProfile(module, null);
|
||||
var top = profile.RedoStack.Pop();
|
||||
var memento = JsonConvert.SerializeObject(profile.ProfileEntity);
|
||||
profile.UndoStack.Push(memento);
|
||||
profile.ProfileEntity = JsonConvert.DeserializeObject<ProfileEntity>(top);
|
||||
profile.ApplyToProfile();
|
||||
ActivateProfile(module, profile);
|
||||
}
|
||||
|
||||
private void InstantiateProfileLayerBrushes(Profile profile)
|
||||
{
|
||||
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
|
||||
|
||||
Reference in new issue
Block a user