Skip to content

Commit

Permalink
Merged develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
KodamaSakuno committed Aug 2, 2016
2 parents 7d2e720 + 24e6c5a commit 276e4ee
Show file tree
Hide file tree
Showing 86 changed files with 1,149 additions and 653 deletions.
4 changes: 2 additions & 2 deletions HeavenlyWind.Base/CollapsedIfNullExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public CollapsedIfNullExtension(string rpPath)
}

public override object ProvideValue(IServiceProvider rpServiceProvider) =>
new Binding(r_Path) { Converter = NullToVisibilityConverter.Instance }.ProvideValue(rpServiceProvider);
new Binding(r_Path) { Converter = NullToVisibilityConverter.Instance, FallbackValue = EnumUtil.GetBoxed(Visibility.Collapsed) }.ProvideValue(rpServiceProvider);

class NullToVisibilityConverter : IValueConverter
{
public static NullToVisibilityConverter Instance { get; } = new NullToVisibilityConverter();

public object Convert(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture) => rpValue == null ? Visibility.Collapsed : Visibility.Visible;
public object Convert(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture) => rpValue == null ? EnumUtil.GetBoxed(Visibility.Collapsed) : EnumUtil.GetBoxed(Visibility.Visible);

public object ConvertBack(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
{
Expand Down
6 changes: 3 additions & 3 deletions HeavenlyWind.Base/CollapsedIfZeroExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public CollapsedIfZeroExtension(string rpPath)
}

public override object ProvideValue(IServiceProvider rpServiceProvider) =>
new Binding(r_Path) { Converter = IsEqualToZeroToVisibilityConverter.Instance }.ProvideValue(rpServiceProvider);
new Binding(r_Path) { Converter = IsEqualToZeroToVisibilityConverter.Instance, FallbackValue = EnumUtil.GetBoxed(Visibility.Collapsed) }.ProvideValue(rpServiceProvider);

class IsEqualToZeroToVisibilityConverter : IValueConverter
{
Expand All @@ -28,9 +28,9 @@ class IsEqualToZeroToVisibilityConverter : IValueConverter
public object Convert(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
{
if (rpValue is double)
return (double)rpValue == .0 ? Visibility.Collapsed : Visibility.Visible;
return (double)rpValue == .0 ? EnumUtil.GetBoxed(Visibility.Collapsed) : EnumUtil.GetBoxed(Visibility.Visible);
else
return ConvertClass.ToInt32(rpValue) == 0 ? Visibility.Collapsed : Visibility.Visible;
return ConvertClass.ToInt32(rpValue) == 0 ? EnumUtil.GetBoxed(Visibility.Collapsed) : EnumUtil.GetBoxed(Visibility.Visible);
}

public object ConvertBack(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
Expand Down
4 changes: 2 additions & 2 deletions HeavenlyWind.Base/CurrentDockExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public override object ProvideValue(IServiceProvider rpServiceProvider)
{
var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = CoreConverter.Instance };
rResult.Bindings.Add(new Binding() { Path = new PropertyPath(MetroWindow.ScreenOrientationProperty), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(MetroWindow), 1) });
rResult.Bindings.Add(new Binding("LandscapeDock.Value") { Source = Preference.Current.Layout });
rResult.Bindings.Add(new Binding("PortraitDock.Value") { Source = Preference.Current.Layout });
rResult.Bindings.Add(new Binding("LandscapeDock.Value") { Source = Preference.Instance.UI });
rResult.Bindings.Add(new Binding("PortraitDock.Value") { Source = Preference.Instance.UI });
rResult.Bindings.Add(new Binding() { RelativeSource = RelativeSource.Self });

if (Converter != null)
Expand Down
17 changes: 15 additions & 2 deletions HeavenlyWind.Base/HeavenlyWind.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.102.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.102.0\lib\net45\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -79,12 +84,14 @@
<Compile Include="GameConstants.cs" />
<Compile Include="HasFlagExtension.cs" />
<Compile Include="IntegerRangeValidationRule.cs" />
<Compile Include="Internal\PreferencePropertyJsonConverter.cs" />
<Compile Include="Internal\OldPreference.cs" />
<Compile Include="Internal\OldPreferenceMappingAttribute.cs" />
<Compile Include="LanguageInfo.cs" />
<Compile Include="LogItem.cs" />
<Compile Include="Logger.cs" />
<Compile Include="LoggingLevel.cs" />
<Compile Include="Models\CacheMode.cs" />
<Compile Include="Models\ConfirmationMode.cs" />
<Compile Include="Models\FlashQuality.cs" />
<Compile Include="Models\FlashRenderMode.cs" />
<Compile Include="Models\FleetFighterPowerFormula.cs" />
Expand All @@ -97,7 +104,6 @@
<Compile Include="Models\Preferences\GamePreference.cs" />
<Compile Include="Models\Preferences\HeavyDamageLinePreference.cs" />
<Compile Include="Models\Preferences\HeavyDamageLineWidthProperty.cs" />
<Compile Include="Models\Preferences\LayoutPreference.cs" />
<Compile Include="Models\Preferences\NetworkPreference.cs" />
<Compile Include="Models\Preferences\NotificationPreference.cs" />
<Compile Include="Models\Preferences\OtherPreference.cs" />
Expand Down Expand Up @@ -146,6 +152,13 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.Data.SQLite.Core.1.0.102.0\build\net45\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.102.0\build\net45\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>このプロジェクトは、このコンピューター上にない NuGet パッケージを参照しています。それらのパッケージをダウンロードするには、[NuGet パッケージの復元] を使用します。詳細については、http://go.microsoft.com/fwlink/?LinkID=322105 を参照してください。見つからないファイルは {0} です。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.102.0\build\net45\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.102.0\build\net45\System.Data.SQLite.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
285 changes: 285 additions & 0 deletions HeavenlyWind.Base/Internal/OldPreference.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Sakuno.KanColle.Amatsukaze.Models;
using System.Windows;
using System.Windows.Controls;

namespace Sakuno.KanColle.Amatsukaze.Internal
{
class OldPreference
{
[JsonProperty("language")]
[OldPreferenceMapping("main.language")]
public string Language { get; private set; }

[JsonProperty("language_extra")]
[OldPreferenceMapping("main.language_extra")]
public string ExtraResourceLanguage { get; private set; }

[JsonProperty("update")]
public UpdatePreference Update { get; private set; }

[JsonProperty("network")]
public NetworkPreference Network { get; private set; }

[JsonProperty("ui")]
public UserInterfacePreference UI { get; private set; }

[JsonProperty("game")]
public GamePreference Game { get; private set; }

[JsonProperty("cache")]
public CachePreference Cache { get; private set; }

[JsonProperty("browser")]
public BrowserPreference Browser { get; private set; }

[JsonProperty("notification")]
public NotificationPreference Notification { get; private set; }

[JsonProperty("windows")]
public WindowsPreference Windows { get; private set; }

[JsonProperty("layout")]
public LayoutPreference Layout { get; private set; } = new LayoutPreference();

[JsonProperty("other")]
public OtherPreference Other { get; private set; } = new OtherPreference();

public class UpdatePreference
{
[JsonProperty("notification")]
[OldPreferenceMapping("update.notification")]
public UpdateNotificationMode NotificationMode { get; private set; }

[JsonProperty("channel")]
[OldPreferenceMapping("update.channel")]
public UpdateChannel UpdateChannel { get; private set; }
}
public class NetworkPreference
{
[JsonProperty("port")]
[OldPreferenceMapping("network.port")]
public int Port { get; private set; }

[JsonProperty("allowremoterequests")]
[OldPreferenceMapping("network.allow_remote_requests")]
public bool AllowRequestsFromOtherDevices { get; private set; }

[JsonProperty("upstreamproxy")]
public UpstreamProxyPreference UpstreamProxy { get; private set; }
}
public class UpstreamProxyPreference
{
[JsonProperty("enabled")]
[OldPreferenceMapping("network.upstream_proxy.enabled")]
public bool Enabled { get; private set; }

[JsonProperty("host")]
[OldPreferenceMapping("network.upstream_proxy.host")]
public string Host { get; private set; }

[JsonProperty("port")]
[OldPreferenceMapping("network.upstream_proxy.port")]
public int Port { get; private set; }

[JsonProperty("http_only")]
[OldPreferenceMapping("network.upstream_proxy.http_only")]
public bool HttpOnly { get; private set; }
}
public class UserInterfacePreference
{
[JsonProperty("font")]
[OldPreferenceMapping("ui.font")]
public string Font { get; private set; }

[JsonProperty("zoom")]
[OldPreferenceMapping("ui.zoom")]
public double Zoom { get; private set; }

[JsonProperty("hd_line")]
public HeavyDamageLinePreference HeavyDamageLine { get; private set; }

[JsonProperty("use_game_material_icons")]
[OldPreferenceMapping("ui.use_game_material_icons")]
public bool UseGameMaterialIcons { get; private set; }
}
public class HeavyDamageLinePreference
{
[JsonProperty("color")]
[OldPreferenceMapping("ui.hd_line.color")]
public HeavyDamageLineType Type { get; private set; }

[JsonProperty("width")]
[OldPreferenceMapping("ui.hd_line.width")]
public int Width { get; private set; }
}
public class GamePreference
{
[JsonProperty("main_los_formula")]
[OldPreferenceMapping("game.formula.los")]
public FleetLoSFormula MainFleetLoSFormula { get; private set; }

[JsonProperty("main_fp_formula")]
[OldPreferenceMapping("game.formula.fighter_power")]
public FleetFighterPowerFormula MainFighterPowerFormula { get; private set; }

[JsonProperty("fatigue_ceiling")]
[OldPreferenceMapping("game.fatigue_ceiling")]
public int FatigueCeiling { get; private set; }

[JsonProperty("show_battle_info")]
[OldPreferenceMapping("game.sortie.show_battle_info")]
public bool ShowBattleInfo { get; private set; }

[JsonProperty("show_drop")]
[OldPreferenceMapping("game.sortie.show_drop")]
public bool ShowDrop { get; private set; }
}
public class CachePreference
{
[JsonProperty("mode")]
[OldPreferenceMapping("cache.mode")]
public CacheMode Mode { get; private set; }

[JsonProperty("path")]
[OldPreferenceMapping("cache.path")]
public string Path { get; private set; }
}
public class BrowserPreference
{
[JsonProperty("zoom")]
[OldPreferenceMapping("browser.zoom")]
public double Zoom { get; private set; }

[JsonProperty("homepage")]
[OldPreferenceMapping("browser.homepage")]
public string Homepage { get; private set; }

[JsonProperty("layoutengine")]
[OldPreferenceMapping("browser.layout_engine")]
public string CurrentLayoutEngine { get; private set; }

[JsonProperty("flash")]
public FlashPreference Flash { get; private set; }

[JsonProperty("screenshot")]
public ScreenshotPreference Screenshot { get; private set; }

[JsonProperty("action_bar_placement")]
[OldPreferenceMapping("browser.action_bar.placement")]
public bool ActionBarPlacement { get; private set; }

[JsonProperty("action_bar_stick_to_browser")]
[OldPreferenceMapping("browser.action_bar.stick_to_browser")]
public bool ActionBarStickToBrowser { get; private set; }
}
public class FlashPreference
{
[JsonProperty("quality")]
[OldPreferenceMapping("browser.flash.quality")]
public FlashQuality Quality { get; private set; }

[JsonProperty("rendermode")]
[OldPreferenceMapping("browser.flash.render_mode")]
public FlashRenderMode RenderMode { get; private set; }
}
public class ScreenshotPreference
{
[JsonProperty("destination")]
[OldPreferenceMapping("browser.screenshot.path")]
public string Destination { get; private set; }

[JsonProperty("filenameformat")]
[OldPreferenceMapping("browser.screenshot.filename_format")]
public string FilenameFormat { get; private set; }
[JsonProperty("imageformat")]
[OldPreferenceMapping("browser.screenshot.image_format")]
public ScreenshotImageFormat ImageFormat { get; private set; }
}
public class NotificationPreference
{
[JsonProperty("expedition")]
[OldPreferenceMapping("notification.expedition")]
public bool Expedition { get; private set; }

[JsonProperty("repair")]
[OldPreferenceMapping("notification.repair")]
public bool Repair { get; private set; }

[JsonProperty("construction")]
[OldPreferenceMapping("notification.construction")]
public bool Construction { get; private set; }

[JsonProperty("heavily_damaged")]
[OldPreferenceMapping("notification.heavy_damage")]
public bool HeavilyDamagedWarning { get; private set; }

[JsonProperty("recovery_from_fatigue")]
[OldPreferenceMapping("notification.recovery_from_fatigue")]
public bool RecoveryFromFatigue { get; private set; }

[JsonProperty("anchorage_repair")]
[OldPreferenceMapping("notification.anchorage_repair")]
public bool AnchorageRepair { get; private set; }

[JsonProperty("sound")]
[OldPreferenceMapping("notification.sound")]
public NotificationSound Sound { get; private set; }
[JsonProperty("sound_filename")]
[OldPreferenceMapping("notification.sound_filename")]
public string SoundFilename { get; private set; }

[JsonProperty("sound_hd")]
[OldPreferenceMapping("notification.sound_hd")]
public NotificationSound HeavilyDamagedWarningSound { get; private set; }
[JsonProperty("sound_filename_hd")]
[OldPreferenceMapping("notification.sound_filename_hd")]
public string HeavilyDamagedWarningSoundFilename { get; private set; }
}
public class WindowsPreference
{
[JsonProperty("landscape")]
[OldPreferenceMapping("main.windows")]
public JToken LandscapeArray { get; private set; }
}
public class LayoutPreference : ModelBase
{
[JsonProperty("landscape")]
[OldPreferenceMapping("ui.layout.lanscape")]
public Dock LandscapeDock { get; private set; }

[JsonProperty("portrait")]
[OldPreferenceMapping("ui.layout.portrait")]
public Dock PortraitDock { get; private set; }
}
public class OtherPreference
{
[JsonProperty("panic_key")]
public PanicKeyPreference PanicKey { get; private set; }

[JsonProperty("session_tool")]
public SessionToolPreference SessionTool { get; private set; }
}
public class PanicKeyPreference
{
[JsonProperty("enabled")]
[OldPreferenceMapping("other.panic_key.enabled")]
public bool Enabled { get; private set; }

[JsonProperty("modifier_keys")]
[OldPreferenceMapping("other.panic_key.modifier_keys")]
public int ModifierKeys { get; private set; }

[JsonProperty("key")]
[OldPreferenceMapping("other.panic_key.key")]
public int Key { get; private set; }
}
public class SessionToolPreference
{
[JsonProperty("start_recording_on_app_startup")]
[OldPreferenceMapping("other.session_tool.start_recording_on_app_startup")]
public bool StartRecordingOnAppStartup { get; private set; }
}
}
}
15 changes: 15 additions & 0 deletions HeavenlyWind.Base/Internal/OldPreferenceMappingAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace Sakuno.KanColle.Amatsukaze.Internal
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
class OldPreferenceMappingAttribute : Attribute
{
public string Key { get; }

public OldPreferenceMappingAttribute(string rpKey)
{
Key = rpKey;
}
}
}
Loading

0 comments on commit 276e4ee

Please sign in to comment.