Skip to content

Commit

Permalink
Merged branch develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
KodamaSakuno committed Jun 9, 2016
2 parents ec33aaa + 8ca7d67 commit 682438c
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 38 deletions.
1 change: 1 addition & 0 deletions HeavenlyWind.Base/HeavenlyWind.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Compile Include="Models\ScreenshotImageFormat.cs" />
<Compile Include="Models\UpdateChannel.cs" />
<Compile Include="Models\UpdateNotificationMode.cs" />
<Compile Include="MultiplyConverter.cs" />
<Compile Include="MultiplyExtension.cs" />
<Compile Include="Preference.cs" />
<Compile Include="Preference.Data.cs" />
Expand Down
16 changes: 14 additions & 2 deletions HeavenlyWind.Base/Models/Preferences/CachePreference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@

namespace Sakuno.KanColle.Amatsukaze.Models.Preferences
{
public class CachePreference
public class CachePreference : ModelBase
{
[JsonProperty("mode")]
public CacheMode Mode { get; set; }

string r_Path = "Cache";
[JsonProperty("path")]
public string Path { get; set; } = "Cache";
public string Path
{
get { return r_Path; }
set
{
if (r_Path != value)
{
r_Path = value;
OnPropertyChanged(nameof(Path));
}
}
}

public CachePreference()
{
Expand Down
25 changes: 25 additions & 0 deletions HeavenlyWind.Base/MultiplyConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace Sakuno.KanColle.Amatsukaze
{
using ConvertClass = Convert;

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

public object Convert(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
{
var x = ConvertClass.ToDouble(rpValue);
var y = ConvertClass.ToDouble(rpParameter);
return (int)(x * y);
}

public object ConvertBack(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
{
throw new NotSupportedException();
}
}
}
20 changes: 0 additions & 20 deletions HeavenlyWind.Base/MultiplyExtension.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace Sakuno.KanColle.Amatsukaze
{
using ConvertClass = Convert;

public class MultiplyExtension : MarkupExtension
{
string r_Path;
Expand All @@ -20,22 +17,5 @@ public MultiplyExtension(string rpPath, double rpParameter)

public override object ProvideValue(IServiceProvider rpServiceProvider) =>
new Binding(r_Path) { Converter = MultiplyConverter.Instance, ConverterParameter = r_Parameter }.ProvideValue(rpServiceProvider);

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

public object Convert(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
{
var x = ConvertClass.ToDouble(rpValue);
var y = ConvertClass.ToDouble(rpParameter);
return x * y;
}

public object ConvertBack(object rpValue, Type rpTargetType, object rpParameter, CultureInfo rpCulture)
{
throw new NotSupportedException();
}
}
}
}
2 changes: 1 addition & 1 deletion HeavenlyWind.Base/ProductInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public static class ProductInfo
public const string AppName = "いんてりじぇんと連装砲くん";
public const string ProductName = "Intelligent Naval Gun";

public const string AssemblyVersionString = "0.1.10.4";
public const string AssemblyVersionString = "0.1.10.5";

public static string Version => AssemblyVersionString;
public static string ReleaseCodeName => "Tiramisu";
Expand Down
2 changes: 2 additions & 0 deletions HeavenlyWind/Styles/Converters.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:rb="clr-namespace:Sakuno.KanColle.Amatsukaze;assembly=HeavenlyWind.Base"
xmlns:rbc="clr-namespace:Sakuno.Converters;assembly=Sakuno.Base"
xmlns:ruic="clr-namespace:Sakuno.UserInterface.Converters;assembly=Sakuno.UserInterface">

Expand All @@ -17,6 +18,7 @@
<ruic:BooleanToInvisibilityConverter x:Key="BooleanToInvisibilityConverter" />

<rbc:OppositeNumberConverter x:Key="OppositeNumberConverter" />
<rb:MultiplyConverter x:Key="MultiplyConverter" />

<ruic:DockToOrientationConverter x:Key="DockToOrientationConverter" />

Expand Down
33 changes: 22 additions & 11 deletions HeavenlyWind/ViewModels/Preferences/PreferencesWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class PreferencesWindowViewModel : WindowViewModel

public bool IsAutoRotationSupported => CurrentDockExtension.IsAutoRotationSupported;

public ICommand OpenScreenshotFolderPickerCommand { get; }
public ICommand OpenFolderPickerCommand { get; }

public ICommand OpenCustomSoundFileDialogCommand { get; }

Expand All @@ -36,7 +36,27 @@ public class PreferencesWindowViewModel : WindowViewModel

LoadedPlugins = PluginService.Instance.LoadedPlugins.Select(r => new PluginViewModel(r)).ToList().AsReadOnly();

OpenScreenshotFolderPickerCommand = new DelegatedCommand(() => GetFilenameWithCommonFolderPicker(r => Preference.Current.Browser.Screenshot.Destination = r));
OpenFolderPickerCommand = new DelegatedCommand<string>(rpType =>
{
using (var rFolderPicker = new CommonOpenFileDialog() { FolderPicker = true })
{
if (rFolderPicker.Show() == CommonFileDialogResult.OK)
{
var rPath = rFolderPicker.Filename;
switch (rpType)
{
case "Cache":
Preference.Current.Cache.Path = rPath;
break;
case "Screenshot":
Preference.Current.Browser.Screenshot.Destination = rPath;
break;
}
}
}
});

OpenCustomSoundFileDialogCommand = new DelegatedCommand<string>(rpType =>
{
Expand All @@ -62,14 +82,5 @@ public class PreferencesWindowViewModel : WindowViewModel
}
});
}

void GetFilenameWithCommonFolderPicker(Action<string> rpContinuation)
{
using (var rFolderPicker = new CommonOpenFileDialog() { FolderPicker = true })
{
if (rFolderPicker.Show() == CommonFileDialogResult.OK)
rpContinuation(rFolderPicker.Filename);
}
}
}
}
23 changes: 21 additions & 2 deletions HeavenlyWind/Views/Game/FleetDetail.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
</Grid.RowDefinitions>

<rc:MaterialIcon Type="Fuel" />
<TextBlock TextAlignment="Right" Margin="4, 2" Grid.Column="1">
<TextBlock Name="FuelToolTipText" TextAlignment="Right" Margin="4, 2" Grid.Column="1">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}/{1}">
<Binding Path="Fuel.Current" />
Expand All @@ -157,7 +157,7 @@
</TextBlock>

<rc:MaterialIcon Type="Bullet" Grid.Row="1" />
<TextBlock TextAlignment="Right" Margin="4, 2" Grid.Column="1" Grid.Row="1">
<TextBlock Name="BulletToolTipText" TextAlignment="Right" Margin="4, 2" Grid.Column="1" Grid.Row="1">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}/{1}">
<Binding Path="Bullet.Current" />
Expand Down Expand Up @@ -225,6 +225,25 @@
<Setter TargetName="Condition" Property="Foreground" Value="Red" />
</DataTrigger>

<DataTrigger Binding="{Binding IsMarried}" Value="True">
<Setter TargetName="FuelToolTipText" Property="Text">
<Setter.Value>
<MultiBinding StringFormat="{}{0}/{1}">
<Binding Path="Fuel.Current" Converter="{StaticResource MultiplyConverter}" ConverterParameter="0.85" />
<Binding Path="Info.MaxFuelConsumption" Converter="{StaticResource MultiplyConverter}" ConverterParameter="0.85" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter TargetName="BulletToolTipText" Property="Text">
<Setter.Value>
<MultiBinding StringFormat="{}{0}/{1}">
<Binding Path="Bullet.Current" Converter="{StaticResource MultiplyConverter}" ConverterParameter="0.85" />
<Binding Path="Info.MaxBulletConsumption" Converter="{StaticResource MultiplyConverter}" ConverterParameter="0.85" />
</MultiBinding>
</Setter.Value>
</Setter>
</DataTrigger>

<DataTrigger Binding="{Binding ExtraSlot}" Value="{x:Null}">
<Setter TargetName="ExtraSlot" Property="Visibility" Value="Collapsed" />
</DataTrigger>
Expand Down
2 changes: 1 addition & 1 deletion HeavenlyWind/Views/Preferences/Cache.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<DockPanel Margin="0, 12, 0, 0">
<TextBlock Text="{rb:StringResource Main.PreferenceWindow_Cache_Path}" />
<Button Content="..." Margin="6, 0, 0, 0" DockPanel.Dock="Right" />
<Button Content="..." Command="{Binding OpenFolderPickerCommand}" CommandParameter="Cache" Margin="6, 0, 0, 0" DockPanel.Dock="Right" />
<TextBox Text="{rb:Preference Cache.Path}" Margin="6, 0, 0, 0" />
</DockPanel>
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion HeavenlyWind/Views/Preferences/Screenshot.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<StackPanel>
<DockPanel>
<TextBlock Text="{rb:StringResource Main.PreferenceWindow_Screenshot_Folder}" />
<Button Content="..." Command="{Binding OpenScreenshotFolderPickerCommand}" Margin="6, 0, 0, 0" DockPanel.Dock="Right" />
<Button Content="..." Command="{Binding OpenFolderPickerCommand}" CommandParameter="Screenshot" Margin="6, 0, 0, 0" DockPanel.Dock="Right" />
<TextBox Text="{rb:Preference Browser.Screenshot.Destination, UpdateSourceTrigger=PropertyChanged}" Margin="6, 0, 0, 0" />
</DockPanel>

Expand Down

0 comments on commit 682438c

Please sign in to comment.