Skip to content

Commit

Permalink
Added optional description text to config menu fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Skippeh committed Jan 30, 2022
1 parent 464eae1 commit bb09282
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions JKMP.Core/Configuration/Attributes/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public abstract class SettingsOptionAttribute : Attribute
/// The name of the property. If null the property name will be used.
/// </summary>
public string? Name { get; set; }

/// <summary>
/// The description of the property. Only visible if value is not null or empty.
/// </summary>
public string? Description { get; set; }
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions JKMP.Core/Configuration/UI/ReflectedConfigMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ private void CreateFields(AdvancedMenuSelector menu, List<IDrawable> 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
Expand Down

0 comments on commit bb09282

Please sign in to comment.