package org.saturnclient.ui.elements; import java.util.function.IntSupplier; import java.util.function.Supplier; import org.saturnclient.ui.Element; import org.saturnclient.ui.ElementContext; import org.saturnclient.ui.RenderScope; import org.saturnclient.ui.resources.Fonts; /** * A line of text whose content, font and color are read on every frame, so it * follows state and theme changes without rebuilding the screen. */ public class Label extends Element { private final Supplier text; private final float textScale; private final IntSupplier font; private final IntSupplier color; public Label(Supplier text, float textScale, IntSupplier font, IntSupplier color) { this.text = text; this.textScale = textScale; this.font = font; this.color = color; this.height = (int) (Fonts.getHeight() * textScale); } @Override public void render(RenderScope renderScope, ElementContext ctx) { renderScope.drawText(textScale, text.get(), 0, 0, font.getAsInt(), color.getAsInt()); } }