diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config index eb58324d3..a339f73ad 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,17 +208,11 @@ 51364 - False + True False - - True - - - True - diff --git a/Artemis/Artemis/App.xaml b/Artemis/Artemis/App.xaml index 110eccc23..d19aed2d9 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 219b237da..71bc748c2 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,6 +103,7 @@ 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) @@ -124,4 +125,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 3bd6fdb74..6cb31f494 100644 --- a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs +++ b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs @@ -1,6 +1,7 @@ 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 5ae38a048..694481b20 100644 --- a/Artemis/Artemis/Managers/EffectManager.cs +++ b/Artemis/Artemis/Managers/EffectManager.cs @@ -10,10 +10,8 @@ namespace Artemis.Managers { public class EffectManager { - private readonly IEventAggregator _events; private readonly MainManager _mainManager; - private bool _clearing; - private EffectModel _pauseEffect; + private readonly IEventAggregator _events; public EffectManager(MainManager mainManager, IEventAggregator events) { @@ -25,6 +23,7 @@ namespace Artemis.Managers public List EffectModels { get; set; } public EffectModel ActiveEffect { get; private set; } + public EffectModel PauseEffect { get; private set; } public IEnumerable EnabledOverlays { @@ -84,27 +83,27 @@ namespace Artemis.Managers private void ChangeEffectWithPause(EffectModel effectModel) { - if (_pauseEffect != null) + if (PauseEffect != null) return; - _pauseEffect = effectModel; + PauseEffect = effectModel; _mainManager.Pause(); - _mainManager.PauseCallback += ChangeEffectPauseCallback; + _mainManager.PauseCallback += MainManagerOnPauseCallback; } - private void ChangeEffectPauseCallback() + private void MainManagerOnPauseCallback() { // 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; @@ -119,34 +118,18 @@ namespace Artemis.Managers /// public void ClearEffect() { - if (_clearing) - return; - // Don't mess with the ActiveEffect if in the process of changing the effect. - if (_pauseEffect != null) + 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 f6e7c9d1f..f17687b39 100644 --- a/Artemis/Artemis/Managers/KeyboardManager.cs +++ b/Artemis/Artemis/Managers/KeyboardManager.cs @@ -19,40 +19,29 @@ namespace Artemis.Managers public List KeyboardProviders { get; set; } public KeyboardProvider ActiveKeyboard { get; set; } - /// - /// Enables the last keyboard according to the settings file - /// - public void EnableLastKeyboard() + public bool LoadLastKeyboard() { - if (General.Default.LastKeyboard == null) - return; - if (General.Default.LastKeyboard == "") - return; - var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard); - EnableKeyboard(keyboard); + return ChangeKeyboard(keyboard ?? KeyboardProviders.First()); } - /// - /// Enables the given keyboard - /// - /// - public void EnableKeyboard(KeyboardProvider keyboardProvider) + public bool ChangeKeyboard(KeyboardProvider keyboardProvider) { - ReleaseActiveKeyboard(); - if (keyboardProvider == null) - return; + return false; if (ActiveKeyboard != null) if (keyboardProvider.Name == ActiveKeyboard.Name) - return; + return true; + + ReleaseActiveKeyboard(); // Disable everything if there's no active keyboard found if (!keyboardProvider.CanEnable()) { - _mainManager.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText); - return; + MessageBox.Show(keyboardProvider.CantEnableText, "Artemis (╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, + MessageBoxIcon.Warning); + return false; } ActiveKeyboard = keyboardProvider; @@ -60,11 +49,10 @@ namespace Artemis.Managers General.Default.LastKeyboard = ActiveKeyboard.Name; General.Default.Save(); + + return true; } - /// - /// Releases the active keyboard - /// public void ReleaseActiveKeyboard() { if (ActiveKeyboard == null) @@ -73,20 +61,5 @@ 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 444aa2c88..2133e92d4 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,12 +17,10 @@ namespace Artemis.Managers private readonly int _fps; private bool _paused; - private bool _restarting; - public MainManager(IEventAggregator events, MetroDialogService dialogService) + public MainManager(IEventAggregator events) { Events = events; - DialogService = dialogService; KeyboardManager = new KeyboardManager(this); EffectManager = new EffectManager(this, Events); @@ -30,7 +28,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; @@ -59,7 +57,6 @@ 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; } @@ -82,8 +79,7 @@ namespace Artemis.Managers return true; // Only continue if a keyboard was loaded - KeyboardManager.EnableLastKeyboard(); - if (KeyboardManager.ActiveKeyboard == null) + if (!KeyboardManager.LoadLastKeyboard()) return false; Running = true; @@ -133,41 +129,6 @@ 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 /// @@ -294,5 +255,12 @@ 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 13f01a478..d41fc862d 100644 --- a/Artemis/Artemis/Models/EffectModel.cs +++ b/Artemis/Artemis/Models/EffectModel.cs @@ -1,32 +1,31 @@ -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(); - } +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(); + } } \ No newline at end of file diff --git a/Artemis/Artemis/Utilities/Memory/GamePointer.cs b/Artemis/Artemis/Models/GamePointersCollectionModel.cs similarity index 86% rename from Artemis/Artemis/Utilities/Memory/GamePointer.cs rename to Artemis/Artemis/Models/GamePointersCollectionModel.cs index 856fc1d73..35279db50 100644 --- a/Artemis/Artemis/Utilities/Memory/GamePointer.cs +++ b/Artemis/Artemis/Models/GamePointersCollectionModel.cs @@ -1,26 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Artemis.Utilities.Memory -{ - public class GamePointer - { - public string Description { get; set; } - public IntPtr BasePointer { get; set; } - public int[] Offsets { get; set; } - - public override string ToString() - { - return Offsets.Aggregate(BasePointer.ToString("X"), - (current, offset) => current + $"+{offset.ToString("X")}"); - } - } - - public class GamePointersCollection - { - public string Game { get; set; } - public string GameVersion { get; set; } - public List GameAddresses { get; set; } - } +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Artemis.Models +{ + public class GamePointersCollectionModel + { + public string Game { get; set; } + public string GameVersion { get; set; } + public List GameAddresses { get; set; } + } + + public class GamePointer + { + public string Description { get; set; } + public IntPtr BasePointer { get; set; } + public int[] Offsets { get; set; } + + public override string ToString() + { + return Offsets.Aggregate(BasePointer.ToString("X"), + (current, offset) => current + $"+{offset.ToString("X")}"); + } + } } \ No newline at end of file diff --git a/Artemis/Artemis/Models/GameSettings.cs b/Artemis/Artemis/Models/GameSettings.cs deleted file mode 100644 index dcfe3527f..000000000 --- a/Artemis/Artemis/Models/GameSettings.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Artemis.Models -{ - public abstract class GameSettings : EffectSettings - { - public bool Enabled { get; set; } - } -} \ 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 3452c7c04..9211b2c72 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 _fromBottom; private bool _generating; - private int _sensitivity; private IWaveIn _waveIn; + private int _sensitivity; + private bool _fromBottom; 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 517f9705f..a5a22d8b9 100644 --- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml +++ b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml @@ -37,8 +37,8 @@