From fb2a87c769e6f8a6211e9ef338bee2281ee92da0 Mon Sep 17 00:00:00 2001 From: veigr Date: Fri, 6 May 2016 23:28:50 +0900 Subject: [PATCH] =?UTF-8?q?*=20=E8=BC=B8=E9=80=81=E3=83=9D=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=A7=E8=BC=B8=E9=80=81=E5=8A=9B=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E5=BE=8C=E3=80=81=E6=AF=8D=E6=B8=AF=E5=B8=B0=E6=8A=95?= =?UTF-8?q?=E6=99=82=E3=81=AB=E5=86=8D=E8=A8=88=E7=AE=97=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20*=20=E9=81=8E=E5=89=B0=E3=81=AA=E8=BC=B8?= =?UTF-8?q?=E9=80=81=E5=8A=9B=E6=9B=B4=E6=96=B0=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E5=89=8A=E6=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EventMapHpViewer/MapHpViewer.cs | 2 +- EventMapHpViewer/Properties/AssemblyInfo.cs | 2 +- EventMapHpViewer/ToolView.xaml | 13 +---- EventMapHpViewer/ViewModels/ToolViewModel.cs | 58 ++++++++++++-------- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/EventMapHpViewer/MapHpViewer.cs b/EventMapHpViewer/MapHpViewer.cs index d5ddb9e..2c0043a 100644 --- a/EventMapHpViewer/MapHpViewer.cs +++ b/EventMapHpViewer/MapHpViewer.cs @@ -15,7 +15,7 @@ namespace EventMapHpViewer public class MapHpViewer : IPlugin, ITool { internal const string title = "MapHPViewer"; - internal const string version = "3.3.2"; + internal const string version = "3.3.3"; private ToolViewModel vm; public void Initialize() diff --git a/EventMapHpViewer/Properties/AssemblyInfo.cs b/EventMapHpViewer/Properties/AssemblyInfo.cs index 091636e..0e88c4c 100644 --- a/EventMapHpViewer/Properties/AssemblyInfo.cs +++ b/EventMapHpViewer/Properties/AssemblyInfo.cs @@ -43,4 +43,4 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.3.2.0")] +[assembly: AssemblyVersion("3.3.3.0")] diff --git a/EventMapHpViewer/ToolView.xaml b/EventMapHpViewer/ToolView.xaml index 931d44c..9e26702 100644 --- a/EventMapHpViewer/ToolView.xaml +++ b/EventMapHpViewer/ToolView.xaml @@ -13,7 +13,7 @@ d:DesignHeight="500" d:DesignWidth="500" d:DataContext="{d:DesignData /SampleData/ToolViewModelSampleData.xaml}"> - + @@ -28,7 +28,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -49,13 +49,6 @@ ConvertWhenFalse="Visible"/> - - - - - - { - () => this.mapInfoProxy.Maps, (sender, args) => - { - // M の中身は殆ど変更通知してくれないし全部一括作りなおししかしないひどい実装 - this.Maps = this.mapInfoProxy.Maps.MapList - .OrderBy(x => x.Id) - .Select(x => new MapViewModel(x)) - .Where(x => !x.IsCleared) - .ToArray(); - this.IsNoMap = !this.Maps.Any(); - this.FleetsUpdated(); - } - } - }); + if (this.mapInfoProxy?.Maps?.MapList == null) return; + // M の中身は殆ど変更通知してくれないし全部一括作りなおししかしないひどい実装 + this.Maps = this.mapInfoProxy.Maps.MapList + .OrderBy(x => x.Id) + .Select(x => new MapViewModel(x)) + .Where(x => !x.IsCleared) + .ToArray(); + this.IsNoMap = !this.Maps.Any(); + this.FleetsUpdated(); + }, false); + + KanColleClient.Current + .Subscribe(nameof(KanColleClient.IsStarted), Initialize, false); } - public void Loaded() + public void Initialize() { + Debug.WriteLine("ToolViewModel: Initialize()"); // 変更検知はあまり深く考えないでやってしまっているのでマズいところあるかも (そもそもVMでやることではない) KanColleClient.Current.Homeport.Organization - .Subscribe(nameof(Organization.Fleets), this.FleetsUpdated) - .Subscribe(nameof(Organization.Combined), this.RaiseTransportCapacityChanged) - .Subscribe(nameof(Organization.Ships), () => this.handledShips.Clear()) + .Subscribe(nameof(Organization.Fleets), this.FleetsUpdated, false) + .Subscribe(nameof(Organization.Combined), this.RaiseTransportCapacityChanged, false) + .Subscribe(nameof(Organization.Ships), () => this.handledShips.Clear(), false) .AddTo(this); KanColleClient.Current.Proxy.ApiSessionSource .Where(s => s.Request.PathAndQuery == "/kcsapi/api_req_map/next") @@ -55,11 +57,21 @@ public void Loaded() .Subscribe(x => { if (x.Data.api_event_id == 9) + { + Debug.WriteLine("ToolViewModel: fixedTransportCapacity = true"); this.fixedTransportCapacity = true; + } }) .AddTo(this); KanColleClient.Current.Proxy.api_port - .Subscribe(_ => this.fixedTransportCapacity = false) + .Subscribe(_ => + { + if (!fixedTransportCapacity) return; + + Debug.WriteLine("ToolViewModel: fixedTransportCapacity = false"); + this.fixedTransportCapacity = false; + this.RaiseTransportCapacityChanged(); + }) .AddTo(this); } @@ -123,12 +135,12 @@ private void FleetsUpdated() this.fleetHandlers.Clear(); foreach (var fleet in KanColleClient.Current.Homeport.Organization.Fleets.Values) { - this.fleetHandlers.Add(fleet.Subscribe(nameof(fleet.Ships), this.RaiseTransportCapacityChanged)); + this.fleetHandlers.Add(fleet.Subscribe(nameof(fleet.Ships), this.RaiseTransportCapacityChanged, false)); foreach (var ship in fleet.Ships) { if (this.handledShips.Contains(ship)) return; - this.fleetHandlers.Add(ship.Subscribe(nameof(ship.Slots), this.RaiseTransportCapacityChanged)); - this.fleetHandlers.Add(ship.Subscribe(nameof(ship.Situation), this.RaiseTransportCapacityChanged)); + this.fleetHandlers.Add(ship.Subscribe(nameof(ship.Slots), this.RaiseTransportCapacityChanged, false)); + this.fleetHandlers.Add(ship.Subscribe(nameof(ship.Situation), this.RaiseTransportCapacityChanged, false)); this.handledShips.Add(ship); } }