mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Improved error catching
Improved tweening
This commit is contained in:
parent
02dbdaf0e4
commit
74889b2fd5
@ -38,7 +38,7 @@ namespace Artemis
|
||||
}
|
||||
}
|
||||
|
||||
private static ExceptionViewer GetArtemisExceptionViewer(Exception e)
|
||||
public static ExceptionViewer GetArtemisExceptionViewer(Exception e)
|
||||
{
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
logger.Fatal(e, "Unhandled exception, showing dialog and shutting down.");
|
||||
|
||||
@ -10,7 +10,6 @@ using Artemis.Utilities;
|
||||
using Artemis.Utilities.Converters;
|
||||
using Artemis.ViewModels;
|
||||
using Caliburn.Micro;
|
||||
using MoonSharp.Interpreter;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ namespace Artemis.DeviceProviders.CoolerMaster
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
|
||||
Height = 6;
|
||||
Width = 17;
|
||||
Width = 18;
|
||||
|
||||
PreviewSettings = new PreviewSettings(683, 242, new Thickness(0, 0, 0, 0), Resources.masterkeys_pro_s);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
|
||||
@ -4,6 +4,8 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Artemis.DeviceProviders;
|
||||
using Ninject.Extensions.Logging;
|
||||
using Timer = System.Timers.Timer;
|
||||
@ -19,21 +21,44 @@ namespace Artemis.Managers
|
||||
private readonly EffectManager _effectManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly Timer _loopTimer;
|
||||
private bool _canShowException;
|
||||
|
||||
public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_effectManager = effectManager;
|
||||
_deviceManager = deviceManager;
|
||||
_canShowException = true;
|
||||
|
||||
// Setup timers
|
||||
_loopTimer = new Timer(40);
|
||||
_loopTimer.Elapsed += Render;
|
||||
_loopTimer.Elapsed += LoopTimerOnElapsed;
|
||||
_loopTimer.Start();
|
||||
|
||||
_logger.Info("Intialized LoopManager");
|
||||
}
|
||||
|
||||
private void LoopTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
|
||||
{
|
||||
try
|
||||
{
|
||||
Render();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (_canShowException)
|
||||
{
|
||||
Caliburn.Micro.Execute.OnUIThread(delegate
|
||||
{
|
||||
_canShowException = false;
|
||||
_loopTimer.Stop();
|
||||
App.GetArtemisExceptionViewer(e).ShowDialog();
|
||||
Environment.Exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the loop is running
|
||||
/// </summary>
|
||||
@ -95,7 +120,7 @@ namespace Artemis.Managers
|
||||
_deviceManager.ReleaseActiveKeyboard();
|
||||
}
|
||||
|
||||
private void Render(object sender, ElapsedEventArgs e)
|
||||
private void Render()
|
||||
{
|
||||
if (!Running || _deviceManager.ChangingKeyboard)
|
||||
return;
|
||||
|
||||
@ -89,8 +89,8 @@ namespace Artemis.Models
|
||||
var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
||||
using (var g = Graphics.FromImage(frame.KeyboardBitmap))
|
||||
{
|
||||
Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Keyboard),
|
||||
DataModel, keyboardRect, false, true, "keyboard");
|
||||
Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Keyboard),
|
||||
DataModel, keyboardRect, false, true, "keyboard");
|
||||
}
|
||||
// Render mice layer-by-layer
|
||||
var devRec = new Rect(0, 0, 40, 40);
|
||||
|
||||
@ -281,19 +281,20 @@ namespace Artemis.Modules.Games.Overwatch
|
||||
|
||||
public void FindOverwatch()
|
||||
{
|
||||
var gameSettings = (OverwatchSettings) Settings;
|
||||
var gameSettings = Settings as OverwatchSettings;
|
||||
if (gameSettings == null)
|
||||
return;
|
||||
|
||||
// If already propertly set up, don't do anything
|
||||
if ((gameSettings.GameDirectory != null) && File.Exists(gameSettings.GameDirectory + "Overwatch.exe") &&
|
||||
File.Exists(gameSettings.GameDirectory + "RzChromaSDK64.dll"))
|
||||
return;
|
||||
|
||||
var key = Registry.LocalMachine.OpenSubKey(
|
||||
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwatch");
|
||||
if (key == null)
|
||||
return;
|
||||
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwatch");
|
||||
var path = key?.GetValue("DisplayIcon")?.ToString();
|
||||
|
||||
var path = key.GetValue("DisplayIcon").ToString();
|
||||
if (!File.Exists(path))
|
||||
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
||||
return;
|
||||
|
||||
gameSettings.GameDirectory = path.Substring(0, path.Length - 14);
|
||||
|
||||
@ -87,6 +87,9 @@ namespace Artemis.Profiles.Layers.Models
|
||||
/// <param name="updateAnimations"></param>
|
||||
public void Draw(IDataModel dataModel, DrawingContext c, bool preview, bool updateAnimations)
|
||||
{
|
||||
if (Brush == null)
|
||||
return;
|
||||
|
||||
LayerType.Draw(this, c);
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
@ -27,13 +26,9 @@ namespace Artemis.Profiles.Layers.Models
|
||||
Conditions = source.Conditions;
|
||||
DynamicProperties = source.DynamicProperties;
|
||||
Brush = source.Brush;
|
||||
XEase = source.XEase;
|
||||
YEase = source.YEase;
|
||||
HeightEase = source.HeightEase;
|
||||
WidthEase = source.WidthEase;
|
||||
OpacityEase = source.OpacityEase;
|
||||
XEaseTime = source.XEaseTime;
|
||||
YEaseTime = source.YEaseTime;
|
||||
HeightEaseTime = source.HeightEaseTime;
|
||||
WidthEaseTime = source.WidthEaseTime;
|
||||
OpacityEaseTime = source.OpacityEaseTime;
|
||||
@ -49,10 +44,6 @@ namespace Artemis.Profiles.Layers.Models
|
||||
public double OpacityEaseTime { get; set; }
|
||||
public double HeightEaseTime { get; set; }
|
||||
public double WidthEaseTime { get; set; }
|
||||
public double YEaseTime { get; set; }
|
||||
public double XEaseTime { get; set; }
|
||||
public string XEase { get; set; }
|
||||
public string YEase { get; set; }
|
||||
public string WidthEase { set; get; }
|
||||
public string HeightEase { get; set; }
|
||||
public string OpacityEase { get; set; }
|
||||
|
||||
@ -6,9 +6,7 @@ namespace Artemis.Profiles.Layers.Models
|
||||
public class TweenModel
|
||||
{
|
||||
private readonly LayerModel _layerModel;
|
||||
private float _x;
|
||||
private Tweener<float> _xTweener;
|
||||
private float _y;
|
||||
private Tweener<float> _yTweener;
|
||||
private float _width;
|
||||
private Tweener<float> _widthTweener;
|
||||
@ -16,11 +14,12 @@ namespace Artemis.Profiles.Layers.Models
|
||||
private Tweener<float> _heightTweener;
|
||||
private float _opacity;
|
||||
private Tweener<float> _opacityTweener;
|
||||
private float _x;
|
||||
private float _y;
|
||||
|
||||
public TweenModel(LayerModel layerModel)
|
||||
{
|
||||
_layerModel = layerModel;
|
||||
|
||||
_xTweener = new Tweener<float>((float) layerModel.X, (float) layerModel.X, 0);
|
||||
_yTweener = new Tweener<float>((float) layerModel.Y, (float) layerModel.Y, 0);
|
||||
_widthTweener = new Tweener<float>((float) layerModel.Width, (float) layerModel.Width, 0);
|
||||
@ -32,22 +31,31 @@ namespace Artemis.Profiles.Layers.Models
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// TODO: Don't update if animation speed is 0
|
||||
if (Math.Abs(_layerModel.X - _x) > 0.001)
|
||||
_xTweener = new Tweener<float>(_x, (float) _layerModel.X, _layerModel.Properties.XEaseTime,
|
||||
GetEaseFunction(_layerModel.Properties.XEase));
|
||||
if (Math.Abs(_layerModel.Y - _y) > 0.001)
|
||||
_yTweener = new Tweener<float>(_y, (float) _layerModel.Y, _layerModel.Properties.YEaseTime,
|
||||
GetEaseFunction(_layerModel.Properties.YEase));
|
||||
// Width
|
||||
if (Math.Abs(_layerModel.Width - _width) > 0.001)
|
||||
_widthTweener = new Tweener<float>(_width, (float) _layerModel.Width,
|
||||
_layerModel.Properties.WidthEaseTime, GetEaseFunction(_layerModel.Properties.WidthEase));
|
||||
{
|
||||
var widthFunc = GetEaseFunction(_layerModel.Properties.WidthEase);
|
||||
var widthSpeed = _layerModel.Properties.WidthEaseTime;
|
||||
|
||||
_xTweener = new Tweener<float>(_xTweener.Value, (float) _layerModel.X, widthSpeed, widthFunc);
|
||||
_widthTweener = new Tweener<float>(_widthTweener.Value, (float) _layerModel.Width, widthSpeed, widthFunc);
|
||||
}
|
||||
|
||||
// Height
|
||||
if (Math.Abs(_layerModel.Height - _height) > 0.001)
|
||||
_heightTweener = new Tweener<float>(_height, (float) _layerModel.Height,
|
||||
_layerModel.Properties.HeightEaseTime, GetEaseFunction(_layerModel.Properties.HeightEase));
|
||||
{
|
||||
var heightFunc = GetEaseFunction(_layerModel.Properties.HeightEase);
|
||||
var heightSpeed = _layerModel.Properties.HeightEaseTime;
|
||||
_yTweener = new Tweener<float>(_y, (float) _layerModel.Y, heightSpeed, heightFunc);
|
||||
_heightTweener = new Tweener<float>(_height, (float) _layerModel.Height, heightSpeed, heightFunc);
|
||||
}
|
||||
|
||||
// Opacity
|
||||
if (Math.Abs(_layerModel.Opacity - _opacity) > 0.001)
|
||||
{
|
||||
_opacityTweener = new Tweener<float>(_opacity, (float) _layerModel.Opacity,
|
||||
_layerModel.Properties.OpacityEaseTime, GetEaseFunction(_layerModel.Properties.OpacityEase));
|
||||
}
|
||||
|
||||
_xTweener.Update(40);
|
||||
_yTweener.Update(40);
|
||||
|
||||
@ -55,6 +55,5 @@ using System.Windows;
|
||||
|
||||
[assembly: AssemblyVersion("1.5.0.4")]
|
||||
[assembly: AssemblyFileVersion("1.5.0.4")]
|
||||
[assembly: InternalsVisibleTo("Artemis.Tests")]
|
||||
[assembly: InternalsVisibleTo("Artemis.Explorables")]
|
||||
|
||||
|
||||
@ -18,43 +18,28 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Grid.Row="0" Grid.Column="0" FontSize="20" HorizontalAlignment="Left" Content="Easing"
|
||||
VerticalAlignment="Bottom" />
|
||||
|
||||
<!-- X -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10" FontSize="13.333" Text="X:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.XEase}" />
|
||||
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.XEaseTime}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Y -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10" FontSize="13.333" Text="Y:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="1" Grid.Column="3" Orientation="Horizontal">
|
||||
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.YEase}" />
|
||||
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.YEaseTime}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Width -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Margin="10" FontSize="13.333" Text="Width:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10" FontSize="13.333" Text="Width:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.WidthEase}" />
|
||||
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.WidthEaseTime}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Height -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="2" Margin="10" FontSize="13.333" Text="Height:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="2" Grid.Column="3" Orientation="Horizontal">
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10" FontSize="13.333" Text="Height:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="1" Grid.Column="3" Orientation="Horizontal">
|
||||
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.HeightEase}" />
|
||||
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.HeightEaseTime}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Opacity -->
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Margin="10" FontSize="13.333" Text="Opacity:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Margin="10" FontSize="13.333" Text="Opacity:" VerticalAlignment="Center" Height="18" />
|
||||
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
|
||||
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.OpacityEase}" />
|
||||
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.OpacityEaseTime}" />
|
||||
</StackPanel>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user