A mod's settings button now opens ModSettings: a header with the mod's icon, name, version, tags and description, a Reset button and an on/off switch, then its properties as rows, with nested namespaces as titled sections and a live preview card beside them for HUD mods. PanelScreen holds the sidebar-and-panel frame that the mod menu, mod settings and config editor share. PropertyList lays out any config as rows. The inputs share one field look: Toggle is a switch, Select steps with arrows, and the number, keybinding and color inputs are boxes. The color picker opens to the left and closes on outside clicks. Every property type now implements reset(), which was a no-op, and ModLayout keeps its settings in order instead of Map.of's. ConfigEditor moves onto the same frame and rows and drops its HUD preview, which added a new element every frame. Co-Authored-By: Claude Opus 5.5 <[email protected]>
45 lines
1.6 KiB
Java
45 lines
1.6 KiB
Java
package org.saturnclient.ui.elements;
|
|
|
|
import org.saturnclient.config.Theme;
|
|
import org.saturnclient.ui.RenderScope;
|
|
import org.saturnclient.ui.resources.Fonts;
|
|
|
|
/**
|
|
* The shared look of input fields: a faint box whose outline brightens on hover
|
|
* and turns to the accent color while focused.
|
|
*/
|
|
public final class Field {
|
|
/** Height of the fields in settings rows */
|
|
public static final int HEIGHT = 32;
|
|
public static final float TEXT_SCALE = 0.68f;
|
|
|
|
private Field() {
|
|
}
|
|
|
|
public static void drawBox(RenderScope renderScope, int width, int height, boolean hovered, boolean focused) {
|
|
int border = focused ? Theme.withAlpha(0.6f, Theme.ACCENT.value)
|
|
: hovered ? Theme.withAlpha(0.25f, Theme.FOREGROUND.value)
|
|
: Theme.withAlpha(0.1f, Theme.FOREGROUND.value);
|
|
|
|
renderScope.drawRoundedRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, 1,
|
|
Theme.withAlpha(0.06f, Theme.FOREGROUND.value), border);
|
|
}
|
|
|
|
/**
|
|
* The y at which text drawn at {@code scale} is vertically centered in a
|
|
* field of the given height.
|
|
*/
|
|
public static int textY(int height, float scale) {
|
|
return (height - (int) (Fonts.getHeight() * scale)) / 2;
|
|
}
|
|
|
|
/**
|
|
* Draws {@code text} centered in a field of the given size.
|
|
*/
|
|
public static void drawCenteredText(RenderScope renderScope, String text, int width, int height, int font,
|
|
int color) {
|
|
int x = (width - (int) (Fonts.getWidth(text, font) * TEXT_SCALE)) / 2;
|
|
renderScope.drawText(TEXT_SCALE, text, x, textY(height, TEXT_SCALE), font, color);
|
|
}
|
|
}
|