From aa8a5681e82e3262a629492bdd0803444d8ec9c1 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Fri, 11 Nov 2022 22:31:25 +0400 Subject: Disabled sorting for predefined palettes --- NesTiler/Config.cs | 4 ++-- NesTiler/NesTiler.csproj | 6 +++--- NesTiler/Palette.cs | 9 ++++++--- NesTiler/Program.cs | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/NesTiler/Config.cs b/NesTiler/Config.cs index 9c1c8f4..6e03d98 100644 --- a/NesTiler/Config.cs +++ b/NesTiler/Config.cs @@ -8,7 +8,7 @@ using System.Text.RegularExpressions; namespace com.clusterrr.Famicom.NesTiler { - class Config + internal class Config { public const string DEFAULT_COLORS_FILE = @"nestiler-colors.json"; @@ -167,7 +167,7 @@ namespace com.clusterrr.Famicom.NesTiler throw new ArgumentException($"{c} - invalid color.", param); } }); - config.FixedPalettes[indexNum] = new Palette(colors); + config.FixedPalettes[indexNum] = new Palette(colors, nosort: true); } i++; break; diff --git a/NesTiler/NesTiler.csproj b/NesTiler/NesTiler.csproj index cd94dcd..1f738fb 100644 --- a/NesTiler/NesTiler.csproj +++ b/NesTiler/NesTiler.csproj @@ -61,9 +61,9 @@ embedded - 1.0.0.0 - 1.0.0.0 - 1.0.0 + 1.1.0 + 1.1.0 + 1.1.0 https://github.com/ClusterM/nestiler Tool for converting pictures into NES format: generating pattern tables, palettes, name tables Alexey "Cluster" Avdyukhin diff --git a/NesTiler/Palette.cs b/NesTiler/Palette.cs index 203a9de..8fad30c 100644 --- a/NesTiler/Palette.cs +++ b/NesTiler/Palette.cs @@ -64,9 +64,12 @@ namespace com.clusterrr.Famicom.NesTiler colors = colorsCandidates.Take(3).OrderBy(kv => kv.Key.ToArgb()).Select(kv => kv.Key).ToArray(); } - public Palette(IEnumerable colors) + public Palette(IEnumerable colors, bool nosort = false) { - this.colors = colors.OrderBy(c => c.ToArgb()).Take(3).ToArray(); + if (!nosort) + this.colors = colors.OrderBy(c => c.ToArgb()).Take(3).ToArray(); + else + this.colors = colors.Take(3).ToArray(); } public double GetTileDelta(FastBitmap image, int leftX, int topY, int width, int height, SKColor bgColor) @@ -126,7 +129,7 @@ namespace com.clusterrr.Famicom.NesTiler return GetEnumerator(); } - public override string ToString() => string.Join(", ", colors.Select(c => ColorTranslator.ToHtml(c.ToColor())).OrderBy(c => c)); + public override string ToString() => string.Join(", ", colors.Select(c => ColorTranslator.ToHtml(c.ToColor()))); public override int GetHashCode() => (int)((this[1]?.ToArgb() ?? 0) + ((this[2]?.ToArgb() ?? 0) << 4) + ((this[3]?.ToArgb() ?? 0) << 8)); } diff --git a/NesTiler/Program.cs b/NesTiler/Program.cs index a05e68e..1ec2578 100644 --- a/NesTiler/Program.cs +++ b/NesTiler/Program.cs @@ -99,7 +99,7 @@ namespace com.clusterrr.Famicom.NesTiler var colorsInPalette = c.FixedPalettes[i]!.ToArray(); for (int j = 0; j < colorsInPalette.Length; j++) colorsInPalette[j] = nesColors.FindSimilarColor(colorsInPalette[j]); - c.FixedPalettes[i] = new Palette(colorsInPalette); + c.FixedPalettes[i] = new Palette(colorsInPalette, nosort: true); } // Loading images -- cgit v1.2.3