Skip to content

Commit

Permalink
Got it working, committing immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
slicedbread committed Jul 29, 2022
1 parent 74334a1 commit 952b499
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using Hearthstone_Deck_Tracker.API;
Expand All @@ -13,13 +14,18 @@ public partial class SchoolCountWidget
public SchoolCountWidget()
{
InitializeComponent();
Debug.WriteLine("________________________________________ini component____________________________________________________");
}

public void Update(List<Card> cards)
{
// hide if card list is empty
this.Visibility = cards.Count <= 0 ? Visibility.Hidden : Visibility.Visible;
this.ItemsSource = cards;
Debug.WriteLine("______________________________________________________________________________________________");
Debug.WriteLine("_________________________________________Update_____________________________________________________");
Debug.WriteLine(cards.Count);
Debug.WriteLine("______________________________________________________________________________________________");
UpdatePosition();
}

Expand Down
19 changes: 19 additions & 0 deletions SpellSchoolCounter/SpellSchoolCounter/SchoolCounterWidget2.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ItemsControl x:Class="SpellSchoolCounter.SchoolCountWidget2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpellSchoolCounter"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="FrameworkElement.Margin" Value="0,1,0,0" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Rectangle Fill="{Binding Background}" Height="34" Width="217" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
49 changes: 49 additions & 0 deletions SpellSchoolCounter/SpellSchoolCounter/SchoolCounterWidget2.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using Hearthstone_Deck_Tracker.API;
using Hearthstone_Deck_Tracker.Hearthstone;

namespace SpellSchoolCounter
{

public partial class SchoolCountWidget2
{

public SchoolCountWidget2()
{
InitializeComponent();
Debug.WriteLine("________________________________________ini component____________________________________________________");
}

public void Update(ObservableCollection<Card> cards)
{
// hide if card list is empty
this.Visibility = cards.Count <= 0 ? Visibility.Hidden : Visibility.Visible;
this.ItemsSource = cards;
Debug.WriteLine("______________________________________________________________________________________________");
Debug.WriteLine("_________________________________________Update_____________________________________________________");
Debug.WriteLine(cards.Count);
Debug.WriteLine("______________________________________________________________________________________________");
UpdatePosition();
}

public void UpdatePosition()
{
Canvas.SetTop(this, Core.OverlayWindow.Height * 5 / 100);
Canvas.SetRight(this, Core.OverlayWindow.Width * 20 / 100);
}

public void Show()
{
this.Visibility = Visibility.Visible;
}

public void Hide()
{
this.Visibility = Visibility.Hidden;
}
}
}
18 changes: 12 additions & 6 deletions SpellSchoolCounter/SpellSchoolCounter/SpellSchoolCounter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using HearthDb.Enums;
using Hearthstone_Deck_Tracker;
Expand All @@ -8,14 +9,14 @@

namespace SpellSchoolCounter
{
public class SpellSchoolCounter
internal class SpellSchoolCounter
{
private SchoolCountWidget _cardListWidget = null;
private SchoolCountWidget2 _cardListWidget = null;

private List<SpellSchool> _schoolsPlayed = new List<SpellSchool>();
private List<Card> _playedList = new List<Card>();
private ObservableCollection<Card> _playedList = new ObservableCollection<Card>();

public SpellSchoolCounter(SchoolCountWidget playerList)
public SpellSchoolCounter(SchoolCountWidget2 playerList)
{

_cardListWidget = playerList;
Expand All @@ -32,8 +33,11 @@ public SpellSchoolCounter(SchoolCountWidget playerList)
internal void GameStart()
{
_schoolsPlayed = new List<SpellSchool>();
_playedList = new List<Card>();
_playedList = new ObservableCollection<Card>();
_cardListWidget.Update(_playedList);
Debug.WriteLine("______________________________________________________________________________________________");
Debug.WriteLine("__________________________________________game start____________________________________________________");
Debug.WriteLine("______________________________________________________________________________________________");
}

internal void OnPlayerPlay(Card card)
Expand Down Expand Up @@ -70,8 +74,10 @@ internal void InMenu()
// Update the card list on player's turn
internal void TurnStart(ActivePlayer player)
{

_cardListWidget.Show();
Debug.WriteLine("______________________________________________________________________________________________");
Debug.WriteLine("__________________________________________turn start____________________________________________________");
Debug.WriteLine("______________________________________________________________________________________________");
}

}
Expand Down
134 changes: 71 additions & 63 deletions SpellSchoolCounter/SpellSchoolCounter/SpellSchoolCounter.csproj
Original file line number Diff line number Diff line change
@@ -1,71 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A3333374-492F-4B54-B710-768832CA1161}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpellSchoolCounter</RootNamespace>
<AssemblyName>SpellSchoolCounter</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HearthDb">
<HintPath>..\lib\HearthDb.dll</HintPath>
</Reference>
<Reference Include="HearthstoneDeckTracker">
<HintPath>..\..\..\Hearthstone-Deck-Tracker\Hearthstone Deck Tracker\bin\x86\Debug\HearthstoneDeckTracker.exe</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="SchoolCountWidget.xaml.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpellSchoolCounter.cs" />
<Compile Include="SpellSchoolCounterPlugin.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="SchoolCountWidget.xaml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetDir)$(ProjectName).*" "C:\Users\ian\AppData\Roaming\HearthstoneDeckTracker\Plugins"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A3333374-492F-4B54-B710-768832CA1161}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpellSchoolCounter</RootNamespace>
<AssemblyName>SpellSchoolCounter</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HearthDb">
<HintPath>..\lib\HearthDb.dll</HintPath>
</Reference>
<Reference Include="HearthstoneDeckTracker">
<HintPath>..\..\..\Hearthstone-Deck-Tracker\Hearthstone Deck Tracker\bin\x86\Debug\HearthstoneDeckTracker.exe</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="SchoolCounterWidget2.xaml.cs">
<DependentUpon>SchoolCounterWidget2.xaml</DependentUpon>
</Compile>
<Compile Include="SchoolCountWidget.xaml.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpellSchoolCounter.cs" />
<Compile Include="SpellSchoolCounterPlugin.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="SchoolCounterWidget2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SchoolCountWidget.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetDir)$(ProjectName).*" "C:\Users\ian\AppData\Roaming\HearthstoneDeckTracker\Plugins"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SpellSchoolCounter
{
public class SpellSchoolCounterPlugin : IPlugin
{
private SchoolCountWidget _playerList;
private SchoolCountWidget2 _widget;

public string Author
{
Expand Down Expand Up @@ -40,11 +40,11 @@ public void OnButtonPress()

public void OnLoad()
{
_playerList = new SchoolCountWidget();
_widget = new SchoolCountWidget2();

Core.OverlayCanvas.Children.Add(_playerList);
Core.OverlayCanvas.Children.Add(_widget);

SpellSchoolCounter curvy = new SpellSchoolCounter(_playerList);
SpellSchoolCounter curvy = new SpellSchoolCounter(_widget);

GameEvents.OnGameStart.Add(curvy.GameStart);
GameEvents.OnInMenu.Add(curvy.InMenu);
Expand All @@ -54,7 +54,7 @@ public void OnLoad()

public void OnUnload()
{
Core.OverlayCanvas.Children.Remove(_playerList);
Core.OverlayCanvas.Children.Remove(_widget);
}

public void OnUpdate()
Expand All @@ -63,7 +63,7 @@ public void OnUpdate()

public Version Version
{
get { return new Version(0,1,1); }
get { return new Version(0,4,3); }
}
}
}

0 comments on commit 952b499

Please sign in to comment.