Skip to content

Commit

Permalink
add damage tab to debug window, fix treeview
Browse files Browse the repository at this point in the history
- fixed the Cards tabs treeview so it saves the expanded collapsed state
- add a damage tab to the debug window, to show the board damage info
  • Loading branch information
Andrew Burnett committed Oct 28, 2015
1 parent 3142306 commit 7b2e724
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Hearthstone Deck Tracker/Hearthstone Deck Tracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
<Compile Include="Exporting\ExportingHelper.cs" />
<Compile Include="Exporting\ExportingInfo.cs" />
<Compile Include="Exporting\HueAndBrightness.cs" />
<<<<<<< HEAD
<Compile Include="Stats\CompiledStats\ArenaRun.cs" />
<Compile Include="Stats\CompiledStats\ChartStats.cs" />
<Compile Include="Stats\CompiledStats\ClassStats.cs" />
Expand All @@ -265,6 +266,9 @@
<Compile Include="Importing\Websites\Hearthstonetopdecks.cs" />
<Compile Include="Importing\Websites\Icyveins.cs" />
<Compile Include="Importing\Websites\Tempostorm.cs" />
=======
<Compile Include="Utility\BoardState.cs" />
>>>>>>> c2c9d20... add damage tab to debug window, and board state stub
<Compile Include="Utility\MouseActions.cs" />
<Compile Include="FlyoutControls\GameDetailItem.cs" />
<Compile Include="FlyoutControls\OpponentDeck.xaml.cs">
Expand Down
21 changes: 21 additions & 0 deletions Hearthstone Deck Tracker/Utility/BoardState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using Hearthstone_Deck_Tracker.Hearthstone;

namespace Hearthstone_Deck_Tracker.Utility
{
public class BoardState
{
public PlayerBoard Player { get; private set; }
public PlayerBoard Opponent { get; private set; }

public BoardState()
{
}
}

public class PlayerBoard
{
public int Damage { get; set; }
public List<CardEntity> Cards { get; set; }
}
}
21 changes: 19 additions & 2 deletions Hearthstone Deck Tracker/Windows/DebugWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
<Grid>
<TabControl Name="TabControlDebug">
<TabItem Header="Cards">
<TreeView Name="TreeViewCards"/>
<DockPanel Margin="0,2">
<WrapPanel DockPanel.Dock="Top">
<Button Name="ExpandAllBtn" Click="ExpandAllBtn_Click" Margin="2,0">Expand All</Button>
<Button Name="CollapseAllBtn" Click="CollapseAllBtn_Click" Margin="2,0">Collapse All</Button>
</WrapPanel>
<TreeView Name="TreeViewCards"/>
</DockPanel>
</TabItem>
<TabItem Header="Entites">

<DockPanel>
<ComboBox DockPanel.Dock="Top" SelectedIndex="0" Name="ComboBoxData">
<ComboBox.Items>
Expand All @@ -20,6 +25,18 @@
<DataGrid Name="DataGridProperties" AutoGenerateColumns="True"/>
</DockPanel>
</TabItem>
<TabItem Header="Damage">
<StackPanel Name="DamageView">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="Opponent" FontSize="18" Margin="0,4"/>
<DataGrid Name="OpponentDataGrid" AutoGenerateColumns="True"/>
</DockPanel>
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="Player" FontSize="18" Margin="0,4"/>
<DataGrid Name="PlayerDataGrid" AutoGenerateColumns="True"/>
</DockPanel>
</StackPanel>
</TabItem>
</TabControl>
</Grid>
</Window>
62 changes: 56 additions & 6 deletions Hearthstone Deck Tracker/Windows/DebugWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Hearthstone_Deck_Tracker.Enums;
using Hearthstone_Deck_Tracker.Enums.Hearthstone;
using Hearthstone_Deck_Tracker.Hearthstone;
using Hearthstone_Deck_Tracker.Utility;

#endregion

Expand All @@ -22,14 +23,15 @@ namespace Hearthstone_Deck_Tracker.Windows
/// </summary>
public partial class DebugWindow : Window
{
private readonly GameV2 _game;
private List<object> _previous = new List<object>();
private readonly GameV2 _game;
private List<object> _previous = new List<object>();
private bool _update;
private List<string> _expanded = new List<string>();

public DebugWindow(GameV2 game)
{
_game = game;
InitializeComponent();
_game = game;
InitializeComponent();
_update = true;
Closing += (sender, args) => _update = false;
Update();
Expand All @@ -43,6 +45,10 @@ private async void Update()
{
UpdateCards();
}
else if(TabControlDebug.SelectedIndex == 2)
{
UpdateBoardDamage();
}
else
{
switch((string)ComboBoxData.SelectedValue)
Expand Down Expand Up @@ -80,8 +86,10 @@ private void UpdateCards()
foreach(var collection in collections)
{
var tvi = new TreeViewItem();
tvi.IsExpanded = true;
tvi.Header = collection.Name;
tvi.IsExpanded = _expanded.Contains(tvi.Header);
tvi.Expanded += OnItemExpanded;
tvi.Collapsed += OnItemCollapsed;
foreach(var item in collection.Collection)
{
tvi.Items.Add(item.ToString());
Expand All @@ -90,6 +98,14 @@ private void UpdateCards()
}
}

private void UpdateBoardDamage()
{
var board = new BoardState();
PlayerDataGrid.ItemsSource = board.Player.Cards;
OpponentDataGrid.ItemsSource = board.Opponent.Cards;
DamageView.UpdateLayout();
}

public class CollectionItem
{
public CollectionItem(List<CardEntity> collection, string name)
Expand Down Expand Up @@ -196,5 +212,39 @@ private void FilterGame()
_previous = list;
}
}

private void OnItemCollapsed(object sender, RoutedEventArgs e)
{
var item = sender as TreeViewItem;
var header = item.Header.ToString();
if(_expanded.Contains(header))
_expanded.Remove(header);
}

private void OnItemExpanded(object sender, RoutedEventArgs e)
{
var item = sender as TreeViewItem;
var header = item.Header.ToString();
if(_expanded.Contains(header) == false)
_expanded.Add(header);
}

private void ExpandAllBtn_Click(object sender, RoutedEventArgs e)
{
foreach(var item in TreeViewCards.Items)
{
var tvi = item as TreeViewItem;
tvi.IsExpanded = true;
}
}

private void CollapseAllBtn_Click(object sender, RoutedEventArgs e)
{
foreach(var item in TreeViewCards.Items)
{
var tvi = item as TreeViewItem;
tvi.IsExpanded = false;
}
}
}
}
}
6 changes: 4 additions & 2 deletions Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Hearthstone_Deck_Tracker.Controls;
using Hearthstone_Deck_Tracker.Enums;
using Hearthstone_Deck_Tracker.Hearthstone;
using Hearthstone_Deck_Tracker.Utility;
using Card = Hearthstone_Deck_Tracker.Hearthstone.Card;

#endregion
Expand Down Expand Up @@ -768,8 +769,9 @@ private void UpdateAttackValues()
{
IconBoardAttackPlayer.Visibility = Config.Instance.HidePlayerAttackIcon || _game.IsInMenu ? Visibility.Collapsed : Visibility.Visible;
IconBoardAttackOpponent.Visibility = Config.Instance.HideOpponentAttackIcon || _game.IsInMenu ? Visibility.Collapsed : Visibility.Visible;
TextBlockPlayerAttack.Text = Core.Game.Player.Board.Where(x => x != null && x.Entity != null).Sum(x => x.Entity.GetTag(GAME_TAG.ATK)).ToString();
TextBlockOpponentAttack.Text = Core.Game.Opponent.Board.Where(x => x != null && x.Entity != null).Sum(x => x.Entity.GetTag(GAME_TAG.ATK)).ToString();
var board = new BoardState();
TextBlockPlayerAttack.Text = board.Player.Damage.ToString();
TextBlockOpponentAttack.Text = board.Opponent.Damage.ToString();
}

private void UpdateGoldProgress()
Expand Down

0 comments on commit 7b2e724

Please sign in to comment.