diff --git a/Graveyard/ChancesTracker.cs b/Graveyard/ChancesTracker.cs index 9f8c59e..a6f1759 100644 --- a/Graveyard/ChancesTracker.cs +++ b/Graveyard/ChancesTracker.cs @@ -7,32 +7,47 @@ using Hearthstone_Deck_Tracker; using Hearthstone_Deck_Tracker.Controls; using Card = Hearthstone_Deck_Tracker.Hearthstone.Card; +using Hearthstone_Deck_Tracker.Utility.Logging; namespace HDT.Plugins.Graveyard { public class ChancesTracker { - private Dictionary _chances = new Dictionary(); + private readonly Dictionary Chances = new Dictionary(); public void Update(Card card, List Cards, AnimatedCardList View) { var count = (double)Cards.Aggregate(0, (total, c) => total + c.Count); for (var i = 0; i < Cards.Count(); i++) { - if (!_chances.ContainsKey(Cards[i])) + if (!Chances.ContainsKey(Cards[i])) { - var chance = new HearthstoneTextBlock(); - chance.FontSize = 18; - chance.TextAlignment = TextAlignment.Left; - var grid = (View.Items.GetItemAt(i) as UserControl).Content as Grid; - grid.Width = 260; - (grid.Children[0] as Hearthstone_Deck_Tracker.Controls.Card).HorizontalAlignment = HorizontalAlignment.Right; - (grid.Children[1] as Rectangle).Width = 260; - grid.Children.Add(chance); - _chances.Add(Cards[i], chance); + var chance = new HearthstoneTextBlock + { + FontSize = 18, + TextAlignment = TextAlignment.Left + }; + if (View.Items.GetItemAt(i) is UserControl control && control.Content is Grid grid) + { + grid.Width = 260; + if (grid.Children[0] is Hearthstone_Deck_Tracker.Controls.Card cardControl) + cardControl.HorizontalAlignment = HorizontalAlignment.Right; + else + Log.Warn("Expected Hearthstone_Deck_Tracker.Controls.Card, check AnimatedCard for layout changes"); + if (grid.Children[2] is Rectangle rectangle) + rectangle.Width = 260; + else + Log.Warn("Expected Rectangle, check AnimatedCard for layout changes"); + grid.Children.Add(chance); + } + else + { + Log.Warn("Expected UserControl and Grid, check AnimatedCard for layout changes"); + } + Chances.Add(Cards[i], chance); } - _chances[Cards[i]].Text = $"{Math.Round(Cards[i].Count / count * 100)}%"; + Chances[Cards[i]].Text = $"{Math.Round(Cards[i].Count / count * 100)}%"; } } } diff --git a/Graveyard/ChancesView.cs b/Graveyard/ChancesView.cs index 77eeed2..9111ac4 100644 --- a/Graveyard/ChancesView.cs +++ b/Graveyard/ChancesView.cs @@ -1,4 +1,6 @@ -using Hearthstone_Deck_Tracker.Hearthstone; +using Hearthstone_Deck_Tracker; +using Hearthstone_Deck_Tracker.Hearthstone; +using System.Windows; namespace HDT.Plugins.Graveyard { @@ -6,6 +8,18 @@ public class ChancesView : NormalView { private readonly ChancesTracker Chances = new ChancesTracker(); + public ChancesView() : base() + { + Margin = new Thickness(Margin.Left + Settings.Default.ChancesViewLeft, Margin.Top, Margin.Right, Margin.Right); + } + + public override HearthstoneTextBlock AddTitle(string text = "") + { + var label = base.AddTitle(text); + label.Margin = new Thickness(label.Margin.Left - Settings.Default.ChancesViewLeft, label.Margin.Top, label.Margin.Right, label.Margin.Right); + return label; + } + public override bool Update(Card card) { if (base.Update(card)) diff --git a/Graveyard/Graveyard.cs b/Graveyard/Graveyard.cs index eab0697..73d7d24 100644 --- a/Graveyard/Graveyard.cs +++ b/Graveyard/Graveyard.cs @@ -77,7 +77,10 @@ public class Graveyard AzeriteRatView.Config, }; - private readonly StackPanel FriendlyPanel; + private readonly FrameworkElement FriendlyView; + private readonly FrameworkElement EnemyView; + + private readonly StackPanel FriendlyPanel; private readonly StackPanel EnemyPanel; private StackPanel FirstPanel; @@ -92,16 +95,36 @@ public Graveyard() { Orientation = Orientation.Vertical }; - Core.OverlayCanvas.Children.Add(EnemyPanel); +#if DEBUGXAML + EnemyView = new Border + { + BorderBrush = Brushes.Green, + BorderThickness = new Thickness(1), + Child = EnemyPanel, + }; +#else + EnemyView = EnemyPanel; +#endif + Core.OverlayCanvas.Children.Add(EnemyView); // Create container FriendlyPanel = new StackPanel { Orientation = Settings.Default.FriendlyOrientation }; - Core.OverlayCanvas.Children.Add(FriendlyPanel); +#if DEBUGXAML + FriendlyView = new Border + { + BorderBrush = Brushes.Green, + BorderThickness = new Thickness(1), + Child = FriendlyPanel, + }; +#else + FriendlyView = FriendlyPanel; +#endif + Core.OverlayCanvas.Children.Add(FriendlyView); - Input = new InputManager(FriendlyPanel, EnemyPanel); + Input = new InputManager(FriendlyPanel, EnemyPanel); Settings.Default.PropertyChanged += SettingsChanged; SettingsChanged(null, null); @@ -111,7 +134,7 @@ public Graveyard() private void SettingsChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { FriendlyPanel.Orientation = Settings.Default.FriendlyOrientation; - FriendlyPanel.RenderTransform = new ScaleTransform(Settings.Default.FriendlyScale / 100, Settings.Default.FriendlyScale / 100); + FriendlyPanel.RenderTransform = new ScaleTransform(Settings.Default.FriendlyScale / 100, Settings.Default.FriendlyScale / 100); FriendlyPanel.Opacity = Settings.Default.FriendlyOpacity / 100; EnemyPanel.RenderTransform = new ScaleTransform(Settings.Default.EnemyScale / 100, Settings.Default.EnemyScale / 100); EnemyPanel.Opacity = Settings.Default.EnemyOpacity / 100; @@ -138,18 +161,18 @@ public void Update() || Core.Game.IsBattlegroundsMatch || Core.Game.IsMercenariesMatch ? Visibility.Collapsed : Visibility.Visible; - FriendlyPanel.Visibility = visibility; - if (FriendlyPanel.Visibility == Visibility.Visible) + FriendlyView.Visibility = visibility; + if (FriendlyView.Visibility == Visibility.Visible) { - Canvas.SetTop(FriendlyPanel, Settings.Default.PlayerTop.PercentageToPixels(Core.OverlayWindow.Height)); - Canvas.SetLeft(FriendlyPanel, Settings.Default.PlayerLeft.PercentageToPixels(Core.OverlayWindow.Width)); + Canvas.SetTop(FriendlyView, Settings.Default.PlayerTop.PercentageToPixels(Core.OverlayWindow.Height)); + Canvas.SetLeft(FriendlyView, Settings.Default.PlayerLeft.PercentageToPixels(Core.OverlayWindow.Width)); } - EnemyPanel.Visibility = visibility; - if (EnemyPanel.Visibility == Visibility.Visible) + EnemyView.Visibility = visibility; + if (EnemyView.Visibility == Visibility.Visible) { - Canvas.SetTop(EnemyPanel, Settings.Default.EnemyTop.PercentageToPixels(Core.OverlayWindow.Height)); - Canvas.SetLeft(EnemyPanel, Settings.Default.EnemyLeft.PercentageToPixels(Core.OverlayWindow.Width)); + Canvas.SetTop(EnemyView, Settings.Default.EnemyTop.PercentageToPixels(Core.OverlayWindow.Height)); + Canvas.SetLeft(EnemyView, Settings.Default.EnemyLeft.PercentageToPixels(Core.OverlayWindow.Width)); } } diff --git a/Graveyard/Settings.Designer.cs b/Graveyard/Settings.Designer.cs index 03487ac..3a3b869 100644 --- a/Graveyard/Settings.Designer.cs +++ b/Graveyard/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace HDT.Plugins.Graveyard { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -634,5 +634,29 @@ public double MaxLeft { this["MaxLeft"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("-14")] + public double TyrViewLeft { + get { + return ((double)(this["TyrViewLeft"])); + } + set { + this["TyrViewLeft"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("-42")] + public double ChancesViewLeft { + get { + return ((double)(this["ChancesViewLeft"])); + } + set { + this["ChancesViewLeft"] = value; + } + } } } diff --git a/Graveyard/Settings.settings b/Graveyard/Settings.settings index 3ec3e86..9e2610b 100644 --- a/Graveyard/Settings.settings +++ b/Graveyard/Settings.settings @@ -155,5 +155,11 @@ 95 + + -14 + + + -42 + \ No newline at end of file diff --git a/Graveyard/TyrView.cs b/Graveyard/TyrView.cs index 6a6e1e7..8df1468 100644 --- a/Graveyard/TyrView.cs +++ b/Graveyard/TyrView.cs @@ -75,7 +75,7 @@ public TitledListView(string name) VerticalAlignment = VerticalAlignment.Top, MinHeight = 30, MinWidth = 30, - Margin = new Thickness(-14,0,0,0), + Margin = new Thickness(Settings.Default.TyrViewLeft, 0, 0, 0), Text = name, }; Children.Add(Title); diff --git a/Graveyard/ViewBase.cs b/Graveyard/ViewBase.cs index 617c4a2..76c847c 100644 --- a/Graveyard/ViewBase.cs +++ b/Graveyard/ViewBase.cs @@ -14,7 +14,7 @@ public void InitialiseDisplay() Orientation = Orientation.Vertical; } - public HearthstoneTextBlock AddTitle(string text = "") + public virtual HearthstoneTextBlock AddTitle(string text = "") { var title = new HearthstoneTextBlock { @@ -23,7 +23,17 @@ public HearthstoneTextBlock AddTitle(string text = "") Text = text, Margin = new Thickness(0, 20, 0, 0), }; +#if DEBUGXAML + var titleBorder = new Border + { + BorderBrush = System.Windows.Media.Brushes.Red, + BorderThickness = new Thickness(1), + Child = title, + }; + Children.Insert(0, titleBorder); +#else Children.Insert(0, title); +#endif return title; } public string Title diff --git a/Graveyard/app.config b/Graveyard/app.config index d02c06e..3ab1400 100644 --- a/Graveyard/app.config +++ b/Graveyard/app.config @@ -160,6 +160,12 @@ 95 + + -14 + + + -42 + \ No newline at end of file