Skip to content

Commit

Permalink
Add additional stats (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuubari committed Nov 9, 2015
1 parent c2429f0 commit ed5e9fb
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 6 deletions.
1 change: 1 addition & 0 deletions source/Grabacr07.KanColleViewer/KanColleViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
<Compile Include="Views\Contents\Tools.xaml.cs">
<DependentUpon>Tools.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\CollapsibleGridViewColumn.cs" />
<Compile Include="Views\Controls\MetroComboBox.cs" />
<Compile Include="Views\Converters\AdmiralRankToStringConverter.cs" />
<Compile Include="Views\Converters\NameLevelAdeptToStringConverter.cs" />
Expand Down
45 changes: 45 additions & 0 deletions source/Grabacr07.KanColleViewer/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion source/Grabacr07.KanColleViewer/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ GPU: Slow! GPU optimization for tablets.</value>
<value>Armor</value>
</data>
<data name="Stats_AttackRange" xml:space="preserve">
<value>Attack Rng</value>
<value>Range</value>
</data>
<data name="Stats_DiveBomb" xml:space="preserve">
<value>Dive Bomb</value>
Expand Down Expand Up @@ -1351,4 +1351,19 @@ HTTP proxy settings are applied immediately. Settings for all other protocols ar
<data name="Ship_Evacuating" xml:space="preserve">
<value>Evac</value>
</data>
<data name="SlotItemCatalog_AttackRange_Long" xml:space="preserve">
<value>Long</value>
</data>
<data name="SlotItemCatalog_AttackRange_Medium" xml:space="preserve">
<value>Medium</value>
</data>
<data name="SlotItemCatalog_AttackRange_Short" xml:space="preserve">
<value>Short</value>
</data>
<data name="SlotItemCatalog_AttackRange_Unknown" xml:space="preserve">
<value>N/A</value>
</data>
<data name="SlotItemCatalog_AttackRange_VeryLong" xml:space="preserve">
<value>Very long</value>
</data>
</root>
15 changes: 15 additions & 0 deletions source/Grabacr07.KanColleViewer/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1361,4 +1361,19 @@ HTTP プロトコルの通信は自動構成も含め「インターネット
<data name="Ship_Evacuating" xml:space="preserve">
<value>退避済</value>
</data>
<data name="SlotItemCatalog_AttackRange_Long" xml:space="preserve">
<value>中</value>
</data>
<data name="SlotItemCatalog_AttackRange_Medium" xml:space="preserve">
<value>超長</value>
</data>
<data name="SlotItemCatalog_AttackRange_Short" xml:space="preserve">
<value>長</value>
</data>
<data name="SlotItemCatalog_AttackRange_Unknown" xml:space="preserve">
<value>N/A</value>
</data>
<data name="SlotItemCatalog_AttackRange_VeryLong" xml:space="preserve">
<value>短</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class ShipCatalogSortWorker : ViewModel
public static readonly SortableColumn LuckColumn = new SortableColumn { Name = Resources.ShipCatalog_Column_Luck, KeySelector = x => x.Luck.Current, DefaultIsDescending = true, };
public static readonly SortableColumn HPColumn = new SortableColumn { Name = Resources.ShipCatalog_SortBy_MaxHP, KeySelector = x => x.HP.Maximum, DefaultIsDescending = true, };
public static readonly SortableColumn ViewRangeColumn = new SortableColumn { Name = Resources.ShipCatalog_Column_ViewRange, KeySelector = x => x.ViewRange, DefaultIsDescending = true, };
public static readonly SortableColumn EvasionColumn = new SortableColumn { Name = Resources.ShipCatalog_Column_Evasion, KeySelector = x => x.Evasion.Current, DefaultIsDescending = true, };
public static readonly SortableColumn AntiSubColumn = new SortableColumn { Name = Resources.ShipCatalog_Column_ASW, KeySelector = x => x.AntiSub.Current, DefaultIsDescending = true, };

public static SortableColumn[] Columns { get; set; }

Expand All @@ -50,6 +52,8 @@ static ShipCatalogSortWorker()
LuckColumn,
HPColumn,
ViewRangeColumn,
EvasionColumn,
AntiSubColumn,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ public bool IsReloading

#endregion

private bool showStats;

public bool ShowStats
{
get { return this.showStats; }
set
{
if (this.showStats != value)
{
this.showStats = value;
this.RaisePropertyChanged();
}
}
}

public SlotItemCatalogViewModel()
{
this.Title = Resources.SlotItemCatalog_WindowTitle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Grabacr07.KanColleViewer.Properties;
using Grabacr07.KanColleWrapper.Models;

namespace Grabacr07.KanColleViewer.ViewModels.Catalogs
Expand Down Expand Up @@ -56,6 +57,46 @@ public void AddShip(Ship ship, int itemLevel, int adept)
{
this.itemsByLevel[new SlotItemCounterKey(itemLevel, adept)].AddShip(ship);
}

public string Stats
{
get
{
var addDetail = "";

if (this.Target.Firepower != 0) addDetail += " " + ToSignedString(this.Target.Firepower) + " " + Resources.Stats_Firepower;
if (this.Target.AA != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.AA) + " " + Resources.Stats_AntiAir;
if (this.Target.Torpedo != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.Torpedo) + " " + Resources.Stats_Torpedo;
if (this.Target.ASW != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.ASW) + " " + Resources.Stats_AntiSub;
if (this.Target.ViewRange != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.ViewRange) + " " + Resources.Stats_SightRange;
if (this.Target.Armer != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.Armer) + " " + Resources.Stats_Armor;
if (this.Target.Evade != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.Evade) + " " + Resources.Stats_Evasion;
if (this.Target.Hit != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.Hit) + " " + Resources.Stats_Accuracy;
if (this.Target.Bomb != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + ToSignedString(this.Target.Bomb) + " " + Resources.Stats_DiveBomb;
if (this.Target.AttackRange != 0) addDetail += (addDetail != "" ? "\n" : "") + " " + IntToRange(this.Target.AttackRange) + " " + Resources.Stats_AttackRange;

return addDetail;
}
}

private string ToSignedString(int value) => value.ToString("+#;-#;#");

private string IntToRange(int value)
{
switch (value)
{
case 1:
return Resources.SlotItemCatalog_AttackRange_Short;
case 2:
return Resources.SlotItemCatalog_AttackRange_Medium;
case 3:
return Resources.SlotItemCatalog_AttackRange_Long;
case 4:
return Resources.SlotItemCatalog_AttackRange_VeryLong;
default:
return Resources.SlotItemCatalog_AttackRange_Unknown;
}
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@
ItemContainerStyle="{DynamicResource GridViewItemContainerStyleKey}"
ScrollViewer.PanningMode="Both">
<ListView.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverterKey" />
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Margin"
Value="5,4" />
Expand Down Expand Up @@ -786,7 +787,49 @@
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>


<controls:CollapsibleGridViewColumn Width="64" Visibility="Visible">
<GridViewColumnHeader>
<!-- <GridViewColumnHeader Visibility="{Binding ShowMoreStats, Converter={StaticResource BooleanToVsibilityConverterKey}}"> -->
<metro2:SortButton MethodName="Sort"
MethodParameter="{x:Static viewModels:ShipCatalogSortWorker.EvasionColumn}">
<TextBlock Text="{Binding Resources.ShipCatalog_Column_Evasion, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />
</metro2:SortButton>
</GridViewColumnHeader>
<controls:CollapsibleGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="9">
<Run Text="{Binding Ship.Evasion.Current, Mode=OneWay}"
FontSize="12"
Foreground="{DynamicResource ActiveForegroundBrushKey}"/>
<Run Text="" />
<Run Text="{Binding Ship.Evasion.Minimum, StringFormat=({0}), Mode=OneWay}" />
</TextBlock>
</DataTemplate>
</controls:CollapsibleGridViewColumn.CellTemplate>
</controls:CollapsibleGridViewColumn>

<controls:CollapsibleGridViewColumn Width="64" Visibility="Visible">
<GridViewColumnHeader>
<!-- <GridViewColumnHeader Visibility="{Binding ShowMoreStats, Converter={StaticResource BooleanToVsibilityConverterKey}}"> -->
<metro2:SortButton MethodName="Sort"
MethodParameter="{x:Static viewModels:ShipCatalogSortWorker.AntiSubColumn}">
<TextBlock Text="{Binding Resources.ShipCatalog_Column_ASW, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />
</metro2:SortButton>
</GridViewColumnHeader>
<controls:CollapsibleGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="9">
<Run Text="{Binding Ship.AntiSub.Current, Mode=OneWay}"
FontSize="12"
Foreground="{DynamicResource ActiveForegroundBrushKey}"/>
<Run Text="" />
<Run Text="{Binding Ship.AntiSub.Minimum, StringFormat=({0}), Mode=OneWay}" />
</TextBlock>
</DataTemplate>
</controls:CollapsibleGridViewColumn.CellTemplate>
</controls:CollapsibleGridViewColumn>

<!--
<GridViewColumn Width="65">
<GridViewColumn.Header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,17 @@
<DockPanel Grid.Row="1">
<Border DockPanel.Dock="Top"
Margin="8,8,8,0">
<metro2:CallMethodButton Content="{Binding Resources.SlotItemCatalog_Refresh, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
Padding="40,6"
MethodName="Update"
HorizontalAlignment="Left" />
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<metro2:CallMethodButton Content="{Binding Resources.SlotItemCatalog_Refresh, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
Padding="40,6"
MethodName="Update"
HorizontalAlignment="Left"
Margin="0,0,3,0" />
<CheckBox IsChecked="{Binding ShowStats, Mode=TwoWay}"
Content="{Binding Resources.SlotItemCatalog_ShowStats, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
Margin="3,0,0,0"
VerticalAlignment="Center" />
</StackPanel>
</Border>

<Border BorderBrush="{DynamicResource BorderBrushKey}"
Expand All @@ -84,6 +91,7 @@
ItemContainerStyle="{DynamicResource GridViewItemContainerStyleKey}"
ScrollViewer.PanningMode="Both">
<ListView.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverterKey" />
<Style TargetType="{x:Type TextBlock}"
BasedOn="{StaticResource DefaultTextStyleKey}">
<Setter Property="Margin"
Expand Down Expand Up @@ -149,6 +157,22 @@
</GridViewColumn.CellTemplate>
</GridViewColumn>

<controls:CollapsibleGridViewColumn Width="120"
Visibility="{Binding ShowStats, Converter={StaticResource BooleanToVisibilityConverterKey}, Mode=OneWay}">
<GridViewColumnHeader Visibility="{Binding ShowStats, Converter={StaticResource BooleanToVisibilityConverterKey}, Mode=OneWay}">
<TextBlock Text="{Binding Resources.SlotItemCatalog_Stats, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />
</GridViewColumnHeader>
<controls:CollapsibleGridViewColumn.CellTemplate>
<DataTemplate DataType="{x:Type viewModels:SlotItemCounter}">
<TextBlock Margin="0,4"
TextWrapping="Wrap">
<Run Text="{Binding Stats, Mode=OneWay}"
Foreground="{DynamicResource ActiveForegroundBrushKey}" />
</TextBlock>
</DataTemplate>
</controls:CollapsibleGridViewColumn.CellTemplate>
</controls:CollapsibleGridViewColumn>

<GridViewColumn Width="52">
<GridViewColumn.Header>
<TextBlock Text="{Binding Resources.SlotItemCatalog_Total, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Windows;
using System.Windows.Controls;

namespace Grabacr07.KanColleViewer.Views.Controls
{
public class CollapsibleGridViewColumn : GridViewColumn
{
public Visibility Visibility
{
get
{
return (Visibility)GetValue(VisibilityProperty);
}
set
{
SetValue(VisibilityProperty, value);
}
}

public static readonly DependencyProperty VisibilityProperty =
DependencyProperty.Register("Visibility", typeof(Visibility),
typeof(CollapsibleGridViewColumn),
new FrameworkPropertyMetadata(Visibility.Visible,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnVisibilityPropertyChanged));

private static void OnVisibilityPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
(d as CollapsibleGridViewColumn)?.OnVisibilityChanged((Visibility)e.NewValue);
}

private void OnVisibilityChanged(Visibility visibility)
{
if (visibility == Visibility.Visible)
{
Width = visibleWidth;
CellTemplate = visibleTemplate;
}
else
{
visibleWidth = Width;
visibleTemplate = CellTemplate;
Width = 0.0;
CellTemplate = new DataTemplate();
}
}

private double visibleWidth;
private DataTemplate visibleTemplate;
}
}
5 changes: 5 additions & 0 deletions source/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public class SlotItemInfo : RawDataWrapper<kcsapi_mst_slotitem>, IIdentifiable
/// </summary>
public int ViewRange => this.RawData.api_saku;

/// <summary>
/// 射程を取得します。
/// </summary>
public int AttackRange => this.RawData.api_leng;

/// <summary>
/// 制空戦に参加できる戦闘機または水上機かどうかを示す値を取得します。
/// </summary>
Expand Down

0 comments on commit ed5e9fb

Please sign in to comment.