From ec6754a5d2b2dca00a749faa89ad3cacdcc6d9e1 Mon Sep 17 00:00:00 2001
From: ds5678 <49847914+ds5678@users.noreply.github.com>
Date: Thu, 26 Feb 2026 17:28:31 -0800
Subject: [PATCH] Replace tuple with record struct in color generation
---
.../Program.cs | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/AssetRipper.TextureDecoder.ColorGenerator/Program.cs b/AssetRipper.TextureDecoder.ColorGenerator/Program.cs
index 0a272ab..02a043b 100644
--- a/AssetRipper.TextureDecoder.ColorGenerator/Program.cs
+++ b/AssetRipper.TextureDecoder.ColorGenerator/Program.cs
@@ -13,18 +13,23 @@ internal static partial class Program
private const string FormatsNamespace = "AssetRipper.TextureDecoder.Rgb.Formats";
private const string FormatsFolder = "../../../../AssetRipper.TextureDecoder/Rgb/Formats/";
- ///
- /// Name, Type, Red, Blue, Green, Alpha, Fully Utilized
- ///
- private static readonly List<(string, Type, bool, bool, bool, bool, bool)> CustomColors = new()
+ private readonly record struct CustomColorDetails(string Name, Type Type, bool HasRed, bool HasGreen, bool HasBlue, bool HasAlpha, bool FullyUtilized)
{
+ public static implicit operator CustomColorDetails((string, Type, bool, bool, bool, bool, bool) details)
+ {
+ return new CustomColorDetails(details.Item1, details.Item2, details.Item3, details.Item4, details.Item5, details.Item6, details.Item7);
+ }
+ }
+
+ private static readonly CustomColorDetails[] CustomColors =
+ [
( "ColorARGB16", typeof(byte), true, true, true, true, false ),
( "ColorRGB16", typeof(byte), true, true, true, false, false ),
( "ColorRGB9e5", typeof(double), true, true, true, false, false ),
( "ColorRGBA16", typeof(byte), true, true, true, true, false ),
- };
+ ];
- private static readonly List GenericColors =
+ private static readonly string[] GenericColors =
[
"ColorR",
"ColorRG",
@@ -38,7 +43,7 @@ internal static partial class Program
static void Main()
{
- foreach (var customColor in CustomColors)
+ foreach (CustomColorDetails customColor in CustomColors)
{
WriteCustomColor(customColor);
}
@@ -54,7 +59,7 @@ internal static partial class Program
Console.WriteLine("Done!");
}
- private static void WriteCustomColor((string, Type, bool, bool, bool, bool, bool) details)
+ private static void WriteCustomColor(CustomColorDetails details)
{
(string name, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha, bool fullyUtilized) = details;
Console.WriteLine(name);