diff --git a/DrawPool/Controls/PoolView.cs b/DrawPool/Controls/PoolView.cs new file mode 100644 index 0000000..c480a44 --- /dev/null +++ b/DrawPool/Controls/PoolView.cs @@ -0,0 +1,213 @@ +namespace DrawPool.Controls +{ + using Hearthstone_Deck_Tracker; + using Hearthstone_Deck_Tracker.Controls; + using Logic; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Windows; + using System.Windows.Controls; + using Card = Hearthstone_Deck_Tracker.Hearthstone.Card; + using Core = Hearthstone_Deck_Tracker.API.Core; + + public partial class PoolView : StackPanel + { + private User32.MouseInput _mouseInput; + + /// + /// The deck hash reference + /// + private int deckHash; + + /// + /// Indicates if the window is movable or pined + /// + private bool isDraggable = false; + + internal Point mousePosition; + + /// + /// The list of Cards + /// + public List Cards; + + protected AnimatedCardList AnimatedCardLister => this.AnimatedCards; + protected HearthstoneTextBlock Chance1 => (HearthstoneTextBlock)this.FindName("LblDrawChance1"); + protected HearthstoneTextBlock Chance2 => (HearthstoneTextBlock)this.FindName("LblDrawChance2"); + protected double ScreenRatio => (4.0 / 3.0) / (Core.OverlayCanvas.Width / Core.OverlayCanvas.Height); + + /// + /// Gets the deck Hash Code. + /// + /// The deck HashCode. + public int DeckHash => Core.Game.Player.Deck.GetHashCode(); + + /// + /// The Hearthstone Text Block With the view's styled Title within + /// + public HearthstoneTextBlock poolTitleLabel => (HearthstoneTextBlock)this.FindName("BlockTitleText"); + + /// + /// Returns the list of Minions Grouped by their Counts, for statistical purposes. + /// + /// The list of Minions Grouped by their Counts, for statistical purposes + protected List> GroupedMinion() => Cards.GroupBy(c => c.Count).OrderByDescending(grp => grp.Count()).OrderBy(g => g.Key).ToList(); + + /// + /// Gets or sets the minion count. + /// + /// The minion count. + protected int MinionCount() => Cards.Sum(c => c.Count); + + /// + /// Writes the deck mix of minions in cards. + /// + /// The count of possible cards that could be draw. + /// The count of cards in the deck. + /// The deck mix of minions in cards as Minion Count/Deck Count + protected string WriteDeckMix(int possibleDraw, int deckCount) + { + return $"{possibleDraw}"; + } + + /// + /// Writes the formatted draw probability text. + /// + /// The . + /// The minion count. + /// The formatted draw probability text + protected string WriteDrawProbability(int copyCount, int minionCount, int drawCount) + { + return $"{DrawProbability(minionCount, copyCount, drawCount)}%"; + } + + /// + /// Checks if the deck changed since the last time we displayed the view. + /// + /// + /// true if the Deck has Changed;otherwise, false + /// + public bool CheckDeckChanged() => (deckHash != Core.Game.Player.Deck.GetHashCode()); + + /// + /// Calculates the Draw the probability. + /// + /// The pool size you will draw from. + /// The number of copies of a card. + /// The number of cards to draw. + /// The decimal place to round to. + /// The Draw probability. + public Double DrawProbability(int poolsize, int copies = 1, int draw = 1, int dec = 1) + { + //double dp = Helper.DrawProbability(copies, poolsize, draw); + return Math.Round(Helper.DrawProbability(copies, poolsize, draw) * 100, dec); + } + + /// + /// Collapsed the view. + /// + public void Hide() + { + this.Visibility = System.Windows.Visibility.Collapsed; + } + + /// + /// Gets or sets a value indicating whether this window instance is draggable. + /// + /// + /// true if window instance is draggable; otherwise, false. + /// + public bool IsPoolWindowDraggable() => isDraggable; + + /// + /// Called when the mouse focus moves off the card. + /// + public void OnMouseOff() + { + Hide(); + } + + public void Pin() + { + isDraggable = false; + } + + /// + /// Indicates if the Pool is visibile. + /// + /// + /// true if it is Visible;otherwise, false. + /// + public bool PoolIsVisibile() => (base.Visibility == System.Windows.Visibility.Visible); + + public void SetTitle() + { + this.poolTitleLabel.Text = StringTools.GetLocalized("MinstrelLabel") + " " + StringTools.GetLocalized("PluginName"); + } + + /// + /// Shows the view. + /// + public void Show() + { + this.Visibility = System.Windows.Visibility.Visible; + } + + public void UnPin() + { + isDraggable = true; + Show(); + } + + public bool Update(Card card) + { + if (card.Type != "Minion") + { + return false; + } + + var match = Cards.FirstOrDefault(c => c.Name == card.Name); + + if (match != null) + { + match.Count++; + } + else + { + Cards.Add(card.Clone() as Card); + } + + //Label.Visibility = Visibility.Visible; + + return true; + } + + public void UpdatePosition() + { + /* OLD CODE; positions near top of screen + Canvas.SetTop(this, Core.OverlayCanvas.Height * 3 / 100); + var xPos = Hearthstone_Deck_Tracker.Helper.GetScaledXPos(8.0 / 100, (int)Core.OverlayCanvas.Width, ScreenRatio); + + if (isLocal) + { + Canvas.SetRight(this, xPos); + } + else + { + Canvas.SetLeft(this, xPos); + } + */ + + // Canvas.SetRight(this, Hearthstone_Deck_Tracker.Helper.GetScaledXPos(5.0 / 100, (int)Core.OverlayCanvas.Width, ScreenRatio)); + if (true) + { + // Canvas.SetTop(this, Core.OverlayCanvas.Height * 65 / 100); + } + else + { + // Canvas.SetBottom(this, Core.OverlayCanvas.Height * 75 / 100); + } + } + } +} \ No newline at end of file diff --git a/DrawPool/Controls/PoolView.xaml b/DrawPool/Controls/PoolView.xaml new file mode 100644 index 0000000..589f883 --- /dev/null +++ b/DrawPool/Controls/PoolView.xaml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + True + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DrawPool/Controls/PoolView.xaml.cs b/DrawPool/Controls/PoolView.xaml.cs new file mode 100644 index 0000000..8020284 --- /dev/null +++ b/DrawPool/Controls/PoolView.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace DrawPool.Controls +{ + /// + /// Interaction logic for PoolView.xaml + /// + public partial class PoolView : StackPanel + { + public PoolView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/DrawPool/Controls/SettingsView.xaml b/DrawPool/Controls/SettingsView.xaml new file mode 100644 index 0000000..f35da0d --- /dev/null +++ b/DrawPool/Controls/SettingsView.xaml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + +