mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Moving to Ninject dependency injection WIP 2
This commit is contained in:
parent
b01ab9b135
commit
f25dc00c16
@ -175,6 +175,14 @@
|
|||||||
<HintPath>..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll</HintPath>
|
<HintPath>..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Ninject.Extensions.Logging, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Ninject.Extensions.Logging.3.2.3.0\lib\net45-full\Ninject.Extensions.Logging.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Ninject.Extensions.Logging.NLog4, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Ninject.Extensions.Logging.nlog4.3.2.3.0\lib\net45-full\Ninject.Extensions.Logging.NLog4.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NLog.4.3.3\lib\net45\NLog.dll</HintPath>
|
<HintPath>..\packages\NLog.4.3.3\lib\net45\NLog.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@ -280,6 +288,7 @@
|
|||||||
<Compile Include="KeyboardProviders\Razer\Utilities\RazerUtilities.cs" />
|
<Compile Include="KeyboardProviders\Razer\Utilities\RazerUtilities.cs" />
|
||||||
<Compile Include="Managers\EffectManager.cs" />
|
<Compile Include="Managers\EffectManager.cs" />
|
||||||
<Compile Include="Managers\KeyboardManager.cs" />
|
<Compile Include="Managers\KeyboardManager.cs" />
|
||||||
|
<Compile Include="Managers\LoopManager.cs" />
|
||||||
<Compile Include="Managers\MainManager.cs" />
|
<Compile Include="Managers\MainManager.cs" />
|
||||||
<Compile Include="Models\EffectModel.cs" />
|
<Compile Include="Models\EffectModel.cs" />
|
||||||
<Compile Include="Models\EffectSettings.cs" />
|
<Compile Include="Models\EffectSettings.cs" />
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using Artemis.Events;
|
using Artemis.Events;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Modules.Effects.ProfilePreview;
|
using Artemis.Modules.Effects.ProfilePreview;
|
||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Ninject;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using LogManager = NLog.LogManager;
|
using LogManager = NLog.LogManager;
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Manages the effects
|
||||||
|
/// </summary>
|
||||||
public class EffectManager
|
public class EffectManager
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IEventAggregator _events;
|
private readonly IEventAggregator _events;
|
||||||
private EffectModel _activeEffect;
|
private EffectModel _activeEffect;
|
||||||
private bool _clearing;
|
|
||||||
|
|
||||||
public EffectManager(IEventAggregator events)
|
public EffectManager(IEventAggregator events)
|
||||||
{
|
{
|
||||||
@ -30,11 +30,6 @@ namespace Artemis.Managers
|
|||||||
Logger.Info("Intialized EffectManager");
|
Logger.Info("Intialized EffectManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Inject]
|
|
||||||
public Lazy<MainManager> MainManager { get; set; }
|
|
||||||
|
|
||||||
public EffectModel PauseEffect { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used by ViewModels to show a preview of the profile currently being edited
|
/// Used by ViewModels to show a preview of the profile currently being edited
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -78,13 +73,9 @@ namespace Artemis.Managers
|
|||||||
public EffectModel GetLastEffect()
|
public EffectModel GetLastEffect()
|
||||||
{
|
{
|
||||||
Logger.Debug("Getting last effect: {0}", General.Default.LastEffect);
|
Logger.Debug("Getting last effect: {0}", General.Default.LastEffect);
|
||||||
if (General.Default.LastEffect == null)
|
return General.Default.LastEffect == null
|
||||||
return null;
|
? null
|
||||||
|
: EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -92,8 +83,10 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="effectModel"></param>
|
/// <param name="effectModel"></param>
|
||||||
/// <param name="force">Changes the effect, even if it's already running (effectively restarting it)</param>
|
/// <param name="force">Changes the effect, even if it's already running (effectively restarting it)</param>
|
||||||
public void ChangeEffect(EffectModel effectModel, bool force = false)
|
public void ChangeEffect(EffectModel effectModel)
|
||||||
{
|
{
|
||||||
|
if (effectModel == null)
|
||||||
|
throw new ArgumentNullException(nameof(effectModel));
|
||||||
if (effectModel is OverlayModel)
|
if (effectModel is OverlayModel)
|
||||||
throw new ArgumentException("Can't set an Overlay effect as the active effect");
|
throw new ArgumentException("Can't set an Overlay effect as the active effect");
|
||||||
|
|
||||||
@ -103,60 +96,21 @@ namespace Artemis.Managers
|
|||||||
if (!gameModel.Enabled)
|
if (!gameModel.Enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ActiveEffect != null)
|
var wasNull = false;
|
||||||
if (effectModel.Name == ActiveEffect.Name && !force)
|
if (ActiveEffect == null)
|
||||||
return;
|
|
||||||
|
|
||||||
Logger.Debug("Changing effect to: {0}, force: {1}", effectModel?.Name, force);
|
|
||||||
// If the main manager is running, pause it and safely change the effect
|
|
||||||
if (MainManager.Value.Running)
|
|
||||||
{
|
{
|
||||||
ChangeEffectWithPause(effectModel);
|
wasNull = true;
|
||||||
return;
|
ActiveEffect = effectModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's not running start it, and let the next recursion handle changing the effect
|
lock (ActiveEffect)
|
||||||
MainManager.Value.Start(effectModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ChangeEffectWithPause(EffectModel effectModel)
|
|
||||||
{
|
{
|
||||||
var tryCount = 0;
|
if (!wasNull)
|
||||||
while (PauseEffect != null)
|
ActiveEffect.Dispose();
|
||||||
{
|
|
||||||
Thread.Sleep(500);
|
|
||||||
tryCount++;
|
|
||||||
if (tryCount > 20)
|
|
||||||
throw new Exception("Couldn't change effect before the time expired");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't interrupt an ongoing effect change
|
ActiveEffect = effectModel;
|
||||||
if (PauseEffect != null)
|
ActiveEffect.Enable();
|
||||||
{
|
|
||||||
Logger.Debug("Change effect with pause cancelled");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Logger.Debug("Changing effect with pause: {0}", effectModel?.Name);
|
|
||||||
|
|
||||||
PauseEffect = effectModel;
|
|
||||||
MainManager.Value.Pause();
|
|
||||||
MainManager.Value.PauseCallback += ChangeEffectPauseCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ChangeEffectPauseCallback()
|
|
||||||
{
|
|
||||||
MainManager.Value.PauseCallback -= ChangeEffectPauseCallback;
|
|
||||||
|
|
||||||
// Change effect logic
|
|
||||||
ActiveEffect?.Dispose();
|
|
||||||
|
|
||||||
ActiveEffect = PauseEffect;
|
|
||||||
ActiveEffect?.Enable();
|
|
||||||
|
|
||||||
MainManager.Value.Unpause();
|
|
||||||
PauseEffect = null;
|
|
||||||
|
|
||||||
Logger.Debug("Finishing change effect with pause");
|
|
||||||
if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel)
|
if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -165,46 +119,25 @@ namespace Artemis.Managers
|
|||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Debug($"Changed active effect to: {effectModel.Name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears the current effect
|
/// Clears the current effect
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearEffect()
|
public void ClearEffect()
|
||||||
{
|
{
|
||||||
if (_clearing)
|
lock (ActiveEffect)
|
||||||
return;
|
|
||||||
|
|
||||||
// Don't mess with the ActiveEffect if in the process of changing the effect.
|
|
||||||
if (PauseEffect != null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (ActiveEffect == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_clearing = true;
|
|
||||||
Logger.Debug("Clearing active effect");
|
|
||||||
MainManager.Value.Pause();
|
|
||||||
MainManager.Value.PauseCallback += ClearEffectPauseCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ClearEffectPauseCallback()
|
|
||||||
{
|
{
|
||||||
MainManager.Value.PauseCallback -= ClearEffectPauseCallback;
|
|
||||||
if (PauseEffect != null)
|
|
||||||
{
|
|
||||||
Logger.Debug("Cancelling clearing effect");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActiveEffect.Dispose();
|
ActiveEffect.Dispose();
|
||||||
ActiveEffect = null;
|
ActiveEffect = null;
|
||||||
|
|
||||||
General.Default.LastEffect = null;
|
General.Default.LastEffect = null;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
|
}
|
||||||
|
|
||||||
_clearing = false;
|
Logger.Debug("Cleared active effect");
|
||||||
|
|
||||||
Logger.Debug("Finishing clearing active effect");
|
|
||||||
MainManager.Value.Unpause();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -213,7 +146,7 @@ namespace Artemis.Managers
|
|||||||
/// <param name="activeEffect"></param>
|
/// <param name="activeEffect"></param>
|
||||||
public void DisableGame(EffectModel activeEffect)
|
public void DisableGame(EffectModel activeEffect)
|
||||||
{
|
{
|
||||||
Logger.Debug("Disabling game: {0}", activeEffect?.Name);
|
Logger.Debug($"Disabling game: {activeEffect?.Name}");
|
||||||
if (GetLastEffect() == null)
|
if (GetLastEffect() == null)
|
||||||
ClearEffect();
|
ClearEffect();
|
||||||
else
|
else
|
||||||
|
|||||||
@ -5,12 +5,14 @@ using Artemis.Events;
|
|||||||
using Artemis.KeyboardProviders;
|
using Artemis.KeyboardProviders;
|
||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Ninject;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using LogManager = NLog.LogManager;
|
using LogManager = NLog.LogManager;
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Manages the keyboard providers
|
||||||
|
/// </summary>
|
||||||
public class KeyboardManager
|
public class KeyboardManager
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
@ -27,9 +29,6 @@ namespace Artemis.Managers
|
|||||||
Logger.Info("Intialized KeyboardManager");
|
Logger.Info("Intialized KeyboardManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Inject]
|
|
||||||
public Lazy<MainManager> MainManager { get; set; }
|
|
||||||
|
|
||||||
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
||||||
|
|
||||||
public KeyboardProvider ActiveKeyboard
|
public KeyboardProvider ActiveKeyboard
|
||||||
@ -43,17 +42,13 @@ namespace Artemis.Managers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanDisable { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enables the last keyboard according to the settings file
|
/// Enables the last keyboard according to the settings file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnableLastKeyboard()
|
public void EnableLastKeyboard()
|
||||||
{
|
{
|
||||||
Logger.Debug("Enabling last keyboard: {0}", General.Default.LastKeyboard);
|
Logger.Debug($"Enabling last keyboard: {General.Default.LastKeyboard}");
|
||||||
if (General.Default.LastKeyboard == null)
|
if (string.IsNullOrEmpty(General.Default.LastKeyboard))
|
||||||
return;
|
|
||||||
if (General.Default.LastKeyboard == "")
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard);
|
var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard);
|
||||||
@ -66,32 +61,41 @@ namespace Artemis.Managers
|
|||||||
/// <param name="keyboardProvider"></param>
|
/// <param name="keyboardProvider"></param>
|
||||||
public void EnableKeyboard(KeyboardProvider keyboardProvider)
|
public void EnableKeyboard(KeyboardProvider keyboardProvider)
|
||||||
{
|
{
|
||||||
Logger.Debug("Enabling keyboard: {0}", keyboardProvider?.Name);
|
|
||||||
ReleaseActiveKeyboard();
|
|
||||||
|
|
||||||
if (keyboardProvider == null)
|
if (keyboardProvider == null)
|
||||||
|
throw new ArgumentNullException(nameof(keyboardProvider));
|
||||||
|
|
||||||
|
if (ActiveKeyboard?.Name == keyboardProvider.Name)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ActiveKeyboard != null)
|
var wasNull = false;
|
||||||
if (keyboardProvider.Name == ActiveKeyboard.Name)
|
if (ActiveKeyboard == null)
|
||||||
return;
|
{
|
||||||
|
wasNull = true;
|
||||||
|
ActiveKeyboard = keyboardProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (ActiveKeyboard)
|
||||||
|
{
|
||||||
|
Logger.Debug($"Enabling keyboard: {keyboardProvider.Name}");
|
||||||
|
|
||||||
|
if (!wasNull)
|
||||||
|
ReleaseActiveKeyboard();
|
||||||
|
|
||||||
// Disable everything if there's no active keyboard found
|
// Disable everything if there's no active keyboard found
|
||||||
if (!keyboardProvider.CanEnable())
|
if (!keyboardProvider.CanEnable())
|
||||||
{
|
{
|
||||||
MainManager.Value.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
|
// TODO: MainManager.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
|
||||||
General.Default.LastKeyboard = null;
|
General.Default.LastKeyboard = null;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CanDisable = false;
|
|
||||||
ActiveKeyboard = keyboardProvider;
|
ActiveKeyboard = keyboardProvider;
|
||||||
keyboardProvider.Enable();
|
ActiveKeyboard.Enable();
|
||||||
|
|
||||||
General.Default.LastKeyboard = ActiveKeyboard.Name;
|
General.Default.LastKeyboard = ActiveKeyboard.Name;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
CanDisable = true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -99,29 +103,16 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReleaseActiveKeyboard()
|
public void ReleaseActiveKeyboard()
|
||||||
{
|
{
|
||||||
if (ActiveKeyboard == null || !CanDisable)
|
lock (ActiveKeyboard)
|
||||||
|
{
|
||||||
|
if (ActiveKeyboard == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ActiveKeyboard.Disable();
|
ActiveKeyboard.Disable();
|
||||||
Logger.Debug("Released keyboard: {0}", ActiveKeyboard?.Name);
|
|
||||||
ActiveKeyboard = null;
|
ActiveKeyboard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
Logger.Debug($"Released keyboard: {ActiveKeyboard?.Name}");
|
||||||
/// Changes the active keyboard
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="keyboardProvider"></param>
|
|
||||||
public void ChangeKeyboard(KeyboardProvider keyboardProvider)
|
|
||||||
{
|
|
||||||
Logger.Debug("Changing active keyboard");
|
|
||||||
if (keyboardProvider == ActiveKeyboard)
|
|
||||||
return;
|
|
||||||
|
|
||||||
General.Default.LastKeyboard = keyboardProvider?.Name;
|
|
||||||
General.Default.Save();
|
|
||||||
|
|
||||||
Logger.Debug("Restarting for keyboard change");
|
|
||||||
MainManager.Value.Restart();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
118
Artemis/Artemis/Managers/LoopManager.cs
Normal file
118
Artemis/Artemis/Managers/LoopManager.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
using System;
|
||||||
|
using System.Timers;
|
||||||
|
using Artemis.Events;
|
||||||
|
using Caliburn.Micro;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Artemis.Managers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Manages the main programn loop
|
||||||
|
/// </summary>
|
||||||
|
public class LoopManager : IDisposable
|
||||||
|
{
|
||||||
|
private readonly EffectManager _effectManager;
|
||||||
|
private readonly IEventAggregator _events;
|
||||||
|
private readonly KeyboardManager _keyboardManager;
|
||||||
|
private readonly Timer _loopTimer;
|
||||||
|
|
||||||
|
public LoopManager(ILogger logger, IEventAggregator events, EffectManager effectManager,
|
||||||
|
KeyboardManager keyboardManager)
|
||||||
|
{
|
||||||
|
Logger = logger;
|
||||||
|
_events = events;
|
||||||
|
_effectManager = effectManager;
|
||||||
|
_keyboardManager = keyboardManager;
|
||||||
|
|
||||||
|
_loopTimer = new Timer(40);
|
||||||
|
_loopTimer.Elapsed += Render;
|
||||||
|
_loopTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILogger Logger { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets whether the loop is running
|
||||||
|
/// </summary>
|
||||||
|
public bool Running { get; private set; }
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_loopTimer.Stop();
|
||||||
|
_loopTimer.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
Logger.Debug("Starting LoopManager");
|
||||||
|
// Setup
|
||||||
|
|
||||||
|
Running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
Logger.Debug("Stopping LoopManager");
|
||||||
|
Running = false;
|
||||||
|
|
||||||
|
// Shut down
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Render(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Running)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Lock both the active keyboard and active effect so they will not change while rendering.
|
||||||
|
lock (_keyboardManager.ActiveKeyboard)
|
||||||
|
{
|
||||||
|
lock (_effectManager.ActiveEffect)
|
||||||
|
{
|
||||||
|
// Stop if no active keyboard/efffect
|
||||||
|
if (_keyboardManager.ActiveKeyboard == null || _effectManager.ActiveEffect == null)
|
||||||
|
{
|
||||||
|
Logger.Debug("No active keyboard/effect, stopping. " +
|
||||||
|
$"Keyboard={_keyboardManager.ActiveKeyboard?.Name}, " +
|
||||||
|
$"effect={_effectManager.ActiveEffect?.Name}");
|
||||||
|
Stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip frame if effect is still initializing
|
||||||
|
if (_effectManager.ActiveEffect.Initialized == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Update the current effect
|
||||||
|
if (_effectManager.ActiveEffect.Initialized)
|
||||||
|
_effectManager.ActiveEffect.Update();
|
||||||
|
|
||||||
|
// Get ActiveEffect's bitmap
|
||||||
|
var bitmap = _effectManager.ActiveEffect.Initialized
|
||||||
|
? _effectManager.ActiveEffect.GenerateBitmap()
|
||||||
|
: null;
|
||||||
|
|
||||||
|
lock (_effectManager.EnabledOverlays)
|
||||||
|
{
|
||||||
|
// Draw enabled overlays on top
|
||||||
|
foreach (var overlayModel in _effectManager.EnabledOverlays)
|
||||||
|
{
|
||||||
|
overlayModel.Update();
|
||||||
|
bitmap = bitmap != null
|
||||||
|
? overlayModel.GenerateBitmap(bitmap)
|
||||||
|
: overlayModel.GenerateBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If it exists, send bitmap to the device
|
||||||
|
_keyboardManager.ActiveKeyboard.DrawBitmap(bitmap);
|
||||||
|
|
||||||
|
// debugging TODO: Disable when window isn't shown (in Debug VM, or get rid of it, w/e)
|
||||||
|
_events.PublishOnUIThread(new ChangeBitmap(bitmap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,42 +12,35 @@ using Artemis.Utilities.LogitechDll;
|
|||||||
using Artemis.ViewModels;
|
using Artemis.ViewModels;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using NLog;
|
using Ninject.Extensions.Logging;
|
||||||
using LogManager = NLog.LogManager;
|
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
public class MainManager
|
/// <summary>
|
||||||
|
/// Contains all the other managers and non-loop related components
|
||||||
|
/// </summary>
|
||||||
|
public class MainManager : IDisposable
|
||||||
{
|
{
|
||||||
public delegate void PauseCallbackHandler();
|
public delegate void PauseCallbackHandler();
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
||||||
private readonly EffectManager _effectManager;
|
|
||||||
private readonly IEventAggregator _events;
|
private readonly IEventAggregator _events;
|
||||||
|
|
||||||
private readonly int _fps;
|
public MainManager(IEventAggregator events, ILogger logger, LoopManager loopManager,
|
||||||
private readonly KeyboardManager _keyboardManager;
|
KeyboardManager keyboardManager, EffectManager effectManager)
|
||||||
private bool _paused;
|
|
||||||
private bool _restarting;
|
|
||||||
|
|
||||||
public MainManager(IEventAggregator events, KeyboardManager keyboardManager, EffectManager effectManager)
|
|
||||||
{
|
{
|
||||||
|
Logger = logger;
|
||||||
|
LoopManager = loopManager;
|
||||||
|
KeyboardManager = keyboardManager;
|
||||||
|
EffectManager = effectManager;
|
||||||
|
|
||||||
Logger.Info("Intializing MainManager");
|
Logger.Info("Intializing MainManager");
|
||||||
|
|
||||||
_events = events;
|
_events = events;
|
||||||
_keyboardManager = keyboardManager;
|
|
||||||
_effectManager = effectManager;
|
|
||||||
_fps = 25;
|
|
||||||
|
|
||||||
//DialogService = dialogService;
|
//DialogService = dialogService;
|
||||||
KeyboardHook = new KeyboardHook();
|
KeyboardHook = new KeyboardHook();
|
||||||
|
|
||||||
UpdateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
|
||||||
ProcessWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
ProcessWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
||||||
|
|
||||||
UpdateWorker.DoWork += UpdateWorker_DoWork;
|
|
||||||
UpdateWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
|
|
||||||
|
|
||||||
ProcessWorker.DoWork += ProcessWorker_DoWork;
|
ProcessWorker.DoWork += ProcessWorker_DoWork;
|
||||||
ProcessWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
|
ProcessWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
|
||||||
|
|
||||||
@ -71,101 +64,21 @@ namespace Artemis.Managers
|
|||||||
[Inject]
|
[Inject]
|
||||||
public Lazy<ShellViewModel> ShellViewModel { get; set; }
|
public Lazy<ShellViewModel> ShellViewModel { get; set; }
|
||||||
|
|
||||||
|
public ILogger Logger { get; }
|
||||||
|
private LoopManager LoopManager { get; }
|
||||||
|
public KeyboardManager KeyboardManager { get; set; }
|
||||||
|
public EffectManager EffectManager { get; set; }
|
||||||
|
|
||||||
public PipeServer PipeServer { get; set; }
|
public PipeServer PipeServer { get; set; }
|
||||||
public BackgroundWorker UpdateWorker { get; set; }
|
|
||||||
public BackgroundWorker ProcessWorker { get; set; }
|
public BackgroundWorker ProcessWorker { get; set; }
|
||||||
|
|
||||||
public MetroDialogService DialogService { get; set; }
|
public MetroDialogService DialogService { get; set; }
|
||||||
|
|
||||||
public KeyboardHook KeyboardHook { get; set; }
|
public KeyboardHook KeyboardHook { get; set; }
|
||||||
|
|
||||||
public GameStateWebServer GameStateWebServer { get; set; }
|
public GameStateWebServer GameStateWebServer { get; set; }
|
||||||
|
|
||||||
public bool ProgramEnabled { get; private set; }
|
public bool ProgramEnabled { get; private set; }
|
||||||
public bool Suspended { get; set; }
|
public bool Suspended { get; set; }
|
||||||
|
|
||||||
public bool Running { get; private set; }
|
public bool Running { get; private set; }
|
||||||
|
|
||||||
public event PauseCallbackHandler PauseCallback;
|
public void Dispose()
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Take control of the keyboard and start sending data to it
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Whether starting was successful or not</returns>
|
|
||||||
public bool Start(EffectModel effect = null)
|
|
||||||
{
|
|
||||||
Logger.Debug("Starting MainManager");
|
|
||||||
// Can't take control when not enabled
|
|
||||||
if (!ProgramEnabled || UpdateWorker.CancellationPending || UpdateWorker.IsBusy || _paused)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Do nothing if already running
|
|
||||||
if (Running)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Only continue if a keyboard was loaded
|
|
||||||
_keyboardManager.EnableLastKeyboard();
|
|
||||||
if (_keyboardManager.ActiveKeyboard == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Running = true;
|
|
||||||
if (effect != null)
|
|
||||||
_effectManager.ChangeEffect(effect);
|
|
||||||
|
|
||||||
// Start the update worker
|
|
||||||
if (!UpdateWorker.IsBusy)
|
|
||||||
UpdateWorker.RunWorkerAsync();
|
|
||||||
|
|
||||||
return Running;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Releases control of the keyboard and stop sending data to it
|
|
||||||
/// </summary>
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
Logger.Debug("Stopping MainManager");
|
|
||||||
if (!Running || UpdateWorker.CancellationPending || _paused)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Stop the update worker
|
|
||||||
UpdateWorker.CancelAsync();
|
|
||||||
UpdateWorker.RunWorkerCompleted += FinishStop;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FinishStop(object sender, RunWorkerCompletedEventArgs e)
|
|
||||||
{
|
|
||||||
UpdateWorker.RunWorkerCompleted -= FinishStop;
|
|
||||||
_keyboardManager.ReleaseActiveKeyboard();
|
|
||||||
Running = false;
|
|
||||||
|
|
||||||
Logger.Debug("Stopped MainManager");
|
|
||||||
if (e.Error != null || !_restarting)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Start();
|
|
||||||
_restarting = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Pause()
|
|
||||||
{
|
|
||||||
if (!Running || UpdateWorker.CancellationPending || _paused)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Logger.Debug("Pausing MainManager");
|
|
||||||
_paused = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Unpause()
|
|
||||||
{
|
|
||||||
if (!_paused)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Logger.Debug("Unpausing MainManager");
|
|
||||||
_paused = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Shutdown()
|
|
||||||
{
|
{
|
||||||
Logger.Debug("Shutting down MainManager");
|
Logger.Debug("Shutting down MainManager");
|
||||||
Stop();
|
Stop();
|
||||||
@ -175,20 +88,46 @@ namespace Artemis.Managers
|
|||||||
PipeServer.Stop();
|
PipeServer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
/// <summary>
|
||||||
|
/// Take control of the keyboard and start sending data to it
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether starting was successful or not</returns>
|
||||||
|
public bool Start(EffectModel effect = null)
|
||||||
{
|
{
|
||||||
if (_restarting)
|
Logger.Debug("Starting MainManager");
|
||||||
return;
|
// Can't take control when not enabled
|
||||||
|
if (!ProgramEnabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
Logger.Debug("Restarting MainManager");
|
// Do nothing if already running
|
||||||
if (!Running)
|
if (Running)
|
||||||
{
|
return true;
|
||||||
Start();
|
|
||||||
return;
|
// Only continue if a keyboard was loaded
|
||||||
|
KeyboardManager.EnableLastKeyboard();
|
||||||
|
if (KeyboardManager.ActiveKeyboard == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Running = true;
|
||||||
|
if (effect != null)
|
||||||
|
EffectManager.ChangeEffect(effect);
|
||||||
|
|
||||||
|
LoopManager.Start();
|
||||||
|
|
||||||
|
return Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
_restarting = true;
|
/// <summary>
|
||||||
Stop();
|
/// Releases control of the keyboard and stop sending data to it
|
||||||
|
/// </summary>
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
if (!Running)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Logger.Debug("Stopping MainManager");
|
||||||
|
|
||||||
|
LoopManager.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -198,7 +137,7 @@ namespace Artemis.Managers
|
|||||||
{
|
{
|
||||||
Logger.Debug("Enabling program");
|
Logger.Debug("Enabling program");
|
||||||
ProgramEnabled = true;
|
ProgramEnabled = true;
|
||||||
Start(_effectManager.GetLastEffect());
|
Start(EffectManager.GetLastEffect());
|
||||||
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,88 +152,6 @@ namespace Artemis.Managers
|
|||||||
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Workers
|
|
||||||
|
|
||||||
private void UpdateWorker_DoWork(object sender, DoWorkEventArgs e)
|
|
||||||
{
|
|
||||||
var sw = new Stopwatch();
|
|
||||||
while (!UpdateWorker.CancellationPending)
|
|
||||||
{
|
|
||||||
// Skip frame when paused
|
|
||||||
if (_paused)
|
|
||||||
{
|
|
||||||
PauseCallback?.Invoke();
|
|
||||||
Thread.Sleep(1000/_fps);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop if no keyboard/effect are present
|
|
||||||
if (_keyboardManager.ActiveKeyboard == null || _effectManager.ActiveEffect == null)
|
|
||||||
{
|
|
||||||
Thread.Sleep(1000/_fps);
|
|
||||||
Logger.Debug("No active effect/keyboard, stopping");
|
|
||||||
|
|
||||||
if (_effectManager.PauseEffect != null)
|
|
||||||
{
|
|
||||||
PauseCallback?.Invoke();
|
|
||||||
Thread.Sleep(1000/_fps);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Stop();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't stop when the effect is still initialized, just skip this frame
|
|
||||||
if (!_effectManager.ActiveEffect.Initialized)
|
|
||||||
{
|
|
||||||
Thread.Sleep(1000/_fps);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.Start();
|
|
||||||
|
|
||||||
// Update the current effect
|
|
||||||
if (_effectManager.ActiveEffect.Initialized)
|
|
||||||
_effectManager.ActiveEffect.Update();
|
|
||||||
|
|
||||||
// Get ActiveEffect's bitmap
|
|
||||||
var bitmap = _effectManager.ActiveEffect.Initialized
|
|
||||||
? _effectManager.ActiveEffect.GenerateBitmap()
|
|
||||||
: null;
|
|
||||||
|
|
||||||
// Draw enabled overlays on top
|
|
||||||
foreach (var overlayModel in _effectManager.EnabledOverlays)
|
|
||||||
{
|
|
||||||
overlayModel.Update();
|
|
||||||
bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it exists, send bitmap to the device
|
|
||||||
if (bitmap != null && _keyboardManager.ActiveKeyboard != null)
|
|
||||||
{
|
|
||||||
_keyboardManager.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 BackgroundWorkerExceptionCatcher(object sender, RunWorkerCompletedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Error == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Logger.Error(e.Error, "Exception in the BackgroundWorker");
|
|
||||||
throw e.Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProcessWorker_DoWork(object sender, DoWorkEventArgs e)
|
private void ProcessWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
while (!ProcessWorker.CancellationPending)
|
while (!ProcessWorker.CancellationPending)
|
||||||
@ -308,28 +165,35 @@ namespace Artemis.Managers
|
|||||||
var runningProcesses = Process.GetProcesses();
|
var runningProcesses = Process.GetProcesses();
|
||||||
|
|
||||||
// If the currently active effect is a disabled game, get rid of it.
|
// If the currently active effect is a disabled game, get rid of it.
|
||||||
if (_effectManager.ActiveEffect != null)
|
if (EffectManager.ActiveEffect != null)
|
||||||
_effectManager.DisableInactiveGame();
|
EffectManager.DisableInactiveGame();
|
||||||
|
|
||||||
// If the currently active effect is a no longer running game, get rid of it.
|
// If the currently active effect is a no longer running game, get rid of it.
|
||||||
var activeGame = _effectManager.ActiveEffect as GameModel;
|
var activeGame = EffectManager.ActiveEffect as GameModel;
|
||||||
if (activeGame != null)
|
if (activeGame != null)
|
||||||
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
|
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
|
||||||
_effectManager.DisableGame(activeGame);
|
EffectManager.DisableGame(activeGame);
|
||||||
|
|
||||||
// Look for running games, stopping on the first one that's found.
|
// Look for running games, stopping on the first one that's found.
|
||||||
var newGame = _effectManager.EnabledGames
|
var newGame = EffectManager.EnabledGames
|
||||||
.FirstOrDefault(
|
.FirstOrDefault(
|
||||||
g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
|
g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
|
||||||
|
|
||||||
// If it's not already enabled, do so.
|
// If it's not already enabled, do so.
|
||||||
if (newGame != null && _effectManager.ActiveEffect != newGame)
|
if (newGame != null && EffectManager.ActiveEffect != newGame)
|
||||||
_effectManager.ChangeEffect(newGame);
|
EffectManager.ChangeEffect(newGame);
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
private void BackgroundWorkerExceptionCatcher(object sender, RunWorkerCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Error == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Logger.Error(e.Error, "Exception in the BackgroundWorker");
|
||||||
|
throw e.Error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,18 +7,13 @@ namespace Artemis.Models
|
|||||||
public abstract class EffectModel : IDisposable
|
public abstract class EffectModel : IDisposable
|
||||||
{
|
{
|
||||||
public delegate void SettingsUpdateHandler(EffectSettings settings);
|
public delegate void SettingsUpdateHandler(EffectSettings settings);
|
||||||
|
|
||||||
public bool Initialized;
|
public bool Initialized;
|
||||||
|
|
||||||
protected KeyboardManager KeyboardManager;
|
|
||||||
|
|
||||||
public MainManager MainManager;
|
public MainManager MainManager;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|
||||||
protected EffectModel(MainManager mainManager, KeyboardManager keyboardManager)
|
protected EffectModel(MainManager mainManager)
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
MainManager = mainManager;
|
||||||
KeyboardManager = keyboardManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
|
|||||||
@ -6,8 +6,7 @@ namespace Artemis.Models
|
|||||||
{
|
{
|
||||||
public abstract class GameModel : EffectModel
|
public abstract class GameModel : EffectModel
|
||||||
{
|
{
|
||||||
protected GameModel(MainManager mainManager, KeyboardManager keyboardManager, GameSettings settings)
|
protected GameModel(MainManager mainManager, GameSettings settings): base(mainManager)
|
||||||
: base(mainManager, keyboardManager)
|
|
||||||
{
|
{
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,7 @@ namespace Artemis.Models
|
|||||||
private bool _enabled;
|
private bool _enabled;
|
||||||
public string ProcessName;
|
public string ProcessName;
|
||||||
|
|
||||||
protected OverlayModel(MainManager mainManager, KeyboardManager keyboardManager)
|
protected OverlayModel(MainManager mainManager): base(mainManager)
|
||||||
: base(mainManager, keyboardManager)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,8 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
|||||||
private ScreenCapture _screenCapturer;
|
private ScreenCapture _screenCapturer;
|
||||||
private KeyboardRectangle _topRect;
|
private KeyboardRectangle _topRect;
|
||||||
|
|
||||||
public AmbientLightningEffectModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public AmbientLightningEffectModel(MainManager mainManager, AmbientLightningEffectSettings settings)
|
||||||
AmbientLightningEffectSettings settings) : base(mainManager, keyboardManager)
|
: base(mainManager)
|
||||||
{
|
{
|
||||||
Name = "Ambient Lightning";
|
Name = "Ambient Lightning";
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
@ -49,9 +49,9 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
|||||||
|
|
||||||
_colors = new List<Color>();
|
_colors = new List<Color>();
|
||||||
_screenCapturer = new ScreenCapture();
|
_screenCapturer = new ScreenCapture();
|
||||||
_topRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
_topRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||||
LinearGradientMode.Horizontal) {Height = KeyboardManager.ActiveKeyboard.Height*Scale/2};
|
LinearGradientMode.Horizontal) {Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale/2};
|
||||||
_botRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
_botRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||||
LinearGradientMode.Horizontal);
|
LinearGradientMode.Horizontal);
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
@ -102,8 +102,8 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Put the resulting colors in 6 rectangles, their size differs per keyboard
|
// Put the resulting colors in 6 rectangles, their size differs per keyboard
|
||||||
var rectWidth = KeyboardManager.ActiveKeyboard.Width/3*Scale;
|
var rectWidth = MainManager.KeyboardManager.ActiveKeyboard.Width/3*Scale;
|
||||||
var rectHeight = KeyboardManager.ActiveKeyboard.Height/2*Scale;
|
var rectHeight = MainManager.KeyboardManager.ActiveKeyboard.Height/2*Scale;
|
||||||
for (var row = 0; row < 2; row++)
|
for (var row = 0; row < 2; row++)
|
||||||
{
|
{
|
||||||
for (var column = 0; column < 3; column++)
|
for (var column = 0; column < 3; column++)
|
||||||
@ -116,7 +116,7 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|||||||
@ -7,16 +7,13 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
|||||||
{
|
{
|
||||||
public sealed class AmbientLightningEffectViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
public sealed class AmbientLightningEffectViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
||||||
{
|
{
|
||||||
public AmbientLightningEffectViewModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public AmbientLightningEffectViewModel(MainManager main, IEventAggregator events)
|
||||||
EffectManager effectManager, IEventAggregator events)
|
: base(main, new AmbientLightningEffectModel(main, new AmbientLightningEffectSettings()))
|
||||||
: base(
|
|
||||||
mainManager, effectManager,
|
|
||||||
new AmbientLightningEffectModel(mainManager, keyboardManager, new AmbientLightningEffectSettings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "Ambient Lightning";
|
DisplayName = "Ambient Lightning";
|
||||||
|
|
||||||
events.Subscribe(this);
|
events.Subscribe(this);
|
||||||
EffectManager.EffectModels.Add(EffectModel);
|
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(ActiveEffectChanged message)
|
public void Handle(ActiveEffectChanged message)
|
||||||
|
|||||||
@ -22,8 +22,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
private int _sensitivity;
|
private int _sensitivity;
|
||||||
private IWaveIn _waveIn;
|
private IWaveIn _waveIn;
|
||||||
|
|
||||||
public AudioVisualizerModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager)
|
||||||
AudioVisualizerSettings settings) : base(mainManager, keyboardManager)
|
|
||||||
{
|
{
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Name = "Audiovisualizer";
|
Name = "Audiovisualizer";
|
||||||
@ -58,7 +57,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
Lines = KeyboardManager.ActiveKeyboard.Width;
|
Lines = MainManager.KeyboardManager.ActiveKeyboard.Width;
|
||||||
|
|
||||||
// TODO: Device selection
|
// TODO: Device selection
|
||||||
SelectedDeviceId = new MMDeviceEnumerator()
|
SelectedDeviceId = new MMDeviceEnumerator()
|
||||||
@ -70,7 +69,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
for (var i = 0; i < Lines; i++)
|
for (var i = 0; i < Lines; i++)
|
||||||
{
|
{
|
||||||
SoundRectangles.Add(new KeyboardRectangle(
|
SoundRectangles.Add(new KeyboardRectangle(
|
||||||
KeyboardManager.ActiveKeyboard,
|
MainManager.KeyboardManager.ActiveKeyboard,
|
||||||
0, 0, new List<Color>
|
0, 0, new List<Color>
|
||||||
{
|
{
|
||||||
ColorHelpers.ToDrawingColor(Settings.TopColor),
|
ColorHelpers.ToDrawingColor(Settings.TopColor),
|
||||||
@ -122,7 +121,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
// Apply Sensitivity setting
|
// Apply Sensitivity setting
|
||||||
height = height*_sensitivity;
|
height = height*_sensitivity;
|
||||||
var keyboardHeight =
|
var keyboardHeight =
|
||||||
(int) Math.Round(KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale);
|
(int) Math.Round(MainManager.KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale);
|
||||||
if (keyboardHeight > SoundRectangles[i].Height)
|
if (keyboardHeight > SoundRectangles[i].Height)
|
||||||
SoundRectangles[i].Height = keyboardHeight;
|
SoundRectangles[i].Height = keyboardHeight;
|
||||||
else
|
else
|
||||||
@ -132,7 +131,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
SoundRectangles[i].Width = Scale;
|
SoundRectangles[i].Width = Scale;
|
||||||
|
|
||||||
if (_fromBottom)
|
if (_fromBottom)
|
||||||
SoundRectangles[i].Y = KeyboardManager.ActiveKeyboard.Height*Scale -
|
SoundRectangles[i].Y = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale -
|
||||||
SoundRectangles[i].Height;
|
SoundRectangles[i].Height;
|
||||||
}
|
}
|
||||||
_generating = false;
|
_generating = false;
|
||||||
@ -146,7 +145,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
// Lock the _spectrumData array while busy with it
|
// Lock the _spectrumData array while busy with it
|
||||||
_generating = true;
|
_generating = true;
|
||||||
|
|
||||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
foreach (var soundRectangle in SoundRectangles)
|
foreach (var soundRectangle in SoundRectangles)
|
||||||
|
|||||||
@ -7,16 +7,13 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
{
|
{
|
||||||
public sealed class AudioVisualizerViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
public sealed class AudioVisualizerViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
||||||
{
|
{
|
||||||
public AudioVisualizerViewModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public AudioVisualizerViewModel(MainManager main, IEventAggregator events)
|
||||||
EffectManager effectManager, IEventAggregator events)
|
: base(main, new AudioVisualizerModel(main, new AudioVisualizerSettings()))
|
||||||
: base(
|
|
||||||
mainManager, effectManager,
|
|
||||||
new AudioVisualizerModel(mainManager, keyboardManager, new AudioVisualizerSettings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "Audio Visualization";
|
DisplayName = "Audio Visualization";
|
||||||
|
|
||||||
events.Subscribe(this);
|
events.Subscribe(this);
|
||||||
EffectManager.EffectModels.Add(EffectModel);
|
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(ActiveEffectChanged message)
|
public void Handle(ActiveEffectChanged message)
|
||||||
|
|||||||
@ -10,8 +10,7 @@ namespace Artemis.Modules.Effects.Debug
|
|||||||
// TODO: Remove
|
// TODO: Remove
|
||||||
internal class DebugEffectModel : EffectModel
|
internal class DebugEffectModel : EffectModel
|
||||||
{
|
{
|
||||||
public DebugEffectModel(MainManager mainManager, KeyboardManager keyboardManager, DebugEffectSettings settings)
|
public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager)
|
||||||
: base(mainManager, keyboardManager)
|
|
||||||
{
|
{
|
||||||
Name = "Debug Effect";
|
Name = "Debug Effect";
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
@ -34,7 +33,7 @@ namespace Artemis.Modules.Effects.Debug
|
|||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
KeyboardRectangle = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
|
KeyboardRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
|
||||||
{
|
{
|
||||||
Color.Red,
|
Color.Red,
|
||||||
Color.OrangeRed,
|
Color.OrangeRed,
|
||||||
|
|||||||
@ -14,16 +14,13 @@ namespace Artemis.Modules.Effects.Debug
|
|||||||
private ImageSource _imageSource;
|
private ImageSource _imageSource;
|
||||||
private string _selectedRectangleType;
|
private string _selectedRectangleType;
|
||||||
|
|
||||||
public DebugEffectViewModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public DebugEffectViewModel(MainManager main, IEventAggregator events)
|
||||||
EffectManager effectManager, IEventAggregator events)
|
: base(main, new DebugEffectModel(main, new DebugEffectSettings()))
|
||||||
: base(
|
|
||||||
mainManager, effectManager,
|
|
||||||
new DebugEffectModel(mainManager, keyboardManager, new DebugEffectSettings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "Debug Effect";
|
DisplayName = "Debug Effect";
|
||||||
|
|
||||||
events.Subscribe(this);
|
events.Subscribe(this);
|
||||||
EffectManager.EffectModels.Add(EffectModel);
|
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BindableCollection<string> RectangleTypes
|
public BindableCollection<string> RectangleTypes
|
||||||
|
|||||||
@ -10,8 +10,7 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
|||||||
{
|
{
|
||||||
private readonly ProfilePreviewDataModel _previewDataModel;
|
private readonly ProfilePreviewDataModel _previewDataModel;
|
||||||
|
|
||||||
public ProfilePreviewModel(MainManager mainManager, KeyboardManager keyboardManager)
|
public ProfilePreviewModel(MainManager main) : base(main)
|
||||||
: base(mainManager, keyboardManager)
|
|
||||||
{
|
{
|
||||||
Name = "Profile Preview";
|
Name = "Profile Preview";
|
||||||
_previewDataModel = new ProfilePreviewDataModel();
|
_previewDataModel = new ProfilePreviewDataModel();
|
||||||
@ -41,12 +40,12 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(4);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4);
|
||||||
|
|
||||||
if (SelectedProfile == null)
|
if (SelectedProfile == null)
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
|
||||||
var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(4);
|
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(4);
|
||||||
var image = SelectedProfile.GenerateBitmap<ProfilePreviewDataModel>(keyboardRect, _previewDataModel, true);
|
var image = SelectedProfile.GenerateBitmap<ProfilePreviewDataModel>(keyboardRect, _previewDataModel, true);
|
||||||
|
|
||||||
// Draw on top of everything else
|
// Draw on top of everything else
|
||||||
|
|||||||
@ -16,8 +16,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
private readonly List<Wave> _waves;
|
private readonly List<Wave> _waves;
|
||||||
private Color _randomColor;
|
private Color _randomColor;
|
||||||
|
|
||||||
public TypeWaveModel(MainManager mainManager, KeyboardManager keyboardManager, TypeWaveSettings settings)
|
public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager)
|
||||||
: base(mainManager, keyboardManager)
|
|
||||||
{
|
{
|
||||||
Name = "TypeWave";
|
Name = "TypeWave";
|
||||||
_waves = new List<Wave>();
|
_waves = new List<Wave>();
|
||||||
@ -97,7 +96,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
if (_waves.Count == 0)
|
if (_waves.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
g.Clear(Color.Transparent);
|
g.Clear(Color.Transparent);
|
||||||
@ -114,7 +113,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
_waves[i].Size, _waves[i].Size);
|
_waves[i].Size, _waves[i].Size);
|
||||||
|
|
||||||
Color fillColor;
|
Color fillColor;
|
||||||
if (KeyboardManager.ActiveKeyboard is CorsairRGB)
|
if (MainManager.KeyboardManager.ActiveKeyboard is CorsairRGB)
|
||||||
fillColor = Color.Black;
|
fillColor = Color.Black;
|
||||||
else
|
else
|
||||||
fillColor = Color.Transparent;
|
fillColor = Color.Transparent;
|
||||||
|
|||||||
@ -7,14 +7,13 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
{
|
{
|
||||||
public sealed class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
public sealed class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
||||||
{
|
{
|
||||||
public TypeWaveViewModel(MainManager mainManager, KeyboardManager keyboardManager, EffectManager effectManager,
|
public TypeWaveViewModel(MainManager main, IEventAggregator events)
|
||||||
IEventAggregator events)
|
: base(main, new TypeWaveModel(main, new TypeWaveSettings()))
|
||||||
: base(mainManager, effectManager, new TypeWaveModel(mainManager, keyboardManager, new TypeWaveSettings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "Type Waves";
|
DisplayName = "Type Waves";
|
||||||
|
|
||||||
events.Subscribe(this);
|
events.Subscribe(this);
|
||||||
EffectManager.EffectModels.Add(EffectModel);
|
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(ActiveEffectChanged message)
|
public void Handle(ActiveEffectChanged message)
|
||||||
|
|||||||
@ -8,8 +8,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
{
|
{
|
||||||
public class CounterStrikeModel : GameModel
|
public class CounterStrikeModel : GameModel
|
||||||
{
|
{
|
||||||
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings,
|
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings)
|
||||||
KeyboardManager keyboardManager) : base(mainManager, keyboardManager, settings)
|
|
||||||
{
|
{
|
||||||
Name = "CounterStrike";
|
Name = "CounterStrike";
|
||||||
ProcessName = "csgo";
|
ProcessName = "csgo";
|
||||||
@ -50,7 +49,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
if (Profile == null || GameDataModel == null)
|
if (Profile == null || GameDataModel == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
||||||
return Profile.GenerateBitmap<CounterStrikeDataModel>(keyboardRect, GameDataModel);
|
return Profile.GenerateBitmap<CounterStrikeDataModel>(keyboardRect, GameDataModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,16 +8,13 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
{
|
{
|
||||||
public sealed class CounterStrikeViewModel : GameViewModel<CounterStrikeDataModel>
|
public sealed class CounterStrikeViewModel : GameViewModel<CounterStrikeDataModel>
|
||||||
{
|
{
|
||||||
public CounterStrikeViewModel(MainManager mainManager, EffectManager effectManager,
|
public CounterStrikeViewModel(MainManager main)
|
||||||
KeyboardManager keyboardManager)
|
: base(main, new CounterStrikeModel(main, new CounterStrikeSettings()))
|
||||||
: base(
|
|
||||||
mainManager, effectManager,
|
|
||||||
new CounterStrikeModel(mainManager, new CounterStrikeSettings(), keyboardManager))
|
|
||||||
{
|
{
|
||||||
DisplayName = "CS:GO";
|
DisplayName = "CS:GO";
|
||||||
|
|
||||||
// Create effect model and add it to MainManager
|
// Create effect model and add it to MainManager
|
||||||
EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
PlaceConfigFile();
|
PlaceConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,15 +15,12 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
{
|
{
|
||||||
internal class Dota2Model : GameModel
|
internal class Dota2Model : GameModel
|
||||||
{
|
{
|
||||||
private readonly KeyboardManager _keyboardManager;
|
|
||||||
private KeyboardRegion _abilityKeys;
|
private KeyboardRegion _abilityKeys;
|
||||||
private KeyboardRegion _keyPad;
|
private KeyboardRegion _keyPad;
|
||||||
private KeyboardRegion _topRow;
|
private KeyboardRegion _topRow;
|
||||||
|
|
||||||
public Dota2Model(MainManager mainManager, KeyboardManager keyboardManager, Dota2Settings settings)
|
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager, settings)
|
||||||
: base(mainManager, keyboardManager, settings)
|
|
||||||
{
|
{
|
||||||
_keyboardManager = keyboardManager;
|
|
||||||
Name = "Dota2";
|
Name = "Dota2";
|
||||||
ProcessName = "dota2";
|
ProcessName = "dota2";
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
@ -43,35 +40,35 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
_topRow = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
|
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
|
||||||
_keyPad = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
|
_keyPad = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
|
||||||
_abilityKeys = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "QWER");
|
_abilityKeys = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "QWER");
|
||||||
HealthRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
|
HealthRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||||
, 0
|
, 0
|
||||||
, _topRow.BottomRight.Y*Scale
|
, _topRow.BottomRight.Y*Scale
|
||||||
, new List<Color>()
|
, new List<Color>()
|
||||||
, LinearGradientMode.Horizontal)
|
, LinearGradientMode.Horizontal)
|
||||||
{Height = Scale, ContainedBrush = false};
|
{Height = Scale, ContainedBrush = false};
|
||||||
|
|
||||||
ManaRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
|
ManaRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||||
, 0
|
, 0
|
||||||
, (_topRow.BottomRight.Y + 1)*Scale
|
, (_topRow.BottomRight.Y + 1)*Scale
|
||||||
, new List<Color>()
|
, new List<Color>()
|
||||||
, LinearGradientMode.Horizontal)
|
, LinearGradientMode.Horizontal)
|
||||||
{Height = Scale, ContainedBrush = false};
|
{Height = Scale, ContainedBrush = false};
|
||||||
|
|
||||||
EventRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
|
EventRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||||
, 0
|
, 0
|
||||||
, _topRow.TopLeft.X + 3
|
, _topRow.TopLeft.X + 3
|
||||||
, new List<Color>()
|
, new List<Color>()
|
||||||
, LinearGradientMode.Horizontal)
|
, LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
Height = _keyboardManager.ActiveKeyboard.Height*Scale - Scale
|
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
|
||||||
,
|
,
|
||||||
Width = _keyboardManager.ActiveKeyboard.Width*Scale - Scale - 12
|
Width = MainManager.KeyboardManager.ActiveKeyboard.Width*Scale - Scale - 12
|
||||||
};
|
};
|
||||||
|
|
||||||
DayCycleRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
|
DayCycleRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||||
, _keyPad.TopLeft.X*Scale
|
, _keyPad.TopLeft.X*Scale
|
||||||
, _keyPad.TopLeft.Y*Scale
|
, _keyPad.TopLeft.Y*Scale
|
||||||
, new List<Color>()
|
, new List<Color>()
|
||||||
@ -99,7 +96,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
case "3": //League of Legends
|
case "3": //League of Legends
|
||||||
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
|
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
|
||||||
{
|
{
|
||||||
AbilityKeysRectangles[i] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||||
(_abilityKeys.TopLeft.X + i)*Scale - 2,
|
(_abilityKeys.TopLeft.X + i)*Scale - 2,
|
||||||
_abilityKeys.TopLeft.Y*Scale,
|
_abilityKeys.TopLeft.Y*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
@ -111,7 +108,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
AbilityKeysRectangles[0] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
AbilityKeysRectangles[0] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||||
_abilityKeys.TopLeft.X*Scale - 2,
|
_abilityKeys.TopLeft.X*Scale - 2,
|
||||||
_abilityKeys.TopLeft.Y*Scale,
|
_abilityKeys.TopLeft.Y*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
@ -120,7 +117,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
Height = Scale,
|
Height = Scale,
|
||||||
Width = Scale
|
Width = Scale
|
||||||
};
|
};
|
||||||
AbilityKeysRectangles[1] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
AbilityKeysRectangles[1] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||||
(_abilityKeys.TopLeft.X + 2)*Scale - 2,
|
(_abilityKeys.TopLeft.X + 2)*Scale - 2,
|
||||||
_abilityKeys.TopLeft.Y*Scale,
|
_abilityKeys.TopLeft.Y*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
@ -129,7 +126,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
Height = Scale,
|
Height = Scale,
|
||||||
Width = Scale
|
Width = Scale
|
||||||
};
|
};
|
||||||
AbilityKeysRectangles[2] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
AbilityKeysRectangles[2] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||||
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
|
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
|
||||||
_abilityKeys.TopLeft.Y*Scale,
|
_abilityKeys.TopLeft.Y*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
@ -138,7 +135,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
Height = Scale,
|
Height = Scale,
|
||||||
Width = Scale
|
Width = Scale
|
||||||
};
|
};
|
||||||
AbilityKeysRectangles[3] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
AbilityKeysRectangles[3] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||||
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
|
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
|
||||||
(_abilityKeys.TopLeft.Y + 1)*Scale,
|
(_abilityKeys.TopLeft.Y + 1)*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
@ -152,7 +149,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
case "5": //Smite
|
case "5": //Smite
|
||||||
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
|
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
|
||||||
{
|
{
|
||||||
AbilityKeysRectangles[i] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||||
(_abilityKeys.TopLeft.X + i)*Scale - 3,
|
(_abilityKeys.TopLeft.X + i)*Scale - 3,
|
||||||
(_abilityKeys.TopLeft.Y - 1)*Scale,
|
(_abilityKeys.TopLeft.Y - 1)*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
@ -297,7 +294,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = _keyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
|
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,12 +9,11 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
{
|
{
|
||||||
public sealed class Dota2ViewModel : GameViewModel<Dota2DataModel>
|
public sealed class Dota2ViewModel : GameViewModel<Dota2DataModel>
|
||||||
{
|
{
|
||||||
public Dota2ViewModel(MainManager mainManager, EffectManager effectManager, KeyboardManager keyboardManager)
|
public Dota2ViewModel(MainManager main) : base(main, new Dota2Model(main, new Dota2Settings()))
|
||||||
: base(mainManager, effectManager, new Dota2Model(mainManager, keyboardManager, new Dota2Settings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "Dota 2";
|
DisplayName = "Dota 2";
|
||||||
|
|
||||||
EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
PlaceConfigFile();
|
PlaceConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
private Memory _memory;
|
private Memory _memory;
|
||||||
private GamePointersCollection _pointer;
|
private GamePointersCollection _pointer;
|
||||||
|
|
||||||
public RocketLeagueModel(MainManager mainManager, KeyboardManager keyboardManager, RocketLeagueSettings settings)
|
public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager, settings)
|
||||||
: base(mainManager, keyboardManager, settings)
|
|
||||||
{
|
{
|
||||||
Name = "RocketLeague";
|
Name = "RocketLeague";
|
||||||
ProcessName = "RocketLeague";
|
ProcessName = "RocketLeague";
|
||||||
@ -73,7 +72,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
if (Profile == null || GameDataModel == null)
|
if (Profile == null || GameDataModel == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
||||||
return Profile.GenerateBitmap<RocketLeagueDataModel>(keyboardRect, GameDataModel);
|
return Profile.GenerateBitmap<RocketLeagueDataModel>(keyboardRect, GameDataModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,15 +11,12 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
{
|
{
|
||||||
private string _versionText;
|
private string _versionText;
|
||||||
|
|
||||||
public RocketLeagueViewModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public RocketLeagueViewModel(MainManager main)
|
||||||
EffectManager effectManager)
|
: base(main, new RocketLeagueModel(main, new RocketLeagueSettings()))
|
||||||
: base(
|
|
||||||
mainManager, effectManager,
|
|
||||||
new RocketLeagueModel(mainManager, keyboardManager, new RocketLeagueSettings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "Rocket League";
|
DisplayName = "Rocket League";
|
||||||
|
|
||||||
EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
SetVersionText();
|
SetVersionText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
{
|
{
|
||||||
public class TheDivisionModel : GameModel
|
public class TheDivisionModel : GameModel
|
||||||
{
|
{
|
||||||
private readonly KeyboardManager _keyboardManager;
|
|
||||||
private Wave _ammoWave;
|
private Wave _ammoWave;
|
||||||
private TheDivisionDataModel _dataModel;
|
private TheDivisionDataModel _dataModel;
|
||||||
private KeyboardRectangle _hpRect;
|
private KeyboardRectangle _hpRect;
|
||||||
@ -23,10 +22,8 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
private StickyValue<bool> _stickyHp;
|
private StickyValue<bool> _stickyHp;
|
||||||
private int _trans;
|
private int _trans;
|
||||||
|
|
||||||
public TheDivisionModel(MainManager mainManager, KeyboardManager keyboardManager, TheDivisionSettings settings)
|
public TheDivisionModel(MainManager mainManager, TheDivisionSettings settings) : base(mainManager, settings)
|
||||||
: base(mainManager, keyboardManager, settings)
|
|
||||||
{
|
{
|
||||||
_keyboardManager = keyboardManager;
|
|
||||||
Name = "TheDivision";
|
Name = "TheDivision";
|
||||||
ProcessName = "TheDivision";
|
ProcessName = "TheDivision";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
@ -50,7 +47,7 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
_ammoWave = new Wave(new Point(30, 14), 0, Color.Transparent);
|
_ammoWave = new Wave(new Point(30, 14), 0, Color.Transparent);
|
||||||
_hpRect = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 3*Scale, 0*Scale,
|
_hpRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 3*Scale, 0*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -60,7 +57,7 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
ContainedBrush = false
|
ContainedBrush = false
|
||||||
};
|
};
|
||||||
|
|
||||||
_p2 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 1*Scale,
|
_p2 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 1*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -69,7 +66,7 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
Rotate = true,
|
Rotate = true,
|
||||||
ContainedBrush = false
|
ContainedBrush = false
|
||||||
};
|
};
|
||||||
_p3 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 3*Scale,
|
_p3 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 3*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -78,7 +75,7 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
Rotate = true,
|
Rotate = true,
|
||||||
ContainedBrush = false
|
ContainedBrush = false
|
||||||
};
|
};
|
||||||
_p4 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 5*Scale,
|
_p4 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 5*Scale,
|
||||||
new List<Color>(),
|
new List<Color>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -207,7 +204,7 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = _keyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
g.Clear(Color.Transparent);
|
g.Clear(Color.Transparent);
|
||||||
|
|||||||
@ -5,14 +5,11 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
{
|
{
|
||||||
public sealed class TheDivisionViewModel : GameViewModel<TheDivisionDataModel>
|
public sealed class TheDivisionViewModel : GameViewModel<TheDivisionDataModel>
|
||||||
{
|
{
|
||||||
public TheDivisionViewModel(MainManager mainManager, EffectManager effectManager,
|
public TheDivisionViewModel(MainManager main)
|
||||||
KeyboardManager keyboardManager)
|
: base(main, new TheDivisionModel(main, new TheDivisionSettings()))
|
||||||
: base(
|
|
||||||
mainManager, effectManager,
|
|
||||||
new TheDivisionModel(mainManager, keyboardManager, new TheDivisionSettings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "The Division";
|
DisplayName = "The Division";
|
||||||
EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,8 +18,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
private KeyboardRectangle _signRect;
|
private KeyboardRectangle _signRect;
|
||||||
private string _witcherSettings;
|
private string _witcherSettings;
|
||||||
|
|
||||||
public Witcher3Model(MainManager mainManager, KeyboardManager keyboardManager, Witcher3Settings settings)
|
public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager, settings)
|
||||||
: base(mainManager, keyboardManager, settings)
|
|
||||||
{
|
{
|
||||||
Name = "Witcher3";
|
Name = "Witcher3";
|
||||||
ProcessName = "witcher3";
|
ProcessName = "witcher3";
|
||||||
@ -45,7 +44,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
_signRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
_signRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
Rotate = true,
|
Rotate = true,
|
||||||
@ -107,7 +106,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
g.Clear(Color.Transparent);
|
g.Clear(Color.Transparent);
|
||||||
|
|||||||
@ -12,11 +12,10 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
{
|
{
|
||||||
public sealed class Witcher3ViewModel : GameViewModel<Witcher3DataModel>
|
public sealed class Witcher3ViewModel : GameViewModel<Witcher3DataModel>
|
||||||
{
|
{
|
||||||
public Witcher3ViewModel(MainManager mainManager, KeyboardManager keyboardManager, EffectManager effectManager)
|
public Witcher3ViewModel(MainManager main) : base(main, new Witcher3Model(main, new Witcher3Settings()))
|
||||||
: base(mainManager, effectManager, new Witcher3Model(mainManager, keyboardManager, new Witcher3Settings()))
|
|
||||||
{
|
{
|
||||||
DisplayName = "The Witcher 3";
|
DisplayName = "The Witcher 3";
|
||||||
EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Name => "The Witcher 3";
|
public static string Name => "The Witcher 3";
|
||||||
|
|||||||
@ -9,14 +9,13 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
{
|
{
|
||||||
public class VolumeDisplayModel : OverlayModel
|
public class VolumeDisplayModel : OverlayModel
|
||||||
{
|
{
|
||||||
public VolumeDisplayModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public VolumeDisplayModel(MainManager mainManager, VolumeDisplaySettings settings) : base(mainManager)
|
||||||
VolumeDisplaySettings settings) : base(mainManager, keyboardManager)
|
|
||||||
{
|
{
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Name = "VolumeDisplay";
|
Name = "VolumeDisplay";
|
||||||
Enabled = Settings.Enabled;
|
Enabled = Settings.Enabled;
|
||||||
|
|
||||||
VolumeDisplay = new VolumeBar(keyboardManager, settings);
|
VolumeDisplay = new VolumeBar(MainManager.KeyboardManager, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VolumeBar VolumeDisplay { get; set; }
|
public VolumeBar VolumeDisplay { get; set; }
|
||||||
@ -64,7 +63,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
return GenerateBitmap(KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
|
return GenerateBitmap(MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Bitmap GenerateBitmap(Bitmap bitmap)
|
public override Bitmap GenerateBitmap(Bitmap bitmap)
|
||||||
|
|||||||
@ -5,9 +5,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
{
|
{
|
||||||
public sealed class VolumeDisplayViewModel : OverlayViewModel
|
public sealed class VolumeDisplayViewModel : OverlayViewModel
|
||||||
{
|
{
|
||||||
public VolumeDisplayViewModel(MainManager mainManager, KeyboardManager keyboardManager,
|
public VolumeDisplayViewModel(MainManager mainManager): base(mainManager)
|
||||||
EffectManager effectManager)
|
|
||||||
: base(mainManager, effectManager)
|
|
||||||
{
|
{
|
||||||
DisplayName = "Volume Display";
|
DisplayName = "Volume Display";
|
||||||
|
|
||||||
@ -15,8 +13,8 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
OverlaySettings = new VolumeDisplaySettings();
|
OverlaySettings = new VolumeDisplaySettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainManager
|
// Create effect model and add it to MainManager
|
||||||
OverlayModel = new VolumeDisplayModel(mainManager, keyboardManager, (VolumeDisplaySettings) OverlaySettings);
|
OverlayModel = new VolumeDisplayModel(mainManager, (VolumeDisplaySettings) OverlaySettings);
|
||||||
EffectManager.EffectModels.Add(OverlayModel);
|
MainManager.EffectManager.EffectModels.Add(OverlayModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,13 +9,11 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
protected readonly EffectModel EffectModel;
|
protected readonly EffectModel EffectModel;
|
||||||
private EffectSettings _effectSettings;
|
private EffectSettings _effectSettings;
|
||||||
private bool _showDisabledPopup;
|
private bool _showDisabledPopup;
|
||||||
protected EffectManager EffectManager;
|
|
||||||
protected MainManager MainManager;
|
protected MainManager MainManager;
|
||||||
|
|
||||||
protected EffectViewModel(MainManager mainManager, EffectManager effectManager, EffectModel effectModel)
|
protected EffectViewModel(MainManager mainManager, EffectModel effectModel)
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
MainManager = mainManager;
|
||||||
EffectManager = effectManager;
|
|
||||||
EffectModel = effectModel;
|
EffectModel = effectModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +28,7 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EffectEnabled => EffectManager.ActiveEffect == EffectModel;
|
public bool EffectEnabled => MainManager.EffectManager.ActiveEffect == EffectModel;
|
||||||
|
|
||||||
public bool ShowDisabledPopup
|
public bool ShowDisabledPopup
|
||||||
{
|
{
|
||||||
@ -53,9 +51,9 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (EffectEnabled)
|
if (EffectEnabled)
|
||||||
EffectManager.ClearEffect();
|
MainManager.EffectManager.ClearEffect();
|
||||||
else
|
else
|
||||||
EffectManager.ChangeEffect(EffectModel);
|
MainManager.EffectManager.ChangeEffect(EffectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveSettings()
|
public void SaveSettings()
|
||||||
@ -65,7 +63,7 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Restart the effect if it's currently running to apply settings.
|
// Restart the effect if it's currently running to apply settings.
|
||||||
EffectManager.ChangeEffect(EffectModel, true);
|
MainManager.EffectManager.ChangeEffect(EffectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ResetSettings()
|
public async void ResetSettings()
|
||||||
|
|||||||
@ -15,12 +15,10 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
private bool _editorShown;
|
private bool _editorShown;
|
||||||
private GameSettings _gameSettings;
|
private GameSettings _gameSettings;
|
||||||
private EffectModel _lastEffect;
|
private EffectModel _lastEffect;
|
||||||
protected EffectManager EffectManager;
|
|
||||||
|
|
||||||
protected GameViewModel(MainManager mainManager, EffectManager effectManager, GameModel gameModel)
|
protected GameViewModel(MainManager mainManager, GameModel gameModel)
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
MainManager = mainManager;
|
||||||
EffectManager = effectManager;
|
|
||||||
GameModel = gameModel;
|
GameModel = gameModel;
|
||||||
GameSettings = gameModel.Settings;
|
GameSettings = gameModel.Settings;
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GameEnabled => EffectManager.ActiveEffect == GameModel;
|
public bool GameEnabled => MainManager.EffectManager.ActiveEffect == GameModel;
|
||||||
|
|
||||||
public void ToggleEffect()
|
public void ToggleEffect()
|
||||||
{
|
{
|
||||||
@ -59,7 +57,7 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Restart the game if it's currently running to apply settings.
|
// Restart the game if it's currently running to apply settings.
|
||||||
EffectManager.ChangeEffect(GameModel, true);
|
MainManager.EffectManager.ChangeEffect(GameModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ResetSettings()
|
public async void ResetSettings()
|
||||||
@ -109,11 +107,11 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
// Store the current effect so it can be restored later
|
// Store the current effect so it can be restored later
|
||||||
if (!(EffectManager.ActiveEffect is ProfilePreviewModel))
|
if (!(MainManager.EffectManager.ActiveEffect is ProfilePreviewModel))
|
||||||
_lastEffect = EffectManager.ActiveEffect;
|
_lastEffect = MainManager.EffectManager.ActiveEffect;
|
||||||
|
|
||||||
EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||||
EffectManager.ChangeEffect(EffectManager.ProfilePreviewModel);
|
MainManager.EffectManager.ChangeEffect(MainManager.EffectManager.ProfilePreviewModel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -123,12 +121,12 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
var gameModel = _lastEffect as GameModel;
|
var gameModel = _lastEffect as GameModel;
|
||||||
if (gameModel != null)
|
if (gameModel != null)
|
||||||
if (!gameModel.Enabled)
|
if (!gameModel.Enabled)
|
||||||
EffectManager.GetLastEffect();
|
MainManager.EffectManager.GetLastEffect();
|
||||||
else
|
else
|
||||||
EffectManager.ChangeEffect(_lastEffect, true);
|
MainManager.EffectManager.ChangeEffect(_lastEffect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
EffectManager.ClearEffect();
|
MainManager.EffectManager.ClearEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
_editorShown = enable;
|
_editorShown = enable;
|
||||||
@ -140,7 +138,7 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
GameModel.Profile = ProfileEditor.SelectedProfile;
|
||||||
EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,13 +6,11 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
{
|
{
|
||||||
public abstract class OverlayViewModel : Screen
|
public abstract class OverlayViewModel : Screen
|
||||||
{
|
{
|
||||||
protected readonly EffectManager EffectManager;
|
|
||||||
protected readonly MainManager MainManager;
|
protected readonly MainManager MainManager;
|
||||||
private OverlaySettings _overlaySettings;
|
private OverlaySettings _overlaySettings;
|
||||||
|
|
||||||
protected OverlayViewModel(MainManager mainManager, EffectManager effectManager)
|
protected OverlayViewModel(MainManager mainManager)
|
||||||
{
|
{
|
||||||
EffectManager = effectManager;
|
|
||||||
MainManager = mainManager;
|
MainManager = mainManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
if (value == null)
|
if (value == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_keyboardManager.ChangeKeyboard(
|
_keyboardManager.EnableKeyboard(
|
||||||
_keyboardManager.KeyboardProviders.FirstOrDefault(
|
_keyboardManager.KeyboardProviders.FirstOrDefault(
|
||||||
k => k.Name == _selectedKeyboardProvider));
|
k => k.Name == _selectedKeyboardProvider));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ namespace Artemis.ViewModels
|
|||||||
|
|
||||||
public void ExitApplication()
|
public void ExitApplication()
|
||||||
{
|
{
|
||||||
MainManager.Shutdown();
|
MainManager.Dispose();
|
||||||
Application.Current.Shutdown();
|
Application.Current.Shutdown();
|
||||||
|
|
||||||
// Sometimes you need to be rough.
|
// Sometimes you need to be rough.
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Caliburn.Micro" version="3.0.1" targetFramework="net452" />
|
<package id="Caliburn.Micro" version="3.0.1" targetFramework="net452" />
|
||||||
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />
|
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />
|
||||||
@ -14,6 +13,8 @@
|
|||||||
<package id="NAudio" version="1.7.3" targetFramework="net452" />
|
<package id="NAudio" version="1.7.3" targetFramework="net452" />
|
||||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
|
||||||
<package id="Ninject" version="3.2.2.0" targetFramework="net452" />
|
<package id="Ninject" version="3.2.2.0" targetFramework="net452" />
|
||||||
|
<package id="Ninject.Extensions.Logging" version="3.2.3.0" targetFramework="net452" />
|
||||||
|
<package id="Ninject.Extensions.Logging.nlog4" version="3.2.3.0" targetFramework="net452" />
|
||||||
<package id="NLog" version="4.3.3" targetFramework="net452" />
|
<package id="NLog" version="4.3.3" targetFramework="net452" />
|
||||||
<package id="NLog.Config" version="4.3.3" targetFramework="net452" />
|
<package id="NLog.Config" version="4.3.3" targetFramework="net452" />
|
||||||
<package id="NLog.Schema" version="4.3.0" targetFramework="net452" />
|
<package id="NLog.Schema" version="4.3.0" targetFramework="net452" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user