Skip to content

Commit

Permalink
3.6対応
Browse files Browse the repository at this point in the history
  • Loading branch information
veigr committed Apr 30, 2015
1 parent e71df15 commit ef214cd
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 41 deletions.
9 changes: 7 additions & 2 deletions EventMapHpViewer/EventMapHpViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,21 @@
</ItemGroup>
<ItemGroup>
<Compile Include="EventMapHpViewer.cs" />
<Compile Include="Models\MapInfos.cs" />
<Compile Include="Models\MapArea.cs" />
<Compile Include="Models\MapInfo.cs" />
<Compile Include="Models\Maps.cs" />
<Compile Include="Models\MapInfoProxy.cs" />
<Compile Include="Models\Raw\Api_Eventmap.cs" />
<Compile Include="Models\Raw\kcsapi_mst_maparea.cs" />
<Compile Include="Models\Raw\kcsapi_mst_mapinfo.cs" />
<Compile Include="Models\Raw\kcsapi_start2.cs" />
<Compile Include="Models\Raw\member_mapinfo.cs" />
<Compile Include="Models\Raw\map_start_next.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ToolView.xaml.cs">
<DependentUpon>ToolView.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\MapInfoViewModel.cs" />
<Compile Include="ViewModels\MapViewModel.cs" />
<Compile Include="ViewModels\ToolViewModel.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
34 changes: 34 additions & 0 deletions EventMapHpViewer/Models/MapArea.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Grabacr07.KanColleWrapper.Models;
using EventMapHpViewer.Models.Raw;

namespace EventMapHpViewer.Models
{
public class MapArea : RawDataWrapper<kcsapi_mst_maparea>, IIdentifiable
{
public int Id { get; private set; }

public string Name { get; private set; }

public MapArea(kcsapi_mst_maparea maparea)
: base(maparea)
{
this.Id = maparea.api_id;
this.Name = maparea.api_name;
}

#region static members

private static MapArea dummy = new MapArea(new kcsapi_mst_maparea()
{
api_id = 0,
api_name = "???",
});

public static MapArea Dummy
{
get { return dummy; }
}

#endregion
}
}
59 changes: 59 additions & 0 deletions EventMapHpViewer/Models/MapInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Grabacr07.KanColleWrapper;
using Grabacr07.KanColleWrapper.Models;
using EventMapHpViewer.Models.Raw;

namespace EventMapHpViewer.Models
{
public class MapInfo : RawDataWrapper<kcsapi_mst_mapinfo>, IIdentifiable
{
public int Id { get; private set; }

public string Name { get; private set; }

public int MapAreaId { get; private set; }

public MapArea MapArea { get; private set; }

public int IdInEachMapArea { get; private set; }

public int Level { get; private set; }

public string OperationName { get; private set; }

public string OperationSummary { get; private set; }

public int RequiredDefeatCount { get; private set; }

public MapInfo(kcsapi_mst_mapinfo mapinfo, MasterTable<MapArea> mapAreas)
: base(mapinfo)
{
this.Id = mapinfo.api_id;
this.Name = mapinfo.api_name;
this.MapAreaId = mapinfo.api_maparea_id;
this.MapArea = mapAreas[mapinfo.api_maparea_id] ?? Models.MapArea.Dummy;
this.IdInEachMapArea = mapinfo.api_no;
this.Level = mapinfo.api_level;
this.OperationName = mapinfo.api_opetext;
this.OperationSummary = mapinfo.api_infotext;
this.RequiredDefeatCount = mapinfo.api_required_defeat_count ?? 1;
}

#region static members

private static MapInfo dummy = new MapInfo(new kcsapi_mst_mapinfo()
{
api_id = 0,
api_name = "???",
api_maparea_id = 0,
api_no = 0,
api_level = 0,
}, new MasterTable<MapArea>());

public static MapInfo Dummy
{
get { return dummy; }
}

#endregion
}
}
22 changes: 13 additions & 9 deletions EventMapHpViewer/Models/MapInfoProxy.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reactive.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using EventMapHpViewer.Models.Raw;
using Fiddler;
using Grabacr07.KanColleWrapper;
using Livet;

Expand All @@ -16,9 +12,9 @@ public class MapInfoProxy : NotificationObject
{

#region Maps変更通知プロパティ
private MapInfos _Maps;
private Maps _Maps;

public MapInfos Maps
public Maps Maps
{
get
{ return this._Maps; }
Expand All @@ -34,16 +30,24 @@ public MapInfos Maps

public MapInfoProxy()
{
this.Maps = new MapInfos();
this.Maps = new Maps();

var proxy = KanColleClient.Current.Proxy;

proxy.api_start2
.TryParse<kcsapi_start2>()
.Subscribe(x =>
{
Maps.MapAreas = new MasterTable<MapArea>(x.Data.api_mst_maparea.Select(m => new MapArea(m)));
Maps.MapInfos = new MasterTable<MapInfo>(x.Data.api_mst_mapinfo.Select(m => new MapInfo(m, Maps.MapAreas)));
});

proxy.ApiSessionSource.Where(s => s.PathAndQuery.StartsWith("/kcsapi/api_get_member/mapinfo"))
.TryParse<member_mapinfo[]>()
.Subscribe(m =>
{
Debug.WriteLine("MapInfoProxy - member_mapinfo");
this.Maps.MapInfoList = m.Data.Select(x => new MapInfo
this.Maps.MapList = m.Data.Select(x => new Map
{
IsCleared = x.api_cleared,
DefeatCount = x.api_defeat_count,
Expand All @@ -68,7 +72,7 @@ public MapInfoProxy()
// .Subscribe(m =>
// {
// if (m.Data.api_eventmap == null) return;
// var eventMap = this.Maps.MapInfoList.LastOrDefault(x => x.Eventmap != null);
// var eventMap = this.Maps.MapList.LastOrDefault(x => x.Eventmap != null);
// if (eventMap == null) return;
// if (eventMap.Eventmap.MaxMapHp != 9999) return;
// Debug.WriteLine("MapInfoProxy - map_start_next");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@

namespace EventMapHpViewer.Models
{
public class MapInfos
public class Maps
{
public MapInfo[] MapInfoList { get; set; }
public Map[] MapList { get; set; }
public static MasterTable<MapArea> MapAreas { get; set; }
public static MasterTable<MapInfo> MapInfos { get; set; }
}

public class MapInfo
public class Map
{
public int Id { get; set; }
public int IsCleared { get; set; }
public int IsExBoss { get; set; }
public int DefeatCount { get; set; }
public Eventmap Eventmap { get; set; }

public Grabacr07.KanColleWrapper.Models.MapInfo Master
public MapInfo Master
{
get { return KanColleClient.Current.Master.MapInfos[this.Id]; }
get { return Maps.MapInfos[this.Id]; }
}

public string MapNumber
Expand Down
9 changes: 9 additions & 0 deletions EventMapHpViewer/Models/Raw/kcsapi_mst_maparea.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace EventMapHpViewer.Models.Raw
{
public class kcsapi_mst_maparea
{
public int api_id { get; set; }
public string api_name { get; set; }
public int api_type { get; set; }
}
}
17 changes: 17 additions & 0 deletions EventMapHpViewer/Models/Raw/kcsapi_mst_mapinfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace EventMapHpViewer.Models.Raw
{
public class kcsapi_mst_mapinfo
{
public int api_id { get; set; }
public int api_maparea_id { get; set; }
public int api_no { get; set; }
public string api_name { get; set; }
public int api_level { get; set; }
public string api_opetext { get; set; }
public string api_infotext { get; set; }
public int[] api_item { get; set; }
public int? api_max_maphp { get; set; }
public int? api_required_defeat_count { get; set; }
public int[] api_sally_flag { get; set; }
}
}
10 changes: 10 additions & 0 deletions EventMapHpViewer/Models/Raw/kcsapi_start2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace EventMapHpViewer.Models.Raw
{
// ReSharper disable InconsistentNaming
public class kcsapi_start2
{
public kcsapi_mst_maparea[] api_mst_maparea { get; set; }
public kcsapi_mst_mapinfo[] api_mst_mapinfo { get; set; }
}
// ReSharper restore InconsistentNaming
}
24 changes: 12 additions & 12 deletions EventMapHpViewer/SampleData/ToolViewModelSampleData.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
xmlns:viewModels="clr-namespace:EventMapHpViewer.ViewModels"
IsNoMap="False">
<viewModels:ToolViewModel.Maps>
<viewModels:MapInfoViewModel Current="1000"
<viewModels:MapViewModel Current="1000"
Max="9999"
RemainingCount="10"
MapNumber="30-5"
AreaName="イベント海域"
Name="サーモン海域北方"
IsCleared="False"
IsRankSelected="False">
<viewModels:MapInfoViewModel.GaugeColor>
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#40C820"/>
</viewModels:MapInfoViewModel.GaugeColor>
</viewModels:MapInfoViewModel>
<viewModels:MapInfoViewModel Current="1"
</viewModels:MapViewModel.GaugeColor>
</viewModels:MapViewModel>
<viewModels:MapViewModel Current="1"
Max="1"
RemainingCount="1"
MapNumber="xx-x"
AreaName="ふつう海域"
Name="ふつうマップ"
IsCleared="False"
IsRankSelected="True">
<viewModels:MapInfoViewModel.GaugeColor>
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#FF2020"/>
</viewModels:MapInfoViewModel.GaugeColor>
</viewModels:MapInfoViewModel>
<viewModels:MapInfoViewModel Current="1"
</viewModels:MapViewModel.GaugeColor>
</viewModels:MapViewModel>
<viewModels:MapViewModel Current="1"
Max="5"
RemainingCount="1"
MapNumber="2-5"
AreaName="アルフォンしーの方面"
Name="あるフォンシーの方面進出"
IsCleared="False"
IsRankSelected="True">
<viewModels:MapInfoViewModel.GaugeColor>
<viewModels:MapViewModel.GaugeColor>
<SolidColorBrush Color="#FF2020"/>
</viewModels:MapInfoViewModel.GaugeColor>
</viewModels:MapInfoViewModel>
</viewModels:MapViewModel.GaugeColor>
</viewModels:MapViewModel>
</viewModels:ToolViewModel.Maps>
</viewModels:ToolViewModel>
2 changes: 1 addition & 1 deletion EventMapHpViewer/ToolView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<ItemsControl Grid.Row="1"
ItemsSource="{Binding Maps}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type viewModels:MapInfoViewModel}">
<DataTemplate DataType="{x:Type viewModels:MapViewModel}">
<Border BorderThickness="0,0,0,1"
BorderBrush="{DynamicResource ActiveBorderBrushKey}">
<Grid Margin="0,5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace EventMapHpViewer.ViewModels
{
public class MapInfoViewModel : ViewModel
public class MapViewModel : ViewModel
{

#region MapNumber変更通知プロパティ
Expand Down Expand Up @@ -170,7 +170,7 @@ public bool IsRankSelected



public MapInfoViewModel(MapInfo info)
public MapViewModel(Map info)
{
this.MapNumber = info.MapNumber;
this.Name = info.Name;
Expand Down
8 changes: 4 additions & 4 deletions EventMapHpViewer/ViewModels/ToolViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public ToolViewModel(MapInfoProxy proxy)
{
() => this.mapInfoProxy.Maps, (sender, args) =>
{
this.Maps = this.mapInfoProxy.Maps.MapInfoList
this.Maps = this.mapInfoProxy.Maps.MapList
.OrderBy(x => x.Id)
.Select(x => new MapInfoViewModel(x))
.Select(x => new MapViewModel(x))
.Where(x => !x.IsCleared)
.ToArray();
this.IsNoMap = !this.Maps.Any();
Expand All @@ -32,9 +32,9 @@ public ToolViewModel(MapInfoProxy proxy)
}

#region Maps変更通知プロパティ
private MapInfoViewModel[] _Maps;
private MapViewModel[] _Maps;

public MapInfoViewModel[] Maps
public MapViewModel[] Maps
{
get
{ return this._Maps; }
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ KanColleViewer で、攻略中マップのHPと最低必要撃破回数を一覧
* 2014秋
* 2014夏

### 動作環境

* KanColleViewer version 3.7 以上

### インストール

* `EventMapHpViewer.dll` を KanColleViewer の `Plugins` ディレクトリに放り込んで下さい。

### 使用ライブラリ

* [KanColleViewer](http://grabacr.net/kancolleviewer)
* [MetroRadiance](https://www.nuget.org/packages/MetroRadiance)
* [Reactive Extensions](http://rx.codeplex.com/)
* [Livet](http://ugaya40.net/livet)
* [FiddlerCore](http://fiddler2.com/fiddlercore)
* [Livet](http://ugaya40.hateblo.jp/entry/Livet)
* [FiddlerCore](http://www.telerik.com/fiddler/fiddlercore)


#### ライセンス
Expand Down

0 comments on commit ef214cd

Please sign in to comment.