Skip to content

Commit

Permalink
Merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuubari committed Jun 2, 2016
2 parents bcdc776 + 6372772 commit 2d98c20
Show file tree
Hide file tree
Showing 22 changed files with 822 additions and 605 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class _KanColleClientSettings : IKanColleClientSettings
public bool EnableTranslations { get; set; }
public bool EnableUpdates { get; set; }
public bool EnableAutosubmission { get; set; }
public bool IsViewRangeCalcIncludeFirstFleet { get; set; }
public bool IsViewRangeCalcIncludeSecondFleet { get; set; }
public bool CheckFlagshipIsRepairShip { get; set; }

event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ public class KanColleSettings : IKanColleClientSettings
public static SerializableProperty<string> ViewRangeCalcType { get; }
= new SerializableProperty<string>(GetKey(), Providers.Roaming, new ViewRangeType1().Id);

/// <summary>
/// 索敵計算に第1艦隊を含めるかどうかの設定値を取得します。
/// </summary>
public static SerializableProperty<bool> IsViewRangeCalcIncludeFirstFleet { get; }
= new SerializableProperty<bool>(GetKey(), Providers.Roaming, true);

/// <summary>
/// 索敵計算に第2艦隊を含めるかどうかの設定値を取得します。
/// </summary>
public static SerializableProperty<bool> IsViewRangeCalcIncludeSecondFleet { get; }
= new SerializableProperty<bool>(GetKey(), Providers.Roaming, false);

/// <summary>
/// 建造完了時に通知するかどうかを示す設定値を取得します。
/// </summary>
Expand Down Expand Up @@ -111,6 +123,8 @@ public KanColleSettings()
NotificationShorteningTime.Subscribe(_ => this.RaisePropertyChanged(nameof(NotificationShorteningTime)));
ReSortieCondition.Subscribe(_ => this.RaisePropertyChanged(nameof(ReSortieCondition)));
ViewRangeCalcType.Subscribe(_ => this.RaisePropertyChanged(nameof(ViewRangeCalcType)));
IsViewRangeCalcIncludeFirstFleet.Subscribe(_ => this.RaisePropertyChanged(nameof(IsViewRangeCalcIncludeFirstFleet)));
IsViewRangeCalcIncludeSecondFleet.Subscribe(_ => this.RaisePropertyChanged(nameof(IsViewRangeCalcIncludeSecondFleet)));
GeneralSettings.Culture.Subscribe(_ => this.RaisePropertyChanged(GeneralSettings.Culture));
}

Expand All @@ -129,6 +143,10 @@ protected void RaisePropertyChanged([CallerMemberName] string propertyName = nul

string IKanColleClientSettings.ViewRangeCalcType => ViewRangeCalcType.Value;

bool IKanColleClientSettings.IsViewRangeCalcIncludeFirstFleet => IsViewRangeCalcIncludeFirstFleet.Value;

bool IKanColleClientSettings.IsViewRangeCalcIncludeSecondFleet => IsViewRangeCalcIncludeSecondFleet.Value;

string IKanColleClientSettings.Culture => GeneralSettings.Culture.Value;

bool IKanColleClientSettings.EnableTranslations => EnableTranslations.Value;
Expand Down
2 changes: 1 addition & 1 deletion source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly)]

[assembly: AssemblyVersion("4.2.4.0")]
[assembly: AssemblyVersion("4.2.5.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Livet;
using Livet.EventListeners;
using MetroTrilithon.Mvvm;
using Livet;

namespace Grabacr07.KanColleViewer.ViewModels.Settings
{
Expand Down Expand Up @@ -50,9 +51,9 @@ public override string Name

#region ViewRangeSettingsCollection 変更通知プロパティ

private List<ViewRangeSettingsViewModel> _ViewRangeSettingsCollection;
private List<ICalcViewRange> _ViewRangeSettingsCollection;

public List<ViewRangeSettingsViewModel> ViewRangeSettingsCollection
public List<ICalcViewRange> ViewRangeSettingsCollection
{
get { return this._ViewRangeSettingsCollection; }
set
Expand All @@ -67,6 +68,26 @@ public List<ViewRangeSettingsViewModel> ViewRangeSettingsCollection

#endregion

#region SelectedViewRangeCalcType 変更通知プロパティ

private ICalcViewRange _SelectedViewRangeCalcType;

public ICalcViewRange SelectedViewRangeCalcType
{
get { return this._SelectedViewRangeCalcType; }
set
{
if (this._SelectedViewRangeCalcType != value)
{
this._SelectedViewRangeCalcType = value;
KanColleSettings.ViewRangeCalcType.Value = value.Id;
this.RaisePropertyChanged();
}
}
}

#endregion

private SettingsViewModel()
{
this.ScreenshotSettings = new ScreenshotSettingsViewModel().AddTo(this);
Expand Down Expand Up @@ -96,15 +117,16 @@ private SettingsViewModel()
return list;
});

this.ViewRangeSettingsCollection = ViewRangeCalcLogic.Logics.ToList();
this.SelectedViewRangeCalcType = this.ViewRangeSettingsCollection
.FirstOrDefault(x => x.Id == KanColleSettings.ViewRangeCalcType)
?? this.ViewRangeSettingsCollection.First();

this.CompositeDisposable.Add(new PropertyChangedEventListener(KanColleClient.Current.Translations)
{
(sender, args) => this.RaisePropertyChanged(args.PropertyName),
});

this.ViewRangeSettingsCollection = ViewRangeCalcLogic.Logics
.Select(x => new ViewRangeSettingsViewModel(x))
.ToList();

this.LoadedPlugins = new List<PluginViewModel>(
PluginService.Current.Plugins.Select(x => new PluginViewModel(x)));

Expand All @@ -119,56 +141,5 @@ public void Initialize()
this.NetworkSettings.Initialize();
this.UserStyleSheetSettings.Initialize();
}


public class ViewRangeSettingsViewModel : ViewModel
{
private bool selected;

public ICalcViewRange Logic { get; set; }

public string Name => GetLocalisedStrings(Logic.Id);

public string Description => GetLocalisedStrings(Logic.Id, true);

public bool Selected
{
get { return this.selected; }
set
{
this.selected = value;
if (value)
{
KanColleSettings.ViewRangeCalcType.Value = this.Logic.Id;
}
}
}

public ViewRangeSettingsViewModel(ICalcViewRange logic)
{
this.Logic = logic;
this.selected = KanColleSettings.ViewRangeCalcType == logic.Id;
ResourceService.Current.Subscribe(x =>
{
this.RaisePropertyChanged(nameof(Name));
this.RaisePropertyChanged(nameof(Description));
});
}

private string GetLocalisedStrings(string type, bool desc = false)
{
switch (type)
{
case "KanColleViewer.Type1":
return !desc ? Resources.ViewRangeLogic_Type1_Name : Resources.ViewRangeLogic_Type1_Desc;
case "KanColleViewer.Type2":
return !desc ? Resources.ViewRangeLogic_Type2_Name : Resources.ViewRangeLogic_Type2_Desc;
case "KanColleViewer.Type3":
return !desc ? Resources.ViewRangeLogic_Type3_Name : Resources.ViewRangeLogic_Type3_Desc;
}

return !desc ? Logic.Name : Logic.Description;
}
}
}
}
43 changes: 25 additions & 18 deletions source/Grabacr07.KanColleViewer/Views/Settings/Operation.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,31 @@
<StackPanel Margin="20,0,0,0">
<TextBlock Text="{Binding Resources.Settings_Operation_LoS_Title, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />

<ItemsControl ItemsSource="{Binding ViewRangeSettingsCollection}"
Margin="0,5">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton IsChecked="{Binding Selected}"
Margin="0,5"
GroupName="ViewRangeCalcLogicSelection">
<TextBlock Style="{DynamicResource DefaultTextStyleKey}"
LineHeight="18">
<Run Text="{Binding Name, Mode=OneWay}"
Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type RadioButton}}, Path=Foreground}" />
<LineBreak />
<Run Text="{Binding Description, Mode=OneWay}" />
</TextBlock>
</RadioButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<metro:PromptComboBox ItemsSource="{Binding ViewRangeSettingsCollection}"
Margin="0,5"
DisplayMemberPath="Name"
SelectedItem="{Binding SelectedViewRangeCalcType}"
MinWidth="100"
Prompt=""
HorizontalAlignment="Left"/>

<TextBlock Text="{Binding SelectedViewRangeCalcType.Description}"
Style="{DynamicResource DetailTextStyleKey}"/>


<TextBlock Text="連合艦隊時、以下の艦隊を索敵値計算の対象として使用する"
Margin="0,12,0,5"
Visibility="{Binding SelectedViewRangeCalcType.HasCombinedSettings, Converter={StaticResource BooleanToVisibilityConverter}}"/>

<StackPanel Orientation="Horizontal"
Visibility="{Binding SelectedViewRangeCalcType.HasCombinedSettings, Converter={StaticResource BooleanToVisibilityConverter}}">
<CheckBox Content="第1艦隊"
IsChecked="{Binding Source={x:Static ms:KanColleSettings.IsViewRangeCalcIncludeFirstFleet}, Path=Value}"
Margin="0,0,20,0"/>
<CheckBox Content="第2艦隊"
IsChecked="{Binding Source={x:Static ms:KanColleSettings.IsViewRangeCalcIncludeSecondFleet}, Path=Value}"/>
</StackPanel>

</StackPanel>

<Rectangle Style="{DynamicResource SeparatorStyleKey}" />
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 5 additions & 2 deletions source/Grabacr07.KanColleWrapper/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static int CalcMinAirSuperiorityPotential(this Ship ship)
{
return ship.EquippedItems
.Select(x => (x.Item.Info.Type == SlotItemType.艦上戦闘機
|| x.Item.Info.Type == SlotItemType.水上戦闘機
? x.Item.CalcAirSuperiorityPotential(x.Current)
: 0)
+ x.Item.CalcMinAirecraftAdeptBonus(x.Current))
Expand Down Expand Up @@ -71,8 +72,9 @@ private static double CalcMinAirecraftAdeptBonus(this SlotItem slotItem, int ons
{
if(onslot < 1) return 0;
return slotItem.Info.Type == SlotItemType.艦上戦闘機
|| slotItem.Info.Type == SlotItemType.水上戦闘機
? slotItem.CalcAirecraftAdeptBonusOfType() + slotItem.CalcMinInternalAirecraftAdeptBonus()
: 0; // 艦戦以外は簡単に吹き飛ぶので最小値としては計算に入れない
: 0; // 艦戦・水戦以外は簡単に吹き飛ぶので最小値としては計算に入れない
}

/// <summary>
Expand All @@ -92,6 +94,7 @@ private static double CalcMaxAirecraftAdeptBonus(this SlotItem slotItem, int ons
/// <returns></returns>
private static int CalcAirecraftAdeptBonusOfType(this SlotItem slotItem)
=> slotItem.Info.Type == SlotItemType.艦上戦闘機
|| slotItem.Info.Type == SlotItemType.水上戦闘機
? slotItem.Adept == 1 ? 0
: slotItem.Adept == 2 ? 2
: slotItem.Adept == 3 ? 5
Expand Down Expand Up @@ -147,7 +150,7 @@ private static double CalcMaxInternalAirecraftAdeptBonus(this SlotItem slotItem)

public static double CalcViewRange(this Fleet fleet)
{
return ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType).Calc(fleet.Ships);
return ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType).Calc(new[] { fleet });
}

public static bool IsHeavilyDamage(this LimitedValue hp)
Expand Down
2 changes: 1 addition & 1 deletion source/Grabacr07.KanColleWrapper/Homeport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ internal Homeport(KanColleProxy proxy)

proxy.api_port.TryParse<kcsapi_port>().Subscribe(x =>
{
this.UpdateAdmiral(x.Data.api_basic);
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 != 0;
this.Materials.Update(x.Data.api_material);
this.UpdateAdmiral(x.Data.api_basic);
});
proxy.api_get_member_basic.TryParse<kcsapi_basic>().Subscribe(x => this.UpdateAdmiral(x.Data));
proxy.api_req_member_updatecomment.TryParse().Subscribe(this.UpdateComment);
Expand Down
2 changes: 2 additions & 0 deletions source/Grabacr07.KanColleWrapper/IKanColleClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface IKanColleClientSettings : INotifyPropertyChanged
/// 索敵計算に使用するロジックを識別する文字列を取得します。
/// </summary>
string ViewRangeCalcType { get; }
bool IsViewRangeCalcIncludeFirstFleet { get; }
bool IsViewRangeCalcIncludeSecondFleet { get; }

string Culture { get; }

Expand Down
8 changes: 8 additions & 0 deletions source/Grabacr07.KanColleWrapper/KanColleProxy.Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ public IObservable<Session> api_req_kaisou_slot_exchange_index
get { return this.ApiSessionSource.Where(x => x.Request.PathAndQuery == "/kcsapi/api_req_kaisou/slot_exchange_index"); }
}

/// <summary>
/// エンド ポイント "/kcsapi/api_req_kaisou/slot_deprive" からのセッションを配信します。
/// </summary>
public IObservable<Session> api_req_kaisou_slot_deprive
{
get { return this.ApiSessionSource.Where(x => x.Request.PathAndQuery == "/kcsapi/api_req_kaisou/slot_deprive"); }
}

/// <summary>
/// エンド ポイント "/kcsapi/api_req_kousyou/getship" からのセッションを配信します。
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"/kcsapi/api_req_hokyu/charge",
"/kcsapi/api_req_kaisou/powerup",
"/kcsapi/api_req_kaisou/slot_exchange_index",
"/kcsapi/api_req_kaisou/slot_deprive",
"/kcsapi/api_req_kousyou/getship",
"/kcsapi/api_req_kousyou/createitem",
"/kcsapi/api_req_kousyou/createship",
Expand Down
1 change: 1 addition & 0 deletions source/Grabacr07.KanColleWrapper/KanColleWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<Compile Include="Models\Raw\kcsapi_powerup.cs" />
<Compile Include="Models\Raw\kcsapi_remodel_slotlist.cs" />
<Compile Include="Models\Raw\kcsapi_remodel_slotlist_detail.cs" />
<Compile Include="Models\Raw\kcsapi_slot_deprive.cs" />
<Compile Include="Models\Raw\kcsapi_slot_exchange_index.cs" />
<Compile Include="Models\ShipSituation.cs" />
<Compile Include="Models\ShipSlot.cs" />
Expand Down
6 changes: 4 additions & 2 deletions source/Grabacr07.KanColleWrapper/Models/FleetState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ public FleetState(Homeport homeport, params Fleet[] fleets)
this.CompositeDisposable.Add(this.Condition);
this.CompositeDisposable.Add(new PropertyChangedWeakEventListener(KanColleClient.Current.Settings)
{
{ nameof(IKanColleClientSettings.ViewRangeCalcType), (sender, args) => this.Calculate() },
{ nameof(IKanColleClientSettings.ViewRangeCalcType), (_, __) => this.Calculate() },
{ nameof(IKanColleClientSettings.IsViewRangeCalcIncludeFirstFleet), (_, __) => this.Calculate() },
{ nameof(IKanColleClientSettings.IsViewRangeCalcIncludeSecondFleet), (_, __) => this.Calculate() },
});
}

Expand All @@ -265,7 +267,7 @@ public void Calculate()
: FleetSpeed.Hybrid;

var logic = ViewRangeCalcLogic.Get(KanColleClient.Current.Settings.ViewRangeCalcType);
this.ViewRange = logic.Calc(ships.ToArray());
this.ViewRange = logic.Calc(this.source);
this.ViewRangeCalcType = logic.Name;

this.Calculated?.Invoke(this, new EventArgs());
Expand Down
27 changes: 27 additions & 0 deletions source/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_slot_deprive.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable InconsistentNaming

namespace Grabacr07.KanColleWrapper.Models.Raw
{
public class kcsapi_slot_deprive
{
public kcsapi_slot_deprive_ship_data api_ship_data { get; set; }
public kcsapi_slot_deprive_unset_List api_unset_list { get; set; }
}

public class kcsapi_slot_deprive_ship_data
{
public kcsapi_ship2 api_set_ship { get; set; }
public kcsapi_ship2 api_unset_ship { get; set; }
}

public class kcsapi_slot_deprive_unset_List
{
public int api_type3No { get; set; }
public int[] api_slot_list { get; set; }
}
}
6 changes: 4 additions & 2 deletions source/Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ public class SlotItemInfo : RawDataWrapper<kcsapi_mst_slotitem>, IIdentifiable
public bool IsAirSuperiorityFighter => this.Type == SlotItemType.艦上戦闘機
|| this.Type == SlotItemType.艦上攻撃機
|| this.Type == SlotItemType.艦上爆撃機
|| this.Type == SlotItemType.水上爆撃機;
|| this.Type == SlotItemType.水上爆撃機
|| this.Type == SlotItemType.水上戦闘機;

public bool IsNumerable => this.Type == SlotItemType.艦上偵察機
|| this.Type == SlotItemType.艦上戦闘機
|| this.Type == SlotItemType.艦上攻撃機
|| this.Type == SlotItemType.艦上爆撃機
|| this.Type == SlotItemType.水上偵察機
|| this.Type == SlotItemType.水上爆撃機;
|| this.Type == SlotItemType.水上爆撃機
|| this.Type == SlotItemType.水上戦闘機;

public SlotItemEquipType EquipType { get; }

Expand Down
Loading

0 comments on commit 2d98c20

Please sign in to comment.