Describe every setting under its name
Properties can carry a one-line description, set with NamedProperty.description for mods, a ConfigManager.property overload for the client's config, and a helper in ModLayout. PropertyList rows show it under the setting's name in muted text. Every mod, HUD layout, general, UI style and animation setting now has one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -77,7 +77,7 @@ public final class PropertyList {
|
||||
continue;
|
||||
}
|
||||
|
||||
scroll.draw(new Row(name, width, control.width).position(0, y));
|
||||
scroll.draw(new Row(name, prop.description, width, control.width).position(0, y));
|
||||
controls.add(control.position(width - control.width, y + (ROW_HEIGHT - control.height) / 2));
|
||||
y += ROW_HEIGHT;
|
||||
}
|
||||
@@ -118,17 +118,22 @@ public final class PropertyList {
|
||||
}
|
||||
|
||||
/**
|
||||
* A row's name and the line under it. The control is a separate element on
|
||||
* top, so it gets the clicks and key presses.
|
||||
* A row's name, its description under it, and the line below the row. The
|
||||
* control is a separate element on top, so it gets the clicks and key
|
||||
* presses.
|
||||
*/
|
||||
private static class Row extends Element {
|
||||
private static final float NAME_SCALE = 0.74f;
|
||||
private static final float DESCRIPTION_SCALE = 0.62f;
|
||||
private static final int LINE_GAP = 4;
|
||||
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final int controlWidth;
|
||||
|
||||
Row(String name, int width, int controlWidth) {
|
||||
Row(String name, String description, int width, int controlWidth) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.controlWidth = controlWidth;
|
||||
this.width = width;
|
||||
this.height = ROW_HEIGHT;
|
||||
@@ -136,10 +141,24 @@ public final class PropertyList {
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
int nameY = (height - (int) (Fonts.getHeight() * NAME_SCALE)) / 2;
|
||||
String text = Fonts.ellipsize(name, Theme.FONT.value, NAME_SCALE, width - controlWidth - 16);
|
||||
int textWidth = width - controlWidth - 16;
|
||||
int nameHeight = (int) (Fonts.getHeight() * NAME_SCALE);
|
||||
int descriptionHeight = (int) (Fonts.getHeight() * DESCRIPTION_SCALE);
|
||||
boolean described = !description.isEmpty();
|
||||
|
||||
int blockHeight = described ? nameHeight + LINE_GAP + descriptionHeight : nameHeight;
|
||||
int nameY = (height - blockHeight) / 2;
|
||||
|
||||
renderScope.drawText(NAME_SCALE, Fonts.ellipsize(name, Theme.FONT.value, NAME_SCALE, textWidth),
|
||||
0, nameY, Theme.FONT.value, Theme.FOREGROUND.value);
|
||||
|
||||
if (described) {
|
||||
int font = Theme.getBodyFont();
|
||||
renderScope.drawText(DESCRIPTION_SCALE,
|
||||
Fonts.ellipsize(description, font, DESCRIPTION_SCALE, textWidth),
|
||||
0, nameY + nameHeight + LINE_GAP, font, Theme.getMutedFg());
|
||||
}
|
||||
|
||||
renderScope.drawText(NAME_SCALE, text, 0, nameY, Theme.FONT.value, Theme.FOREGROUND.value);
|
||||
renderScope.drawRectangle(0, height - 1, width, 1, Theme.withAlpha(0.06f, Theme.FOREGROUND.value));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user