diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config
index 0de9f6336..6eb4fe3f8 100644
--- a/Artemis/Artemis/App.config
+++ b/Artemis/Artemis/App.config
@@ -30,6 +30,12 @@
+
+ True
+
+
+ True
+
diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 0f459c912..b542dc1d8 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -435,6 +435,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+ Designer
SettingsSingleFileGenerator
@@ -474,6 +475,7 @@
+
@@ -567,7 +569,7 @@
PreserveNewest
-
+
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs
index bfcfda60b..56031a7e0 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeViewModel.cs
@@ -44,7 +44,7 @@ namespace Artemis.Modules.Games.CounterStrike
return;
if (Directory.Exists(((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg"))
{
- var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}",
+ var cfgFile = Resources.csgoGamestateConfiguration.Replace("{{port}}",
MainManager.GameStateWebServer.Port.ToString());
File.WriteAllText(
((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg",
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs
index 6f9530bef..f40fe2afa 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs
@@ -46,5 +46,29 @@ namespace Artemis.Modules.Games.Dota2 {
this["GameDirectory"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool CanCastAbility {
+ get {
+ return ((bool)(this["CanCastAbility"]));
+ }
+ set {
+ this["CanCastAbility"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool ShowHealth {
+ get {
+ return ((bool)(this["ShowHealth"]));
+ }
+ set {
+ this["ShowHealth"] = value;
+ }
+ }
}
}
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings b/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings
index a9a33f1de..7444214e6 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings
@@ -8,5 +8,11 @@
+
+ True
+
+
+ True
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs
index a5fbff92b..64e4d7176 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs
@@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
using System.Drawing;
+using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Artemis.KeyboardProviders;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities.GameState;
+using Artemis.Utilities.Keyboard;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -14,6 +17,8 @@ namespace Artemis.Modules.Games.Dota2
{
class Dota2Model : GameModel
{
+
+ private KeyboardRegion _topRow;
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager)
{
Settings = settings;
@@ -29,50 +34,81 @@ namespace Artemis.Modules.Games.Dota2
public Dota2Settings Settings { get; set; }
public JObject D2Json { get; set; }
public int Scale { get; set; }
+ public KeyboardRectangle HealthRect { get; set; }
+
#endregion
public override void Dispose()
{
- Initialized = false;
+ Initialized = false;
MainManager.GameStateWebServer.GameDataReceived -= HandleGameData;
}
public override void Enable()
{
Initialized = false;
-
+ _topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
+ HealthRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X,
+ new List(),
+ LinearGradientMode.Horizontal)
+ { Height = Scale, ContainedBrush = false };
MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true;
}
public override void Update()
{
- throw new NotImplementedException();
+ if (D2Json == null)
+ return;
+
+ if (Settings.CanCastAbility)
+ UpdateAbilities();
+ if (Settings.ShowHealth)
+ UpdateHealth();
+ }
+
+ private void UpdateHealth()
+ {
+ var health = D2Json["hero"]["health_percent"];
+ if((int)health > 66)
+ HealthRect.Colors = new List { Color.Lime };
+ else if ((int) health > 33)
+ HealthRect.Colors = new List {Color.Yellow};
+ else
+ HealthRect.Colors = new List {Color.Red};
+
+ }
+
+ private void UpdateAbilities()
+ {
+ //Update keys according to the abilities they take.
}
public override Bitmap GenerateBitmap()
{
- var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
-
- using (var g = Graphics.FromImage(bitmap))
- {
- g.Clear(Color.Transparent);
- }
+ var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
+
+ using (var g = Graphics.FromImage(bitmap))
+ {
+ g.Clear(Color.Transparent);
+ HealthRect.Draw(g);
+ }
return bitmap;
}
- public void HandleGameData(object sender, GameDataReceivedEventArgs e)
- {
- var jsonString = e.Json.ToString();
-
- // Ensure it's CS:GO JSON
- if (!jsonString.Contains("Dota 2"))
- return;
-
- // Parse the JSON
- D2Json = JsonConvert.DeserializeObject(jsonString);
+
+ public void HandleGameData(object sender, GameDataReceivedEventArgs e)
+ {
+ var jsonString = e.Json.ToString();
+
+ // Ensure it's Dota 2 JSON
+ if (!jsonString.Contains("Dota 2"))
+ return;
+
+ // Parse the JSON
+ D2Json = JsonConvert.DeserializeObject(jsonString);
}
}
}
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs
index 6ee180183..f9a87cd21 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs
@@ -18,23 +18,31 @@ namespace Artemis.Modules.Games.Dota2
#region Variables
public string GameDirectory { get; set; }
+ public bool CanCastAbility { get; set; }
+ public bool ShowHealth { get; set; }
#endregion
public override void Load()
{
+ ShowHealth = Dota2.Default.ShowHealth;
+ CanCastAbility = Dota2.Default.CanCastAbility;
Enabled = Dota2.Default.Enabled;
GameDirectory = Dota2.Default.GameDirectory;
}
public override void Save()
{
+ Dota2.Default.ShowHealth = ShowHealth;
+ Dota2.Default.CanCastAbility = CanCastAbility;
Dota2.Default.Enabled = Enabled;
Dota2.Default.GameDirectory = GameDirectory;
}
public override void ToDefault()
{
+ ShowHealth = true;
+ CanCastAbility = true;
Enabled = false;
GameDirectory = string.Empty;
}
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml
index 903ad837d..5a90707c4 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml
@@ -1,59 +1,88 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ xmlns:cal="http://www.caliburnproject.org"
+ xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
+ mc:Ignorable="d"
+ d:DesignHeight="424" d:DesignWidth="635">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Show abilities that can be cast.
+
+
+
+
+
+ Show health on F-Keys.
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs
index a967d193d..73f1c9dde 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2ViewModel.cs
@@ -1,61 +1,73 @@
-using System.IO;
-using System.Windows.Forms;
-using Artemis.Managers;
-using Artemis.Properties;
-using Artemis.ViewModels.Abstract;
-
-namespace Artemis.Modules.Games.Dota2
-{
- public class Dota2ViewModel : GameViewModel
- {
- public Dota2ViewModel(MainManager mainManager)
- {
- MainManager = mainManager;
- GameSettings = new Dota2Settings();
-
- GameModel = new Dota2Model(mainManager, (Dota2Settings) GameSettings);
- MainManager.EffectManager.EffectModels.Add(GameModel);
- PlaceConfigFile();
- }
-
- public static string Name => "Dota 2";
- public string Content => "Dota 2 Content";
+using System;
+using System.IO;
+using System.Windows.Forms;
+using Artemis.Managers;
+using Artemis.Properties;
+using Artemis.ViewModels.Abstract;
- public void BrowseDirectory()
- {
- var dialog = new FolderBrowserDialog { SelectedPath = ((Dota2Settings)GameSettings).GameDirectory };
- var result = dialog.ShowDialog();
- if (result != DialogResult.OK)
- return;
-
- ((Dota2Settings)GameSettings).GameDirectory = dialog.SelectedPath;
- NotifyOfPropertyChange(() => GameSettings);
-
- GameSettings.Save();
- PlaceConfigFile();
+namespace Artemis.Modules.Games.Dota2
+{
+ public class Dota2ViewModel : GameViewModel
+ {
+ public Dota2ViewModel(MainManager mainManager)
+ {
+ MainManager = mainManager;
+ GameSettings = new Dota2Settings();
+
+ GameModel = new Dota2Model(mainManager, (Dota2Settings) GameSettings);
+ MainManager.EffectManager.EffectModels.Add(GameModel);
+ PlaceConfigFile();
}
- public void PlaceConfigFile()
- {
- if (((Dota2Settings)GameSettings).GameDirectory == string.Empty)
- return;
- if (Directory.Exists(((Dota2Settings)GameSettings).GameDirectory + "/dota2/cfg"))
- {
- var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}",
- MainManager.GameStateWebServer.Port.ToString());
- File.WriteAllText(
- ((Dota2Settings)GameSettings).GameDirectory + "/dota2/cfg/gamestate_integration_artemis.cfg",
- cfgFile);
-
- return;
- }
-
- MainManager.DialogService.ShowErrorMessageBox("Please select a valid Dota 2 directory\n\n" +
- @"By default Dota 2 is in \SteamApps\common\Dota2");
- ((Dota2Settings)GameSettings).GameDirectory = string.Empty;
- NotifyOfPropertyChange(() => GameSettings);
-
- GameSettings.Save();
- }
- }
+ public static string Name => "Dota 2";
+ public string Content => "Dota 2 Content";
+
+ public void BrowseDirectory()
+ {
+ var dialog = new FolderBrowserDialog { SelectedPath = ((Dota2Settings)GameSettings).GameDirectory };
+ var result = dialog.ShowDialog();
+ if (result != DialogResult.OK)
+ return;
+
+ ((Dota2Settings)GameSettings).GameDirectory = dialog.SelectedPath;
+ NotifyOfPropertyChange(() => GameSettings);
+
+ GameSettings.Save();
+ PlaceConfigFile();
+ }
+
+ public void PlaceConfigFile()
+ {
+ if (((Dota2Settings)GameSettings).GameDirectory == string.Empty)
+ return;
+ if (Directory.Exists(((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg"))
+ {
+ var cfgFile = Resources.dotaGamestateConfiguration.Replace("{{port}}",
+ MainManager.GameStateWebServer.Port.ToString());
+ try
+ {
+ File.WriteAllText(
+ ((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
+ cfgFile);
+ }
+ catch (DirectoryNotFoundException)
+ {
+ Directory.CreateDirectory(((Dota2Settings) GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/");
+ File.WriteAllText(
+ ((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
+ cfgFile);
+ }
+
+
+ return;
+ }
+
+ MainManager.DialogService.ShowErrorMessageBox("Please select a valid Dota 2 directory\n\n" +
+ @"By default Dota 2 is in \SteamApps\common\Dota2");
+ ((Dota2Settings)GameSettings).GameDirectory = string.Empty;
+ NotifyOfPropertyChange(() => GameSettings);
+
+ GameSettings.Save();
+ }
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Properties/Resources.Designer.cs b/Artemis/Artemis/Properties/Resources.Designer.cs
index 1d5940ce5..41a8288e4 100644
--- a/Artemis/Artemis/Properties/Resources.Designer.cs
+++ b/Artemis/Artemis/Properties/Resources.Designer.cs
@@ -61,14 +61,14 @@ namespace Artemis.Properties {
}
///
- /// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-16"?>
- ///<!-- Used by Artemis to get the active Sign -->
- ///<UserConfig>
- /// <Group id="Artemis" displayName="Artemis">
- /// <VisibleVars>
- /// <Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
- /// </VisibleVars>
- /// </Group>
+ /// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-16"?>
+ ///<!-- Used by Artemis to get the active Sign -->
+ ///<UserConfig>
+ /// <Group id="Artemis" displayName="Artemis">
+ /// <VisibleVars>
+ /// <Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
+ /// </VisibleVars>
+ /// </Group>
///</UserConfig>.
///
internal static string artemisXml {
@@ -88,28 +88,53 @@ namespace Artemis.Properties {
}
///
- /// Looks up a localized string similar to "Artemis"
- ///{
- /// "uri" "http://localhost:{{port}}/csgo_game_event"
- /// "timeout" "5.0"
- /// "buffer" "0.1"
- /// "throttle" "0.1"
- /// "heartbeat" "30.0"
- /// "data"
- /// {
- /// "provider" "1"
- /// "map" "1"
- /// "round" "1"
- /// "player_id" "1"
- /// "player_state" "1"
- /// "player_weapons" "1"
- /// "player_match_stats" "1"
- /// }
+ /// Looks up a localized string similar to "Artemis"
+ ///{
+ /// "uri" "http://localhost:{{port}}/csgo_game_event"
+ /// "timeout" "5.0"
+ /// "buffer" "0.1"
+ /// "throttle" "0.1"
+ /// "heartbeat" "30.0"
+ /// "data"
+ /// {
+ /// "provider" "1"
+ /// "map" "1"
+ /// "round" "1"
+ /// "player_id" "1"
+ /// "player_state" "1"
+ /// "player_weapons" "1"
+ /// "player_match_stats" "1"
+ /// }
///}.
///
- internal static string gamestateConfiguration {
+ internal static string csgoGamestateConfiguration {
get {
- return ResourceManager.GetString("gamestateConfiguration", resourceCulture);
+ return ResourceManager.GetString("csgoGamestateConfiguration", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to "Artemis"
+ ///{
+ /// "uri" "http://localhost:4000/"
+ /// "timeout" "5.0"
+ /// "buffer" "0.1"
+ /// "throttle" "0.1"
+ /// "heartbeat" "30.0"
+ /// "data"
+ /// {
+ /// "provider" "1"
+ /// "map" "1"
+ /// "player" "1"
+ /// "hero" "1"
+ /// "abilities" "1"
+ /// "items" "1"
+ /// }
+ ///}.
+ ///
+ internal static string dotaGamestateConfiguration {
+ get {
+ return ResourceManager.GetString("dotaGamestateConfiguration", resourceCulture);
}
}
diff --git a/Artemis/Artemis/Properties/Resources.resx b/Artemis/Artemis/Properties/Resources.resx
index 1fa4c4c83..8bb379458 100644
--- a/Artemis/Artemis/Properties/Resources.resx
+++ b/Artemis/Artemis/Properties/Resources.resx
@@ -124,8 +124,11 @@
..\Resources\bow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\resources\counterstrike\gamestateconfiguration.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+ ..\resources\counterstrike\csgoGamestateconfiguration.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+
+ ..\resources\dota2\dotaGamestateconfiguration.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
..\Resources\logo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/Artemis/Artemis/Resources/CounterStrike/gamestateConfiguration.txt b/Artemis/Artemis/Resources/CounterStrike/csgoGamestateConfiguration.txt
similarity index 100%
rename from Artemis/Artemis/Resources/CounterStrike/gamestateConfiguration.txt
rename to Artemis/Artemis/Resources/CounterStrike/csgoGamestateConfiguration.txt
diff --git a/Artemis/Artemis/Resources/Dota2/dotaGamestateConfiguration.txt b/Artemis/Artemis/Resources/Dota2/dotaGamestateConfiguration.txt
new file mode 100644
index 000000000..0ae517634
--- /dev/null
+++ b/Artemis/Artemis/Resources/Dota2/dotaGamestateConfiguration.txt
@@ -0,0 +1,17 @@
+"Artemis"
+{
+ "uri" "http://localhost:{{port}}/"
+ "timeout" "5.0"
+ "buffer" "0.1"
+ "throttle" "0.1"
+ "heartbeat" "30.0"
+ "data"
+ {
+ "provider" "1"
+ "map" "1"
+ "player" "1"
+ "hero" "1"
+ "abilities" "1"
+ "items" "1"
+ }
+}
\ No newline at end of file