From a2a9cdd2878e42e2cbc306a11803da4640e16fc6 Mon Sep 17 00:00:00 2001 From: Logan Saso Date: Wed, 9 Mar 2016 22:08:30 -0800 Subject: [PATCH] Changed decision making slightly --- Artemis/Artemis/App.config | 6 ++ .../Modules/Games/Dota2/Dota2.Designer.cs | 24 ++++++ .../Modules/Games/Dota2/Dota2.settings | 6 ++ .../Artemis/Modules/Games/Dota2/Dota2Model.cs | 32 ++++++-- .../Modules/Games/Dota2/Dota2Settings.cs | 11 ++- .../Modules/Games/Dota2/Dota2View.xaml | 79 ++++++++++++------- .../Modules/Games/Dota2/Dota2ViewModel.cs | 2 +- 7 files changed, 124 insertions(+), 36 deletions(-) diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config index e85c8a403..1f453afa7 100644 --- a/Artemis/Artemis/App.config +++ b/Artemis/Artemis/App.config @@ -48,6 +48,12 @@ True + + #FFFF0000 + + + #FF0000FF + diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs index 07b71ff5c..bcd46002b 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs @@ -118,5 +118,29 @@ namespace Artemis.Modules.Games.Dota2 { this["ShowDead"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FFFF0000")] + public global::System.Windows.Media.Color MainColor { + get { + return ((global::System.Windows.Media.Color)(this["MainColor"])); + } + set { + this["MainColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("#FF0000FF")] + public global::System.Windows.Media.Color ManaColor { + get { + return ((global::System.Windows.Media.Color)(this["ManaColor"])); + } + set { + this["ManaColor"] = value; + } + } } } diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings b/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings index e1b994e94..064cc8115 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2.settings @@ -26,5 +26,11 @@ True + + #FFFF0000 + + + #FF0000FF + \ 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 caea1d196..bcb6f21e9 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs @@ -14,6 +14,7 @@ using Artemis.Utilities.Keyboard; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Artemis.Modules.Games.Dota2; +using Artemis.Utilities; namespace Artemis.Modules.Games.Dota2 { @@ -95,8 +96,12 @@ namespace Artemis.Modules.Games.Dota2 if (D2Json == null) return; - if (Settings.ShowDead) - UpdateDead(); + if (Settings.ShowDead && D2Json?.hero?.alive != null && !D2Json.hero.alive) + { + UpdateLifeStatus(); + return; + } + UpdateMainColor(); if (Settings.CanCastAbility) UpdateAbilities(); if (Settings.ShowHealth) @@ -107,15 +112,28 @@ namespace Artemis.Modules.Games.Dota2 UpdateMana(); if (Settings.CanCastItem) UpdateItems(); + + } - private void UpdateDead() + private void UpdateMainColor() { - if (D2Json?.hero?.alive == null) - return; + var list = new List { ColorHelpers.ToDrawingColor(Settings.MainColor) }; + EventRectangle.Colors = list; + DayCycleRectangle.Colors = list; + HealthRectangle.Colors = list; + ManaRectangle.Colors = list; + } - EventRectangle.Colors = D2Json.hero.alive ? new List { Color.Lime } : new List {Color.LightGray}; + private void UpdateLifeStatus() + { + var list = new List { Color.LightGray }; + EventRectangle.Colors = list; + DayCycleRectangle.Colors = list; + HealthRectangle.Colors = list; + ManaRectangle.Colors = list; + } private void UpdateDay() @@ -143,7 +161,7 @@ namespace Artemis.Modules.Games.Dota2 return; var manaPercent = D2Json.hero.mana_percent; - ManaRectangle.Colors = new List {Color.Blue}; + ManaRectangle.Colors = new List { ColorHelpers.ToDrawingColor(Settings.ManaColor) }; ManaRectangle.Width = (int)Math.Floor(_topRow.BottomRight.Y / 100.00 * manaPercent) * Scale; } diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs b/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs index a481522f9..2332a99dd 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Windows.Media; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -24,11 +25,15 @@ namespace Artemis.Modules.Games.Dota2 public bool CanCastItem { get; set; } public bool ShowMana { get; set; } public bool ShowDead { get; set; } + public Color MainColor { get; set; } + public Color ManaColor { get; set; } #endregion public override void Load() { + MainColor = Dota2.Default.MainColor; + ManaColor = Dota2.Default.ManaColor; ShowHealth = Dota2.Default.ShowHealth; CanCastAbility = Dota2.Default.CanCastAbility; Enabled = Dota2.Default.Enabled; @@ -41,6 +46,8 @@ namespace Artemis.Modules.Games.Dota2 public override void Save() { + Dota2.Default.MainColor = MainColor; + Dota2.Default.ManaColor = ManaColor; Dota2.Default.ShowDayCycle = ShowDayCycle; Dota2.Default.ShowHealth = ShowHealth; Dota2.Default.CanCastAbility = CanCastAbility; @@ -56,9 +63,11 @@ namespace Artemis.Modules.Games.Dota2 public override void ToDefault() { - Enabled = false; + Enabled = true; GameDirectory = string.Empty; + MainColor = Color.FromArgb(255,255,0,0); + ManaColor = Color.FromArgb(255,0,0,255); ShowHealth = true; CanCastAbility = true; ShowDayCycle = true; diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml index 2c7f4f56c..5648d2de4 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml @@ -5,8 +5,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:cal="http://www.caliburnproject.org" xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" - d:DesignHeight="424" d:DesignWidth="635"> + d:DesignHeight="495" d:DesignWidth="635"> @@ -23,13 +24,15 @@ + + @@ -41,6 +44,8 @@ + + @@ -56,64 +61,84 @@ + + + Main keyboard color + + + - - Show abilities that can be cast. - - - - - Show items that can be cast. + Castable abilities - - + - Show health on F-Keys. + Castable items - - + - Show mana on the number keys. + Display health - - + - Show day/night cycle. + Display mana - - - + + Mana color + + + + + - Turn grey when dead. + Display day/night + + + + + + Display gray when dead - +