Make the minimap icons transparent.

This commit is contained in:
GlenCFL 2018-09-06 20:01:16 -04:00
parent b31ce1d843
commit 910b2b8c7f
18 changed files with 173 additions and 173 deletions

View File

@ -1,17 +1,23 @@
using System.ComponentModel;
namespace Filtration.ObjectModel.Enums
{
public enum IconColor
{
/// <summary>
/// Each of the colors supported by the MinimapIcon block rule.
/// </summary>
/// <remarks>
/// The ordering here should match the ordering of the colors within the source image.
/// </remarks>
public enum IconColor
{
[Description("Red")]
[Description("Blue")]
Blue,
[Description("Green")]
Green,
[Description("Brown")]
Brown,
[Description("Red")]
Red,
[Description("Green")]
Green,
[Description("Blue")]
Blue,
[Description("Brown")]
Brown,
[Description("White")]
White,
[Description("Yellow")]

View File

@ -1,8 +1,14 @@
using System.ComponentModel;
namespace Filtration.ObjectModel.Enums
{
public enum IconShape
{
/// <summary>
/// Each of the shapes supported by the MinimapIcon block rule.
/// </summary>
/// <remarks>
/// The ordering here should match the ordering of the shapes within the source image.
/// </remarks>
public enum IconShape
{
[Description("Circle")]
Circle,

View File

@ -1,8 +1,14 @@
using System.ComponentModel;
namespace Filtration.ObjectModel.Enums
{
public enum IconSize
{
/// <summary>
/// Each of the sizes supported by the MinimapIcon block rule.
/// </summary>
/// <remarks>
/// The ordering here should match the ordering of the sizes within the source image.
/// </remarks>
public enum IconSize
{
[Description("Largest")]
Largest,

View File

@ -1,37 +0,0 @@
using Filtration.ObjectModel.Enums;
using System;
using System.Globalization;
using System.Windows.Data;
namespace Filtration.Converters
{
internal class IconShapeToSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var iconShape = (IconShape)(int)value;
switch (iconShape)
{
case IconShape.Circle:
return "/Filtration;component/Resources/DropIcons/Circle.png";
case IconShape.Diamond:
return "/Filtration;component/Resources/DropIcons/Diamond.png";
case IconShape.Hexagon:
return "/Filtration;component/Resources/DropIcons/Hexagon.png";
case IconShape.Square:
return "/Filtration;component/Resources/DropIcons/Square.png";
case IconShape.Star:
return "/Filtration;component/Resources/DropIcons/Star.png";
case IconShape.Triangle:
return "/Filtration;component/Resources/DropIcons/Triangle.png";
}
return "/Filtration;component/Resources/DropIcons/NoIcon.png";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using Filtration.ObjectModel.Enums;
namespace Filtration.Converters
{
internal class MinimapIconToCroppedBitmapConverter : IMultiValueConverter
{
private static readonly int cellHeight = 64;
private static readonly int cellWidth = 64;
private static readonly int gridWidth = 14;
private static readonly int startColumn = 4;
private static readonly int startRow = 3;
private static readonly int emptyColumn = 2;
private static readonly int emptyRow = 11;
private static readonly int colorCount = 6;
private static readonly int shapeCount = 6;
private static readonly int sizeCount = 3;
private static readonly Uri uri;
private static readonly CroppedBitmap empty;
private static readonly List<CroppedBitmap> bitmaps;
static MinimapIconToCroppedBitmapConverter()
{
uri = new Uri("pack://application:,,,/Filtration;component/Resources/minimap_icons.png", UriKind.Absolute);
var sourceImage = new BitmapImage(uri);
var emptyRect = new Int32Rect
{
Width = cellWidth,
Height = cellHeight,
X = emptyColumn * cellWidth,
Y = emptyRow * cellHeight
};
empty = new CroppedBitmap(new BitmapImage(uri), emptyRect);
bitmaps = new List<CroppedBitmap>(shapeCount * colorCount * sizeCount);
var row = startRow;
var column = startColumn;
for (var i = 0; i < shapeCount; i++) {
for (var j = 0; j < colorCount; j++) {
for (var k = 0; k < sizeCount; k++) {
if (column == gridWidth) {
column = 0;
row++;
}
var bitmapRect = new Int32Rect
{
Width = cellWidth,
Height = cellHeight,
X = column * cellWidth,
Y = row * cellWidth
};
bitmaps.Add(new CroppedBitmap(sourceImage, bitmapRect));
column++;
}
}
}
}
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] == DependencyProperty.UnsetValue ||
values[1] == DependencyProperty.UnsetValue ||
values[2] == DependencyProperty.UnsetValue) {
return empty;
}
var iconSize = (int)(values[0]);
var iconColor = (int)(values[1]);
var iconShape = (int)(values[2]);
switch ((IconSize) iconSize) {
case IconSize.Largest:
case IconSize.Medium:
case IconSize.Small:
break;
default:
return empty;
}
switch ((IconColor) iconColor) {
case IconColor.Blue:
case IconColor.Green:
case IconColor.Brown:
case IconColor.Red:
case IconColor.White:
case IconColor.Yellow:
break;
default:
return empty;
}
switch ((IconShape) iconShape) {
case IconShape.Circle:
case IconShape.Diamond:
case IconShape.Hexagon:
case IconShape.Square:
case IconShape.Star:
case IconShape.Triangle:
break;
default:
return empty;
}
var shapeOffset = iconShape * (sizeCount * colorCount);
var colorOffset = iconColor * sizeCount;
var iconIndex = shapeOffset + colorOffset + iconSize;
if (iconIndex >= bitmaps.Count) {
return empty;
} else {
return bitmaps[iconIndex];
}
}
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,38 +0,0 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Filtration.Converters
{
internal class SizeColorToRectConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] == DependencyProperty.UnsetValue ||
values[1] == DependencyProperty.UnsetValue)
return new Rect(0, 0, 0, 0);
var size = (int)(values[0]);
var color = (int)(values[1]);
if (size < 0 || color < 0)
return new Rect(0, 0, 0, 0);
var cropArea = new Rect
{
Width = 64,
Height = 64,
X = 0 + size * 64,
Y = 0 + color * 64
};
return cropArea;
}
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -167,9 +167,8 @@
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
<Compile Include="Converters\BooleanToBlockActionConverter.cs" />
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
<Compile Include="Converters\SizeColorToRectConverter.cs" />
<Compile Include="Converters\MinimapIconToCroppedBitmapConverter.cs" />
<Compile Include="Converters\HashSignRemovalConverter.cs" />
<Compile Include="Converters\IconShapeToSourceConverter.cs" />
<Compile Include="Converters\ItemRarityConverter.cs" />
<Compile Include="Converters\TreeViewMarginConverter.cs" />
<Compile Include="Models\UpdateData.cs" />
@ -190,9 +189,6 @@
<Compile Include="UserControls\EditableListBoxControl.xaml.cs">
<DependentUpon>EditableListBoxControl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\ImageComboBoxControl.xaml.cs">
<DependentUpon>ImageComboBoxControl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\ItemPreviewControl.xaml.cs">
<DependentUpon>ItemPreviewControl.xaml</DependentUpon>
</Compile>
@ -233,10 +229,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControls\ImageComboBoxControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControls\ThemeComponentSelectionControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -545,13 +537,7 @@
</None>
<Resource Include="Resources\Icons\redo_icon.png" />
<Resource Include="Resources\Icons\undo_icon.png" />
<Resource Include="Resources\DropIcons\NoIcon.png" />
<Resource Include="Resources\DropIcons\Circle.png" />
<Resource Include="Resources\DropIcons\Diamond.png" />
<Resource Include="Resources\DropIcons\Hexagon.png" />
<Resource Include="Resources\DropIcons\Square.png" />
<Resource Include="Resources\DropIcons\Star.png" />
<Resource Include="Resources\DropIcons\Triangle.png" />
<Resource Include="Resources\minimap_icons.png" />
<Content Include="Resources\ItemBaseTypes.txt" />
<Content Include="Resources\ItemClasses.txt" />
</ItemGroup>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 KiB

View File

@ -1,26 +0,0 @@
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Filtration.UserControls"
xmlns:Converters="clr-namespace:Filtration.Converters" x:Class="Filtration.UserControls.ImageComboBoxControl"
mc:Ignorable="d">
<UserControl.Resources>
<Converters:SizeColorToRectConverter x:Key="DropIconConverter"/>
</UserControl.Resources>
<Grid>
<ComboBox ItemsSource="{Binding DataContext.IconsAvailable, ElementName=BlockItemContentControl}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image MaxWidth="20" MaxHeight="20" Source="{Binding Converter={StaticResource DropIconConverter}, Mode=OneWay}" />
<Label Content="{Binding}" VerticalAlignment="Stretch"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</UserControl>

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Filtration.UserControls
{
/// <summary>
/// Interaction logic for ImageComboBoxControl.xaml
/// </summary>
public partial class ImageComboBoxControl : UserControl
{
public ImageComboBoxControl()
{
InitializeComponent();
}
}
}

View File

@ -18,8 +18,7 @@
<ResourceDictionary>
<views:BindingProxy x:Key="Proxy" Data="{Binding}" />
<converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
<converters:IconShapeToSourceConverter x:Key="IconShapeToSourceConverter"/>
<converters:SizeColorToRectConverter x:Key="SizeColorToRectConverter"/>
<converters:MinimapIconToCroppedBitmapConverter x:Key="MinimapIconToCroppedBitmapConverter"/>
<Style TargetType="{x:Type ContentPresenter}" x:Key="BlockItemFadeInStyle">
<Setter Property="LayoutTransform">
<Setter.Value>
@ -132,19 +131,15 @@
<!-- Item Preview Box -->
<WrapPanel Grid.Row="0" Grid.Column="2" VerticalAlignment="Center">
<Rectangle Height="40" Width="40" Margin="0,0,10,0">
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding DisplayIconShape, Converter={StaticResource IconShapeToSourceConverter}, Mode=OneWay}"
ViewboxUnits="Absolute" Stretch="Fill">
<ImageBrush.Viewbox>
<MultiBinding Converter="{StaticResource SizeColorToRectConverter}">
<Binding Path="DisplayIconSize"/>
<Binding Path="DisplayIconColor"/>
</MultiBinding>
</ImageBrush.Viewbox>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
<Image Height="40" Width="40" Margin="0,0,10,0" Stretch="Fill">
<Image.Source>
<MultiBinding Converter="{StaticResource MinimapIconToCroppedBitmapConverter}">
<Binding Path="DisplayIconSize"/>
<Binding Path="DisplayIconColor"/>
<Binding Path="DisplayIconShape"/>
</MultiBinding>
</Image.Source>
</Image>
<Button Command="{Binding PlaySoundCommand}"
Width="25"
Height="25"