diff --git a/Artemis/Artemis.sln b/Artemis/Artemis.sln index 216a773bc..cf6e97100 100644 --- a/Artemis/Artemis.sln +++ b/Artemis/Artemis.sln @@ -1,93 +1,61 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}" -EndProject -Project("{6141683F-8A12-4E36-9623-2EB02B2C2303}") = "ArtemisSetup", "ArtemisSetup\ArtemisSetup.isproj", "{9E76B2E0-12AE-431D-8FA5-2233D6853F29}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CD_ROM|Any CPU = CD_ROM|Any CPU - CD_ROM|x64 = CD_ROM|x64 - CD_ROM|x86 = CD_ROM|x86 - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - DVD-5|Any CPU = DVD-5|Any CPU - DVD-5|x64 = DVD-5|x64 - DVD-5|x86 = DVD-5|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - SingleImage|Any CPU = SingleImage|Any CPU - SingleImage|x64 = SingleImage|x64 - SingleImage|x86 = SingleImage|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|Any CPU.Build.0 = Release|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x64.ActiveCfg = Release|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x64.Build.0 = Release|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x86.ActiveCfg = Release|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x86.Build.0 = Release|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x64.ActiveCfg = Debug|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x64.Build.0 = Debug|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x86.ActiveCfg = Debug|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x86.Build.0 = Debug|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|Any CPU.Build.0 = Debug|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x64.ActiveCfg = Debug|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x64.Build.0 = Debug|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x86.ActiveCfg = Debug|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x86.Build.0 = Debug|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.Build.0 = Release|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x64.ActiveCfg = Release|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x64.Build.0 = Release|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x86.ActiveCfg = Release|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x86.Build.0 = Release|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|Any CPU.Build.0 = Release|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.ActiveCfg = Release|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86 - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|Any CPU.ActiveCfg = CD_ROM - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|Any CPU.Build.0 = CD_ROM - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x64.ActiveCfg = CD_ROM - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x64.Build.0 = CD_ROM - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x86.ActiveCfg = CD_ROM - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x86.Build.0 = CD_ROM - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|Any CPU.ActiveCfg = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|Any CPU.Build.0 = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x64.ActiveCfg = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x64.Build.0 = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x86.ActiveCfg = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x86.Build.0 = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|Any CPU.ActiveCfg = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|Any CPU.Build.0 = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x64.ActiveCfg = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x64.Build.0 = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x86.ActiveCfg = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x86.Build.0 = DVD-5 - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|Any CPU.ActiveCfg = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|Any CPU.Build.0 = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x64.ActiveCfg = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x64.Build.0 = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x86.ActiveCfg = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x86.Build.0 = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|Any CPU.ActiveCfg = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|Any CPU.Build.0 = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x64.ActiveCfg = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x64.Build.0 = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x86.ActiveCfg = SingleImage - {9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x86.Build.0 = SingleImage - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + CD_ROM|Any CPU = CD_ROM|Any CPU + CD_ROM|x64 = CD_ROM|x64 + CD_ROM|x86 = CD_ROM|x86 + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + DVD-5|Any CPU = DVD-5|Any CPU + DVD-5|x64 = DVD-5|x64 + DVD-5|x86 = DVD-5|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + SingleImage|Any CPU = SingleImage|Any CPU + SingleImage|x64 = SingleImage|x64 + SingleImage|x86 = SingleImage|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|Any CPU.Build.0 = Release|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x64.ActiveCfg = Release|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x64.Build.0 = Release|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x86.ActiveCfg = Release|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x86.Build.0 = Release|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x64.ActiveCfg = Debug|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x64.Build.0 = Debug|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x86.ActiveCfg = Debug|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x86.Build.0 = Debug|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|Any CPU.Build.0 = Debug|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x64.ActiveCfg = Debug|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x64.Build.0 = Debug|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x86.ActiveCfg = Debug|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x86.Build.0 = Debug|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.Build.0 = Release|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x64.ActiveCfg = Release|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x64.Build.0 = Release|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x86.ActiveCfg = Release|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x86.Build.0 = Release|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|Any CPU.Build.0 = Release|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.ActiveCfg = Release|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86 + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config index 4f3f4dc8c..261aa7ea0 100644 --- a/Artemis/Artemis/App.config +++ b/Artemis/Artemis/App.config @@ -4,7 +4,8 @@ -
+
-
@@ -47,6 +45,17 @@ + + + True + + + #FFFF2900 + + + #FF26F600 + + True @@ -95,6 +104,9 @@ + + True + @@ -119,9 +131,6 @@ True - - True - @@ -149,17 +158,6 @@ True - - - #FFFF2900 - - - #FF26F600 - - - True - - 4 diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 5ccd4da7e..042691be2 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -228,7 +228,7 @@ - + @@ -241,6 +241,9 @@ + + + @@ -278,13 +281,12 @@ Witcher3.settings - - VolumeDisplay.settings True True + VolumeDisplay.settings @@ -323,6 +325,7 @@ + diff --git a/Artemis/Artemis/Events/ChangeActiveEffect.cs b/Artemis/Artemis/Events/ActiveEffectChanged.cs similarity index 62% rename from Artemis/Artemis/Events/ChangeActiveEffect.cs rename to Artemis/Artemis/Events/ActiveEffectChanged.cs index 47addd474..a7a90c3e4 100644 --- a/Artemis/Artemis/Events/ChangeActiveEffect.cs +++ b/Artemis/Artemis/Events/ActiveEffectChanged.cs @@ -1,8 +1,8 @@ namespace Artemis.Events { - public class ChangeActiveEffect + public class ActiveEffectChanged { - public ChangeActiveEffect(string activeEffect) + public ActiveEffectChanged(string activeEffect) { ActiveEffect = activeEffect; } diff --git a/Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs b/Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs index c72f0e92d..945ee7ae2 100644 --- a/Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs +++ b/Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs @@ -4,15 +4,15 @@ namespace Artemis.KeyboardProviders { public class KeyboardRegion { - public string RegionName { get; set; } - public Point TopLeft { get; set; } - public Point BottomRight { get; set; } - public KeyboardRegion(string regionName, Point topLeft, Point bottomRight) { RegionName = regionName; TopLeft = topLeft; BottomRight = bottomRight; } + + public string RegionName { get; set; } + public Point TopLeft { get; set; } + public Point BottomRight { get; set; } } } \ No newline at end of file diff --git a/Artemis/Artemis/Managers/EffectManager.cs b/Artemis/Artemis/Managers/EffectManager.cs new file mode 100644 index 000000000..5d6eac557 --- /dev/null +++ b/Artemis/Artemis/Managers/EffectManager.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Artemis.Events; +using Artemis.Models; +using Artemis.Settings; +using Caliburn.Micro; + +namespace Artemis.Managers +{ + public class EffectManager + { + private readonly MainManager _mainManager; + private readonly IEventAggregator _events; + + public EffectManager(MainManager mainManager, IEventAggregator events) + { + _mainManager = mainManager; + _events = events; + + EffectModels = new List(); + } + + public List EffectModels { get; set; } + public EffectModel ActiveEffect { get; private set; } + + public IEnumerable EnabledOverlays + { + get { return EffectModels.OfType().Where(o => o.Enabled); } + } + + public IEnumerable EnabledGames + { + get { return EffectModels.OfType().Where(g => g.Enabled); } + } + + /// + /// Loads the last active effect from settings and enables it. + /// + /// Whether enabling was successful or not. + public EffectModel GetLastEffect() + { + if (General.Default.LastEffect == null) + return null; + + var effect = EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect); + + // Fall back to the first effect found, in case settings are messed up + return effect ?? EffectModels.First(); + } + + /// + /// Disables the current effect and changes it to the provided effect. + /// + /// + public void ChangeEffect(EffectModel effectModel) + { + if (effectModel is OverlayModel) + throw new ArgumentException("Can't set an Overlay effect as the active effect"); + + // Game models are only used if they are enabled + var gameModel = effectModel as GameModel; + if (gameModel != null) + if (!gameModel.Enabled) + return; + + if (ActiveEffect != null) + if (effectModel.Name == ActiveEffect.Name) + return; + + ActiveEffect?.Dispose(); + + if (!_mainManager.Running) + { + _mainManager.Start(effectModel); + return; + } + + ActiveEffect = effectModel; + ActiveEffect.Enable(); + + if (ActiveEffect is GameModel) + return; + + // Non-game effects are stored as the new LastEffect. + General.Default.LastEffect = ActiveEffect.Name; + General.Default.Save(); + + // Let the ViewModels know + _events.PublishOnUIThread(new ActiveEffectChanged(ActiveEffect.Name)); + } + + /// + /// Clears the current effect + /// + public void ClearEffect() + { + if (ActiveEffect == null) + return; + + ActiveEffect.Dispose(); + ActiveEffect = null; + + General.Default.LastEffect = null; + General.Default.Save(); + } + + /// + /// Disables the given game + /// + /// + public void DisableGame(EffectModel activeEffect) + { + if (GetLastEffect() == null) + ClearEffect(); + else + ChangeEffect(GetLastEffect()); + } + + /// + /// Disables the current ActiveEffect if it's a game that is disabled. + /// + public void DisableInactiveGame() + { + if (!(ActiveEffect is GameModel)) + return; + if (EnabledGames.Contains(ActiveEffect)) + return; + + DisableGame(ActiveEffect); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Managers/KeyboardManager.cs b/Artemis/Artemis/Managers/KeyboardManager.cs new file mode 100644 index 000000000..f17687b39 --- /dev/null +++ b/Artemis/Artemis/Managers/KeyboardManager.cs @@ -0,0 +1,65 @@ +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using Artemis.KeyboardProviders; +using Artemis.Settings; + +namespace Artemis.Managers +{ + public class KeyboardManager + { + private readonly MainManager _mainManager; + + public KeyboardManager(MainManager mainManager) + { + _mainManager = mainManager; + KeyboardProviders = ProviderHelper.GetKeyboardProviders(); + } + + public List KeyboardProviders { get; set; } + public KeyboardProvider ActiveKeyboard { get; set; } + + public bool LoadLastKeyboard() + { + var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard); + return ChangeKeyboard(keyboard ?? KeyboardProviders.First()); + } + + public bool ChangeKeyboard(KeyboardProvider keyboardProvider) + { + if (keyboardProvider == null) + return false; + + if (ActiveKeyboard != null) + if (keyboardProvider.Name == ActiveKeyboard.Name) + return true; + + ReleaseActiveKeyboard(); + + // Disable everything if there's no active keyboard found + if (!keyboardProvider.CanEnable()) + { + MessageBox.Show(keyboardProvider.CantEnableText, "Artemis (╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, + MessageBoxIcon.Warning); + return false; + } + + ActiveKeyboard = keyboardProvider; + ActiveKeyboard.Enable(); + + General.Default.LastKeyboard = ActiveKeyboard.Name; + General.Default.Save(); + + return true; + } + + public void ReleaseActiveKeyboard() + { + if (ActiveKeyboard == null) + return; + + ActiveKeyboard.Disable(); + ActiveKeyboard = null; + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Models/EffectModel.cs b/Artemis/Artemis/Models/EffectModel.cs index f2623faa1..ee7d3d4f8 100644 --- a/Artemis/Artemis/Models/EffectModel.cs +++ b/Artemis/Artemis/Models/EffectModel.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using Artemis.Managers; namespace Artemis.Models { @@ -7,12 +8,12 @@ namespace Artemis.Models { public delegate void SettingsUpdateHandler(EffectSettings settings); - public MainModel MainModel; + public MainManager MainManager; public string Name; - protected EffectModel(MainModel mainModel) + protected EffectModel(MainManager mainManager) { - MainModel = mainModel; + MainManager = mainManager; } public abstract void Dispose(); diff --git a/Artemis/Artemis/Models/GameModel.cs b/Artemis/Artemis/Models/GameModel.cs index b1addf204..585304267 100644 --- a/Artemis/Artemis/Models/GameModel.cs +++ b/Artemis/Artemis/Models/GameModel.cs @@ -1,11 +1,13 @@ -namespace Artemis.Models +using Artemis.Managers; + +namespace Artemis.Models { public abstract class GameModel : EffectModel { public bool Enabled; public string ProcessName; - protected GameModel(MainModel mainModel) : base(mainModel) + protected GameModel(MainManager mainManager) : base(mainManager) { } } diff --git a/Artemis/Artemis/Models/MainModel.cs b/Artemis/Artemis/Models/MainModel.cs deleted file mode 100644 index f0ef13d90..000000000 --- a/Artemis/Artemis/Models/MainModel.cs +++ /dev/null @@ -1,323 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using System.Windows.Forms; -using Artemis.Events; -using Artemis.KeyboardProviders; -using Artemis.Settings; -using Artemis.Utilities.GameState; -using Artemis.Utilities.Keyboard; -using Artemis.Utilities.Memory; -using Caliburn.Micro; - -namespace Artemis.Models -{ - public class MainModel - { - private readonly int _fps; - private readonly BackgroundWorker _processWorker; - private readonly BackgroundWorker _updateWorker; - - private EffectModel _activeEffect; - private bool _wasSuspendedBeforeGame; - - public MainModel(IEventAggregator events) - { - EffectModels = new List(); - KeyboardProviders = ProviderHelper.GetKeyboardProviders(); - GameStateWebServer = new GameStateWebServer(); - KeyboardHook = new KeyboardHook(); - Suspended = false; - - Events = events; - - _fps = 25; - _updateWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; - _processWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; - _updateWorker.DoWork += UpdateWorker_DoWork; - _processWorker.DoWork += ProcessWorker_DoWork; - } - - public KeyboardHook KeyboardHook { get; set; } - public KeyboardProvider ActiveKeyboard { get; set; } - public List EffectModels { get; set; } - public List KeyboardProviders { get; set; } - public GameStateWebServer GameStateWebServer { get; set; } - public IEventAggregator Events { get; set; } - public bool Enabled { get; private set; } - public bool Suspended { get; private set; } - - #region Effect methods - - public void StartEffects() - { - if (Enabled) - return; - if (_updateWorker.IsBusy || _processWorker.IsBusy) - { - Events.PublishOnUIThread(new ToggleEnabled(Enabled)); - return; - } - - LoadLastKeyboard(); - // If no keyboard was loaded, don't enable effects. - if (ActiveKeyboard == null) - return; - - // Start the webserver - GameStateWebServer.Start(); - - // Load last non-game effect and enable - LoadLastEffect(); - - // Start the Background Workers - _updateWorker.RunWorkerAsync(); - _processWorker.RunWorkerAsync(); - - Enabled = true; - Events.PublishOnUIThread(new ToggleEnabled(Enabled)); - - if (General.Default.Suspended && !Suspended) - ToggleSuspension(); - } - - public void ShutdownEffects() - { - if (!Enabled) - return; - - // Stop the Background Worker - _updateWorker.CancelAsync(); - _processWorker.CancelAsync(); - - // Dispose the current active effect - _activeEffect?.Dispose(); - _activeEffect = null; - - ActiveKeyboard?.Disable(); - ActiveKeyboard = null; - - Enabled = false; - Events.PublishOnUIThread(new ToggleEnabled(Enabled)); - } - - private void LoadLastEffect() - { - var effect = EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect); - ChangeEffect(effect ?? EffectModels.First(e => e.Name == "TypeWave")); - } - - private void ChangeEffect(EffectModel effectModel) - { - // Can't set a new effect if ActiveKeyboard is null - if (ActiveKeyboard == null) - return; - - if (effectModel is OverlayModel) - throw new ArgumentException("Can't set an Overlay effect as the active effect"); - - // Game models are only used if they are enabled - var gameModel = effectModel as GameModel; - if (gameModel != null) - if (!gameModel.Enabled) - return; - - if (_activeEffect != null && effectModel.Name == _activeEffect.Name) - return; - - _activeEffect?.Dispose(); - - // If needed, unsuspend when loading a new effect - if (Suspended) - { - _wasSuspendedBeforeGame = true; - ToggleSuspension(); - } - - _activeEffect = effectModel; - _activeEffect.Enable(); - - if (_activeEffect is GameModel) - return; - - // Non-game effects are stored as the new LastEffect. - General.Default.LastEffect = _activeEffect.Name; - General.Default.Save(); - - // Let the ViewModels know - Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect.Name)); - } - - public void EnableEffect(EffectModel effectModel) - { - if (effectModel is GameModel || effectModel is OverlayModel) - return; - - ChangeEffect(effectModel); - } - - public void ToggleSuspension() - { - if (Suspended) - { - LoadLastKeyboard(); - - // Don't resume if no keyboard was found - if (ActiveKeyboard == null) - return; - - Suspended = false; - General.Default.Suspended = false; - General.Default.Save(); - Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect?.Name)); - return; - } - - Suspended = true; - General.Default.Suspended = true; - General.Default.Save(); - ActiveKeyboard?.Disable(); - ActiveKeyboard = null; - Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect?.Name)); - } - - public bool IsEnabled(EffectModel effectModel) - { - if (Suspended) - return false; - if (effectModel is GameModel) - return false; - - return General.Default.LastEffect == effectModel.Name; - } - - #endregion - - #region Keyboard methods - - private void LoadLastKeyboard() - { - var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard); - ChangeKeyboard(keyboard ?? KeyboardProviders.First()); - } - - public void ChangeKeyboard(KeyboardProvider keyboardProvider) - { - if (ActiveKeyboard != null && keyboardProvider.Name == ActiveKeyboard.Name) - return; - - ActiveKeyboard?.Disable(); - - // Disable everything if there's no active keyboard found - if (!keyboardProvider.CanEnable()) - { - ActiveKeyboard = null; - MessageBox.Show(keyboardProvider.CantEnableText, "Artemis (╯°□°)╯︵ ┻━┻", - MessageBoxButtons.OK, MessageBoxIcon.Warning); - ShutdownEffects(); - return; - } - - ActiveKeyboard = keyboardProvider; - ActiveKeyboard.Enable(); - - General.Default.LastKeyboard = ActiveKeyboard.Name; - General.Default.Save(); - } - - #endregion - - #region Workers - - private void UpdateWorker_DoWork(object sender, DoWorkEventArgs e) - { - var sw = new Stopwatch(); - while (!_updateWorker.CancellationPending) - { - if (ActiveKeyboard == null || Suspended || _activeEffect == null) - { - Thread.Sleep(1000/_fps); - continue; - } - - sw.Start(); - - // Update the current effect - _activeEffect.Update(); - - // Get ActiveEffect's bitmap - var bitmap = _activeEffect.GenerateBitmap(); - - // Draw enabled overlays on top - foreach (var overlayModel in EffectModels.OfType() - .Where(overlayModel => overlayModel.Enabled)) - { - overlayModel.Update(); - bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap(); - } - - // If it exists, send bitmap to the device - if (bitmap != null && ActiveKeyboard != null) - { - ActiveKeyboard.DrawBitmap(bitmap); - - // debugging TODO: Disable when window isn't shown - Events.PublishOnUIThread(new ChangeBitmap(bitmap)); - } - - // Sleep according to time left this frame - var sleep = (int) (1000/_fps - sw.ElapsedMilliseconds); - if (sleep > 0) - Thread.Sleep(sleep); - sw.Reset(); - } - } - - private void ProcessWorker_DoWork(object sender, DoWorkEventArgs e) - { - while (!_processWorker.CancellationPending) - { - var foundProcess = false; - - // ReSharper disable once LoopCanBePartlyConvertedToQuery - foreach (var effectModel in EffectModels.OfType()) - { - var process = MemoryHelpers.GetProcessIfRunning(effectModel.ProcessName); - if (process == null) - continue; - if (process.HasExited) - continue; - - // If the active effect is a disabled game model, disable it - var model = _activeEffect as GameModel; - if (model != null && !model.Enabled) - LoadLastEffect(); - else - { - ChangeEffect(effectModel); - foundProcess = true; - } - } - - // If no game process is found, but the active effect still belongs to a game, - // set it to a normal effect, and if needed, suspend again. - if (!foundProcess && _activeEffect is GameModel) - { - LoadLastEffect(); - if (_wasSuspendedBeforeGame) - { - ToggleSuspension(); - _wasSuspendedBeforeGame = false; - } - } - - Thread.Sleep(1000); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/Artemis/Artemis/Models/OverlayModel.cs b/Artemis/Artemis/Models/OverlayModel.cs index 11988a1f1..21d2ddd2f 100644 --- a/Artemis/Artemis/Models/OverlayModel.cs +++ b/Artemis/Artemis/Models/OverlayModel.cs @@ -1,4 +1,5 @@ using System.Drawing; +using Artemis.Managers; namespace Artemis.Models { @@ -7,11 +8,10 @@ namespace Artemis.Models private bool _enabled; public string ProcessName; - protected OverlayModel(MainModel mainModel) : base(mainModel) + protected OverlayModel(MainManager mainManager) : base(mainManager) { } - // Overlay Enabled() and Dispose() is called when changing the Enabled value public bool Enabled { get { return _enabled; } diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs index c1fd4626a..015c01e15 100644 --- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs +++ b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; +using Artemis.Managers; using Artemis.Models; using Artemis.Utilities; using Artemis.Utilities.Audio; @@ -19,7 +20,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer private bool _generating; private IWaveIn _waveIn; - public AudioVisualizerModel(MainModel mainModel, AudioVisualizerSettings settings) : base(mainModel) + public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager) { Settings = settings; Name = "Audiovisualizer"; @@ -51,7 +52,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer public override void Enable() { - Lines = MainModel.ActiveKeyboard.Width; + Lines = MainManager.KeyboardManager.ActiveKeyboard.Width; // TODO: Device selection SelectedDeviceId = new MMDeviceEnumerator() @@ -62,7 +63,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer for (var i = 0; i < Lines; i++) { SoundRectangles.Add(new KeyboardRectangle( - MainModel.ActiveKeyboard, + MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List { ColorHelpers.ToDrawingColor(Settings.TopColor), @@ -108,7 +109,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer // Apply Sensitivity setting height = height*Settings.Sensitivity; - var keyboardHeight = (int) Math.Round(MainModel.ActiveKeyboard.Height/100.00*height*Scale); + var keyboardHeight = + (int) Math.Round(MainManager.KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale); if (keyboardHeight > SoundRectangles[i].Height) SoundRectangles[i].Height = keyboardHeight; else @@ -118,7 +120,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer SoundRectangles[i].Width = Scale; if (Settings.FromBottom) - SoundRectangles[i].Y = MainModel.ActiveKeyboard.Height*Scale - SoundRectangles[i].Height; + SoundRectangles[i].Y = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - + SoundRectangles[i].Height; } _generating = false; } @@ -131,7 +134,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer // Lock the _spectrumData array while busy with it _generating = true; - var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); + var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); using (var g = Graphics.FromImage(bitmap)) { foreach (var soundRectangle in SoundRectangles) diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml index 03ecaa8f8..670968277 100644 --- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml +++ b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml @@ -47,7 +47,7 @@ Color used on top @@ -57,7 +57,7 @@ Color used in the middle @@ -67,7 +67,7 @@ Color used on the bottom @@ -76,7 +76,7 @@ Height="16" Margin="0,9,0,10"> Grow bars bottom (broken, sorry!) - @@ -88,7 +88,7 @@ @@ -98,7 +98,7 @@ @@ -108,7 +108,7 @@ diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerViewModel.cs b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerViewModel.cs index fd491e91c..1a88a7803 100644 --- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerViewModel.cs +++ b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerViewModel.cs @@ -1,74 +1,31 @@ using Artemis.Events; -using Artemis.Models; +using Artemis.Managers; +using Artemis.ViewModels.Abstract; using Caliburn.Micro; namespace Artemis.Modules.Effects.AudioVisualizer { - public class AudioVisualizerViewModel : Screen, IHandle + public class AudioVisualizerViewModel : EffectViewModel, IHandle { - private AudioVisualizerSettings _audioVisualizerSettings; - - public AudioVisualizerViewModel(MainModel mainModel) + public AudioVisualizerViewModel(MainManager mainManager) { // Subscribe to main model - MainModel = mainModel; - MainModel.Events.Subscribe(this); + MainManager = mainManager; + MainManager.Events.Subscribe(this); // Settings are loaded from file by class - AudioVisualizerSettings = new AudioVisualizerSettings(); + EffectSettings = new AudioVisualizerSettings(); - // Create effect model and add it to MainModel - AudioVisualizerModel = new AudioVisualizerModel(mainModel, AudioVisualizerSettings); - MainModel.EffectModels.Add(AudioVisualizerModel); + // Create effect model and add it to MainManager + EffectModel = new AudioVisualizerModel(mainManager, (AudioVisualizerSettings) EffectSettings); + MainManager.EffectManager.EffectModels.Add((AudioVisualizerModel) EffectModel); } - public MainModel MainModel { get; set; } - public AudioVisualizerModel AudioVisualizerModel { get; set; } - public static string Name => "Audio Visualizer"; - public bool EffectEnabled => MainModel.IsEnabled(AudioVisualizerModel); - public AudioVisualizerSettings AudioVisualizerSettings - { - get { return _audioVisualizerSettings; } - set - { - if (Equals(value, _audioVisualizerSettings)) return; - _audioVisualizerSettings = value; - NotifyOfPropertyChange(() => AudioVisualizerSettings); - } - } - - public void Handle(ChangeActiveEffect message) + public void Handle(ActiveEffectChanged message) { NotifyOfPropertyChange(() => EffectEnabled); } - - public void ToggleEffect() - { - if (EffectEnabled && !MainModel.Suspended) - MainModel.ToggleSuspension(); - else if (!EffectEnabled && !MainModel.Suspended) - MainModel.EnableEffect(AudioVisualizerModel); - else - { - MainModel.ToggleSuspension(); - MainModel.EnableEffect(AudioVisualizerModel); - } - } - - public void SaveSettings() - { - AudioVisualizerSettings?.Save(); - } - - public void ResetSettings() - { - // TODO: Confirmation dialog (Generic MVVM approach) - AudioVisualizerSettings.ToDefault(); - NotifyOfPropertyChange(() => AudioVisualizerSettings); - - SaveSettings(); - } } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectModel.cs b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectModel.cs index 3d65ec62a..bc0883139 100644 --- a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectModel.cs +++ b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectModel.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; +using Artemis.Managers; using Artemis.Models; using Artemis.Utilities.Keyboard; @@ -8,7 +9,7 @@ namespace Artemis.Modules.Effects.Debug { internal class DebugEffectModel : EffectModel { - public DebugEffectModel(MainModel mainModel, DebugEffectSettings settings) : base(mainModel) + public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager) { Name = "Debug Effect"; Settings = settings; @@ -27,7 +28,7 @@ namespace Artemis.Modules.Effects.Debug public override void Enable() { - KeyboardRectangle = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List + KeyboardRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List { Color.Red, Color.OrangeRed, diff --git a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectView.xaml b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectView.xaml index 4456af08a..f8de110b4 100644 --- a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectView.xaml +++ b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectView.xaml @@ -54,7 +54,7 @@ @@ -64,7 +64,7 @@ @@ -74,7 +74,7 @@ @@ -82,7 +82,7 @@ Height="16" Margin="0,9,0,10"> Rotate colors on debug-rectangle - diff --git a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs index 0296523b9..ee6bdd8c3 100644 --- a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs +++ b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs @@ -5,49 +5,33 @@ using System.IO; using System.Windows.Media; using System.Windows.Media.Imaging; using Artemis.Events; -using Artemis.Models; +using Artemis.Managers; +using Artemis.ViewModels.Abstract; using Caliburn.Micro; namespace Artemis.Modules.Effects.Debug { - internal class DebugEffectViewModel : Screen, IHandle, IHandle + internal class DebugEffectViewModel : EffectViewModel, IHandle, IHandle { - private DebugEffectSettings _debugEffectSettings; private ImageSource _imageSource; private string _selectedRectangleType; - public DebugEffectViewModel(MainModel mainModel) + public DebugEffectViewModel(MainManager mainManager) { // Subscribe to main model - MainModel = mainModel; - MainModel.Events.Subscribe(this); + MainManager = mainManager; + MainManager.Events.Subscribe(this); // Settings are loaded from file by class - DebugEffectSettings = new DebugEffectSettings(); + EffectSettings = new DebugEffectSettings(); - // Create effect model and add it to MainModel - DebugEffectModel = new DebugEffectModel(mainModel, DebugEffectSettings); - MainModel.EffectModels.Add(DebugEffectModel); + // Create effect model and add it to MainManager + EffectModel = new DebugEffectModel(mainManager, (DebugEffectSettings) EffectSettings); + MainManager.EffectManager.EffectModels.Add((DebugEffectModel) EffectModel); } - public MainModel MainModel { get; set; } - public DebugEffectModel DebugEffectModel { get; set; } - public static string Name => "Type Waves"; - public bool EffectEnabled => MainModel.IsEnabled(DebugEffectModel); - - public DebugEffectSettings DebugEffectSettings - { - get { return _debugEffectSettings; } - set - { - if (Equals(value, _debugEffectSettings)) return; - _debugEffectSettings = value; - NotifyOfPropertyChange(() => DebugEffectSettings); - - SelectedRectangleType = value.Type.ToString(); - } - } + public static string Name => "Debug Effect"; public BindableCollection RectangleTypes => new BindableCollection(Enum.GetNames(typeof (LinearGradientMode))); @@ -61,7 +45,8 @@ namespace Artemis.Modules.Effects.Debug _selectedRectangleType = value; NotifyOfPropertyChange(() => SelectedRectangleType); - DebugEffectSettings.Type = (LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value); + ((DebugEffectSettings) EffectSettings).Type = + (LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value); } } @@ -75,14 +60,13 @@ namespace Artemis.Modules.Effects.Debug } } - public void Handle(ChangeActiveEffect message) + public void Handle(ActiveEffectChanged message) { NotifyOfPropertyChange(() => EffectEnabled); } public void Handle(ChangeBitmap message) { - // Doesn't show transparancy using (var memory = new MemoryStream()) { message.Bitmap.Save(memory, ImageFormat.Png); @@ -97,25 +81,5 @@ namespace Artemis.Modules.Effects.Debug ImageSource = bitmapImage; } } - - public void ToggleEffect() - { - if (EffectEnabled && !MainModel.Suspended) - MainModel.ToggleSuspension(); - else if (!EffectEnabled && !MainModel.Suspended) - MainModel.EnableEffect(DebugEffectModel); - else - { - MainModel.ToggleSuspension(); - MainModel.EnableEffect(DebugEffectModel); - } - } - - public void ResetSettings() - { - // TODO: Confirmation dialog (Generic MVVM approach) - DebugEffectSettings.ToDefault(); - NotifyOfPropertyChange(() => DebugEffectSettings); - } } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleModel.cs b/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleModel.cs index 10f55584b..216ea04e3 100644 --- a/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleModel.cs +++ b/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleModel.cs @@ -1,11 +1,12 @@ using System.Drawing; +using Artemis.Managers; using Artemis.Models; namespace Artemis.Modules.Effects.TypeHole { public class TypeHoleModel : EffectModel { - public TypeHoleModel(MainModel mainModel) : base(mainModel) + public TypeHoleModel(MainManager mainManager) : base(mainManager) { Name = "TypeHole"; } diff --git a/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleViewModel.cs b/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleViewModel.cs index 0de2f92cd..eb17d8c38 100644 --- a/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleViewModel.cs +++ b/Artemis/Artemis/Modules/Effects/TypeHole/TypeHoleViewModel.cs @@ -1,44 +1,28 @@ using Artemis.Events; -using Artemis.Models; +using Artemis.Managers; +using Artemis.ViewModels.Abstract; using Caliburn.Micro; namespace Artemis.Modules.Effects.TypeHole { - public class TypeHoleViewModel : Screen, IHandle + public class TypeHoleViewModel : EffectViewModel, IHandle { - public TypeHoleViewModel(MainModel mainModel) + public TypeHoleViewModel(MainManager mainManager) { // Subscribe to main model - MainModel = mainModel; - MainModel.Events.Subscribe(this); + MainManager = mainManager; + MainManager.Events.Subscribe(this); - // Create effect model and add it to MainModel - TypeHoleModel = new TypeHoleModel(mainModel); - MainModel.EffectModels.Add(TypeHoleModel); + // Create effect model and add it to MainManager + EffectModel = new TypeHoleModel(mainManager); + MainManager.EffectManager.EffectModels.Add((TypeHoleModel) EffectModel); } - public MainModel MainModel { get; set; } - public TypeHoleModel TypeHoleModel { get; set; } - public static string Name => "Type Holes (NYI)"; - public bool EffectEnabled => MainModel.IsEnabled(TypeHoleModel); - public void Handle(ChangeActiveEffect message) + public void Handle(ActiveEffectChanged message) { NotifyOfPropertyChange(() => EffectEnabled); } - - public void ToggleEffect() - { - if (EffectEnabled && !MainModel.Suspended) - MainModel.ToggleSuspension(); - else if (!EffectEnabled && !MainModel.Suspended) - MainModel.EnableEffect(TypeHoleModel); - else - { - MainModel.ToggleSuspension(); - MainModel.EnableEffect(TypeHoleModel); - } - } } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs index 932f2058a..61610445e 100644 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs +++ b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using Artemis.KeyboardProviders.Corsair; using Artemis.KeyboardProviders.Logitech.Utilities; +using Artemis.Managers; using Artemis.Models; using Artemis.Utilities; @@ -16,7 +17,7 @@ namespace Artemis.Modules.Effects.TypeWave private readonly List _waves; private Color _randomColor; - public TypeWaveModel(MainModel mainModel, TypeWaveSettings settings) : base(mainModel) + public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager) { Name = "TypeWave"; _waves = new List(); @@ -28,13 +29,13 @@ namespace Artemis.Modules.Effects.TypeWave public override void Dispose() { - MainModel.KeyboardHook.Unsubscribe(HandleKeypress); + MainManager.KeyboardHook.Unsubscribe(HandleKeypress); } public override void Enable() { // Listener won't start unless the effect is active - MainModel.KeyboardHook.Subscribe(HandleKeypress); + MainManager.KeyboardHook.Subscribe(HandleKeypress); } public override void Update() @@ -71,13 +72,13 @@ namespace Artemis.Modules.Effects.TypeWave if (_waves.Count == 0) return null; - var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(); + var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(); using (var g = Graphics.FromImage(bitmap)) { g.Clear(Color.Transparent); g.SmoothingMode = SmoothingMode.HighQuality; - // Don't want a foreach, collection is changed in different thread + // Don't want a for-each, collection is changed in different thread // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _waves.Count; i++) { @@ -88,7 +89,7 @@ namespace Artemis.Modules.Effects.TypeWave _waves[i].Size, _waves[i].Size); Color fillColor; - if (MainModel.ActiveKeyboard is CorsairRGB) + if (MainManager.KeyboardManager.ActiveKeyboard is CorsairRGB) fillColor = Color.Black; else fillColor = Color.Transparent; diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml index 0010ad2dc..df0cd582d 100644 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml +++ b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml @@ -46,7 +46,7 @@ Wave color @@ -55,7 +55,7 @@ Height="16" Margin="0,8"> Use random colors - @@ -65,7 +65,7 @@ Height="16" Margin="0,8"> Shift through colors as the wave grows - @@ -77,7 +77,7 @@ @@ -87,7 +87,7 @@ @@ -97,7 +97,7 @@ diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveViewModel.cs b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveViewModel.cs index 7e238abe4..cd861471c 100644 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveViewModel.cs +++ b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveViewModel.cs @@ -1,77 +1,31 @@ using Artemis.Events; -using Artemis.Models; +using Artemis.Managers; +using Artemis.ViewModels.Abstract; using Caliburn.Micro; namespace Artemis.Modules.Effects.TypeWave { - public class TypeWaveViewModel : Screen, IHandle + public class TypeWaveViewModel : EffectViewModel, IHandle { - private TypeWaveSettings _typeWaveSettings; - - public TypeWaveViewModel(MainModel mainModel) + public TypeWaveViewModel(MainManager mainManager) { // Subscribe to main model - MainModel = mainModel; - MainModel.Events.Subscribe(this); + MainManager = mainManager; + MainManager.Events.Subscribe(this); // Settings are loaded from file by class - TypeWaveSettings = new TypeWaveSettings(); + EffectSettings = new TypeWaveSettings(); - // Create effect model and add it to MainModel - TypeWaveModel = new TypeWaveModel(mainModel, TypeWaveSettings); - MainModel.EffectModels.Add(TypeWaveModel); + // Create effect model and add it to MainManager + EffectModel = new TypeWaveModel(mainManager, (TypeWaveSettings) EffectSettings); + MainManager.EffectManager.EffectModels.Add((TypeWaveModel) EffectModel); } - public MainModel MainModel { get; set; } - public TypeWaveModel TypeWaveModel { get; set; } - public static string Name => "Type Waves"; - public bool EffectEnabled => MainModel.IsEnabled(TypeWaveModel); - public TypeWaveSettings TypeWaveSettings - { - get { return _typeWaveSettings; } - set - { - if (Equals(value, _typeWaveSettings)) return; - _typeWaveSettings = value; - NotifyOfPropertyChange(() => TypeWaveSettings); - } - } - - public void Handle(ChangeActiveEffect message) + public void Handle(ActiveEffectChanged message) { NotifyOfPropertyChange(() => EffectEnabled); } - - public void ToggleEffect() - { - if (EffectEnabled && !MainModel.Suspended) - MainModel.ToggleSuspension(); - else if (!EffectEnabled && !MainModel.Suspended) - MainModel.EnableEffect(TypeWaveModel); - else - { - MainModel.ToggleSuspension(); - MainModel.EnableEffect(TypeWaveModel); - } - } - - public void SaveSettings() - { - if (TypeWaveModel == null) - return; - - TypeWaveSettings.Save(); - } - - public void ResetSettings() - { - // TODO: Confirmation dialog (Generic MVVM approach) - TypeWaveSettings.ToDefault(); - NotifyOfPropertyChange(() => TypeWaveSettings); - - SaveSettings(); - } } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.Designer.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.Designer.cs index 71d9a1953..ffed5f5c6 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.Designer.cs +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.Designer.cs @@ -1,134 +1,134 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Artemis.Modules.Games.CounterStrike { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class CounterStrike : global::System.Configuration.ApplicationSettingsBase { - - private static CounterStrike defaultInstance = ((CounterStrike)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new CounterStrike()))); - - public static CounterStrike Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool Enabled { - get { - return ((bool)(this["Enabled"])); - } - set { - this["Enabled"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string GameDirectory { - get { - return ((string)(this["GameDirectory"])); - } - set { - this["GameDirectory"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool AmmoEnabled { - get { - return ((bool)(this["AmmoEnabled"])); - } - set { - this["AmmoEnabled"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#FFFF2900")] - public global::System.Windows.Media.Color AmmoMainColor { - get { - return ((global::System.Windows.Media.Color)(this["AmmoMainColor"])); - } - set { - this["AmmoMainColor"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#FF26F600")] - public global::System.Windows.Media.Color AmmoSecondaryColor { - get { - return ((global::System.Windows.Media.Color)(this["AmmoSecondaryColor"])); - } - set { - this["AmmoSecondaryColor"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool TeamColorEnabled { - get { - return ((bool)(this["TeamColorEnabled"])); - } - set { - this["TeamColorEnabled"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool FlashEnabled { - get { - return ((bool)(this["FlashEnabled"])); - } - set { - this["FlashEnabled"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool SmokeEnabled { - get { - return ((bool)(this["SmokeEnabled"])); - } - set { - this["SmokeEnabled"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool LowHpEnabled { - get { - return ((bool)(this["LowHpEnabled"])); - } - set { - this["LowHpEnabled"] = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Artemis.Modules.Games.CounterStrike { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class CounterStrike : global::System.Configuration.ApplicationSettingsBase { + + private static CounterStrike defaultInstance = ((CounterStrike)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new CounterStrike()))); + + public static CounterStrike Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Enabled { + get { + return ((bool)(this["Enabled"])); + } + set { + this["Enabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string GameDirectory { + get { + return ((string)(this["GameDirectory"])); + } + set { + this["GameDirectory"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool AmmoEnabled { + get { + return ((bool)(this["AmmoEnabled"])); + } + set { + this["AmmoEnabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FFFF2900")] + public global::System.Windows.Media.Color AmmoMainColor { + get { + return ((global::System.Windows.Media.Color)(this["AmmoMainColor"])); + } + set { + this["AmmoMainColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FF26F600")] + public global::System.Windows.Media.Color AmmoSecondaryColor { + get { + return ((global::System.Windows.Media.Color)(this["AmmoSecondaryColor"])); + } + set { + this["AmmoSecondaryColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool TeamColorEnabled { + get { + return ((bool)(this["TeamColorEnabled"])); + } + set { + this["TeamColorEnabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool FlashEnabled { + get { + return ((bool)(this["FlashEnabled"])); + } + set { + this["FlashEnabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool SmokeEnabled { + get { + return ((bool)(this["SmokeEnabled"])); + } + set { + this["SmokeEnabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool LowHpEnabled { + get { + return ((bool)(this["LowHpEnabled"])); + } + set { + this["LowHpEnabled"] = value; + } + } + } +} diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.settings b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.settings index d45c34188..45108356e 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.settings +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrike.settings @@ -1,35 +1,33 @@ - - - - - - - True - - - - - - True - - - #FFFF2900 - - - #FF26F600 - - - True - - - True - - - True - - - True - - + + + + + + True + + + + + + True + + + #FFFF2900 + + + #FF26F600 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs index f593815f1..73e63ed77 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs @@ -4,8 +4,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using Artemis.KeyboardProviders; -using Artemis.KeyboardProviders.Corsair; -using Artemis.KeyboardProviders.Logitech; +using Artemis.Managers; using Artemis.Models; using Artemis.Utilities; using Artemis.Utilities.GameState; @@ -19,7 +18,7 @@ namespace Artemis.Modules.Games.CounterStrike { private KeyboardRegion _topRow; - public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings settings) : base(mainModel) + public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager) { Settings = settings; Name = "CounterStrike"; @@ -42,20 +41,29 @@ namespace Artemis.Modules.Games.CounterStrike public override void Dispose() { - MainModel.GameStateWebServer.GameDataReceived -= HandleGameData; + MainManager.GameStateWebServer.GameDataReceived -= HandleGameData; } public override void Enable() { // Some keyboards have a different baseline, Corsair F-keys start at row 1 - _topRow = MainModel.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow"); - AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X, new List(), + _topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow"); + AmmoRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X, + new List(), LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false}; - TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List(), - LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale}; - EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List(), - LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale}; - MainModel.GameStateWebServer.GameDataReceived += HandleGameData; + TeamRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, + new List(), + LinearGradientMode.Horizontal) + { + Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale + }; + EventRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, + new List(), + LinearGradientMode.Horizontal) + { + Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale + }; + MainManager.GameStateWebServer.GameDataReceived += HandleGameData; } public override void Update() @@ -152,7 +160,7 @@ namespace Artemis.Modules.Games.CounterStrike return; var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo; - AmmoRect.Width = (int) Math.Floor(_topRow.BottomRight.Y / 100.00*ammoPercentage)*Scale; + AmmoRect.Width = (int) Math.Floor(_topRow.BottomRight.Y/100.00*ammoPercentage)*Scale; AmmoRect.Colors = new List { ColorHelpers.ToDrawingColor(Settings.AmmoMainColor), @@ -168,7 +176,7 @@ namespace Artemis.Modules.Games.CounterStrike public override Bitmap GenerateBitmap() { - var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); + var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); using (var g = Graphics.FromImage(bitmap)) { diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs index f605d619f..d115bc2ca 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs @@ -1,6 +1,6 @@ using System.IO; using System.Windows.Forms; -using Artemis.Models; +using Artemis.Managers; using Artemis.Properties; using Screen = Caliburn.Micro.Screen; @@ -10,16 +10,16 @@ namespace Artemis.Modules.Games.CounterStrike { private CounterStrikeSettings _counterStrikeSettings; - public CounterStrikeViewModel(MainModel mainModel) + public CounterStrikeViewModel(MainManager mainManager) { - MainModel = mainModel; + MainManager = mainManager; // Settings are loaded from file by class CounterStrikeSettings = new CounterStrikeSettings(); - // Create effect model and add it to MainModel - CounterStrikeModel = new CounterStrikeModel(mainModel, CounterStrikeSettings); - MainModel.EffectModels.Add(CounterStrikeModel); + // Create effect model and add it to MainManager + CounterStrikeModel = new CounterStrikeModel(mainManager, CounterStrikeSettings); + MainManager.EffectManager.EffectModels.Add(CounterStrikeModel); PlaceConfigFile(); } @@ -36,7 +36,7 @@ namespace Artemis.Modules.Games.CounterStrike public CounterStrikeModel CounterStrikeModel { get; set; } - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } public static string Name => "CS:GO"; public string Content => "Counter-Strike: GO Content"; @@ -79,7 +79,7 @@ namespace Artemis.Modules.Games.CounterStrike if (Directory.Exists(CounterStrikeSettings.GameDirectory + "/csgo/cfg")) { var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}", - MainModel.GameStateWebServer.Port.ToString()); + MainManager.GameStateWebServer.Port.ToString()); File.WriteAllText(CounterStrikeSettings.GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg", cfgFile); return; diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs index 9eaf40d1a..918dd13e8 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs @@ -1,16 +1,16 @@ -using Artemis.Models; +using Artemis.Managers; using Caliburn.Micro; namespace Artemis.Modules.Games.Dota2 { public class Dota2ViewModel : Screen { - public Dota2ViewModel(MainModel mainModel) + public Dota2ViewModel(MainManager mainManager) { - MainModel = mainModel; + MainManager = mainManager; } - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } public static string Name => "Dota 2 (NYI)"; public string Content => "Dota 2 Content"; diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.Designer.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.Designer.cs index 60877516e..b90298a28 100644 --- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.Designer.cs +++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.Designer.cs @@ -1,62 +1,62 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Artemis.Modules.Games.RocketLeague { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class RocketLeague : global::System.Configuration.ApplicationSettingsBase { - - private static RocketLeague defaultInstance = ((RocketLeague)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new RocketLeague()))); - - public static RocketLeague Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool Enabled { - get { - return ((bool)(this["Enabled"])); - } - set { - this["Enabled"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#FFFF5000")] - public global::System.Windows.Media.Color MainColor { - get { - return ((global::System.Windows.Media.Color)(this["MainColor"])); - } - set { - this["MainColor"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#FFFF0000")] - public global::System.Windows.Media.Color SecondaryColor { - get { - return ((global::System.Windows.Media.Color)(this["SecondaryColor"])); - } - set { - this["SecondaryColor"] = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Artemis.Modules.Games.RocketLeague { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class RocketLeague : global::System.Configuration.ApplicationSettingsBase { + + private static RocketLeague defaultInstance = ((RocketLeague)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new RocketLeague()))); + + public static RocketLeague Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Enabled { + get { + return ((bool)(this["Enabled"])); + } + set { + this["Enabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FFFF5000")] + public global::System.Windows.Media.Color MainColor { + get { + return ((global::System.Windows.Media.Color)(this["MainColor"])); + } + set { + this["MainColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FFFF0000")] + public global::System.Windows.Media.Color SecondaryColor { + get { + return ((global::System.Windows.Media.Color)(this["SecondaryColor"])); + } + set { + this["SecondaryColor"] = value; + } + } + } +} diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.settings b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.settings index 44ad08314..386d61448 100644 --- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.settings +++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeague.settings @@ -1,17 +1,15 @@ - - - - - - - True - - - #FFFF5000 - - - #FFFF0000 - - + + + + + + True + + + #FFFF5000 + + + #FFFF0000 + + \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs index 1353fbcf5..3a172baec 100644 --- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs +++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs @@ -5,6 +5,7 @@ using System.Drawing.Drawing2D; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Artemis.Managers; using Artemis.Models; using Artemis.Settings; using Artemis.Utilities; @@ -23,7 +24,7 @@ namespace Artemis.Modules.Games.RocketLeague private GamePointersCollectionModel _pointer; private int _previousBoost; - public RocketLeagueModel(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel) + public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager) { Settings = settings; Name = "RocketLeague"; @@ -43,7 +44,7 @@ namespace Artemis.Modules.Games.RocketLeague public override void Enable() { - _boostRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List + _boostRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List { ColorHelpers.ToDrawingColor(Settings.MainColor), ColorHelpers.ToDrawingColor(Settings.SecondaryColor) @@ -91,7 +92,8 @@ namespace Artemis.Modules.Games.RocketLeague if (_boostAmount > 100) _boostAmount = 100; - _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount); + _boostRect.Width = + (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount); _boostRect.Colors = new List { ColorHelpers.ToDrawingColor(Settings.MainColor), @@ -113,7 +115,8 @@ namespace Artemis.Modules.Games.RocketLeague var differenceStep = difference/amountOfSteps; var differenceStepRest = difference%amountOfSteps; _boostAmount = _previousBoost; - _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount); + _boostRect.Width = + (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount); for (var i = 0; i < amountOfSteps; i++) { @@ -121,10 +124,12 @@ namespace Artemis.Modules.Games.RocketLeague { differenceStepRest -= 1; _boostAmount += 1; - _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount); + _boostRect.Width = + (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount); } _boostAmount += differenceStep; - _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount); + _boostRect.Width = + (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount); Thread.Sleep(50); } @@ -134,7 +139,7 @@ namespace Artemis.Modules.Games.RocketLeague public override Bitmap GenerateBitmap() { - var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); + var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); if (_boostRect == null) return null; diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs index 9aaaf2c4a..43dbf53a7 100644 --- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs +++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs @@ -1,4 +1,4 @@ -using Artemis.Models; +using Artemis.Managers; using Caliburn.Micro; namespace Artemis.Modules.Games.RocketLeague @@ -7,21 +7,21 @@ namespace Artemis.Modules.Games.RocketLeague { private RocketLeagueSettings _rocketLeagueSettings; - public RocketLeagueViewModel(MainModel mainModel) + public RocketLeagueViewModel(MainManager mainManager) { - MainModel = mainModel; + MainManager = mainManager; // Settings are loaded from file by class RocketLeagueSettings = new RocketLeagueSettings(); - // Create effect model and add it to MainModel - RocketLeagueModel = new RocketLeagueModel(mainModel, RocketLeagueSettings); - MainModel.EffectModels.Add(RocketLeagueModel); + // Create effect model and add it to MainManager + RocketLeagueModel = new RocketLeagueModel(mainManager, RocketLeagueSettings); + MainManager.EffectManager.EffectModels.Add(RocketLeagueModel); } public static string Name => "Rocket League"; - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } public RocketLeagueModel RocketLeagueModel { get; set; } public RocketLeagueSettings RocketLeagueSettings diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.Designer.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.Designer.cs index 05b6e6662..f7a1d649b 100644 --- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.Designer.cs +++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.Designer.cs @@ -1,38 +1,38 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Artemis.Modules.Games.Witcher3 { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class Witcher3 : global::System.Configuration.ApplicationSettingsBase { - - private static Witcher3 defaultInstance = ((Witcher3)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Witcher3()))); - - public static Witcher3 Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool Enabled { - get { - return ((bool)(this["Enabled"])); - } - set { - this["Enabled"] = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Artemis.Modules.Games.Witcher3 { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class Witcher3 : global::System.Configuration.ApplicationSettingsBase { + + private static Witcher3 defaultInstance = ((Witcher3)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Witcher3()))); + + public static Witcher3 Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Enabled { + get { + return ((bool)(this["Enabled"])); + } + set { + this["Enabled"] = value; + } + } + } +} diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.settings b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.settings index adbc00bca..1a68809bc 100644 --- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.settings +++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3.settings @@ -1,11 +1,9 @@ - - - - - - - True - - + + + + + + True + + \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs index ff23fd6b8..1a9d02576 100644 --- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs +++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs @@ -5,6 +5,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.IO; using System.Text.RegularExpressions; +using Artemis.Managers; using Artemis.Models; using Artemis.Utilities.Keyboard; @@ -17,7 +18,7 @@ namespace Artemis.Modules.Games.Witcher3 private KeyboardRectangle _signRect; private string _witcherSettings; - public Witcher3Model(MainModel mainModel, Witcher3Settings settings) : base(mainModel) + public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager) { Settings = settings; Name = "Witcher3"; @@ -42,7 +43,7 @@ namespace Artemis.Modules.Games.Witcher3 public override void Enable() { - _signRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List(), + _signRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List(), LinearGradientMode.Horizontal) { Rotate = true, @@ -102,7 +103,7 @@ namespace Artemis.Modules.Games.Witcher3 public override Bitmap GenerateBitmap() { - var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); + var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); using (var g = Graphics.FromImage(bitmap)) { g.Clear(Color.Transparent); diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs index c94c3b9c6..3eb76357c 100644 --- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs +++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs @@ -3,7 +3,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Windows.Forms; -using Artemis.Models; +using Artemis.Managers; using Artemis.Properties; using Screen = Caliburn.Micro.Screen; @@ -13,21 +13,21 @@ namespace Artemis.Modules.Games.Witcher3 { private Witcher3Settings _witcher3Settings; - public Witcher3ViewModel(MainModel mainModel) + public Witcher3ViewModel(MainManager mainManager) { - MainModel = mainModel; + MainManager = mainManager; // Settings are loaded from file by class Witcher3Settings = new Witcher3Settings(); - // Create effect model and add it to MainModel - Witcher3Model = new Witcher3Model(mainModel, Witcher3Settings); - MainModel.EffectModels.Add(Witcher3Model); + // Create effect model and add it to MainManager + Witcher3Model = new Witcher3Model(mainManager, Witcher3Settings); + MainManager.EffectManager.EffectModels.Add(Witcher3Model); } public static string Name => "The Witcher 3"; - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } public Witcher3Model Witcher3Model { get; set; } public Witcher3Settings Witcher3Settings @@ -115,8 +115,11 @@ namespace Artemis.Modules.Games.Witcher3 Directory.CreateDirectory(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc"); // Install the mod files - File.WriteAllText(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc\artemis.xml",Resources.artemisXml); - File.WriteAllText(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",Resources.playerWitcherWs); + File.WriteAllText(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc\artemis.xml", + Resources.artemisXml); + File.WriteAllText( + folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player\playerWitcher.ws", + Resources.playerWitcherWs); Process.Start(new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3")); diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.Designer.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.Designer.cs index 9d4a388a9..cc98a9abc 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.Designer.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.Designer.cs @@ -1,62 +1,62 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Artemis.Settings { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class VolumeDisplay : global::System.Configuration.ApplicationSettingsBase { - - private static VolumeDisplay defaultInstance = ((VolumeDisplay)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new VolumeDisplay()))); - - public static VolumeDisplay Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#FFFF2900")] - public global::System.Windows.Media.Color MainColor { - get { - return ((global::System.Windows.Media.Color)(this["MainColor"])); - } - set { - this["MainColor"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#FF26F600")] - public global::System.Windows.Media.Color SecondaryColor { - get { - return ((global::System.Windows.Media.Color)(this["SecondaryColor"])); - } - set { - this["SecondaryColor"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool Enabled { - get { - return ((bool)(this["Enabled"])); - } - set { - this["Enabled"] = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Artemis.Modules.Overlays.VolumeDisplay { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class VolumeDisplay : global::System.Configuration.ApplicationSettingsBase { + + private static VolumeDisplay defaultInstance = ((VolumeDisplay)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new VolumeDisplay()))); + + public static VolumeDisplay Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Enabled { + get { + return ((bool)(this["Enabled"])); + } + set { + this["Enabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FFFF2900")] + public global::System.Windows.Media.Color MainColor { + get { + return ((global::System.Windows.Media.Color)(this["MainColor"])); + } + set { + this["MainColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FF26F600")] + public global::System.Windows.Media.Color SecondaryColor { + get { + return ((global::System.Windows.Media.Color)(this["SecondaryColor"])); + } + set { + this["SecondaryColor"] = value; + } + } + } +} diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs index 0adeb1102..395a74070 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs @@ -1,23 +1,23 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; -using Artemis.Models; +using Artemis.Managers; using Artemis.Utilities; using Artemis.Utilities.Keyboard; namespace Artemis.Modules.Overlays.VolumeDisplay { - public class VolumeDisplay + public class VolumeBar { - public VolumeDisplay(MainModel mainModel, VolumeDisplaySettings settings) + public VolumeBar(MainManager mainManager, VolumeDisplaySettings settings) { - MainModel = mainModel; + MainManager = mainManager; Settings = settings; Transparancy = 255; Scale = 4; } - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } public VolumeDisplaySettings Settings { get; set; } @@ -30,14 +30,14 @@ namespace Artemis.Modules.Overlays.VolumeDisplay public void Draw(Graphics g) { - var volumeRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List + var volumeRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List { ColorHelpers.ToDrawingColor(Settings.SecondaryColor), ColorHelpers.ToDrawingColor(Settings.MainColor) }, LinearGradientMode.Horizontal) { - Width = (int) (MainModel.ActiveKeyboard.Width*Scale/100.00*Volume), + Width = (int) (MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume), ContainedBrush = false }; volumeRect.Draw(g); diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.settings b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.settings index 1202c6f4e..88f34366e 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.settings +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.settings @@ -1,17 +1,15 @@ - - - - - - - #FFFF2900 - - - #FF26F600 - - - True - - + + + + + + True + + + #FFFF2900 + + + #FF26F600 + + \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayModel.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayModel.cs index 428cdcd91..ff4398e5c 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayModel.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayModel.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows.Forms; +using Artemis.Managers; using Artemis.Models; using NAudio.CoreAudioApi; @@ -9,28 +10,28 @@ namespace Artemis.Modules.Overlays.VolumeDisplay { public class VolumeDisplayModel : OverlayModel { - public VolumeDisplayModel(MainModel mainModel, VolumeDisplaySettings settings) : base(mainModel) + public VolumeDisplayModel(MainManager mainManager, VolumeDisplaySettings settings) : base(mainManager) { Settings = settings; Name = "VolumeDisplay"; Enabled = Settings.Enabled; - VolumeDisplay = new VolumeDisplay(mainModel, settings); + VolumeDisplay = new VolumeBar(mainManager, settings); } - public VolumeDisplay VolumeDisplay { get; set; } + public VolumeBar VolumeDisplay { get; set; } public VolumeDisplaySettings Settings { get; set; } public override void Dispose() { - MainModel.KeyboardHook.Unsubscribe(HandleKeypress); + MainManager.KeyboardHook.Unsubscribe(HandleKeypress); } public override void Enable() { // Listener won't start unless the effect is active - MainModel.KeyboardHook.Subscribe(HandleKeypress); + MainManager.KeyboardHook.Subscribe(HandleKeypress); } public override void Update() @@ -63,7 +64,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay public override Bitmap GenerateBitmap() { - return GenerateBitmap(MainModel.ActiveKeyboard.KeyboardBitmap(4)); + return GenerateBitmap(MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4)); } public override Bitmap GenerateBitmap(Bitmap bitmap) diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs index 9c46879df..92990d6e2 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs @@ -16,18 +16,18 @@ namespace Artemis.Modules.Overlays.VolumeDisplay public sealed override void Load() { - Enabled = Settings.VolumeDisplay.Default.Enabled; - MainColor = Settings.VolumeDisplay.Default.MainColor; - SecondaryColor = Settings.VolumeDisplay.Default.SecondaryColor; + Enabled = VolumeDisplay.Default.Enabled; + MainColor = VolumeDisplay.Default.MainColor; + SecondaryColor = VolumeDisplay.Default.SecondaryColor; } public sealed override void Save() { - Settings.VolumeDisplay.Default.Enabled = Enabled; - Settings.VolumeDisplay.Default.MainColor = MainColor; - Settings.VolumeDisplay.Default.SecondaryColor = SecondaryColor; + VolumeDisplay.Default.Enabled = Enabled; + VolumeDisplay.Default.MainColor = MainColor; + VolumeDisplay.Default.SecondaryColor = SecondaryColor; - Settings.VolumeDisplay.Default.Save(); + VolumeDisplay.Default.Save(); } public sealed override void ToDefault() diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs index 5eb11307b..68b8f51f2 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs @@ -1,4 +1,4 @@ -using Artemis.Models; +using Artemis.Managers; using Caliburn.Micro; namespace Artemis.Modules.Overlays.VolumeDisplay @@ -7,21 +7,21 @@ namespace Artemis.Modules.Overlays.VolumeDisplay { private VolumeDisplaySettings _volumeDisplaySettings; - public VolumeDisplayViewModel(MainModel mainModel) + public VolumeDisplayViewModel(MainManager mainManager) { - MainModel = mainModel; + MainManager = mainManager; // Settings are loaded from file by class VolumeDisplaySettings = new VolumeDisplaySettings(); - // Create effect model and add it to MainModel - VolumeDisplayModel = new VolumeDisplayModel(mainModel, VolumeDisplaySettings); - MainModel.EffectModels.Add(VolumeDisplayModel); + // Create effect model and add it to MainManager + VolumeDisplayModel = new VolumeDisplayModel(mainManager, VolumeDisplaySettings); + MainManager.EffectManager.EffectModels.Add(VolumeDisplayModel); } public static string Name => "Volume Display"; - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } public VolumeDisplayModel VolumeDisplayModel { get; set; } public VolumeDisplaySettings VolumeDisplaySettings diff --git a/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs b/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs index a8fc3ff8e..61df97f21 100644 --- a/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs +++ b/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs @@ -18,8 +18,8 @@ namespace Artemis.Utilities.Memory public static Process GetProcessIfRunning(string processName) { - var rlProcess = Process.GetProcessesByName(processName); - return rlProcess.Length >= 1 ? rlProcess[0] : null; + var processes = Process.GetProcessesByName(processName); + return processes.Length >= 1 ? processes[0] : null; } public static IntPtr FindAddress(IntPtr pHandle, IntPtr baseAddress, IntPtr staticPointer, int[] offsets) diff --git a/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs new file mode 100644 index 000000000..b03f9b760 --- /dev/null +++ b/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs @@ -0,0 +1,49 @@ +using Artemis.Managers; +using Artemis.Models; +using Caliburn.Micro; + +namespace Artemis.ViewModels.Abstract +{ + public abstract class EffectViewModel : Screen + { + private EffectSettings _effectSettings; + + public EffectModel EffectModel { get; set; } + public MainManager MainManager { get; set; } + + public EffectSettings EffectSettings + { + get { return _effectSettings; } + set + { + if (Equals(value, _effectSettings)) return; + _effectSettings = value; + NotifyOfPropertyChange(() => EffectSettings); + } + } + + public bool EffectEnabled => MainManager.EffectManager.ActiveEffect == EffectModel; + + public void ToggleEffect() + { + if (EffectEnabled) + MainManager.EffectManager.ClearEffect(); + else + MainManager.EffectManager.ChangeEffect(EffectModel); + } + + public void SaveSettings() + { + EffectSettings?.Save(); + } + + public void ResetSettings() + { + // TODO: Confirmation dialog (Generic MVVM approach) + EffectSettings.ToDefault(); + NotifyOfPropertyChange(() => EffectSettings); + + SaveSettings(); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/ViewModels/EffectsViewModel.cs b/Artemis/Artemis/ViewModels/EffectsViewModel.cs index 8d193f416..1f2b5be68 100644 --- a/Artemis/Artemis/ViewModels/EffectsViewModel.cs +++ b/Artemis/Artemis/ViewModels/EffectsViewModel.cs @@ -1,4 +1,4 @@ -using Artemis.Models; +using Artemis.Managers; using Artemis.Modules.Effects.AudioVisualizer; using Artemis.Modules.Effects.Debug; using Artemis.Modules.Effects.TypeHole; @@ -14,12 +14,12 @@ namespace Artemis.ViewModels private readonly TypeHoleViewModel _typeHoleVm; private readonly TypeWaveViewModel _typeWaveVm; - public EffectsViewModel(MainModel mainModel) + public EffectsViewModel(MainManager mainManager) { - _typeWaveVm = new TypeWaveViewModel(mainModel) {DisplayName = "Type Waves"}; - //_typeHoleVm = new TypeHoleViewModel(mainModel) {DisplayName = "Type Holes (NYI)"}; - _audioVisualizerVm = new AudioVisualizerViewModel(mainModel) {DisplayName = "Audio Visualization"}; - _debugVm = new DebugEffectViewModel(mainModel) {DisplayName = "Debug Effect"}; + _typeWaveVm = new TypeWaveViewModel(mainManager) {DisplayName = "Type Waves"}; + //_typeHoleVm = new TypeHoleViewModel(MainManager) {DisplayName = "Type Holes (NYI)"}; + _audioVisualizerVm = new AudioVisualizerViewModel(mainManager) {DisplayName = "Audio Visualization"}; + _debugVm = new DebugEffectViewModel(mainManager) {DisplayName = "Debug Effect"}; } protected override void OnActivate() diff --git a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs index 8034942a9..05cc0d9f4 100644 --- a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs +++ b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Linq; using Artemis.Events; -using Artemis.Models; +using Artemis.Managers; using Artemis.Settings; using Caliburn.Micro; using MahApps.Metro.Controls; @@ -14,14 +14,14 @@ namespace Artemis.ViewModels.Flyouts private GeneralSettings _generalSettings; private string _selectedKeyboardProvider; - public FlyoutSettingsViewModel(MainModel mainModel) + public FlyoutSettingsViewModel(MainManager mainManager) { - MainModel = mainModel; - Header = "settings"; + MainManager = mainManager; + Header = "Settings"; Position = Position.Right; GeneralSettings = new GeneralSettings(); - MainModel.Events.Subscribe(this); + MainManager.Events.Subscribe(this); } public GeneralSettings GeneralSettings @@ -35,10 +35,10 @@ namespace Artemis.ViewModels.Flyouts } } - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } public BindableCollection KeyboardProviders - => new BindableCollection(MainModel.KeyboardProviders.Select(k => k.Name)); + => new BindableCollection(MainManager.KeyboardManager.KeyboardProviders.Select(k => k.Name)); public string SelectedKeyboardProvider { @@ -51,7 +51,8 @@ namespace Artemis.ViewModels.Flyouts if (value == null) return; - MainModel.ChangeKeyboard(MainModel.KeyboardProviders.First(k => k.Name == _selectedKeyboardProvider)); + MainManager.KeyboardManager.ChangeKeyboard( + MainManager.KeyboardManager.KeyboardProviders.First(k => k.Name == _selectedKeyboardProvider)); } } @@ -75,9 +76,11 @@ namespace Artemis.ViewModels.Flyouts public void ToggleEnabled() { if (Enabled) - MainModel.ShutdownEffects(); + MainManager.Stop(); + else if (MainManager.EffectManager.ActiveEffect != null) + MainManager.Start(); else - MainModel.StartEffects(); + MainManager.Start(MainManager.EffectManager.GetLastEffect()); } public void ResetSettings() @@ -98,7 +101,7 @@ namespace Artemis.ViewModels.Flyouts protected override void HandleOpen() { - SelectedKeyboardProvider = MainModel.ActiveKeyboard?.Name; + SelectedKeyboardProvider = MainManager.KeyboardManager.ActiveKeyboard?.Name; } } } \ No newline at end of file diff --git a/Artemis/Artemis/ViewModels/GamesViewModel.cs b/Artemis/Artemis/ViewModels/GamesViewModel.cs index 5588c0175..95c3f3745 100644 --- a/Artemis/Artemis/ViewModels/GamesViewModel.cs +++ b/Artemis/Artemis/ViewModels/GamesViewModel.cs @@ -1,4 +1,4 @@ -using Artemis.Models; +using Artemis.Managers; using Artemis.Modules.Games.CounterStrike; using Artemis.Modules.Games.Dota2; using Artemis.Modules.Games.RocketLeague; @@ -14,12 +14,12 @@ namespace Artemis.ViewModels private readonly RocketLeagueViewModel _rocketLeagueVm; private readonly Witcher3ViewModel _witcher3Vm; - public GamesViewModel(MainModel mainModel) + public GamesViewModel(MainManager mainManager) { - _rocketLeagueVm = new RocketLeagueViewModel(mainModel) {DisplayName = "Rocket League"}; - _counterStrikeVm = new CounterStrikeViewModel(mainModel) {DisplayName = "CS:GO"}; - //_dota2Vm = new Dota2ViewModel(mainModel) {DisplayName = "Dota 2 (NYI)"}; - _witcher3Vm = new Witcher3ViewModel(mainModel) {DisplayName = "The Witcher 3"}; + _rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"}; + _counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"}; + //_dota2Vm = new Dota2ViewModel(MainManager) {DisplayName = "Dota 2 (NYI)"}; + _witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"}; } protected override void OnActivate() diff --git a/Artemis/Artemis/ViewModels/OverlaysViewModel.cs b/Artemis/Artemis/ViewModels/OverlaysViewModel.cs index 8a707be80..c6290e7e1 100644 --- a/Artemis/Artemis/ViewModels/OverlaysViewModel.cs +++ b/Artemis/Artemis/ViewModels/OverlaysViewModel.cs @@ -1,4 +1,4 @@ -using Artemis.Models; +using Artemis.Managers; using Artemis.Modules.Overlays.VolumeDisplay; using Caliburn.Micro; @@ -6,12 +6,12 @@ namespace Artemis.ViewModels { public class OverlaysViewModel : Conductor.Collection.OneActive { - private readonly MainModel _mainModel; + private readonly MainManager _mainManager; private VolumeDisplayViewModel _volumeDisplayVm; - public OverlaysViewModel(MainModel mainModel) + public OverlaysViewModel(MainManager mainManager) { - _mainModel = mainModel; + _mainManager = mainManager; } protected override void OnActivate() @@ -21,7 +21,7 @@ namespace Artemis.ViewModels Items.Clear(); // This VM appears to be going out of scope, so recreating it every time just to be sure. - _volumeDisplayVm = new VolumeDisplayViewModel(_mainModel) { DisplayName = "Volume Display" }; + _volumeDisplayVm = new VolumeDisplayViewModel(_mainManager) {DisplayName = "Volume Display"}; ActivateItem(_volumeDisplayVm); ActiveItem = _volumeDisplayVm; } diff --git a/Artemis/Artemis/ViewModels/ShellViewModel.cs b/Artemis/Artemis/ViewModels/ShellViewModel.cs index fbf978e71..4105c1295 100644 --- a/Artemis/Artemis/ViewModels/ShellViewModel.cs +++ b/Artemis/Artemis/ViewModels/ShellViewModel.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Windows; -using Artemis.Models; +using Artemis.Managers; using Artemis.ViewModels.Flyouts; using Caliburn.Micro; @@ -17,21 +17,21 @@ namespace Artemis.ViewModels public ShellViewModel() { IEventAggregator events = new EventAggregator(); - MainModel = new MainModel(events); + MainManager = new MainManager(events); DisplayName = "Artemis"; _welcomeVm = new WelcomeViewModel {DisplayName = "Welcome"}; - _effectsVm = new EffectsViewModel(MainModel) {DisplayName = "Effects"}; - _gamesVm = new GamesViewModel(MainModel) {DisplayName = "Games"}; - _overlaysVm = new OverlaysViewModel(MainModel) {DisplayName = "Overlays"}; + _effectsVm = new EffectsViewModel(MainManager) {DisplayName = "Effects"}; + _gamesVm = new GamesViewModel(MainManager) {DisplayName = "Games"}; + _overlaysVm = new OverlaysViewModel(MainManager) {DisplayName = "Overlays"}; - Flyouts.Add(new FlyoutSettingsViewModel(MainModel)); + Flyouts.Add(new FlyoutSettingsViewModel(MainManager)); } public IObservableCollection Flyouts { get; set; } = new BindableCollection(); - public MainModel MainModel { get; set; } + public MainManager MainManager { get; set; } protected override void OnActivate() { @@ -47,7 +47,7 @@ namespace Artemis.ViewModels public void OnClose(EventArgs e) { - MainModel.ShutdownEffects(); + MainManager.Stop(); Application.Current.Shutdown(); } diff --git a/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs b/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs index a1b4c6289..7e016ff49 100644 --- a/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs +++ b/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs @@ -24,14 +24,7 @@ namespace Artemis.ViewModels { _windowManager = windowManager; _shellViewModel = shellViewModel; - _shellViewModel.MainModel.Events.Subscribe(this); - - /* - * By now Effects are added to the MainModel so we can savely start - * This is done from here to make sure all UI elements listening to - * events will receive the first ToggleEnabled event - * */ - _shellViewModel.MainModel.StartEffects(); + _shellViewModel.MainManager.Events.Subscribe(this); // TODO: Check if show on startup is enabled, if so, show window. } @@ -72,9 +65,9 @@ namespace Artemis.ViewModels public void ToggleEnabled() { if (Enabled) - _shellViewModel.MainModel.ShutdownEffects(); + _shellViewModel.MainManager.Stop(); else - _shellViewModel.MainModel.StartEffects(); + _shellViewModel.MainManager.Start(); } protected override void OnActivate() @@ -110,7 +103,7 @@ namespace Artemis.ViewModels public void ExitApplication() { - _shellViewModel.MainModel.ShutdownEffects(); + _shellViewModel.MainManager.Stop(); Application.Current.Shutdown(); } } diff --git a/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml b/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml index b89bd924a..232525c54 100644 --- a/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml +++ b/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml @@ -32,8 +32,7 @@ Content="Enable Artemis:" /> + IsChecked="{Binding Path=Enabled, Mode=OneWay}" />