From bb092820969111308f3dd822669582bdbb415cc8 Mon Sep 17 00:00:00 2001 From: Skipcast Date: Sun, 30 Jan 2022 15:21:08 +0100 Subject: [PATCH] Added optional description text to config menu fields --- JKMP.Core/Configuration/Attributes/Attributes.cs | 5 +++++ JKMP.Core/Configuration/UI/ReflectedConfigMenu.cs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/JKMP.Core/Configuration/Attributes/Attributes.cs b/JKMP.Core/Configuration/Attributes/Attributes.cs index 3eaded8..504dba2 100644 --- a/JKMP.Core/Configuration/Attributes/Attributes.cs +++ b/JKMP.Core/Configuration/Attributes/Attributes.cs @@ -38,6 +38,11 @@ public abstract class SettingsOptionAttribute : Attribute /// The name of the property. If null the property name will be used. /// public string? Name { get; set; } + + /// + /// The description of the property. Only visible if value is not null or empty. + /// + public string? Description { get; set; } } /// diff --git a/JKMP.Core/Configuration/UI/ReflectedConfigMenu.cs b/JKMP.Core/Configuration/UI/ReflectedConfigMenu.cs index f74cf31..9516b1e 100644 --- a/JKMP.Core/Configuration/UI/ReflectedConfigMenu.cs +++ b/JKMP.Core/Configuration/UI/ReflectedConfigMenu.cs @@ -107,6 +107,12 @@ private void CreateFields(AdvancedMenuSelector menu, List drawables) } }; + // Create the description text if it's not empty/null + if (!string.IsNullOrEmpty(optionAttribute.Description)) + { + menu.AddChild(new TextInfo(optionAttribute.Description, Color.Gray, JKContentManager.Font.MenuFontSmall)); + } + string fieldName = optionAttribute.Name ?? property.Name; // Create the field