diff --git a/.gitignore b/.gitignore index 6f1430b..a4b762a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ obj/ *.user .vs/ publish/ +.vscode/launch.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..dec90ef --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/MapExplorer.App/MapExplorer.App.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} diff --git a/src/MapExplorer.App/Converters/BlockColorConverter.cs b/src/MapExplorer.App/Converters/BlockColorConverter.cs new file mode 100644 index 0000000..aee4fde --- /dev/null +++ b/src/MapExplorer.App/Converters/BlockColorConverter.cs @@ -0,0 +1,25 @@ +using System.Globalization; +using Avalonia.Data.Converters; +using Avalonia.Media; +using RenderColors = MapExplorer.Rendering.Colors; + +namespace MapExplorer.App.Converters; + +/// Converts a block name (e.g. "minecraft:dirt") to its curated swatch color — used by the +/// edit-mode material palette/search list/recents, which bind directly to plain block-name strings +/// rather than a wrapping view-model per entry (unlike OreOption, this list is filtered/reordered +/// live by search text and MRU order, so a lightweight converter is simpler than keeping a parallel +/// ObservableCollection of wrapper objects in sync). +public sealed class BlockColorConverter : IValueConverter +{ + public static readonly BlockColorConverter Instance = new(); + + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + var rgb = RenderColors.GetBlockColor(value as string ?? "minecraft:air"); + return new SolidColorBrush(Color.FromRgb(rgb.R, rgb.G, rgb.B)); + } + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => + throw new NotSupportedException(); +} diff --git a/src/MapExplorer.App/Converters/SavingLabelConverter.cs b/src/MapExplorer.App/Converters/SavingLabelConverter.cs new file mode 100644 index 0000000..0bdab1a --- /dev/null +++ b/src/MapExplorer.App/Converters/SavingLabelConverter.cs @@ -0,0 +1,16 @@ +using System.Globalization; +using Avalonia.Data.Converters; + +namespace MapExplorer.App.Converters; + +/// Save button label: "Saving…" while EditViewModel.SaveCommand is running, "Save" otherwise. +public sealed class SavingLabelConverter : IValueConverter +{ + public static readonly SavingLabelConverter Instance = new(); + + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => + value is true ? "Saving…" : "Save"; + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => + throw new NotSupportedException(); +} diff --git a/src/MapExplorer.App/MainWindow.axaml b/src/MapExplorer.App/MainWindow.axaml index 6ad0844..8f4e6ce 100644 --- a/src/MapExplorer.App/MainWindow.axaml +++ b/src/MapExplorer.App/MainWindow.axaml @@ -40,6 +40,8 @@ IsEnabled="{Binding IsEndAvailable}" ToolTip.Tip="{Binding EndTooltip}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +