Skip to content

Commit

Permalink
reintroduced minors to deck versioning (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
epix37 committed Jan 29, 2015
1 parent 5c49e79 commit eb4bf05
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 150 deletions.
8 changes: 4 additions & 4 deletions Hearthstone Deck Tracker/Controls/DeckVersionChange.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<StackPanel Orientation="Vertical">
<TextBlock x:Name="Label" Text="Hist change" Height="25" FontSize="14" Background="White"/>
<TextBlock x:Name="Label" Text="Hist change" FontSize="12" VerticalAlignment="Center" TextAlignment="Center" FontWeight="Medium"/>
<ListView x:Name="ListViewDeck" Grid.Row="0"
ItemsSource="{Binding}"
Background="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"
Foreground="White" FontWeight="Bold" BorderThickness="1"
Foreground="White" FontWeight="Bold" BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.CanContentScroll="False" FontFamily="Arial" Margin="0,6,0,6"
ScrollViewer.CanContentScroll="False" FontFamily="Arial"
HorizontalAlignment="Stretch"
>
<ListView.Resources>
Expand All @@ -30,7 +30,7 @@
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip Background="Transparent" BorderBrush="Transparent">
<local:CardToolTip></local:CardToolTip>
<local:CardToolTip />
</ToolTip>
</Setter.Value>
</Setter>
Expand Down
4 changes: 2 additions & 2 deletions Hearthstone Deck Tracker/FlyoutControls/DeckStatsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
CanUserReorderColumns="False" CanUserSortColumns="False"
CanUserResizeColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Version" Binding="{Binding Version}">
<DataGridTextColumn Header="Ver." Binding="{Binding Version}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
Expand Down Expand Up @@ -361,7 +361,7 @@
MouseDoubleClick="DGrid_MouseDoubleClick"
SelectionChanged="DGrid_SelectionChanged">
<DataGrid.Columns>
<DataGridTextColumn Header="Version" Binding="{Binding PlayerDeckVersionMajor}">
<DataGridTextColumn Header="Ver." Binding="{Binding PlayerDeckVersionString}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ public WinLoss(List<GameStats> stats, string text, SerializableVersion version)
}
else
{
Version = version.Major.ToString();
Version = version.ToString("v{M}.{m}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion Hearthstone Deck Tracker/Hearthstone/Deck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public string NameAndVersion
{
get
{
return string.Format("{0} (v{1})", Name, Version.Major);
return string.Format("{0} (v{1}.{2})", Name, Version.Major, Version.Minor);
}
}
public SerializableVersion Version = new SerializableVersion(1, 0);
Expand Down
19 changes: 10 additions & 9 deletions Hearthstone Deck Tracker/MainWindow/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@
</Rectangle>
</MenuItem.Icon>
</MenuItem>
<CheckBox x:Name="IncraseVersion" Content="Increase version" IsChecked="True"/>
<MenuItem Header="CANCEL" Click="BtnCancelEdit_Click">
<MenuItem.Icon>
<Rectangle Width="16" Height="16">
Expand Down Expand Up @@ -440,18 +439,20 @@
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackPanel Orientation="Vertical" Grid.Column="1">
<TextBlock x:Name="DeckCurrentVersionHeader" Text="Deck History" HorizontalAlignment="Center" FontSize="16"/>
<TextBlock x:Name="DeckCurrentVersion" FontSize="12"/>
</StackPanel>
<ScrollViewer Grid.Column="1" Grid.Row="1">
<DockPanel Grid.Column="1" Margin="0,6,0,0">
<TextBlock x:Name="DeckCurrentVersionHeader" Text="DECK HISTORY:" VerticalAlignment="Center" FontSize="12" DockPanel.Dock="Left"/>
<TextBlock x:Name="DeckCurrentVersion" Margin="6,0,0,0" FontSize="12" Text="v1.0" VerticalAlignment="Center" DockPanel.Dock="Left"/>
<Label Content="->" VerticalAlignment="Center" DockPanel.Dock="Left"/>
<ComboBox Name="ComboBoxVersionIncrement" Margin="0,0,6,0" />
</DockPanel>
<ScrollViewer Grid.Column="1" Grid.Row="1" Margin="0,6,6,6" Background="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}">
<StackPanel x:Name="DeckHistoryPanel"
Orientation="Vertical"
Background="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"

ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.CanContentScroll="True" Margin="0,6,0,6"
HorizontalAlignment="Center" Width="220" Height="auto"
ScrollViewer.CanContentScroll="True"
HorizontalAlignment="Center" Height="auto" Width="220" Margin="0,0,0,0"
/>
</ScrollViewer>
</Grid>
Expand Down
18 changes: 12 additions & 6 deletions Hearthstone Deck Tracker/MainWindow/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -815,19 +815,25 @@ public void UpdateDeckList(Deck selected)
}
}

private void UpdateDeckHistoryPanel(Deck selected)
private void UpdateDeckHistoryPanel(Deck selected, bool isNewDeck)
{
DeckHistoryPanel.Children.Clear();
DeckCurrentVersion.Text = "Current version is " + _newDeck.Version.Major.ToString();
IncraseVersion.IsChecked = true; //increase by default
DeckCurrentVersion.Text = string.Format("v{0}.{1}",_newDeck.Version.Major, _newDeck.Version.Minor);
ComboBoxVersionIncrement.ItemsSource = new List<string>
{
_newDeck.Version.ToString("v{M}.{m}"),
string.Format("v{0}.{1}", _newDeck.Version.Major, _newDeck.Version.Minor + 1),
string.Format("v{0}.{1}", _newDeck.Version.Major + 1, 0)
};
ComboBoxVersionIncrement.SelectedIndex = isNewDeck ? 0 : 1;

if (selected.Versions.Count > 0)
{
Deck current = selected;
List<Card> history = new List<Card>();
foreach (Deck prevVersion in selected.Versions.OrderByDescending(d => d.Version))
{
Controls.DeckVersionChange versionChange = new Controls.DeckVersionChange();
versionChange.Label.Text = string.Format("{0} to {1}", prevVersion.Version.Major, current.Version.Major);
var versionChange = new Controls.DeckVersionChange();
versionChange.Label.Text = string.Format("{0} -> {1}", prevVersion.Version.ToString("v{M}.{m}"), current.Version.ToString("v{M}.{m}"));
versionChange.ListViewDeck.ItemsSource = current - prevVersion;
DeckHistoryPanel.Children.Add(versionChange);
current = prevVersion;
Expand Down
10 changes: 5 additions & 5 deletions Hearthstone Deck Tracker/MainWindow/MainWindow_NewDeck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ private async void SaveDeck(bool overwrite)
return;
}

if (overwrite && IncraseVersion.IsChecked.HasValue && IncraseVersion.IsChecked.Value)
if (overwrite)
{
_newDeck.Version = SerializableVersion.IncreaseMajor(_newDeck.Version);
_newDeck.Version = SerializableVersion.Parse(ComboBoxVersionIncrement.SelectedValue.ToString());
AddDeckHistory();
UpdateDeckHistoryPanel(_newDeck);
UpdateDeckHistoryPanel(_newDeck, false);
}

if(EditingDeck && overwrite)
Expand Down Expand Up @@ -286,7 +286,7 @@ public void SetNewDeck(Deck deck, bool editing = false)
ListViewDeck.ItemsSource = _newDeck.Cards;
Helper.SortCardCollection(ListViewDeck.ItemsSource, false);
TextBoxDeckName.Text = _newDeck.Name;
UpdateDeckHistoryPanel(deck);
UpdateDeckHistoryPanel(deck, false);
UpdateDbListView();
ExpandNewDeck();
UpdateTitle();
Expand Down Expand Up @@ -388,7 +388,7 @@ private void CreateNewDeck(string hero)
ExpandNewDeck();
_newDeck = new Deck {Class = hero};
ListViewDeck.ItemsSource = _newDeck.Cards;
UpdateDeckHistoryPanel(_newDeck);
UpdateDeckHistoryPanel(_newDeck, true);
ManaCurveMyDecks.SetDeck(_newDeck);
UpdateDbListView();
}
Expand Down
11 changes: 7 additions & 4 deletions Hearthstone Deck Tracker/Stats/GameStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,17 @@ public string ResultString

[XmlIgnore]
public SerializableVersion PlayerDeckVersion { get; set; }
public string PlayerDeckVersionMajor

[XmlIgnore]
public string PlayerDeckVersionString
{
get
{
//can't fnd a way to bind PlayerDeckVersion.Major in datagrid
return PlayerDeckVersion != null ? PlayerDeckVersion.Major.ToString() : SerializableVersion.Default.Major.ToString();
return PlayerDeckVersion != null ? PlayerDeckVersion.ToString("v{M}.{m}") : SerializableVersion.Default.ToString("v{M}.{m}");
}
}
}

[XmlIgnore]
public ToolTip ResultToolTip
{
get { return new ToolTip {Content = "conceded", Visibility = (WasConceded ? Visibility.Visible : Visibility.Hidden)}; }
Expand Down
Loading

0 comments on commit eb4bf05

Please sign in to comment.