From 8a304b279c9cfc54c0f559d1ec0f4342765a4424 Mon Sep 17 00:00:00 2001
From: flibber-hk <76987839+flibber-hk@users.noreply.github.com>
Date: Mon, 27 Apr 2026 21:48:05 +0100
Subject: [PATCH 1/4] Add option to localize enum description
---
Silksong.ModMenu/Models/Attributes.cs | 19 ++++++++++
.../Plugin/MenuElementGenerators.cs | 38 +++++++++++++++----
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/Silksong.ModMenu/Models/Attributes.cs b/Silksong.ModMenu/Models/Attributes.cs
index cf42398..a6dab46 100644
--- a/Silksong.ModMenu/Models/Attributes.cs
+++ b/Silksong.ModMenu/Models/Attributes.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Reflection;
+using Silksong.ModMenu.Plugin;
namespace Silksong.ModMenu.Models;
@@ -31,3 +32,21 @@ internal static bool IgnoreForModMenu(this MemberInfo self) =>
|| self.GetCustomAttributes(true)
.Any(attr => attr.GetType().Name == nameof(ModMenuIgnoreAttribute));
}
+
+///
+/// Attribute added to an enum member to indicate how its description should be localized,
+/// for use in .
+///
+[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
+public class LocalizedDescriptionAttribute(string sheetTitle, string key) : Attribute
+{
+ ///
+ /// The sheet title for the localized description.
+ ///
+ public string SheetTitle => sheetTitle;
+
+ ///
+ /// The key for the localized description.
+ ///
+ public string Key => key;
+}
diff --git a/Silksong.ModMenu/Plugin/MenuElementGenerators.cs b/Silksong.ModMenu/Plugin/MenuElementGenerators.cs
index 9b1b8e8..8b206ec 100644
--- a/Silksong.ModMenu/Plugin/MenuElementGenerators.cs
+++ b/Silksong.ModMenu/Plugin/MenuElementGenerators.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -15,7 +16,7 @@ namespace Silksong.ModMenu.Plugin;
public static class MenuElementGenerators
{
///
- /// Returns a Generator that creates a choice element with a description below the option value.
+ /// Returns a generator that creates a choice element with a description below the option value.
///
/// The description will be taken from the attributes on the enum members.
///
@@ -43,9 +44,9 @@ out ListChoiceModel