1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Setup keyboard alignments for all Corsair keyboards. Converted Dota2 to use profiles

This commit is contained in:
SpoinkyNL 2016-05-12 23:37:52 +02:00
parent 0739885453
commit 8cb783f5f8
29 changed files with 372 additions and 730 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -368,6 +368,8 @@
<DependentUpon>TheDivisionView.xaml</DependentUpon> <DependentUpon>TheDivisionView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Modules\Games\TheDivision\TheDivisionViewModel.cs" /> <Compile Include="Modules\Games\TheDivision\TheDivisionViewModel.cs" />
<Compile Include="Modules\Games\Witcher3\TheWitcherDataModel.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3DataModel.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3Settings.cs" /> <Compile Include="Modules\Games\Witcher3\Witcher3Settings.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3.Designer.cs"> <Compile Include="Modules\Games\Witcher3\Witcher3.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>

View File

@ -24,7 +24,6 @@ namespace Artemis.KeyboardProviders.Corsair
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\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" + "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>();
} }
public override bool CanEnable() public override bool CanEnable()
@ -74,40 +73,29 @@ namespace Artemis.KeyboardProviders.Corsair
/*CUE is already initialized*/ /*CUE is already initialized*/
} }
_keyboard = CueSDK.KeyboardSDK; _keyboard = CueSDK.KeyboardSDK;
switch (_keyboard.DeviceInfo.Model) if (_keyboard.DeviceInfo.Model == "K95 RGB")
{ {
case "K95 RGB": Height = 7;
Height = 7; Width = 25;
Width = 25; PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k95);
PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k95); }
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(20, 1))); else if (_keyboard.DeviceInfo.Model == "K70 RGB")
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(21, 2), new Point(25, 7))); {
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(5, 3), new Point(8, 3))); Height = 7;
break; Width = 21;
case "K70 RGB": PreviewSettings = new PreviewSettings(626, 195, new Thickness(0, -25, 0, 0), Resources.k70);
Height = 7; }
Width = 21; else if (_keyboard.DeviceInfo.Model == "K65 RGB")
PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k70); {
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1))); Height = 7;
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(17, 2), new Point(21, 7))); Width = 18;
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 3), new Point(5, 3))); PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
break; }
case "K65 RGB": else if (_keyboard.DeviceInfo.Model == "STRAFE RGB")
Height = 7; {
Width = 18; Height = 6;
PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k65); Width = 22;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1))); PreviewSettings = new PreviewSettings(620, 215, new Thickness(0, -15, 0, 0), Resources.strafe);
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(17, 2), new Point(20, 7)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 3), new Point(5, 3)));
break;
case "STRAFE RGB":
Height = 6;
Width = 22;
PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.strafe);
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(18, 2), new Point(22, 7)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(1, 3), new Point(4, 3)));
break;
} }
} }

View File

@ -12,8 +12,6 @@ namespace Artemis.KeyboardProviders
public int Width { get; set; } public int Width { get; set; }
public string CantEnableText { get; set; } public string CantEnableText { get; set; }
public List<KeyboardRegion> KeyboardRegions { get; set; }
public PreviewSettings PreviewSettings { get; set; } public PreviewSettings PreviewSettings { get; set; }
public abstract bool CanEnable(); public abstract bool CanEnable();

View File

@ -21,12 +21,6 @@ namespace Artemis.KeyboardProviders.Logitech
Height = 6; Height = 6;
Width = 21; Width = 21;
PreviewSettings = new PreviewSettings(540, 154, new Thickness(25, -80, 0, 0), Resources.g910); PreviewSettings = new PreviewSettings(540, 154, new Thickness(25, -80, 0, 0), Resources.g910);
KeyboardRegions = new List<KeyboardRegion>
{
new KeyboardRegion("TopRow", new Point(0, 0), new Point(18, 0)),
new KeyboardRegion("NumPad", new Point(17, 1), new Point(21, 6)),
new KeyboardRegion("QWER", new Point(2, 2), new Point(5, 2))
};
} }
public override bool CanEnable() public override bool CanEnable()

View File

@ -32,10 +32,6 @@ namespace Artemis.KeyboardProviders.Razer
Chroma.Instance.Initialize(); Chroma.Instance.Initialize();
Height = Constants.MaxRows; Height = Constants.MaxRows;
Width = Constants.MaxColumns; Width = Constants.MaxColumns;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 0), new Point(19, 0)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(20, 1), new Point(23, 6)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 2), new Point(5, 2)));
} }
public override void Disable() public override void Disable()

View File

@ -94,13 +94,20 @@ namespace Artemis.Managers
_keyboardManager.EnableLastKeyboard(); _keyboardManager.EnableLastKeyboard();
// If still null, no last keyboard, so stop. // If still null, no last keyboard, so stop.
if (_keyboardManager.ActiveKeyboard == null) if (_keyboardManager.ActiveKeyboard == null)
{
_logger.Debug("Cancelling effect change, no LastKeyboard");
return; return;
}
// Game models are only used if they are enabled // Game models are only used if they are enabled
var gameModel = effectModel as GameModel; var gameModel = effectModel as GameModel;
if (gameModel != null) if (gameModel != null)
if (!gameModel.Enabled) if (!gameModel.Enabled)
{
_logger.Debug("Cancelling effect change, provided game not enabled");
return; return;
}
var wasNull = false; var wasNull = false;
if (ActiveEffect == null) if (ActiveEffect == null)
@ -116,13 +123,6 @@ namespace Artemis.Managers
ActiveEffect = effectModel; ActiveEffect = effectModel;
ActiveEffect.Enable(); ActiveEffect.Enable();
if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel)
return;
// Non-game effects are stored as the new LastEffect.
General.Default.LastEffect = ActiveEffect?.Name;
General.Default.Save();
} }
if (loopManager != null && !loopManager.Running) if (loopManager != null && !loopManager.Running)
@ -132,6 +132,13 @@ namespace Artemis.Managers
} }
_logger.Debug("Changed active effect to: {0}", effectModel.Name); _logger.Debug("Changed active effect to: {0}", effectModel.Name);
if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel)
return;
// Non-game effects are stored as the new LastEffect.
General.Default.LastEffect = ActiveEffect?.Name;
General.Default.Save();
} }

View File

@ -135,14 +135,16 @@ namespace Artemis.Managers
if (bitmap == null) if (bitmap == null)
return; return;
// Fill the bitmap's background with blackness to avoid trailing colors on some keyboards // Fill the bitmap's background with black to avoid trailing colors on some keyboards
using (var g = Graphics.FromImage(bitmap)) var fixedBmp = new Bitmap(bitmap.Width, bitmap.Height);
using (var g = Graphics.FromImage(fixedBmp))
{ {
var preFix = (Bitmap)bitmap.Clone();
g.Clear(Color.Black); g.Clear(Color.Black);
g.DrawImage(preFix, 0, 0); g.DrawImage(bitmap, 0, 0);
} }
bitmap = fixedBmp;
// If it exists, send bitmap to the device // If it exists, send bitmap to the device
_keyboardManager.ActiveKeyboard?.DrawBitmap(bitmap); _keyboardManager.ActiveKeyboard?.DrawBitmap(bitmap);

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using Artemis.Events; using Artemis.Events;
using Artemis.Models; using Artemis.Models;
using Artemis.Services; using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Utilities.GameState; using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard; using Artemis.Utilities.Keyboard;
using Artemis.Utilities.LogitechDll; using Artemis.Utilities.LogitechDll;
@ -126,20 +126,31 @@ namespace Artemis.Managers
if (EffectManager.ActiveEffect != null) if (EffectManager.ActiveEffect != null)
EffectManager.DisableInactiveGame(); EffectManager.DisableInactiveGame();
if (EffectManager.ActiveEffect is ProfilePreviewModel)
return;
// If the currently active effect is a no longer running game, get rid of it. // If the currently active effect is a no longer running game, get rid of it.
var activeGame = EffectManager.ActiveEffect as GameModel; var activeGame = EffectManager.ActiveEffect as GameModel;
if (activeGame != null) if (activeGame != null)
{
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false)) if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
{
_logger.Info("Disabling game: {0}", activeGame.Name);
EffectManager.DisableGame(activeGame); EffectManager.DisableGame(activeGame);
}
}
// Look for running games, stopping on the first one that's found. // Look for running games, stopping on the first one that's found.
var newGame = EffectManager.EnabledGames var newGame = EffectManager.EnabledGames
.FirstOrDefault( .FirstOrDefault(g => runningProcesses
g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false)); .Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
// If it's not already enabled, do so. // If it's not already enabled, do so.
if (newGame != null && EffectManager.ActiveEffect != newGame) if (newGame != null && EffectManager.ActiveEffect != newGame)
EffectManager.ChangeEffect(newGame); {
_logger.Info("Detected and enabling game: {0}", newGame.Name);
EffectManager.ChangeEffect(newGame, LoopManager);
}
Thread.Sleep(1000); Thread.Sleep(1000);
} }

View File

@ -1,14 +1,16 @@
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.RocketLeague;
namespace Artemis.Models namespace Artemis.Models
{ {
public abstract class GameModel : EffectModel public abstract class GameModel : EffectModel
{ {
protected GameModel(MainManager mainManager, GameSettings settings) : base(mainManager) protected GameModel(MainManager mainManager, GameSettings settings, IGameDataModel gameDataModel) : base(mainManager)
{ {
Settings = settings; Settings = settings;
GameDataModel = gameDataModel;
} }
public GameSettings Settings { get; set; } public GameSettings Settings { get; set; }

View File

@ -60,7 +60,7 @@ namespace Artemis.Models.Profiles
layerProp.SetValue(props, opacity); layerProp.SetValue(props, opacity);
} }
else else
layerProp.SetValue(props, (int) (percentage*(int) userProp.GetValue(userProps, null))); layerProp.SetValue(props, percentage*(double) userProp.GetValue(userProps, null));
} }
private void ApplyProp(LayerPropertiesModel props, LayerPropertiesModel userProps, IGameDataModel data) private void ApplyProp(LayerPropertiesModel props, LayerPropertiesModel userProps, IGameDataModel data)

View File

@ -11,10 +11,10 @@ namespace Artemis.Models.Profiles
[XmlInclude(typeof(MatrixTransform))] [XmlInclude(typeof(MatrixTransform))]
public class LayerPropertiesModel public class LayerPropertiesModel
{ {
public int X { get; set; } public double X { get; set; }
public int Y { get; set; } public double Y { get; set; }
public int Width { get; set; } public double Width { get; set; }
public int Height { get; set; } public double Height { get; set; }
public double Opacity { get; set; } public double Opacity { get; set; }
public bool ContainedBrush { get; set; } public bool ContainedBrush { get; set; }
public LayerAnimation Animation { get; set; } public LayerAnimation Animation { get; set; }

View File

@ -8,7 +8,7 @@ namespace Artemis.Modules.Games.CounterStrike
{ {
public class CounterStrikeModel : GameModel public class CounterStrikeModel : GameModel
{ {
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings) public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings, new CounterStrikeDataModel())
{ {
Name = "CounterStrike"; Name = "CounterStrike";
ProcessName = "csgo"; ProcessName = "csgo";
@ -29,7 +29,6 @@ namespace Artemis.Modules.Games.CounterStrike
{ {
Initialized = false; Initialized = false;
GameDataModel = new CounterStrikeDataModel();
MainManager.GameStateWebServer.GameDataReceived += HandleGameData; MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true; Initialized = true;

View File

@ -3,8 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="476.986" d:DesignWidth="538.772"> d:DesignHeight="476.986" d:DesignWidth="538.772">
@ -20,8 +18,8 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0"> <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
<Label FontSize="20" HorizontalAlignment="Left"> <Label FontSize="20" HorizontalAlignment="Left">
<Label.Content> <Label.Content>

View File

@ -15,7 +15,6 @@ namespace Artemis.Modules.Games.CounterStrike
{ {
DisplayName = "CS:GO"; DisplayName = "CS:GO";
// Create effect model and add it to MainManager
MainManager.EffectManager.EffectModels.Add(GameModel); MainManager.EffectManager.EffectModels.Add(GameModel);
PlaceConfigFile(); PlaceConfigFile();
} }

View File

@ -1,228 +1,227 @@
namespace Artemis.Modules.Games.Dota2 using Artemis.Models.Interfaces;
namespace Artemis.Modules.Games.Dota2
{ {
public class Dota2DataModel public class Dota2DataModel : IGameDataModel
{ {
public class Rootobject public Provider provider { get; set; }
{ public Map map { get; set; }
public Provider provider { get; set; } public Player player { get; set; }
public Map map { get; set; } public Hero hero { get; set; }
public Player player { get; set; } public Abilities abilities { get; set; }
public Hero hero { get; set; } public Items items { get; set; }
public Abilities abilities { get; set; } public Previously previously { get; set; }
public Items items { get; set; } }
public Previously previously { get; set; }
}
public class Provider public class Provider
{ {
public string name { get; set; } public string name { get; set; }
public int appid { get; set; } public int appid { get; set; }
public int version { get; set; } public int version { get; set; }
public int timestamp { get; set; } public int timestamp { get; set; }
} }
public class Map public class Map
{ {
public string name { get; set; } public string name { get; set; }
public long matchid { get; set; } public long matchid { get; set; }
public int game_time { get; set; } public int game_time { get; set; }
public int clock_time { get; set; } public int clock_time { get; set; }
public bool daytime { get; set; } public bool daytime { get; set; }
public bool nightstalker_night { get; set; } public bool nightstalker_night { get; set; }
public string game_state { get; set; } public string game_state { get; set; }
public string win_team { get; set; } public string win_team { get; set; }
public string customgamename { get; set; } public string customgamename { get; set; }
public int ward_purchase_cooldown { get; set; } public int ward_purchase_cooldown { get; set; }
} }
public class Player public class Player
{ {
public string steamid { get; set; } public string steamid { get; set; }
public string name { get; set; } public string name { get; set; }
public string activity { get; set; } public string activity { get; set; }
public int kills { get; set; } public int kills { get; set; }
public int deaths { get; set; } public int deaths { get; set; }
public int assists { get; set; } public int assists { get; set; }
public int last_hits { get; set; } public int last_hits { get; set; }
public int denies { get; set; } public int denies { get; set; }
public int kill_streak { get; set; } public int kill_streak { get; set; }
public string team_name { get; set; } public string team_name { get; set; }
public int gold { get; set; } public int gold { get; set; }
public int gold_reliable { get; set; } public int gold_reliable { get; set; }
public int gold_unreliable { get; set; } public int gold_unreliable { get; set; }
public int gpm { get; set; } public int gpm { get; set; }
public int xpm { get; set; } public int xpm { get; set; }
} }
public class Hero public class Hero
{ {
public int id { get; set; } public int id { get; set; }
public string name { get; set; } public string name { get; set; }
public int level { get; set; } public int level { get; set; }
public bool alive { get; set; } public bool alive { get; set; }
public int respawn_seconds { get; set; } public int respawn_seconds { get; set; }
public int buyback_cost { get; set; } public int buyback_cost { get; set; }
public int buyback_cooldown { get; set; } public int buyback_cooldown { get; set; }
public int health { get; set; } public int health { get; set; }
public int max_health { get; set; } public int max_health { get; set; }
public int health_percent { get; set; } public int health_percent { get; set; }
public int mana { get; set; } public int mana { get; set; }
public int max_mana { get; set; } public int max_mana { get; set; }
public int mana_percent { get; set; } public int mana_percent { get; set; }
public bool silenced { get; set; } public bool silenced { get; set; }
public bool stunned { get; set; } public bool stunned { get; set; }
public bool disarmed { get; set; } public bool disarmed { get; set; }
public bool magicimmune { get; set; } public bool magicimmune { get; set; }
public bool hexed { get; set; } public bool hexed { get; set; }
public bool muted { get; set; } public bool muted { get; set; }
public bool _break { get; set; } public bool _break { get; set; }
public bool has_debuff { get; set; } public bool has_debuff { get; set; }
} }
public class Abilities public class Abilities
{ {
public Ability0 ability0 { get; set; } public Ability0 ability0 { get; set; }
public Ability1 ability1 { get; set; } public Ability1 ability1 { get; set; }
public Ability2 ability2 { get; set; } public Ability2 ability2 { get; set; }
public Ability3 ability3 { get; set; } public Ability3 ability3 { get; set; }
public Attributes attributes { get; set; } public Attributes attributes { get; set; }
} }
public class Ability0 public class Ability0
{ {
public string name { get; set; } public string name { get; set; }
public int level { get; set; } public int level { get; set; }
public bool can_cast { get; set; } public bool can_cast { get; set; }
public bool passive { get; set; } public bool passive { get; set; }
public bool ability_active { get; set; } public bool ability_active { get; set; }
public int cooldown { get; set; } public int cooldown { get; set; }
public bool ultimate { get; set; } public bool ultimate { get; set; }
} }
public class Ability1 public class Ability1
{ {
public string name { get; set; } public string name { get; set; }
public int level { get; set; } public int level { get; set; }
public bool can_cast { get; set; } public bool can_cast { get; set; }
public bool passive { get; set; } public bool passive { get; set; }
public bool ability_active { get; set; } public bool ability_active { get; set; }
public int cooldown { get; set; } public int cooldown { get; set; }
public bool ultimate { get; set; } public bool ultimate { get; set; }
} }
public class Ability2 public class Ability2
{ {
public string name { get; set; } public string name { get; set; }
public int level { get; set; } public int level { get; set; }
public bool can_cast { get; set; } public bool can_cast { get; set; }
public bool passive { get; set; } public bool passive { get; set; }
public bool ability_active { get; set; } public bool ability_active { get; set; }
public int cooldown { get; set; } public int cooldown { get; set; }
public bool ultimate { get; set; } public bool ultimate { get; set; }
} }
public class Ability3 public class Ability3
{ {
public string name { get; set; } public string name { get; set; }
public int level { get; set; } public int level { get; set; }
public bool can_cast { get; set; } public bool can_cast { get; set; }
public bool passive { get; set; } public bool passive { get; set; }
public bool ability_active { get; set; } public bool ability_active { get; set; }
public int cooldown { get; set; } public int cooldown { get; set; }
public bool ultimate { get; set; } public bool ultimate { get; set; }
} }
public class Attributes public class Attributes
{ {
public int level { get; set; } public int level { get; set; }
} }
public class Items public class Items
{ {
public Slot0 slot0 { get; set; } public Slot0 slot0 { get; set; }
public Slot1 slot1 { get; set; } public Slot1 slot1 { get; set; }
public Slot2 slot2 { get; set; } public Slot2 slot2 { get; set; }
public Slot3 slot3 { get; set; } public Slot3 slot3 { get; set; }
public Slot4 slot4 { get; set; } public Slot4 slot4 { get; set; }
public Slot5 slot5 { get; set; } public Slot5 slot5 { get; set; }
public Stash0 stash0 { get; set; } public Stash0 stash0 { get; set; }
public Stash1 stash1 { get; set; } public Stash1 stash1 { get; set; }
public Stash2 stash2 { get; set; } public Stash2 stash2 { get; set; }
public Stash3 stash3 { get; set; } public Stash3 stash3 { get; set; }
public Stash4 stash4 { get; set; } public Stash4 stash4 { get; set; }
public Stash5 stash5 { get; set; } public Stash5 stash5 { get; set; }
} }
public class Slot0 public class Slot0
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Slot1 public class Slot1
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Slot2 public class Slot2
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Slot3 public class Slot3
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Slot4 public class Slot4
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Slot5 public class Slot5
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Stash0 public class Stash0
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Stash1 public class Stash1
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Stash2 public class Stash2
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Stash3 public class Stash3
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Stash4 public class Stash4
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Stash5 public class Stash5
{ {
public string name { get; set; } public string name { get; set; }
} }
public class Previously public class Previously
{ {
public Player1 player { get; set; } public Player1 player { get; set; }
} }
public class Player1 public class Player1
{ {
public int gold { get; set; } public int gold { get; set; }
public int gold_unreliable { get; set; } public int gold_unreliable { get; set; }
}
} }
} }

View File

@ -1,25 +1,15 @@
using System; using System.Drawing;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.KeyboardProviders;
using Artemis.Managers; using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.Utilities;
using Artemis.Utilities.GameState; using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Artemis.Modules.Games.Dota2 namespace Artemis.Modules.Games.Dota2
{ {
internal class Dota2Model : GameModel internal class Dota2Model : GameModel
{ {
private KeyboardRegion _abilityKeys; public Dota2Model(MainManager mainManager, Dota2Settings settings)
private KeyboardRegion _keyPad; : base(mainManager, settings, new Dota2DataModel())
private KeyboardRegion _topRow;
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager, settings)
{ {
Name = "Dota2"; Name = "Dota2";
ProcessName = "dota2"; ProcessName = "dota2";
@ -29,7 +19,9 @@ namespace Artemis.Modules.Games.Dota2
Scale = 4; Scale = 4;
} }
public int Scale { get; set; }
public new Dota2Settings Settings { get; set; } public new Dota2Settings Settings { get; set; }
public Dota2DataModel D2Json { get; set; }
public override void Dispose() public override void Dispose()
{ {
@ -40,186 +32,17 @@ namespace Artemis.Modules.Games.Dota2
public override void Enable() public override void Enable()
{ {
Initialized = false; Initialized = false;
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
_keyPad = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
_abilityKeys = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "QWER");
HealthRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, 0
, _topRow.BottomRight.Y*Scale
, new List<Color>()
, LinearGradientMode.Horizontal)
{Height = Scale, ContainedBrush = false};
ManaRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, 0
, (_topRow.BottomRight.Y + 1)*Scale
, new List<Color>()
, LinearGradientMode.Horizontal)
{Height = Scale, ContainedBrush = false};
EventRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, 0
, _topRow.TopLeft.X + 3
, new List<Color>()
, LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
,
Width = MainManager.KeyboardManager.ActiveKeyboard.Width*Scale - Scale - 12
};
DayCycleRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, _keyPad.TopLeft.X*Scale
, _keyPad.TopLeft.Y*Scale
, new List<Color>()
, LinearGradientMode.Horizontal)
{
Height = _keyPad.GetRectangle().Height*Scale,
Width = _keyPad.GetRectangle().Width*Scale
};
SetAbilityKeys();
MainManager.GameStateWebServer.GameDataReceived += HandleGameData; MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true; Initialized = true;
} }
private void SetAbilityKeys()
{
#region Long Switch Statement for Keys
switch (Settings.KeyboardLayout)
{
case "0":
case "Default": //default
case "4": //Heroes of newearth
case "3": //League of Legends
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
{
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + i)*Scale - 2,
_abilityKeys.TopLeft.Y*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = Scale,
Width = Scale
};
}
break;
case "2":
AbilityKeysRectangles[0] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
_abilityKeys.TopLeft.X*Scale - 2,
_abilityKeys.TopLeft.Y*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = Scale,
Width = Scale
};
AbilityKeysRectangles[1] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + 2)*Scale - 2,
_abilityKeys.TopLeft.Y*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = Scale,
Width = Scale
};
AbilityKeysRectangles[2] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
_abilityKeys.TopLeft.Y*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = Scale,
Width = Scale
};
AbilityKeysRectangles[3] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
(_abilityKeys.TopLeft.Y + 1)*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = Scale,
Width = Scale
};
break;
case "1": //MMO
case "5": //Smite
for (var i = 0; i < AbilityKeysRectangles.Length; i++)
{
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + i)*Scale - 3,
(_abilityKeys.TopLeft.Y - 1)*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = Scale,
Width = Scale
};
}
break;
}
#endregion
}
public override void Update() public override void Update()
{ {
if (D2Json?.map == null) if (D2Json?.map == null)
return; return;
UpdateMainColor(); UpdateDay();
if (Settings.ShowEvents)
UpdateEvents();
if (Settings.ShowDayCycle)
UpdateDay();
if (!D2Json.hero.alive)
return;
if (Settings.CanCastAbility)
UpdateAbilities();
if (Settings.ShowHealth)
UpdateHealth();
if (Settings.ShowMana)
UpdateMana();
}
private void UpdateMainColor()
{
var list = new List<Color> {ColorHelpers.ToDrawingColor(Settings.MainColor)};
EventRectangle.Colors = list;
DayCycleRectangle.Colors = list;
HealthRectangle.Colors = list;
ManaRectangle.Colors = list;
foreach (var key in AbilityKeysRectangles)
key.Colors = list;
}
private void UpdateEvents()
{
List<Color> list = null;
if (!D2Json.hero.alive)
list = new List<Color> {Color.LightGray};
else if (D2Json.hero.disarmed)
list = new List<Color> {Color.Yellow};
else if (D2Json.hero.hexed)
list = new List<Color> {Color.Yellow};
else if (D2Json.hero.silenced)
list = new List<Color> {Color.Yellow};
else if (D2Json.hero.stunned)
list = new List<Color> {Color.Yellow};
else if (D2Json.hero.magicimmune)
list = new List<Color> {Color.Lime};
if (list == null)
return;
EventRectangle.Colors = list;
DayCycleRectangle.Colors = list;
HealthRectangle.Colors = list;
ManaRectangle.Colors = list;
foreach (var item in AbilityKeysRectangles)
item.Colors = list;
} }
private void UpdateDay() private void UpdateDay()
@ -227,88 +50,19 @@ namespace Artemis.Modules.Games.Dota2
if (D2Json?.map?.daytime == null) if (D2Json?.map?.daytime == null)
return; return;
if (D2Json.map.nightstalker_night)
{
DayCycleRectangle.Colors = new List<Color> {Color.Blue};
return;
}
var timeLeft = 240 - D2Json.map.clock_time%240; var timeLeft = 240 - D2Json.map.clock_time%240;
var timePercentage = 100.00/240*timeLeft; var timePercentage = 100.00/240*timeLeft;
DayCycleRectangle.Width = (int) (_keyPad.GetRectangle().Width*Scale/100.00*timePercentage); // TODO: Insert timePercentage into the DataModel as it will be useful when creating profiles
DayCycleRectangle.Colors = D2Json.map.daytime
? new List<Color> {Color.Yellow}
: new List<Color> {Color.Blue};
}
private void UpdateMana()
{
if (D2Json?.hero == null || D2Json.hero.mana_percent == -1)
return;
var manaPercent = D2Json.hero.mana_percent;
ManaRectangle.Colors = new List<Color> {ColorHelpers.ToDrawingColor(Settings.ManaColor)};
ManaRectangle.Width = (int) Math.Floor(_topRow.GetRectangle().Width*Scale/100.00*manaPercent);
}
private void UpdateAbilities()
{
if (AbilityKeysRectangles == null)
return;
AbilityKeysRectangles[0].Colors = D2Json?.abilities?.ability0?.can_cast == true
? new List<Color>
{ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor)}
: new List<Color> {ColorHelpers.ToDrawingColor(Settings.AbilityCooldownColor)};
AbilityKeysRectangles[1].Colors = D2Json?.abilities?.ability1?.can_cast == true
? new List<Color>
{ColorHelpers.ToDrawingColor(Settings.AbilityReadyColor)}
: 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)};
}
private void UpdateHealth()
{
if (D2Json?.hero == null || D2Json.hero.health_percent == -1)
return;
var healthPercent = D2Json.hero.health_percent;
if (healthPercent > 66)
HealthRectangle.Colors = new List<Color> {Color.Lime};
else if (healthPercent > 33)
HealthRectangle.Colors = new List<Color> {Color.Yellow};
else
HealthRectangle.Colors = new List<Color> {Color.Red};
HealthRectangle.Width = (int) Math.Floor(_topRow.GetRectangle().Width*Scale/100.00*healthPercent);
} }
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); if (Profile == null || GameDataModel == null)
return null;
using (var g = Graphics.FromImage(bitmap)) var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
{ return Profile.GenerateBitmap<Dota2DataModel>(keyboardRect, GameDataModel);
g.Clear(Color.Transparent);
EventRectangle.Draw(g);
HealthRectangle.Draw(g);
ManaRectangle.Draw(g);
foreach (var item in AbilityKeysRectangles)
{
item.Draw(g);
}
DayCycleRectangle.Draw(g);
}
return bitmap;
} }
@ -321,19 +75,7 @@ namespace Artemis.Modules.Games.Dota2
return; return;
// Parse the JSON // Parse the JSON
D2Json = JsonConvert.DeserializeObject<Dota2DataModel.Rootobject>(jsonString); D2Json = JsonConvert.DeserializeObject<Dota2DataModel>(jsonString);
} }
#region Variables
public Dota2DataModel.Rootobject D2Json { get; set; }
public int Scale { get; set; }
public KeyboardRectangle HealthRectangle { get; set; }
public KeyboardRectangle EventRectangle { get; set; }
public KeyboardRectangle DayCycleRectangle { get; set; }
public KeyboardRectangle ManaRectangle { get; set; }
public KeyboardRectangle[] AbilityKeysRectangles = new KeyboardRectangle[4];
#endregion
} }
} }

View File

@ -4,10 +4,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" mc:Ignorable="d"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" d:DesignHeight="476.986" d:DesignWidth="538.772">
mc:Ignorable="d" d:DesignWidth="635" Height="515.691"> <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="0,0,0,-19">
<Grid Margin="15, 5, 15, 5"> <Grid Margin="15, 5, 15, 5">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -18,22 +17,14 @@
<RowDefinition Height="80" /> <RowDefinition Height="80" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0"> <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
<Label FontSize="20" HorizontalAlignment="Left"> <Label FontSize="20" HorizontalAlignment="Left">
<Label.Content> <Label.Content>
<AccessText TextWrapping="Wrap" <AccessText TextWrapping="Wrap"
Text="Shows game states and events from Dota 2." /> Text="Shows verious game states and events on the keyboard." />
</Label.Content> </Label.Content>
</Label> </Label>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
@ -45,7 +36,6 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="1" <StackPanel Grid.Row="1"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="2" Margin="0,0,1,0"> Grid.ColumnSpan="2" Margin="0,0,1,0">
@ -57,118 +47,21 @@
cal:Message.Attach="[Event LostFocus] = [Action PlaceConfigFile]" /> cal:Message.Attach="[Event LostFocus] = [Action PlaceConfigFile]" />
<Button x:Name="BrowseDirectory" Content="..." RenderTransformOrigin="-0.039,-0.944" <Button x:Name="BrowseDirectory" Content="..." RenderTransformOrigin="-0.039,-0.944"
HorizontalAlignment="Right" Width="25" HorizontalAlignment="Right" Width="25"
Style="{DynamicResource SquareButtonStyle}" Height="25" /> Style="{DynamicResource SquareButtonStyle}" Height="26" Margin="0,-2,0,0" />
</Grid> </Grid>
</StackPanel> </StackPanel>
<!-- Main Color --> <!-- Profile editor -->
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Width="114" VerticalAlignment="Center" <ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" Margin="0,0,-30,0" />
Height="16" Margin="0,8">
Main keyboard color
</TextBlock>
<xctk:ColorPicker x:Name="MainColor"
SelectedColor="{Binding Path=GameSettings.MainColor, Mode=TwoWay}"
Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
<!-- Ability Ready Color --> <!-- Buttons -->
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Width="114" VerticalAlignment="Center" <StackPanel Grid.Column="0" Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Bottom">
Height="16" Margin="0,8">
Ability Ready Color
</TextBlock>
<xctk:ColorPicker x:Name="AbilityReadyColor"
SelectedColor="{Binding Path=GameSettings.AbilityReadyColor, Mode=TwoWay}"
Grid.Row="3" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
<!-- Ability on Cooldown Color -->
<TextBlock Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" Width="147" VerticalAlignment="Center"
Height="16" Margin="0,8">
Ability on Cooldown Color
</TextBlock>
<xctk:ColorPicker x:Name="AbilityCooldownColor"
SelectedColor="{Binding Path=GameSettings.AbilityCooldownColor, Mode=TwoWay}"
Grid.Row="4" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
<!-- Abilities Display -->
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Keyboard Template
</TextBlock>
<ComboBox Grid.Row="5" Grid.Column="1" x:Name="KeyboardLayouts"
ItemsSource="{Binding Path=KeyboardLayouts}"
SelectedIndex="{Binding Path=GameSettings.KeyboardLayout}" VerticalAlignment="Center"
HorizontalAlignment="Right"
Width="109" Margin="0,6,0,7" />
<!-- Items Display -->
<TextBlock Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Castable Abilities
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.CanCastAbility, Mode=TwoWay}"
Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Health Display -->
<TextBlock Grid.Row="7" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Display health
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowHealth, Mode=TwoWay}"
Grid.Row="7" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Mana Display-->
<TextBlock Grid.Row="8" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Display mana
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowMana, Mode=TwoWay}"
Grid.Row="8" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Mana Color -->
<TextBlock Grid.Row="9" Grid.Column="0" HorizontalAlignment="Left" Width="114" VerticalAlignment="Center"
Height="16" Margin="0,8">
Mana color
</TextBlock>
<xctk:ColorPicker x:Name="ManaColor"
SelectedColor="{Binding Path=GameSettings.ManaColor, Mode=TwoWay}"
Grid.Row="9" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
<!-- Daytime Display -->
<TextBlock Grid.Row="10" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Display day/night
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowDayCycle, Mode=TwoWay}"
Grid.Row="10" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Dead Display -->
<TextBlock Grid.Row="11" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Show events on the keyboard
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowEvents, Mode=TwoWay}"
Grid.Row="11" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<StackPanel Grid.Column="0" Grid.Row="12" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100" <Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
Style="{DynamicResource SquareButtonStyle}" /> Style="{DynamicResource SquareButtonStyle}" />
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100" <Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
Margin="10,0,0,0" Margin="10,0,0,0"
Style="{DynamicResource SquareButtonStyle}" /> Style="{DynamicResource SquareButtonStyle}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</UserControl> </UserControl>

View File

@ -10,7 +10,7 @@ namespace Artemis.Modules.Games.Dota2
{ {
public sealed class Dota2ViewModel : GameViewModel public sealed class Dota2ViewModel : GameViewModel
{ {
public Dota2ViewModel(MainManager main, IEventAggregator events, IProfileEditorViewModelFactory pFactory) public Dota2ViewModel(MainManager main, IEventAggregator events, IProfileEditorViewModelFactory pFactory)
: base(main, new Dota2Model(main, new Dota2Settings()), events, pFactory) : base(main, new Dota2Model(main, new Dota2Settings()), events, pFactory)
{ {
DisplayName = "Dota 2"; DisplayName = "Dota 2";
@ -18,20 +18,7 @@ namespace Artemis.Modules.Games.Dota2
MainManager.EffectManager.EffectModels.Add(GameModel); MainManager.EffectManager.EffectModels.Add(GameModel);
PlaceConfigFile(); PlaceConfigFile();
} }
public BindableCollection<string> KeyboardLayouts => new BindableCollection<string>(new[]
{
"Default",
"MMO",
"WASD",
"League of Legends",
"Heros of Newearth",
"Smite"
});
public static string Name => "Dota 2";
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};
@ -70,8 +57,7 @@ namespace Artemis.Modules.Games.Dota2
"/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg", "/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
cfgFile); cfgFile);
} }
return; return;
} }

View File

@ -15,7 +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, settings) public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings)
: base(mainManager, settings, new RocketLeagueDataModel())
{ {
Name = "RocketLeague"; Name = "RocketLeague";
ProcessName = "RocketLeague"; ProcessName = "RocketLeague";
@ -41,7 +42,6 @@ namespace Artemis.Modules.Games.RocketLeague
var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName); var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName);
_memory = new Memory(tempProcess); _memory = new Memory(tempProcess);
GameDataModel = new RocketLeagueDataModel();
Initialized = true; Initialized = true;
} }

View File

@ -13,7 +13,6 @@ namespace Artemis.Modules.Games.TheDivision
public class TheDivisionModel : GameModel public class TheDivisionModel : GameModel
{ {
private Wave _ammoWave; private Wave _ammoWave;
private TheDivisionDataModel _dataModel;
private KeyboardRectangle _hpRect; private KeyboardRectangle _hpRect;
private KeyboardRectangle _p2; private KeyboardRectangle _p2;
private KeyboardRectangle _p3; private KeyboardRectangle _p3;
@ -22,7 +21,7 @@ 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, settings) public TheDivisionModel(MainManager mainManager, TheDivisionSettings settings) : base(mainManager, settings, new TheDivisionDataModel())
{ {
Name = "TheDivision"; Name = "TheDivision";
ProcessName = "TheDivision"; ProcessName = "TheDivision";
@ -89,7 +88,6 @@ namespace Artemis.Modules.Games.TheDivision
_stickyHp = new StickyValue<bool>(200); _stickyHp = new StickyValue<bool>(200);
DllManager.PlaceDll(); DllManager.PlaceDll();
_dataModel = new TheDivisionDataModel();
MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage; MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
Initialized = true; Initialized = true;
@ -113,6 +111,7 @@ namespace Artemis.Modules.Games.TheDivision
// Parses Division key data to game data // Parses Division key data to game data
private void InterpertrateDivisionKey(IReadOnlyList<int> parts) private void InterpertrateDivisionKey(IReadOnlyList<int> parts)
{ {
var gameDataModel = (TheDivisionDataModel)GameDataModel;
var keyCode = parts[1]; var keyCode = parts[1];
var rPer = parts[2]; var rPer = parts[2];
var gPer = parts[3]; var gPer = parts[3];
@ -132,39 +131,40 @@ namespace Artemis.Modules.Games.TheDivision
newState = PlayerState.Offline; newState = PlayerState.Offline;
if (playerId == 1) if (playerId == 1)
_dataModel.PartyMember1 = newState; gameDataModel.PartyMember1 = newState;
else if (playerId == 2) else if (playerId == 2)
_dataModel.PartyMember2 = newState; gameDataModel.PartyMember2 = newState;
else if (playerId == 3) else if (playerId == 3)
_dataModel.PartyMember3 = newState; gameDataModel.PartyMember3 = newState;
} }
// R blinks white when low on ammo // R blinks white when low on ammo
else if (keyCode == 19) else if (keyCode == 19)
{ {
_stickyAmmo.Value = rPer == 100 && gPer > 1 && bPer > 1; _stickyAmmo.Value = rPer == 100 && gPer > 1 && bPer > 1;
_dataModel.LowAmmo = _stickyAmmo.Value; gameDataModel.LowAmmo = _stickyAmmo.Value;
} }
// G turns white when holding a grenade, turns off when out of grenades // G turns white when holding a grenade, turns off when out of grenades
else if (keyCode == 34) else if (keyCode == 34)
{ {
if (rPer == 100 && gPer < 10 && bPer < 10) if (rPer == 100 && gPer < 10 && bPer < 10)
_dataModel.GrenadeState = GrenadeState.HasGrenade; gameDataModel.GrenadeState = GrenadeState.HasGrenade;
else if (rPer == 100 && gPer > 10 && bPer > 10) else if (rPer == 100 && gPer > 10 && bPer > 10)
_dataModel.GrenadeState = GrenadeState.GrenadeEquipped; gameDataModel.GrenadeState = GrenadeState.GrenadeEquipped;
else else
_dataModel.GrenadeState = GrenadeState.HasNoGrenade; gameDataModel.GrenadeState = GrenadeState.HasNoGrenade;
} }
// V blinks on low HP // V blinks on low HP
else if (keyCode == 47) else if (keyCode == 47)
{ {
_stickyHp.Value = rPer == 100 && gPer > 1 && bPer > 1; _stickyHp.Value = rPer == 100 && gPer > 1 && bPer > 1;
_dataModel.LowHp = _stickyHp.Value; gameDataModel.LowHp = _stickyHp.Value;
} }
} }
public override void Update() public override void Update()
{ {
if (_dataModel.LowAmmo) var gameDataModel = (TheDivisionDataModel)GameDataModel;
if (gameDataModel.LowAmmo)
{ {
_ammoWave.Size++; _ammoWave.Size++;
if (_ammoWave.Size > 30) if (_ammoWave.Size > 30)
@ -176,27 +176,27 @@ namespace Artemis.Modules.Games.TheDivision
else else
_ammoWave.Size = 0; _ammoWave.Size = 0;
_hpRect.Colors = _dataModel.LowHp _hpRect.Colors = gameDataModel.LowHp
? new List<Color> {Color.Red, Color.Orange} ? new List<Color> {Color.Red, Color.Orange}
: new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)}; : new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)};
if (_dataModel.PartyMember1 == PlayerState.Offline) if (gameDataModel.PartyMember1 == PlayerState.Offline)
_p2.Colors = new List<Color> {Color.Gray, Color.White}; _p2.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.PartyMember1 == PlayerState.Online) else if (gameDataModel.PartyMember1 == PlayerState.Online)
_p2.Colors = new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)}; _p2.Colors = new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)};
else else
_p2.Colors = new List<Color> {Color.Red, Color.Orange}; _p2.Colors = new List<Color> {Color.Red, Color.Orange};
if (_dataModel.PartyMember2 == PlayerState.Offline) if (gameDataModel.PartyMember2 == PlayerState.Offline)
_p3.Colors = new List<Color> {Color.Gray, Color.White}; _p3.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.PartyMember2 == PlayerState.Online) else if (gameDataModel.PartyMember2 == PlayerState.Online)
_p3.Colors = new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)}; _p3.Colors = new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)};
else else
_p3.Colors = new List<Color> {Color.Red, Color.Orange}; _p3.Colors = new List<Color> {Color.Red, Color.Orange};
if (_dataModel.PartyMember3 == PlayerState.Offline) if (gameDataModel.PartyMember3 == PlayerState.Offline)
_p4.Colors = new List<Color> {Color.Gray, Color.White}; _p4.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.PartyMember3 == PlayerState.Online) else if (gameDataModel.PartyMember3 == PlayerState.Online)
_p4.Colors = new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)}; _p4.Colors = new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45)};
else else
_p4.Colors = new List<Color> {Color.Red, Color.Orange}; _p4.Colors = new List<Color> {Color.Red, Color.Orange};

View File

@ -0,0 +1,18 @@
using Artemis.Models.Interfaces;
namespace Artemis.Modules.Games.Witcher3
{
public class TheWitcherDataModel : IGameDataModel
{
public WitcherSign WitcherSign { get; set; }
}
public enum WitcherSign
{
Aard,
Yrden,
Igni,
Quen,
Axii
}
}

View File

@ -0,0 +1,8 @@
using Artemis.Models.Interfaces;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3DataModel : IGameDataModel
{
}
}

View File

@ -18,7 +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, settings) public Witcher3Model(MainManager mainManager, Witcher3Settings settings)
: base(mainManager, settings, new TheWitcherDataModel())
{ {
Name = "Witcher3"; Name = "Witcher3";
ProcessName = "witcher3"; ProcessName = "witcher3";
@ -64,6 +65,7 @@ namespace Artemis.Modules.Games.Witcher3
public override void Update() public override void Update()
{ {
var gameDataModel = (TheWitcherDataModel) GameDataModel;
// Witcher effect is very static and reads from disk, don't want to update too often. // Witcher effect is very static and reads from disk, don't want to update too often.
if (_updateSw.ElapsedMilliseconds < 500) if (_updateSw.ElapsedMilliseconds < 500)
return; return;
@ -72,10 +74,8 @@ namespace Artemis.Modules.Games.Witcher3
if (_witcherSettings == null) if (_witcherSettings == null)
return; return;
var reader = new StreamReader(File.Open(_witcherSettings, var reader = new StreamReader(
FileMode.Open, File.Open(_witcherSettings, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
FileAccess.Read,
FileShare.ReadWrite));
var configContent = reader.ReadToEnd(); var configContent = reader.ReadToEnd();
reader.Close(); reader.Close();
@ -87,32 +87,30 @@ namespace Artemis.Modules.Games.Witcher3
switch (sign) switch (sign)
{ {
case "ST_Aard\r": case "ST_Aard\r":
_signRect.Colors = new List<Color> {Color.DeepSkyBlue, Color.Blue}; gameDataModel.WitcherSign = WitcherSign.Aard;
break; break;
case "ST_Yrden\r": case "ST_Yrden\r":
_signRect.Colors = new List<Color> {Color.Purple, Color.DeepPink}; gameDataModel.WitcherSign = WitcherSign.Yrden;
break; break;
case "ST_Igni\r": case "ST_Igni\r":
_signRect.Colors = new List<Color> {Color.DarkOrange, Color.Red}; gameDataModel.WitcherSign = WitcherSign.Igni;
break; break;
case "ST_Quen\r": case "ST_Quen\r":
_signRect.Colors = new List<Color> {Color.DarkOrange, Color.FromArgb(232, 193, 0)}; gameDataModel.WitcherSign = WitcherSign.Quen;
break; break;
case "ST_Axii\r": case "ST_Axii\r":
_signRect.Colors = new List<Color> {Color.LawnGreen, Color.DarkGreen}; gameDataModel.WitcherSign = WitcherSign.Axii;
break; break;
} }
} }
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); if (Profile == null || GameDataModel == null)
using (var g = Graphics.FromImage(bitmap)) return null;
{
g.Clear(Color.Transparent); var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
_signRect.Draw(g); return Profile.GenerateBitmap<TheWitcherDataModel>(keyboardRect, GameDataModel);
}
return bitmap;
} }
} }
} }

View File

@ -5,7 +5,6 @@ using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.InjectionFactories; using Artemis.InjectionFactories;
using Artemis.Managers; using Artemis.Managers;
using Artemis.Models.Interfaces;
using Artemis.Properties; using Artemis.Properties;
using Artemis.ViewModels.Abstract; using Artemis.ViewModels.Abstract;
using Caliburn.Micro; using Caliburn.Micro;
@ -107,8 +106,4 @@ namespace Artemis.Modules.Games.Witcher3
DialogService.ShowMessageBox("Success", "The mod was successfully installed!"); DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
} }
} }
public class Witcher3DataModel : IGameDataModel
{
}
} }

View File

@ -46,13 +46,21 @@ namespace Artemis.Utilities.Memory
/// <returns></returns> /// <returns></returns>
protected ProcessModule FindModule(string name) protected ProcessModule FindModule(string name)
{ {
if (string.IsNullOrEmpty(name)) try
throw new ArgumentNullException("name");
foreach (ProcessModule module in Process.Modules)
{ {
if (module.ModuleName.ToLower() == name.ToLower()) if (string.IsNullOrEmpty(name))
return module; throw new ArgumentNullException("name");
foreach (ProcessModule module in Process.Modules)
{
if (module.ModuleName.ToLower() == name.ToLower())
return module;
}
} }
catch (Exception)
{
return null;
}
return null; return null;
} }

View File

@ -6,6 +6,8 @@ using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Media; using System.Windows.Media;
using Artemis.KeyboardProviders; using Artemis.KeyboardProviders;
using Artemis.Models;
using Artemis.Models.Interfaces;
using Artemis.Models.Profiles; using Artemis.Models.Profiles;
using Artemis.Services; using Artemis.Services;
using Artemis.Utilities; using Artemis.Utilities;
@ -15,7 +17,7 @@ using Screen = Caliburn.Micro.Screen;
namespace Artemis.ViewModels.LayerEditor namespace Artemis.ViewModels.LayerEditor
{ {
public class LayerEditorViewModel : Screen public sealed class LayerEditorViewModel : Screen
{ {
private readonly KeyboardProvider _activeKeyboard; private readonly KeyboardProvider _activeKeyboard;
private readonly BackgroundWorker _previewWorker; private readonly BackgroundWorker _previewWorker;
@ -25,7 +27,7 @@ namespace Artemis.ViewModels.LayerEditor
private LayerModel _proposedLayer; private LayerModel _proposedLayer;
private LayerPropertiesModel _proposedProperties; private LayerPropertiesModel _proposedProperties;
public LayerEditorViewModel(KeyboardProvider activeKeyboard, LayerModel layer) public LayerEditorViewModel(IGameDataModel gameDataModel, KeyboardProvider activeKeyboard, LayerModel layer)
{ {
_activeKeyboard = activeKeyboard; _activeKeyboard = activeKeyboard;
_wasEnabled = layer.Enabled; _wasEnabled = layer.Enabled;
@ -36,7 +38,7 @@ namespace Artemis.ViewModels.LayerEditor
Layer.Enabled = false; Layer.Enabled = false;
DataModelProps = new BindableCollection<GeneralHelpers.PropertyCollection>(); DataModelProps = new BindableCollection<GeneralHelpers.PropertyCollection>();
ProposedProperties = new LayerPropertiesModel(); ProposedProperties = new LayerPropertiesModel();
//DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap<T>()); DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap(gameDataModel));
LayerConditionVms = LayerConditionVms =
new BindableCollection<LayerConditionViewModel>( new BindableCollection<LayerConditionViewModel>(
layer.LayerConditions.Select(c => new LayerConditionViewModel(this, c, DataModelProps))); layer.LayerConditions.Select(c => new LayerConditionViewModel(this, c, DataModelProps)));

View File

@ -265,7 +265,7 @@ namespace Artemis.ViewModels
public void LayerEditor(LayerModel layer) public void LayerEditor(LayerModel layer)
{ {
IWindowManager manager = new WindowManager(); IWindowManager manager = new WindowManager();
_editorVm = new LayerEditorViewModel(ActiveKeyboard, layer); _editorVm = new LayerEditorViewModel(_gameModel.GameDataModel, ActiveKeyboard, layer);
dynamic settings = new ExpandoObject(); dynamic settings = new ExpandoObject();
settings.Title = "Artemis | Edit " + layer.Name; settings.Title = "Artemis | Edit " + layer.Name;

View File

@ -133,9 +133,6 @@ namespace Artemis.ViewModels
{ {
MainManager.Dispose(); MainManager.Dispose();
Application.Current.Shutdown(); Application.Current.Shutdown();
// Sometimes you need to be rough.
Environment.Exit(0);
} }
} }
} }