From 6869be85da692d6092efcff2c8c43ba9254d3910 Mon Sep 17 00:00:00 2001 From: GlitchedReme <1445424285@qq.com> Date: Fri, 24 Apr 2026 17:57:39 +0800 Subject: [PATCH 1/3] feat(ergonomic): add method to create ShaderMaterial with RGB parameters and page descripition Co-authored-by: Copilot --- Scaffolding/Content/ModEventTemplate.cs | 6 +++++ Scaffolding/Content/TypeListCardPoolModel.cs | 2 ++ Utils/MaterialUtils.cs | 24 +++++++++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Scaffolding/Content/ModEventTemplate.cs b/Scaffolding/Content/ModEventTemplate.cs index 38a8a6b2..d85c2aa5 100644 --- a/Scaffolding/Content/ModEventTemplate.cs +++ b/Scaffolding/Content/ModEventTemplate.cs @@ -1,5 +1,6 @@ using Godot; using MegaCrit.Sts2.Core.Events; +using MegaCrit.Sts2.Core.Localization; using MegaCrit.Sts2.Core.Models; using STS2RitsuLib.Scaffolding.Content.Patches; @@ -94,6 +95,11 @@ protected string ModOptionKey(string pageName, string optionName) return ModOptionKey("INITIAL", optionName); } + /// + /// Gets the localized description for a page. + /// + protected LocString PageDescription(string pageName) => L10NLookup($"{Id.Entry}.pages.{pageName}.description"); + /// /// Creates a relic-grant option for a mutable relic resolved from . /// diff --git a/Scaffolding/Content/TypeListCardPoolModel.cs b/Scaffolding/Content/TypeListCardPoolModel.cs index c38da570..688e9517 100644 --- a/Scaffolding/Content/TypeListCardPoolModel.cs +++ b/Scaffolding/Content/TypeListCardPoolModel.cs @@ -11,6 +11,8 @@ namespace STS2RitsuLib.Scaffolding.Content public abstract class TypeListCardPoolModel : CardPoolModel, IModBigEnergyIconPool, IModTextEnergyIconPool, IModCardPoolFrameMaterial { + public override string Title => EnergyColorName; + /// /// Legacy hook: enumerating card types on the pool class. Prefer registering each card through /// ModContentRegistry.RegisterCard<TPool, TCard>(), CreateContentPack.Card<TPool, TCard>(), diff --git a/Utils/MaterialUtils.cs b/Utils/MaterialUtils.cs index ea614a7c..af6575cb 100644 --- a/Utils/MaterialUtils.cs +++ b/Utils/MaterialUtils.cs @@ -19,14 +19,32 @@ public static class MaterialUtils private static NoiseTexture2D VanillaDoomBarNoiseTexture => _vanillaDoomBarNoiseTexture ??= CreateVanillaDoomBarNoiseTexture(); + /// + /// Builds a ShaderMaterial using the game's HSV shader with the given RGB parameters. + /// + public static ShaderMaterial CreateRgbShaderMaterial(float r, float g, float b) + { + var shader = GameHsvShader ?? throw new InvalidOperationException($"Failed to load HSV shader ({HsvShaderPath})."); + var color = new Color(r, g, b); + + var material = new ShaderMaterial + { + Shader = shader, + }; + + material.SetShaderParameter("h", color.H); + material.SetShaderParameter("s", color.S); + material.SetShaderParameter("v", color.V); + + return material; + } + /// /// Builds a ShaderMaterial using the game's HSV shader with the given parameters. /// public static ShaderMaterial CreateHsvShaderMaterial(float h, float s, float v) { - var shader = GameHsvShader; - if (shader == null) - throw new InvalidOperationException($"Failed to load HSV shader ({HsvShaderPath})."); + var shader = GameHsvShader ?? throw new InvalidOperationException($"Failed to load HSV shader ({HsvShaderPath})."); var material = new ShaderMaterial { From f9f7246ebc0063c36189cf913ff4347148e29499 Mon Sep 17 00:00:00 2001 From: GlitchedReme <1445424285@qq.com> Date: Sun, 26 Apr 2026 14:35:27 +0800 Subject: [PATCH 2/3] remove title override --- Scaffolding/Content/TypeListCardPoolModel.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Scaffolding/Content/TypeListCardPoolModel.cs b/Scaffolding/Content/TypeListCardPoolModel.cs index 688e9517..c38da570 100644 --- a/Scaffolding/Content/TypeListCardPoolModel.cs +++ b/Scaffolding/Content/TypeListCardPoolModel.cs @@ -11,8 +11,6 @@ namespace STS2RitsuLib.Scaffolding.Content public abstract class TypeListCardPoolModel : CardPoolModel, IModBigEnergyIconPool, IModTextEnergyIconPool, IModCardPoolFrameMaterial { - public override string Title => EnergyColorName; - /// /// Legacy hook: enumerating card types on the pool class. Prefer registering each card through /// ModContentRegistry.RegisterCard<TPool, TCard>(), CreateContentPack.Card<TPool, TCard>(), From 97f2654a1bde4fd239d66a4df819072179920b47 Mon Sep 17 00:00:00 2001 From: GlitchedReme <1445424285@qq.com> Date: Sun, 26 Apr 2026 14:49:43 +0800 Subject: [PATCH 3/3] feat(material): enhance CreateRgbShaderMaterial to compute HSV parameters from RGB inputs Co-authored-by: Copilot --- Utils/MaterialUtils.cs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Utils/MaterialUtils.cs b/Utils/MaterialUtils.cs index af6575cb..257c5f07 100644 --- a/Utils/MaterialUtils.cs +++ b/Utils/MaterialUtils.cs @@ -24,19 +24,22 @@ public static class MaterialUtils /// public static ShaderMaterial CreateRgbShaderMaterial(float r, float g, float b) { - var shader = GameHsvShader ?? throw new InvalidOperationException($"Failed to load HSV shader ({HsvShaderPath})."); - var color = new Color(r, g, b); + var max = Math.Max(r, Math.Max(g, b)); + var min = Math.Min(r, Math.Min(g, b)); + var delta = max - min; - var material = new ShaderMaterial + float h = 0; + if (delta != 0) { - Shader = shader, - }; - - material.SetShaderParameter("h", color.H); - material.SetShaderParameter("s", color.S); - material.SetShaderParameter("v", color.V); - - return material; + if (max == r) h = (g - b) / delta + (g < b ? 6 : 0); + else if (max == g) h = (b - r) / delta + 2; + else h = (r - g) / delta + 4; + h /= 6; + } + + var s = (max == 0) ? 0 : (delta / max); + var v = max; + return CreateHsvShaderMaterial(h, s, v); } ///