From dd3cbed990bf0445820c0d20238f553e31b03360 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Mon, 9 Feb 2015 09:13:55 +0900 Subject: [PATCH 01/14] =?UTF-8?q?=E8=89=A6=E9=9A=8A=E3=82=BF=E3=83=96?= =?UTF-8?q?=E3=82=92=E6=96=B0=E3=81=97=E3=81=8F=E3=81=97=E3=81=A6=E3=81=BF?= =?UTF-8?q?=E3=82=8B=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KanColleViewer.csproj | 1 + .../Properties/AssemblyInfo.cs | 2 +- .../ViewModels/Contents/ShipSlotViewModel.cs | 27 + .../ViewModels/Contents/ShipViewModel.cs | 19 +- .../Views/Contents/Fleets.xaml | 604 +++++++++++------- .../KanColleWrapper.csproj | 1 - Grabacr07.KanColleWrapper/Models/ShipInfo.cs | 2 + .../Models/SlotItemInfo.cs | 8 + 8 files changed, 430 insertions(+), 234 deletions(-) create mode 100644 Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs diff --git a/Grabacr07.KanColleViewer/KanColleViewer.csproj b/Grabacr07.KanColleViewer/KanColleViewer.csproj index b471a92bd..8f2939a90 100644 --- a/Grabacr07.KanColleViewer/KanColleViewer.csproj +++ b/Grabacr07.KanColleViewer/KanColleViewer.csproj @@ -171,6 +171,7 @@ + diff --git a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs index 0d6dcb6dc..d0654d95d 100644 --- a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs +++ b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs @@ -51,4 +51,4 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.5.0.0")] +[assembly: AssemblyVersion("3.5.1.0")] diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs new file mode 100644 index 000000000..8dbffe958 --- /dev/null +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Grabacr07.KanColleWrapper.Models; +using Livet; + +namespace Grabacr07.KanColleViewer.ViewModels.Contents +{ + public class ShipSlotViewModel : ViewModel + { + public SlotItemInfo Item { get; } + + public string Current { get; } + + public string Maximum { get; } + + public ShipSlotViewModel(Ship ship, int num) + { + var info = ship.SlotItems[num].Info; + + this.Item = info; + this.Current = info.IsNumerable ? ship.OnSlot[num].ToString() : "-"; + this.Maximum = ship.Info.Slots[num].ToString(); + } + } +} \ No newline at end of file diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs index 87503e279..e3524e805 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs @@ -7,13 +7,16 @@ namespace Grabacr07.KanColleViewer.ViewModels.Contents { - public class ShipViewModel : ViewModel - { - public Ship Ship { get; private set; } + public class ShipViewModel : ViewModel + { + public Ship Ship { get; private set; } - public ShipViewModel(Ship ship) - { - this.Ship = ship; - } - } + public ShipSlotViewModel[] Slots { get; } + + public ShipViewModel(Ship ship) + { + this.Ship = ship; + this.Slots = ship.SlotItems.Select((_, i) => new ShipSlotViewModel(ship, i)).ToArray(); + } + } } diff --git a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml index e6ca60f1a..1aceb50e5 100644 --- a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml +++ b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml @@ -1,244 +1,400 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" + xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:livet="http://schemas.livet-mvvm.net/2011/wpf" + xmlns:controls="clr-namespace:Grabacr07.KanColleViewer.Views.Controls" + xmlns:views="clr-namespace:Grabacr07.KanColleViewer.Views" + xmlns:vm="clr-namespace:Grabacr07.KanColleViewer.ViewModels" + xmlns:behaviors="clr-namespace:Grabacr07.KanColleViewer.Views.Behaviors" + xmlns:fleets="clr-namespace:Grabacr07.KanColleViewer.ViewModels.Contents.Fleets" + xmlns:contents="clr-namespace:Grabacr07.KanColleViewer.Views.Contents" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="400" + d:DataContext="{d:DesignInstance fleets:FleetsViewModel}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FontSize="14" /> - - - + FontSize="22" + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + + + - - - + FontSize="22" + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + + + - - + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + + + FontSize="9" /> + FontSize="9" /> - + - + + Style="{DynamicResource EmphaticTextElementStyleKey}" /> - - - - - - - - - + + + + + + + + + - - + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + FontSize="9" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj index cf70ce9d4..63a769e34 100644 --- a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj +++ b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj @@ -82,7 +82,6 @@ False ..\packages\Rx-PlatformServices.2.2.4\lib\net45\System.Reactive.PlatformServices.dll - diff --git a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs index b1106216e..313b1b7f9 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs @@ -32,6 +32,8 @@ public class ShipInfo : RawDataWrapper, IIdentifiable /// public ShipType ShipType => this.shipType ?? (this.shipType = KanColleClient.Current.Master.ShipTypes[this.RawData.api_stype]) ?? ShipType.Dummy; + public int[] Slots => this.RawData.api_maxeq; + #region 用意したけど使わないっぽい? /// diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs index 9942f2d8c..8935f89dd 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs @@ -42,6 +42,14 @@ public bool IsAirSuperiorityFighter } } + public bool IsNumerable + { + get + { + var type = this.RawData.api_type.Get(2); + return type.HasValue && (type == 6 || type == 7 || type == 8 || type == 11); + } + } internal SlotItemInfo(kcsapi_mst_slotitem rawData) : base(rawData) { } From 6e89f160dca957fcfbecd120bea1c6a45b66307d Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Wed, 11 Feb 2015 23:00:17 +0900 Subject: [PATCH 02/14] =?UTF-8?q?=E9=80=A3=E5=90=88=E8=89=A6=E9=9A=8A?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=A1=E3=82=85=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Grabacr07.KanColleWrapper/Calculator.cs | 236 ++++++++++++------ Grabacr07.KanColleWrapper/Homeport.cs | 2 +- .../KanColleProxy.Endpoints.cs | 8 + .../KanColleProxy.Endpoints.tt | 1 + .../KanColleWrapper.csproj | 3 +- .../kcsapi_combined_battle_battleresult.cs | 91 +++---- .../Models/SlotItemIconType.cs | 168 +++++++++++++ .../Models/SlotItemInfo.cs | 3 + .../Models/SlotItemType.cs | 170 +------------ Grabacr07.KanColleWrapper/Organization.cs | 2 +- 10 files changed, 398 insertions(+), 286 deletions(-) create mode 100644 Grabacr07.KanColleWrapper/Models/SlotItemIconType.cs diff --git a/Grabacr07.KanColleWrapper/Calculator.cs b/Grabacr07.KanColleWrapper/Calculator.cs index db400e5cd..f887ab594 100644 --- a/Grabacr07.KanColleWrapper/Calculator.cs +++ b/Grabacr07.KanColleWrapper/Calculator.cs @@ -7,87 +7,157 @@ namespace Grabacr07.KanColleWrapper { - internal static class Calculator - { - /// - /// 装備と搭載数を指定して、スロット単位の制空能力を計算します。 - /// - /// 対空能力を持つ装備。 - /// 搭載数。 - /// - public static int CalcAirSuperiorityPotential(this SlotItem slotItem, int onslot) - { - if (slotItem.Info.IsAirSuperiorityFighter) - { - return (int)(slotItem.Info.AA * Math.Sqrt(onslot)); - } - - return 0; - } - - /// - /// 指定した艦の制空能力を計算します。 - /// - public static int CalcAirSuperiorityPotential(this Ship ship) - { - return ship.SlotItems.Zip(ship.OnSlot, (item, i) => item.CalcAirSuperiorityPotential(i)).Sum(); - } - - - /// - /// 艦隊の索敵値を計算します。 - /// - /// - public static int CalcFleetViewRange(this Fleet fleet, ViewRangeCalcLogic logic) - { - if (fleet == null || fleet.Ships.Length == 0) return 0; - - if (logic == ViewRangeCalcLogic.Type1) - { - return fleet.Ships.Sum(x => x.ViewRange); - } - - if (logic == ViewRangeCalcLogic.Type2) - { - // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 - // [索敵装備と装備例] によって示されている計算式 - // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 - - var spotter = fleet.Ships.SelectMany( - x => x.SlotItems - .Zip(x.OnSlot, (i, o) => new { Item = i.Info, Slot = o }) - .Where(a => a.Item.RawData.api_type.Get(1) == 7) - .Where(a => a.Slot > 0) - .Select(a => a.Item.RawData.api_saku) - ).Sum(); - - var radar = fleet.Ships.SelectMany( - x => x.SlotItems - .Where(i => i.Info.RawData.api_type.Get(1) == 8) - .Select(i => i.Info.RawData.api_saku) - ).Sum(); - - return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); - } - - return 0; - } - } - - - /// - /// 索敵値の計算に使用するロジックの種類を示す識別します。 - /// - public enum ViewRangeCalcLogic - { - /// - /// 単純な索敵合計値。 - /// - Type1, - - /// - /// (偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)。 - /// - Type2, - } + internal static class Calculator + { + /// + /// 装備と搭載数を指定して、スロット単位の制空能力を計算します。 + /// + /// 対空能力を持つ装備。 + /// 搭載数。 + /// + public static int CalcAirSuperiorityPotential(this SlotItem slotItem, int onslot) + { + if (slotItem.Info.IsAirSuperiorityFighter) + { + return (int)(slotItem.Info.AA * Math.Sqrt(onslot)); + } + + return 0; + } + + /// + /// 指定した艦の制空能力を計算します。 + /// + public static int CalcAirSuperiorityPotential(this Ship ship) + { + return ship.SlotItems.Zip(ship.OnSlot, (item, i) => item.CalcAirSuperiorityPotential(i)).Sum(); + } + + + /// + /// 艦隊の索敵値を計算します。 + /// + /// + public static int CalcFleetViewRange(this Fleet fleet, ViewRangeCalcLogic logic) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + if (logic == ViewRangeCalcLogic.Type1) + { + return fleet.Ships.Sum(x => x.ViewRange); + } + + if (logic == ViewRangeCalcLogic.Type2) + { + // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 + // [索敵装備と装備例] によって示されている計算式 + // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 + + var spotter = fleet.Ships.SelectMany( + x => x.SlotItems + .Zip(x.OnSlot, (i, o) => new { Item = i.Info, Slot = o }) + .Where(a => a.Item.RawData.api_type.Get(1) == 7) + .Where(a => a.Slot > 0) + .Select(a => a.Item.RawData.api_saku) + ).Sum(); + + var radar = fleet.Ships.SelectMany( + x => x.SlotItems + .Where(i => i.Info.RawData.api_type.Get(1) == 8) + .Select(i => i.Info.RawData.api_saku) + ).Sum(); + + return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); + } + + if (logic == ViewRangeCalcLogic.Type3) + { + + } + + return 0; + } + } + + + /// + /// 索敵値の計算に使用するロジックの種類を示す識別します。 + /// + public enum ViewRangeCalcLogic + { + /// + /// 単純な索敵合計値。 + /// + Type1, + + /// + /// (偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)。 + /// + Type2, + + Type3, + } + + + public interface ICalcViewRange + { + string Description { get; } + + int Calc(Fleet fleet); + } + + public class ViewRangeType1 : ICalcViewRange + { + public string Description + { + get + { + throw new NotImplementedException(); + } + } + + public int Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + return fleet.Ships.Sum(x => x.ViewRange); + } + } + + public class ViewRangeType2 : ICalcViewRange + { + public string Description + { + get + { + throw new NotImplementedException(); + } + } + + public int Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 + // [索敵装備と装備例] によって示されている計算式 + // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 + + var spotter = fleet.Ships.SelectMany( + x => x.SlotItems + .Zip(x.OnSlot, (i, o) => new { Item = i.Info, Slot = o }) + .Where(a => a.Item.RawData.api_type.Get(1) == 7) + .Where(a => a.Slot > 0) + .Select(a => a.Item.RawData.api_saku) + ).Sum(); + + var radar = fleet.Ships.SelectMany( + x => x.SlotItems + .Where(i => i.Info.RawData.api_type.Get(1) == 8) + .Select(i => i.Info.RawData.api_saku) + ).Sum(); + + return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); + } + } } +----- \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Homeport.cs b/Grabacr07.KanColleWrapper/Homeport.cs index 3fe83e0ff..bafe844c8 100644 --- a/Grabacr07.KanColleWrapper/Homeport.cs +++ b/Grabacr07.KanColleWrapper/Homeport.cs @@ -89,7 +89,7 @@ internal Homeport(KanColleProxy proxy) this.Organization.Update(x.Data.api_ship); this.Repairyard.Update(x.Data.api_ndock); this.Organization.Update(x.Data.api_deck_port); - this.Organization.Combined = x.Data.api_combined_flag == 1; + this.Organization.Combined = x.Data.api_combined_flag != 0; this.Materials.Update(x.Data.api_material); }); proxy.api_get_member_basic.TryParse().Subscribe(x => this.UpdateAdmiral(x.Data)); diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs index 1b2f51dab..806c9c19f 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs +++ b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs @@ -295,6 +295,14 @@ public IObservable api_req_combined_battle_battleresult get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_combined_battle/battleresult"); } } + /// + /// エンド ポイント "/kcsapi/api_req_combined_battle/goback_port" からのセッションを配信します。 + /// + public IObservable api_req_combined_battle_goback_port + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_combined_battle/goback_port"); } + } + // ReSharper restore InconsistentNaming } } diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt index 052940521..dccd53627 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt +++ b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt @@ -43,6 +43,7 @@ "/kcsapi/api_req_combined_battle/battle", "/kcsapi/api_req_combined_battle/airbattle", "/kcsapi/api_req_combined_battle/battleresult", + "/kcsapi/api_req_combined_battle/goback_port", }; #> // diff --git a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj index cf70ce9d4..52f244dd7 100644 --- a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj +++ b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj @@ -120,6 +120,7 @@ + True @@ -165,7 +166,7 @@ - + diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs index 4099340fe..269b3a30c 100644 --- a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_combined_battle_battleresult.cs @@ -6,48 +6,55 @@ namespace Grabacr07.KanColleWrapper.Models.Raw { - // ReSharper disable InconsistentNaming - public class kcsapi_combined_battle_battleresult - { - public int[] api_ship_id { get; set; } - public string api_win_rank { get; set; } - public int api_get_exp { get; set; } - public int api_mvp { get; set; } - public int api_mvp_combined { get; set; } - public int api_member_lv { get; set; } - public int api_member_exp { get; set; } - public int api_get_base_exp { get; set; } - public int[] api_get_ship_exp { get; set; } - public int[] api_get_ship_exp_combined { get; set; } - public int[][] api_get_exp_lvup { get; set; } - public int[][] api_get_exp_lvup_combined { get; set; } - public int api_dests { get; set; } - public int api_destsf { get; set; } - public string api_quest_name { get; set; } - public int api_quest_level { get; set; } - public Api_Enemy_Info api_enemy_info { get; set; } - public int api_first_clear { get; set; } - public int[] api_get_flag { get; set; } - public Api_Get_Ship api_get_ship { get; set; } - public int api_get_exmap_rate { get; set; } - public int api_get_exmap_useitem_id { get; set; } - public int api_escape_flag { get; set; } - public object api_escape { get; set; } - } + // ReSharper disable InconsistentNaming + public class kcsapi_combined_battle_battleresult + { + public int[] api_ship_id { get; set; } + public string api_win_rank { get; set; } + public int api_get_exp { get; set; } + public int api_mvp { get; set; } + public int api_mvp_combined { get; set; } + public int api_member_lv { get; set; } + public int api_member_exp { get; set; } + public int api_get_base_exp { get; set; } + public int[] api_get_ship_exp { get; set; } + public int[] api_get_ship_exp_combined { get; set; } + public int[][] api_get_exp_lvup { get; set; } + public int[][] api_get_exp_lvup_combined { get; set; } + public int api_dests { get; set; } + public int api_destsf { get; set; } + public string api_quest_name { get; set; } + public int api_quest_level { get; set; } + public Api_Enemy_Info api_enemy_info { get; set; } + public int api_first_clear { get; set; } + public int[] api_get_flag { get; set; } + public Api_Get_Ship api_get_ship { get; set; } + public int api_get_exmap_rate { get; set; } + public int api_get_exmap_useitem_id { get; set; } + public int api_escape_flag { get; set; } + public Api_Escape api_escape { get; set; } + } - public class Api_Enemy_Info - { - public string api_level { get; set; } - public string api_rank { get; set; } - public string api_deck_name { get; set; } - } + public class Api_Enemy_Info + { + public string api_level { get; set; } + public string api_rank { get; set; } + public string api_deck_name { get; set; } + } - public class Api_Get_Ship - { - public int api_ship_id { get; set; } - public string api_ship_type { get; set; } - public string api_ship_name { get; set; } - public string api_ship_getmes { get; set; } - } - // ReSharper restore InconsistentNaming + public class Api_Get_Ship + { + public int api_ship_id { get; set; } + public string api_ship_type { get; set; } + public string api_ship_name { get; set; } + public string api_ship_getmes { get; set; } + } + + public class Api_Escape + { + public int[] api_escape_idx { get; set; } + public int[] api_tow_idx { get; set; } + } + + // ReSharper restore InconsistentNaming } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemIconType.cs b/Grabacr07.KanColleWrapper/Models/SlotItemIconType.cs new file mode 100644 index 000000000..24ff9a422 --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/SlotItemIconType.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Grabacr07.KanColleWrapper.Models +{ + public enum SlotItemIconType + { + Unknown = 0, + + /// + /// 小口径主砲。 + /// + MainCanonLight = 1, + + /// + /// 中口径主砲。 + /// + MainCanonMedium = 2, + + /// + /// 大口径主砲。 + /// + MainCanonHeavy = 3, + + /// + /// 副砲。 + /// + SecondaryCanon = 4, + + /// + /// 魚雷。 + /// + Torpedo = 5, + + /// + /// 艦戦。 + /// + Fighter = 6, + + /// + /// 艦爆。 + /// + DiveBomber = 7, + + /// + /// 艦攻。 + /// + TorpedoBomber = 8, + + /// + /// 偵察機。 + /// + ReconPlane = 9, + + /// + /// 水上機。 + /// + ReconSeaplane = 10, + + /// + /// 電探。 + /// + Rader = 11, + + /// + /// 三式弾。 + /// + AAShell = 12, + + /// + /// 徹甲弾。 + /// + APShell = 13, + + /// + /// ダメコン。 + /// + DamageControl = 14, + + /// + /// 機銃。 + /// + AAGun = 15, + + /// + /// 高角砲。 + /// + HighAngleGun = 16, + + /// + /// 爆雷投射機。 + /// + ASW = 17, + + /// + /// ソナー。 + /// + Soner = 18, + + /// + /// 機関部強化。 + /// + EngineImprovement = 19, + + /// + /// 上陸用舟艇。 + /// + LandingCraft = 20, + + /// + /// オートジャイロ。 + /// + Autogyro = 21, + + /// + /// 指揮連絡機。 + /// + ArtillerySpotter = 22, + + /// + /// 増設バルジ。 + /// + AntiTorpedoBulge = 23, + + /// + /// 探照灯。 + /// + Searchlight = 24, + + /// + /// ドラム缶。 + /// + DrumCanister = 25, + + /// + /// 施設。 + /// + Facility = 26, + + /// + /// 照明弾。 + /// + Flare = 27, + + /// + /// 司令部施設。 + /// + FleetCommandFacility = 28, + + /// + /// 航空要員。 + /// + MaintenancePersonnel = 29, + + /// + /// 高射砲。 + /// + AntiAircraftFireDirector = 30, + + /// + /// ロケットランチャー。 + /// + RocketLauncher = 31, + } +} diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs index 9942f2d8c..dd9ba631f 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs @@ -14,6 +14,7 @@ namespace Grabacr07.KanColleWrapper.Models /// public class SlotItemInfo : RawDataWrapper, IIdentifiable { + private SlotItemType? type; private SlotItemIconType? iconType; private int? categoryId; @@ -21,6 +22,8 @@ public class SlotItemInfo : RawDataWrapper, IIdentifiable public string Name => this.RawData.api_name; + public SlotItemType Type => this.type ?? (SlotItemType)(this.type = (SlotItemType)(this.RawData.api_type.Get(2) ?? 0)); + public SlotItemIconType IconType => this.iconType ?? (SlotItemIconType)(this.iconType = (SlotItemIconType)(this.RawData.api_type.Get(3) ?? 0)); public int CategoryId => this.categoryId ?? (int)(this.categoryId = this.RawData.api_type.Get(2) ?? int.MaxValue); diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemType.cs b/Grabacr07.KanColleWrapper/Models/SlotItemType.cs index 5a4787d2a..df0cf98a6 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItemType.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItemType.cs @@ -6,163 +6,17 @@ namespace Grabacr07.KanColleWrapper.Models { - public enum SlotItemIconType - { - Unknown = 0, - - /// - /// 小口径主砲。 - /// - MainCanonLight = 1, - - /// - /// 中口径主砲。 - /// - MainCanonMedium = 2, - - /// - /// 大口径主砲。 - /// - MainCanonHeavy = 3, - - /// - /// 副砲。 - /// - SecondaryCanon = 4, - - /// - /// 魚雷。 - /// - Torpedo = 5, - - /// - /// 艦戦。 - /// - Fighter = 6, - - /// - /// 艦爆。 - /// - DiveBomber = 7, - - /// - /// 艦攻。 - /// - TorpedoBomber = 8, - - /// - /// 偵察機。 - /// - ReconPlane = 9, - - /// - /// 水上機。 - /// - ReconSeaplane = 10, - - /// - /// 電探。 - /// - Rader = 11, - - /// - /// 三式弾。 - /// - AAShell = 12, - - /// - /// 徹甲弾。 - /// - APShell = 13, - - /// - /// ダメコン。 - /// - DamageControl = 14, - - /// - /// 機銃。 - /// - AAGun = 15, - - /// - /// 高角砲。 - /// - HighAngleGun = 16, - - /// - /// 爆雷投射機。 - /// - ASW = 17, - - /// - /// ソナー。 - /// - Soner = 18, - - /// - /// 機関部強化。 - /// - EngineImprovement = 19, - - /// - /// 上陸用舟艇。 - /// - LandingCraft = 20, - - /// - /// オートジャイロ。 - /// - Autogyro = 21, - - /// - /// 指揮連絡機。 - /// - ArtillerySpotter = 22, - - /// - /// 増設バルジ。 - /// - AntiTorpedoBulge = 23, - - /// - /// 探照灯。 - /// - Searchlight = 24, - - /// - /// ドラム缶。 - /// - DrumCanister = 25, - - /// - /// 施設。 - /// - Facility = 26, - - /// - /// 照明弾。 - /// - Flare = 27, - - /// - /// 司令部施設。 - /// - FleetCommandFacility = 28, - - /// - /// 航空要員。 - /// - MaintenancePersonnel = 29, - - /// - /// 高射砲。 - /// - AntiAircraftFireDirector = 30, - - /// - /// ロケットランチャー。 - /// - RocketLauncher = 31, + public enum SlotItemType + { + 艦上戦闘機 = 6, + 艦上爆撃機 = 7, + 艦上攻撃機 = 8, + 艦上偵察機 = 9, + 水上偵察機 = 10, + 水上爆撃機 = 11, + 小型電探 = 12, + 大型電探 = 13, + + 探照灯 = 29, } } diff --git a/Grabacr07.KanColleWrapper/Organization.cs b/Grabacr07.KanColleWrapper/Organization.cs index f44869eba..d71c45b14 100644 --- a/Grabacr07.KanColleWrapper/Organization.cs +++ b/Grabacr07.KanColleWrapper/Organization.cs @@ -113,7 +113,7 @@ public Organization(Homeport parent, KanColleProxy proxy) proxy.api_req_member_updatedeckname.TryParse().Subscribe(this.UpdateFleetName); proxy.api_req_hensei_combined.TryParse() - .Subscribe(x => this.Combined = x.Data.api_combined == 1); + .Subscribe(x => this.Combined = x.Data.api_combined != 0); proxy.ApiSessionSource .SkipUntil(proxy.api_req_map_start.TryParse().Do(this.Sortie)) From d6d6959737095f1edf5f97e4c9895daba7f65e45 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Wed, 11 Feb 2015 23:02:09 +0900 Subject: [PATCH 03/14] =?UTF-8?q?=E8=89=A6=E9=9A=8A=E3=82=BF=E3=83=96?= =?UTF-8?q?=E5=86=8D=E8=80=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Composition/PluginHost.cs | 6 ++---- Grabacr07.KanColleViewer/Models/NotifierHost.cs | 4 +--- .../Models/ResourceService.cs | 15 +++++---------- Grabacr07.KanColleViewer/Models/StatusService.cs | 3 +-- .../ViewModels/StartContentViewModel.cs | 4 +--- .../Views/Behaviors/FlickFleetsAction.cs | 10 ++-------- .../Views/Contents/Fleets.xaml | 3 ++- .../Models/ModernizableStatus.cs | 4 +--- Grabacr07.KanColleWrapper/Models/ShipInfo.cs | 8 +++----- Grabacr07.KanColleWrapper/Models/ShipType.cs | 10 ++++------ Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs | 8 +++----- 11 files changed, 25 insertions(+), 50 deletions(-) diff --git a/Grabacr07.KanColleViewer/Composition/PluginHost.cs b/Grabacr07.KanColleViewer/Composition/PluginHost.cs index 6060954b9..3cc468da4 100644 --- a/Grabacr07.KanColleViewer/Composition/PluginHost.cs +++ b/Grabacr07.KanColleViewer/Composition/PluginHost.cs @@ -22,13 +22,11 @@ public class PluginHost : IDisposable #region singleton members - private static readonly PluginHost instance = new PluginHost(); - - /// + /// /// のインスタンスを取得します。 /// /// のインスタンス。 - public static PluginHost Instance => instance; + public static PluginHost Instance { get; } = new PluginHost(); #endregion diff --git a/Grabacr07.KanColleViewer/Models/NotifierHost.cs b/Grabacr07.KanColleViewer/Models/NotifierHost.cs index 892c57193..a6549eeab 100644 --- a/Grabacr07.KanColleViewer/Models/NotifierHost.cs +++ b/Grabacr07.KanColleViewer/Models/NotifierHost.cs @@ -13,9 +13,7 @@ public class NotifierHost : NotificationObject { #region singleton members - private static readonly NotifierHost instance = new NotifierHost(); - - public static NotifierHost Instance => instance; + public static NotifierHost Instance { get; } = new NotifierHost(); #endregion diff --git a/Grabacr07.KanColleViewer/Models/ResourceService.cs b/Grabacr07.KanColleViewer/Models/ResourceService.cs index 2537bda4f..7415bf729 100644 --- a/Grabacr07.KanColleViewer/Models/ResourceService.cs +++ b/Grabacr07.KanColleViewer/Models/ResourceService.cs @@ -15,9 +15,7 @@ public class ResourceService : NotificationObject { #region static members - private static readonly ResourceService current = new ResourceService(); - - public static ResourceService Current => current; + public static ResourceService Current { get; } = new ResourceService(); #endregion @@ -32,22 +30,19 @@ public class ResourceService : NotificationObject "ko-KR", }; - private readonly Resources _Resources = new Resources(); - private readonly IReadOnlyCollection _SupportedCultures; - - /// + /// /// 多言語化されたリソースを取得します。 /// - public Resources Resources => this._Resources; + public Resources Resources { get; } = new Resources(); /// /// サポートされているカルチャを取得します。 /// - public IReadOnlyCollection SupportedCultures => this._SupportedCultures; + public IReadOnlyCollection SupportedCultures { get; } private ResourceService() { - this._SupportedCultures = this.supportedCultureNames + this.SupportedCultures = this.supportedCultureNames .Select(x => { try diff --git a/Grabacr07.KanColleViewer/Models/StatusService.cs b/Grabacr07.KanColleViewer/Models/StatusService.cs index f47605624..538d4329e 100644 --- a/Grabacr07.KanColleViewer/Models/StatusService.cs +++ b/Grabacr07.KanColleViewer/Models/StatusService.cs @@ -16,8 +16,7 @@ public class StatusService : NotificationObject { #region static members - private static readonly StatusService current = new StatusService(); - public static StatusService Current => current; + public static StatusService Current { get; } = new StatusService(); #endregion diff --git a/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs index 2450cbb5e..22c354605 100644 --- a/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs @@ -12,9 +12,7 @@ public class StartContentViewModel : ViewModel { #region singleton - private static readonly StartContentViewModel instance = new StartContentViewModel(); - - public static StartContentViewModel Instance => instance; + public static StartContentViewModel Instance { get; } = new StartContentViewModel(); #endregion diff --git a/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs b/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs index b4b2ddda6..d70e78610 100644 --- a/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs +++ b/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs @@ -15,15 +15,9 @@ public enum FlickOrientation public class FlickFleetsAction : TargetedTriggerAction { - private FlickOrientation orientation = FlickOrientation.Horizontal; + public FlickOrientation Orientation { get; set; } = FlickOrientation.Horizontal; - public FlickOrientation Orientation - { - get { return orientation; } - set { orientation = value; } - } - - public bool IsCyclic { get; set; } + public bool IsCyclic { get; set; } protected override void Invoke(object parameter) { diff --git a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml index 1aceb50e5..15801c3b7 100644 --- a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml +++ b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml @@ -58,7 +58,8 @@ + VerticalAlignment="Top" + Margin="0,0,10,0"> diff --git a/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs b/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs index caa940986..e31f429e0 100644 --- a/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs +++ b/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs @@ -62,9 +62,7 @@ public override string ToString() #region static members - private static readonly ModernizableStatus dummy = new ModernizableStatus(new[] { -1, -1 }, 0); - - public static ModernizableStatus Dummy => dummy; + public static ModernizableStatus Dummy { get; } = new ModernizableStatus(new[] { -1, -1 }, 0); #endregion } diff --git a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs index 313b1b7f9..a01bd8406 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs @@ -99,14 +99,12 @@ public override string ToString() #region static members - private static readonly ShipInfo dummy = new ShipInfo(new kcsapi_mst_ship + public static ShipInfo Dummy { get; } = new ShipInfo(new kcsapi_mst_ship { - api_id = 0, - api_name = "???" + api_id = 0, + api_name = "???" }); - public static ShipInfo Dummy => dummy; - #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/ShipType.cs b/Grabacr07.KanColleWrapper/Models/ShipType.cs index cdc29ebed..bc4986433 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipType.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipType.cs @@ -28,15 +28,13 @@ public override string ToString() #region static members - private static readonly ShipType dummy = new ShipType(new kcsapi_mst_stype + public static ShipType Dummy { get; } = new ShipType(new kcsapi_mst_stype { - api_id = 999, - api_sortno = 999, - api_name = "不審船", + api_id = 999, + api_sortno = 999, + api_name = "不審船", }); - public static ShipType Dummy => dummy; - #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs index 8935f89dd..15a2e8a37 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs @@ -60,14 +60,12 @@ public override string ToString() #region static members - private static readonly SlotItemInfo dummy = new SlotItemInfo(new kcsapi_mst_slotitem() + public static SlotItemInfo Dummy { get; } = new SlotItemInfo(new kcsapi_mst_slotitem() { - api_id = 0, - api_name = "???", + api_id = 0, + api_name = "???", }); - public static SlotItemInfo Dummy => dummy; - #endregion } } From b905a298ad38348dd11849767fea19d5ccf807c8 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Wed, 11 Feb 2015 23:23:15 +0900 Subject: [PATCH 04/14] =?UTF-8?q?Error=20"csc2.exe"=20exited=20with=20code?= =?UTF-8?q?=201.=20=E3=81=8C=E3=81=B2=E3=81=A9=E3=81=99=E3=81=8E=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=81=A7=E8=AB=A6=E3=82=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Grabacr07.KanColleWrapper/Homeport.cs | 4 +- Grabacr07.KanColleWrapper/KanColleClient.cs | 279 +++++++++--------- Grabacr07.KanColleWrapper/KanColleProxy.cs | 10 +- Grabacr07.KanColleWrapper/MasterTable.cs | 20 +- Grabacr07.KanColleWrapper/MemberTable.cs | 5 +- Grabacr07.KanColleWrapper/Models/Admiral.cs | 50 +++- .../Models/CreatedSlotItem.cs | 5 +- .../Models/ModernizableStatus.cs | 108 ++++--- Grabacr07.KanColleWrapper/Models/Quest.cs | 30 +- Grabacr07.KanColleWrapper/Models/Ship.cs | 45 ++- Grabacr07.KanColleWrapper/Models/ShipInfo.cs | 75 ++++- Grabacr07.KanColleWrapper/Models/ShipType.cs | 15 +- Grabacr07.KanColleWrapper/Models/SlotItem.cs | 5 +- .../Models/SlotItemInfo.cs | 105 ++++--- Grabacr07.KanColleWrapper/Models/SvData.cs | 20 +- Grabacr07.KanColleWrapper/Models/UseItem.cs | 15 +- .../Models/UseItemInfo.cs | 10 +- 17 files changed, 513 insertions(+), 288 deletions(-) diff --git a/Grabacr07.KanColleWrapper/Homeport.cs b/Grabacr07.KanColleWrapper/Homeport.cs index bafe844c8..3cb6329df 100644 --- a/Grabacr07.KanColleWrapper/Homeport.cs +++ b/Grabacr07.KanColleWrapper/Homeport.cs @@ -32,12 +32,12 @@ public class Homeport : NotificationObject /// /// 複数の建造ドックを持つ工廠を取得します。 /// - public Dockyard Dockyard { get; private set; } + public Dockyard Dockyard { get; } /// /// 複数の入渠ドックを持つ工廠を取得します。 /// - public Repairyard Repairyard { get; } + public Repairyard Repairyard { get; private set; } /// /// 任務情報を取得します。 diff --git a/Grabacr07.KanColleWrapper/KanColleClient.cs b/Grabacr07.KanColleWrapper/KanColleClient.cs index 0a418d27d..5d9e34ec4 100644 --- a/Grabacr07.KanColleWrapper/KanColleClient.cs +++ b/Grabacr07.KanColleWrapper/KanColleClient.cs @@ -11,141 +11,146 @@ namespace Grabacr07.KanColleWrapper { - public class KanColleClient : NotificationObject - { - #region singleton - - public static KanColleClient Current { get; } = new KanColleClient(); - - #endregion - - /// - /// 艦これの通信をフックするプロキシを取得します。 - /// - public KanColleProxy Proxy { get; private set; } - - /// - /// ユーザーに依存しないマスター情報を取得します。 - /// - public Master Master { get; private set; } - - /// - /// 母港の情報を取得します。 - /// - public Homeport Homeport { get; private set; } - - #region IsStarted 変更通知プロパティ - - private bool _IsStarted; - - /// - /// 艦これが開始されているかどうかを示す値を取得します。 - /// - public bool IsStarted - { - get { return this._IsStarted; } - set - { - if (this._IsStarted != value) - { - this._IsStarted = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - - #region IsInSortie 変更通知プロパティ - - private bool _IsInSortie; - - /// - /// 艦隊が出撃中かどうかを示す値を取得します。 - /// - public bool IsInSortie - { - get { return this._IsInSortie; } - private set - { - if (this._IsInSortie != value) - { - this._IsInSortie = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - - #region Settings 変更通知プロパティ - - private KanColleClientSettings _Settings; - - public KanColleClientSettings Settings - { - get { return this._Settings ?? (this._Settings = new KanColleClientSettings()); } - set - { - if (this._Settings != value) - { - this._Settings = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - - - private KanColleClient() - { - this.Initialieze(); - - var start = this.Proxy.api_req_map_start; - var end = this.Proxy.api_port; - - this.Proxy.ApiSessionSource - .SkipUntil(start.Do(_ => this.IsInSortie = true)) - .TakeUntil(end) - .Finally(() => this.IsInSortie = false) - .Repeat() - .Subscribe(); - } - - - public void Initialieze() - { - var proxy = this.Proxy ?? (this.Proxy = new KanColleProxy()); - var basic = proxy.api_get_member_basic.TryParse().FirstAsync().ToTask(); - var kdock = proxy.api_get_member_kdock.TryParse().FirstAsync().ToTask(); - var sitem = proxy.api_get_member_slot_item.TryParse().FirstAsync().ToTask(); - - proxy.api_start2.FirstAsync().Subscribe(async session => - { - var timeout = Task.Delay(TimeSpan.FromSeconds(20)); - var canInitialize = await Task.WhenAny(new Task[] { basic, kdock, sitem }.WhenAll(), timeout) != timeout; - - // タイムアウト仕掛けてるのは、今後のアップデートで basic, kdock, slot_item のいずれかが来なくなったときに - // 起動できなくなる (IsStarted を true にできなくなる) のを防ぐため - // ----- - // ま、そんな規模の変更があったらそもそもまともに動作せんだろうがな ☝(◞‸◟)☝ 野良ツールはつらいよ - - SvData svd; - if (!SvData.TryParse(session, out svd)) return; - - this.Master = new Master(svd.Data); - if (this.Homeport == null) this.Homeport = new Homeport(proxy); - - if (canInitialize) - { - this.Homeport.UpdateAdmiral((await basic).Data); - this.Homeport.Itemyard.Update((await sitem).Data); - this.Homeport.Dockyard.Update((await kdock).Data); - } - - this.IsStarted = true; - }); - } - } + public class KanColleClient : NotificationObject + { + #region singleton + + private static KanColleClient current = new KanColleClient(); + + public static KanColleClient Current + { + get { return current; } + } + + #endregion + + /// + /// 艦これの通信をフックするプロキシを取得します。 + /// + public KanColleProxy Proxy { get; private set; } + + /// + /// ユーザーに依存しないマスター情報を取得します。 + /// + public Master Master { get; private set; } + + /// + /// 母港の情報を取得します。 + /// + public Homeport Homeport { get; private set; } + + #region IsStarted 変更通知プロパティ + + private bool _IsStarted; + + /// + /// 艦これが開始されているかどうかを示す値を取得します。 + /// + public bool IsStarted + { + get { return this._IsStarted; } + set + { + if (this._IsStarted != value) + { + this._IsStarted = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + #region IsInSortie 変更通知プロパティ + + private bool _IsInSortie; + + /// + /// 艦隊が出撃中かどうかを示す値を取得します。 + /// + public bool IsInSortie + { + get { return this._IsInSortie; } + private set + { + if (this._IsInSortie != value) + { + this._IsInSortie = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + #region Settings 変更通知プロパティ + + private KanColleClientSettings _Settings; + + public KanColleClientSettings Settings + { + get { return this._Settings ?? (this._Settings = new KanColleClientSettings()); } + set + { + if (this._Settings != value) + { + this._Settings = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + + private KanColleClient() + { + this.Initialieze(); + + var start = this.Proxy.api_req_map_start; + var end = this.Proxy.api_port; + + this.Proxy.ApiSessionSource + .SkipUntil(start.Do(_ => this.IsInSortie = true)) + .TakeUntil(end) + .Finally(() => this.IsInSortie = false) + .Repeat() + .Subscribe(); + } + + + public void Initialieze() + { + var proxy = this.Proxy ?? (this.Proxy = new KanColleProxy()); + var basic = proxy.api_get_member_basic.TryParse().FirstAsync().ToTask(); + var kdock = proxy.api_get_member_kdock.TryParse().FirstAsync().ToTask(); + var sitem = proxy.api_get_member_slot_item.TryParse().FirstAsync().ToTask(); + + proxy.api_start2.FirstAsync().Subscribe(async session => + { + var timeout = Task.Delay(TimeSpan.FromSeconds(20)); + var canInitialize = await Task.WhenAny(new Task[] { basic, kdock, sitem }.WhenAll(), timeout) != timeout; + + // タイムアウト仕掛けてるのは、今後のアップデートで basic, kdock, slot_item のいずれかが来なくなったときに + // 起動できなくなる (IsStarted を true にできなくなる) のを防ぐため + // ----- + // ま、そんな規模の変更があったらそもそもまともに動作せんだろうがな ☝(◞‸◟)☝ 野良ツールはつらいよ + + SvData svd; + if (!SvData.TryParse(session, out svd)) return; + + this.Master = new Master(svd.Data); + if (this.Homeport == null) this.Homeport = new Homeport(proxy); + + if (canInitialize) + { + this.Homeport.UpdateAdmiral((await basic).Data); + this.Homeport.Itemyard.Update((await sitem).Data); + this.Homeport.Dockyard.Update((await kdock).Data); + } + + this.IsStarted = true; + }); + } + } } diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.cs b/Grabacr07.KanColleWrapper/KanColleProxy.cs index ba99270b9..6ffba07a2 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.cs +++ b/Grabacr07.KanColleWrapper/KanColleProxy.cs @@ -18,9 +18,15 @@ public partial class KanColleProxy private readonly IConnectableObservable apiSource; private readonly LivetCompositeDisposable compositeDisposable; - public IObservable SessionSource => this.connectableSessionSource.AsObservable(); + public IObservable SessionSource + { + get { return this.connectableSessionSource.AsObservable(); } + } - public IObservable ApiSessionSource => this.apiSource.AsObservable(); + public IObservable ApiSessionSource + { + get { return this.apiSource.AsObservable(); } + } public IProxySettings UpstreamProxySettings { get; set; } diff --git a/Grabacr07.KanColleWrapper/MasterTable.cs b/Grabacr07.KanColleWrapper/MasterTable.cs index aa1df2692..fcec3700f 100644 --- a/Grabacr07.KanColleWrapper/MasterTable.cs +++ b/Grabacr07.KanColleWrapper/MasterTable.cs @@ -18,7 +18,10 @@ public class MasterTable : IReadOnlyDictionary where TValue /// /// テーブルから指定した ID の要素を取得します。ID が存在しない場合は null を返します。 /// - public TValue this[int key] => this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; + public TValue this[int key] + { + get { return this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; } + } public MasterTable() : this(new List()) { } @@ -40,7 +43,10 @@ IEnumerator IEnumerable.GetEnumerator() return this.GetEnumerator(); } - public int Count => this.dictionary.Count; + public int Count + { + get { return this.dictionary.Count; } + } public bool ContainsKey(int key) { @@ -52,9 +58,15 @@ public bool TryGetValue(int key, out TValue value) return this.dictionary.TryGetValue(key, out value); } - public IEnumerable Keys => this.dictionary.Keys; + public IEnumerable Keys + { + get { return this.dictionary.Keys; } + } - public IEnumerable Values => this.dictionary.Values; + public IEnumerable Values + { + get { return this.dictionary.Values; } + } #endregion } diff --git a/Grabacr07.KanColleWrapper/MemberTable.cs b/Grabacr07.KanColleWrapper/MemberTable.cs index 284266acf..46a24673f 100644 --- a/Grabacr07.KanColleWrapper/MemberTable.cs +++ b/Grabacr07.KanColleWrapper/MemberTable.cs @@ -20,7 +20,10 @@ public class MemberTable : IReadOnlyDictionary where TValue /// /// テーブルから指定した ID の要素を取得します。ID が存在しない場合は null を返します。 /// - public TValue this[int key] => this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; + public TValue this[int key] + { + get { return this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; } + } public MemberTable() : this(new List()) { } diff --git a/Grabacr07.KanColleWrapper/Models/Admiral.cs b/Grabacr07.KanColleWrapper/Models/Admiral.cs index b910a60bc..c896cc2d5 100644 --- a/Grabacr07.KanColleWrapper/Models/Admiral.cs +++ b/Grabacr07.KanColleWrapper/Models/Admiral.cs @@ -14,9 +14,15 @@ namespace Grabacr07.KanColleWrapper.Models /// public class Admiral : RawDataWrapper { - public string MemberId => this.RawData.api_member_id; + public string MemberId + { + get { return this.RawData.api_member_id; } + } - public string Nickname => this.RawData.api_nickname; + public string Nickname + { + get { return this.RawData.api_nickname; } + } #region Comment 変更通知プロパティ @@ -41,32 +47,50 @@ public string Comment /// /// 提督経験値を取得します。 /// - public int Experience => this.RawData.api_experience; + public int Experience + { + get { return this.RawData.api_experience; } + } /// /// 次のレベルに上がるために必要な提督経験値を取得します。 /// - public int ExperienceForNexeLevel => Models.Experience.GetAdmiralExpForNextLevel(this.RawData.api_level, this.RawData.api_experience); + public int ExperienceForNexeLevel + { + get { return Models.Experience.GetAdmiralExpForNextLevel(this.RawData.api_level, this.RawData.api_experience); } + } /// /// 艦隊司令部レベルを取得します。 /// - public int Level => this.RawData.api_level; + public int Level + { + get { return this.RawData.api_level; } + } /// /// 提督のランク名 (元帥, 大将, 中将, ...) を取得します。 /// - public string Rank => Models.Rank.GetName(this.RawData.api_rank); + public string Rank + { + get { return Models.Rank.GetName(this.RawData.api_rank); } + } /// /// 出撃時の勝利数を取得します。 /// - public int SortieWins => this.RawData.api_st_win; + public int SortieWins + { + get { return this.RawData.api_st_win; } + } /// /// 出撃時の敗北数を取得します。 /// - public int SortieLoses => this.RawData.api_st_lose; + public int SortieLoses + { + get { return this.RawData.api_st_lose; } + } /// /// 出撃時の勝率を取得します。 @@ -84,12 +108,18 @@ public double SortieWinningRate /// /// 司令部に所属できる艦娘の最大値を取得します。 /// - public int MaxShipCount => this.RawData.api_max_chara; + public int MaxShipCount + { + get { return this.RawData.api_max_chara; } + } /// /// 司令部が保有できる装備アイテムの最大値を取得します。 /// - public int MaxSlotItemCount => this.RawData.api_max_slotitem; + public int MaxSlotItemCount + { + get { return this.RawData.api_max_slotitem; } + } internal Admiral(kcsapi_basic rawData) diff --git a/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs b/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs index f1a70b4b0..a36faef82 100644 --- a/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs +++ b/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs @@ -11,7 +11,10 @@ namespace Grabacr07.KanColleWrapper.Models /// public class CreatedSlotItem : RawDataWrapper { - public bool Succeed => this.RawData.api_create_flag == 1; + public bool Succeed + { + get { return this.RawData.api_create_flag == 1; } + } public SlotItemInfo SlotItemInfo { get; } diff --git a/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs b/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs index e31f429e0..6fa71c36f 100644 --- a/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs +++ b/Grabacr07.KanColleWrapper/Models/ModernizableStatus.cs @@ -6,64 +6,78 @@ namespace Grabacr07.KanColleWrapper.Models { - /// - /// 近代化改修による数値の上昇が可能なステータスを表します。 - /// - public struct ModernizableStatus - { - /// - /// 艦娘ごとに定義されたステータスの最大値を取得します。 - /// - public int Max { get; internal set; } + /// + /// 近代化改修による数値の上昇が可能なステータスを表します。 + /// + public struct ModernizableStatus + { + /// + /// 艦娘ごとに定義されたステータスの最大値を取得します。 + /// + public int Max { get; internal set; } - /// - /// 艦娘ごとに定義されたステータスの初期値を取得します。 - /// - public int Default { get; internal set; } + /// + /// 艦娘ごとに定義されたステータスの初期値を取得します。 + /// + public int Default { get; internal set; } - /// - /// 近代化改修による現在の上昇値を取得します。 - /// - public int Upgraded { get; internal set; } + /// + /// 近代化改修による現在の上昇値を取得します。 + /// + public int Upgraded { get; internal set; } - /// - /// 近代化改修によって上昇した分を含む現在のステータス値を取得します。 - /// - public int Current => this.Default + this.Upgraded; + /// + /// 近代化改修によって上昇した分を含む現在のステータス値を取得します。 + /// + public int Current + { + get { return this.Default + this.Upgraded; } + } - /// - /// このステータスが上限に達するのに必要な値を取得します。 - /// - public int Shortfall => this.Max - this.Current; + /// + /// このステータスが上限に達するのに必要な値を取得します。 + /// + public int Shortfall + { + get { return this.Max - this.Current; } + } - /// - /// このステータスが上限に達しているかどうかを示す値を取得します。 - /// - public bool IsMax => this.Max <= this.Current; + /// + /// このステータスが上限に達しているかどうかを示す値を取得します。 + /// + public bool IsMax + { + get { return this.Max <= this.Current; } + } - internal ModernizableStatus(int[] status, int upgraded) - : this() - { - if (status.Length == 2) - { - this.Default = status[0]; - this.Max = status[1]; - } + internal ModernizableStatus(int[] status, int upgraded) + : this() + { + if (status.Length == 2) + { + this.Default = status[0]; + this.Max = status[1]; + } - this.Upgraded = upgraded; - } + this.Upgraded = upgraded; + } - public override string ToString() - { - return string.Format("Status = {0}->{1}, Current = {2}{3}", this.Default, this.Max, this.Current, this.IsMax ? "(max)" : ""); - } + public override string ToString() + { + return string.Format("Status = {0}->{1}, Current = {2}{3}", this.Default, this.Max, this.Current, this.IsMax ? "(max)" : ""); + } - #region static members + #region static members - public static ModernizableStatus Dummy { get; } = new ModernizableStatus(new[] { -1, -1 }, 0); + private static ModernizableStatus dummy = new ModernizableStatus(new[] { -1, -1 }, 0); - #endregion - } + public static ModernizableStatus Dummy + { + get { return dummy; } + } + + #endregion + } } diff --git a/Grabacr07.KanColleWrapper/Models/Quest.cs b/Grabacr07.KanColleWrapper/Models/Quest.cs index b34c4e43a..71c18eb0b 100644 --- a/Grabacr07.KanColleWrapper/Models/Quest.cs +++ b/Grabacr07.KanColleWrapper/Models/Quest.cs @@ -14,32 +14,50 @@ public class Quest : RawDataWrapper, IIdentifiable /// /// 任務のカテゴリ (編成、出撃、演習 など) を取得します。 /// - public QuestCategory Category => (QuestCategory)this.RawData.api_category; + public QuestCategory Category + { + get { return (QuestCategory)this.RawData.api_category; } + } /// /// 任務の種類 (1 回のみ、デイリー、ウィークリー) を取得します。 /// - public QuestType Type => (QuestType)this.RawData.api_type; + public QuestType Type + { + get { return (QuestType)this.RawData.api_type; } + } /// /// 任務の状態を取得します。 /// - public QuestState State => (QuestState)this.RawData.api_state; + public QuestState State + { + get { return (QuestState)this.RawData.api_state; } + } /// /// 任務の進捗状況を取得します。 /// - public QuestProgress Progress => (QuestProgress)this.RawData.api_progress_flag; + public QuestProgress Progress + { + get { return (QuestProgress)this.RawData.api_progress_flag; } + } /// /// 任務名を取得します。 /// - public string Title => this.RawData.api_title; + public string Title + { + get { return this.RawData.api_title; } + } /// /// 任務の詳細を取得します。 /// - public string Detail => this.RawData.api_detail; + public string Detail + { + get { return this.RawData.api_detail; } + } public Quest(kcsapi_quest rawData) : base(rawData) { } diff --git a/Grabacr07.KanColleWrapper/Models/Ship.cs b/Grabacr07.KanColleWrapper/Models/Ship.cs index 209f3ac34..c6562e7a5 100644 --- a/Grabacr07.KanColleWrapper/Models/Ship.cs +++ b/Grabacr07.KanColleWrapper/Models/Ship.cs @@ -20,7 +20,10 @@ public class Ship : RawDataWrapper, IIdentifiable /// /// この艦娘を識別する ID を取得します。 /// - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } /// /// 艦娘の種類に基づく情報を取得します。 @@ -32,17 +35,26 @@ public class Ship : RawDataWrapper, IIdentifiable /// /// 艦娘の現在のレベルを取得します。 /// - public int Level => this.RawData.api_lv; + public int Level + { + get { return this.RawData.api_lv; } + } /// /// 艦娘がロックされているかどうかを示す値を取得します。 /// - public bool IsLocked => this.RawData.api_locked == 1; + public bool IsLocked + { + get { return this.RawData.api_locked == 1; } + } /// /// 艦娘の現在の累積経験値を取得します。 /// - public int Exp => this.RawData.api_exp.Get(0) ?? 0; + public int Exp + { + get { return this.RawData.api_exp.Get(0) ?? 0; } + } /// /// この艦娘が次のレベルに上がるために必要な経験値を取得します。 @@ -207,22 +219,34 @@ private set /// /// 装備によるボーナスを含めた索敵ステータス値を取得します。 /// - public int ViewRange => this.RawData.api_sakuteki.Get(0) ?? 0; + public int ViewRange + { + get { return this.RawData.api_sakuteki.Get(0) ?? 0; } + } /// /// 火力・雷装・対空・装甲のすべてのステータス値が最大値に達しているかどうかを示す値を取得します。 /// - public bool IsMaxModernized => this.Firepower.IsMax && this.Torpedo.IsMax && this.AA.IsMax && this.Armer.IsMax; + public bool IsMaxModernized + { + get { return this.Firepower.IsMax && this.Torpedo.IsMax && this.AA.IsMax && this.Armer.IsMax; } + } /// /// 現在のコンディション値を取得します。 /// - public int Condition => this.RawData.api_cond; + public int Condition + { + get { return this.RawData.api_cond; } + } /// /// コンディションの種類を示す 値を取得します。 /// - public ConditionType ConditionType => ConditionTypeHelper.ToConditionType(this.RawData.api_cond); + public ConditionType ConditionType + { + get { return ConditionTypeHelper.ToConditionType(this.RawData.api_cond); } + } public SlotItem[] SlotItems { get; private set; } @@ -274,7 +298,10 @@ internal set /// /// この艦が出撃した海域を識別する整数値を取得します。 /// - public int SallyArea => this.RawData.api_sally_area; + public int SallyArea + { + get { return this.RawData.api_sally_area; } + } internal Ship(Homeport parent, kcsapi_ship2 rawData) diff --git a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs index a01bd8406..3ff6fbd72 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs @@ -18,76 +18,121 @@ public class ShipInfo : RawDataWrapper, IIdentifiable /// /// 艦を一意に識別する ID を取得します。 /// - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public int SortId => this.RawData.api_sortno; + public int SortId + { + get { return this.RawData.api_sortno; } + } /// /// 艦の名称を取得します。 /// - public string Name => this.RawData.api_name; + public string Name + { + get { return this.RawData.api_name; } + } /// /// 艦種を取得します。 /// - public ShipType ShipType => this.shipType ?? (this.shipType = KanColleClient.Current.Master.ShipTypes[this.RawData.api_stype]) ?? ShipType.Dummy; + public ShipType ShipType + { + get { return this.shipType ?? (this.shipType = KanColleClient.Current.Master.ShipTypes[this.RawData.api_stype]) ?? ShipType.Dummy; } + } - public int[] Slots => this.RawData.api_maxeq; + public int[] Slots + { + get { return this.RawData.api_maxeq; } + } #region 用意したけど使わないっぽい? /// /// 火力の最大値を取得します。 /// - public int MaxFirepower => this.RawData.api_houg.Get(1) ?? 0; + public int MaxFirepower + { + get { return this.RawData.api_houg.Get(1) ?? 0; } + } /// /// 装甲の最大値を取得します。 /// - public int MaxArmer => this.RawData.api_souk.Get(1) ?? 0; + public int MaxArmer + { + get { return this.RawData.api_souk.Get(1) ?? 0; } + } /// /// 雷装の最大値を取得します。 /// - public int MaxTorpedo => this.RawData.api_raig.Get(1) ?? 0; + public int MaxTorpedo + { + get { return this.RawData.api_raig.Get(1) ?? 0; } + } /// /// 対空の最大値を取得します。 /// - public int MaxAA => this.RawData.api_tyku.Get(1) ?? 0; + public int MaxAA + { + get { return this.RawData.api_tyku.Get(1) ?? 0; } + } /// /// 耐久値を取得します。 /// - public int HP => this.RawData.api_taik.Get(0) ?? 0; + public int HP + { + get { return this.RawData.api_taik.Get(0) ?? 0; } + } /// /// 回避の最大値を取得します。 /// - public int MaxEvasion => this.RawData.api_kaih.Get(1) ?? 0; + public int MaxEvasion + { + get { return this.RawData.api_kaih.Get(1) ?? 0; } + } /// /// 対潜の最大値を取得します (ASW: Anti-submarine warfare)。 /// - public int MaxASW => this.RawData.api_tais.Get(1) ?? 0; + public int MaxASW + { + get { return this.RawData.api_tais.Get(1) ?? 0; } + } /// /// 索敵の最大値を取得します。 /// - public int MaxLOS => this.RawData.api_saku.Get(1) ?? 0; + public int MaxLOS + { + get { return this.RawData.api_saku.Get(1) ?? 0; } + } #endregion /// /// 速力を取得します。 /// - public Speed Speed => (Speed)this.RawData.api_soku; + public Speed Speed + { + get { return (Speed)this.RawData.api_soku; } + } /// /// 次の改造が実施できるレベルを取得します。 /// - public int? NextRemodelingLevel => this.RawData.api_afterlv == 0 ? null : (int?)this.RawData.api_afterlv; + public int? NextRemodelingLevel + { + get { return this.RawData.api_afterlv == 0 ? null : (int?)this.RawData.api_afterlv; } + } internal ShipInfo(kcsapi_mst_ship rawData) : base(rawData) { } diff --git a/Grabacr07.KanColleWrapper/Models/ShipType.cs b/Grabacr07.KanColleWrapper/Models/ShipType.cs index bc4986433..582fe2278 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipType.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipType.cs @@ -13,11 +13,20 @@ namespace Grabacr07.KanColleWrapper.Models /// public class ShipType : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public string Name => this.RawData.api_name; + public string Name + { + get { return this.RawData.api_name; } + } - public int SortNumber => this.RawData.api_sortno; + public int SortNumber + { + get { return this.RawData.api_sortno; } + } public ShipType(kcsapi_mst_stype rawData) : base(rawData) { } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItem.cs b/Grabacr07.KanColleWrapper/Models/SlotItem.cs index 111efc645..63103e80f 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItem.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItem.cs @@ -10,7 +10,10 @@ namespace Grabacr07.KanColleWrapper.Models { public class SlotItem : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } public SlotItemInfo Info { get; } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs index bad2e1293..bf14a09b2 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs @@ -9,43 +9,61 @@ namespace Grabacr07.KanColleWrapper.Models { - /// - /// 装備アイテムの種類に基づく情報を表します。 - /// - public class SlotItemInfo : RawDataWrapper, IIdentifiable - { + /// + /// 装備アイテムの種類に基づく情報を表します。 + /// + public class SlotItemInfo : RawDataWrapper, IIdentifiable + { private SlotItemType? type; - private SlotItemIconType? iconType; - private int? categoryId; + private SlotItemIconType? iconType; + private int? categoryId; - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public string Name => this.RawData.api_name; + public string Name + { + get { return this.RawData.api_name; } + } - public SlotItemType Type => this.type ?? (SlotItemType)(this.type = (SlotItemType)(this.RawData.api_type.Get(2) ?? 0)); + public SlotItemType Type + { + get { return this.type ?? (SlotItemType)(this.type = (SlotItemType)(this.RawData.api_type.Get(2) ?? 0)); } + } - public SlotItemIconType IconType => this.iconType ?? (SlotItemIconType)(this.iconType = (SlotItemIconType)(this.RawData.api_type.Get(3) ?? 0)); + public SlotItemIconType IconType + { + get { return this.iconType ?? (SlotItemIconType)(this.iconType = (SlotItemIconType)(this.RawData.api_type.Get(3) ?? 0)); } + } - public int CategoryId => this.categoryId ?? (int)(this.categoryId = this.RawData.api_type.Get(2) ?? int.MaxValue); + public int CategoryId + { + get { return this.categoryId ?? (int)(this.categoryId = this.RawData.api_type.Get(2) ?? int.MaxValue); } + } - /// - /// 対空値を取得します。 - /// - public int AA => this.RawData.api_tyku; + /// + /// 対空値を取得します。 + /// + public int AA + { + get { return this.RawData.api_tyku; } + } - /// - /// 制空戦に参加できる戦闘機または水上機かどうかを示す値を取得します。 - /// - public bool IsAirSuperiorityFighter - { - get - { - var type = this.RawData.api_type.Get(2); - return type.HasValue && (type == 6 || type == 7 || type == 8 || type == 11); - } - } + /// + /// 制空戦に参加できる戦闘機または水上機かどうかを示す値を取得します。 + /// + public bool IsAirSuperiorityFighter + { + get + { + var type = this.RawData.api_type.Get(2); + return type.HasValue && (type == 6 || type == 7 || type == 8 || type == 11); + } + } - public bool IsNumerable + public bool IsNumerable { get { @@ -54,21 +72,26 @@ public bool IsNumerable } } - internal SlotItemInfo(kcsapi_mst_slotitem rawData) : base(rawData) { } + internal SlotItemInfo(kcsapi_mst_slotitem rawData) : base(rawData) { } - public override string ToString() - { - return string.Format("ID = {0}, Name = \"{1}\", Type = {{{2}}}", this.Id, this.Name, this.RawData.api_type.ToString(", ")); - } + public override string ToString() + { + return string.Format("ID = {0}, Name = \"{1}\", Type = {{{2}}}", this.Id, this.Name, this.RawData.api_type.ToString(", ")); + } + + #region static members - #region static members + private static SlotItemInfo dummy = new SlotItemInfo(new kcsapi_mst_slotitem() + { + api_id = 0, + api_name = "???", + }); - public static SlotItemInfo Dummy { get; } = new SlotItemInfo(new kcsapi_mst_slotitem() - { - api_id = 0, - api_name = "???", - }); + public static SlotItemInfo Dummy + { + get { return dummy; } + } - #endregion - } + #endregion + } } diff --git a/Grabacr07.KanColleWrapper/Models/SvData.cs b/Grabacr07.KanColleWrapper/Models/SvData.cs index 6de9da60c..49c177749 100644 --- a/Grabacr07.KanColleWrapper/Models/SvData.cs +++ b/Grabacr07.KanColleWrapper/Models/SvData.cs @@ -18,11 +18,20 @@ public class SvData : RawDataWrapper> { public NameValueCollection Request { get; private set; } - public bool IsSuccess => this.RawData.api_result == 1; + public bool IsSuccess + { + get { return this.RawData.api_result == 1; } + } - public T Data => this.RawData.api_data; + public T Data + { + get { return this.RawData.api_data; } + } - public kcsapi_deck[] Fleets => this.RawData.api_data_deck; + public kcsapi_deck[] Fleets + { + get { return this.RawData.api_data_deck; } + } public SvData(svdata rawData, string reqBody) : base(rawData) @@ -35,7 +44,10 @@ public class SvData : RawDataWrapper { public NameValueCollection Request { get; private set; } - public bool IsSuccess => this.RawData.api_result == 1; + public bool IsSuccess + { + get { return this.RawData.api_result == 1; } + } public SvData(svdata rawData, string reqBody) : base(rawData) diff --git a/Grabacr07.KanColleWrapper/Models/UseItem.cs b/Grabacr07.KanColleWrapper/Models/UseItem.cs index efc63ad54..68f914e31 100644 --- a/Grabacr07.KanColleWrapper/Models/UseItem.cs +++ b/Grabacr07.KanColleWrapper/Models/UseItem.cs @@ -13,11 +13,20 @@ namespace Grabacr07.KanColleWrapper.Models /// public class UseItem : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public string Name => this.RawData.api_name; + public string Name + { + get { return this.RawData.api_name; } + } - public int Count => this.RawData.api_count; + public int Count + { + get { return this.RawData.api_count; } + } internal UseItem(kcsapi_useitem rawData) : base(rawData) { } diff --git a/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs b/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs index 5c011b69a..97744066c 100644 --- a/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/UseItemInfo.cs @@ -13,9 +13,15 @@ namespace Grabacr07.KanColleWrapper.Models /// public class UseItemInfo : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_id; + public int Id + { + get { return this.RawData.api_id; } + } - public string Name => this.RawData.api_name; + public string Name + { + get { return this.RawData.api_name; } + } internal UseItemInfo(kcsapi_mst_useitem rawData) : base(rawData) { } From af6bf4c75d0aa4a665d54b165316c849e1eb80ac Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Thu, 12 Feb 2015 00:04:15 +0900 Subject: [PATCH 05/14] C# 5.0 --- .../Composition/PluginHost.cs | 16 +- Grabacr07.KanColleViewer/Models/Helper.cs | 7 +- .../Models/NotifierHost.cs | 13 +- .../Models/ProductInfo.cs | 67 +++- .../Models/ResourceService.cs | 20 +- .../Models/StatusService.cs | 9 +- .../Catalogs/ShipCatalogSortWorker.cs | 12 +- .../Catalogs/ShipCatalogWindowViewModel.cs | 20 +- .../ViewModels/Catalogs/SlotItemViewModel.cs | 17 +- .../Composition/PluginViewModelBase.cs | 24 +- .../ViewModels/Composition/ToolViewModel.cs | 12 +- .../ViewModels/Contents/AdmiralViewModel.cs | 7 +- .../Contents/BuildingDockViewModel.cs | 25 +- .../Contents/Fleets/ConditionViewModel.cs | 35 ++- .../Contents/Fleets/ExpeditionViewModel.cs | 40 ++- .../Contents/Fleets/FleetViewModel.cs | 43 ++- .../Contents/Fleets/FleetsViewModel.cs | 7 +- .../Contents/Fleets/HomeportViewModel.cs | 2 +- .../ViewModels/Contents/OverviewViewModel.cs | 2 +- .../Contents/RepairingDockViewModel.cs | 38 ++- .../ViewModels/Contents/ShipSlotViewModel.cs | 6 +- .../ViewModels/Contents/ShipViewModel.cs | 2 +- .../ViewModels/Contents/ShipyardViewModel.cs | 2 +- .../ViewModels/MainContentViewModel.cs | 8 +- .../ViewModels/SettingsViewModel.cs | 7 +- .../ViewModels/StartContentViewModel.cs | 11 +- .../Views/Behaviors/FlickFleetsAction.cs | 7 +- Grabacr07.KanColleWrapper/Calculator.cs | 3 +- Grabacr07.KanColleWrapper/Homeport.cs | 6 +- Grabacr07.KanColleWrapper/Itemyard.cs | 37 ++- Grabacr07.KanColleWrapper/Materials.cs | 7 +- Grabacr07.KanColleWrapper/MemberTable.cs | 23 +- .../Models/CreatedSlotItem.cs | 2 +- .../Models/Expedition.cs | 7 +- .../Models/Experience.cs | 2 +- Grabacr07.KanColleWrapper/Models/Fleet.cs | 4 +- .../Models/FleetCondition.cs | 5 +- .../Models/LimitedValue.cs | 4 +- Grabacr07.KanColleWrapper/Models/Mission.cs | 2 +- Grabacr07.KanColleWrapper/Models/Quest.cs | 55 ++-- Grabacr07.KanColleWrapper/Models/Ship.cs | 10 +- Grabacr07.KanColleWrapper/Models/ShipInfo.cs | 293 +++++++++--------- Grabacr07.KanColleWrapper/Models/ShipType.cs | 35 ++- Grabacr07.KanColleWrapper/Models/SlotItem.cs | 2 +- Plugins/Counter/KanColleCounter.cs | 7 +- Plugins/MasterDataViewer/MasterDataViewer.cs | 7 +- Plugins/WindowsNotifier/Windows8Notifier.cs | 13 +- 47 files changed, 613 insertions(+), 370 deletions(-) diff --git a/Grabacr07.KanColleViewer/Composition/PluginHost.cs b/Grabacr07.KanColleViewer/Composition/PluginHost.cs index 3cc468da4..0505f84c4 100644 --- a/Grabacr07.KanColleViewer/Composition/PluginHost.cs +++ b/Grabacr07.KanColleViewer/Composition/PluginHost.cs @@ -22,13 +22,18 @@ public class PluginHost : IDisposable #region singleton members - /// + private static readonly PluginHost instance = new PluginHost(); + + /// /// のインスタンスを取得します。 /// /// のインスタンス。 - public static PluginHost Instance { get; } = new PluginHost(); + public static PluginHost Instance + { + get { return instance; } + } - #endregion + #endregion private readonly CompositionContainer container; @@ -69,6 +74,11 @@ private PluginHost() this.container = new CompositionContainer(catalog); } + static PluginHost() + { + + } + public void Dispose() { this.container.Dispose(); diff --git a/Grabacr07.KanColleViewer/Models/Helper.cs b/Grabacr07.KanColleViewer/Models/Helper.cs index 86610972b..f892026a7 100644 --- a/Grabacr07.KanColleViewer/Models/Helper.cs +++ b/Grabacr07.KanColleViewer/Models/Helper.cs @@ -31,10 +31,13 @@ static Helper() /// /// デザイナーのコンテキストで実行されているかどうかを取得します。 /// - public static bool IsInDesignMode => DesignerProperties.GetIsInDesignMode(new DependencyObject()); + public static bool IsInDesignMode + { + get { return DesignerProperties.GetIsInDesignMode(new DependencyObject()); } + } - public static string CreateScreenshotFilePath() + public static string CreateScreenshotFilePath() { var filePath = Path.Combine( Settings.Current.ScreenshotFolder, diff --git a/Grabacr07.KanColleViewer/Models/NotifierHost.cs b/Grabacr07.KanColleViewer/Models/NotifierHost.cs index a6549eeab..36bc69840 100644 --- a/Grabacr07.KanColleViewer/Models/NotifierHost.cs +++ b/Grabacr07.KanColleViewer/Models/NotifierHost.cs @@ -13,9 +13,14 @@ public class NotifierHost : NotificationObject { #region singleton members - public static NotifierHost Instance { get; } = new NotifierHost(); + private static readonly NotifierHost instance = new NotifierHost(); - #endregion + public static NotifierHost Instance + { + get { return instance; } + } + + #endregion private NotifierHost() { } @@ -75,8 +80,8 @@ private static void UpdateDockyard(Dockyard dockyard) { if (Settings.Current.NotifyBuildingCompleted) { - var shipName = Settings.Current.CanDisplayBuildingShipName - ? args.Ship.Name + var shipName = Settings.Current.CanDisplayBuildingShipName + ? args.Ship.Name : Resources.Common_ShipGirl; PluginHost.Instance.GetNotifier().Show( diff --git a/Grabacr07.KanColleViewer/Models/ProductInfo.cs b/Grabacr07.KanColleViewer/Models/ProductInfo.cs index 3085ba1c6..3a946cba7 100644 --- a/Grabacr07.KanColleViewer/Models/ProductInfo.cs +++ b/Grabacr07.KanColleViewer/Models/ProductInfo.cs @@ -20,34 +20,67 @@ public class ProductInfo private string _VersionString; private IReadOnlyCollection _Libraries; - public string Title => this._Title ?? (this._Title = ((AssemblyTitleAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTitleAttribute))).Title); + public string Title + { + get { return this._Title ?? (this._Title = ((AssemblyTitleAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTitleAttribute))).Title); } + } - public string Description => this._Description ?? (this._Description = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyDescriptionAttribute))).Description); + public string Description + { + get { return this._Description ?? (this._Description = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyDescriptionAttribute))).Description); } + } - public string Company => this._Company ?? (this._Company = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCompanyAttribute))).Company); + public string Company + { + get { return this._Company ?? (this._Company = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCompanyAttribute))).Company); } + } - public string Product => this._Product ?? (this._Product = ((AssemblyProductAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyProductAttribute))).Product); + public string Product + { + get { return this._Product ?? (this._Product = ((AssemblyProductAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyProductAttribute))).Product); } + } - public string Copyright => this._Copyright ?? (this._Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCopyrightAttribute))).Copyright); + public string Copyright + { + get { return this._Copyright ?? (this._Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCopyrightAttribute))).Copyright); } + } - public string Trademark => this._Trademark ?? (this._Trademark = ((AssemblyTrademarkAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTrademarkAttribute))).Trademark); + public string Trademark + { + get { return this._Trademark ?? (this._Trademark = ((AssemblyTrademarkAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTrademarkAttribute))).Trademark); } + } - public Version Version => this._Version ?? (this._Version = this.assembly.GetName().Version); + public Version Version + { + get { return this._Version ?? (this._Version = this.assembly.GetName().Version); } + } - public string VersionString => this._VersionString ?? (this._VersionString = string.Format("{0}{1}{2}", this.Version.ToString(3), this.IsBetaRelease ? " β" : "", this.Version.Revision == 0 ? "" : " rev." + this.Version.Revision)); + public string VersionString + { + get { return this._VersionString ?? (this._VersionString = string.Format("{0}{1}{2}", this.Version.ToString(3), this.IsBetaRelease ? " β" : "", this.Version.Revision == 0 ? "" : " rev." + this.Version.Revision)); } + } - public bool IsBetaRelease => false; + public bool IsBetaRelease + { + get { return false; } + } - public IReadOnlyCollection Libraries => this._Libraries ?? (this._Libraries = new List + public IReadOnlyCollection Libraries { - new Library("Reactive Extensions", new Uri("http://rx.codeplex.com/")), - new Library("Interactive Extensions", new Uri("http://rx.codeplex.com/")), - new Library("Windows API Code Pack", new Uri("http://archive.msdn.microsoft.com/WindowsAPICodePack")), - new Library("Livet", new Uri("http://ugaya40.net/livet")), - new Library("DynamicJson", new Uri("http://dynamicjson.codeplex.com/")), - new Library("FiddlerCore", new Uri("http://fiddler2.com/fiddlercore")), - }); + get + { + return this._Libraries ?? (this._Libraries = new List + { + new Library("Reactive Extensions", new Uri("http://rx.codeplex.com/")), + new Library("Interactive Extensions", new Uri("http://rx.codeplex.com/")), + new Library("Windows API Code Pack", new Uri("http://archive.msdn.microsoft.com/WindowsAPICodePack")), + new Library("Livet", new Uri("http://ugaya40.net/livet")), + new Library("DynamicJson", new Uri("http://dynamicjson.codeplex.com/")), + new Library("FiddlerCore", new Uri("http://fiddler2.com/fiddlercore")), + }); + } + } } public class Library diff --git a/Grabacr07.KanColleViewer/Models/ResourceService.cs b/Grabacr07.KanColleViewer/Models/ResourceService.cs index 7415bf729..55371cf8f 100644 --- a/Grabacr07.KanColleViewer/Models/ResourceService.cs +++ b/Grabacr07.KanColleViewer/Models/ResourceService.cs @@ -15,9 +15,14 @@ public class ResourceService : NotificationObject { #region static members - public static ResourceService Current { get; } = new ResourceService(); + private static readonly ResourceService current = new ResourceService(); - #endregion + public static ResourceService Current + { + get { return current; } + } + + #endregion /// /// サポートされているカルチャの名前。 @@ -30,18 +35,19 @@ public class ResourceService : NotificationObject "ko-KR", }; - /// + /// /// 多言語化されたリソースを取得します。 /// - public Resources Resources { get; } = new Resources(); + public Resources Resources { get; private set; } - /// + /// /// サポートされているカルチャを取得します。 /// - public IReadOnlyCollection SupportedCultures { get; } + public IReadOnlyCollection SupportedCultures { get; private set; } - private ResourceService() + private ResourceService() { + this.Resources = new Resources(); this.SupportedCultures = this.supportedCultureNames .Select(x => { diff --git a/Grabacr07.KanColleViewer/Models/StatusService.cs b/Grabacr07.KanColleViewer/Models/StatusService.cs index 538d4329e..3c844e0cc 100644 --- a/Grabacr07.KanColleViewer/Models/StatusService.cs +++ b/Grabacr07.KanColleViewer/Models/StatusService.cs @@ -16,9 +16,14 @@ public class StatusService : NotificationObject { #region static members - public static StatusService Current { get; } = new StatusService(); + private static readonly StatusService current = new StatusService(); - #endregion + public static StatusService Current + { + get { return current; } + } + + #endregion private readonly Subject notifier; private string persisitentMessage = ""; diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs index 50410de45..dca3edc69 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogSortWorker.cs @@ -15,12 +15,12 @@ public class ShipCatalogSortWorker private readonly NoneColumnViewModel noneColumn = new NoneColumnViewModel(); private SortableColumnViewModel currentSortTarget; - public IdColumnViewModel IdColumn { get; } - public TypeColumnViewModel TypeColumn { get; } - public NameColumnViewModel NameColumn { get; } - public LevelColumnViewModel LevelColumn { get; } - public ConditionColumnViewModel ConditionColumn { get; } - public ViewRangeColumnViewModel ViewRangeColumn { get; } + public IdColumnViewModel IdColumn { get; private set; } + public TypeColumnViewModel TypeColumn { get; private set; } + public NameColumnViewModel NameColumn { get; private set; } + public LevelColumnViewModel LevelColumn { get; private set; } + public ConditionColumnViewModel ConditionColumn { get; private set; } + public ViewRangeColumnViewModel ViewRangeColumn { get; private set; } public ShipCatalogSortWorker() { diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs index c796509f2..e27cc695e 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogWindowViewModel.cs @@ -17,16 +17,16 @@ public class ShipCatalogWindowViewModel : WindowViewModel private readonly Subject updateSource = new Subject(); private readonly Homeport homeport = KanColleClient.Current.Homeport; - public ShipCatalogSortWorker SortWorker { get; } - public IReadOnlyCollection ShipTypes { get; } - - public ShipLevelFilter ShipLevelFilter { get; } - public ShipLockFilter ShipLockFilter { get; } - public ShipSpeedFilter ShipSpeedFilter { get; } - public ShipModernizeFilter ShipModernizeFilter { get; } - public ShipRemodelingFilter ShipRemodelingFilter { get; } - public ShipExpeditionFilter ShipExpeditionFilter { get; } - public ShipSallyAreaFilter ShipSallyAreaFilter { get; } + public ShipCatalogSortWorker SortWorker { get; private set; } + public IReadOnlyCollection ShipTypes { get; private set; } + + public ShipLevelFilter ShipLevelFilter { get; private set; } + public ShipLockFilter ShipLockFilter { get; private set; } + public ShipSpeedFilter ShipSpeedFilter { get; private set; } + public ShipModernizeFilter ShipModernizeFilter { get; private set; } + public ShipRemodelingFilter ShipRemodelingFilter { get; private set; } + public ShipExpeditionFilter ShipExpeditionFilter { get; private set; } + public ShipSallyAreaFilter ShipSallyAreaFilter { get; private set; } public bool CheckAllShipTypes { diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs index c17766d53..9a6564a99 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemViewModel.cs @@ -12,18 +12,27 @@ namespace Grabacr07.KanColleViewer.ViewModels.Catalogs public class SlotItemViewModel : ViewModel { private int count; - public List Ships { get; } + public List Ships { get; private set; } public class Counter { public Ship Ship { get; set; } public int Count { get; set; } - public string ShipName => this.Ship.Info.Name; + public string ShipName + { + get { return this.Ship.Info.Name; } + } - public string ShipLevel => "Lv." + this.Ship.Level; + public string ShipLevel + { + get { return "Lv." + this.Ship.Level; } + } - public string CountString => this.Count == 1 ? "" : " x " + this.Count + " "; + public string CountString + { + get { return this.Count == 1 ? "" : " x " + this.Count + " "; } + } } diff --git a/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs b/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs index 976c469f3..3febf8091 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Composition/PluginViewModelBase.cs @@ -12,19 +12,31 @@ public abstract class PluginViewModelBase : ViewModel where TPlugin : I { protected TPlugin Plugin { get; private set; } - private IPluginMetadata Metadata { get; } + private IPluginMetadata Metadata { get; set; } - public string Title => this.Metadata.Title; + public string Title + { + get { return this.Metadata.Title; } + } - public string Description => this.Metadata.Description; + public string Description + { + get { return this.Metadata.Description; } + } - public string Author => this.Metadata.Author; + public string Author + { + get { return this.Metadata.Author; } + } - public string Version => this.Metadata.Version; + public string Version + { + get { return this.Metadata.Version; } + } - protected PluginViewModelBase(Lazy plugin) + protected PluginViewModelBase(Lazy plugin) { this.Plugin = plugin.Value; this.Metadata = plugin.Metadata; diff --git a/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs index a6de2e145..eb35303d9 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Composition/ToolViewModel.cs @@ -11,11 +11,17 @@ public class ToolViewModel : PluginViewModelBase { public ToolViewModel(Lazy plugin) : base(plugin) { } - public string ToolName => this.Plugin.ToolName; + public string ToolName + { + get { return this.Plugin.ToolName; } + } - public object View => this.Plugin.GetToolView(); + public object View + { + get { return this.Plugin.GetToolView(); } + } - public override string ToString() + public override string ToString() { return this.Title; } diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs index 0bdc9c72f..18516972f 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/AdmiralViewModel.cs @@ -13,9 +13,12 @@ public class AdmiralViewModel : ViewModel { #region Model 変更通知プロパティ - public Admiral Model => KanColleClient.Current.Homeport.Admiral; + public Admiral Model + { + get { return KanColleClient.Current.Homeport.Admiral; } + } - #endregion + #endregion public AdmiralViewModel() { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs index afad0b78d..1031b4298 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/BuildingDockViewModel.cs @@ -12,15 +12,30 @@ public class BuildingDockViewModel : ViewModel { private readonly BuildingDock source; - public int Id => this.source.Id; + public int Id + { + get { return this.source.Id; } + } - public string Ship => this.source.Ship == null ? "----" : this.source.Ship.Name; + public string Ship + { + get { return this.source.Ship == null ? "----" : this.source.Ship.Name; } + } - public string CompleteTime => this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; + public string CompleteTime + { + get { return this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; } + } - public string Remaining => this.source.Remaining.HasValue ? this.source.Remaining.Value.ToString(@"hh\:mm\:ss") : "--:--:--"; + public string Remaining + { + get { return this.source.Remaining.HasValue ? this.source.Remaining.Value.ToString(@"hh\:mm\:ss") : "--:--:--"; } + } - public BuildingDockState State => this.source.State; + public BuildingDockState State + { + get { return this.source.State; } + } public BuildingDockViewModel(BuildingDock source) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs index f1202a941..81d38b324 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ConditionViewModel.cs @@ -12,20 +12,35 @@ public class ConditionViewModel : ViewModel { private readonly FleetCondition source; - public string RejuvenateTime => this.source.RejuvenateTime.HasValue - ? this.source.RejuvenateTime.Value.LocalDateTime.ToString("MM/dd HH:mm") - : "--/-- --:--"; + public string RejuvenateTime + { + get + { + return this.source.RejuvenateTime.HasValue + ? this.source.RejuvenateTime.Value.LocalDateTime.ToString("MM/dd HH:mm") + : "--/-- --:--"; + } + } - public string Remaining => this.source.Remaining.HasValue - ? string.Format("{0:D2}:{1}", - (int)this.source.Remaining.Value.TotalHours, - this.source.Remaining.Value.ToString(@"mm\:ss")) - : "--:--:--"; + public string Remaining + { + get + { + return this.source.Remaining.HasValue + ? string.Format("{0:D2}:{1}", + (int)this.source.Remaining.Value.TotalHours, + this.source.Remaining.Value.ToString(@"mm\:ss")) + : "--:--:--"; + } + } - public bool IsRejuvenating => this.source.IsRejuvenating; + public bool IsRejuvenating + { + get { return this.source.IsRejuvenating; } + } - public ConditionViewModel(FleetCondition condition) + public ConditionViewModel(FleetCondition condition) { this.source = condition; this.CompositeDisposable.Add(new PropertyChangedEventListener(condition, (sender, args) => this.RaisePropertyChanged(args.PropertyName))); diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs index b192a858c..e528b5e98 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/ExpeditionViewModel.cs @@ -13,21 +13,39 @@ public class ExpeditionViewModel : ViewModel { private readonly Expedition source; - public Mission Mission => this.source.Mission; + public Mission Mission + { + get { return this.source.Mission; } + } - public bool IsInExecution => this.source.IsInExecution; + public bool IsInExecution + { + get { return this.source.IsInExecution; } + } - public string ReturnTime => this.source.ReturnTime.HasValue - ? this.source.ReturnTime.Value.LocalDateTime.ToString("MM/dd HH:mm") - : "--/-- --:--"; + public string ReturnTime + { + get + { + return this.source.ReturnTime.HasValue + ? this.source.ReturnTime.Value.LocalDateTime.ToString("MM/dd HH:mm") + : "--/-- --:--"; + } + } - public string Remaining => this.source.Remaining.HasValue - ? string.Format("{0:D2}:{1}", - (int)this.source.Remaining.Value.TotalHours, - this.source.Remaining.Value.ToString(@"mm\:ss")) - : "--:--:--"; + public string Remaining + { + get + { + return this.source.Remaining.HasValue + ? string.Format("{0:D2}:{1}", + (int)this.source.Remaining.Value.TotalHours, + this.source.Remaining.Value.ToString(@"mm\:ss")) + : "--:--:--"; + } + } - public ExpeditionViewModel(Expedition expedition) + public ExpeditionViewModel(Expedition expedition) { this.source = expedition; this.CompositeDisposable.Add(new PropertyChangedEventListener(expedition, (sender, args) => this.RaisePropertyChanged(args.PropertyName))); diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs index 1eb85a0f4..b6bd66533 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs @@ -17,11 +17,11 @@ public class FleetViewModel : ViewModel { private readonly Fleet source; - public SortieViewModel Sortie { get; } + public SortieViewModel Sortie { get; private set; } - public ExpeditionViewModel Expedition { get; } + public ExpeditionViewModel Expedition { get; private set; } - public HomeportViewModel Homeport { get; } + public HomeportViewModel Homeport { get; private set; } /// /// 艦隊に所属している艦娘のコレクションを取得します。 @@ -76,21 +76,42 @@ public bool IsSelected #region wrapper properties - public int Id => this.source.Id; + public int Id + { + get { return this.source.Id; } + } - public string Name => string.IsNullOrEmpty(this.source.Name.Trim()) ? "(第 " + this.source.Id + " 艦隊)" : this.source.Name; + public string Name + { + get { return string.IsNullOrEmpty(this.source.Name.Trim()) ? "(第 " + this.source.Id + " 艦隊)" : this.source.Name; } + } - public string TotalLevel => this.source.TotalLevel.ToString("####"); + public string TotalLevel + { + get { return this.source.TotalLevel.ToString("####"); } + } - public string AverageLevel => this.source.AverageLevel.ToString("##.##"); + public string AverageLevel + { + get { return this.source.AverageLevel.ToString("##.##"); } + } - public string Speed => this.source.Speed == KanColleWrapper.Models.Speed.Fast ? Resources.Fleets_Speed_Fast : Resources.Fleets_Speed_Slow; + public string Speed + { + get { return this.source.Speed == KanColleWrapper.Models.Speed.Fast ? Resources.Fleets_Speed_Fast : Resources.Fleets_Speed_Slow; } + } - public int AirSuperiorityPotential => this.source.AirSuperiorityPotential; + public int AirSuperiorityPotential + { + get { return this.source.AirSuperiorityPotential; } + } - public string TotalViewRange => this.source.TotalViewRange.ToString("####"); + public string TotalViewRange + { + get { return this.source.TotalViewRange.ToString("####"); } + } - #endregion + #endregion public FleetViewModel(Fleet fleet) diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs index 39fcf225e..72387bf7b 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetsViewModel.cs @@ -60,10 +60,13 @@ public FleetViewModel SelectedFleet #endregion - public bool IsSupportedNotification => Helper.IsWindows8OrGreater; + public bool IsSupportedNotification + { + get { return Helper.IsWindows8OrGreater; } + } - public FleetsViewModel() + public FleetsViewModel() { this.CompositeDisposable.Add(new PropertyChangedEventListener(KanColleClient.Current.Homeport.Organization) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs index 98695bf48..d00ce90aa 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/HomeportViewModel.cs @@ -15,7 +15,7 @@ public class HomeportViewModel : ViewModel { public Fleet Fleet { get; private set; } - public ConditionViewModel Condition { get; } + public ConditionViewModel Condition { get; private set; } public HomeportViewModel(Fleet fleet) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs index 83ecfb918..aa74a3cb9 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/OverviewViewModel.cs @@ -16,7 +16,7 @@ public override string Name protected set { throw new NotImplementedException(); } } - public MainContentViewModel Content { get; } + public MainContentViewModel Content { get; private set; } public OverviewViewModel(MainContentViewModel owner) diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs index 06734ea37..bc5914cc3 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/RepairingDockViewModel.cs @@ -12,21 +12,39 @@ public class RepairingDockViewModel : ViewModel { private readonly RepairingDock source; - public int Id => this.source.Id; + public int Id + { + get { return this.source.Id; } + } - public string Ship => this.source.Ship == null ? "----" : this.source.Ship.Info.Name; + public string Ship + { + get { return this.source.Ship == null ? "----" : this.source.Ship.Info.Name; } + } - public string CompleteTime => this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; + public string CompleteTime + { + get { return this.source.CompleteTime.HasValue ? this.source.CompleteTime.Value.LocalDateTime.ToString("MM/dd HH:mm") : "--/-- --:--:--"; } + } - public string Remaining => this.source.Remaining.HasValue - ? string.Format("{0:D2}:{1}", - (int)this.source.Remaining.Value.TotalHours, - this.source.Remaining.Value.ToString(@"mm\:ss")) - : "--:--:--"; + public string Remaining + { + get + { + return this.source.Remaining.HasValue + ? string.Format("{0:D2}:{1}", + (int)this.source.Remaining.Value.TotalHours, + this.source.Remaining.Value.ToString(@"mm\:ss")) + : "--:--:--"; + } + } - public RepairingDockState State => this.source.State; + public RepairingDockState State + { + get { return this.source.State; } + } - public RepairingDockViewModel(RepairingDock source) + public RepairingDockViewModel(RepairingDock source) { this.source = source; this.CompositeDisposable.Add(new PropertyChangedEventListener(source, (sender, args) => this.RaisePropertyChanged(args.PropertyName))); diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs index 8dbffe958..3ab774d62 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs @@ -9,11 +9,11 @@ namespace Grabacr07.KanColleViewer.ViewModels.Contents { public class ShipSlotViewModel : ViewModel { - public SlotItemInfo Item { get; } + public SlotItemInfo Item { get; private set; } - public string Current { get; } + public string Current { get; private set; } - public string Maximum { get; } + public string Maximum { get; private set; } public ShipSlotViewModel(Ship ship, int num) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs index e3524e805..4b9b840b2 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs @@ -11,7 +11,7 @@ public class ShipViewModel : ViewModel { public Ship Ship { get; private set; } - public ShipSlotViewModel[] Slots { get; } + public ShipSlotViewModel[] Slots { get; private set; } public ShipViewModel(Ship ship) { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs index a30075537..62672e29c 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipyardViewModel.cs @@ -53,7 +53,7 @@ public BuildingDockViewModel[] BuildingDocks #endregion - public CreatedSlotItemViewModel CreatedSlotItem { get; } + public CreatedSlotItemViewModel CreatedSlotItem { get; private set; } public ShipyardViewModel() diff --git a/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs index c874139b4..330eea2e8 100644 --- a/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/MainContentViewModel.cs @@ -16,10 +16,10 @@ public class MainContentViewModel : ViewModel public ShipsViewModel Ships { get; private set; } public SlotItemsViewModel SlotItems { get; private set; } - public FleetsViewModel Fleets { get; } - public ShipyardViewModel Shipyard { get; } - public QuestsViewModel Quests { get; } - public ExpeditionsViewModel Expeditions { get; } + public FleetsViewModel Fleets { get; private set; } + public ShipyardViewModel Shipyard { get; private set; } + public QuestsViewModel Quests { get; private set; } + public ExpeditionsViewModel Expeditions { get; private set; } public IList TabItems { get; set; } public IList SystemTabItems { get; set; } diff --git a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs index af8b88ea6..6287b54fb 100644 --- a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs @@ -48,9 +48,12 @@ public string ScreenshotFolder #region CanOpenScreenshotFolder 変更通知プロパティ - public bool CanOpenScreenshotFolder => Directory.Exists(this.ScreenshotFolder); + public bool CanOpenScreenshotFolder + { + get { return Directory.Exists(this.ScreenshotFolder); } + } - #endregion + #endregion #region ScreenshotImageFormat 変更通知プロパティ diff --git a/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs index 22c354605..a28379873 100644 --- a/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/StartContentViewModel.cs @@ -10,11 +10,16 @@ namespace Grabacr07.KanColleViewer.ViewModels { public class StartContentViewModel : ViewModel { - #region singleton + #region singleton - public static StartContentViewModel Instance { get; } = new StartContentViewModel(); + private static readonly StartContentViewModel instance = new StartContentViewModel(); - #endregion + public static StartContentViewModel Instance + { + get { return instance; } + } + + #endregion #region CanDeleteInternetCache 変更通知プロパティ diff --git a/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs b/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs index d70e78610..3aa503f2c 100644 --- a/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs +++ b/Grabacr07.KanColleViewer/Views/Behaviors/FlickFleetsAction.cs @@ -15,10 +15,15 @@ public enum FlickOrientation public class FlickFleetsAction : TargetedTriggerAction { - public FlickOrientation Orientation { get; set; } = FlickOrientation.Horizontal; + public FlickOrientation Orientation { get; set; } public bool IsCyclic { get; set; } + public FlickFleetsAction() + { + this.Orientation = FlickOrientation.Horizontal; + } + protected override void Invoke(object parameter) { if (!(parameter is FlickDirection)) return; diff --git a/Grabacr07.KanColleWrapper/Calculator.cs b/Grabacr07.KanColleWrapper/Calculator.cs index f887ab594..f9660b05d 100644 --- a/Grabacr07.KanColleWrapper/Calculator.cs +++ b/Grabacr07.KanColleWrapper/Calculator.cs @@ -159,5 +159,4 @@ public int Calc(Fleet fleet) return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); } } -} ------ \ No newline at end of file +} \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Homeport.cs b/Grabacr07.KanColleWrapper/Homeport.cs index 3cb6329df..a27c9bcd9 100644 --- a/Grabacr07.KanColleWrapper/Homeport.cs +++ b/Grabacr07.KanColleWrapper/Homeport.cs @@ -17,12 +17,12 @@ public class Homeport : NotificationObject /// /// 艦隊の編成状況にアクセスできるようにします。 /// - public Organization Organization { get; } + public Organization Organization { get; private set; } /// /// 資源および資材の保有状況にアクセスできるようにします。 /// - public Materials Materials { get; } + public Materials Materials { get; private set; } /// /// 装備や消費アイテムの保有状況にアクセスできるようにします。 @@ -32,7 +32,7 @@ public class Homeport : NotificationObject /// /// 複数の建造ドックを持つ工廠を取得します。 /// - public Dockyard Dockyard { get; } + public Dockyard Dockyard { get; private set; } /// /// 複数の入渠ドックを持つ工廠を取得します。 diff --git a/Grabacr07.KanColleWrapper/Itemyard.cs b/Grabacr07.KanColleWrapper/Itemyard.cs index bbf02ebff..e962ecb4c 100644 --- a/Grabacr07.KanColleWrapper/Itemyard.cs +++ b/Grabacr07.KanColleWrapper/Itemyard.cs @@ -22,9 +22,12 @@ public class Itemyard : NotificationObject /// /// と、出撃中に入手したものを含んだ装備数を取得します。 /// - public int SlotItemsCount => this.SlotItems.Count + this.droppedItemsCount; + public int SlotItemsCount + { + get { return this.SlotItems.Count + this.droppedItemsCount; } + } - #region SlotItems 変更通知プロパティ + #region SlotItems 変更通知プロパティ private MemberTable _SlotItems; @@ -144,21 +147,21 @@ private void DestroyItem(SvData data) private void DropShip(kcsapi_battleresult source) { - try - { - if (source.api_get_ship == null) return; - - var target = KanColleClient.Current.Master.Ships[source.api_get_ship.api_ship_id]; - if (target == null) return; - - this.droppedItemsCount += target.RawData.api_defeq.Count(x => x != -1); - this.RaisePropertyChanged("SlotItemsCount"); - } - catch (Exception ex) - { - // defeq が消えてるっぽい暫定対応 (雑) - Debug.WriteLine(ex); - } + try + { + if (source.api_get_ship == null) return; + + var target = KanColleClient.Current.Master.Ships[source.api_get_ship.api_ship_id]; + if (target == null) return; + + this.droppedItemsCount += target.RawData.api_defeq.Count(x => x != -1); + this.RaisePropertyChanged("SlotItemsCount"); + } + catch (Exception ex) + { + // defeq が消えてるっぽい暫定対応 (雑) + Debug.WriteLine(ex); + } } diff --git a/Grabacr07.KanColleWrapper/Materials.cs b/Grabacr07.KanColleWrapper/Materials.cs index 1d5267d23..55c6fa6f6 100644 --- a/Grabacr07.KanColleWrapper/Materials.cs +++ b/Grabacr07.KanColleWrapper/Materials.cs @@ -147,9 +147,12 @@ private set /// /// バケツ!!! ぶっかけ!!!! /// - public int Bucket => this.InstantRepairMaterials; + public int Bucket + { + get { return this.InstantRepairMaterials; } + } - #endregion + #endregion #region InstantBuildMaterials 変更通知プロパティ diff --git a/Grabacr07.KanColleWrapper/MemberTable.cs b/Grabacr07.KanColleWrapper/MemberTable.cs index 46a24673f..8e29acb5c 100644 --- a/Grabacr07.KanColleWrapper/MemberTable.cs +++ b/Grabacr07.KanColleWrapper/MemberTable.cs @@ -22,11 +22,11 @@ public class MemberTable : IReadOnlyDictionary where TValue /// public TValue this[int key] { - get { return this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; } + get { return this.dictionary.ContainsKey(key) ? this.dictionary[key] : null; } } - public MemberTable() : this(new List()) { } + public MemberTable() : this(new List()) { } public MemberTable(IEnumerable source) { @@ -62,9 +62,12 @@ IEnumerator IEnumerable.GetEnumerator() return this.GetEnumerator(); } - public int Count => this.dictionary.Count; + public int Count + { + get { return this.dictionary.Count; } + } - public bool ContainsKey(int key) + public bool ContainsKey(int key) { return this.dictionary.ContainsKey(key); } @@ -74,10 +77,16 @@ public bool TryGetValue(int key, out TValue value) return this.dictionary.TryGetValue(key, out value); } - public IEnumerable Keys => this.dictionary.Keys; + public IEnumerable Keys + { + get { return this.dictionary.Keys; } + } - public IEnumerable Values => this.dictionary.Values; + public IEnumerable Values + { + get { return this.dictionary.Values; } + } - #endregion + #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs b/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs index a36faef82..09128bf51 100644 --- a/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs +++ b/Grabacr07.KanColleWrapper/Models/CreatedSlotItem.cs @@ -16,7 +16,7 @@ public bool Succeed get { return this.RawData.api_create_flag == 1; } } - public SlotItemInfo SlotItemInfo { get; } + public SlotItemInfo SlotItemInfo { get; private set; } public CreatedSlotItem(kcsapi_createitem rawData) : base(rawData) diff --git a/Grabacr07.KanColleWrapper/Models/Expedition.cs b/Grabacr07.KanColleWrapper/Models/Expedition.cs index c49d9db7b..5c2977ec0 100644 --- a/Grabacr07.KanColleWrapper/Models/Expedition.cs +++ b/Grabacr07.KanColleWrapper/Models/Expedition.cs @@ -79,9 +79,12 @@ private set /// /// 現在遠征を実行中かどうかを示す値を取得します。 /// - public bool IsInExecution => this.ReturnTime.HasValue; + public bool IsInExecution + { + get { return this.ReturnTime.HasValue; } + } - #endregion + #endregion #region Remaining 変更通知プロパティ diff --git a/Grabacr07.KanColleWrapper/Models/Experience.cs b/Grabacr07.KanColleWrapper/Models/Experience.cs index d74f6aa81..82709a663 100644 --- a/Grabacr07.KanColleWrapper/Models/Experience.cs +++ b/Grabacr07.KanColleWrapper/Models/Experience.cs @@ -12,7 +12,7 @@ public class Experience { public int Level { get; private set; } public int Next { get; private set; } - public int Total { get; } + public int Total { get; private set; } private Experience(int level, int next, int total) { diff --git a/Grabacr07.KanColleWrapper/Models/Fleet.cs b/Grabacr07.KanColleWrapper/Models/Fleet.cs index b71c8d8ee..b848675fb 100644 --- a/Grabacr07.KanColleWrapper/Models/Fleet.cs +++ b/Grabacr07.KanColleWrapper/Models/Fleet.cs @@ -210,12 +210,12 @@ private set /// /// 艦隊に編成されている艦娘のコンディションを取得します。 /// - public FleetCondition Condition { get; } + public FleetCondition Condition { get; private set; } /// /// 艦隊の遠征に関するステータスを取得します。 /// - public Expedition Expedition { get; } + public Expedition Expedition { get; private set; } #region IsReady 変更通知プロパティ diff --git a/Grabacr07.KanColleWrapper/Models/FleetCondition.cs b/Grabacr07.KanColleWrapper/Models/FleetCondition.cs index eef8cd0c3..beadc381b 100644 --- a/Grabacr07.KanColleWrapper/Models/FleetCondition.cs +++ b/Grabacr07.KanColleWrapper/Models/FleetCondition.cs @@ -38,7 +38,10 @@ private set /// /// 艦隊に編成されている艦娘の疲労を自然回復しているかどうかを示す値を取得します。 /// - public bool IsRejuvenating => this.RejuvenateTime.HasValue; + public bool IsRejuvenating + { + get { return this.RejuvenateTime.HasValue; } + } #endregion diff --git a/Grabacr07.KanColleWrapper/Models/LimitedValue.cs b/Grabacr07.KanColleWrapper/Models/LimitedValue.cs index 38efdd24e..2e4e5d67a 100644 --- a/Grabacr07.KanColleWrapper/Models/LimitedValue.cs +++ b/Grabacr07.KanColleWrapper/Models/LimitedValue.cs @@ -19,12 +19,12 @@ public struct LimitedValue /// /// 最大値を取得します。 /// - public int Maximum { get; } + public int Maximum { get; private set; } /// /// 最小値を取得します。 /// - public int Minimum { get; } + public int Minimum { get; private set; } public LimitedValue(int current, int maximum, int minimum) : this() diff --git a/Grabacr07.KanColleWrapper/Models/Mission.cs b/Grabacr07.KanColleWrapper/Models/Mission.cs index 121b55f0f..9e4aa9c75 100644 --- a/Grabacr07.KanColleWrapper/Models/Mission.cs +++ b/Grabacr07.KanColleWrapper/Models/Mission.cs @@ -10,7 +10,7 @@ namespace Grabacr07.KanColleWrapper.Models [DebuggerDisplay("[{Id}] {Title} - {Detail}")] public class Mission : RawDataWrapper, IIdentifiable { - public int Id { get; } + public int Id { get; private set; } public string Title { get; private set; } diff --git a/Grabacr07.KanColleWrapper/Models/Quest.cs b/Grabacr07.KanColleWrapper/Models/Quest.cs index 71c18eb0b..0072b6a3c 100644 --- a/Grabacr07.KanColleWrapper/Models/Quest.cs +++ b/Grabacr07.KanColleWrapper/Models/Quest.cs @@ -9,58 +9,61 @@ namespace Grabacr07.KanColleWrapper.Models { public class Quest : RawDataWrapper, IIdentifiable { - public int Id => this.RawData.api_no; + public int Id + { + get { return this.RawData.api_no; } + } - /// + /// /// 任務のカテゴリ (編成、出撃、演習 など) を取得します。 /// public QuestCategory Category - { - get { return (QuestCategory)this.RawData.api_category; } - } + { + get { return (QuestCategory)this.RawData.api_category; } + } - /// + /// /// 任務の種類 (1 回のみ、デイリー、ウィークリー) を取得します。 /// public QuestType Type - { - get { return (QuestType)this.RawData.api_type; } - } + { + get { return (QuestType)this.RawData.api_type; } + } - /// + /// /// 任務の状態を取得します。 /// public QuestState State - { - get { return (QuestState)this.RawData.api_state; } - } + { + get { return (QuestState)this.RawData.api_state; } + } - /// + /// /// 任務の進捗状況を取得します。 /// public QuestProgress Progress - { - get { return (QuestProgress)this.RawData.api_progress_flag; } - } + { + get { return (QuestProgress)this.RawData.api_progress_flag; } + } - /// + /// /// 任務名を取得します。 /// public string Title - { - get { return this.RawData.api_title; } - } + { + get { return this.RawData.api_title; } + } - /// + /// /// 任務の詳細を取得します。 /// public string Detail - { - get { return this.RawData.api_detail; } - } + { + get { return this.RawData.api_detail; } + } - public Quest(kcsapi_quest rawData) : base(rawData) { } + public Quest(kcsapi_quest rawData) : base(rawData) { } public override string ToString() diff --git a/Grabacr07.KanColleWrapper/Models/Ship.cs b/Grabacr07.KanColleWrapper/Models/Ship.cs index c6562e7a5..9d87bd1a7 100644 --- a/Grabacr07.KanColleWrapper/Models/Ship.cs +++ b/Grabacr07.KanColleWrapper/Models/Ship.cs @@ -30,7 +30,10 @@ public int Id /// public ShipInfo Info { get; private set; } - public int SortNumber => this.RawData.api_sortno; + public int SortNumber + { + get { return this.RawData.api_sortno; } + } /// /// 艦娘の現在のレベルを取得します。 @@ -59,7 +62,10 @@ public int Exp /// /// この艦娘が次のレベルに上がるために必要な経験値を取得します。 /// - public int ExpForNextLevel => this.RawData.api_exp.Get(1) ?? 0; + public int ExpForNextLevel + { + get { return this.RawData.api_exp.Get(1) ?? 0; } + } #region HP 変更通知プロパティ diff --git a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs index 3ff6fbd72..c7e6c5cf8 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipInfo.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipInfo.cs @@ -8,148 +8,153 @@ namespace Grabacr07.KanColleWrapper.Models { - /// - /// 艦娘の種類に基づく情報を表します。 - /// - public class ShipInfo : RawDataWrapper, IIdentifiable - { - private ShipType shipType; - - /// - /// 艦を一意に識別する ID を取得します。 - /// - public int Id - { - get { return this.RawData.api_id; } - } - - public int SortId - { - get { return this.RawData.api_sortno; } - } - - /// - /// 艦の名称を取得します。 - /// - public string Name - { - get { return this.RawData.api_name; } - } - - /// - /// 艦種を取得します。 - /// - public ShipType ShipType - { - get { return this.shipType ?? (this.shipType = KanColleClient.Current.Master.ShipTypes[this.RawData.api_stype]) ?? ShipType.Dummy; } - } - - public int[] Slots - { - get { return this.RawData.api_maxeq; } - } - - #region 用意したけど使わないっぽい? - - /// - /// 火力の最大値を取得します。 - /// - public int MaxFirepower - { - get { return this.RawData.api_houg.Get(1) ?? 0; } - } - - /// - /// 装甲の最大値を取得します。 - /// - public int MaxArmer - { - get { return this.RawData.api_souk.Get(1) ?? 0; } - } - - /// - /// 雷装の最大値を取得します。 - /// - public int MaxTorpedo - { - get { return this.RawData.api_raig.Get(1) ?? 0; } - } - - /// - /// 対空の最大値を取得します。 - /// - public int MaxAA - { - get { return this.RawData.api_tyku.Get(1) ?? 0; } - } - - - /// - /// 耐久値を取得します。 - /// - public int HP - { - get { return this.RawData.api_taik.Get(0) ?? 0; } - } - - /// - /// 回避の最大値を取得します。 - /// - public int MaxEvasion - { - get { return this.RawData.api_kaih.Get(1) ?? 0; } - } - - /// - /// 対潜の最大値を取得します (ASW: Anti-submarine warfare)。 - /// - public int MaxASW - { - get { return this.RawData.api_tais.Get(1) ?? 0; } - } - - /// - /// 索敵の最大値を取得します。 - /// - public int MaxLOS - { - get { return this.RawData.api_saku.Get(1) ?? 0; } - } - - #endregion - - /// - /// 速力を取得します。 - /// - public Speed Speed - { - get { return (Speed)this.RawData.api_soku; } - } - - /// - /// 次の改造が実施できるレベルを取得します。 - /// - public int? NextRemodelingLevel - { - get { return this.RawData.api_afterlv == 0 ? null : (int?)this.RawData.api_afterlv; } - } - - - internal ShipInfo(kcsapi_mst_ship rawData) : base(rawData) { } - - public override string ToString() - { - return string.Format("ID = {0}, Name = \"{1}\", ShipType = \"{2}\"", this.Id, this.Name, this.ShipType.Name); - } - - #region static members - - public static ShipInfo Dummy { get; } = new ShipInfo(new kcsapi_mst_ship - { - api_id = 0, - api_name = "???" - }); - - #endregion - } + /// + /// 艦娘の種類に基づく情報を表します。 + /// + public class ShipInfo : RawDataWrapper, IIdentifiable + { + private ShipType shipType; + + /// + /// 艦を一意に識別する ID を取得します。 + /// + public int Id + { + get { return this.RawData.api_id; } + } + + public int SortId + { + get { return this.RawData.api_sortno; } + } + + /// + /// 艦の名称を取得します。 + /// + public string Name + { + get { return this.RawData.api_name; } + } + + /// + /// 艦種を取得します。 + /// + public ShipType ShipType + { + get { return this.shipType ?? (this.shipType = KanColleClient.Current.Master.ShipTypes[this.RawData.api_stype]) ?? ShipType.Dummy; } + } + + public int[] Slots + { + get { return this.RawData.api_maxeq; } + } + + #region 用意したけど使わないっぽい? + + /// + /// 火力の最大値を取得します。 + /// + public int MaxFirepower + { + get { return this.RawData.api_houg.Get(1) ?? 0; } + } + + /// + /// 装甲の最大値を取得します。 + /// + public int MaxArmer + { + get { return this.RawData.api_souk.Get(1) ?? 0; } + } + + /// + /// 雷装の最大値を取得します。 + /// + public int MaxTorpedo + { + get { return this.RawData.api_raig.Get(1) ?? 0; } + } + + /// + /// 対空の最大値を取得します。 + /// + public int MaxAA + { + get { return this.RawData.api_tyku.Get(1) ?? 0; } + } + + + /// + /// 耐久値を取得します。 + /// + public int HP + { + get { return this.RawData.api_taik.Get(0) ?? 0; } + } + + /// + /// 回避の最大値を取得します。 + /// + public int MaxEvasion + { + get { return this.RawData.api_kaih.Get(1) ?? 0; } + } + + /// + /// 対潜の最大値を取得します (ASW: Anti-submarine warfare)。 + /// + public int MaxASW + { + get { return this.RawData.api_tais.Get(1) ?? 0; } + } + + /// + /// 索敵の最大値を取得します。 + /// + public int MaxLOS + { + get { return this.RawData.api_saku.Get(1) ?? 0; } + } + + #endregion + + /// + /// 速力を取得します。 + /// + public Speed Speed + { + get { return (Speed)this.RawData.api_soku; } + } + + /// + /// 次の改造が実施できるレベルを取得します。 + /// + public int? NextRemodelingLevel + { + get { return this.RawData.api_afterlv == 0 ? null : (int?)this.RawData.api_afterlv; } + } + + + internal ShipInfo(kcsapi_mst_ship rawData) : base(rawData) { } + + public override string ToString() + { + return string.Format("ID = {0}, Name = \"{1}\", ShipType = \"{2}\"", this.Id, this.Name, this.ShipType.Name); + } + + #region static members + + private static ShipInfo dummy = new ShipInfo(new kcsapi_mst_ship + { + api_id = 0, + api_name = "???" + }); + + public static ShipInfo Dummy + { + get { return dummy; } + } + + #endregion + } } diff --git a/Grabacr07.KanColleWrapper/Models/ShipType.cs b/Grabacr07.KanColleWrapper/Models/ShipType.cs index 582fe2278..219ddb2c4 100644 --- a/Grabacr07.KanColleWrapper/Models/ShipType.cs +++ b/Grabacr07.KanColleWrapper/Models/ShipType.cs @@ -15,20 +15,20 @@ public class ShipType : RawDataWrapper, IIdentifiable { public int Id { - get { return this.RawData.api_id; } + get { return this.RawData.api_id; } } - public string Name - { - get { return this.RawData.api_name; } - } + public string Name + { + get { return this.RawData.api_name; } + } - public int SortNumber - { - get { return this.RawData.api_sortno; } - } + public int SortNumber + { + get { return this.RawData.api_sortno; } + } - public ShipType(kcsapi_mst_stype rawData) : base(rawData) { } + public ShipType(kcsapi_mst_stype rawData) : base(rawData) { } public override string ToString() { @@ -37,13 +37,18 @@ public override string ToString() #region static members - public static ShipType Dummy { get; } = new ShipType(new kcsapi_mst_stype + private static ShipType dummy = new ShipType(new kcsapi_mst_stype { - api_id = 999, - api_sortno = 999, - api_name = "不審船", + api_id = 999, + api_sortno = 999, + api_name = "不審船", }); - #endregion + public static ShipType Dummy + { + get { return dummy; } + } + + #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/SlotItem.cs b/Grabacr07.KanColleWrapper/Models/SlotItem.cs index 63103e80f..8319f1461 100644 --- a/Grabacr07.KanColleWrapper/Models/SlotItem.cs +++ b/Grabacr07.KanColleWrapper/Models/SlotItem.cs @@ -15,7 +15,7 @@ public int Id get { return this.RawData.api_id; } } - public SlotItemInfo Info { get; } + public SlotItemInfo Info { get; private set; } internal SlotItem(kcsapi_slotitem rawData) : base(rawData) { diff --git a/Plugins/Counter/KanColleCounter.cs b/Plugins/Counter/KanColleCounter.cs index 6a6106385..ffb6c46c5 100644 --- a/Plugins/Counter/KanColleCounter.cs +++ b/Plugins/Counter/KanColleCounter.cs @@ -26,9 +26,12 @@ public class KanColleCounter : IToolPlugin } }; - public string ToolName => "Counter"; + public string ToolName + { + get { return "Counter"; } + } - public object GetSettingsView() + public object GetSettingsView() { return null; } diff --git a/Plugins/MasterDataViewer/MasterDataViewer.cs b/Plugins/MasterDataViewer/MasterDataViewer.cs index b5ee9bced..a13d28809 100644 --- a/Plugins/MasterDataViewer/MasterDataViewer.cs +++ b/Plugins/MasterDataViewer/MasterDataViewer.cs @@ -18,10 +18,13 @@ public class MasterDataViewer : IToolPlugin { private readonly PortalViewModel portalViewModel = new PortalViewModel(); - public string ToolName => "MasterView"; + public string ToolName + { + get { return "MasterView"; } + } - public object GetSettingsView() + public object GetSettingsView() { return null; } diff --git a/Plugins/WindowsNotifier/Windows8Notifier.cs b/Plugins/WindowsNotifier/Windows8Notifier.cs index 583f0446a..468a5859a 100644 --- a/Plugins/WindowsNotifier/Windows8Notifier.cs +++ b/Plugins/WindowsNotifier/Windows8Notifier.cs @@ -14,9 +14,12 @@ internal class Windows8Notifier : INotifier { #region static members - public static bool IsSupported => Toast.IsSupported; + public static bool IsSupported + { + get { return Toast.IsSupported; } + } - #endregion + #endregion public void Initialize() { @@ -41,12 +44,12 @@ public void Initialize() private static void InstallShortcut(string shortcutPath) { var exePath = Process.GetCurrentProcess().MainModule.FileName; - var newShortcut = (IShellLinkW) new CShellLink(); + var newShortcut = (IShellLinkW)new CShellLink(); ErrorHelper.VerifySucceeded(newShortcut.SetPath(exePath)); ErrorHelper.VerifySucceeded(newShortcut.SetArguments("")); - var newShortcutProperties = (IPropertyStore) newShortcut; + var newShortcutProperties = (IPropertyStore)newShortcut; using (var appId = new PropVariant(Toast.AppId)) { @@ -54,7 +57,7 @@ private static void InstallShortcut(string shortcutPath) ErrorHelper.VerifySucceeded(newShortcutProperties.Commit()); } - var newShortcutSave = (IPersistFile) newShortcut; + var newShortcutSave = (IPersistFile)newShortcut; ErrorHelper.VerifySucceeded(newShortcutSave.Save(shortcutPath, true)); } From d0a38c43122fe8100244ab3d14205d59df69ec74 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Thu, 12 Feb 2015 03:39:41 +0900 Subject: [PATCH 06/14] =?UTF-8?q?=E7=B4=A2=E6=95=B5=E5=80=A4=E8=A8=88?= =?UTF-8?q?=E7=AE=97=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF=E3=81=AB=20[2-5?= =?UTF-8?q?=20=E5=BC=8F=20(=E7=A7=8B)]=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KanColleViewer.csproj | 1 - .../Catalogs/SlotItemCatalogViewModel.cs | 2 +- .../ViewModels/Contents/ShipSlotViewModel.cs | 27 - .../ViewModels/Contents/ShipViewModel.cs | 19 +- .../Views/Contents/Fleets.xaml | 688 +++++++++--------- Grabacr07.KanColleWrapper/Calculator.cs | 234 +++--- Grabacr07.KanColleWrapper/Itemyard.cs | 4 +- .../KanColleWrapper.csproj | 1 + Grabacr07.KanColleWrapper/Models/Ship.cs | 139 ++-- Grabacr07.KanColleWrapper/Models/ViewRange.cs | 168 +++++ 10 files changed, 685 insertions(+), 598 deletions(-) delete mode 100644 Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs create mode 100644 Grabacr07.KanColleWrapper/Models/ViewRange.cs diff --git a/Grabacr07.KanColleViewer/KanColleViewer.csproj b/Grabacr07.KanColleViewer/KanColleViewer.csproj index 8f2939a90..b471a92bd 100644 --- a/Grabacr07.KanColleViewer/KanColleViewer.csproj +++ b/Grabacr07.KanColleViewer/KanColleViewer.csproj @@ -171,7 +171,6 @@ - diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs index 2ff5d05c9..89f41e25f 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs @@ -79,7 +79,7 @@ private static Task> UpdateCore() foreach (var ship in ships.Values) { - foreach (var target in ship.SlotItems.Where(x => x != null).Select(item => dic[item.Info.Id])) + foreach (var target in ship.Slots.Where(x => x.Equipped).Select(slot => dic[slot.Item.Info.Id])) { target.AddShip(ship); } diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs deleted file mode 100644 index 3ab774d62..000000000 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipSlotViewModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Grabacr07.KanColleWrapper.Models; -using Livet; - -namespace Grabacr07.KanColleViewer.ViewModels.Contents -{ - public class ShipSlotViewModel : ViewModel - { - public SlotItemInfo Item { get; private set; } - - public string Current { get; private set; } - - public string Maximum { get; private set; } - - public ShipSlotViewModel(Ship ship, int num) - { - var info = ship.SlotItems[num].Info; - - this.Item = info; - this.Current = info.IsNumerable ? ship.OnSlot[num].ToString() : "-"; - this.Maximum = ship.Info.Slots[num].ToString(); - } - } -} \ No newline at end of file diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs index 4b9b840b2..87503e279 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/ShipViewModel.cs @@ -7,16 +7,13 @@ namespace Grabacr07.KanColleViewer.ViewModels.Contents { - public class ShipViewModel : ViewModel - { - public Ship Ship { get; private set; } + public class ShipViewModel : ViewModel + { + public Ship Ship { get; private set; } - public ShipSlotViewModel[] Slots { get; private set; } - - public ShipViewModel(Ship ship) - { - this.Ship = ship; - this.Slots = ship.SlotItems.Select((_, i) => new ShipSlotViewModel(ship, i)).ToArray(); - } - } + public ShipViewModel(Ship ship) + { + this.Ship = ship; + } + } } diff --git a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml index 15801c3b7..6e9969da1 100644 --- a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml +++ b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml @@ -1,401 +1,401 @@  + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" + xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:livet="http://schemas.livet-mvvm.net/2011/wpf" + xmlns:controls="clr-namespace:Grabacr07.KanColleViewer.Views.Controls" + xmlns:views="clr-namespace:Grabacr07.KanColleViewer.Views" + xmlns:vm="clr-namespace:Grabacr07.KanColleViewer.ViewModels" + xmlns:behaviors="clr-namespace:Grabacr07.KanColleViewer.Views.Behaviors" + xmlns:fleets="clr-namespace:Grabacr07.KanColleViewer.ViewModels.Contents.Fleets" + xmlns:contents="clr-namespace:Grabacr07.KanColleViewer.Views.Contents" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="400" + d:DataContext="{d:DesignInstance fleets:FleetsViewModel}"> - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - + + FontSize="18" + Style="{DynamicResource EmphaticTextElementStyleKey}" /> - + FontSize="14" /> + - + + FontSize="18" + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + FontSize="9" /> - - + FontSize="9" /> + + - - - - - - + + + + + + - - + + + Style="{DynamicResource EmphaticTextElementStyleKey}" /> - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + + FontSize="14" /> - + FontSize="22" + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + - + - + FontSize="22" + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + - + - - + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + + + FontSize="9" /> + FontSize="9" /> - + - + + Style="{DynamicResource EmphaticTextElementStyleKey}" /> - - + + - - - - + + + + - + - - + Style="{DynamicResource EmphaticTextElementStyleKey}" /> + + - + FontSize="9" /> + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Calculator.cs b/Grabacr07.KanColleWrapper/Calculator.cs index f9660b05d..b3e103bcb 100644 --- a/Grabacr07.KanColleWrapper/Calculator.cs +++ b/Grabacr07.KanColleWrapper/Calculator.cs @@ -7,156 +7,86 @@ namespace Grabacr07.KanColleWrapper { - internal static class Calculator - { - /// - /// 装備と搭載数を指定して、スロット単位の制空能力を計算します。 - /// - /// 対空能力を持つ装備。 - /// 搭載数。 - /// - public static int CalcAirSuperiorityPotential(this SlotItem slotItem, int onslot) - { - if (slotItem.Info.IsAirSuperiorityFighter) - { - return (int)(slotItem.Info.AA * Math.Sqrt(onslot)); - } - - return 0; - } - - /// - /// 指定した艦の制空能力を計算します。 - /// - public static int CalcAirSuperiorityPotential(this Ship ship) - { - return ship.SlotItems.Zip(ship.OnSlot, (item, i) => item.CalcAirSuperiorityPotential(i)).Sum(); - } - - - /// - /// 艦隊の索敵値を計算します。 - /// - /// - public static int CalcFleetViewRange(this Fleet fleet, ViewRangeCalcLogic logic) - { - if (fleet == null || fleet.Ships.Length == 0) return 0; - - if (logic == ViewRangeCalcLogic.Type1) - { - return fleet.Ships.Sum(x => x.ViewRange); - } - - if (logic == ViewRangeCalcLogic.Type2) - { - // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 - // [索敵装備と装備例] によって示されている計算式 - // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 - - var spotter = fleet.Ships.SelectMany( - x => x.SlotItems - .Zip(x.OnSlot, (i, o) => new { Item = i.Info, Slot = o }) - .Where(a => a.Item.RawData.api_type.Get(1) == 7) - .Where(a => a.Slot > 0) - .Select(a => a.Item.RawData.api_saku) - ).Sum(); - - var radar = fleet.Ships.SelectMany( - x => x.SlotItems - .Where(i => i.Info.RawData.api_type.Get(1) == 8) - .Select(i => i.Info.RawData.api_saku) - ).Sum(); - - return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); - } - - if (logic == ViewRangeCalcLogic.Type3) - { - - } - - return 0; - } - } - - - /// - /// 索敵値の計算に使用するロジックの種類を示す識別します。 - /// - public enum ViewRangeCalcLogic - { - /// - /// 単純な索敵合計値。 - /// - Type1, - - /// - /// (偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)。 - /// - Type2, - - Type3, - } - - - public interface ICalcViewRange - { - string Description { get; } - - int Calc(Fleet fleet); - } - - public class ViewRangeType1 : ICalcViewRange - { - public string Description - { - get - { - throw new NotImplementedException(); - } - } - - public int Calc(Fleet fleet) - { - if (fleet == null || fleet.Ships.Length == 0) return 0; - - return fleet.Ships.Sum(x => x.ViewRange); - } - } - - public class ViewRangeType2 : ICalcViewRange - { - public string Description - { - get - { - throw new NotImplementedException(); - } - } - - public int Calc(Fleet fleet) - { - if (fleet == null || fleet.Ships.Length == 0) return 0; - - // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 - // [索敵装備と装備例] によって示されている計算式 - // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 - - var spotter = fleet.Ships.SelectMany( - x => x.SlotItems - .Zip(x.OnSlot, (i, o) => new { Item = i.Info, Slot = o }) - .Where(a => a.Item.RawData.api_type.Get(1) == 7) - .Where(a => a.Slot > 0) - .Select(a => a.Item.RawData.api_saku) - ).Sum(); - - var radar = fleet.Ships.SelectMany( - x => x.SlotItems - .Where(i => i.Info.RawData.api_type.Get(1) == 8) - .Select(i => i.Info.RawData.api_saku) - ).Sum(); - - return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); - } - } + internal static class Calculator + { + /// + /// 装備と搭載数を指定して、スロット単位の制空能力を計算します。 + /// + /// 対空能力を持つ装備。 + /// 搭載数。 + /// + public static int CalcAirSuperiorityPotential(this SlotItem slotItem, int onslot) + { + if (slotItem.Info.IsAirSuperiorityFighter) + { + return (int)(slotItem.Info.AA * Math.Sqrt(onslot)); + } + + return 0; + } + + /// + /// 指定した艦の制空能力を計算します。 + /// + public static int CalcAirSuperiorityPotential(this Ship ship) + { + return ship.Slots.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)).Sum(); + } + + + /// + /// 艦隊の索敵値を計算します。 + /// + /// + public static int CalcFleetViewRange(this Fleet fleet, ViewRangeCalcLogic logic) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + if (logic == ViewRangeCalcLogic.Type1) + { + return fleet.Ships.Sum(x => x.ViewRange); + } + + if (logic == ViewRangeCalcLogic.Type2) + { + // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 + // [索敵装備と装備例] によって示されている計算式 + // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 + + var spotter = fleet.Ships.SelectMany( + x => x.Slots + .Where(s => s.Item.Info.RawData.api_type.Get(1) == 7) + .Where(s => s.Current > 0) + .Select(s => s.Item.Info.RawData.api_saku) + ).Sum(); + + var radar = fleet.Ships.SelectMany( + x => x.Slots + .Where(s => s.Item.Info.RawData.api_type.Get(1) == 8) + .Select(s => s.Item.Info.RawData.api_saku) + ).Sum(); + + return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); + } + + return 0; + } + } + + + /// + /// 索敵値の計算に使用するロジックの種類を示す識別します。 + /// + public enum ViewRangeCalcLogic + { + /// + /// 単純な索敵合計値。 + /// + Type1, + + /// + /// (偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)。 + /// + Type2, + } } \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Itemyard.cs b/Grabacr07.KanColleWrapper/Itemyard.cs index e962ecb4c..97395510d 100644 --- a/Grabacr07.KanColleWrapper/Itemyard.cs +++ b/Grabacr07.KanColleWrapper/Itemyard.cs @@ -110,9 +110,9 @@ internal void AddFromDock(kcsapi_kdock_getship source) internal void RemoveFromShip(Ship ship) { - foreach (var x in ship.SlotItems.Where(x => x != null).ToArray()) + foreach (var x in ship.Slots.Where(x => x.Equipped).ToArray()) { - this.SlotItems.Remove(x); + this.SlotItems.Remove(x.Item); } this.RaiseSlotItemsChanged(); } diff --git a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj index b93003c9c..38ad92c98 100644 --- a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj +++ b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj @@ -120,6 +120,7 @@ + True diff --git a/Grabacr07.KanColleWrapper/Models/Ship.cs b/Grabacr07.KanColleWrapper/Models/Ship.cs index 9d87bd1a7..3aaf47cbc 100644 --- a/Grabacr07.KanColleWrapper/Models/Ship.cs +++ b/Grabacr07.KanColleWrapper/Models/Ship.cs @@ -7,6 +7,7 @@ using Fiddler; using Grabacr07.KanColleWrapper.Internal; using Grabacr07.KanColleWrapper.Models.Raw; +using Livet; namespace Grabacr07.KanColleWrapper.Models { @@ -22,52 +23,52 @@ public class Ship : RawDataWrapper, IIdentifiable /// public int Id { - get { return this.RawData.api_id; } + get { return this.RawData.api_id; } } - /// + /// /// 艦娘の種類に基づく情報を取得します。 /// public ShipInfo Info { get; private set; } public int SortNumber { - get { return this.RawData.api_sortno; } + get { return this.RawData.api_sortno; } } - /// + /// /// 艦娘の現在のレベルを取得します。 /// public int Level - { - get { return this.RawData.api_lv; } - } + { + get { return this.RawData.api_lv; } + } - /// + /// /// 艦娘がロックされているかどうかを示す値を取得します。 /// public bool IsLocked - { - get { return this.RawData.api_locked == 1; } - } + { + get { return this.RawData.api_locked == 1; } + } - /// + /// /// 艦娘の現在の累積経験値を取得します。 /// public int Exp - { - get { return this.RawData.api_exp.Get(0) ?? 0; } - } + { + get { return this.RawData.api_exp.Get(0) ?? 0; } + } - /// + /// /// この艦娘が次のレベルに上がるために必要な経験値を取得します。 /// public int ExpForNextLevel - { - get { return this.RawData.api_exp.Get(1) ?? 0; } - } + { + get { return this.RawData.api_exp.Get(1) ?? 0; } + } - #region HP 変更通知プロパティ + #region HP 変更通知プロパティ private LimitedValue _HP; @@ -227,57 +228,34 @@ private set /// public int ViewRange { - get { return this.RawData.api_sakuteki.Get(0) ?? 0; } + get { return this.RawData.api_sakuteki.Get(0) ?? 0; } } - /// + /// /// 火力・雷装・対空・装甲のすべてのステータス値が最大値に達しているかどうかを示す値を取得します。 /// public bool IsMaxModernized - { - get { return this.Firepower.IsMax && this.Torpedo.IsMax && this.AA.IsMax && this.Armer.IsMax; } - } + { + get { return this.Firepower.IsMax && this.Torpedo.IsMax && this.AA.IsMax && this.Armer.IsMax; } + } - /// + /// /// 現在のコンディション値を取得します。 /// public int Condition - { - get { return this.RawData.api_cond; } - } + { + get { return this.RawData.api_cond; } + } - /// + /// /// コンディションの種類を示す 値を取得します。 /// public ConditionType ConditionType - { - get { return ConditionTypeHelper.ToConditionType(this.RawData.api_cond); } - } - - - public SlotItem[] SlotItems { get; private set; } - - #region OnSlot 変更通知プロパティ - - private int[] _OnSlot; - - /// - /// 各装備スロットの艦載機数を取得します。 - /// - public int[] OnSlot { - get { return this._OnSlot; } - private set - { - if (this._OnSlot != value) - { - this._OnSlot = value; - this.RaisePropertyChanged(); - } - } + get { return ConditionTypeHelper.ToConditionType(this.RawData.api_cond); } } - #endregion + public ShipSlot[] Slots { get; private set; } #region IsInRepairing 変更通知プロパティ @@ -306,11 +284,11 @@ internal set /// public int SallyArea { - get { return this.RawData.api_sally_area; } + get { return this.RawData.api_sally_area; } } - internal Ship(Homeport parent, kcsapi_ship2 rawData) + internal Ship(Homeport parent, kcsapi_ship2 rawData) : base(rawData) { this.homeport = parent; @@ -335,8 +313,10 @@ internal void Update(kcsapi_ship2 rawData) this.Luck = new ModernizableStatus(this.Info.RawData.api_luck, this.RawData.api_kyouka[4]); } - this.SlotItems = this.RawData.api_slot.Select(id => this.homeport.Itemyard.SlotItems[id]).Where(x => x != null).ToArray(); - this.OnSlot = this.RawData.api_onslot; + this.Slots = this.RawData.api_slot + .Select(id => this.homeport.Itemyard.SlotItems[id]) + .Select((t, i) => new ShipSlot(t, this.Info.RawData.api_maxeq.Get(i) ?? 0, this.RawData.api_onslot.Get(i) ?? 0)) + .ToArray(); } @@ -344,7 +324,7 @@ internal void Charge(int fuel, int bull, int[] onslot) { this.Fuel = this.Fuel.Update(fuel); this.Bull = this.Bull.Update(bull); - this.OnSlot = onslot; + for (var i = 0; i < this.Slots.Length; i++) this.Slots[i].Current = onslot.Get(i) ?? 0; } internal void Repair() @@ -358,4 +338,43 @@ public override string ToString() return string.Format("ID = {0}, Name = \"{1}\", ShipType = \"{2}\", Level = {3}", this.Id, this.Info.Name, this.Info.ShipType.Name, this.Level); } } + + + public class ShipSlot : NotificationObject + { + public SlotItem Item { get; private set; } + + public int Maximum { get; private set; } + + public bool Equipped + { + get { return this.Item != null; } + } + + #region Current 変更通知プロパティ + + private int _Current; + + public int Current + { + get { return this._Current; } + set + { + if (this._Current != value) + { + this._Current = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + + public ShipSlot(SlotItem item, int maximum, int current) + { + this.Item = item; + this.Maximum = maximum; + this.Current = current; + } + } } diff --git a/Grabacr07.KanColleWrapper/Models/ViewRange.cs b/Grabacr07.KanColleWrapper/Models/ViewRange.cs new file mode 100644 index 000000000..eab370afe --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/ViewRange.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Grabacr07.KanColleWrapper.Internal; + +namespace Grabacr07.KanColleWrapper.Models +{ + /// + /// 索敵値計算を提供します。 + /// + public interface ICalcViewRange + { + string Name { get; } + + string Description { get; } + + double Calc(Fleet fleet); + } + + + public class ViewRangeType1 : ICalcViewRange + { + public string Name + { + get { return "単純計算"; } + } + + public string Description + { + get { return "艦娘と装備の索敵値の単純な合計値"; } + } + + public double Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + return fleet.Ships.Sum(x => x.ViewRange); + } + } + + + public class ViewRangeType2 : ICalcViewRange + { + public string Name + { + get { return "2-5 式 (旧)"; } + } + + public string Description + { + get { return "(偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)"; } + } + + public double Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 + // [索敵装備と装備例] によって示されている計算式 + // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 + + var spotter = fleet.Ships.SelectMany( + x => x.Slots + .Where(s => s.Item.Info.RawData.api_type.Get(1) == 7) + .Where(s => s.Current > 0) + .Select(s => s.Item.Info.RawData.api_saku) + ).Sum(); + + var radar = fleet.Ships.SelectMany( + x => x.Slots + .Where(s => s.Item.Info.RawData.api_type.Get(1) == 8) + .Select(s => s.Item.Info.RawData.api_saku) + ).Sum(); + + return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); + } + } + + + public class ViewRangeType3 : ICalcViewRange + { + public string Name + { + get { return "2-5 式 (秋)"; } + } + + public string Description + { + get + { + return @"(艦上爆撃機 × 1.04) + (艦上攻撃機 × 1.37) + (艦上偵察機 × 1.66) ++ (水上偵察機 × 2.00) + (水上爆撃機 × 1.78) + (探照灯 × 0.91) ++ (小型電探 × 1.00) + (大型電探 × 0.99) + (√各艦毎の素索敵 × 1.69) ++ (司令部レベルを 5 の倍数に切り上げ × -0.61)"; + } + } + + public double Calc(Fleet fleet) + { + if (fleet == null || fleet.Ships.Length == 0) return 0; + + // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#search-calc + // > 2-5式では説明出来ない事象を解決するため膨大な検証報告数より導き出した新式。2014年11月に改良され精度があがった。 + // > 索敵スコア + // > = 艦上爆撃機 × (1.04) + // > + 艦上攻撃機 × (1.37) + // > + 艦上偵察機 × (1.66) + // > + 水上偵察機 × (2.00) + // > + 水上爆撃機 × (1.78) + // > + 小型電探 × (1.00) + // > + 大型電探 × (0.99) + // > + 探照灯 × (0.91) + // > + √(各艦毎の素索敵) × (1.69) + // > + (司令部レベルを5の倍数に切り上げ) × (-0.61) + + var itemScore = fleet.Ships + .SelectMany(x => x.Slots.Where(s => s.Equipped)) + .Select(x => x.Item.Info) + .GroupBy( + x => x.Type, + x => x.RawData.api_saku, + (type, scores) => new { type, score = scores.Sum() }) + .Aggregate(.0, (score, item) => score + GetScore(item.type, item.score)); + + var shipScore = fleet.Ships + .Select(x => x.ViewRange - x.Slots + .Where(s => s.Equipped) + .Sum(s => s.Item.Info.RawData.api_saku)) + .Select(x => Math.Sqrt(x)) + .Sum() * 1.69; + + var level = (((KanColleClient.Current.Homeport.Admiral.Level + 4) / 5) * 5); + var admiralScore = level * -0.61; + + return itemScore + shipScore + admiralScore; + } + + private static double GetScore(SlotItemType type, int score) + { + switch (type) + { + case SlotItemType.艦上爆撃機: + return score * 1.04; + case SlotItemType.艦上攻撃機: + return score * 1.37; + case SlotItemType.艦上偵察機: + return score * 1.66; + + case SlotItemType.水上偵察機: + return score * 2.00; + case SlotItemType.水上爆撃機: + return score * 1.78; + + case SlotItemType.小型電探: + return score * 1.00; + case SlotItemType.大型電探: + return score * 0.99; + + case SlotItemType.探照灯: + return score * 0.91; + } + + return .0; + } + } +} From 53ea626a1e476cd18fa0681b337c8c0540c11e9b Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Fri, 13 Feb 2015 01:37:15 +0900 Subject: [PATCH 07/14] MMCSS --- Grabacr07.KanColleViewer/App.xaml.cs | 1 + Grabacr07.KanColleViewer/Models/Helper.cs | 6 ++++++ Grabacr07.KanColleViewer/Win32/NativeMethods.cs | 2 ++ 3 files changed, 9 insertions(+) diff --git a/Grabacr07.KanColleViewer/App.xaml.cs b/Grabacr07.KanColleViewer/App.xaml.cs index 8209724a7..577f412da 100644 --- a/Grabacr07.KanColleViewer/App.xaml.cs +++ b/Grabacr07.KanColleViewer/App.xaml.cs @@ -40,6 +40,7 @@ protected override void OnStartup(StartupEventArgs e) PluginHost.Instance.Initialize(); NotifierHost.Instance.Initialize(KanColleClient.Current); Helper.SetRegistryFeatureBrowserEmulation(); + Helper.SetMMCSSTask(); KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort); KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings; diff --git a/Grabacr07.KanColleViewer/Models/Helper.cs b/Grabacr07.KanColleViewer/Models/Helper.cs index f892026a7..052efbf90 100644 --- a/Grabacr07.KanColleViewer/Models/Helper.cs +++ b/Grabacr07.KanColleViewer/Models/Helper.cs @@ -75,6 +75,12 @@ public static void SetRegistryFeatureBrowserEmulation() } } + public static void SetMMCSSTask() + { + var index = 0u; + NativeMethods.AvSetMmThreadCharacteristics("Games", ref index); + } + /// /// キャッシュを削除します。 diff --git a/Grabacr07.KanColleViewer/Win32/NativeMethods.cs b/Grabacr07.KanColleViewer/Win32/NativeMethods.cs index 1acd16172..ad0dc0be1 100644 --- a/Grabacr07.KanColleViewer/Win32/NativeMethods.cs +++ b/Grabacr07.KanColleViewer/Win32/NativeMethods.cs @@ -8,5 +8,7 @@ namespace Grabacr07.KanColleViewer.Win32 { internal static class NativeMethods { + [DllImport("Avrt.dll")] + public static extern IntPtr AvSetMmThreadCharacteristics(string taskName, ref uint taskIndex); } } From add3b0f23fe0d597dae403b368a7f51c7d3da991 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Fri, 13 Feb 2015 03:10:07 +0900 Subject: [PATCH 08/14] =?UTF-8?q?=E7=B4=A2=E6=95=B5=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF=E3=81=AE=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20(UI=20=E3=81=8C=E3=81=BE=E3=81=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Grabacr07.KanColleViewer/Models/Settings.cs | 21 +++++- .../Contents/Fleets/FleetViewModel.cs | 16 ++++- .../ViewModels/SettingsViewModel.cs | 8 +-- Grabacr07.KanColleWrapper/Calculator.cs | 58 +--------------- .../KanColleClientSettings.cs | 19 ------ Grabacr07.KanColleWrapper/Models/Fleet.cs | 23 ------- Grabacr07.KanColleWrapper/Models/ViewRange.cs | 68 +++++++++++++++---- 7 files changed, 96 insertions(+), 117 deletions(-) diff --git a/Grabacr07.KanColleViewer/Models/Settings.cs b/Grabacr07.KanColleViewer/Models/Settings.cs index c2e102d1a..655a45369 100644 --- a/Grabacr07.KanColleViewer/Models/Settings.cs +++ b/Grabacr07.KanColleViewer/Models/Settings.cs @@ -368,7 +368,26 @@ public KanColleClientSettings KanColleClientSettings } #endregion - + + #region ViewRangeCalcType 変更通知プロパティ + + private string _ViewRangeCalcType; + + public string ViewRangeCalcType + { + get { return this._ViewRangeCalcType; } + set + { + if (this._ViewRangeCalcType != value) + { + this._ViewRangeCalcType = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + public void Save() { diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs index b6bd66533..d13e5a94a 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs @@ -15,6 +15,20 @@ namespace Grabacr07.KanColleViewer.ViewModels.Contents.Fleets /// public class FleetViewModel : ViewModel { + #region static members + + static FleetViewModel() + { + // ひどぅい設計を見た + // ReSharper disable ObjectCreationAsStatement + new ViewRangeType1(); + new ViewRangeType2(); + new ViewRangeType3(); + // ReSharper restore ObjectCreationAsStatement + } + + #endregion + private readonly Fleet source; public SortieViewModel Sortie { get; private set; } @@ -108,7 +122,7 @@ public int AirSuperiorityPotential public string TotalViewRange { - get { return this.source.TotalViewRange.ToString("####"); } + get { return ViewRangeCalcLogic.Get(Models.Settings.Current.ViewRangeCalcType).Calc(this.source).ToString("####"); } } #endregion diff --git a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs index 6287b54fb..ed05cb468 100644 --- a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs @@ -260,7 +260,7 @@ public bool ViewRangeType1 { this._ViewRangeType1 = value; this.RaisePropertyChanged(); - if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type1; + //if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type1; } } } @@ -280,7 +280,7 @@ public bool ViewRangeType2 { this._ViewRangeType2 = value; this.RaisePropertyChanged(); - if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type2; + //if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type2; } } } @@ -323,8 +323,8 @@ public SettingsViewModel() }); this.BrowserZoomFactor = zoomFactor; - this._ViewRangeType1 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type1; - this._ViewRangeType2 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type2; + //this._ViewRangeType1 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type1; + //this._ViewRangeType2 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type2; this.ReloadPlugins(); } diff --git a/Grabacr07.KanColleWrapper/Calculator.cs b/Grabacr07.KanColleWrapper/Calculator.cs index b3e103bcb..4e3df44b7 100644 --- a/Grabacr07.KanColleWrapper/Calculator.cs +++ b/Grabacr07.KanColleWrapper/Calculator.cs @@ -30,63 +30,7 @@ public static int CalcAirSuperiorityPotential(this SlotItem slotItem, int onslot /// public static int CalcAirSuperiorityPotential(this Ship ship) { - return ship.Slots.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)).Sum(); + return ship.Slots.Where(x => x.Equipped).Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)).Sum(); } - - - /// - /// 艦隊の索敵値を計算します。 - /// - /// - public static int CalcFleetViewRange(this Fleet fleet, ViewRangeCalcLogic logic) - { - if (fleet == null || fleet.Ships.Length == 0) return 0; - - if (logic == ViewRangeCalcLogic.Type1) - { - return fleet.Ships.Sum(x => x.ViewRange); - } - - if (logic == ViewRangeCalcLogic.Type2) - { - // http://wikiwiki.jp/kancolle/?%C6%EE%C0%BE%BD%F4%C5%E7%B3%A4%B0%E8#area5 - // [索敵装備と装備例] によって示されている計算式 - // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 - - var spotter = fleet.Ships.SelectMany( - x => x.Slots - .Where(s => s.Item.Info.RawData.api_type.Get(1) == 7) - .Where(s => s.Current > 0) - .Select(s => s.Item.Info.RawData.api_saku) - ).Sum(); - - var radar = fleet.Ships.SelectMany( - x => x.Slots - .Where(s => s.Item.Info.RawData.api_type.Get(1) == 8) - .Select(s => s.Item.Info.RawData.api_saku) - ).Sum(); - - return (spotter * 2) + radar + (int)Math.Sqrt(fleet.Ships.Sum(x => x.ViewRange) - spotter - radar); - } - - return 0; - } - } - - - /// - /// 索敵値の計算に使用するロジックの種類を示す識別します。 - /// - public enum ViewRangeCalcLogic - { - /// - /// 単純な索敵合計値。 - /// - Type1, - - /// - /// (偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)。 - /// - Type2, } } \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/KanColleClientSettings.cs b/Grabacr07.KanColleWrapper/KanColleClientSettings.cs index d852828fc..f37830b46 100644 --- a/Grabacr07.KanColleWrapper/KanColleClientSettings.cs +++ b/Grabacr07.KanColleWrapper/KanColleClientSettings.cs @@ -72,24 +72,5 @@ public bool EnableLogging } #endregion - - #region ViewRangeCalcLogic 変更通知プロパティ - - private ViewRangeCalcLogic _ViewRangeCalcLogic; - - public ViewRangeCalcLogic ViewRangeCalcLogic - { - get { return this._ViewRangeCalcLogic; } - set - { - if (this._ViewRangeCalcLogic != value) - { - this._ViewRangeCalcLogic = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/Fleet.cs b/Grabacr07.KanColleWrapper/Models/Fleet.cs index b848675fb..e8f142171 100644 --- a/Grabacr07.KanColleWrapper/Models/Fleet.cs +++ b/Grabacr07.KanColleWrapper/Models/Fleet.cs @@ -143,28 +143,6 @@ private set #endregion - #region TotalViewRange 変更通知プロパティ - - private int _TotalViewRange; - - /// - /// 各艦娘の装備によるボーナスを含めた、艦隊の索敵合計値を取得します。 - /// - public int TotalViewRange - { - get { return this._TotalViewRange; } - private set - { - if (this._TotalViewRange != value) - { - this._TotalViewRange = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - #region Speed 変更通知プロパティ private Speed _Speed; @@ -405,7 +383,6 @@ internal void Calculate() this.TotalLevel = this.Ships.HasItems() ? this.Ships.Sum(x => x.Level) : 0; this.AverageLevel = this.Ships.HasItems() ? (double)this.TotalLevel / this.Ships.Length : 0.0; this.AirSuperiorityPotential = this.Ships.Sum(s => s.CalcAirSuperiorityPotential()); - this.TotalViewRange = this.CalcFleetViewRange(KanColleClient.Current.Settings.ViewRangeCalcLogic); this.Speed = this.Ships.All(s => s.Info.Speed == Speed.Fast) ? Speed.Fast : Speed.Low; } diff --git a/Grabacr07.KanColleWrapper/Models/ViewRange.cs b/Grabacr07.KanColleWrapper/Models/ViewRange.cs index eab370afe..87bda4c0e 100644 --- a/Grabacr07.KanColleWrapper/Models/ViewRange.cs +++ b/Grabacr07.KanColleWrapper/Models/ViewRange.cs @@ -20,19 +20,53 @@ public interface ICalcViewRange } - public class ViewRangeType1 : ICalcViewRange + public abstract class ViewRangeCalcLogic : ICalcViewRange { - public string Name + private static readonly Dictionary logics = new Dictionary(); + + public static IEnumerable Logics + { + get { return logics.Values; } + } + + public static ICalcViewRange Get(string key) + { + ICalcViewRange logic; + return logics.TryGetValue(key, out logic) ? logic : new ViewRangeType1(); + } + + public abstract string Key { get; } + public abstract string Name { get; } + public abstract string Description { get; } + public abstract double Calc(Fleet fleet); + + protected ViewRangeCalcLogic() + { + // ReSharper disable once DoNotCallOverridableMethodsInConstructor + var key = this.Key; + if (key != null && !logics.ContainsKey(key)) logics.Add(key, this); + } + } + + + public class ViewRangeType1 : ViewRangeCalcLogic + { + public override sealed string Key + { + get { return "Type1"; } + } + + public override string Name { get { return "単純計算"; } } - public string Description + public override string Description { get { return "艦娘と装備の索敵値の単純な合計値"; } } - public double Calc(Fleet fleet) + public override double Calc(Fleet fleet) { if (fleet == null || fleet.Ships.Length == 0) return 0; @@ -41,19 +75,24 @@ public double Calc(Fleet fleet) } - public class ViewRangeType2 : ICalcViewRange + public class ViewRangeType2 : ViewRangeCalcLogic { - public string Name + public override sealed string Key + { + get { return "Type2"; } + } + + public override string Name { get { return "2-5 式 (旧)"; } } - public string Description + public override string Description { get { return "(偵察機 × 2) + (電探) + √(装備込みの艦隊索敵値合計 - 偵察機 - 電探)"; } } - public double Calc(Fleet fleet) + public override double Calc(Fleet fleet) { if (fleet == null || fleet.Ships.Length == 0) return 0; @@ -79,14 +118,19 @@ public double Calc(Fleet fleet) } - public class ViewRangeType3 : ICalcViewRange + public class ViewRangeType3 : ViewRangeCalcLogic { - public string Name + public override sealed string Key + { + get { return "Type3"; } + } + + public override string Name { get { return "2-5 式 (秋)"; } } - public string Description + public override string Description { get { @@ -97,7 +141,7 @@ public string Description } } - public double Calc(Fleet fleet) + public override double Calc(Fleet fleet) { if (fleet == null || fleet.Ships.Length == 0) return 0; From 32638a4bb03041f1d2242bfe66870f64e5c53fae Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Sat, 14 Feb 2015 21:09:40 +0900 Subject: [PATCH 09/14] =?UTF-8?q?=E7=B4=A2=E6=95=B5=E8=A8=88=E7=AE=97=202-?= =?UTF-8?q?5=20=E7=A7=8B=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Grabacr07.KanColleViewer/Models/Settings.cs | 20 +----- .../Catalogs/SlotItemCatalogViewModel.cs | 2 +- .../Contents/Fleets/FleetViewModel.cs | 16 +---- .../ViewModels/SettingsViewModel.cs | 67 +++++++++++-------- .../Views/Contents/Fleets.xaml | 12 ++-- .../Views/Settings/Operation.xaml | 52 +++++--------- Grabacr07.KanColleWrapper/Calculator.cs | 2 +- Grabacr07.KanColleWrapper/Itemyard.cs | 2 +- .../KanColleClientSettings.cs | 20 ++++++ Grabacr07.KanColleWrapper/Models/Fleet.cs | 25 ++++++- Grabacr07.KanColleWrapper/Models/Ship.cs | 3 + Grabacr07.KanColleWrapper/Models/ViewRange.cs | 40 ++++++----- 12 files changed, 139 insertions(+), 122 deletions(-) diff --git a/Grabacr07.KanColleViewer/Models/Settings.cs b/Grabacr07.KanColleViewer/Models/Settings.cs index 655a45369..84df4aea9 100644 --- a/Grabacr07.KanColleViewer/Models/Settings.cs +++ b/Grabacr07.KanColleViewer/Models/Settings.cs @@ -6,6 +6,7 @@ using System.Xml.Serialization; using Grabacr07.KanColleViewer.Models.Data.Xml; using Grabacr07.KanColleWrapper; +using Grabacr07.KanColleWrapper.Models; using Livet; namespace Grabacr07.KanColleViewer.Models @@ -369,25 +370,6 @@ public KanColleClientSettings KanColleClientSettings #endregion - #region ViewRangeCalcType 変更通知プロパティ - - private string _ViewRangeCalcType; - - public string ViewRangeCalcType - { - get { return this._ViewRangeCalcType; } - set - { - if (this._ViewRangeCalcType != value) - { - this._ViewRangeCalcType = value; - this.RaisePropertyChanged(); - } - } - } - - #endregion - public void Save() { diff --git a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs index 89f41e25f..797cb6c55 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Catalogs/SlotItemCatalogViewModel.cs @@ -79,7 +79,7 @@ private static Task> UpdateCore() foreach (var ship in ships.Values) { - foreach (var target in ship.Slots.Where(x => x.Equipped).Select(slot => dic[slot.Item.Info.Id])) + foreach (var target in ship.EquippedSlots.Select(slot => dic[slot.Item.Info.Id])) { target.AddShip(ship); } diff --git a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs index d13e5a94a..0ca84ab3b 100644 --- a/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/Contents/Fleets/FleetViewModel.cs @@ -15,20 +15,6 @@ namespace Grabacr07.KanColleViewer.ViewModels.Contents.Fleets /// public class FleetViewModel : ViewModel { - #region static members - - static FleetViewModel() - { - // ひどぅい設計を見た - // ReSharper disable ObjectCreationAsStatement - new ViewRangeType1(); - new ViewRangeType2(); - new ViewRangeType3(); - // ReSharper restore ObjectCreationAsStatement - } - - #endregion - private readonly Fleet source; public SortieViewModel Sortie { get; private set; } @@ -122,7 +108,7 @@ public int AirSuperiorityPotential public string TotalViewRange { - get { return ViewRangeCalcLogic.Get(Models.Settings.Current.ViewRangeCalcType).Calc(this.source).ToString("####"); } + get { return this.source.TotalViewRange.ToString("###.##"); } } #endregion diff --git a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs index ed05cb468..4c68bab87 100644 --- a/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/SettingsViewModel.cs @@ -12,6 +12,7 @@ using Grabacr07.KanColleViewer.ViewModels.Composition; using Grabacr07.KanColleViewer.ViewModels.Messages; using Grabacr07.KanColleWrapper; +using Grabacr07.KanColleWrapper.Models; using Livet.EventListeners; using Livet.Messaging; using Livet.Messaging.IO; @@ -247,40 +248,19 @@ public List ToolPlugins #endregion - #region ViewRangeType1 変更通知プロパティ + #region ViewRangeSettingsCollection 変更通知プロパティ - private bool _ViewRangeType1; + private List _ViewRangeSettingsCollection; - public bool ViewRangeType1 + public List ViewRangeSettingsCollection { - get { return this._ViewRangeType1; } + get { return this._ViewRangeSettingsCollection; } set { - if (this._ViewRangeType1 != value) + if (this._ViewRangeSettingsCollection != value) { - this._ViewRangeType1 = value; + this._ViewRangeSettingsCollection = value; this.RaisePropertyChanged(); - //if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type1; - } - } - } - - #endregion - - #region ViewRangeType2 変更通知プロパティ - - private bool _ViewRangeType2; - - public bool ViewRangeType2 - { - get { return this._ViewRangeType2; } - set - { - if (this._ViewRangeType2 != value) - { - this._ViewRangeType2 = value; - this.RaisePropertyChanged(); - //if (value) Settings.Current.KanColleClientSettings.ViewRangeCalcLogic = ViewRangeCalcLogic.Type2; } } } @@ -323,8 +303,9 @@ public SettingsViewModel() }); this.BrowserZoomFactor = zoomFactor; - //this._ViewRangeType1 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type1; - //this._ViewRangeType2 = Settings.Current.KanColleClientSettings.ViewRangeCalcLogic == ViewRangeCalcLogic.Type2; + this.ViewRangeSettingsCollection = ViewRangeCalcLogic.Logics + .Select(x => new ViewRangeSettingsViewModel(x)) + .ToList(); this.ReloadPlugins(); } @@ -381,5 +362,33 @@ public void ReloadPlugins() this.NotifierPlugins = new List(PluginHost.Instance.Notifiers.Select(x => new NotifierViewModel(x))); this.ToolPlugins = new List(PluginHost.Instance.Tools.Select(x => new ToolViewModel(x))); } + + + public class ViewRangeSettingsViewModel + { + private bool selected; + + public ICalcViewRange Logic { get; set; } + + public bool Selected + { + get { return this.selected; } + set + { + this.selected = value; + if (value) + { + Settings.Current.KanColleClientSettings.ViewRangeCalcType = this.Logic.Id; + foreach (var f in KanColleClient.Current.Homeport.Organization.Fleets) f.Value.Calculate(); + } + } + } + + public ViewRangeSettingsViewModel(ICalcViewRange logic) + { + this.Logic = logic; + this.selected = Settings.Current.KanColleClientSettings.ViewRangeCalcType == logic.Id; + } + } } } diff --git a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml index 6e9969da1..cd78f5020 100644 --- a/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml +++ b/Grabacr07.KanColleViewer/Views/Contents/Fleets.xaml @@ -59,7 +59,8 @@ + Margin="0,0,10,0" + Visibility="Collapsed"> @@ -212,8 +213,7 @@ + Grid.IsSharedSizeScope="True"> @@ -354,7 +354,7 @@ @@ -364,9 +364,9 @@ - - diff --git a/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml b/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml index fc8c6470b..80abe309b 100644 --- a/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml +++ b/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml @@ -63,40 +63,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + public static int CalcAirSuperiorityPotential(this Ship ship) { - return ship.Slots.Where(x => x.Equipped).Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)).Sum(); + return ship.EquippedSlots.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)).Sum(); } } } \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Itemyard.cs b/Grabacr07.KanColleWrapper/Itemyard.cs index 97395510d..598825173 100644 --- a/Grabacr07.KanColleWrapper/Itemyard.cs +++ b/Grabacr07.KanColleWrapper/Itemyard.cs @@ -110,7 +110,7 @@ internal void AddFromDock(kcsapi_kdock_getship source) internal void RemoveFromShip(Ship ship) { - foreach (var x in ship.Slots.Where(x => x.Equipped).ToArray()) + foreach (var x in ship.EquippedSlots.ToArray()) { this.SlotItems.Remove(x.Item); } diff --git a/Grabacr07.KanColleWrapper/KanColleClientSettings.cs b/Grabacr07.KanColleWrapper/KanColleClientSettings.cs index f37830b46..34fd8b2d4 100644 --- a/Grabacr07.KanColleWrapper/KanColleClientSettings.cs +++ b/Grabacr07.KanColleWrapper/KanColleClientSettings.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Grabacr07.KanColleWrapper.Models; using Livet; namespace Grabacr07.KanColleWrapper @@ -72,5 +73,24 @@ public bool EnableLogging } #endregion + + #region ViewRangeCalcType 変更通知プロパティ + + private string _ViewRangeCalcType; + + public string ViewRangeCalcType + { + get { return this._ViewRangeCalcType ?? (this._ViewRangeCalcType = new ViewRangeType1().Id); } + set + { + if (this._ViewRangeCalcType != value) + { + this._ViewRangeCalcType = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion } } diff --git a/Grabacr07.KanColleWrapper/Models/Fleet.cs b/Grabacr07.KanColleWrapper/Models/Fleet.cs index e8f142171..42cf89fac 100644 --- a/Grabacr07.KanColleWrapper/Models/Fleet.cs +++ b/Grabacr07.KanColleWrapper/Models/Fleet.cs @@ -143,6 +143,28 @@ private set #endregion + #region TotalViewRange 変更通知プロパティ + + private double _TotalViewRange; + + /// + /// 各艦娘の装備によるボーナスを含めた、艦隊の索敵合計値を取得します。 + /// + public double TotalViewRange + { + get { return this._TotalViewRange; } + private set + { + if (this._TotalViewRange != value) + { + this._TotalViewRange = value; + this.RaisePropertyChanged(); + } + } + } + + #endregion + #region Speed 変更通知プロパティ private Speed _Speed; @@ -378,11 +400,12 @@ internal void UnsetAll() /// /// 艦隊の平均レベルや制空戦力などの各種数値を再計算します。 /// - internal void Calculate() + public void Calculate() { this.TotalLevel = this.Ships.HasItems() ? this.Ships.Sum(x => x.Level) : 0; this.AverageLevel = this.Ships.HasItems() ? (double)this.TotalLevel / this.Ships.Length : 0.0; this.AirSuperiorityPotential = this.Ships.Sum(s => s.CalcAirSuperiorityPotential()); + this.TotalViewRange = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType).Calc(this); this.Speed = this.Ships.All(s => s.Info.Speed == Speed.Fast) ? Speed.Fast : Speed.Low; } diff --git a/Grabacr07.KanColleWrapper/Models/Ship.cs b/Grabacr07.KanColleWrapper/Models/Ship.cs index 3aaf47cbc..5f5ba5661 100644 --- a/Grabacr07.KanColleWrapper/Models/Ship.cs +++ b/Grabacr07.KanColleWrapper/Models/Ship.cs @@ -257,6 +257,8 @@ public ConditionType ConditionType public ShipSlot[] Slots { get; private set; } + public ShipSlot[] EquippedSlots { get; private set; } + #region IsInRepairing 変更通知プロパティ private bool _IsInRepairing; @@ -317,6 +319,7 @@ internal void Update(kcsapi_ship2 rawData) .Select(id => this.homeport.Itemyard.SlotItems[id]) .Select((t, i) => new ShipSlot(t, this.Info.RawData.api_maxeq.Get(i) ?? 0, this.RawData.api_onslot.Get(i) ?? 0)) .ToArray(); + this.EquippedSlots = this.Slots.Where(x => x.Equipped).ToArray(); } diff --git a/Grabacr07.KanColleWrapper/Models/ViewRange.cs b/Grabacr07.KanColleWrapper/Models/ViewRange.cs index 87bda4c0e..9c10dc5ff 100644 --- a/Grabacr07.KanColleWrapper/Models/ViewRange.cs +++ b/Grabacr07.KanColleWrapper/Models/ViewRange.cs @@ -12,6 +12,8 @@ namespace Grabacr07.KanColleWrapper.Models /// public interface ICalcViewRange { + string Id { get; } + string Name { get; } string Description { get; } @@ -27,7 +29,7 @@ public abstract class ViewRangeCalcLogic : ICalcViewRange public static IEnumerable Logics { get { return logics.Values; } - } + } public static ICalcViewRange Get(string key) { @@ -35,7 +37,17 @@ public static ICalcViewRange Get(string key) return logics.TryGetValue(key, out logic) ? logic : new ViewRangeType1(); } - public abstract string Key { get; } + static ViewRangeCalcLogic() + { + // ひどぅい設計を見た + // ReSharper disable ObjectCreationAsStatement + new ViewRangeType1(); + new ViewRangeType2(); + new ViewRangeType3(); + // ReSharper restore ObjectCreationAsStatement + } + + public abstract string Id { get; } public abstract string Name { get; } public abstract string Description { get; } public abstract double Calc(Fleet fleet); @@ -43,7 +55,7 @@ public static ICalcViewRange Get(string key) protected ViewRangeCalcLogic() { // ReSharper disable once DoNotCallOverridableMethodsInConstructor - var key = this.Key; + var key = this.Id; if (key != null && !logics.ContainsKey(key)) logics.Add(key, this); } } @@ -51,9 +63,9 @@ protected ViewRangeCalcLogic() public class ViewRangeType1 : ViewRangeCalcLogic { - public override sealed string Key + public override sealed string Id { - get { return "Type1"; } + get { return "KanColleViewer.Type1"; } } public override string Name @@ -77,9 +89,9 @@ public override double Calc(Fleet fleet) public class ViewRangeType2 : ViewRangeCalcLogic { - public override sealed string Key + public override sealed string Id { - get { return "Type2"; } + get { return "KanColleViewer.Type2"; } } public override string Name @@ -101,14 +113,14 @@ public override double Calc(Fleet fleet) // stype=7 が偵察機 (2 倍する索敵値)、stype=8 が電探 var spotter = fleet.Ships.SelectMany( - x => x.Slots + x => x.EquippedSlots .Where(s => s.Item.Info.RawData.api_type.Get(1) == 7) .Where(s => s.Current > 0) .Select(s => s.Item.Info.RawData.api_saku) ).Sum(); var radar = fleet.Ships.SelectMany( - x => x.Slots + x => x.EquippedSlots .Where(s => s.Item.Info.RawData.api_type.Get(1) == 8) .Select(s => s.Item.Info.RawData.api_saku) ).Sum(); @@ -120,9 +132,9 @@ public override double Calc(Fleet fleet) public class ViewRangeType3 : ViewRangeCalcLogic { - public override sealed string Key + public override sealed string Id { - get { return "Type3"; } + get { return "KanColleViewer.Type3"; } } public override string Name @@ -160,7 +172,7 @@ public override double Calc(Fleet fleet) // > + (司令部レベルを5の倍数に切り上げ) × (-0.61) var itemScore = fleet.Ships - .SelectMany(x => x.Slots.Where(s => s.Equipped)) + .SelectMany(x => x.EquippedSlots) .Select(x => x.Item.Info) .GroupBy( x => x.Type, @@ -169,9 +181,7 @@ public override double Calc(Fleet fleet) .Aggregate(.0, (score, item) => score + GetScore(item.type, item.score)); var shipScore = fleet.Ships - .Select(x => x.ViewRange - x.Slots - .Where(s => s.Equipped) - .Sum(s => s.Item.Info.RawData.api_saku)) + .Select(x => x.ViewRange - x.EquippedSlots.Sum(s => s.Item.Info.RawData.api_saku)) .Select(x => Math.Sqrt(x)) .Sum() * 1.69; From d3c884aff328735efaf21750678283b765a34189 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Sat, 14 Feb 2015 23:05:17 +0900 Subject: [PATCH 10/14] =?UTF-8?q?=E6=94=B9=E4=BF=AE=E5=B7=A5=E5=BB=A0?= =?UTF-8?q?=E3=81=A7=E6=94=B9=E4=BF=AE=E3=81=AB=E4=BD=BF=E7=94=A8=E3=81=97?= =?UTF-8?q?=E3=81=9F=E8=A3=85=E5=82=99=E3=81=8C=E8=A3=85=E5=82=99=E6=95=B0?= =?UTF-8?q?=E3=81=AB=E5=8F=8D=E6=98=A0=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #121 --- Grabacr07.KanColleWrapper/Itemyard.cs | 12 +++++++- .../KanColleProxy.Endpoints.cs | 28 +++++++++++++++++-- .../KanColleProxy.Endpoints.tt | 7 +++-- .../KanColleWrapper.csproj | 3 ++ .../Models/Raw/kcsapi_remodel_slot.cs | 26 +++++++++++++++++ .../Models/Raw/kcsapi_remodel_slotlist.cs | 22 +++++++++++++++ .../Raw/kcsapi_remodel_slotlist_detail.cs | 19 +++++++++++++ 7 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slot.cs create mode 100644 Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist.cs create mode 100644 Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist_detail.cs diff --git a/Grabacr07.KanColleWrapper/Itemyard.cs b/Grabacr07.KanColleWrapper/Itemyard.cs index 598825173..e88c06bef 100644 --- a/Grabacr07.KanColleWrapper/Itemyard.cs +++ b/Grabacr07.KanColleWrapper/Itemyard.cs @@ -85,6 +85,8 @@ internal Itemyard(KanColleProxy proxy) proxy.api_req_sortie_battleresult.TryParse().Subscribe(x => this.DropShip(x.Data)); proxy.api_get_member_useitem.TryParse().Subscribe(x => this.Update(x.Data)); + + proxy.api_req_kousyou_remodel_slot.TryParse().Subscribe(x => this.RemoveFromRemodel(x.Data)); } @@ -117,6 +119,14 @@ internal void RemoveFromShip(Ship ship) this.RaiseSlotItemsChanged(); } + internal void RemoveFromRemodel(kcsapi_remodel_slot source) + { + foreach (var id in source.api_use_slot_id) + { + this.SlotItems.Remove(id); + } + this.RaiseSlotItemsChanged(); + } private void CreateItem(kcsapi_createitem source) { @@ -133,7 +143,7 @@ private void DestroyItem(SvData data) try { - foreach (var x in data.Request["api_slotitem_ids"].Split(new[] { ',' }).Select(int.Parse)) + foreach (var x in data.Request["api_slotitem_ids"].Split(',').Select(int.Parse)) { this.SlotItems.Remove(x); } diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs index 806c9c19f..5fd5adf10 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs +++ b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs @@ -8,13 +8,12 @@ using System.Reactive.Linq; using System.Threading.Tasks; using Fiddler; +// ReSharper disable InconsistentNaming namespace Grabacr07.KanColleWrapper { partial class KanColleProxy { - // ReSharper disable InconsistentNaming - /// /// エンド ポイント "/kcsapi/api_start2" からのセッションを配信します。 /// @@ -199,6 +198,30 @@ public IObservable api_req_kousyou_destroyitem2 get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/destroyitem2"); } } + /// + /// エンド ポイント "/kcsapi/api_req_kousyou/remodel_slotlist" からのセッションを配信します。 + /// + public IObservable api_req_kousyou_remodel_slotlist + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/remodel_slotlist"); } + } + + /// + /// エンド ポイント "/kcsapi/api_req_kousyou/remodel_slotlist_detail" からのセッションを配信します。 + /// + public IObservable api_req_kousyou_remodel_slotlist_detail + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/remodel_slotlist_detail"); } + } + + /// + /// エンド ポイント "/kcsapi/api_req_kousyou/remodel_slot" からのセッションを配信します。 + /// + public IObservable api_req_kousyou_remodel_slot + { + get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_kousyou/remodel_slot"); } + } + /// /// エンド ポイント "/kcsapi/api_req_nyukyo/start" からのセッションを配信します。 /// @@ -303,6 +326,5 @@ public IObservable api_req_combined_battle_goback_port get { return this.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_combined_battle/goback_port"); } } - // ReSharper restore InconsistentNaming } } diff --git a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt index dccd53627..3cd3516db 100644 --- a/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt +++ b/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.tt @@ -31,6 +31,9 @@ "/kcsapi/api_req_kousyou/createship_speedchange", "/kcsapi/api_req_kousyou/destroyship", "/kcsapi/api_req_kousyou/destroyitem2", + "/kcsapi/api_req_kousyou/remodel_slotlist", + "/kcsapi/api_req_kousyou/remodel_slotlist_detail", + "/kcsapi/api_req_kousyou/remodel_slot", "/kcsapi/api_req_nyukyo/start", "/kcsapi/api_req_nyukyo/speedchange", "/kcsapi/api_req_map/start", @@ -56,13 +59,12 @@ using System.Linq; using System.Reactive.Linq; using System.Threading.Tasks; using Fiddler; +// ReSharper disable InconsistentNaming namespace Grabacr07.KanColleWrapper { partial class KanColleProxy { - // ReSharper disable InconsistentNaming - <# foreach (var endpoint in endpoints) { @@ -85,6 +87,5 @@ namespace Grabacr07.KanColleWrapper <# } #> - // ReSharper restore InconsistentNaming } } diff --git a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj index 38ad92c98..4752d77e3 100644 --- a/Grabacr07.KanColleWrapper/KanColleWrapper.csproj +++ b/Grabacr07.KanColleWrapper/KanColleWrapper.csproj @@ -107,6 +107,7 @@ + @@ -119,6 +120,8 @@ + + diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slot.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slot.cs new file mode 100644 index 000000000..75eec3304 --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slot.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +// ReSharper disable InconsistentNaming + +namespace Grabacr07.KanColleWrapper.Models.Raw +{ + public class kcsapi_remodel_slot + { + public int api_remodel_flag { get; set; } + public int[] api_remodel_id { get; set; } + public int[] api_after_material { get; set; } + public string api_voice_id { get; set; } + public Api_After_Slot api_after_slot { get; set; } + public int[] api_use_slot_id { get; set; } + } + + public class Api_After_Slot + { + public int api_id { get; set; } + public int api_slotitem_id { get; set; } + public int api_locked { get; set; } + public int api_level { get; set; } + } +} \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist.cs new file mode 100644 index 000000000..d5b8f114c --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +// ReSharper disable InconsistentNaming + +namespace Grabacr07.KanColleWrapper.Models.Raw +{ + public class kcsapi_remodel_slotlist + { + public int api_id { get; set; } + public int api_slot_id { get; set; } + public int api_req_fuel { get; set; } + public int api_req_bull { get; set; } + public int api_req_steel { get; set; } + public int api_req_bauxite { get; set; } + public int api_req_buildkit { get; set; } + public int api_req_remodelkit { get; set; } + public int api_req_slot_id { get; set; } + public int api_req_slot_num { get; set; } + } +} \ No newline at end of file diff --git a/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist_detail.cs b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist_detail.cs new file mode 100644 index 000000000..a39041820 --- /dev/null +++ b/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_remodel_slotlist_detail.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +// ReSharper disable InconsistentNaming + +namespace Grabacr07.KanColleWrapper.Models.Raw +{ + public class kcsapi_remodel_slotlist_detail + { + public int api_req_buildkit { get; set; } + public int api_req_remodelkit { get; set; } + public int api_certain_buildkit { get; set; } + public int api_certain_remodelkit { get; set; } + public int api_req_slot_id { get; set; } + public int api_req_slot_num { get; set; } + public int api_change_flag { get; set; } + } +} \ No newline at end of file From b09ebebfc6a2a1150d777aad32c2492be1784e51 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Sat, 14 Feb 2015 23:05:47 +0900 Subject: [PATCH 11/14] =?UTF-8?q?=E6=AF=8D=E6=B8=AF=E3=81=AB=E6=88=BB?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=82=BF=E3=82=A4=E3=83=9F=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=81=A7=E6=8F=90=E7=9D=A3=E7=B5=8C=E9=A8=93=E5=80=A4=E7=AD=89?= =?UTF-8?q?=E3=82=92=E5=8F=8D=E6=98=A0=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Grabacr07.KanColleWrapper/Homeport.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Grabacr07.KanColleWrapper/Homeport.cs b/Grabacr07.KanColleWrapper/Homeport.cs index a27c9bcd9..e26051039 100644 --- a/Grabacr07.KanColleWrapper/Homeport.cs +++ b/Grabacr07.KanColleWrapper/Homeport.cs @@ -91,6 +91,7 @@ internal Homeport(KanColleProxy proxy) this.Organization.Update(x.Data.api_deck_port); this.Organization.Combined = x.Data.api_combined_flag != 0; this.Materials.Update(x.Data.api_material); + this.UpdateAdmiral(x.Data.api_basic); }); proxy.api_get_member_basic.TryParse().Subscribe(x => this.UpdateAdmiral(x.Data)); proxy.api_req_member_updatecomment.TryParse().Subscribe(this.UpdateComment); From 233b80369405680e57a03eabe2cea5f6892f8627 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Sun, 15 Feb 2015 01:25:47 +0900 Subject: [PATCH 12/14] version 3.6 --- Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs index d0654d95d..47839421f 100644 --- a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs +++ b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs @@ -51,4 +51,4 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.5.1.0")] +[assembly: AssemblyVersion("3.6.0.0")] From b59ffdb1ddd65fd06dd8608dd2a42b5f0d5363b6 Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Sun, 15 Feb 2015 01:57:34 +0900 Subject: [PATCH 13/14] =?UTF-8?q?api=5Fuse=5Fslot=5Fid=20=E3=81=AE=20null?= =?UTF-8?q?=20=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Grabacr07.KanColleWrapper/Itemyard.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Grabacr07.KanColleWrapper/Itemyard.cs b/Grabacr07.KanColleWrapper/Itemyard.cs index e88c06bef..e90982d06 100644 --- a/Grabacr07.KanColleWrapper/Itemyard.cs +++ b/Grabacr07.KanColleWrapper/Itemyard.cs @@ -121,11 +121,14 @@ internal void RemoveFromShip(Ship ship) internal void RemoveFromRemodel(kcsapi_remodel_slot source) { - foreach (var id in source.api_use_slot_id) + if (source.api_use_slot_id != null) { - this.SlotItems.Remove(id); + foreach (var id in source.api_use_slot_id) + { + this.SlotItems.Remove(id); + } + this.RaiseSlotItemsChanged(); } - this.RaiseSlotItemsChanged(); } private void CreateItem(kcsapi_createitem source) From be313f60d34a8472938e1862de12bff8c1d85dce Mon Sep 17 00:00:00 2001 From: Grabacr07 Date: Sun, 15 Feb 2015 15:46:42 +0900 Subject: [PATCH 14/14] =?UTF-8?q?=E8=89=A6=E5=A8=98=E4=B8=80=E8=A6=A7?= =?UTF-8?q?=E3=81=AE=E8=A3=85=E5=82=99=E8=A1=A8=E7=A4=BA=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed #125 --- Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs | 2 +- .../Views/Catalogs/ShipCatalogWindow.xaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs index 47839421f..fa8f636a7 100644 --- a/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs +++ b/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs @@ -51,4 +51,4 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.6.0.0")] +[assembly: AssemblyVersion("3.6.1.0")] diff --git a/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml b/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml index 00ac6bf5c..9cf069223 100644 --- a/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml +++ b/Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml @@ -711,7 +711,7 @@ - + - -