mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Core - Reworked brush/effect property storage
Profile editor - Added brush selection Profile editor - Added playback controls
This commit is contained in:
1 parent
022beb6a48
commit
1832a25426
64 files changed
+1168
-481
No files matched your search
@@ -332,19 +332,19 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
if (SelectedProfileElement == null)
|
||||
return;
|
||||
|
||||
// Remove VMs of effects no longer applied on the layer
|
||||
List<LayerPropertyGroupViewModel> toRemove = Items
|
||||
.Where(l => l.LayerPropertyGroup.LayerEffect != null && !SelectedProfileElement.LayerEffects.Contains(l.LayerPropertyGroup.LayerEffect))
|
||||
.ToList();
|
||||
Items.RemoveRange(toRemove);
|
||||
|
||||
foreach (BaseLayerEffect layerEffect in SelectedProfileElement.LayerEffects)
|
||||
{
|
||||
if (Items.Any(l => l.LayerPropertyGroup.LayerEffect == layerEffect) || layerEffect.BaseProperties == null)
|
||||
continue;
|
||||
|
||||
Items.Add(_layerPropertyVmFactory.LayerPropertyGroupViewModel(layerEffect.BaseProperties));
|
||||
}
|
||||
// // Remove VMs of effects no longer applied on the layer
|
||||
// List<LayerPropertyGroupViewModel> toRemove = Items
|
||||
// .Where(l => l.LayerPropertyGroup.LayerEffect != null && !SelectedProfileElement.LayerEffects.Contains(l.LayerPropertyGroup.LayerEffect))
|
||||
// .ToList();
|
||||
// Items.RemoveRange(toRemove);
|
||||
//
|
||||
// foreach (BaseLayerEffect layerEffect in SelectedProfileElement.LayerEffects)
|
||||
// {
|
||||
// if (Items.Any(l => l.LayerPropertyGroup.LayerEffect == layerEffect) || layerEffect.BaseProperties == null)
|
||||
// continue;
|
||||
//
|
||||
// Items.Add(_layerPropertyVmFactory.LayerPropertyGroupViewModel(layerEffect.BaseProperties));
|
||||
// }
|
||||
|
||||
SortProperties();
|
||||
}
|
||||
@@ -355,11 +355,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
List<LayerPropertyGroupViewModel> nonEffectProperties = Items
|
||||
.Where(l => l.TreeGroupViewModel.GroupType != LayerEffectRoot)
|
||||
.ToList();
|
||||
// Order the effects
|
||||
List<LayerPropertyGroupViewModel> effectProperties = Items
|
||||
.Where(l => l.TreeGroupViewModel.GroupType == LayerEffectRoot && l.LayerPropertyGroup.LayerEffect != null)
|
||||
.OrderBy(l => l.LayerPropertyGroup.LayerEffect.Order)
|
||||
.ToList();
|
||||
// // Order the effects
|
||||
// List<LayerPropertyGroupViewModel> effectProperties = Items
|
||||
// .Where(l => l.TreeGroupViewModel.GroupType == LayerEffectRoot && l.LayerPropertyGroup.LayerEffect != null)
|
||||
// .OrderBy(l => l.LayerPropertyGroup.LayerEffect.Order)
|
||||
// .ToList();
|
||||
|
||||
// Put the non-effect properties in front
|
||||
for (int index = 0; index < nonEffectProperties.Count; index++)
|
||||
@@ -369,13 +369,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
((BindableCollection<LayerPropertyGroupViewModel>) Items).Move(Items.IndexOf(layerPropertyGroupViewModel), index);
|
||||
}
|
||||
|
||||
// Put the effect properties after, sorted by their order
|
||||
for (int index = 0; index < effectProperties.Count; index++)
|
||||
{
|
||||
LayerPropertyGroupViewModel layerPropertyGroupViewModel = effectProperties[index];
|
||||
if (Items.IndexOf(layerPropertyGroupViewModel) != index + nonEffectProperties.Count)
|
||||
((BindableCollection<LayerPropertyGroupViewModel>) Items).Move(Items.IndexOf(layerPropertyGroupViewModel), index + nonEffectProperties.Count);
|
||||
}
|
||||
// // Put the effect properties after, sorted by their order
|
||||
// for (int index = 0; index < effectProperties.Count; index++)
|
||||
// {
|
||||
// LayerPropertyGroupViewModel layerPropertyGroupViewModel = effectProperties[index];
|
||||
// if (Items.IndexOf(layerPropertyGroupViewModel) != index + nonEffectProperties.Count)
|
||||
// ((BindableCollection<LayerPropertyGroupViewModel>) Items).Move(Items.IndexOf(layerPropertyGroupViewModel), index + nonEffectProperties.Count);
|
||||
// }
|
||||
}
|
||||
|
||||
public async void ToggleEffectsViewModel()
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
|
||||
public void UpdateOrder(int order)
|
||||
{
|
||||
if (LayerPropertyGroup.LayerEffect != null)
|
||||
LayerPropertyGroup.LayerEffect.Order = order;
|
||||
// if (LayerPropertyGroup.LayerEffect != null)
|
||||
// LayerPropertyGroup.LayerEffect.Order = order;
|
||||
NotifyOfPropertyChange(nameof(IsExpanded));
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -59,7 +59,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Models
|
||||
|
||||
public KeyframeClipboardModel(ILayerPropertyKeyframe layerPropertyKeyframe)
|
||||
{
|
||||
FeatureId = layerPropertyKeyframe.UntypedLayerProperty.LayerPropertyGroup.Feature.Id;
|
||||
// FeatureId = layerPropertyKeyframe.UntypedLayerProperty.LayerPropertyGroup.Feature.Id;
|
||||
Path = layerPropertyKeyframe.UntypedLayerProperty.Path;
|
||||
KeyframeEntity = layerPropertyKeyframe.GetKeyframeEntity();
|
||||
}
|
||||
@@ -70,15 +70,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Models
|
||||
|
||||
public ILayerPropertyKeyframe Paste(List<ILayerProperty> properties, TimeSpan offset)
|
||||
{
|
||||
ILayerProperty property = properties.FirstOrDefault(p => p.LayerPropertyGroup.Feature.Id == FeatureId && p.Path == Path);
|
||||
if (property != null)
|
||||
{
|
||||
KeyframeEntity.Position += offset;
|
||||
ILayerPropertyKeyframe keyframe = property.AddKeyframeEntity(KeyframeEntity);
|
||||
KeyframeEntity.Position -= offset;
|
||||
|
||||
return keyframe;
|
||||
}
|
||||
// ILayerProperty property = properties.FirstOrDefault(p => p.LayerPropertyGroup.Feature.Id == FeatureId && p.Path == Path);
|
||||
// if (property != null)
|
||||
// {
|
||||
// KeyframeEntity.Position += offset;
|
||||
// ILayerPropertyKeyframe keyframe = property.AddKeyframeEntity(KeyframeEntity);
|
||||
// KeyframeEntity.Position -= offset;
|
||||
//
|
||||
// return keyframe;
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -56,94 +56,94 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
? LayerPropertyGroupViewModel.Items
|
||||
: null;
|
||||
|
||||
public void OpenBrushSettings()
|
||||
{
|
||||
BaseLayerBrush layerBrush = LayerPropertyGroup.LayerBrush;
|
||||
LayerBrushConfigurationDialog configurationViewModel = (LayerBrushConfigurationDialog) layerBrush.ConfigurationDialog;
|
||||
if (configurationViewModel == null)
|
||||
return;
|
||||
// public void OpenBrushSettings()
|
||||
// {
|
||||
// BaseLayerBrush layerBrush = LayerPropertyGroup.LayerBrush;
|
||||
// LayerBrushConfigurationDialog configurationViewModel = (LayerBrushConfigurationDialog) layerBrush.ConfigurationDialog;
|
||||
// if (configurationViewModel == null)
|
||||
// return;
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// // Limit to one constructor, there's no need to have more and it complicates things anyway
|
||||
// ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors();
|
||||
// if (constructors.Length != 1)
|
||||
// throw new ArtemisUIException("Brush configuration dialogs must have exactly one constructor");
|
||||
//
|
||||
// // Find the BaseLayerBrush parameter, it is required by the base constructor so its there for sure
|
||||
// ParameterInfo brushParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerBrush).IsAssignableFrom(p.ParameterType));
|
||||
// ConstructorArgument argument = new(brushParameter.Name, layerBrush);
|
||||
// BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||
//
|
||||
// _layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel, configurationViewModel);
|
||||
// _windowManager.ShowDialog(_layerBrushSettingsWindowVm);
|
||||
//
|
||||
// // Save changes after the dialog closes
|
||||
// _profileEditorService.SaveSelectedProfileConfiguration();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _dialogService.ShowExceptionDialog("An exception occured while trying to show the brush's settings window", e);
|
||||
// }
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
// Limit to one constructor, there's no need to have more and it complicates things anyway
|
||||
ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors();
|
||||
if (constructors.Length != 1)
|
||||
throw new ArtemisUIException("Brush configuration dialogs must have exactly one constructor");
|
||||
// public void OpenEffectSettings()
|
||||
// {
|
||||
// BaseLayerEffect layerEffect = LayerPropertyGroup.LayerEffect;
|
||||
// LayerEffectConfigurationDialog configurationViewModel = (LayerEffectConfigurationDialog) layerEffect.ConfigurationDialog;
|
||||
// if (configurationViewModel == null)
|
||||
// return;
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// // Limit to one constructor, there's no need to have more and it complicates things anyway
|
||||
// ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors();
|
||||
// if (constructors.Length != 1)
|
||||
// throw new ArtemisUIException("Effect configuration dialogs must have exactly one constructor");
|
||||
//
|
||||
// ParameterInfo effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType));
|
||||
// ConstructorArgument argument = new(effectParameter.Name, layerEffect);
|
||||
// EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||
//
|
||||
// _layerEffectSettingsWindowVm = new LayerEffectSettingsWindowViewModel(viewModel, configurationViewModel);
|
||||
// _windowManager.ShowDialog(_layerEffectSettingsWindowVm);
|
||||
//
|
||||
// // Save changes after the dialog closes
|
||||
// _profileEditorService.SaveSelectedProfileConfiguration();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _dialogService.ShowExceptionDialog("An exception occured while trying to show the effect's settings window", e);
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Find the BaseLayerBrush parameter, it is required by the base constructor so its there for sure
|
||||
ParameterInfo brushParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerBrush).IsAssignableFrom(p.ParameterType));
|
||||
ConstructorArgument argument = new(brushParameter.Name, layerBrush);
|
||||
BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||
|
||||
_layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel, configurationViewModel);
|
||||
_windowManager.ShowDialog(_layerBrushSettingsWindowVm);
|
||||
|
||||
// Save changes after the dialog closes
|
||||
_profileEditorService.SaveSelectedProfileConfiguration();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_dialogService.ShowExceptionDialog("An exception occured while trying to show the brush's settings window", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenEffectSettings()
|
||||
{
|
||||
BaseLayerEffect layerEffect = LayerPropertyGroup.LayerEffect;
|
||||
LayerEffectConfigurationDialog configurationViewModel = (LayerEffectConfigurationDialog) layerEffect.ConfigurationDialog;
|
||||
if (configurationViewModel == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// Limit to one constructor, there's no need to have more and it complicates things anyway
|
||||
ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors();
|
||||
if (constructors.Length != 1)
|
||||
throw new ArtemisUIException("Effect configuration dialogs must have exactly one constructor");
|
||||
|
||||
ParameterInfo effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType));
|
||||
ConstructorArgument argument = new(effectParameter.Name, layerEffect);
|
||||
EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||
|
||||
_layerEffectSettingsWindowVm = new LayerEffectSettingsWindowViewModel(viewModel, configurationViewModel);
|
||||
_windowManager.ShowDialog(_layerEffectSettingsWindowVm);
|
||||
|
||||
// Save changes after the dialog closes
|
||||
_profileEditorService.SaveSelectedProfileConfiguration();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_dialogService.ShowExceptionDialog("An exception occured while trying to show the effect's settings window", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async void RenameEffect()
|
||||
{
|
||||
object result = await _dialogService.ShowDialogAt<RenameViewModel>(
|
||||
"PropertyTreeDialogHost",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{"subject", "effect"},
|
||||
{"currentName", LayerPropertyGroup.LayerEffect.Name}
|
||||
}
|
||||
);
|
||||
if (result is string newName)
|
||||
{
|
||||
LayerPropertyGroup.LayerEffect.Name = newName;
|
||||
LayerPropertyGroup.LayerEffect.HasBeenRenamed = true;
|
||||
_profileEditorService.SaveSelectedProfileConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteEffect()
|
||||
{
|
||||
if (LayerPropertyGroup.LayerEffect == null)
|
||||
return;
|
||||
|
||||
LayerPropertyGroup.ProfileElement.RemoveLayerEffect(LayerPropertyGroup.LayerEffect);
|
||||
_profileEditorService.SaveSelectedProfileConfiguration();
|
||||
}
|
||||
// public async void RenameEffect()
|
||||
// {
|
||||
// object result = await _dialogService.ShowDialogAt<RenameViewModel>(
|
||||
// "PropertyTreeDialogHost",
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// {"subject", "effect"},
|
||||
// {"currentName", LayerPropertyGroup.LayerEffect.Name}
|
||||
// }
|
||||
// );
|
||||
// if (result is string newName)
|
||||
// {
|
||||
// LayerPropertyGroup.LayerEffect.Name = newName;
|
||||
// LayerPropertyGroup.LayerEffect.HasBeenRenamed = true;
|
||||
// _profileEditorService.SaveSelectedProfileConfiguration();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void DeleteEffect()
|
||||
// {
|
||||
// if (LayerPropertyGroup.LayerEffect == null)
|
||||
// return;
|
||||
//
|
||||
// LayerPropertyGroup.ProfileElement.RemoveLayerEffect(LayerPropertyGroup.LayerEffect);
|
||||
// _profileEditorService.SaveSelectedProfileConfiguration();
|
||||
// }
|
||||
|
||||
public void SuspendedToggled()
|
||||
{
|
||||
@@ -175,10 +175,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
GroupType = LayerPropertyGroupType.General;
|
||||
else if (LayerPropertyGroup is LayerTransformProperties)
|
||||
GroupType = LayerPropertyGroupType.Transform;
|
||||
else if (LayerPropertyGroup.Parent == null && LayerPropertyGroup.LayerBrush != null)
|
||||
GroupType = LayerPropertyGroupType.LayerBrushRoot;
|
||||
else if (LayerPropertyGroup.Parent == null && LayerPropertyGroup.LayerEffect != null)
|
||||
GroupType = LayerPropertyGroupType.LayerEffectRoot;
|
||||
// else if (LayerPropertyGroup.Parent == null && LayerPropertyGroup.LayerBrush != null)
|
||||
// GroupType = LayerPropertyGroupType.LayerBrushRoot;
|
||||
// else if (LayerPropertyGroup.Parent == null && LayerPropertyGroup.LayerEffect != null)
|
||||
// GroupType = LayerPropertyGroupType.LayerEffectRoot;
|
||||
else
|
||||
GroupType = LayerPropertyGroupType.None;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user