diff --git a/Artemis/Artemis/App.xaml.cs b/Artemis/Artemis/App.xaml.cs index f68067c70..5379a5cf8 100644 --- a/Artemis/Artemis/App.xaml.cs +++ b/Artemis/Artemis/App.xaml.cs @@ -2,6 +2,7 @@ using System.Windows; using System.Windows.Threading; using Artemis.Utilities; +using NLog; using WpfExceptionViewer; namespace Artemis @@ -40,7 +41,6 @@ namespace Artemis } } - private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = e.ExceptionObject as Exception; @@ -49,6 +49,8 @@ namespace Artemis private static ExceptionViewer GetArtemisExceptionViewer(Exception e) { + var logger = LogManager.GetCurrentClassLogger(); + logger.Fatal(e, "Unhandled exception, showing dialog and shutting down."); return new ExceptionViewer("An unexpected error occurred in Artemis.", e) { Title = "Artemis - Exception :c", diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index b0e05c345..8666ec87a 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -310,6 +310,7 @@ + diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs index 0a95d6ff5..af78cc0ec 100644 --- a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs +++ b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs @@ -66,7 +66,7 @@ namespace Artemis.KeyboardProviders.Corsair try { if (CueSDK.ProtocolDetails == null) - CueSDK.Initialize(); + CueSDK.Initialize(true); } catch (WrapperException) { diff --git a/Artemis/Artemis/Managers/EffectManager.cs b/Artemis/Artemis/Managers/EffectManager.cs index d564cdf6c..1bf8d8bb1 100644 --- a/Artemis/Artemis/Managers/EffectManager.cs +++ b/Artemis/Artemis/Managers/EffectManager.cs @@ -123,6 +123,12 @@ namespace Artemis.Managers ActiveEffect = effectModel; ActiveEffect.Enable(); + if (!ActiveEffect.Initialized) + { + _logger.Debug("Cancelling effect change, couldn't initialize the effect ({0})", effectModel.Name); + ActiveEffect = null; + return; + } } if (loopManager != null && !loopManager.Running) diff --git a/Artemis/Artemis/Models/Profiles/LayerModel.cs b/Artemis/Artemis/Models/Profiles/LayerModel.cs index 7666d5621..350560b0b 100644 --- a/Artemis/Artemis/Models/Profiles/LayerModel.cs +++ b/Artemis/Artemis/Models/Profiles/LayerModel.cs @@ -25,13 +25,14 @@ namespace Artemis.Models.Profiles public ChildItemCollection Children { get; } [XmlIgnore] - public ImageSource LayerImage => GetThumbnail(); + public ImageSource LayerImage => Drawer.DrawThumbnail(this); [XmlIgnore] public LayerModel Parent { get; internal set; } [XmlIgnore] public ProfileModel Profile { get; internal set; } + [XmlIgnore] public GifImage GifImage { get; set; } @@ -44,22 +45,26 @@ namespace Artemis.Models.Profiles { // Don't draw when the layer is disabled if (!Enabled) - return; + return; // Preview simply shows the properties as they are. When not previewing they are applied - LayerPropertiesModel properties; + LayerPropertiesModel appliedProperties; if (!preview) { if (!ConditionsMet(dataModel)) return; // Don't draw the layer when not previewing and the conditions arent met - properties = Properties.GetAppliedProperties(dataModel); + appliedProperties = Properties.GetAppliedProperties(dataModel); } else - properties = GeneralHelpers.Clone(Properties); + appliedProperties = GeneralHelpers.Clone(Properties); // Update animations on layer types that support them if (LayerType == LayerType.Keyboard || LayerType == LayerType.KeyboardGif) - AnimationUpdater.UpdateAnimation((KeyboardPropertiesModel) properties); + { + AnimationUpdater.UpdateAnimation((KeyboardPropertiesModel) Properties); + ((KeyboardPropertiesModel) appliedProperties).AnimationProgress = + ((KeyboardPropertiesModel) Properties).AnimationProgress; + } // Folders are drawn recursively if (LayerType == LayerType.Folder) @@ -69,19 +74,35 @@ namespace Artemis.Models.Profiles } // All other types are handles by the Drawer helper else if (LayerType == LayerType.Keyboard) - Drawer.Draw(c, (KeyboardPropertiesModel) properties); + Drawer.Draw(c, (KeyboardPropertiesModel) appliedProperties); else if (LayerType == LayerType.KeyboardGif) - Drawer.DrawGif(c, (KeyboardPropertiesModel) properties, GifImage); + GifImage = Drawer.DrawGif(c, (KeyboardPropertiesModel) appliedProperties, GifImage); else if (LayerType == LayerType.Mouse) - Drawer.UpdateMouse(properties); + Drawer.UpdateMouse(appliedProperties); else if (LayerType == LayerType.Headset) - Drawer.UpdateHeadset(properties); + Drawer.UpdateHeadset(appliedProperties); } - private ImageSource GetThumbnail() + public void SetupProperties() { - // TODO - return null; + if ((LayerType == LayerType.Keyboard || LayerType == LayerType.KeyboardGif) && + !(Properties is KeyboardPropertiesModel)) + { + Properties = new KeyboardPropertiesModel + { + Brush = new SolidColorBrush(ColorHelpers.GetRandomRainbowMediaColor()), + Animation = LayerAnimation.None, + Height = 1, + Width = 1, + X = 0, + Y = 0, + Opacity = 1 + }; + } + else if (LayerType == LayerType.Mouse && !(Properties is MousePropertiesModel)) + Properties = new MousePropertiesModel(); + else if (!(Properties is GenericPropertiesModel)) + Properties = new GenericPropertiesModel(); } public void Reorder(LayerModel selectedLayer, bool moveUp) diff --git a/Artemis/Artemis/Models/Profiles/Properties/GenericPropertiesModel.cs b/Artemis/Artemis/Models/Profiles/Properties/GenericPropertiesModel.cs new file mode 100644 index 000000000..a09f12fc8 --- /dev/null +++ b/Artemis/Artemis/Models/Profiles/Properties/GenericPropertiesModel.cs @@ -0,0 +1,13 @@ +using Artemis.Models.Interfaces; +using Artemis.Utilities; + +namespace Artemis.Models.Profiles.Properties +{ + public class GenericPropertiesModel : LayerPropertiesModel + { + public override LayerPropertiesModel GetAppliedProperties(IGameDataModel dataModel) + { + return GeneralHelpers.Clone(this); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Models/Profiles/Properties/KeyboardPropertiesModel.cs b/Artemis/Artemis/Models/Profiles/Properties/KeyboardPropertiesModel.cs index 8a3dc7be1..3f02b5950 100644 --- a/Artemis/Artemis/Models/Profiles/Properties/KeyboardPropertiesModel.cs +++ b/Artemis/Artemis/Models/Profiles/Properties/KeyboardPropertiesModel.cs @@ -26,7 +26,7 @@ namespace Artemis.Models.Profiles.Properties public List DynamicProperties { get; set; } [XmlIgnore] - public int AnimationProgress { get; set; } + public double AnimationProgress { get; set; } public Rect GetRect(int scale = 4) { diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs index 2032b3076..32e93b9f1 100644 --- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs +++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs @@ -41,6 +41,9 @@ namespace Artemis.Modules.Games.RocketLeague _pointer = JsonConvert.DeserializeObject(Offsets.Default.RocketLeague); var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName); + if (tempProcess == null) + return; + _memory = new Memory(tempProcess); Initialized = true; diff --git a/Artemis/Artemis/NLog.config b/Artemis/Artemis/NLog.config index 8e6815325..c21a93a2e 100644 --- a/Artemis/Artemis/NLog.config +++ b/Artemis/Artemis/NLog.config @@ -6,8 +6,15 @@ throwExceptions="false" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" > - - + + + diff --git a/Artemis/Artemis/Styles/ColorBox.xaml b/Artemis/Artemis/Styles/ColorBox.xaml index 8eee66da0..39439d247 100644 --- a/Artemis/Artemis/Styles/ColorBox.xaml +++ b/Artemis/Artemis/Styles/ColorBox.xaml @@ -446,6 +446,11 @@ + + +