TextOverlay
com.jsmacrosce.jsmacros.client.gui.overlays.TextOverlay
A WagYourGUI text-message overlay with a confirmation button that closes it.
The constructor stores the supplied text component; open the overlay through its parent to initialize it.
js
function showText(parent, font, text) {
const TextOverlay = Java.type('com.jsmacrosce.jsmacros.client.gui.overlays.TextOverlay');
const overlay = new TextOverlay(10, 10, 180, 80, font, parent, text);
overlay.centered = false;
parent.openOverlay(overlay);
}Here parent, font, and text are caller-supplied overlay parent, native font, and native text component.
Constructors
new TextOverlay
new TextOverlay(int x, int y, int width, int height, Font textRenderer, IOverlayParent parent, Component text)#Stores the overlay bounds, font, parent, and text; it does not open or initialize the overlay.
Parameters:
x: left edge of the overlay in screen GUI coordinatesy: top edge of the overlay in screen GUI coordinateswidth: overlay widthheight: overlay heighttextRenderer: non-null font used to measure and draw the textparent: non-null overlay host used to register widgets and close this overlaytext: non-null native text component to display
Fields
centered
centered: boolean#Whether to horizontally offset the text toward the center of the overlay; defaults to
true. The offset uses the full component's measured width, is clamped to the left text inset, and does not center wrapped lines or affect wrapping.Methods
extractRenderState
extractRenderState(GuiGraphicsExtractor drawContext, int mouseX, int mouseY, float delta): void#Submits the overlay background and wrapped text, then forwards the hook to its buttons and any child overlay. This method does not consult the inherited visibility flag. When
centered is true, the text's horizontal offset is based on the full component width and clamped to the left inset.Parameters:
drawContext: graphics context receiving the overlay contentmouseX: current mouse x-coordinate, forwarded to widgets and a child overlaymouseY: current mouse y-coordinate, forwarded to widgets and a child overlaydelta: frame value forwarded to widgets and a child overlay
init
init(): void#Clears this overlay's tracked buttons and registers a confirmation button with its parent; the button closes this overlay. Reinitializing clears the local tracking list but does not unregister buttons previously registered with the parent.