From ef9af2cd8342dea7f6acbaeb7354f8647dfeba71 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Mon, 7 Mar 2016 17:39:24 +0100 Subject: [PATCH] Fixed that 'merge' >_< --- Artemis/Artemis/App.config | 14 +- Artemis/Artemis/App.xaml | 6 +- .../KeyboardProviders/Corsair/CorsairRGB.cs | 7 +- .../KeyboardProviders/Logitech/Orion.cs | 1 - Artemis/Artemis/Managers/EffectManager.cs | 39 +- Artemis/Artemis/Managers/KeyboardManager.cs | 51 +- Artemis/Artemis/Managers/MainManager.cs | 54 +- Artemis/Artemis/Models/EffectModel.cs | 61 +- .../AudioVisualizer/AudioVisualizerModel.cs | 10 +- .../AudioVisualizer/AudioVisualizerView.xaml | 4 +- .../AudioVisualizerViewModel.cs | 2 +- .../Effects/Debug/DebugEffectView.xaml | 4 +- .../Effects/Debug/DebugEffectViewModel.cs | 2 +- .../Effects/TypeHole/TypeHoleView.xaml | 3 +- .../Effects/TypeHole/TypeHoleViewModel.cs | 2 +- .../Modules/Effects/TypeWave/TypeWaveModel.cs | 49 +- .../Effects/TypeWave/TypeWaveView.xaml | 3 +- .../Effects/TypeWave/TypeWaveViewModel.cs | 2 +- .../CounterStrike/CounterStrike.settings | 4 +- .../CounterStrike/CounterStrikeSettings.cs | 3 +- .../CounterStrike/CounterStrikeView.xaml | 18 +- .../CounterStrike/CounterStrikeViewModel.cs | 71 +- .../Modules/Games/Dota2/Dota2ViewModel.cs | 6 +- .../Games/RocketLeague/RocketLeague.settings | 4 +- .../Games/RocketLeague/RocketLeagueModel.cs | 3 +- .../RocketLeague/RocketLeagueSettings.cs | 3 +- .../Games/RocketLeague/RocketLeagueView.xaml | 13 +- .../RocketLeague/RocketLeagueViewModel.cs | 52 +- .../Modules/Games/Witcher3/Witcher3.settings | 4 +- .../Modules/Games/Witcher3/Witcher3Model.cs | 16 +- .../Games/Witcher3/Witcher3Settings.cs | 4 +- .../Modules/Games/Witcher3/Witcher3View.xaml | 2 +- .../Games/Witcher3/Witcher3ViewModel.cs | 84 +- .../VolumeDisplay/VolumeDisplay.settings | 4 +- .../VolumeDisplay/VolumeDisplayModel.cs | 10 +- .../VolumeDisplay/VolumeDisplayView.xaml | 12 +- .../Artemis/Properties/Resources.Designer.cs | 250 +- Artemis/Artemis/Properties/Resources.resx | 270 +- Artemis/Artemis/Settings/General.Designer.cs | 220 +- Artemis/Artemis/Settings/General.settings | 54 +- Artemis/Artemis/Settings/GeneralSettings.cs | 22 + .../Utilities/GameState/GameStateWebServer.cs | 21 +- .../Utilities/Keyboard/KeyboardHook.cs | 32 +- .../Artemis/Utilities/Memory/MemoryHelpers.cs | 6 - Artemis/Artemis/Utilities/Updater.cs | 28 +- .../ViewModels/Abstract/EffectViewModel.cs | 10 +- .../Flyouts/FlyoutSettingsViewModel.cs | 37 +- Artemis/Artemis/ViewModels/ShellViewModel.cs | 14 +- .../Artemis/ViewModels/SystemTrayViewModel.cs | 46 +- .../Views/Flyouts/FlyoutSettingsView.xaml | 47 +- Artemis/Artemis/Views/ShellView.xaml | 6 +- Artemis/Artemis/Views/SystemTrayView.xaml | 2 +- Artemis/Artemis/Views/WelcomeView.xaml | 4 +- Artemis/ArtemisSetup/ArtemisSetup.isl | 5956 ----------------- Artemis/ArtemisSetup/ArtemisSetup.isproj | 31 - 55 files changed, 907 insertions(+), 6776 deletions(-) delete mode 100644 Artemis/ArtemisSetup/ArtemisSetup.isl delete mode 100644 Artemis/ArtemisSetup/ArtemisSetup.isproj diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config index a339f73ad..eb58324d3 100644 --- a/Artemis/Artemis/App.config +++ b/Artemis/Artemis/App.config @@ -3,8 +3,8 @@ -
-
+
+
@@ -199,7 +199,7 @@ TypeWave - Logitech G910 RGB + True @@ -208,11 +208,17 @@ 51364 - True + False False + + True + + + True + diff --git a/Artemis/Artemis/App.xaml b/Artemis/Artemis/App.xaml index d19aed2d9..110eccc23 100644 --- a/Artemis/Artemis/App.xaml +++ b/Artemis/Artemis/App.xaml @@ -1,14 +1,14 @@  - + diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs index 71bc748c2..219b237da 100644 --- a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs +++ b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs @@ -16,8 +16,8 @@ namespace Artemis.KeyboardProviders.Corsair public CorsairRGB() { Name = "Corsair RGB Keyboards"; - CantEnableText = "Couldn't connect to your Corsair keyboard.\n " + - "Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " + + CantEnableText = "Couldn't connect to your Corsair keyboard.\n" + + "Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n" + "If needed, you can select a different keyboard in Artemis under settings."; KeyboardRegions = new List(); } @@ -103,7 +103,6 @@ namespace Artemis.KeyboardProviders.Corsair /// /// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap /// size. - /// Does not reset the color each time. Uncomment line 48 for collor reset. /// /// public override void DrawBitmap(Bitmap bitmap) @@ -125,4 +124,4 @@ namespace Artemis.KeyboardProviders.Corsair _keyboard.Update(true); } } -} \ No newline at end of file +} diff --git a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs index 6cb31f494..3bd6fdb74 100644 --- a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs +++ b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Drawing; using System.Threading; -using System.Windows.Forms; using Artemis.KeyboardProviders.Logitech.Utilities; namespace Artemis.KeyboardProviders.Logitech diff --git a/Artemis/Artemis/Managers/EffectManager.cs b/Artemis/Artemis/Managers/EffectManager.cs index 694481b20..5ae38a048 100644 --- a/Artemis/Artemis/Managers/EffectManager.cs +++ b/Artemis/Artemis/Managers/EffectManager.cs @@ -10,8 +10,10 @@ namespace Artemis.Managers { public class EffectManager { - private readonly MainManager _mainManager; private readonly IEventAggregator _events; + private readonly MainManager _mainManager; + private bool _clearing; + private EffectModel _pauseEffect; public EffectManager(MainManager mainManager, IEventAggregator events) { @@ -23,7 +25,6 @@ namespace Artemis.Managers public List EffectModels { get; set; } public EffectModel ActiveEffect { get; private set; } - public EffectModel PauseEffect { get; private set; } public IEnumerable EnabledOverlays { @@ -83,27 +84,27 @@ namespace Artemis.Managers private void ChangeEffectWithPause(EffectModel effectModel) { - if (PauseEffect != null) + if (_pauseEffect != null) return; - PauseEffect = effectModel; + _pauseEffect = effectModel; _mainManager.Pause(); - _mainManager.PauseCallback += MainManagerOnPauseCallback; + _mainManager.PauseCallback += ChangeEffectPauseCallback; } - private void MainManagerOnPauseCallback() + private void ChangeEffectPauseCallback() { // Change effect logic ActiveEffect?.Dispose(); - ActiveEffect = PauseEffect; + ActiveEffect = _pauseEffect; ActiveEffect.Enable(); // Let the ViewModels know _events.PublishOnUIThread(new ActiveEffectChanged(ActiveEffect.Name)); - PauseEffect = null; _mainManager.Unpause(); + _pauseEffect = null; if (ActiveEffect is GameModel) return; @@ -118,18 +119,34 @@ namespace Artemis.Managers /// public void ClearEffect() { - // Don't mess with the ActiveEffect if in the process of changing the effect. - if (PauseEffect != null) + if (_clearing) return; - + + // Don't mess with the ActiveEffect if in the process of changing the effect. + if (_pauseEffect != null) + return; + if (ActiveEffect == null) return; + _clearing = true; + + _mainManager.Pause(); + _mainManager.PauseCallback += ClearEffectPauseCallback; + } + + private void ClearEffectPauseCallback() + { ActiveEffect.Dispose(); ActiveEffect = null; General.Default.LastEffect = null; General.Default.Save(); + + _events.PublishOnUIThread(new ActiveEffectChanged("")); + + _clearing = false; + _mainManager.Unpause(); } /// diff --git a/Artemis/Artemis/Managers/KeyboardManager.cs b/Artemis/Artemis/Managers/KeyboardManager.cs index f17687b39..f6e7c9d1f 100644 --- a/Artemis/Artemis/Managers/KeyboardManager.cs +++ b/Artemis/Artemis/Managers/KeyboardManager.cs @@ -19,29 +19,40 @@ namespace Artemis.Managers public List KeyboardProviders { get; set; } public KeyboardProvider ActiveKeyboard { get; set; } - public bool LoadLastKeyboard() + /// + /// Enables the last keyboard according to the settings file + /// + public void EnableLastKeyboard() { + if (General.Default.LastKeyboard == null) + return; + if (General.Default.LastKeyboard == "") + return; + var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard); - return ChangeKeyboard(keyboard ?? KeyboardProviders.First()); + EnableKeyboard(keyboard); } - public bool ChangeKeyboard(KeyboardProvider keyboardProvider) + /// + /// Enables the given keyboard + /// + /// + public void EnableKeyboard(KeyboardProvider keyboardProvider) { + ReleaseActiveKeyboard(); + if (keyboardProvider == null) - return false; + return; if (ActiveKeyboard != null) if (keyboardProvider.Name == ActiveKeyboard.Name) - return true; - - ReleaseActiveKeyboard(); + return; // Disable everything if there's no active keyboard found if (!keyboardProvider.CanEnable()) { - MessageBox.Show(keyboardProvider.CantEnableText, "Artemis (╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, - MessageBoxIcon.Warning); - return false; + _mainManager.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText); + return; } ActiveKeyboard = keyboardProvider; @@ -49,10 +60,11 @@ namespace Artemis.Managers General.Default.LastKeyboard = ActiveKeyboard.Name; General.Default.Save(); - - return true; } + /// + /// Releases the active keyboard + /// public void ReleaseActiveKeyboard() { if (ActiveKeyboard == null) @@ -61,5 +73,20 @@ namespace Artemis.Managers ActiveKeyboard.Disable(); ActiveKeyboard = null; } + + /// + /// Changes the active keyboard + /// + /// + public void ChangeKeyboard(KeyboardProvider keyboardProvider) + { + if (keyboardProvider == ActiveKeyboard) + return; + + General.Default.LastKeyboard = keyboardProvider?.Name; + General.Default.Save(); + + _mainManager.Restart(); + } } } \ No newline at end of file diff --git a/Artemis/Artemis/Managers/MainManager.cs b/Artemis/Artemis/Managers/MainManager.cs index 2133e92d4..444aa2c88 100644 --- a/Artemis/Artemis/Managers/MainManager.cs +++ b/Artemis/Artemis/Managers/MainManager.cs @@ -2,9 +2,9 @@ using System.Diagnostics; using System.Linq; using System.Threading; -using System.Windows.Forms; using Artemis.Events; using Artemis.Models; +using Artemis.Services; using Artemis.Utilities.GameState; using Artemis.Utilities.Keyboard; using Caliburn.Micro; @@ -17,10 +17,12 @@ namespace Artemis.Managers private readonly int _fps; private bool _paused; + private bool _restarting; - public MainManager(IEventAggregator events) + public MainManager(IEventAggregator events, MetroDialogService dialogService) { Events = events; + DialogService = dialogService; KeyboardManager = new KeyboardManager(this); EffectManager = new EffectManager(this, Events); @@ -28,7 +30,7 @@ namespace Artemis.Managers _fps = 25; UpdateWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; - ProcessWorker = new BackgroundWorker { WorkerSupportsCancellation = true }; + ProcessWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; UpdateWorker.DoWork += UpdateWorker_DoWork; UpdateWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher; @@ -57,6 +59,7 @@ namespace Artemis.Managers public GameStateWebServer GameStateWebServer { get; set; } public IEventAggregator Events { get; set; } + public MetroDialogService DialogService { get; set; } public bool ProgramEnabled { get; private set; } public bool Suspended { get; set; } @@ -79,7 +82,8 @@ namespace Artemis.Managers return true; // Only continue if a keyboard was loaded - if (!KeyboardManager.LoadLastKeyboard()) + KeyboardManager.EnableLastKeyboard(); + if (KeyboardManager.ActiveKeyboard == null) return false; Running = true; @@ -129,6 +133,41 @@ namespace Artemis.Managers PauseCallback = null; } + public void Shutdown() + { + Stop(); + ProcessWorker.CancelAsync(); + GameStateWebServer.Stop(); + } + + public void Restart() + { + if (_restarting) + return; + if (!Running) + { + Start(); + return; + } + + _restarting = true; + + UpdateWorker.RunWorkerCompleted += FinishRestart; + Stop(); + } + + public void FinishRestart(object sender, RunWorkerCompletedEventArgs e) + { + UpdateWorker.RunWorkerCompleted -= FinishRestart; + + if (e.Error != null) + return; + + Start(); + + _restarting = false; + } + /// /// Loads the last active effect and starts the program /// @@ -255,12 +294,5 @@ namespace Artemis.Managers } #endregion - - public void Shutdown() - { - Stop(); - ProcessWorker.CancelAsync(); - GameStateWebServer.Stop(); - } } } \ No newline at end of file diff --git a/Artemis/Artemis/Models/EffectModel.cs b/Artemis/Artemis/Models/EffectModel.cs index d41fc862d..13f01a478 100644 --- a/Artemis/Artemis/Models/EffectModel.cs +++ b/Artemis/Artemis/Models/EffectModel.cs @@ -1,31 +1,32 @@ -using System; -using System.Drawing; -using Artemis.Managers; - -namespace Artemis.Models -{ - public abstract class EffectModel : IDisposable - { - public delegate void SettingsUpdateHandler(EffectSettings settings); - - public MainManager MainManager; - public string Name; - public bool Initialized; - - protected EffectModel(MainManager mainManager) - { - MainManager = mainManager; - } - - public abstract void Dispose(); - - // Called on creation - public abstract void Enable(); - - // Called every iteration - public abstract void Update(); - - // Called after every update - public abstract Bitmap GenerateBitmap(); - } +using System; +using System.Drawing; +using Artemis.Managers; + +namespace Artemis.Models +{ + public abstract class EffectModel : IDisposable + { + public delegate void SettingsUpdateHandler(EffectSettings settings); + + public bool Initialized; + + public MainManager MainManager; + public string Name; + + protected EffectModel(MainManager mainManager) + { + MainManager = mainManager; + } + + public abstract void Dispose(); + + // Called on creation + public abstract void Enable(); + + // Called every iteration + public abstract void Update(); + + // Called after every update + public abstract Bitmap GenerateBitmap(); + } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs index 9211b2c72..3452c7c04 100644 --- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs +++ b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs @@ -17,10 +17,10 @@ namespace Artemis.Modules.Effects.AudioVisualizer { private const int FftLength = 2048; private readonly SampleAggregator _sampleAggregator = new SampleAggregator(FftLength); - private bool _generating; - private IWaveIn _waveIn; - private int _sensitivity; private bool _fromBottom; + private bool _generating; + private int _sensitivity; + private IWaveIn _waveIn; public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager) { @@ -92,7 +92,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer } public override void Update() - { + { // Start filling the model _generating = true; @@ -118,7 +118,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer height = (int) Math.Round(SpectrumData[i]/2.55); // Apply Sensitivity setting - height = height* _sensitivity; + height = height*_sensitivity; var keyboardHeight = (int) Math.Round(MainManager.KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale); if (keyboardHeight > SoundRectangles[i].Height) diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml index a5a22d8b9..517f9705f 100644 --- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml +++ b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml @@ -37,8 +37,8 @@