diff --git a/README.md b/README.md index a4529c7a8..9c4d65a3a 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ [![Github All Releases](https://img.shields.io/github/downloads/spoinkynl/artemis/setup.exe.svg)](https://github.com/SpoinkyNL/Artemis/releases) [![GitHub license](https://img.shields.io/badge/license-GPL3-blue.svg)](https://github.com/SpoinkyNL/Artemis/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/SpoinkyNL/Artemis.svg)](https://github.com/SpoinkyNL/Artemis/stargazers) +[![Discord](https://img.shields.io/discord/392093058352676874?logo=discord&logoColor=white)](https://discord.gg/S3MVaC9) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VQBAEJYUFLU4J) Artemis adds highly configurable support for several games to a range of RGB keyboards, mice and headsets. -**Download**: https://github.com/SpoinkyNL/Artemis/releases -**FAQ**: https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-(FAQ) -**Documentation**: https://artemis-rgb.com/docs/ +**Pre-release download**: https://github.com/SpoinkyNL/Artemis/releases +**Plugin Documentation**: https://artemis-rgb.com/docs/ ### Notice Artemis 2 is in development. In the meanwhile I'm no longer supporting Artemis 1.x, sorry! diff --git a/src/Artemis.Core/Models/Profile/Folder.cs b/src/Artemis.Core/Models/Profile/Folder.cs index 30062e553..4bacbaf4d 100644 --- a/src/Artemis.Core/Models/Profile/Folder.cs +++ b/src/Artemis.Core/Models/Profile/Folder.cs @@ -82,6 +82,10 @@ namespace Artemis.Core if (!Enabled) return; + // Disable data bindings during an override + var wasApplyingDataBindings = ApplyDataBindingsEnabled; + ApplyDataBindingsEnabled = false; + UpdateDisplayCondition(); // Update the layer timeline, this will give us a new delta time which could be negative in case the main segment wrapped back @@ -100,6 +104,9 @@ namespace Artemis.Core var profileElement = Children[index]; profileElement.Update(deltaTime); } + + // Restore the old data bindings enabled state + ApplyDataBindingsEnabled = wasApplyingDataBindings; } protected internal override void UpdateTimelineLength() diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 914e9de02..9bd5aaa14 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -76,7 +76,7 @@ namespace Artemis.Core var result = new List(); result.AddRange(General.GetAllLayerProperties()); result.AddRange(Transform.GetAllLayerProperties()); - if (LayerBrush?.BaseProperties != null) + if (LayerBrush?.BaseProperties != null) result.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties()); foreach (var layerEffect in LayerEffects) { @@ -300,6 +300,10 @@ namespace Artemis.Core if (!Enabled || LayerBrush?.BaseProperties == null || !LayerBrush.BaseProperties.PropertiesInitialized) return; + // Disable data bindings during an override + var wasApplyingDataBindings = ApplyDataBindingsEnabled; + ApplyDataBindingsEnabled = false; + var beginTime = TimelinePosition; if (stickToMainSegment) @@ -330,6 +334,9 @@ namespace Artemis.Core baseLayerEffect.BaseProperties?.Update(delta); baseLayerEffect.Update(delta); } + + // Restore the old data bindings enabled state + ApplyDataBindingsEnabled = wasApplyingDataBindings; } /// @@ -373,7 +380,7 @@ namespace Artemis.Core // No point rendering if the alpha was set to zero by one of the effects if (layerPaint.Color.Alpha == 0) return; - + if (!LayerBrush.SupportsTransformation) SimpleRender(layerCanvas, _layerBitmap.Info, layerPaint, layerPath); else if (General.ResizeMode.CurrentValue == LayerResizeMode.Normal) diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs index b2403dc20..36f59be34 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs @@ -43,8 +43,10 @@ namespace Artemis.Core CurrentValue = BaseValue; - UpdateKeyframes(); - UpdateDataBindings(deltaTime); + if (ProfileElement.ApplyKeyframesEnabled) + UpdateKeyframes(); + if (ProfileElement.ApplyDataBindingsEnabled) + UpdateDataBindings(deltaTime); OnUpdated(); } diff --git a/src/Artemis.Core/Models/Profile/RenderProfileElement.cs b/src/Artemis.Core/Models/Profile/RenderProfileElement.cs index 06146e6a3..60e646947 100644 --- a/src/Artemis.Core/Models/Profile/RenderProfileElement.cs +++ b/src/Artemis.Core/Models/Profile/RenderProfileElement.cs @@ -15,6 +15,9 @@ namespace Artemis.Core { protected RenderProfileElement() { + ApplyDataBindingsEnabled = true; + ApplyKeyframesEnabled = true; + LayerEffectStore.LayerEffectAdded += LayerEffectStoreOnLayerEffectAdded; LayerEffectStore.LayerEffectRemoved += LayerEffectStoreOnLayerEffectRemoved; } @@ -405,6 +408,16 @@ namespace Artemis.Core set => SetAndNotify(ref _displayCondition, value); } + /// + /// Gets or sets whether keyframes should be applied when this profile element updates + /// + public bool ApplyKeyframesEnabled { get; set; } + + /// + /// Gets or sets whether data bindings should be applied when this profile element updates + /// + public bool ApplyDataBindingsEnabled { get; set; } + public void UpdateDisplayCondition() { var conditionMet = DisplayCondition == null || DisplayCondition.Evaluate(); diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml index e09257740..7fe5a0bfe 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml @@ -83,6 +83,10 @@ + + + + @@ -91,8 +95,18 @@ Test result - - + + Preview on layer + + + diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs index 3897fa0fd..88ade0bd2 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Timers; using Artemis.Core; using Artemis.UI.Ninject.Factories; using Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline; @@ -12,9 +13,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings public class DataBindingViewModel : Conductor, IDataBindingViewModel { private readonly IDataBindingsVmFactory _dataBindingsVmFactory; - private readonly IDataModelUIService _dataModelUIService; private readonly IProfileEditorService _profileEditorService; - private DataBinding _dataBinding; + private readonly Timer _updateTimer; private int _easingTime; private bool _isDataBindingEnabled; private bool _isEasingTimeEnabled; @@ -22,6 +22,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings private TimelineEasingViewModel _selectedEasingViewModel; private bool _updating; + private bool _applyTestResultToLayer; + public DataBindingViewModel(DataBindingRegistration registration, IProfileEditorService profileEditorService, @@ -30,8 +32,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings { Registration = registration; _profileEditorService = profileEditorService; - _dataModelUIService = dataModelUIService; _dataBindingsVmFactory = dataBindingsVmFactory; + _updateTimer = new Timer(40); if (Registration.Member != null) DisplayName = Registration.Member.Name.ToUpper(); @@ -40,8 +42,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings DataBindingModes = new BindableCollection(EnumUtilities.GetAllValuesAndDescriptions(typeof(DataBindingModeType))); EasingViewModels = new BindableCollection(); - TestInputValue = _dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true); - TestResultValue = _dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true); + TestInputValue = dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true); + TestResultValue = dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true); Initialize(); } @@ -69,6 +71,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings set => SetAndNotify(ref _isDataBindingEnabled, value); } + public bool ApplyTestResultToLayer + { + get => _applyTestResultToLayer; + set => SetAndNotify(ref _applyTestResultToLayer, value); + } + public TimelineEasingViewModel SelectedEasingViewModel { get => _selectedEasingViewModel; @@ -101,13 +109,16 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings public void Dispose() { - _profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated; + _updateTimer.Dispose(); + _updateTimer.Elapsed -= OnUpdateTimerOnElapsed; } private void Initialize() { EasingViewModels.AddRange(Enum.GetValues(typeof(Easings.Functions)).Cast().Select(v => new TimelineEasingViewModel(v, false))); - _profileEditorService.ProfilePreviewUpdated += ProfileEditorServiceOnProfilePreviewUpdated; + + _updateTimer.Start(); + _updateTimer.Elapsed += OnUpdateTimerOnElapsed; CreateDataBindingModeModeViewModel(); Update(); @@ -212,6 +223,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings return; } + Registration.DataBinding.Update(0.04); if (ActiveItem.SupportsTestValue) { var currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty)); @@ -220,8 +232,14 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings } else TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(default) : default); - } + if (ApplyTestResultToLayer) + { + Registration.DataBinding.Apply(); + _profileEditorService.UpdateProfilePreview(); + } + } + private void EnableDataBinding() { if (Registration.DataBinding != null) @@ -242,7 +260,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings _profileEditorService.UpdateSelectedProfileElement(); } - private void ProfileEditorServiceOnProfilePreviewUpdated(object sender, EventArgs e) + private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs e) { UpdateTestResult(); }