diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config index eb58324d3..6eb4fe3f8 100644 --- a/Artemis/Artemis/App.config +++ b/Artemis/Artemis/App.config @@ -3,6 +3,7 @@ +
@@ -22,6 +23,20 @@ + + + True + + + + + + True + + + True + + True diff --git a/Artemis/Artemis/App.xaml b/Artemis/Artemis/App.xaml index 110eccc23..bae7d6958 100644 --- a/Artemis/Artemis/App.xaml +++ b/Artemis/Artemis/App.xaml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - + xmlns:artemis="clr-namespace:Artemis" + DispatcherUnhandledException="Application_DispatcherUnhandledException" + ShutdownMode="OnExplicitShutdown"> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 7962bd8fc..de223736e 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -293,6 +293,14 @@ + + True + True + Dota2.settings + + + + RocketLeague.settings True @@ -430,6 +438,7 @@ ResXFileCodeGenerator Resources.Designer.cs + Designer SettingsSingleFileGenerator @@ -443,6 +452,10 @@ SettingsSingleFileGenerator CounterStrike.Designer.cs + + SettingsSingleFileGenerator + Dota2.Designer.cs + SettingsSingleFileGenerator RocketLeague.Designer.cs @@ -465,6 +478,7 @@ + @@ -559,7 +573,7 @@ PreserveNewest - + diff --git a/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs b/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs index cc33c32d5..07c7a17d7 100644 --- a/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs +++ b/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs @@ -1,6 +1,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; +using Artemis.Utilities; using Corale.Colore.Razer.Keyboard.Effects; namespace Artemis.KeyboardProviders.Razer.Utilities @@ -11,7 +12,7 @@ namespace Artemis.KeyboardProviders.Razer.Utilities { var keyboardGrid = Custom.Create(); if (b.Width > width || b.Height > height) - b = ResizeImage(b, width, height); + b = ImageUtilities.ResizeImage(b, width, height); for (var y = 0; y < b.Height; y++) for (var x = 0; x < b.Width; x++) @@ -19,37 +20,5 @@ namespace Artemis.KeyboardProviders.Razer.Utilities return keyboardGrid; } - - /// - /// Resize the image to the specified width and height. - /// - /// The image to resize. - /// The width to resize to. - /// The height to resize to. - /// The resized image. - public static Bitmap ResizeImage(Image image, int width, int height) - { - var destRect = new Rectangle(0, 0, width, height); - var destImage = new Bitmap(width, height); - - destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); - - using (var graphics = Graphics.FromImage(destImage)) - { - graphics.CompositingMode = CompositingMode.SourceCopy; - graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; - graphics.SmoothingMode = SmoothingMode.HighQuality; - graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - - using (var wrapMode = new ImageAttributes()) - { - wrapMode.SetWrapMode(WrapMode.TileFlipXY); - graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); - } - } - - return destImage; - } } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/AmbientLightning/AmbientLightningEffectModel.cs b/Artemis/Artemis/Modules/Effects/AmbientLightning/AmbientLightningEffectModel.cs index 3fc79e42a..8f97f156c 100644 --- a/Artemis/Artemis/Modules/Effects/AmbientLightning/AmbientLightningEffectModel.cs +++ b/Artemis/Artemis/Modules/Effects/AmbientLightning/AmbientLightningEffectModel.cs @@ -1,139 +1,139 @@ -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.IO; -using System.Linq; -using System.Windows.Forms; -using Artemis.Managers; -using Artemis.Models; -using Artemis.Utilities; -using Artemis.Utilities.Keyboard; -using Kaliko.ImageLibrary; -using Kaliko.ImageLibrary.Filters; - -namespace Artemis.Modules.Effects.AmbientLightning -{ - internal class AmbientLightningEffectModel : EffectModel - { - private KeyboardRectangle _botRect; - private List _colors; - private List _rectangles; - private ScreenCapture _screenCapturer; - private KeyboardRectangle _topRect; - - public AmbientLightningEffectModel(MainManager mainManager, AmbientLightningEffectSettings settings) - : base(mainManager) - { - Name = "Ambient Lightning"; - Settings = settings; - Scale = 4; - Initialized = false; - } - - public int Scale { get; set; } - - public AmbientLightningEffectSettings Settings { get; set; } - - public KeyboardRectangle KeyboardRectangle { get; set; } - - public override void Dispose() - { - Initialized = false; - - _screenCapturer.Dispose(); - _screenCapturer = null; - } - - public override void Enable() - { - Initialized = false; - - _colors = new List(); - _screenCapturer = new ScreenCapture(); - _topRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List(), - LinearGradientMode.Horizontal) {Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale/2}; - _botRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List(), - LinearGradientMode.Horizontal); - - Initialized = true; - } - - public override void Update() - { - var capture = _screenCapturer.Capture(); - if (capture == null) - return; - - _rectangles = new List(); - // Analise the result - // Chop the screen into 2 rows and 3 columns - var resolution = Screen.PrimaryScreen.Bounds; - var blockWidth = resolution.Width/3; - var blockHeight = resolution.Height/2; - var colorIndex = 0; - for (var row = 0; row < 2; row++) - { - for (var column = 0; column < 3; column++) - { - var blockBase = new Point(blockWidth*column, blockHeight*row); - var samples = new List(); - // For each block, take samples - for (var blockRow = 0; blockRow < 6; blockRow++) - { - for (var blockColumn = 0; blockColumn < 6; blockColumn++) - { - var x = blockWidth/6*blockColumn + blockWidth/6/4 + blockBase.X; - var y = blockHeight/6*blockRow + blockHeight/6/4 + blockBase.Y; - samples.Add(_screenCapturer.GetColor(capture, new Point(x, y))); - } - } - - // Take the average of the samples - var averageR = samples.Sum(s => s.R)/samples.Count; - var averageG = samples.Sum(s => s.G)/samples.Count; - var averageB = samples.Sum(s => s.B)/samples.Count; - - if (_colors.Count <= colorIndex) - _colors.Add(Color.FromArgb(255, averageR, averageG, averageB)); - else - _colors[colorIndex] = Color.FromArgb(255, (averageR + _colors[colorIndex].R * 5) / 6, (averageG + _colors[colorIndex].G * 5) / 6, (averageB + _colors[colorIndex].B * 5) / 6); - colorIndex++; - } - } - - // Put the resulting colors in 6 rectangles, their size differs per keyboard - var rectWidth = MainManager.KeyboardManager.ActiveKeyboard.Width/3*Scale; - var rectHeight = MainManager.KeyboardManager.ActiveKeyboard.Height/2*Scale; - for (var row = 0; row < 2; row++) - { - for (var column = 0; column < 3; column++) - { - var rectBase = new Point(rectWidth * column, rectHeight * row); - _rectangles.Add(new Rectangle(rectBase.X, rectBase.Y, rectWidth, rectHeight)); - } - } - } - - public override Bitmap GenerateBitmap() - { - var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); - using (var g = Graphics.FromImage(bitmap)) - { - var i = 0; - foreach (var rectangle in _rectangles) - { - g.FillRectangle(new SolidBrush(_colors[i]), rectangle); - i++; - } - } - - var test = new KalikoImage(bitmap); - test.ApplyFilter(new GaussianBlurFilter(8f)); +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Artemis.Managers; +using Artemis.Models; +using Artemis.Utilities; +using Artemis.Utilities.Keyboard; +using Kaliko.ImageLibrary; +using Kaliko.ImageLibrary.Filters; + +namespace Artemis.Modules.Effects.AmbientLightning +{ + internal class AmbientLightningEffectModel : EffectModel + { + private KeyboardRectangle _botRect; + private List _colors; + private List _rectangles; + private ScreenCapture _screenCapturer; + private KeyboardRectangle _topRect; + + public AmbientLightningEffectModel(MainManager mainManager, AmbientLightningEffectSettings settings) + : base(mainManager) + { + Name = "Ambient Lightning"; + Settings = settings; + Scale = 4; + Initialized = false; + } + + public int Scale { get; set; } + + public AmbientLightningEffectSettings Settings { get; set; } + + public KeyboardRectangle KeyboardRectangle { get; set; } + + public override void Dispose() + { + Initialized = false; + + _screenCapturer.Dispose(); + _screenCapturer = null; + } + + public override void Enable() + { + Initialized = false; + + _colors = new List(); + _screenCapturer = new ScreenCapture(); + _topRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List(), + LinearGradientMode.Horizontal) {Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale/2}; + _botRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List(), + LinearGradientMode.Horizontal); + + Initialized = true; + } + + public override void Update() + { + var capture = _screenCapturer.Capture(); + if (capture == null) + return; + + _rectangles = new List(); + // Analise the result + // Chop the screen into 2 rows and 3 columns + var resolution = Screen.PrimaryScreen.Bounds; + var blockWidth = resolution.Width/3; + var blockHeight = resolution.Height/2; + var colorIndex = 0; + for (var row = 0; row < 2; row++) + { + for (var column = 0; column < 3; column++) + { + var blockBase = new Point(blockWidth*column, blockHeight*row); + var samples = new List(); + // For each block, take samples + for (var blockRow = 0; blockRow < 6; blockRow++) + { + for (var blockColumn = 0; blockColumn < 6; blockColumn++) + { + var x = blockWidth/6*blockColumn + blockWidth/6/4 + blockBase.X; + var y = blockHeight/6*blockRow + blockHeight/6/4 + blockBase.Y; + samples.Add(_screenCapturer.GetColor(capture, new Point(x, y))); + } + } + + // Take the average of the samples + var averageR = samples.Sum(s => s.R)/samples.Count; + var averageG = samples.Sum(s => s.G)/samples.Count; + var averageB = samples.Sum(s => s.B)/samples.Count; + + if (_colors.Count <= colorIndex) + _colors.Add(Color.FromArgb(255, averageR, averageG, averageB)); + else + _colors[colorIndex] = Color.FromArgb(255, (averageR + _colors[colorIndex].R * 5) / 6, (averageG + _colors[colorIndex].G * 5) / 6, (averageB + _colors[colorIndex].B * 5) / 6); + colorIndex++; + } + } + + // Put the resulting colors in 6 rectangles, their size differs per keyboard + var rectWidth = MainManager.KeyboardManager.ActiveKeyboard.Width/3*Scale; + var rectHeight = MainManager.KeyboardManager.ActiveKeyboard.Height/2*Scale; + for (var row = 0; row < 2; row++) + { + for (var column = 0; column < 3; column++) + { + var rectBase = new Point(rectWidth * column, rectHeight * row); + _rectangles.Add(new Rectangle(rectBase.X, rectBase.Y, rectWidth, rectHeight)); + } + } + } + + public override Bitmap GenerateBitmap() + { + var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); + using (var g = Graphics.FromImage(bitmap)) + { + var i = 0; + foreach (var rectangle in _rectangles) + { + g.FillRectangle(new SolidBrush(_colors[i]), rectangle); + i++; + } + } + + var test = new KalikoImage(bitmap); + test.ApplyFilter(new GaussianBlurFilter(8f)); var ms = new MemoryStream(); test.SaveBmp(ms); - ms.Position = 0; - return new Bitmap(ms); - - } - } + ms.Position = 0; + return new Bitmap(ms); + + } + } } \ No newline at end of file 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 new file mode 100644 index 000000000..f40fe2afa --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs @@ -0,0 +1,74 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Artemis.Modules.Games.Dota2 { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class Dota2 : global::System.Configuration.ApplicationSettingsBase { + + private static Dota2 defaultInstance = ((Dota2)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Dota2()))); + + public static Dota2 Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Enabled { + get { + return ((bool)(this["Enabled"])); + } + set { + this["Enabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string GameDirectory { + get { + return ((string)(this["GameDirectory"])); + } + set { + 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 new file mode 100644 index 000000000..7444214e6 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings @@ -0,0 +1,18 @@ + + + + + + True + + + + + + True + + + True + + + \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2DataModel.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2DataModel.cs new file mode 100644 index 000000000..5b73cacad --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2DataModel.cs @@ -0,0 +1,227 @@ +namespace Artemis.Modules.Games.Dota2 +{ + class Dota2DataModel + { + public class Rootobject + { + public Provider provider { get; set; } + public Map map { get; set; } + public Player player { get; set; } + public Hero hero { get; set; } + public Abilities abilities { get; set; } + public Items items { get; set; } + public Previously previously { get; set; } + } + + public class Provider + { + public string name { get; set; } + public int appid { get; set; } + public int version { get; set; } + public int timestamp { get; set; } + } + + public class Map + { + public string name { get; set; } + public long matchid { get; set; } + public int game_time { get; set; } + public int clock_time { get; set; } + public bool daytime { get; set; } + public bool nightstalker_night { get; set; } + public string game_state { get; set; } + public string win_team { get; set; } + public string customgamename { get; set; } + public int ward_purchase_cooldown { get; set; } + } + + public class Player + { + public string steamid { get; set; } + public string name { get; set; } + public string activity { get; set; } + public int kills { get; set; } + public int deaths { get; set; } + public int assists { get; set; } + public int last_hits { get; set; } + public int denies { get; set; } + public int kill_streak { get; set; } + public string team_name { get; set; } + public int gold { get; set; } + public int gold_reliable { get; set; } + public int gold_unreliable { get; set; } + public int gpm { get; set; } + public int xpm { get; set; } + } + + public class Hero + { + public int id { get; set; } + public string name { get; set; } + public int level { get; set; } + public bool alive { get; set; } + public int respawn_seconds { get; set; } + public int buyback_cost { get; set; } + public int buyback_cooldown { get; set; } + public int health { get; set; } + public int max_health { get; set; } + public int health_percent { get; set; } + public int mana { get; set; } + public int max_mana { get; set; } + public int mana_percent { get; set; } + public bool silenced { get; set; } + public bool stunned { get; set; } + public bool disarmed { get; set; } + public bool magicimmune { get; set; } + public bool hexed { get; set; } + public bool muted { get; set; } + public bool _break { get; set; } + public bool has_debuff { get; set; } + } + + public class Abilities + { + public Ability0 ability0 { get; set; } + public Ability1 ability1 { get; set; } + public Ability2 ability2 { get; set; } + public Ability3 ability3 { get; set; } + public Attributes attributes { get; set; } + } + + public class Ability0 + { + public string name { get; set; } + public int level { get; set; } + public bool can_cast { get; set; } + public bool passive { get; set; } + public bool ability_active { get; set; } + public int cooldown { get; set; } + public bool ultimate { get; set; } + } + + public class Ability1 + { + public string name { get; set; } + public int level { get; set; } + public bool can_cast { get; set; } + public bool passive { get; set; } + public bool ability_active { get; set; } + public int cooldown { get; set; } + public bool ultimate { get; set; } + } + + public class Ability2 + { + public string name { get; set; } + public int level { get; set; } + public bool can_cast { get; set; } + public bool passive { get; set; } + public bool ability_active { get; set; } + public int cooldown { get; set; } + public bool ultimate { get; set; } + } + + public class Ability3 + { + public string name { get; set; } + public int level { get; set; } + public bool can_cast { get; set; } + public bool passive { get; set; } + public bool ability_active { get; set; } + public int cooldown { get; set; } + public bool ultimate { get; set; } + } + + public class Attributes + { + public int level { get; set; } + } + + public class Items + { + public Slot0 slot0 { get; set; } + public Slot1 slot1 { get; set; } + public Slot2 slot2 { get; set; } + public Slot3 slot3 { get; set; } + public Slot4 slot4 { get; set; } + public Slot5 slot5 { get; set; } + public Stash0 stash0 { get; set; } + public Stash1 stash1 { get; set; } + public Stash2 stash2 { get; set; } + public Stash3 stash3 { get; set; } + public Stash4 stash4 { get; set; } + public Stash5 stash5 { get; set; } + } + + public class Slot0 + { + public string name { get; set; } + } + + public class Slot1 + { + public string name { get; set; } + } + + public class Slot2 + { + public string name { get; set; } + } + + public class Slot3 + { + public string name { get; set; } + } + + public class Slot4 + { + public string name { get; set; } + } + + public class Slot5 + { + public string name { get; set; } + } + + public class Stash0 + { + public string name { get; set; } + } + + public class Stash1 + { + public string name { get; set; } + } + + public class Stash2 + { + public string name { get; set; } + } + + public class Stash3 + { + public string name { get; set; } + } + + public class Stash4 + { + public string name { get; set; } + } + + public class Stash5 + { + public string name { get; set; } + } + + public class Previously + { + public Player1 player { get; set; } + } + + public class Player1 + { + public int gold { get; set; } + public int gold_unreliable { get; set; } + } + } +} diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs new file mode 100644 index 000000000..1f4862088 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs @@ -0,0 +1,118 @@ +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; +using Artemis.Modules.Games.Dota2; + +namespace Artemis.Modules.Games.Dota2 +{ + class Dota2Model : GameModel + { + + private KeyboardRegion _topRow; + public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager) + { + Settings = settings; + Name = "Dota2"; + ProcessName = "dota2"; + Enabled = Settings.Enabled; + Initialized = false; + Scale = 4; + } + + #region Variables + + public Dota2Settings Settings { get; set; } + public Dota2DataModel.Rootobject D2Json { get; set; } + public int Scale { get; set; } + public KeyboardRectangle HealthRect { get; set; } + + #endregion + + + public override void Dispose() + { + 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() + { + if (D2Json == null) + return; + + if (Settings.CanCastAbility) + UpdateAbilities(); + if (Settings.ShowHealth) + UpdateHealth(); + } + + private void UpdateHealth() + { + var health = D2Json.hero.health_percent; + if(health > 66) + HealthRect.Colors = new List { Color.Lime }; + else if (health > 33) + HealthRect.Colors = new List {Color.Yellow}; + else + HealthRect.Colors = new List {Color.Red}; + + } + + private void UpdateAbilities() + { + + Console.WriteLine(); + + //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); + HealthRect.Draw(g); + } + return bitmap; + } + + + + 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 new file mode 100644 index 000000000..971ac8243 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Artemis.Models; + +namespace Artemis.Modules.Games.Dota2 +{ + class Dota2Settings : GameSettings + { + + public Dota2Settings() + { + Load(); + } + + + #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; + + Dota2.Default.Save(); + } + + 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 deffd25e7..5a90707c4 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml @@ -1,13 +1,88 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + +