mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Implemented keyboard preview, added logging
This commit is contained in:
parent
9d966b9321
commit
32a651ffec
@ -175,6 +175,10 @@
|
|||||||
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NLog.4.3.2\lib\net45\NLog.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
<Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\SharpDX.3.0.2\lib\net45\SharpDX.dll</HintPath>
|
<HintPath>..\packages\SharpDX.3.0.2\lib\net45\SharpDX.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@ -299,6 +303,7 @@
|
|||||||
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\FftEventArgs.cs" />
|
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\FftEventArgs.cs" />
|
||||||
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\SampleAggregator.cs" />
|
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\SampleAggregator.cs" />
|
||||||
<Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" />
|
<Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" />
|
||||||
|
<Compile Include="Modules\Effects\ProfilePreview\ProfilePreviewModel.cs" />
|
||||||
<Compile Include="Modules\Effects\TypeHole\TypeHoleModel.cs" />
|
<Compile Include="Modules\Effects\TypeHole\TypeHoleModel.cs" />
|
||||||
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
|
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
|
||||||
<DependentUpon>TypeWave.settings</DependentUpon>
|
<DependentUpon>TypeWave.settings</DependentUpon>
|
||||||
@ -529,6 +534,12 @@
|
|||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput>
|
<LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
|
<Content Include="NLog.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<None Include="NLog.xsd">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
<Resource Include="Resources\bow.png" />
|
<Resource Include="Resources\bow.png" />
|
||||||
|
|||||||
@ -1,29 +1,45 @@
|
|||||||
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.Settings;
|
using Artemis.Settings;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using NLog;
|
||||||
|
using LogManager = NLog.LogManager;
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
public class EffectManager
|
public class EffectManager
|
||||||
{
|
{
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IEventAggregator _events;
|
private readonly IEventAggregator _events;
|
||||||
private readonly MainManager _mainManager;
|
private readonly MainManager _mainManager;
|
||||||
private bool _clearing;
|
|
||||||
private EffectModel _pauseEffect;
|
|
||||||
private EffectModel _activeEffect;
|
private EffectModel _activeEffect;
|
||||||
|
private bool _clearing;
|
||||||
|
public EffectModel PauseEffect { get; set; }
|
||||||
|
|
||||||
public EffectManager(MainManager mainManager, IEventAggregator events)
|
public EffectManager(MainManager mainManager, IEventAggregator events)
|
||||||
{
|
{
|
||||||
|
Logger.Info("Intializing EffectManager");
|
||||||
_mainManager = mainManager;
|
_mainManager = mainManager;
|
||||||
_events = events;
|
_events = events;
|
||||||
|
|
||||||
EffectModels = new List<EffectModel>();
|
EffectModels = new List<EffectModel>();
|
||||||
|
ProfilePreviewModel = new ProfilePreviewModel(_mainManager);
|
||||||
|
Logger.Info("Intialized EffectManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used by ViewModels to show a preview of the profile currently being edited
|
||||||
|
/// </summary>
|
||||||
|
public ProfilePreviewModel ProfilePreviewModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Holds all the effects the program has
|
||||||
|
/// </summary>
|
||||||
public List<EffectModel> EffectModels { get; set; }
|
public List<EffectModel> EffectModels { get; set; }
|
||||||
|
|
||||||
public EffectModel ActiveEffect
|
public EffectModel ActiveEffect
|
||||||
@ -36,11 +52,17 @@ namespace Artemis.Managers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all enabled overlays
|
||||||
|
/// </summary>
|
||||||
public IEnumerable<OverlayModel> EnabledOverlays
|
public IEnumerable<OverlayModel> EnabledOverlays
|
||||||
{
|
{
|
||||||
get { return EffectModels.OfType<OverlayModel>().Where(o => o.Enabled); }
|
get { return EffectModels.OfType<OverlayModel>().Where(o => o.Enabled); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all enabled games
|
||||||
|
/// </summary>
|
||||||
public IEnumerable<GameModel> EnabledGames
|
public IEnumerable<GameModel> EnabledGames
|
||||||
{
|
{
|
||||||
get { return EffectModels.OfType<GameModel>().Where(g => g.Enabled); }
|
get { return EffectModels.OfType<GameModel>().Where(g => g.Enabled); }
|
||||||
@ -52,13 +74,14 @@ namespace Artemis.Managers
|
|||||||
/// <returns>Whether enabling was successful or not.</returns>
|
/// <returns>Whether enabling was successful or not.</returns>
|
||||||
public EffectModel GetLastEffect()
|
public EffectModel GetLastEffect()
|
||||||
{
|
{
|
||||||
|
Logger.Debug("Getting last effect: {0}", General.Default.LastEffect);
|
||||||
if (General.Default.LastEffect == null)
|
if (General.Default.LastEffect == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var effect = 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
|
// Fall back to the first effect found, in case settings are messed up
|
||||||
return effect ?? EffectModels.First();
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -81,6 +104,7 @@ namespace Artemis.Managers
|
|||||||
if (effectModel.Name == ActiveEffect.Name && !force)
|
if (effectModel.Name == ActiveEffect.Name && !force)
|
||||||
return;
|
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 the main manager is running, pause it and safely change the effect
|
||||||
if (_mainManager.Running)
|
if (_mainManager.Running)
|
||||||
{
|
{
|
||||||
@ -94,27 +118,40 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
private void ChangeEffectWithPause(EffectModel effectModel)
|
private void ChangeEffectWithPause(EffectModel effectModel)
|
||||||
{
|
{
|
||||||
if (_pauseEffect != null)
|
var tryCount = 0;
|
||||||
return;
|
while (PauseEffect != null)
|
||||||
|
{
|
||||||
|
Thread.Sleep(100);
|
||||||
|
tryCount++;
|
||||||
|
if (tryCount > 20)
|
||||||
|
throw new Exception("Couldn't change effect before the time expired");
|
||||||
|
}
|
||||||
|
|
||||||
_pauseEffect = effectModel;
|
// Don't interrupt an ongoing effect change
|
||||||
|
if (PauseEffect != null)
|
||||||
|
{
|
||||||
|
Logger.Debug("Change effect with pause cancelled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logger.Debug("Changing effect with pause: {0}", effectModel?.Name);
|
||||||
|
|
||||||
|
PauseEffect = effectModel;
|
||||||
_mainManager.Pause();
|
_mainManager.Pause();
|
||||||
_mainManager.PauseCallback += ChangeEffectPauseCallback;
|
_mainManager.PauseCallback += ChangeEffectPauseCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeEffectPauseCallback()
|
private void ChangeEffectPauseCallback()
|
||||||
{
|
{
|
||||||
|
_mainManager.PauseCallback -= ChangeEffectPauseCallback;
|
||||||
|
|
||||||
// Change effect logic
|
// Change effect logic
|
||||||
ActiveEffect?.Dispose();
|
ActiveEffect?.Dispose();
|
||||||
|
|
||||||
ActiveEffect = _pauseEffect;
|
ActiveEffect = PauseEffect;
|
||||||
ActiveEffect.Enable();
|
ActiveEffect.Enable();
|
||||||
|
|
||||||
// Let the ViewModels know
|
|
||||||
//_events.PublishOnUIThread(new ActiveEffectChanged(ActiveEffect.Name));
|
|
||||||
|
|
||||||
_mainManager.Unpause();
|
_mainManager.Unpause();
|
||||||
_pauseEffect = null;
|
PauseEffect = null;
|
||||||
|
|
||||||
if (ActiveEffect is GameModel)
|
if (ActiveEffect is GameModel)
|
||||||
return;
|
return;
|
||||||
@ -122,6 +159,8 @@ namespace Artemis.Managers
|
|||||||
// Non-game effects are stored as the new LastEffect.
|
// Non-game effects are stored as the new LastEffect.
|
||||||
General.Default.LastEffect = ActiveEffect.Name;
|
General.Default.LastEffect = ActiveEffect.Name;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
|
|
||||||
|
Logger.Debug("Finishing change effect with pause");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -133,29 +172,36 @@ namespace Artemis.Managers
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't mess with the ActiveEffect if in the process of changing the effect.
|
// Don't mess with the ActiveEffect if in the process of changing the effect.
|
||||||
if (_pauseEffect != null)
|
if (PauseEffect != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ActiveEffect == null)
|
if (ActiveEffect == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_clearing = true;
|
_clearing = true;
|
||||||
|
Logger.Debug("Clearing active effect");
|
||||||
_mainManager.Pause();
|
_mainManager.Pause();
|
||||||
_mainManager.PauseCallback += ClearEffectPauseCallback;
|
_mainManager.PauseCallback += ClearEffectPauseCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearEffectPauseCallback()
|
private void ClearEffectPauseCallback()
|
||||||
{
|
{
|
||||||
|
_mainManager.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();
|
||||||
|
|
||||||
//_events.PublishOnUIThread(new ActiveEffectChanged(""));
|
|
||||||
|
|
||||||
_clearing = false;
|
_clearing = false;
|
||||||
|
|
||||||
|
Logger.Debug("Finishing clearing active effect");
|
||||||
_mainManager.Unpause();
|
_mainManager.Unpause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +211,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);
|
||||||
if (GetLastEffect() == null)
|
if (GetLastEffect() == null)
|
||||||
ClearEffect();
|
ClearEffect();
|
||||||
else
|
else
|
||||||
|
|||||||
@ -4,20 +4,25 @@ using Artemis.Events;
|
|||||||
using Artemis.KeyboardProviders;
|
using Artemis.KeyboardProviders;
|
||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using NLog;
|
||||||
|
using LogManager = NLog.LogManager;
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
public class KeyboardManager
|
public class KeyboardManager
|
||||||
{
|
{
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IEventAggregator _events;
|
private readonly IEventAggregator _events;
|
||||||
private readonly MainManager _mainManager;
|
private readonly MainManager _mainManager;
|
||||||
private KeyboardProvider _activeKeyboard;
|
private KeyboardProvider _activeKeyboard;
|
||||||
|
|
||||||
public KeyboardManager(MainManager mainManager, IEventAggregator events)
|
public KeyboardManager(MainManager mainManager, IEventAggregator events)
|
||||||
{
|
{
|
||||||
|
Logger.Info("Intializing KeyboardManager");
|
||||||
_mainManager = mainManager;
|
_mainManager = mainManager;
|
||||||
_events = events;
|
_events = events;
|
||||||
KeyboardProviders = ProviderHelper.GetKeyboardProviders();
|
KeyboardProviders = ProviderHelper.GetKeyboardProviders();
|
||||||
|
Logger.Info("Intialized KeyboardManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
||||||
@ -33,11 +38,14 @@ 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);
|
||||||
if (General.Default.LastKeyboard == null)
|
if (General.Default.LastKeyboard == null)
|
||||||
return;
|
return;
|
||||||
if (General.Default.LastKeyboard == "")
|
if (General.Default.LastKeyboard == "")
|
||||||
@ -53,6 +61,7 @@ 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();
|
ReleaseActiveKeyboard();
|
||||||
|
|
||||||
if (keyboardProvider == null)
|
if (keyboardProvider == null)
|
||||||
@ -69,22 +78,25 @@ namespace Artemis.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CanDisable = false;
|
||||||
ActiveKeyboard = keyboardProvider;
|
ActiveKeyboard = keyboardProvider;
|
||||||
ActiveKeyboard.Enable();
|
keyboardProvider.Enable();
|
||||||
|
|
||||||
General.Default.LastKeyboard = ActiveKeyboard.Name;
|
General.Default.LastKeyboard = ActiveKeyboard.Name;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
|
CanDisable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases the active keyboard
|
/// Releases the active keyboard, if CanDisable is true
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReleaseActiveKeyboard()
|
public void ReleaseActiveKeyboard()
|
||||||
{
|
{
|
||||||
if (ActiveKeyboard == null)
|
if (ActiveKeyboard == null || !CanDisable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ActiveKeyboard.Disable();
|
ActiveKeyboard.Disable();
|
||||||
|
Logger.Debug("Released keyboard: {0}", ActiveKeyboard?.Name);
|
||||||
ActiveKeyboard = null;
|
ActiveKeyboard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,12 +106,14 @@ namespace Artemis.Managers
|
|||||||
/// <param name="keyboardProvider"></param>
|
/// <param name="keyboardProvider"></param>
|
||||||
public void ChangeKeyboard(KeyboardProvider keyboardProvider)
|
public void ChangeKeyboard(KeyboardProvider keyboardProvider)
|
||||||
{
|
{
|
||||||
|
Logger.Debug("Changing active keyboard");
|
||||||
if (keyboardProvider == ActiveKeyboard)
|
if (keyboardProvider == ActiveKeyboard)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
General.Default.LastKeyboard = keyboardProvider?.Name;
|
General.Default.LastKeyboard = keyboardProvider?.Name;
|
||||||
General.Default.Save();
|
General.Default.Save();
|
||||||
|
|
||||||
|
Logger.Debug("Restarting for keyboard change");
|
||||||
_mainManager.Restart();
|
_mainManager.Restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,8 @@ using Artemis.Utilities.GameState;
|
|||||||
using Artemis.Utilities.Keyboard;
|
using Artemis.Utilities.Keyboard;
|
||||||
using Artemis.Utilities.LogitechDll;
|
using Artemis.Utilities.LogitechDll;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using NLog;
|
||||||
|
using LogManager = NLog.LogManager;
|
||||||
|
|
||||||
namespace Artemis.Managers
|
namespace Artemis.Managers
|
||||||
{
|
{
|
||||||
@ -16,12 +18,16 @@ namespace Artemis.Managers
|
|||||||
{
|
{
|
||||||
public delegate void PauseCallbackHandler();
|
public delegate void PauseCallbackHandler();
|
||||||
|
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly int _fps;
|
private readonly int _fps;
|
||||||
private bool _paused;
|
private bool _paused;
|
||||||
private bool _restarting;
|
private bool _restarting;
|
||||||
|
|
||||||
public MainManager(IEventAggregator events, MetroDialogService dialogService)
|
public MainManager(IEventAggregator events, MetroDialogService dialogService)
|
||||||
{
|
{
|
||||||
|
Logger.Info("Intializing MainManager");
|
||||||
|
|
||||||
Events = events;
|
Events = events;
|
||||||
DialogService = dialogService;
|
DialogService = dialogService;
|
||||||
|
|
||||||
@ -52,6 +58,8 @@ namespace Artemis.Managers
|
|||||||
// Start the named pipe
|
// Start the named pipe
|
||||||
PipeServer = new PipeServer();
|
PipeServer = new PipeServer();
|
||||||
PipeServer.Start("artemis");
|
PipeServer.Start("artemis");
|
||||||
|
|
||||||
|
Logger.Info("Intialized MainManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipeServer PipeServer { get; set; }
|
public PipeServer PipeServer { get; set; }
|
||||||
@ -80,6 +88,7 @@ namespace Artemis.Managers
|
|||||||
/// <returns>Whether starting was successful or not</returns>
|
/// <returns>Whether starting was successful or not</returns>
|
||||||
public bool Start(EffectModel effect = null)
|
public bool Start(EffectModel effect = null)
|
||||||
{
|
{
|
||||||
|
Logger.Debug("Starting MainManager");
|
||||||
// Can't take control when not enabled
|
// Can't take control when not enabled
|
||||||
if (!ProgramEnabled || UpdateWorker.CancellationPending || UpdateWorker.IsBusy || _paused)
|
if (!ProgramEnabled || UpdateWorker.CancellationPending || UpdateWorker.IsBusy || _paused)
|
||||||
return false;
|
return false;
|
||||||
@ -109,6 +118,7 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
|
Logger.Debug("Stopping MainManager");
|
||||||
if (!Running || UpdateWorker.CancellationPending || _paused)
|
if (!Running || UpdateWorker.CancellationPending || _paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -123,6 +133,7 @@ namespace Artemis.Managers
|
|||||||
KeyboardManager.ReleaseActiveKeyboard();
|
KeyboardManager.ReleaseActiveKeyboard();
|
||||||
Running = false;
|
Running = false;
|
||||||
|
|
||||||
|
Logger.Debug("Stopped MainManager");
|
||||||
if (e.Error != null || !_restarting)
|
if (e.Error != null || !_restarting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -135,6 +146,7 @@ namespace Artemis.Managers
|
|||||||
if (!Running || UpdateWorker.CancellationPending || _paused)
|
if (!Running || UpdateWorker.CancellationPending || _paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Logger.Debug("Pausing MainManager");
|
||||||
_paused = true;
|
_paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,23 +155,26 @@ namespace Artemis.Managers
|
|||||||
if (!_paused)
|
if (!_paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Logger.Debug("Unpausing MainManager");
|
||||||
_paused = false;
|
_paused = false;
|
||||||
PauseCallback = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Shutdown()
|
public void Shutdown()
|
||||||
{
|
{
|
||||||
|
Logger.Debug("Shutting down MainManager");
|
||||||
Stop();
|
Stop();
|
||||||
ProcessWorker.CancelAsync();
|
ProcessWorker.CancelAsync();
|
||||||
ProcessWorker.CancelAsync();
|
ProcessWorker.CancelAsync();
|
||||||
GameStateWebServer.Stop();
|
GameStateWebServer.Stop();
|
||||||
//NamedPipeServer.StopServer();
|
PipeServer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
if (_restarting)
|
if (_restarting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Logger.Debug("Restarting MainManager");
|
||||||
if (!Running)
|
if (!Running)
|
||||||
{
|
{
|
||||||
Start();
|
Start();
|
||||||
@ -175,6 +190,7 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnableProgram()
|
public void EnableProgram()
|
||||||
{
|
{
|
||||||
|
Logger.Debug("Enabling program");
|
||||||
ProgramEnabled = true;
|
ProgramEnabled = true;
|
||||||
Start(EffectManager.GetLastEffect());
|
Start(EffectManager.GetLastEffect());
|
||||||
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||||
@ -185,6 +201,7 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void DisableProgram()
|
public void DisableProgram()
|
||||||
{
|
{
|
||||||
|
Logger.Debug("Disabling program");
|
||||||
Stop();
|
Stop();
|
||||||
ProgramEnabled = false;
|
ProgramEnabled = false;
|
||||||
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||||
@ -209,6 +226,14 @@ namespace Artemis.Managers
|
|||||||
if (KeyboardManager.ActiveKeyboard == null || EffectManager.ActiveEffect == null)
|
if (KeyboardManager.ActiveKeyboard == null || EffectManager.ActiveEffect == null)
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000/_fps);
|
Thread.Sleep(1000/_fps);
|
||||||
|
Logger.Debug("No active effect/keyboard, stopping");
|
||||||
|
|
||||||
|
if (EffectManager.PauseEffect != null)
|
||||||
|
{
|
||||||
|
PauseCallback?.Invoke();
|
||||||
|
Thread.Sleep(1000/_fps);
|
||||||
|
}
|
||||||
|
else
|
||||||
Stop();
|
Stop();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -257,7 +282,10 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
private void BackgroundWorkerExceptionCatcher(object sender, RunWorkerCompletedEventArgs e)
|
private void BackgroundWorkerExceptionCatcher(object sender, RunWorkerCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Error != null)
|
if (e.Error == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Logger.Error(e.Error, "Exception in the BackgroundWorker");
|
||||||
throw e.Error;
|
throw e.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +313,8 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
// 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(g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
|
.FirstOrDefault(
|
||||||
|
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)
|
||||||
|
|||||||
@ -1,18 +1,21 @@
|
|||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Models.Profiles;
|
using Artemis.Models.Profiles;
|
||||||
|
using Artemis.Modules.Games.Witcher3;
|
||||||
|
|
||||||
namespace Artemis.Models
|
namespace Artemis.Models
|
||||||
{
|
{
|
||||||
public abstract class GameModel : EffectModel
|
public abstract class GameModel : EffectModel
|
||||||
{
|
{
|
||||||
|
public GameSettings Settings { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
public string ProcessName { get; set; }
|
public string ProcessName { get; set; }
|
||||||
public IGameDataModel GameDataModel { get; set; }
|
public IGameDataModel GameDataModel { get; set; }
|
||||||
public ProfileModel Profile { get; set; }
|
public ProfileModel Profile { get; set; }
|
||||||
|
|
||||||
protected GameModel(MainManager mainManager) : base(mainManager)
|
protected GameModel(MainManager mainManager, GameSettings settings) : base(mainManager)
|
||||||
{
|
{
|
||||||
|
Settings = settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,8 +64,10 @@ namespace Artemis.Models.Profiles
|
|||||||
_mustDraw = false;
|
_mustDraw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw<T>(IGameDataModel dataModel, DrawingContext c)
|
public void Draw<T>(IGameDataModel dataModel, DrawingContext c, bool preview = false)
|
||||||
{
|
{
|
||||||
|
// Conditions aren't checked during a preview because there is no game data to base them on
|
||||||
|
if (!preview)
|
||||||
if (!ConditionsMet<T>(dataModel))
|
if (!ConditionsMet<T>(dataModel))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -82,7 +84,7 @@ namespace Artemis.Models.Profiles
|
|||||||
_drawer.UpdateHeadset();
|
_drawer.UpdateHeadset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update<T>(IGameDataModel dataModel)
|
public void Update<T>(IGameDataModel dataModel, bool preview = false)
|
||||||
{
|
{
|
||||||
if (LayerType == LayerType.Folder)
|
if (LayerType == LayerType.Folder)
|
||||||
{
|
{
|
||||||
@ -92,6 +94,10 @@ namespace Artemis.Models.Profiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
GeneralHelpers.CopyProperties(CalcProps, UserProps);
|
GeneralHelpers.CopyProperties(CalcProps, UserProps);
|
||||||
|
|
||||||
|
// Dynamic properties aren't applied during preview because there is no game data to base them on
|
||||||
|
if (preview)
|
||||||
|
return;
|
||||||
foreach (var dynamicProperty in LayerProperties)
|
foreach (var dynamicProperty in LayerProperties)
|
||||||
dynamicProperty.ApplyProperty<T>(dataModel, UserProps, CalcProps);
|
dynamicProperty.ApplyProperty<T>(dataModel, UserProps, CalcProps);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,7 +106,7 @@ namespace Artemis.Models.Profiles
|
|||||||
Layers[i].Order = i;
|
Layers[i].Order = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap GenerateBitmap<T>(Rect keyboardRect, IGameDataModel gameDataModel)
|
public Bitmap GenerateBitmap<T>(Rect keyboardRect, IGameDataModel gameDataModel, bool preview = false)
|
||||||
{
|
{
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
DrawingVisual.Dispatcher.Invoke(delegate
|
DrawingVisual.Dispatcher.Invoke(delegate
|
||||||
@ -120,7 +120,7 @@ namespace Artemis.Models.Profiles
|
|||||||
|
|
||||||
// Draw the layers
|
// Draw the layers
|
||||||
foreach (var layerModel in Layers.OrderByDescending(l => l.Order))
|
foreach (var layerModel in Layers.OrderByDescending(l => l.Order))
|
||||||
layerModel.Draw<T>(gameDataModel, c);
|
layerModel.Draw<T>(gameDataModel, c, preview);
|
||||||
|
|
||||||
// Remove the clip
|
// Remove the clip
|
||||||
c.Pop();
|
c.Pop();
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using Artemis.Utilities.Keyboard;
|
|||||||
|
|
||||||
namespace Artemis.Modules.Effects.Debug
|
namespace Artemis.Modules.Effects.Debug
|
||||||
{
|
{
|
||||||
|
// TODO: Remove
|
||||||
internal class DebugEffectModel : EffectModel
|
internal class DebugEffectModel : EffectModel
|
||||||
{
|
{
|
||||||
public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager)
|
public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager)
|
||||||
|
|||||||
@ -0,0 +1,62 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
using Artemis.Managers;
|
||||||
|
using Artemis.Models;
|
||||||
|
using Artemis.Models.Interfaces;
|
||||||
|
using Artemis.Models.Profiles;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Effects.ProfilePreview
|
||||||
|
{
|
||||||
|
public class ProfilePreviewModel : EffectModel
|
||||||
|
{
|
||||||
|
private readonly ProfilePreviewDataModel _previewDataModel;
|
||||||
|
|
||||||
|
public ProfilePreviewModel(MainManager mainManager) : base(mainManager)
|
||||||
|
{
|
||||||
|
Name = "Profile Preview";
|
||||||
|
_previewDataModel = new ProfilePreviewDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProfileModel SelectedProfile { get; set; }
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
Initialized = false;
|
||||||
|
SelectedProfile = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Enable()
|
||||||
|
{
|
||||||
|
Initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
if (SelectedProfile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var layerModel in SelectedProfile.Layers)
|
||||||
|
layerModel.Update<ProfilePreviewDataModel>(_previewDataModel, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Bitmap GenerateBitmap()
|
||||||
|
{
|
||||||
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4);
|
||||||
|
|
||||||
|
if (SelectedProfile == null)
|
||||||
|
return bitmap;
|
||||||
|
|
||||||
|
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(4);
|
||||||
|
var image = SelectedProfile.GenerateBitmap<ProfilePreviewDataModel>(keyboardRect, _previewDataModel, true);
|
||||||
|
|
||||||
|
// Draw on top of everything else
|
||||||
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
|
g.DrawImage(image, 0, 0);
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProfilePreviewDataModel : IGameDataModel
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,9 +9,8 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
{
|
{
|
||||||
public class CounterStrikeModel : GameModel
|
public class CounterStrikeModel : GameModel
|
||||||
{
|
{
|
||||||
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager)
|
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
|
||||||
Name = "CounterStrike";
|
Name = "CounterStrike";
|
||||||
ProcessName = "csgo";
|
ProcessName = "csgo";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
@ -19,8 +18,6 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
Initialized = false;
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterStrikeSettings Settings { get; set; }
|
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|||||||
@ -8,33 +8,15 @@ using Artemis.ViewModels.Abstract;
|
|||||||
|
|
||||||
namespace Artemis.Modules.Games.CounterStrike
|
namespace Artemis.Modules.Games.CounterStrike
|
||||||
{
|
{
|
||||||
public class CounterStrikeViewModel : GameViewModel
|
public class CounterStrikeViewModel : GameViewModel<CounterStrikeDataModel>
|
||||||
{
|
{
|
||||||
public CounterStrikeViewModel(MainManager mainManager)
|
public CounterStrikeViewModel(MainManager mainManager) : base(mainManager, new CounterStrikeModel(mainManager, new CounterStrikeSettings()))
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
|
||||||
|
|
||||||
// Settings are loaded from file by class
|
|
||||||
GameSettings = new CounterStrikeSettings();
|
|
||||||
|
|
||||||
// Create effect model and add it to MainManager
|
// Create effect model and add it to MainManager
|
||||||
GameModel = new CounterStrikeModel(mainManager, (CounterStrikeSettings) GameSettings);
|
|
||||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
PlaceConfigFile();
|
PlaceConfigFile();
|
||||||
|
|
||||||
ProfileEditor = new ProfileEditorViewModel<CounterStrikeDataModel>(MainManager, GameModel);
|
|
||||||
ProfileEditor.PropertyChanged += ProfileUpdater;
|
|
||||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.PropertyName == "SelectedProfile")
|
|
||||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileEditorViewModel<CounterStrikeDataModel> ProfileEditor { get; set; }
|
|
||||||
|
|
||||||
public static string Name => "CS:GO";
|
public static string Name => "CS:GO";
|
||||||
public string Content => "Counter-Strike: GO Content";
|
public string Content => "Counter-Strike: GO Content";
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
namespace Artemis.Modules.Games.Dota2
|
namespace Artemis.Modules.Games.Dota2
|
||||||
{
|
{
|
||||||
class Dota2DataModel
|
public class Dota2DataModel
|
||||||
{
|
{
|
||||||
public class Rootobject
|
public class Rootobject
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,8 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms.VisualStyles;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using Artemis.KeyboardProviders;
|
using Artemis.KeyboardProviders;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
@ -12,26 +10,26 @@ using Artemis.Utilities;
|
|||||||
using Artemis.Utilities.GameState;
|
using Artemis.Utilities.GameState;
|
||||||
using Artemis.Utilities.Keyboard;
|
using Artemis.Utilities.Keyboard;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Color = System.Drawing.Color;
|
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.Dota2
|
namespace Artemis.Modules.Games.Dota2
|
||||||
{
|
{
|
||||||
internal class Dota2Model : GameModel
|
internal class Dota2Model : GameModel
|
||||||
{
|
{
|
||||||
private KeyboardRegion _keyPad;
|
|
||||||
private KeyboardRegion _abilityKeys;
|
private KeyboardRegion _abilityKeys;
|
||||||
|
private KeyboardRegion _keyPad;
|
||||||
private KeyboardRegion _topRow;
|
private KeyboardRegion _topRow;
|
||||||
|
|
||||||
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager)
|
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager, settings)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
|
||||||
Name = "Dota2";
|
Name = "Dota2";
|
||||||
ProcessName = "dota2";
|
ProcessName = "dota2";
|
||||||
|
Settings = settings;
|
||||||
Enabled = Settings.Enabled;
|
Enabled = Settings.Enabled;
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new Dota2Settings Settings { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
@ -72,7 +70,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
|
|
||||||
DayCycleRectangle = new KeyboardRectangle(MainManager.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>()
|
||||||
, LinearGradientMode.Horizontal)
|
, LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -89,17 +87,18 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
private void SetAbilityKeys()
|
private void SetAbilityKeys()
|
||||||
{
|
{
|
||||||
#region Long Switch Statement for Keys
|
#region Long Switch Statement for Keys
|
||||||
|
|
||||||
switch (Settings.KeyboardLayout)
|
switch (Settings.KeyboardLayout)
|
||||||
{
|
{
|
||||||
case "0":
|
case "0":
|
||||||
case "Default": //default
|
case "Default": //default
|
||||||
case "4": //Heroes of newearth
|
case "4": //Heroes of newearth
|
||||||
case "3": //League of Legends
|
case "3": //League of Legends
|
||||||
for (int i = 0; i < AbilityKeysRectangles.Length; i++)
|
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
|
||||||
{
|
{
|
||||||
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.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>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -110,8 +109,8 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
AbilityKeysRectangles[0] = new KeyboardRectangle(MainManager.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>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -119,8 +118,8 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
Width = Scale
|
Width = Scale
|
||||||
};
|
};
|
||||||
AbilityKeysRectangles[1] = new KeyboardRectangle(MainManager.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>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -128,8 +127,8 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
Width = Scale
|
Width = Scale
|
||||||
};
|
};
|
||||||
AbilityKeysRectangles[2] = new KeyboardRectangle(MainManager.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>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -137,8 +136,8 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
Width = Scale
|
Width = Scale
|
||||||
};
|
};
|
||||||
AbilityKeysRectangles[3] = new KeyboardRectangle(MainManager.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>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -148,11 +147,11 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
break;
|
break;
|
||||||
case "1": //MMO
|
case "1": //MMO
|
||||||
case "5": //Smite
|
case "5": //Smite
|
||||||
for (int i = 0; i < AbilityKeysRectangles.Length; i++)
|
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
|
||||||
{
|
{
|
||||||
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.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>(),
|
||||||
LinearGradientMode.Horizontal)
|
LinearGradientMode.Horizontal)
|
||||||
{
|
{
|
||||||
@ -161,8 +160,8 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +183,6 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
UpdateHealth();
|
UpdateHealth();
|
||||||
if (Settings.ShowMana)
|
if (Settings.ShowMana)
|
||||||
UpdateMana();
|
UpdateMana();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateMainColor()
|
private void UpdateMainColor()
|
||||||
@ -202,18 +200,18 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
{
|
{
|
||||||
List<Color> list = null;
|
List<Color> list = null;
|
||||||
if (!D2Json.hero.alive)
|
if (!D2Json.hero.alive)
|
||||||
list = new List<Color> { Color.LightGray };
|
list = new List<Color> {Color.LightGray};
|
||||||
else if (D2Json.hero.disarmed)
|
else if (D2Json.hero.disarmed)
|
||||||
list = new List<Color> { Color.Yellow };
|
list = new List<Color> {Color.Yellow};
|
||||||
else if (D2Json.hero.hexed)
|
else if (D2Json.hero.hexed)
|
||||||
list = new List<Color> { Color.Yellow };
|
list = new List<Color> {Color.Yellow};
|
||||||
else if (D2Json.hero.silenced)
|
else if (D2Json.hero.silenced)
|
||||||
list = new List<Color> { Color.Yellow };
|
list = new List<Color> {Color.Yellow};
|
||||||
else if (D2Json.hero.stunned)
|
else if (D2Json.hero.stunned)
|
||||||
list = new List<Color> { Color.Yellow };
|
list = new List<Color> {Color.Yellow};
|
||||||
else if (D2Json.hero.magicimmune)
|
else if (D2Json.hero.magicimmune)
|
||||||
list = new List<Color> { Color.Lime };
|
list = new List<Color> {Color.Lime};
|
||||||
if(list == null)
|
if (list == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EventRectangle.Colors = list;
|
EventRectangle.Colors = list;
|
||||||
@ -258,14 +256,22 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
if (AbilityKeysRectangles == null)
|
if (AbilityKeysRectangles == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AbilityKeysRectangles[0].Colors = D2Json?.abilities?.ability0?.can_cast == true ? new List<Color>
|
AbilityKeysRectangles[0].Colors = D2Json?.abilities?.ability0?.can_cast == true
|
||||||
{ ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor) } : new List<Color> { ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor) };
|
? new List<Color>
|
||||||
AbilityKeysRectangles[1].Colors = D2Json?.abilities?.ability1?.can_cast == true ? new List<Color>
|
{ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor)}
|
||||||
{ ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor) } : new List<Color> { ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor) };
|
: new List<Color> {ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor)};
|
||||||
AbilityKeysRectangles[2].Colors = D2Json?.abilities?.ability2?.can_cast == true ? new List<Color>
|
AbilityKeysRectangles[1].Colors = D2Json?.abilities?.ability1?.can_cast == true
|
||||||
{ ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor) } : new List<Color> { ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor) };
|
? new List<Color>
|
||||||
AbilityKeysRectangles[3].Colors = D2Json?.abilities?.ability3?.can_cast == true ? new List<Color>
|
{ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor)}
|
||||||
{ ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor) } : new List<Color> { ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor) };
|
: new List<Color> {ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor)};
|
||||||
|
AbilityKeysRectangles[2].Colors = D2Json?.abilities?.ability2?.can_cast == true
|
||||||
|
? new List<Color>
|
||||||
|
{ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor)}
|
||||||
|
: new List<Color> {ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor)};
|
||||||
|
AbilityKeysRectangles[3].Colors = D2Json?.abilities?.ability3?.can_cast == true
|
||||||
|
? new List<Color>
|
||||||
|
{ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor)}
|
||||||
|
: new List<Color> {ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -301,7 +307,6 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
item.Draw(g);
|
item.Draw(g);
|
||||||
}
|
}
|
||||||
DayCycleRectangle.Draw(g);
|
DayCycleRectangle.Draw(g);
|
||||||
|
|
||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
@ -321,7 +326,6 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
|
|
||||||
#region Variables
|
#region Variables
|
||||||
|
|
||||||
public Dota2Settings Settings { get; set; }
|
|
||||||
public Dota2DataModel.Rootobject D2Json { get; set; }
|
public Dota2DataModel.Rootobject D2Json { get; set; }
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
public KeyboardRectangle HealthRectangle { get; set; }
|
public KeyboardRectangle HealthRectangle { get; set; }
|
||||||
@ -329,7 +333,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
public KeyboardRectangle DayCycleRectangle { get; set; }
|
public KeyboardRectangle DayCycleRectangle { get; set; }
|
||||||
public KeyboardRectangle ManaRectangle { get; set; }
|
public KeyboardRectangle ManaRectangle { get; set; }
|
||||||
public KeyboardRectangle[] AbilityKeysRectangles = new KeyboardRectangle[4];
|
public KeyboardRectangle[] AbilityKeysRectangles = new KeyboardRectangle[4];
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,46 +1,41 @@
|
|||||||
using System;
|
using System.IO;
|
||||||
using System.IO;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
|
||||||
using Artemis.Properties;
|
using Artemis.Properties;
|
||||||
using Artemis.ViewModels.Abstract;
|
using Artemis.ViewModels.Abstract;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.Dota2
|
namespace Artemis.Modules.Games.Dota2
|
||||||
{
|
{
|
||||||
public class Dota2ViewModel : GameViewModel
|
public class Dota2ViewModel : GameViewModel<Dota2DataModel>
|
||||||
{
|
{
|
||||||
public Dota2ViewModel(MainManager mainManager)
|
public Dota2ViewModel(MainManager mainManager) : base(mainManager, new Dota2Model(mainManager, new Dota2Settings()))
|
||||||
{
|
{
|
||||||
|
|
||||||
MainManager = mainManager;
|
|
||||||
GameSettings = new Dota2Settings();
|
|
||||||
|
|
||||||
GameModel = new Dota2Model(mainManager, (Dota2Settings) GameSettings);
|
|
||||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
PlaceConfigFile();
|
PlaceConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BindableCollection<string> KeyboardLayouts
|
public BindableCollection<string> KeyboardLayouts => new BindableCollection<string>(new[]
|
||||||
{
|
{
|
||||||
get
|
"Default",
|
||||||
{
|
"MMO",
|
||||||
return new BindableCollection<string>(new[] {"Default","MMO","WASD","League of Legends","Heros of Newearth","Smite"});
|
"WASD",
|
||||||
}
|
"League of Legends",
|
||||||
}
|
"Heros of Newearth",
|
||||||
|
"Smite"
|
||||||
|
});
|
||||||
|
|
||||||
public static string Name => "Dota 2";
|
public static string Name => "Dota 2";
|
||||||
public string Content => "Dota 2 Content";
|
public string Content => "Dota 2 Content";
|
||||||
|
|
||||||
public void BrowseDirectory()
|
public void BrowseDirectory()
|
||||||
{
|
{
|
||||||
var dialog = new FolderBrowserDialog { SelectedPath = ((Dota2Settings)GameSettings).GameDirectory };
|
var dialog = new FolderBrowserDialog {SelectedPath = ((Dota2Settings) GameSettings).GameDirectory};
|
||||||
var result = dialog.ShowDialog();
|
var result = dialog.ShowDialog();
|
||||||
if (result != DialogResult.OK)
|
if (result != DialogResult.OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((Dota2Settings)GameSettings).GameDirectory = dialog.SelectedPath;
|
((Dota2Settings) GameSettings).GameDirectory = dialog.SelectedPath;
|
||||||
NotifyOfPropertyChange(() => GameSettings);
|
NotifyOfPropertyChange(() => GameSettings);
|
||||||
|
|
||||||
GameSettings.Save();
|
GameSettings.Save();
|
||||||
@ -49,23 +44,26 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
|
|
||||||
public void PlaceConfigFile()
|
public void PlaceConfigFile()
|
||||||
{
|
{
|
||||||
if (((Dota2Settings)GameSettings).GameDirectory == string.Empty)
|
if (((Dota2Settings) GameSettings).GameDirectory == string.Empty)
|
||||||
return;
|
return;
|
||||||
if (Directory.Exists(((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg"))
|
if (Directory.Exists(((Dota2Settings) GameSettings).GameDirectory + "/game/dota/cfg"))
|
||||||
{
|
{
|
||||||
var cfgFile = Resources.dotaGamestateConfiguration.Replace("{{port}}",
|
var cfgFile = Resources.dotaGamestateConfiguration.Replace("{{port}}",
|
||||||
MainManager.GameStateWebServer.Port.ToString());
|
MainManager.GameStateWebServer.Port.ToString());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.WriteAllText(
|
File.WriteAllText(
|
||||||
((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
|
((Dota2Settings) GameSettings).GameDirectory +
|
||||||
|
"/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
|
||||||
cfgFile);
|
cfgFile);
|
||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException)
|
catch (DirectoryNotFoundException)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(((Dota2Settings) GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/");
|
Directory.CreateDirectory(((Dota2Settings) GameSettings).GameDirectory +
|
||||||
|
"/game/dota/cfg/gamestate_integration/");
|
||||||
File.WriteAllText(
|
File.WriteAllText(
|
||||||
((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
|
((Dota2Settings) GameSettings).GameDirectory +
|
||||||
|
"/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
|
||||||
cfgFile);
|
cfgFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +73,7 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
|
|
||||||
MainManager.DialogService.ShowErrorMessageBox("Please select a valid Dota 2 directory\n\n" +
|
MainManager.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);
|
||||||
|
|
||||||
GameSettings.Save();
|
GameSettings.Save();
|
||||||
|
|||||||
@ -15,9 +15,8 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
private Memory _memory;
|
private Memory _memory;
|
||||||
private GamePointersCollection _pointer;
|
private GamePointersCollection _pointer;
|
||||||
|
|
||||||
public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager)
|
public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager, settings)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
|
||||||
Name = "RocketLeague";
|
Name = "RocketLeague";
|
||||||
ProcessName = "RocketLeague";
|
ProcessName = "RocketLeague";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
@ -25,8 +24,6 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
Initialized = false;
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RocketLeagueSettings Settings { get; set; }
|
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|||||||
@ -1,37 +1,22 @@
|
|||||||
using System.ComponentModel;
|
using Artemis.Managers;
|
||||||
using Artemis.Managers;
|
|
||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.Memory;
|
using Artemis.Utilities.Memory;
|
||||||
using Artemis.ViewModels;
|
|
||||||
using Artemis.ViewModels.Abstract;
|
using Artemis.ViewModels.Abstract;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.RocketLeague
|
namespace Artemis.Modules.Games.RocketLeague
|
||||||
{
|
{
|
||||||
public class RocketLeagueViewModel : GameViewModel
|
public class RocketLeagueViewModel : GameViewModel<RocketLeagueDataModel>
|
||||||
{
|
{
|
||||||
private string _versionText;
|
private string _versionText;
|
||||||
|
|
||||||
public RocketLeagueViewModel(MainManager mainManager)
|
public RocketLeagueViewModel(MainManager mainManager) : base(mainManager, new RocketLeagueModel(mainManager, new RocketLeagueSettings()))
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
|
||||||
|
|
||||||
// Settings are loaded from file by class
|
|
||||||
GameSettings = new RocketLeagueSettings();
|
|
||||||
|
|
||||||
// Create effect model and add it to MainManager
|
|
||||||
GameModel = new RocketLeagueModel(mainManager, (RocketLeagueSettings) GameSettings);
|
|
||||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
SetVersionText();
|
SetVersionText();
|
||||||
|
|
||||||
ProfileEditor = new ProfileEditorViewModel<RocketLeagueDataModel>(MainManager, GameModel);
|
|
||||||
ProfileEditor.PropertyChanged += ProfileUpdater;
|
|
||||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileEditorViewModel<RocketLeagueDataModel> ProfileEditor { get; set; }
|
|
||||||
|
|
||||||
public static string Name => "Rocket League";
|
public static string Name => "Rocket League";
|
||||||
|
|
||||||
public string VersionText
|
public string VersionText
|
||||||
@ -47,12 +32,6 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
|
|
||||||
public RocketLeagueModel RocketLeagueModel { get; set; }
|
public RocketLeagueModel RocketLeagueModel { get; set; }
|
||||||
|
|
||||||
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.PropertyName == "SelectedProfile")
|
|
||||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetVersionText()
|
private void SetVersionText()
|
||||||
{
|
{
|
||||||
if (!General.Default.EnablePointersUpdate)
|
if (!General.Default.EnablePointersUpdate)
|
||||||
|
|||||||
@ -22,9 +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, TheDivisionSettings settings) : base(mainManager)
|
public TheDivisionModel(MainManager mainManager, TheDivisionSettings settings) : base(mainManager, settings)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
|
||||||
Name = "TheDivision";
|
Name = "TheDivision";
|
||||||
ProcessName = "TheDivision";
|
ProcessName = "TheDivision";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
@ -32,8 +31,6 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
Initialized = false;
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TheDivisionSettings Settings { get; set; }
|
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|||||||
@ -4,24 +4,13 @@ using Artemis.ViewModels.Abstract;
|
|||||||
|
|
||||||
namespace Artemis.Modules.Games.TheDivision
|
namespace Artemis.Modules.Games.TheDivision
|
||||||
{
|
{
|
||||||
public class TheDivisionViewModel : GameViewModel
|
public class TheDivisionViewModel : GameViewModel<TheDivisionDataModel>
|
||||||
{
|
{
|
||||||
public TheDivisionViewModel(MainManager mainManager)
|
public TheDivisionViewModel(MainManager mainManager) : base(mainManager, new TheDivisionModel(mainManager, new TheDivisionSettings()))
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
|
||||||
|
|
||||||
// Settings are loaded from file by class
|
|
||||||
GameSettings = new TheDivisionSettings();
|
|
||||||
|
|
||||||
// Create effect model and add it to MainManager
|
|
||||||
GameModel = new TheDivisionModel(mainManager, (TheDivisionSettings) GameSettings);
|
|
||||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
|
|
||||||
ProfileEditor = new ProfileEditorViewModel<TheDivisionDataModel>(MainManager, GameModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileEditorViewModel<TheDivisionDataModel> ProfileEditor { get; set; }
|
|
||||||
|
|
||||||
public static string Name => "The Division";
|
public static string Name => "The Division";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,9 +18,8 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
private KeyboardRectangle _signRect;
|
private KeyboardRectangle _signRect;
|
||||||
private string _witcherSettings;
|
private string _witcherSettings;
|
||||||
|
|
||||||
public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager)
|
public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager, settings)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
|
||||||
Name = "Witcher3";
|
Name = "Witcher3";
|
||||||
ProcessName = "witcher3";
|
ProcessName = "witcher3";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
@ -31,8 +30,6 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
|
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Witcher3Settings Settings { get; set; }
|
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|||||||
@ -4,14 +4,15 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Properties;
|
using Artemis.Properties;
|
||||||
using Artemis.ViewModels.Abstract;
|
using Artemis.ViewModels.Abstract;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.Witcher3
|
namespace Artemis.Modules.Games.Witcher3
|
||||||
{
|
{
|
||||||
public class Witcher3ViewModel : GameViewModel
|
public class Witcher3ViewModel : GameViewModel<Witcher3DataModel>
|
||||||
{
|
{
|
||||||
public Witcher3ViewModel(MainManager mainManager)
|
public Witcher3ViewModel(MainManager mainManager) : base(mainManager, new Witcher3Model(mainManager, new Witcher3Settings()))
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
MainManager = mainManager;
|
||||||
|
|
||||||
@ -109,4 +110,8 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
MainManager.DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
|
MainManager.DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Witcher3DataModel : IGameDataModel
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
18
Artemis/Artemis/NLog.config
Normal file
18
Artemis/Artemis/NLog.config
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
||||||
|
autoReload="false"
|
||||||
|
throwExceptions="false"
|
||||||
|
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
|
||||||
|
|
||||||
|
<targets>
|
||||||
|
<target name="file" xsi:type="File" maxArchiveFiles="7" fileName="${specialfolder:folder=MyDocuments}/Artemis/logs/${shortdate}.txt"/>
|
||||||
|
<target name="debugger" xsi:type="Debugger" layout="${logger:shortName=True} - ${uppercase:${level}}: ${message}"/>
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<logger name="*" minlevel="Debug" writeTo="file" />
|
||||||
|
<logger name="*" minlevel="Debug" writeTo="debugger" />
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
2601
Artemis/Artemis/NLog.xsd
Normal file
2601
Artemis/Artemis/NLog.xsd
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,38 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
|
using Artemis.Modules.Effects.ProfilePreview;
|
||||||
|
using Artemis.Modules.Games.Witcher3;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
|
||||||
namespace Artemis.ViewModels.Abstract
|
namespace Artemis.ViewModels.Abstract
|
||||||
{
|
{
|
||||||
public abstract class GameViewModel : Screen
|
public abstract class GameViewModel<T> : Screen
|
||||||
{
|
{
|
||||||
|
private bool _doActivate;
|
||||||
|
|
||||||
|
private bool _editorShown;
|
||||||
private GameSettings _gameSettings;
|
private GameSettings _gameSettings;
|
||||||
|
private EffectModel _lastEffect;
|
||||||
|
|
||||||
|
protected GameViewModel(MainManager mainManager, GameModel gameModel)
|
||||||
|
{
|
||||||
|
MainManager = mainManager;
|
||||||
|
GameModel = gameModel;
|
||||||
|
GameSettings = gameModel.Settings;
|
||||||
|
|
||||||
|
ProfileEditor = new ProfileEditorViewModel<T>(MainManager, GameModel);
|
||||||
|
GameModel.Profile = ProfileEditor.SelectedProfile;
|
||||||
|
ProfileEditor.PropertyChanged += ProfileUpdater;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProfileEditorViewModel<T> ProfileEditor { get; set; }
|
||||||
|
|
||||||
public GameModel GameModel { get; set; }
|
public GameModel GameModel { get; set; }
|
||||||
public MainManager MainManager { get; set; }
|
public MainManager MainManager { get; set; }
|
||||||
public event OnLayersUpdatedCallback OnLayersUpdatedCallback;
|
|
||||||
public GameSettings GameSettings
|
public GameSettings GameSettings
|
||||||
{
|
{
|
||||||
get { return _gameSettings; }
|
get { return _gameSettings; }
|
||||||
@ -54,6 +75,63 @@ namespace Artemis.ViewModels.Abstract
|
|||||||
|
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnActivate()
|
||||||
|
{
|
||||||
|
base.OnActivate();
|
||||||
|
|
||||||
|
// OnActive is triggered at odd moments, only activate the profile
|
||||||
|
// preview if OnDeactivate isn't called right after it
|
||||||
|
_doActivate = true;
|
||||||
|
Task.Factory.StartNew(() =>
|
||||||
|
{
|
||||||
|
Thread.Sleep(100);
|
||||||
|
if (_doActivate)
|
||||||
|
SetEditorShown(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate(bool close)
|
||||||
|
{
|
||||||
|
base.OnDeactivate(close);
|
||||||
|
|
||||||
|
_doActivate = false;
|
||||||
|
SetEditorShown(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetEditorShown(bool enable)
|
||||||
|
{
|
||||||
|
if (enable == _editorShown)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
// Store the current effect so it can be restored later
|
||||||
|
if (!(MainManager.EffectManager.ActiveEffect is ProfilePreviewModel))
|
||||||
|
_lastEffect = MainManager.EffectManager.ActiveEffect;
|
||||||
|
|
||||||
|
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||||
|
MainManager.EffectManager.ChangeEffect(MainManager.EffectManager.ProfilePreviewModel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_lastEffect != null)
|
||||||
|
MainManager.EffectManager.ChangeEffect(_lastEffect, true);
|
||||||
|
else
|
||||||
|
MainManager.EffectManager.ClearEffect();
|
||||||
|
}
|
||||||
|
|
||||||
|
_editorShown = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName != "SelectedProfile")
|
||||||
|
return;
|
||||||
|
|
||||||
|
GameModel.Profile = ProfileEditor.SelectedProfile;
|
||||||
|
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void OnLayersUpdatedCallback(object sender);
|
public delegate void OnLayersUpdatedCallback(object sender);
|
||||||
|
|||||||
@ -9,7 +9,6 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Xml.Serialization;
|
|
||||||
using Artemis.DAL;
|
using Artemis.DAL;
|
||||||
using Artemis.Events;
|
using Artemis.Events;
|
||||||
using Artemis.KeyboardProviders;
|
using Artemis.KeyboardProviders;
|
||||||
@ -51,6 +50,10 @@ namespace Artemis.ViewModels
|
|||||||
LoadProfiles();
|
LoadProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProfileEditorViewModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public BindableCollection<ProfileModel> Profiles
|
public BindableCollection<ProfileModel> Profiles
|
||||||
{
|
{
|
||||||
get { return _profiles; }
|
get { return _profiles; }
|
||||||
@ -105,7 +108,8 @@ namespace Artemis.ViewModels
|
|||||||
_selectedProfile = value;
|
_selectedProfile = value;
|
||||||
|
|
||||||
Layers.Clear();
|
Layers.Clear();
|
||||||
Layers.AddRange(_selectedProfile?.Layers);
|
if (_selectedProfile != null)
|
||||||
|
Layers.AddRange(_selectedProfile.Layers);
|
||||||
|
|
||||||
NotifyOfPropertyChange(() => SelectedProfile);
|
NotifyOfPropertyChange(() => SelectedProfile);
|
||||||
NotifyOfPropertyChange(() => CanAddLayer);
|
NotifyOfPropertyChange(() => CanAddLayer);
|
||||||
|
|||||||
@ -14,6 +14,9 @@
|
|||||||
<package id="MahApps.Metro.Resources" version="0.5.0.0" targetFramework="net452" />
|
<package id="MahApps.Metro.Resources" version="0.5.0.0" targetFramework="net452" />
|
||||||
<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="NLog" version="4.3.2" targetFramework="net452" />
|
||||||
|
<package id="NLog.Config" version="4.3.2" 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" />
|
||||||
<package id="SharpDX.DXGI" version="3.0.2" targetFramework="net452" />
|
<package id="SharpDX.DXGI" version="3.0.2" targetFramework="net452" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user