diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 485691460..9f86bf865 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -132,6 +132,10 @@
..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll
True
+
+ ..\packages\Castle.Core.3.2.0\lib\net45\Castle.Core.dll
+ True
+
False
lib\ColorBox.dll
@@ -175,6 +179,10 @@
..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll
True
+
+ ..\packages\Ninject.Extensions.Factory.3.2.1.0\lib\net45-full\Ninject.Extensions.Factory.dll
+ True
+
..\packages\Ninject.Extensions.Logging.3.2.3.0\lib\net45-full\Ninject.Extensions.Logging.dll
True
@@ -274,6 +282,7 @@
+
@@ -379,9 +388,9 @@
-
-
-
+
+
+
True
diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs
index 719f7fcb8..2e62c48e6 100644
--- a/Artemis/Artemis/ArtemisBootstrapper.cs
+++ b/Artemis/Artemis/ArtemisBootstrapper.cs
@@ -6,7 +6,7 @@ using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
-using Artemis.NinjectModules;
+using Artemis.InjectionModules;
using Artemis.ViewModels;
using Caliburn.Micro;
using Ninject;
diff --git a/Artemis/Artemis/InjectionFactories/IProfileEditorViewModelFactory.cs b/Artemis/Artemis/InjectionFactories/IProfileEditorViewModelFactory.cs
new file mode 100644
index 000000000..1ed1c17aa
--- /dev/null
+++ b/Artemis/Artemis/InjectionFactories/IProfileEditorViewModelFactory.cs
@@ -0,0 +1,13 @@
+using Artemis.Managers;
+using Artemis.Models;
+using Artemis.ViewModels;
+using Caliburn.Micro;
+
+namespace Artemis.InjectionFactories
+{
+ public interface IProfileEditorViewModelFactory
+ {
+ ProfileEditorViewModel CreateProfileEditorViewModel(IEventAggregator events, MainManager mainManager,
+ GameModel gameModel);
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/NinjectModules/ArtemisModules.cs b/Artemis/Artemis/InjectionModules/ArtemisModules.cs
similarity index 57%
rename from Artemis/Artemis/NinjectModules/ArtemisModules.cs
rename to Artemis/Artemis/InjectionModules/ArtemisModules.cs
index cc9350970..63f55cce0 100644
--- a/Artemis/Artemis/NinjectModules/ArtemisModules.cs
+++ b/Artemis/Artemis/InjectionModules/ArtemisModules.cs
@@ -8,32 +8,28 @@ using Artemis.Modules.Games.TheDivision;
using Artemis.Modules.Games.Witcher3;
using Artemis.Modules.Overlays.VolumeDisplay;
using Artemis.ViewModels.Abstract;
-using Caliburn.Micro;
using Ninject.Modules;
-namespace Artemis.NinjectModules
+namespace Artemis.InjectionModules
{
public class ArtemisModules : NinjectModule
{
public override void Load()
{
// Effects
- Bind().To(); // TODO: Needed?
Bind().To().InSingletonScope();
Bind().To().InSingletonScope();
Bind().To().InSingletonScope();
//Bind().To().InSingletonScope();
// Games
- Bind().To(typeof(GameViewModel<>)); // TODO: Needed?
- Bind>().To().InSingletonScope();
- Bind>().To().InSingletonScope();
- Bind>().To().InSingletonScope();
- Bind>().To().InSingletonScope();
- Bind>().To().InSingletonScope();
+ Bind().To().InSingletonScope();
+ Bind().To().InSingletonScope();
+ Bind().To().InSingletonScope();
+ Bind().To().InSingletonScope();
+ Bind().To().InSingletonScope();
// Overlays
- Bind().To(); // TODO: Needed?
Bind().To().InSingletonScope();
}
}
diff --git a/Artemis/Artemis/NinjectModules/BaseModules.cs b/Artemis/Artemis/InjectionModules/BaseModules.cs
similarity index 61%
rename from Artemis/Artemis/NinjectModules/BaseModules.cs
rename to Artemis/Artemis/InjectionModules/BaseModules.cs
index bf5285b21..145255a33 100644
--- a/Artemis/Artemis/NinjectModules/BaseModules.cs
+++ b/Artemis/Artemis/InjectionModules/BaseModules.cs
@@ -1,9 +1,12 @@
-using Artemis.ViewModels;
+using Artemis.InjectionFactories;
+using Artemis.Modules.Effects.ProfilePreview;
+using Artemis.ViewModels;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
+using Ninject.Extensions.Factory;
using Ninject.Modules;
-namespace Artemis.NinjectModules
+namespace Artemis.InjectionModules
{
internal class BaseModules : NinjectModule
{
@@ -11,10 +14,14 @@ namespace Artemis.NinjectModules
{
// ViewModels
Bind().To().InSingletonScope();
+ Bind().ToFactory();
Bind().To().InSingletonScope();
Bind().To().InSingletonScope();
Bind().To().InSingletonScope();
+
+ // Models
+ Bind().ToSelf().InSingletonScope();
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/NinjectModules/ManagerModules.cs b/Artemis/Artemis/InjectionModules/ManagerModules.cs
similarity index 91%
rename from Artemis/Artemis/NinjectModules/ManagerModules.cs
rename to Artemis/Artemis/InjectionModules/ManagerModules.cs
index b36e5c897..f3d917790 100644
--- a/Artemis/Artemis/NinjectModules/ManagerModules.cs
+++ b/Artemis/Artemis/InjectionModules/ManagerModules.cs
@@ -1,7 +1,7 @@
using Artemis.Managers;
using Ninject.Modules;
-namespace Artemis.NinjectModules
+namespace Artemis.InjectionModules
{
internal class ManagerModules : NinjectModule
{
diff --git a/Artemis/Artemis/Managers/EffectManager.cs b/Artemis/Artemis/Managers/EffectManager.cs
index 5305f4411..0968ebc60 100644
--- a/Artemis/Artemis/Managers/EffectManager.cs
+++ b/Artemis/Artemis/Managers/EffectManager.cs
@@ -18,23 +18,19 @@ namespace Artemis.Managers
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IEventAggregator _events;
+ private readonly KeyboardManager _keyboardManager;
private EffectModel _activeEffect;
- public EffectManager(IEventAggregator events)
+ public EffectManager(IEventAggregator events, KeyboardManager keyboardManager)
{
Logger.Info("Intializing EffectManager");
_events = events;
+ _keyboardManager = keyboardManager;
EffectModels = new List();
- //ProfilePreviewModel = new ProfilePreviewModel(MainManager.Value);
Logger.Info("Intialized EffectManager");
}
- ///
- /// Used by ViewModels to show a preview of the profile currently being edited
- ///
- public ProfilePreviewModel ProfilePreviewModel { get; set; }
-
///
/// Holds all the effects the program has
///
@@ -81,42 +77,53 @@ namespace Artemis.Managers
///
/// Disables the current effect and changes it to the provided effect.
///
- ///
- /// Changes the effect, even if it's already running (effectively restarting it)
- public void ChangeEffect(EffectModel effectModel)
+ /// The effect to activate
+ /// Optionally pass the LoopManager to automatically start it, if it's not running.
+ public void ChangeEffect(EffectModel effectModel, LoopManager loopManager = null)
{
if (effectModel == null)
throw new ArgumentNullException(nameof(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 (_keyboardManager.ActiveKeyboard == null)
+ _keyboardManager.EnableLastKeyboard();
- var wasNull = false;
- if (ActiveEffect == null)
+ lock (_keyboardManager.ActiveKeyboard)
{
- wasNull = true;
- ActiveEffect = effectModel;
+ // Game models are only used if they are enabled
+ var gameModel = effectModel as GameModel;
+ if (gameModel != null)
+ if (!gameModel.Enabled)
+ return;
+
+ var wasNull = false;
+ if (ActiveEffect == null)
+ {
+ wasNull = true;
+ ActiveEffect = effectModel;
+ }
+
+ lock (ActiveEffect)
+ {
+ if (!wasNull)
+ ActiveEffect.Dispose();
+
+ ActiveEffect = effectModel;
+ ActiveEffect.Enable();
+
+ if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel)
+ return;
+
+ // Non-game effects are stored as the new LastEffect.
+ General.Default.LastEffect = ActiveEffect?.Name;
+ General.Default.Save();
+ }
}
- lock (ActiveEffect)
+ if (loopManager != null && !loopManager.Running)
{
- if (!wasNull)
- ActiveEffect.Dispose();
-
- ActiveEffect = effectModel;
- ActiveEffect.Enable();
-
- if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel)
- return;
-
- // Non-game effects are stored as the new LastEffect.
- General.Default.LastEffect = ActiveEffect?.Name;
- General.Default.Save();
+ loopManager.Start();
}
Logger.Debug($"Changed active effect to: {effectModel.Name}");
@@ -128,13 +135,16 @@ namespace Artemis.Managers
///
public void ClearEffect()
{
- lock (ActiveEffect)
+ lock (_keyboardManager.ActiveKeyboard)
{
- ActiveEffect.Dispose();
- ActiveEffect = null;
+ lock (ActiveEffect)
+ {
+ ActiveEffect.Dispose();
+ ActiveEffect = null;
- General.Default.LastEffect = null;
- General.Default.Save();
+ General.Default.LastEffect = null;
+ General.Default.Save();
+ }
}
Logger.Debug("Cleared active effect");
diff --git a/Artemis/Artemis/Managers/KeyboardManager.cs b/Artemis/Artemis/Managers/KeyboardManager.cs
index a7309a093..aa61b270d 100644
--- a/Artemis/Artemis/Managers/KeyboardManager.cs
+++ b/Artemis/Artemis/Managers/KeyboardManager.cs
@@ -107,7 +107,7 @@ namespace Artemis.Managers
{
if (ActiveKeyboard == null)
return;
-
+
ActiveKeyboard.Disable();
ActiveKeyboard = null;
}
diff --git a/Artemis/Artemis/Managers/LoopManager.cs b/Artemis/Artemis/Managers/LoopManager.cs
index 32f7120f3..0dd826b73 100644
--- a/Artemis/Artemis/Managers/LoopManager.cs
+++ b/Artemis/Artemis/Managers/LoopManager.cs
@@ -45,7 +45,18 @@ namespace Artemis.Managers
public void Start()
{
Logger.Debug("Starting LoopManager");
- // Setup
+
+ if (_keyboardManager.ActiveKeyboard == null)
+ _keyboardManager.EnableLastKeyboard();
+
+ if (_effectManager.ActiveEffect == null)
+ {
+ var lastEffect = _effectManager.GetLastEffect();
+ if (lastEffect == null)
+ return;
+
+ _effectManager.ChangeEffect(lastEffect);
+ }
Running = true;
}
@@ -55,7 +66,7 @@ namespace Artemis.Managers
Logger.Debug("Stopping LoopManager");
Running = false;
- // Shut down
+ _keyboardManager.ReleaseActiveKeyboard();
}
private void Render(object sender, ElapsedEventArgs e)
@@ -63,21 +74,21 @@ namespace Artemis.Managers
if (!Running)
return;
+ // 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;
+ }
+
// 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;
diff --git a/Artemis/Artemis/Managers/MainManager.cs b/Artemis/Artemis/Managers/MainManager.cs
index 73ec376ec..7ab5fa55a 100644
--- a/Artemis/Artemis/Managers/MainManager.cs
+++ b/Artemis/Artemis/Managers/MainManager.cs
@@ -65,7 +65,7 @@ namespace Artemis.Managers
public Lazy ShellViewModel { get; set; }
public ILogger Logger { get; }
- private LoopManager LoopManager { get; }
+ public LoopManager LoopManager { get; }
public KeyboardManager KeyboardManager { get; set; }
public EffectManager EffectManager { get; set; }
@@ -81,55 +81,13 @@ namespace Artemis.Managers
public void Dispose()
{
Logger.Debug("Shutting down MainManager");
- Stop();
+ LoopManager.Stop();
ProcessWorker.CancelAsync();
ProcessWorker.CancelAsync();
GameStateWebServer.Stop();
PipeServer.Stop();
}
- ///
- /// Take control of the keyboard and start sending data to it
- ///
- /// Whether starting was successful or not
- public bool Start(EffectModel effect = null)
- {
- Logger.Debug("Starting MainManager");
- // Can't take control when not enabled
- if (!ProgramEnabled)
- 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);
-
- LoopManager.Start();
-
- return Running;
- }
-
- ///
- /// Releases control of the keyboard and stop sending data to it
- ///
- public void Stop()
- {
- if (!Running)
- return;
-
- Logger.Debug("Stopping MainManager");
-
- LoopManager.Stop();
- }
-
///
/// Loads the last active effect and starts the program
///
@@ -137,7 +95,7 @@ namespace Artemis.Managers
{
Logger.Debug("Enabling program");
ProgramEnabled = true;
- Start(EffectManager.GetLastEffect());
+ LoopManager.Start();
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
}
@@ -147,7 +105,7 @@ namespace Artemis.Managers
public void DisableProgram()
{
Logger.Debug("Disabling program");
- Stop();
+ LoopManager.Stop();
ProgramEnabled = false;
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
}
diff --git a/Artemis/Artemis/Models/EffectModel.cs b/Artemis/Artemis/Models/EffectModel.cs
index a70af27f1..f4d0b12ee 100644
--- a/Artemis/Artemis/Models/EffectModel.cs
+++ b/Artemis/Artemis/Models/EffectModel.cs
@@ -7,6 +7,7 @@ namespace Artemis.Models
public abstract class EffectModel : IDisposable
{
public delegate void SettingsUpdateHandler(EffectSettings settings);
+
public bool Initialized;
public MainManager MainManager;
public string Name;
diff --git a/Artemis/Artemis/Models/GameModel.cs b/Artemis/Artemis/Models/GameModel.cs
index a499076b5..ab209277e 100644
--- a/Artemis/Artemis/Models/GameModel.cs
+++ b/Artemis/Artemis/Models/GameModel.cs
@@ -6,7 +6,7 @@ namespace Artemis.Models
{
public abstract class GameModel : EffectModel
{
- protected GameModel(MainManager mainManager, GameSettings settings): base(mainManager)
+ protected GameModel(MainManager mainManager, GameSettings settings) : base(mainManager)
{
Settings = settings;
}
diff --git a/Artemis/Artemis/Models/OverlayModel.cs b/Artemis/Artemis/Models/OverlayModel.cs
index ffd43b5e4..3e8369345 100644
--- a/Artemis/Artemis/Models/OverlayModel.cs
+++ b/Artemis/Artemis/Models/OverlayModel.cs
@@ -8,7 +8,7 @@ namespace Artemis.Models
private bool _enabled;
public string ProcessName;
- protected OverlayModel(MainManager mainManager): base(mainManager)
+ protected OverlayModel(MainManager mainManager) : base(mainManager)
{
}
diff --git a/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs b/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
index 3cfe203ab..ece8fae49 100644
--- a/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
+++ b/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
@@ -10,7 +10,7 @@ namespace Artemis.Modules.Effects.ProfilePreview
{
private readonly ProfilePreviewDataModel _previewDataModel;
- public ProfilePreviewModel(MainManager main) : base(main)
+ public ProfilePreviewModel(MainManager mainManager) : base(mainManager)
{
Name = "Profile Preview";
_previewDataModel = new ProfilePreviewDataModel();
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs
index f2d54f056..deebbe23a 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs
@@ -1,15 +1,17 @@
using System.IO;
using System.Windows.Forms;
+using Artemis.InjectionFactories;
using Artemis.Managers;
using Artemis.Properties;
using Artemis.ViewModels.Abstract;
+using Caliburn.Micro;
namespace Artemis.Modules.Games.CounterStrike
{
- public sealed class CounterStrikeViewModel : GameViewModel
+ public sealed class CounterStrikeViewModel : GameViewModel
{
- public CounterStrikeViewModel(MainManager main)
- : base(main, new CounterStrikeModel(main, new CounterStrikeSettings()))
+ public CounterStrikeViewModel(MainManager main, IEventAggregator events, IProfileEditorViewModelFactory pFactory)
+ : base(main, new CounterStrikeModel(main, new CounterStrikeSettings()), events, pFactory)
{
DisplayName = "CS:GO";
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs
index f7fc3b862..ee7b73d04 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs
@@ -1,5 +1,6 @@
using System.IO;
using System.Windows.Forms;
+using Artemis.InjectionFactories;
using Artemis.Managers;
using Artemis.Properties;
using Artemis.ViewModels.Abstract;
@@ -7,9 +8,10 @@ using Caliburn.Micro;
namespace Artemis.Modules.Games.Dota2
{
- public sealed class Dota2ViewModel : GameViewModel
+ public sealed class Dota2ViewModel : GameViewModel
{
- public Dota2ViewModel(MainManager main) : base(main, new Dota2Model(main, new Dota2Settings()))
+ public Dota2ViewModel(MainManager main, IEventAggregator events, IProfileEditorViewModelFactory pFactory)
+ : base(main, new Dota2Model(main, new Dota2Settings()), events, pFactory)
{
DisplayName = "Dota 2";
diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs
index 65e70557d..2cd6d9111 100644
--- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs
@@ -1,18 +1,20 @@
-using Artemis.Managers;
+using Artemis.InjectionFactories;
+using Artemis.Managers;
using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.Memory;
using Artemis.ViewModels.Abstract;
+using Caliburn.Micro;
using Newtonsoft.Json;
namespace Artemis.Modules.Games.RocketLeague
{
- public sealed class RocketLeagueViewModel : GameViewModel
+ public sealed class RocketLeagueViewModel : GameViewModel
{
private string _versionText;
- public RocketLeagueViewModel(MainManager main)
- : base(main, new RocketLeagueModel(main, new RocketLeagueSettings()))
+ public RocketLeagueViewModel(MainManager main, IEventAggregator events, IProfileEditorViewModelFactory pFactory)
+ : base(main, new RocketLeagueModel(main, new RocketLeagueSettings()), events, pFactory)
{
DisplayName = "Rocket League";
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs
index b0606d0b1..4d33f68c2 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs
@@ -1,12 +1,14 @@
-using Artemis.Managers;
+using Artemis.InjectionFactories;
+using Artemis.Managers;
using Artemis.ViewModels.Abstract;
+using Caliburn.Micro;
namespace Artemis.Modules.Games.TheDivision
{
- public sealed class TheDivisionViewModel : GameViewModel
+ public sealed class TheDivisionViewModel : GameViewModel
{
- public TheDivisionViewModel(MainManager main)
- : base(main, new TheDivisionModel(main, new TheDivisionSettings()))
+ public TheDivisionViewModel(MainManager main, IEventAggregator events, IProfileEditorViewModelFactory pFactory)
+ : base(main, new TheDivisionModel(main, new TheDivisionSettings()), events, pFactory)
{
DisplayName = "The Division";
MainManager.EffectManager.EffectModels.Add(GameModel);
diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs
index d08f291de..bbb8df0a7 100644
--- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3ViewModel.cs
@@ -3,16 +3,19 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
+using Artemis.InjectionFactories;
using Artemis.Managers;
using Artemis.Models.Interfaces;
using Artemis.Properties;
using Artemis.ViewModels.Abstract;
+using Caliburn.Micro;
namespace Artemis.Modules.Games.Witcher3
{
- public sealed class Witcher3ViewModel : GameViewModel
+ public sealed class Witcher3ViewModel : GameViewModel
{
- public Witcher3ViewModel(MainManager main) : base(main, new Witcher3Model(main, new Witcher3Settings()))
+ public Witcher3ViewModel(MainManager main, IEventAggregator events, IProfileEditorViewModelFactory pFactory)
+ : base(main, new Witcher3Model(main, new Witcher3Settings()), events, pFactory)
{
DisplayName = "The Witcher 3";
MainManager.EffectManager.EffectModels.Add(GameModel);
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs
index 1e205efb8..664c6b0e1 100644
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs
+++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs
@@ -5,7 +5,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{
public sealed class VolumeDisplayViewModel : OverlayViewModel
{
- public VolumeDisplayViewModel(MainManager mainManager): base(mainManager)
+ public VolumeDisplayViewModel(MainManager mainManager) : base(mainManager)
{
DisplayName = "Volume Display";
diff --git a/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs
index 1a8b5025d..46bb14c22 100644
--- a/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs
@@ -53,7 +53,7 @@ namespace Artemis.ViewModels.Abstract
if (EffectEnabled)
MainManager.EffectManager.ClearEffect();
else
- MainManager.EffectManager.ChangeEffect(EffectModel);
+ MainManager.EffectManager.ChangeEffect(EffectModel, MainManager.LoopManager);
}
public void SaveSettings()
diff --git a/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
index 3a175ba24..3b28bdef4 100644
--- a/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
@@ -1,14 +1,16 @@
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
+using Artemis.InjectionFactories;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview;
using Caliburn.Micro;
+using Ninject;
namespace Artemis.ViewModels.Abstract
{
- public abstract class GameViewModel : Screen
+ public abstract class GameViewModel : Screen
{
private bool _doActivate;
@@ -16,18 +18,26 @@ namespace Artemis.ViewModels.Abstract
private GameSettings _gameSettings;
private EffectModel _lastEffect;
- protected GameViewModel(MainManager mainManager, GameModel gameModel)
+ protected GameViewModel(MainManager mainManager, GameModel gameModel, IEventAggregator events,
+ IProfileEditorViewModelFactory pFactory)
{
MainManager = mainManager;
GameModel = gameModel;
+ Events = events;
+ PFactory = pFactory;
GameSettings = gameModel.Settings;
- //ProfileEditor = new ProfileEditorViewModel(MainManager, GameModel);
+ ProfileEditor = PFactory.CreateProfileEditorViewModel(Events, mainManager, gameModel);
GameModel.Profile = ProfileEditor.SelectedProfile;
ProfileEditor.PropertyChanged += ProfileUpdater;
}
- public ProfileEditorViewModel ProfileEditor { get; set; }
+ [Inject]
+ public ProfilePreviewModel ProfilePreviewModel { get; set; }
+ public IEventAggregator Events { get; set; }
+ public IProfileEditorViewModelFactory PFactory { get; set; }
+
+ public ProfileEditorViewModel ProfileEditor { get; set; }
public GameModel GameModel { get; set; }
public MainManager MainManager { get; set; }
@@ -57,7 +67,7 @@ namespace Artemis.ViewModels.Abstract
return;
// Restart the game if it's currently running to apply settings.
- MainManager.EffectManager.ChangeEffect(GameModel);
+ MainManager.EffectManager.ChangeEffect(GameModel, MainManager.LoopManager);
}
public async void ResetSettings()
@@ -110,8 +120,8 @@ namespace Artemis.ViewModels.Abstract
if (!(MainManager.EffectManager.ActiveEffect is ProfilePreviewModel))
_lastEffect = MainManager.EffectManager.ActiveEffect;
- MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
- MainManager.EffectManager.ChangeEffect(MainManager.EffectManager.ProfilePreviewModel);
+ ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
+ MainManager.EffectManager.ChangeEffect(ProfilePreviewModel, MainManager.LoopManager);
}
else
{
@@ -123,7 +133,7 @@ namespace Artemis.ViewModels.Abstract
if (!gameModel.Enabled)
MainManager.EffectManager.GetLastEffect();
else
- MainManager.EffectManager.ChangeEffect(_lastEffect);
+ MainManager.EffectManager.ChangeEffect(_lastEffect, MainManager.LoopManager);
}
else
MainManager.EffectManager.ClearEffect();
@@ -138,7 +148,7 @@ namespace Artemis.ViewModels.Abstract
return;
GameModel.Profile = ProfileEditor.SelectedProfile;
- MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
+ ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
}
}
diff --git a/Artemis/Artemis/ViewModels/GamesViewModel.cs b/Artemis/Artemis/ViewModels/GamesViewModel.cs
index 063a01cb0..6c787d40d 100644
--- a/Artemis/Artemis/ViewModels/GamesViewModel.cs
+++ b/Artemis/Artemis/ViewModels/GamesViewModel.cs
@@ -4,14 +4,20 @@ namespace Artemis.ViewModels
{
public sealed class GamesViewModel : BaseViewModel
{
- public GamesViewModel()
+ private readonly GameViewModel[] _gameViewModels;
+
+ public GamesViewModel(GameViewModel[] gameViewModels)
{
DisplayName = "Games";
+ _gameViewModels = gameViewModels;
}
protected override void OnActivate()
{
base.OnActivate();
+
+ foreach (var gameViewModel in _gameViewModels)
+ ActivateItem(gameViewModel);
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs b/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
index 82d8ebdcd..1a1fe2e0f 100644
--- a/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
+++ b/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
@@ -6,7 +6,7 @@ using Caliburn.Micro;
namespace Artemis.ViewModels.LayerEditor
{
- public class LayerConditionViewModel : Screen
+ public class LayerConditionViewModel : Screen
{
private readonly NamedOperator[] _boolOperators =
{
@@ -14,7 +14,7 @@ namespace Artemis.ViewModels.LayerEditor
new NamedOperator("False", "== False")
};
- private readonly LayerEditorViewModel _conditionModel;
+ private readonly LayerEditorViewModel _conditionModel;
private readonly NamedOperator[] _int32Operators =
{
@@ -39,7 +39,7 @@ namespace Artemis.ViewModels.LayerEditor
private string _userValue;
private bool _userValueIsVisible;
- public LayerConditionViewModel(LayerEditorViewModel conditionModel, LayerConditionModel layerConditionModel,
+ public LayerConditionViewModel(LayerEditorViewModel conditionModel, LayerConditionModel layerConditionModel,
BindableCollection dataModelProps)
{
_conditionModel = conditionModel;
diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerEditorViewModel.cs b/Artemis/Artemis/ViewModels/LayerEditor/LayerEditorViewModel.cs
index a2163d458..2ffc978af 100644
--- a/Artemis/Artemis/ViewModels/LayerEditor/LayerEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/LayerEditor/LayerEditorViewModel.cs
@@ -14,7 +14,7 @@ using Screen = Caliburn.Micro.Screen;
namespace Artemis.ViewModels.LayerEditor
{
- public class LayerEditorViewModel : Screen
+ public class LayerEditorViewModel : Screen
{
private readonly KeyboardProvider _activeKeyboard;
private readonly MetroDialogService _dialogService;
@@ -37,10 +37,10 @@ namespace Artemis.ViewModels.LayerEditor
Layer.Enabled = false;
DataModelProps = new BindableCollection();
ProposedProperties = new LayerPropertiesModel();
- DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap());
+ //DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap());
LayerConditionVms =
- new BindableCollection>(
- layer.LayerConditions.Select(c => new LayerConditionViewModel(this, c, DataModelProps)));
+ new BindableCollection(
+ layer.LayerConditions.Select(c => new LayerConditionViewModel(this, c, DataModelProps)));
HeightProperties = new LayerDynamicPropertiesViewModel("Height", DataModelProps, layer);
WidthProperties = new LayerDynamicPropertiesViewModel("Width", DataModelProps, layer);
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", DataModelProps, layer);
@@ -63,7 +63,7 @@ namespace Artemis.ViewModels.LayerEditor
public BindableCollection LayerTypes => new BindableCollection();
- public BindableCollection> LayerConditionVms { get; set; }
+ public BindableCollection LayerConditionVms { get; set; }
public LayerModel Layer
{
@@ -166,7 +166,7 @@ namespace Artemis.ViewModels.LayerEditor
{
var condition = new LayerConditionModel();
Layer.LayerConditions.Add(condition);
- LayerConditionVms.Add(new LayerConditionViewModel(this, condition, DataModelProps));
+ LayerConditionVms.Add(new LayerConditionViewModel(this, condition, DataModelProps));
}
public void Apply()
@@ -180,7 +180,7 @@ namespace Artemis.ViewModels.LayerEditor
_dialogService.ShowErrorMessageBox("Couldn't find or access the provided GIF file.");
}
- public void DeleteCondition(LayerConditionViewModel layerConditionViewModel,
+ public void DeleteCondition(LayerConditionViewModel layerConditionViewModel,
LayerConditionModel layerConditionModel)
{
LayerConditionVms.Remove(layerConditionViewModel);
diff --git a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs b/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
index 034acde6e..a865a7d0c 100644
--- a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
@@ -19,15 +19,14 @@ using MahApps.Metro;
namespace Artemis.ViewModels
{
- public sealed class ProfileEditorViewModel : Screen, IHandle
+ public sealed class ProfileEditorViewModel : Screen, IHandle
{
private readonly GameModel _gameModel;
- private readonly KeyboardManager _keyboardManager;
private readonly MainManager _mainManager;
private DateTime _downTime;
private LayerModel _draggingLayer;
private Point? _draggingLayerOffset;
- private LayerEditorViewModel _editorVm;
+ private LayerEditorViewModel _editorVm;
private Cursor _keyboardPreviewCursor;
private BindableCollection _layers;
private BindableCollection _profiles;
@@ -35,11 +34,9 @@ namespace Artemis.ViewModels
private LayerModel _selectedLayer;
private ProfileModel _selectedProfile;
- public ProfileEditorViewModel(MainManager mainManager, KeyboardManager keyboardManager, GameModel gameModel,
- IEventAggregator events)
+ public ProfileEditorViewModel(IEventAggregator events, MainManager mainManager, GameModel gameModel)
{
_mainManager = mainManager;
- _keyboardManager = keyboardManager;
_gameModel = gameModel;
Profiles = new BindableCollection();
@@ -50,10 +47,6 @@ namespace Artemis.ViewModels
LoadProfiles();
}
- public ProfileEditorViewModel()
- {
- }
-
public BindableCollection Profiles
{
get { return _profiles; }
@@ -180,7 +173,7 @@ namespace Artemis.ViewModels
public bool CanAddLayer => _selectedProfile != null;
public bool CanRemoveLayer => _selectedProfile != null && _selectedLayer != null;
- private KeyboardProvider ActiveKeyboard => _keyboardManager.ActiveKeyboard;
+ private KeyboardProvider ActiveKeyboard => _mainManager.KeyboardManager.ActiveKeyboard;
///
/// Handles chaning the active keyboard, updating the preview image and profiles collection
@@ -265,7 +258,7 @@ namespace Artemis.ViewModels
public void LayerEditor(LayerModel layer)
{
IWindowManager manager = new WindowManager();
- _editorVm = new LayerEditorViewModel(ActiveKeyboard, layer);
+ _editorVm = new LayerEditorViewModel(ActiveKeyboard, layer);
dynamic settings = new ExpandoObject();
settings.Title = "Artemis | Edit " + layer.Name;
diff --git a/Artemis/Artemis/packages.config b/Artemis/Artemis/packages.config
index bd14a3c12..f1426999b 100644
--- a/Artemis/Artemis/packages.config
+++ b/Artemis/Artemis/packages.config
@@ -1,7 +1,9 @@
+
+
@@ -13,6 +15,7 @@
+