Add a DisableDropSound indicator. (#118)

* Add a DisableDropSound indicator.

* Improve the DisableDropSound indicator tooltip.
This commit is contained in:
Glen M 2018-12-06 10:15:46 -05:00 committed by Ben Wallis
parent dce0af7fd6
commit 2f49e85227
9 changed files with 116 additions and 24 deletions

View File

@ -0,0 +1,31 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media.Imaging;
namespace Filtration.Converters
{
public class DisabledDefaultSoundConverter : IValueConverter
{
private static readonly BitmapImage _soundIcon;
private static readonly BitmapImage _soundDDSIcon;
static DisabledDefaultSoundConverter()
{
var soundUri = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/sound.png", UriKind.Absolute);
var soundDDSUri = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/sound_dds.png", UriKind.Absolute);
_soundIcon = new BitmapImage(soundUri);
_soundDDSIcon = new BitmapImage(soundDDSUri);
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? _soundDDSIcon : _soundIcon;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return ReferenceEquals(value, _soundDDSIcon);
}
}
}

View File

@ -0,0 +1,38 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Filtration.Converters
{
class DisabledDefaultSoundTooltipConverter : IMultiValueConverter
{
private static readonly string appendage = "\nNote: the default drop sound is disabled for this block.";
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] == DependencyProperty.UnsetValue ||
values[1] == DependencyProperty.UnsetValue)
{
return string.Empty;
}
var baseText = (string)(values[0]);
var hasDisabledDefaultSound = (bool)(values[1]);
if (hasDisabledDefaultSound)
{
return $"{baseText}{appendage}";
}
else
{
return baseText;
}
}
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -210,6 +210,8 @@
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" /> <Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
<Compile Include="Converters\BooleanToBlockActionConverter.cs" /> <Compile Include="Converters\BooleanToBlockActionConverter.cs" />
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" /> <Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
<Compile Include="Converters\DisabledDefaultSoundConverter.cs" />
<Compile Include="Converters\DisabledDefaultSoundTooltipConverter.cs" />
<Compile Include="Converters\MinimapIconToCroppedBitmapConverter.cs" /> <Compile Include="Converters\MinimapIconToCroppedBitmapConverter.cs" />
<Compile Include="Converters\HashSignRemovalConverter.cs" /> <Compile Include="Converters\HashSignRemovalConverter.cs" />
<Compile Include="Converters\ItemRarityConverter.cs" /> <Compile Include="Converters\ItemRarityConverter.cs" />
@ -460,6 +462,7 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Resource Include="Resources\Icons\sound_dds.png" />
<EmbeddedResource Include="Resources\Prophecies.txt" /> <EmbeddedResource Include="Resources\Prophecies.txt" />
<EmbeddedResource Include="Resources\ItemMods.txt" /> <EmbeddedResource Include="Resources\ItemMods.txt" />
<Resource Include="Resources\loading_spinner.gif" /> <Resource Include="Resources\loading_spinner.gif" />
@ -504,7 +507,7 @@
<Resource Include="Resources\Icons\open_icon.png" /> <Resource Include="Resources\Icons\open_icon.png" />
<Resource Include="Resources\Icons\arrow_down_large_icon.png" /> <Resource Include="Resources\Icons\arrow_down_large_icon.png" />
<Resource Include="Resources\Icons\arrow_up_large_icon.png" /> <Resource Include="Resources\Icons\arrow_up_large_icon.png" />
<Resource Include="Resources\Icons\speaker_icon.png" /> <Resource Include="Resources\Icons\sound.png" />
<Resource Include="Resources\Icons\play_icon.png" /> <Resource Include="Resources\Icons\play_icon.png" />
<Resource Include="Resources\Icons\arrow_top_icon.png" /> <Resource Include="Resources\Icons\arrow_top_icon.png" />
<Resource Include="Resources\Icons\arrow_bottom_icon.png" /> <Resource Include="Resources\Icons\arrow_bottom_icon.png" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -150,6 +150,7 @@ namespace Filtration.ViewModels.DesignTime
public bool HasSound { get; } public bool HasSound { get; }
public bool HasPositionalSound { get; } public bool HasPositionalSound { get; }
public bool HasCustomSound { get; } public bool HasCustomSound { get; }
public bool HasDisabledDefaultSound { get; }
public bool HasAudioVisualBlockItems { get; } public bool HasAudioVisualBlockItems { get; }
public void RefreshBlockPreview() public void RefreshBlockPreview()
{ {

View File

@ -65,6 +65,7 @@ namespace Filtration.ViewModels
bool HasSound { get; } bool HasSound { get; }
bool HasPositionalSound { get; } bool HasPositionalSound { get; }
bool HasCustomSound { get; } bool HasCustomSound { get; }
bool HasDisabledDefaultSound { get; }
bool HasAudioVisualBlockItems { get; } bool HasAudioVisualBlockItems { get; }
void RefreshBlockPreview(); void RefreshBlockPreview();
} }
@ -287,6 +288,7 @@ namespace Filtration.ViewModels
public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>(); public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>();
public bool HasPositionalSound => Block.HasBlockItemOfType<PositionalSoundBlockItem>(); public bool HasPositionalSound => Block.HasBlockItemOfType<PositionalSoundBlockItem>();
public bool HasCustomSound => Block.HasBlockItemOfType<CustomSoundBlockItem>(); public bool HasCustomSound => Block.HasBlockItemOfType<CustomSoundBlockItem>();
public bool HasDisabledDefaultSound => Block.HasBlockItemOfType<DisableDropSoundBlockItem>();
public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any(); public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any();
@ -526,6 +528,7 @@ namespace Filtration.ViewModels
RaisePropertyChanged(nameof(HasSound)); RaisePropertyChanged(nameof(HasSound));
RaisePropertyChanged(nameof(HasPositionalSound)); RaisePropertyChanged(nameof(HasPositionalSound));
RaisePropertyChanged(nameof(HasCustomSound)); RaisePropertyChanged(nameof(HasCustomSound));
RaisePropertyChanged(nameof(HasDisabledDefaultSound));
} }
private void OnBlockItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) private void OnBlockItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)

View File

@ -11,7 +11,6 @@
<Image Source="/Filtration;component/Resources/Icons/arrow_up_large_icon.png" x:Key="MoveUpIcon" x:Shared="false" /> <Image Source="/Filtration;component/Resources/Icons/arrow_up_large_icon.png" x:Key="MoveUpIcon" x:Shared="false" />
<Image Source="/Filtration;component/Resources/Icons/arrow_bottom_icon.png" x:Key="MoveToBottomIcon" x:Shared="false" /> <Image Source="/Filtration;component/Resources/Icons/arrow_bottom_icon.png" x:Key="MoveToBottomIcon" x:Shared="false" />
<Image Source="/Filtration;component/Resources/Icons/arrow_down_large_icon.png" x:Key="MoveDownIcon" x:Shared="false" /> <Image Source="/Filtration;component/Resources/Icons/arrow_down_large_icon.png" x:Key="MoveDownIcon" x:Shared="false" />
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" x:Key="SpeakerIcon" x:Shared="false" />
<Image Source="/Filtration;component/Resources/Icons/play_icon.png" x:Key="PlayIcon" x:Shared="false" /> <Image Source="/Filtration;component/Resources/Icons/play_icon.png" x:Key="PlayIcon" x:Shared="false" />
<Image Source="/Filtration;component/Resources/Icons/about_icon.png" x:Key="AboutIcon" x:Shared="false" /> <Image Source="/Filtration;component/Resources/Icons/about_icon.png" x:Key="AboutIcon" x:Shared="false" />
<Image Source="/Filtration;component/Resources/Icons/ReplaceColors.ico" x:Key="ReplaceColorsIcon" x:Shared="false" /> <Image Source="/Filtration;component/Resources/Icons/ReplaceColors.ico" x:Key="ReplaceColorsIcon" x:Shared="false" />

View File

@ -18,6 +18,8 @@
<views:BindingProxy x:Key="Proxy" Data="{Binding}" /> <views:BindingProxy x:Key="Proxy" Data="{Binding}" />
<converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" /> <converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
<converters:MinimapIconToCroppedBitmapConverter x:Key="MinimapIconToCroppedBitmapConverter"/> <converters:MinimapIconToCroppedBitmapConverter x:Key="MinimapIconToCroppedBitmapConverter"/>
<converters:DisabledDefaultSoundConverter x:Key="DisabledDefaultSoundConverter"/>
<converters:DisabledDefaultSoundTooltipConverter x:Key="DisabledDefaultSoundTooltipConverter"/>
<Style TargetType="{x:Type ContentPresenter}" x:Key="BlockItemFadeInStyle"> <Style TargetType="{x:Type ContentPresenter}" x:Key="BlockItemFadeInStyle">
<Setter Property="LayoutTransform"> <Setter Property="LayoutTransform">
<Setter.Value> <Setter.Value>
@ -138,40 +140,55 @@
</Image.Source> </Image.Source>
</Image> </Image>
<Button Command="{Binding PlaySoundCommand}" <Button Command="{Binding PlaySoundCommand}"
Width="25" Width="32"
Height="25" Height="32"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Margin="0,0,3,0" Margin="0,0,3,0"
Visibility="{Binding HasSound, Converter={StaticResource BooleanVisibilityConverter}}" Visibility="{Binding HasSound, Converter={StaticResource BooleanVisibilityConverter}}"
Background="Transparent" Background="Transparent"
BorderBrush="Transparent" BorderBrush="Transparent">
ToolTip="Click to preview drop sound"> <Button.ToolTip>
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <MultiBinding Converter="{StaticResource DisabledDefaultSoundTooltipConverter}">
<Binding Source="Click to preview drop sound."/>
<Binding Path="HasDisabledDefaultSound"/>
</MultiBinding>
</Button.ToolTip>
<Image Source="{Binding HasDisabledDefaultSound, Converter={StaticResource DisabledDefaultSoundConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
<Button Command="{Binding PlayPositionalSoundCommand}" <Button Command="{Binding PlayPositionalSoundCommand}"
Width="25" Width="32"
Height="25" Height="32"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Margin="0,0,3,0" Margin="0,0,3,0"
Visibility="{Binding HasPositionalSound, Converter={StaticResource BooleanVisibilityConverter}}" Visibility="{Binding HasPositionalSound, Converter={StaticResource BooleanVisibilityConverter}}"
Background="Transparent" Background="Transparent"
BorderBrush="Transparent" BorderBrush="Transparent">
ToolTip="Click to preview positional drop sound"> <Button.ToolTip>
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <MultiBinding Converter="{StaticResource DisabledDefaultSoundTooltipConverter}">
<Binding Source="Click to preview positional drop sound."/>
<Binding Path="HasDisabledDefaultSound"/>
</MultiBinding>
</Button.ToolTip>
<Image Source="{Binding HasDisabledDefaultSound, Converter={StaticResource DisabledDefaultSoundConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
<Button Command="{Binding PlayCustomSoundCommand}" <Button Command="{Binding PlayCustomSoundCommand}"
Width="25" Width="32"
Height="25" Height="32"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Margin="0,0,3,0" Margin="0,0,3,0"
Visibility="{Binding HasCustomSound, Converter={StaticResource BooleanVisibilityConverter}}" Visibility="{Binding HasCustomSound, Converter={StaticResource BooleanVisibilityConverter}}"
Background="Transparent" Background="Transparent"
BorderBrush="Transparent" BorderBrush="Transparent">
ToolTip="Click to preview custom drop sound"> <Button.ToolTip>
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <MultiBinding Converter="{StaticResource DisabledDefaultSoundTooltipConverter}">
<Binding Source="Click to preview custom drop sound."/>
<Binding Path="HasDisabledDefaultSound"/>
</MultiBinding>
</Button.ToolTip>
<Image Source="{Binding HasDisabledDefaultSound, Converter={StaticResource DisabledDefaultSoundConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
<Line Y1="5" Y2="38" StrokeThickness="2" Panel.ZIndex="999" <Line Y1="5" Y2="38" StrokeThickness="2" Panel.ZIndex="999"
Stroke="{Binding DisplayEffectColor, Converter={StaticResource ColorToSolidColorBrushConverter}, Mode=OneWay}" Stroke="{Binding DisplayEffectColor, Converter={StaticResource ColorToSolidColorBrushConverter}, Mode=OneWay}"