Skip to content

Commit

Permalink
* 輸送ポイントで輸送力固定後、母港帰投時に再計算されなかった問題を修正
Browse files Browse the repository at this point in the history
* 過剰な輸送力更新処理を削減
  • Loading branch information
veigr committed May 6, 2016
1 parent 6bc7328 commit fb2a87c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion EventMapHpViewer/MapHpViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion EventMapHpViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.3.2.0")]
[assembly: AssemblyVersion("3.3.3.0")]
13 changes: 3 additions & 10 deletions EventMapHpViewer/ToolView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
d:DesignHeight="500"
d:DesignWidth="500"
d:DataContext="{d:DesignData /SampleData/ToolViewModelSampleData.xaml}">

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand All @@ -28,7 +28,7 @@
<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Styles/Controls.Scrollbar.xaml" />
<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Styles/Controls.Tooltip.xaml" />
<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Styles/Icons.xaml" />

<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Themes/Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MetroRadiance;component/Themes/Accents/Purple.xaml" />

Expand All @@ -40,7 +40,7 @@
<ResourceDictionary Source="pack://application:,,,/KanColleViewer.Controls;component/Styles/Controls.TabControl.xaml" />
<ResourceDictionary Source="pack://application:,,,/KanColleViewer.Controls;component/Styles/Controls.Text.xaml" />
</ResourceDictionary.MergedDictionaries>

<l:VisibilityAndBooleanConverter x:Key="TrueToVisibleConverter"
ConvertWhenTrue="Visible"
ConvertWhenFalse="Collapsed"/>
Expand All @@ -49,13 +49,6 @@
ConvertWhenFalse="Visible"/>
</ResourceDictionary>
</UserControl.Resources>

<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<l:LivetCallMethodAction MethodTarget="{Binding}"
MethodName="Loaded" />
</i:EventTrigger>
</i:Interaction.Triggers>

<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
Expand Down
58 changes: 35 additions & 23 deletions EventMapHpViewer/ViewModels/ToolViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,55 @@ public ToolViewModel(MapInfoProxy proxy)

if (this.mapInfoProxy == null) return;

this.CompositeDisposable.Add(new PropertyChangedEventListener(this.mapInfoProxy)
{
this.mapInfoProxy.Subscribe(
nameof(MapInfoProxy.Maps),
() =>
{
() => 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")
.TryParse<map_start_next>()
.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);
}

Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit fb2a87c

Please sign in to comment.