mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Finished most of the Ninject conversion. Also hopefully solved the deadlocking (but I don't want to jinx it)
This commit is contained in:
parent
a09efc6845
commit
2bc7bbfd58
@ -2,50 +2,21 @@
|
|||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="userSettings"
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<section name="Artemis.Modules.Games.TheDivision.TheDivision" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Modules.Games.TheDivision.TheDivision"
|
<section name="Artemis.Modules.Games.Dota2.Dota2" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
<section name="Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="Artemis.Modules.Games.RocketLeague.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Modules.Games.Dota2.Dota2"
|
<section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
<section name="Artemis.Modules.Games.Witcher3.Witcher3" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay"
|
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
<section name="Artemis.Settings.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="Artemis.Settings.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Modules.Games.RocketLeague.RocketLeague"
|
<section name="Artemis.Settings.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
<section name="Artemis.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="Artemis.Settings.TypeWave" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Settings.Offsets"
|
<section name="Artemis.Settings.General" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Modules.Games.Witcher3.Witcher3"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Settings.CounterStrike"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Settings.AudioVisualization"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Settings.RocketLeague"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Properties.Settings"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Settings.TypeWave"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
<section name="Artemis.Settings.General"
|
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
||||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
<connectionStrings />
|
<connectionStrings />
|
||||||
@ -321,6 +292,10 @@
|
|||||||
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral" />
|
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-3.0.2.0" newVersion="3.0.2.0" />
|
<bindingRedirect oldVersion="0.0.0.0-3.0.2.0" newVersion="3.0.2.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
|
|
||||||
|
|||||||
@ -132,8 +132,8 @@
|
|||||||
<HintPath>..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
|
<HintPath>..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Castle.Core.3.2.0\lib\net45\Castle.Core.dll</HintPath>
|
<HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ColorBox, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f971124b2576acfc, processorArchitecture=MSIL">
|
<Reference Include="ColorBox, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f971124b2576acfc, processorArchitecture=MSIL">
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using Artemis.InjectionFactories;
|
using Artemis.InjectionFactories;
|
||||||
using Artemis.Modules.Effects.ProfilePreview;
|
using Artemis.Modules.Effects.ProfilePreview;
|
||||||
|
using Artemis.Services;
|
||||||
using Artemis.ViewModels;
|
using Artemis.ViewModels;
|
||||||
using Artemis.ViewModels.Abstract;
|
using Artemis.ViewModels.Abstract;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
@ -22,6 +23,9 @@ namespace Artemis.InjectionModules
|
|||||||
|
|
||||||
// Models
|
// Models
|
||||||
Bind<ProfilePreviewModel>().ToSelf().InSingletonScope();
|
Bind<ProfilePreviewModel>().ToSelf().InSingletonScope();
|
||||||
|
|
||||||
|
// Services
|
||||||
|
Bind<MetroDialogService>().ToSelf().InSingletonScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,7 +21,8 @@ namespace Artemis.KeyboardProviders.Corsair
|
|||||||
{
|
{
|
||||||
Name = "Corsair RGB Keyboards";
|
Name = "Corsair RGB Keyboards";
|
||||||
CantEnableText = "Couldn't connect to your Corsair keyboard.\n" +
|
CantEnableText = "Couldn't connect to your Corsair keyboard.\n" +
|
||||||
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n" +
|
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n" +
|
||||||
|
"In CUE, make sure \"Enable SDK\" is checked under Settings > Program.\n\n" +
|
||||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||||
KeyboardRegions = new List<KeyboardRegion>();
|
KeyboardRegions = new List<KeyboardRegion>();
|
||||||
}
|
}
|
||||||
@ -34,7 +35,8 @@ namespace Artemis.KeyboardProviders.Corsair
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CueSDK.Initialize();
|
if (CueSDK.ProtocolDetails == null)
|
||||||
|
CueSDK.Initialize();
|
||||||
}
|
}
|
||||||
catch (CUEException e)
|
catch (CUEException e)
|
||||||
{
|
{
|
||||||
@ -64,7 +66,8 @@ namespace Artemis.KeyboardProviders.Corsair
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CueSDK.Initialize();
|
if (CueSDK.ProtocolDetails == null)
|
||||||
|
CueSDK.Initialize();
|
||||||
}
|
}
|
||||||
catch (WrapperException)
|
catch (WrapperException)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,7 +17,7 @@ namespace Artemis.KeyboardProviders
|
|||||||
public PreviewSettings PreviewSettings { get; set; }
|
public PreviewSettings PreviewSettings { get; set; }
|
||||||
|
|
||||||
public abstract bool CanEnable();
|
public abstract bool CanEnable();
|
||||||
public abstract void Enable();
|
public abstract void Enable(); // TODO: This should be done in a background thread with a callback mechanism as it causes UI lag
|
||||||
public abstract void Disable();
|
public abstract void Disable();
|
||||||
public abstract void DrawBitmap(Bitmap bitmap);
|
public abstract void DrawBitmap(Bitmap bitmap);
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Timers;
|
||||||
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 NLog;
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
@ -19,6 +20,7 @@ namespace Artemis.Managers
|
|||||||
private readonly KeyboardManager _keyboardManager;
|
private readonly KeyboardManager _keyboardManager;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private EffectModel _activeEffect;
|
private EffectModel _activeEffect;
|
||||||
|
private EffectModel _prePreviewEffect;
|
||||||
|
|
||||||
public EffectManager(IEventAggregator events, ILogger logger, KeyboardManager keyboardManager)
|
public EffectManager(IEventAggregator events, ILogger logger, KeyboardManager keyboardManager)
|
||||||
{
|
{
|
||||||
@ -29,9 +31,16 @@ namespace Artemis.Managers
|
|||||||
_keyboardManager = keyboardManager;
|
_keyboardManager = keyboardManager;
|
||||||
|
|
||||||
EffectModels = new List<EffectModel>();
|
EffectModels = new List<EffectModel>();
|
||||||
|
|
||||||
|
var profilePreviewTimer = new Timer(500);
|
||||||
|
profilePreviewTimer.Elapsed += SetupProfilePreview;
|
||||||
|
profilePreviewTimer.Start();
|
||||||
|
|
||||||
_logger.Info("Intialized EffectManager");
|
_logger.Info("Intialized EffectManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProfilePreviewModel ProfilePreviewModel { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds all the effects the program has
|
/// Holds all the effects the program has
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -63,6 +72,43 @@ namespace Artemis.Managers
|
|||||||
get { return EffectModels.OfType<GameModel>().Where(g => g.Enabled); }
|
get { return EffectModels.OfType<GameModel>().Where(g => g.Enabled); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Keeps track of profiles being previewed and sets up the active efffect accordingly
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void SetupProfilePreview(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
// Make sure the preview model should still be active
|
||||||
|
if (ActiveEffect is ProfilePreviewModel)
|
||||||
|
{
|
||||||
|
// Should not be active if no selected profile is set
|
||||||
|
if (ProfilePreviewModel.SelectedProfile != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_prePreviewEffect != null)
|
||||||
|
{
|
||||||
|
_logger.Debug("Change back effect after profile preview");
|
||||||
|
ChangeEffect(_prePreviewEffect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Debug("Clear effect after profile preview");
|
||||||
|
ClearEffect(); // TODO: This fails to lock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Else make sure preview model indeed shouldn't be active
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ProfilePreviewModel?.SelectedProfile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_prePreviewEffect = ActiveEffect;
|
||||||
|
_logger.Debug("Activate profile preview");
|
||||||
|
ChangeEffect(ProfilePreviewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the last active effect from settings and enables it.
|
/// Loads the last active effect from settings and enables it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -87,26 +133,28 @@ namespace Artemis.Managers
|
|||||||
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");
|
||||||
|
|
||||||
if (_keyboardManager.ActiveKeyboard == null)
|
lock (_keyboardManager)
|
||||||
_keyboardManager.EnableLastKeyboard();
|
|
||||||
|
|
||||||
lock (_keyboardManager.ActiveKeyboard)
|
|
||||||
{
|
{
|
||||||
// Game models are only used if they are enabled
|
lock (this)
|
||||||
var gameModel = effectModel as GameModel;
|
{
|
||||||
if (gameModel != null)
|
if (_keyboardManager.ActiveKeyboard == null)
|
||||||
if (!gameModel.Enabled)
|
_keyboardManager.EnableLastKeyboard();
|
||||||
|
// If still null, no last keyboard, so stop.
|
||||||
|
if (_keyboardManager.ActiveKeyboard == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var wasNull = false;
|
// Game models are only used if they are enabled
|
||||||
if (ActiveEffect == null)
|
var gameModel = effectModel as GameModel;
|
||||||
{
|
if (gameModel != null)
|
||||||
wasNull = true;
|
if (!gameModel.Enabled)
|
||||||
ActiveEffect = effectModel;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
lock (ActiveEffect)
|
var wasNull = false;
|
||||||
{
|
if (ActiveEffect == null)
|
||||||
|
{
|
||||||
|
wasNull = true;
|
||||||
|
ActiveEffect = effectModel;
|
||||||
|
}
|
||||||
if (!wasNull)
|
if (!wasNull)
|
||||||
ActiveEffect.Dispose();
|
ActiveEffect.Dispose();
|
||||||
|
|
||||||
@ -124,10 +172,11 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
if (loopManager != null && !loopManager.Running)
|
if (loopManager != null && !loopManager.Running)
|
||||||
{
|
{
|
||||||
|
_logger.Debug("Starting LoopManager for effect change");
|
||||||
loopManager.Start();
|
loopManager.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Changed active effect to: {effectModel.Name}");
|
_logger.Debug("Changed active effect to: {0}", effectModel.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,9 +185,9 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearEffect()
|
public void ClearEffect()
|
||||||
{
|
{
|
||||||
lock (_keyboardManager.ActiveKeyboard)
|
lock (_keyboardManager)
|
||||||
{
|
{
|
||||||
lock (ActiveEffect)
|
lock (this)
|
||||||
{
|
{
|
||||||
ActiveEffect.Dispose();
|
ActiveEffect.Dispose();
|
||||||
ActiveEffect = null;
|
ActiveEffect = null;
|
||||||
@ -157,7 +206,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: {activeEffect?.Name}");
|
_logger.Debug("Disabling game: {0}", activeEffect?.Name);
|
||||||
if (GetLastEffect() == null)
|
if (GetLastEffect() == null)
|
||||||
ClearEffect();
|
ClearEffect();
|
||||||
else
|
else
|
||||||
|
|||||||
@ -3,9 +3,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Events;
|
using Artemis.Events;
|
||||||
using Artemis.KeyboardProviders;
|
using Artemis.KeyboardProviders;
|
||||||
|
using Artemis.Services;
|
||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using NLog;
|
using Ninject;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
@ -29,6 +31,9 @@ namespace Artemis.Managers
|
|||||||
_logger.Info("Intialized KeyboardManager");
|
_logger.Info("Intialized KeyboardManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public MetroDialogService DialogService { get; set; }
|
||||||
|
|
||||||
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
||||||
|
|
||||||
public KeyboardProvider ActiveKeyboard
|
public KeyboardProvider ActiveKeyboard
|
||||||
@ -47,7 +52,7 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnableLastKeyboard()
|
public void EnableLastKeyboard()
|
||||||
{
|
{
|
||||||
_logger.Debug($"Enabling last keyboard: {General.Default.LastKeyboard}");
|
_logger.Debug("Getting last keyboard: {0}", General.Default.LastKeyboard);
|
||||||
if (string.IsNullOrEmpty(General.Default.LastKeyboard))
|
if (string.IsNullOrEmpty(General.Default.LastKeyboard))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -61,22 +66,22 @@ namespace Artemis.Managers
|
|||||||
/// <param name="keyboardProvider"></param>
|
/// <param name="keyboardProvider"></param>
|
||||||
public void EnableKeyboard(KeyboardProvider keyboardProvider)
|
public void EnableKeyboard(KeyboardProvider keyboardProvider)
|
||||||
{
|
{
|
||||||
if (keyboardProvider == null)
|
lock (this)
|
||||||
throw new ArgumentNullException(nameof(keyboardProvider));
|
|
||||||
|
|
||||||
if (ActiveKeyboard?.Name == keyboardProvider.Name)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var wasNull = false;
|
|
||||||
if (ActiveKeyboard == null)
|
|
||||||
{
|
{
|
||||||
wasNull = true;
|
if (keyboardProvider == null)
|
||||||
ActiveKeyboard = keyboardProvider;
|
throw new ArgumentNullException(nameof(keyboardProvider));
|
||||||
}
|
|
||||||
|
|
||||||
lock (ActiveKeyboard)
|
if (ActiveKeyboard?.Name == keyboardProvider.Name)
|
||||||
{
|
return;
|
||||||
_logger.Debug($"Enabling keyboard: {keyboardProvider.Name}");
|
|
||||||
|
var wasNull = false;
|
||||||
|
if (ActiveKeyboard == null)
|
||||||
|
{
|
||||||
|
wasNull = true;
|
||||||
|
ActiveKeyboard = keyboardProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Debug("Enabling keyboard: {0}", keyboardProvider.Name);
|
||||||
|
|
||||||
if (!wasNull)
|
if (!wasNull)
|
||||||
ReleaseActiveKeyboard();
|
ReleaseActiveKeyboard();
|
||||||
@ -84,9 +89,11 @@ namespace Artemis.Managers
|
|||||||
// Disable everything if there's no active keyboard found
|
// Disable everything if there's no active keyboard found
|
||||||
if (!keyboardProvider.CanEnable())
|
if (!keyboardProvider.CanEnable())
|
||||||
{
|
{
|
||||||
// TODO: MainManager.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
|
DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
|
||||||
|
ActiveKeyboard = null;
|
||||||
General.Default.LastKeyboard = null;
|
General.Default.LastKeyboard = null;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
|
_logger.Warn("Failed enabling keyboard: {0}", keyboardProvider.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +102,7 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
General.Default.LastKeyboard = ActiveKeyboard.Name;
|
General.Default.LastKeyboard = ActiveKeyboard.Name;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
|
_logger.Debug("Enabled keyboard: {0}", keyboardProvider.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,16 +111,16 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReleaseActiveKeyboard()
|
public void ReleaseActiveKeyboard()
|
||||||
{
|
{
|
||||||
lock (ActiveKeyboard)
|
lock (this)
|
||||||
{
|
{
|
||||||
if (ActiveKeyboard == null)
|
if (ActiveKeyboard == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var releaseName = ActiveKeyboard.Name;
|
||||||
ActiveKeyboard.Disable();
|
ActiveKeyboard.Disable();
|
||||||
ActiveKeyboard = null;
|
ActiveKeyboard = null;
|
||||||
|
_logger.Debug("Released keyboard: {0}", releaseName);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Released keyboard: {ActiveKeyboard?.Name}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,18 +43,29 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
if (Running)
|
||||||
|
return;
|
||||||
|
|
||||||
_logger.Debug("Starting LoopManager");
|
_logger.Debug("Starting LoopManager");
|
||||||
|
|
||||||
if (_keyboardManager.ActiveKeyboard == null)
|
if (_keyboardManager.ActiveKeyboard == null)
|
||||||
_keyboardManager.EnableLastKeyboard();
|
_keyboardManager.EnableLastKeyboard();
|
||||||
|
// If still null, no last keyboard, so stop.
|
||||||
|
if (_keyboardManager.ActiveKeyboard == null)
|
||||||
|
{
|
||||||
|
_logger.Debug("Cancel LoopManager start, no keyboard");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Deadlock maybe? I don't know what Resharper is on about
|
// TODO: Deadlock maybe? I don't know what Resharper is on about
|
||||||
if (_effectManager.ActiveEffect == null)
|
if (_effectManager.ActiveEffect == null)
|
||||||
{
|
{
|
||||||
var lastEffect = _effectManager.GetLastEffect();
|
var lastEffect = _effectManager.GetLastEffect();
|
||||||
if (lastEffect == null)
|
if (lastEffect == null)
|
||||||
|
{
|
||||||
|
_logger.Debug("Cancel LoopManager start, no effect");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
_effectManager.ChangeEffect(lastEffect);
|
_effectManager.ChangeEffect(lastEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +74,9 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
|
if (!Running)
|
||||||
|
return;
|
||||||
|
|
||||||
_logger.Debug("Stopping LoopManager");
|
_logger.Debug("Stopping LoopManager");
|
||||||
Running = false;
|
Running = false;
|
||||||
|
|
||||||
@ -74,21 +88,26 @@ namespace Artemis.Managers
|
|||||||
if (!Running)
|
if (!Running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stop if no active keyboard/efffect
|
// Stop if no active keyboard
|
||||||
if (_keyboardManager.ActiveKeyboard == null || _effectManager.ActiveEffect == null)
|
if (_keyboardManager.ActiveKeyboard == null)
|
||||||
{
|
{
|
||||||
_logger.Debug("No active keyboard/effect, stopping. " +
|
_logger.Debug("No active keyboard, stopping");
|
||||||
$"Keyboard={_keyboardManager.ActiveKeyboard?.Name}, " +
|
|
||||||
$"effect={_effectManager.ActiveEffect?.Name}");
|
|
||||||
Stop();
|
Stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock both the active keyboard and active effect so they will not change while rendering.
|
// Lock both the active keyboard and active effect so they will not change while rendering.
|
||||||
lock (_keyboardManager.ActiveKeyboard)
|
lock (_keyboardManager)
|
||||||
{
|
{
|
||||||
lock (_effectManager.ActiveEffect)
|
lock (_effectManager)
|
||||||
{
|
{
|
||||||
|
// Stop if no active effect
|
||||||
|
if (_effectManager.ActiveEffect == null)
|
||||||
|
{
|
||||||
|
_logger.Debug("No active effect, stopping");
|
||||||
|
Stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip frame if effect is still initializing
|
// Skip frame if effect is still initializing
|
||||||
if (_effectManager.ActiveEffect.Initialized == false)
|
if (_effectManager.ActiveEffect.Initialized == false)
|
||||||
return;
|
return;
|
||||||
@ -102,16 +121,13 @@ namespace Artemis.Managers
|
|||||||
? _effectManager.ActiveEffect.GenerateBitmap()
|
? _effectManager.ActiveEffect.GenerateBitmap()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
lock (_effectManager.EnabledOverlays)
|
// Draw enabled overlays on top
|
||||||
|
foreach (var overlayModel in _effectManager.EnabledOverlays)
|
||||||
{
|
{
|
||||||
// Draw enabled overlays on top
|
overlayModel.Update();
|
||||||
foreach (var overlayModel in _effectManager.EnabledOverlays)
|
bitmap = bitmap != null
|
||||||
{
|
? overlayModel.GenerateBitmap(bitmap)
|
||||||
overlayModel.Update();
|
: overlayModel.GenerateBitmap();
|
||||||
bitmap = bitmap != null
|
|
||||||
? overlayModel.GenerateBitmap(bitmap)
|
|
||||||
: overlayModel.GenerateBitmap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitmap == null)
|
if (bitmap == null)
|
||||||
|
|||||||
@ -71,7 +71,6 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
public PipeServer PipeServer { get; set; }
|
public PipeServer PipeServer { get; set; }
|
||||||
public BackgroundWorker ProcessWorker { get; set; }
|
public BackgroundWorker ProcessWorker { 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; }
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainManager.DialogService.ShowErrorMessageBox("Please select a valid CS:GO directory\n\n" +
|
DialogService.ShowErrorMessageBox("Please select a valid CS:GO directory\n\n" +
|
||||||
@"By default CS:GO is in \SteamApps\common\Counter-Strike Global Offensive");
|
@"By default CS:GO is in \SteamApps\common\Counter-Strike Global Offensive");
|
||||||
((CounterStrikeSettings) GameSettings).GameDirectory = string.Empty;
|
((CounterStrikeSettings) GameSettings).GameDirectory = string.Empty;
|
||||||
NotifyOfPropertyChange(() => GameSettings);
|
NotifyOfPropertyChange(() => GameSettings);
|
||||||
|
|||||||
@ -75,7 +75,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainManager.DialogService.ShowErrorMessageBox("Please select a valid Dota 2 directory\n\n" +
|
DialogService.ShowErrorMessageBox("Please select a valid Dota 2 directory\n\n" +
|
||||||
@"By default Dota 2 is in \SteamApps\common\dota 2 beta");
|
@"By default Dota 2 is in \SteamApps\common\dota 2 beta");
|
||||||
((Dota2Settings) GameSettings).GameDirectory = string.Empty;
|
((Dota2Settings) GameSettings).GameDirectory = string.Empty;
|
||||||
NotifyOfPropertyChange(() => GameSettings);
|
NotifyOfPropertyChange(() => GameSettings);
|
||||||
|
|||||||
@ -38,7 +38,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
if (!File.Exists(dialog.SelectedPath + @"\bin\x64\witcher3.exe"))
|
if (!File.Exists(dialog.SelectedPath + @"\bin\x64\witcher3.exe"))
|
||||||
{
|
{
|
||||||
var retry = await
|
var retry = await
|
||||||
MainManager.DialogService.ShowQuestionMessageBox("Installation error",
|
DialogService.ShowQuestionMessageBox("Installation error",
|
||||||
"That's not a valid Witcher 3 directory\n\n" +
|
"That's not a valid Witcher 3 directory\n\n" +
|
||||||
"Default directories:\n" +
|
"Default directories:\n" +
|
||||||
"Steam: \\SteamApps\\common\\The Witcher 3\n" +
|
"Steam: \\SteamApps\\common\\The Witcher 3\n" +
|
||||||
@ -61,7 +61,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
if (!file.Contains("modArtemis"))
|
if (!file.Contains("modArtemis"))
|
||||||
{
|
{
|
||||||
var viewHelp = await
|
var viewHelp = await
|
||||||
MainManager.DialogService.ShowQuestionMessageBox("Conflicting mod found",
|
DialogService.ShowQuestionMessageBox("Conflicting mod found",
|
||||||
"Oh no, you have a conflicting mod!\n\n" +
|
"Oh no, you have a conflicting mod!\n\n" +
|
||||||
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
|
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
|
||||||
"\n\nWould you like to view instructions on how to manually install the mod?");
|
"\n\nWould you like to view instructions on how to manually install the mod?");
|
||||||
@ -104,7 +104,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
|
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
|
||||||
Resources.playerWitcherWs);
|
Resources.playerWitcherWs);
|
||||||
|
|
||||||
MainManager.DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
|
DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,29 +27,20 @@ using Caliburn.Micro;
|
|||||||
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls;
|
||||||
using MahApps.Metro.Controls.Dialogs;
|
using MahApps.Metro.Controls.Dialogs;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Ninject;
|
||||||
|
|
||||||
namespace Artemis.Services
|
namespace Artemis.Services
|
||||||
{
|
{
|
||||||
public class MetroDialogService : DialogService
|
public class MetroDialogService : DialogService
|
||||||
{
|
{
|
||||||
private readonly IScreen _viewModel;
|
|
||||||
|
|
||||||
public MetroDialogService(IScreen viewModel)
|
|
||||||
{
|
|
||||||
_viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MetroWindow GetActiveWindow()
|
private MetroWindow GetActiveWindow()
|
||||||
{
|
{
|
||||||
MetroWindow window = null;
|
MetroWindow window = null;
|
||||||
|
|
||||||
Execute.OnUIThread(() =>
|
Execute.OnUIThread(() =>
|
||||||
{
|
{
|
||||||
window = Application.Current.Windows.OfType<MetroWindow>().FirstOrDefault(w => w.IsActive);
|
window = Application.Current.Windows.OfType<MetroWindow>().FirstOrDefault(w => w.IsActive) ??
|
||||||
if (window == null)
|
Application.Current.Windows.OfType<MetroWindow>().FirstOrDefault();
|
||||||
{
|
|
||||||
window = Application.Current.Windows.OfType<MetroWindow>().FirstOrDefault();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
@ -57,7 +48,7 @@ namespace Artemis.Services
|
|||||||
|
|
||||||
public override void ShowMessageBox(string title, string message)
|
public override void ShowMessageBox(string title, string message)
|
||||||
{
|
{
|
||||||
if (_viewModel.IsActive == false)
|
if (GetActiveWindow() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Execute.OnUIThread(() => GetActiveWindow().ShowMessageAsync(title, message));
|
Execute.OnUIThread(() => GetActiveWindow().ShowMessageAsync(title, message));
|
||||||
@ -65,7 +56,7 @@ namespace Artemis.Services
|
|||||||
|
|
||||||
public override async Task<bool?> ShowQuestionMessageBox(string title, string message)
|
public override async Task<bool?> ShowQuestionMessageBox(string title, string message)
|
||||||
{
|
{
|
||||||
if (_viewModel.IsActive == false)
|
if (GetActiveWindow() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var metroDialogSettings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
|
var metroDialogSettings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
|
||||||
@ -86,7 +77,7 @@ namespace Artemis.Services
|
|||||||
|
|
||||||
public override Task<string> ShowInputDialog(string title, string message)
|
public override Task<string> ShowInputDialog(string title, string message)
|
||||||
{
|
{
|
||||||
if (_viewModel.IsActive == false)
|
if (GetActiveWindow() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return GetActiveWindow().ShowInputAsync(title, message);
|
return GetActiveWindow().ShowInputAsync(title, message);
|
||||||
@ -94,7 +85,7 @@ namespace Artemis.Services
|
|||||||
|
|
||||||
public override bool ShowOpenDialog(out string path, string defaultExt, string filter, string initialDir = null)
|
public override bool ShowOpenDialog(out string path, string defaultExt, string filter, string initialDir = null)
|
||||||
{
|
{
|
||||||
if (_viewModel.IsActive == false)
|
if (GetActiveWindow() == null)
|
||||||
{
|
{
|
||||||
path = null;
|
path = null;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
|
using Artemis.Services;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using Ninject;
|
||||||
|
|
||||||
namespace Artemis.ViewModels.Abstract
|
namespace Artemis.ViewModels.Abstract
|
||||||
{
|
{
|
||||||
@ -17,6 +19,8 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
EffectModel = effectModel;
|
EffectModel = effectModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public MetroDialogService DialogService { get; set; }
|
||||||
public EffectSettings EffectSettings
|
public EffectSettings EffectSettings
|
||||||
{
|
{
|
||||||
get { return _effectSettings; }
|
get { return _effectSettings; }
|
||||||
@ -69,7 +73,7 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
public async void ResetSettings()
|
public async void ResetSettings()
|
||||||
{
|
{
|
||||||
var resetConfirm = await
|
var resetConfirm = await
|
||||||
MainManager.DialogService.ShowQuestionMessageBox("Reset effect settings",
|
DialogService.ShowQuestionMessageBox("Reset effect settings",
|
||||||
"Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost.");
|
"Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost.");
|
||||||
|
|
||||||
if (!resetConfirm.Value)
|
if (!resetConfirm.Value)
|
||||||
|
|||||||
@ -1,22 +1,22 @@
|
|||||||
using System.ComponentModel;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.InjectionFactories;
|
using Artemis.InjectionFactories;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Modules.Effects.ProfilePreview;
|
using Artemis.Modules.Effects.ProfilePreview;
|
||||||
|
using Artemis.Services;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
namespace Artemis.ViewModels.Abstract
|
namespace Artemis.ViewModels.Abstract
|
||||||
{
|
{
|
||||||
public abstract class GameViewModel : Screen
|
public abstract class GameViewModel : Screen
|
||||||
{
|
{
|
||||||
private bool _doActivate;
|
|
||||||
|
|
||||||
private bool _editorShown;
|
|
||||||
private GameSettings _gameSettings;
|
private GameSettings _gameSettings;
|
||||||
private EffectModel _lastEffect;
|
private bool _startLoopManager;
|
||||||
|
|
||||||
protected GameViewModel(MainManager mainManager, GameModel gameModel, IEventAggregator events,
|
protected GameViewModel(MainManager mainManager, GameModel gameModel, IEventAggregator events,
|
||||||
IProfileEditorViewModelFactory pFactory)
|
IProfileEditorViewModelFactory pFactory)
|
||||||
@ -32,9 +32,14 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
ProfileEditor.PropertyChanged += ProfileUpdater;
|
ProfileEditor.PropertyChanged += ProfileUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
[Inject]
|
[Inject]
|
||||||
public ProfilePreviewModel ProfilePreviewModel { get; set; }
|
public ProfilePreviewModel ProfilePreviewModel { get; set; }
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public MetroDialogService DialogService { get; set; }
|
||||||
|
|
||||||
public IEventAggregator Events { get; set; }
|
public IEventAggregator Events { get; set; }
|
||||||
public IProfileEditorViewModelFactory PFactory { get; set; }
|
public IProfileEditorViewModelFactory PFactory { get; set; }
|
||||||
|
|
||||||
@ -74,9 +79,8 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
public async void ResetSettings()
|
public async void ResetSettings()
|
||||||
{
|
{
|
||||||
var resetConfirm =
|
var resetConfirm =
|
||||||
await
|
await DialogService.ShowQuestionMessageBox("Reset effect settings",
|
||||||
MainManager.DialogService.ShowQuestionMessageBox("Reset effect settings",
|
"Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost.");
|
||||||
"Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost.");
|
|
||||||
|
|
||||||
if (!resetConfirm.Value)
|
if (!resetConfirm.Value)
|
||||||
return;
|
return;
|
||||||
@ -90,57 +94,34 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
base.OnActivate();
|
base.OnActivate();
|
||||||
|
SetEditorShown(true);
|
||||||
|
|
||||||
// OnActive is triggered at odd moments, only activate the profile
|
// OnActivate gets called at odd times, only start the LoopManager if it's been active
|
||||||
// preview if OnDeactivate isn't called right after it
|
// for 600ms.
|
||||||
_doActivate = true;
|
_startLoopManager = true;
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(600);
|
||||||
if (_doActivate)
|
if (MainManager.LoopManager.Running || !_startLoopManager)
|
||||||
SetEditorShown(true);
|
return;
|
||||||
|
|
||||||
|
Logger.Debug("Starting LoopManager for profile preview");
|
||||||
|
MainManager.LoopManager.Start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDeactivate(bool close)
|
protected override void OnDeactivate(bool close)
|
||||||
{
|
{
|
||||||
base.OnDeactivate(close);
|
base.OnDeactivate(close);
|
||||||
|
|
||||||
_doActivate = false;
|
|
||||||
SetEditorShown(false);
|
SetEditorShown(false);
|
||||||
|
|
||||||
|
_startLoopManager = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEditorShown(bool enable)
|
public void SetEditorShown(bool enable)
|
||||||
{
|
{
|
||||||
if (enable == _editorShown)
|
MainManager.EffectManager.ProfilePreviewModel = ProfilePreviewModel;
|
||||||
return;
|
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = enable ? ProfileEditor.SelectedProfile : null;
|
||||||
|
|
||||||
if (enable)
|
|
||||||
{
|
|
||||||
// Store the current effect so it can be restored later
|
|
||||||
if (!(MainManager.EffectManager.ActiveEffect is ProfilePreviewModel))
|
|
||||||
_lastEffect = MainManager.EffectManager.ActiveEffect;
|
|
||||||
|
|
||||||
ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
|
||||||
MainManager.EffectManager.ChangeEffect(ProfilePreviewModel, MainManager.LoopManager);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_lastEffect != null)
|
|
||||||
{
|
|
||||||
// Game models are only used if they are enabled
|
|
||||||
var gameModel = _lastEffect as GameModel;
|
|
||||||
if (gameModel != null)
|
|
||||||
if (!gameModel.Enabled)
|
|
||||||
MainManager.EffectManager.GetLastEffect();
|
|
||||||
else
|
|
||||||
MainManager.EffectManager.ChangeEffect(_lastEffect, MainManager.LoopManager);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
MainManager.EffectManager.ClearEffect();
|
|
||||||
}
|
|
||||||
|
|
||||||
_editorShown = enable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
|
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
|
using Artemis.Services;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using Ninject;
|
||||||
|
|
||||||
namespace Artemis.ViewModels.Abstract
|
namespace Artemis.ViewModels.Abstract
|
||||||
{
|
{
|
||||||
@ -14,6 +16,8 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
MainManager = mainManager;
|
MainManager = mainManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public MetroDialogService DialogService { get; set; }
|
||||||
public OverlayModel OverlayModel { get; set; }
|
public OverlayModel OverlayModel { get; set; }
|
||||||
|
|
||||||
public OverlaySettings OverlaySettings
|
public OverlaySettings OverlaySettings
|
||||||
@ -40,7 +44,7 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
public async void ResetSettings()
|
public async void ResetSettings()
|
||||||
{
|
{
|
||||||
var resetConfirm = await
|
var resetConfirm = await
|
||||||
MainManager.DialogService.ShowQuestionMessageBox("Reset overlay settings",
|
DialogService.ShowQuestionMessageBox("Reset overlay settings",
|
||||||
"Are you sure you wish to reset this overlay's settings? \nAny changes you made will be lost.");
|
"Are you sure you wish to reset this overlay's settings? \nAny changes you made will be lost.");
|
||||||
|
|
||||||
if (!resetConfirm.Value)
|
if (!resetConfirm.Value)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Events;
|
using Artemis.Events;
|
||||||
@ -5,24 +6,28 @@ using Artemis.Managers;
|
|||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
namespace Artemis.ViewModels.Flyouts
|
namespace Artemis.ViewModels.Flyouts
|
||||||
{
|
{
|
||||||
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
|
public sealed class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>,
|
||||||
|
IHandle<ActiveEffectChanged>
|
||||||
{
|
{
|
||||||
private readonly KeyboardManager _keyboardManager;
|
private readonly ILogger _logger;
|
||||||
private string _activeEffectName;
|
private string _activeEffectName;
|
||||||
private GeneralSettings _generalSettings;
|
private GeneralSettings _generalSettings;
|
||||||
private string _selectedKeyboardProvider;
|
private string _selectedKeyboardProvider;
|
||||||
|
|
||||||
public FlyoutSettingsViewModel(MainManager mainManager, KeyboardManager keyboardManager, IEventAggregator events)
|
public FlyoutSettingsViewModel(MainManager mainManager, IEventAggregator events, ILogger logger)
|
||||||
{
|
{
|
||||||
_keyboardManager = keyboardManager;
|
_logger = logger;
|
||||||
|
|
||||||
MainManager = mainManager;
|
MainManager = mainManager;
|
||||||
Header = "Settings";
|
Header = "Settings";
|
||||||
Position = Position.Right;
|
Position = Position.Right;
|
||||||
GeneralSettings = new GeneralSettings();
|
GeneralSettings = new GeneralSettings();
|
||||||
|
|
||||||
|
PropertyChanged += KeyboardUpdater;
|
||||||
events.Subscribe(this);
|
events.Subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +48,7 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var collection = new BindableCollection<string>(_keyboardManager.KeyboardProviders.Select(k => k.Name));
|
var collection = new BindableCollection<string>(MainManager.KeyboardManager.KeyboardProviders.Select(k => k.Name));
|
||||||
collection.Insert(0, "None");
|
collection.Insert(0, "None");
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
@ -57,12 +62,6 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
if (value == _selectedKeyboardProvider) return;
|
if (value == _selectedKeyboardProvider) return;
|
||||||
_selectedKeyboardProvider = value;
|
_selectedKeyboardProvider = value;
|
||||||
NotifyOfPropertyChange(() => SelectedKeyboardProvider);
|
NotifyOfPropertyChange(() => SelectedKeyboardProvider);
|
||||||
if (value == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_keyboardManager.EnableKeyboard(
|
|
||||||
_keyboardManager.KeyboardProviders.FirstOrDefault(
|
|
||||||
k => k.Name == _selectedKeyboardProvider));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +70,7 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
get { return MainManager.ProgramEnabled; }
|
get { return MainManager.ProgramEnabled; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
MainManager.EnableProgram();
|
MainManager.EnableProgram();
|
||||||
else
|
else
|
||||||
@ -100,6 +100,28 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
NotifyOfPropertyChange(() => Enabled);
|
NotifyOfPropertyChange(() => Enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Takes proper action when the selected keyboard is changed in the UI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void KeyboardUpdater(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName != "SelectedKeyboardProvider")
|
||||||
|
return;
|
||||||
|
|
||||||
|
_logger.Debug("Handling SelectedKeyboard change in UI");
|
||||||
|
var keyboard = MainManager.KeyboardManager.KeyboardProviders.FirstOrDefault(k => k.Name == SelectedKeyboardProvider);
|
||||||
|
if (keyboard != null)
|
||||||
|
{
|
||||||
|
MainManager.KeyboardManager.EnableKeyboard(keyboard);
|
||||||
|
MainManager.LoopManager.Start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MainManager.KeyboardManager.ReleaseActiveKeyboard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void ToggleEnabled()
|
public void ToggleEnabled()
|
||||||
{
|
{
|
||||||
if (Enabled)
|
if (Enabled)
|
||||||
|
|||||||
@ -10,6 +10,7 @@ using Artemis.Models.Profiles;
|
|||||||
using Artemis.Services;
|
using Artemis.Services;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using Ninject;
|
||||||
using Screen = Caliburn.Micro.Screen;
|
using Screen = Caliburn.Micro.Screen;
|
||||||
|
|
||||||
namespace Artemis.ViewModels.LayerEditor
|
namespace Artemis.ViewModels.LayerEditor
|
||||||
@ -17,7 +18,6 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
public class LayerEditorViewModel : Screen
|
public class LayerEditorViewModel : Screen
|
||||||
{
|
{
|
||||||
private readonly KeyboardProvider _activeKeyboard;
|
private readonly KeyboardProvider _activeKeyboard;
|
||||||
private readonly MetroDialogService _dialogService;
|
|
||||||
private readonly BackgroundWorker _previewWorker;
|
private readonly BackgroundWorker _previewWorker;
|
||||||
private readonly bool _wasEnabled;
|
private readonly bool _wasEnabled;
|
||||||
private LayerModel _layer;
|
private LayerModel _layer;
|
||||||
@ -30,7 +30,6 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
_activeKeyboard = activeKeyboard;
|
_activeKeyboard = activeKeyboard;
|
||||||
_wasEnabled = layer.Enabled;
|
_wasEnabled = layer.Enabled;
|
||||||
|
|
||||||
_dialogService = new MetroDialogService(this);
|
|
||||||
Layer = layer;
|
Layer = layer;
|
||||||
ProposedLayer = new LayerModel();
|
ProposedLayer = new LayerModel();
|
||||||
GeneralHelpers.CopyProperties(ProposedLayer, Layer);
|
GeneralHelpers.CopyProperties(ProposedLayer, Layer);
|
||||||
@ -53,6 +52,8 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
PreSelect();
|
PreSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public MetroDialogService DialogService { get; set; }
|
||||||
public LayerDynamicPropertiesViewModel OpacityProperties { get; set; }
|
public LayerDynamicPropertiesViewModel OpacityProperties { get; set; }
|
||||||
|
|
||||||
public LayerDynamicPropertiesViewModel WidthProperties { get; set; }
|
public LayerDynamicPropertiesViewModel WidthProperties { get; set; }
|
||||||
@ -177,7 +178,7 @@ namespace Artemis.ViewModels.LayerEditor
|
|||||||
OpacityProperties.Apply();
|
OpacityProperties.Apply();
|
||||||
|
|
||||||
if (!File.Exists(Layer.GifFile) && Layer.LayerType == LayerType.KeyboardGif)
|
if (!File.Exists(Layer.GifFile) && Layer.LayerType == LayerType.KeyboardGif)
|
||||||
_dialogService.ShowErrorMessageBox("Couldn't find or access the provided GIF file.");
|
DialogService.ShowErrorMessageBox("Couldn't find or access the provided GIF file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteCondition(LayerConditionViewModel layerConditionViewModel,
|
public void DeleteCondition(LayerConditionViewModel layerConditionViewModel,
|
||||||
|
|||||||
@ -12,10 +12,12 @@ using Artemis.KeyboardProviders;
|
|||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Models.Profiles;
|
using Artemis.Models.Profiles;
|
||||||
|
using Artemis.Services;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.ViewModels.LayerEditor;
|
using Artemis.ViewModels.LayerEditor;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using MahApps.Metro;
|
using MahApps.Metro;
|
||||||
|
using Ninject;
|
||||||
|
|
||||||
namespace Artemis.ViewModels
|
namespace Artemis.ViewModels
|
||||||
{
|
{
|
||||||
@ -47,6 +49,8 @@ namespace Artemis.ViewModels
|
|||||||
LoadProfiles();
|
LoadProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public MetroDialogService DialogService { get; set; }
|
||||||
public BindableCollection<ProfileModel> Profiles
|
public BindableCollection<ProfileModel> Profiles
|
||||||
{
|
{
|
||||||
get { return _profiles; }
|
get { return _profiles; }
|
||||||
@ -217,11 +221,11 @@ namespace Artemis.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public async void AddProfile()
|
public async void AddProfile()
|
||||||
{
|
{
|
||||||
var name = await _mainManager.DialogService.ShowInputDialog("Add new profile",
|
var name = await DialogService.ShowInputDialog("Add new profile",
|
||||||
"Please provide a profile name unique to this game and keyboard.");
|
"Please provide a profile name unique to this game and keyboard.");
|
||||||
if (name.Length < 1)
|
if (name.Length < 1)
|
||||||
{
|
{
|
||||||
_mainManager.DialogService.ShowMessageBox("Invalid profile name", "Please provide a valid profile name");
|
DialogService.ShowMessageBox("Invalid profile name", "Please provide a valid profile name");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +238,7 @@ namespace Artemis.ViewModels
|
|||||||
|
|
||||||
if (ProfileProvider.GetAll().Contains(profile))
|
if (ProfileProvider.GetAll().Contains(profile))
|
||||||
{
|
{
|
||||||
var overwrite = await _mainManager.DialogService.ShowQuestionMessageBox("Overwrite existing profile",
|
var overwrite = await DialogService.ShowQuestionMessageBox("Overwrite existing profile",
|
||||||
"A profile with this name already exists for this game. Would you like to overwrite it?");
|
"A profile with this name already exists for this game. Would you like to overwrite it?");
|
||||||
if (!overwrite.Value)
|
if (!overwrite.Value)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -2,9 +2,11 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Artemis.Events;
|
using Artemis.Events;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
|
using Artemis.Services;
|
||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using Ninject;
|
||||||
|
|
||||||
namespace Artemis.ViewModels
|
namespace Artemis.ViewModels
|
||||||
{
|
{
|
||||||
@ -33,6 +35,8 @@ namespace Artemis.ViewModels
|
|||||||
ShowWindow();
|
ShowWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public MetroDialogService DialogService { get; set; }
|
||||||
public MainManager MainManager { get; set; }
|
public MainManager MainManager { get; set; }
|
||||||
|
|
||||||
public bool CanShowWindow => !_shellViewModel.IsActive;
|
public bool CanShowWindow => !_shellViewModel.IsActive;
|
||||||
@ -110,7 +114,7 @@ namespace Artemis.ViewModels
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_checkedForUpdate = true;
|
_checkedForUpdate = true;
|
||||||
Updater.CheckForUpdate(MainManager.DialogService);
|
Updater.CheckForUpdate(DialogService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
<?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" />
|
||||||
<package id="Castle.Core" version="3.2.0" targetFramework="net452" />
|
<package id="Castle.Core" version="3.3.3" targetFramework="net452" />
|
||||||
<package id="Colore" version="4.0.0" targetFramework="net452" />
|
<package id="Colore" version="4.0.0" targetFramework="net452" />
|
||||||
<package id="CUE.NET" version="1.0.2.2" targetFramework="net452" />
|
<package id="CUE.NET" version="1.0.2.2" targetFramework="net452" />
|
||||||
<package id="Extended.Wpf.Toolkit" version="2.7" targetFramework="net452" />
|
<package id="Extended.Wpf.Toolkit" version="2.7" targetFramework="net452" />
|
||||||
@ -19,7 +18,6 @@
|
|||||||
<package id="Ninject.Extensions.Logging" version="3.2.3.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="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.Schema" version="4.3.0" targetFramework="net452" />
|
<package id="NLog.Schema" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="SharpDX" version="3.0.2" targetFramework="net452" />
|
<package id="SharpDX" version="3.0.2" targetFramework="net452" />
|
||||||
<package id="SharpDX.Direct3D11" version="3.0.2" targetFramework="net452" />
|
<package id="SharpDX.Direct3D11" version="3.0.2" targetFramework="net452" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user