ConfirmOverlay
com.jsmacrosce.wagyourgui.overlays.ConfirmOverlay
A WagYourGUI message overlay with Confirm and Cancel buttons. Confirm passes this overlay to the optional callback,
then closes it after a normal callback return; it also closes when no callback was supplied. Cancel closes without invoking the callback. The factory takes a caller-supplied IOverlayParent, native Font,
native Component message and JavaScript callback:
js
function showConfirm(parent, font, message, onConfirm) {
const ConfirmOverlay = Java.type('com.jsmacrosce.wagyourgui.overlays.ConfirmOverlay');
const overlay = new ConfirmOverlay(10, 10, 240, 100, font, message, parent, JavaWrapper.methodToJava(onConfirm));
parent.openOverlay(overlay);
return overlay;
}Constructors
new ConfirmOverlay
new ConfirmOverlay(int x, int y, int width, int height, Font textRenderer, Component message, IOverlayParent parent, Consumer<ConfirmOverlay> accept)#Stores the overlay configuration and computes the cached message layout immediately, with centered message alignment. This does not open the overlay or register its buttons; opening through the parent initializes them.
Parameters:
x: left edge in GUI coordinatesy: top edge in GUI coordinateswidth: overlay width in GUI coordinatesheight: overlay height in GUI coordinatestextRenderer: non-null font used to measure and draw the messagemessage: non-null message to split into cached display linesparent: non-null overlay hostaccept: optional callback receiving this overlay when Confirm is pressed, before it closes
new ConfirmOverlay(int x, int y, int width, int height, boolean hcenter, Font textRenderer, Component message, IOverlayParent parent, Consumer<ConfirmOverlay> accept)#Stores the overlay configuration and computes the cached message layout immediately, then sets the specified alignment. This does not open the overlay or register its buttons; opening through the parent initializes them.
Parameters:
x: left edge in GUI coordinatesy: top edge in GUI coordinateswidth: overlay width in GUI coordinatesheight: overlay height in GUI coordinateshcenter:trueto center each line;falseto place lines atx + 3textRenderer: non-null font used to measure and draw the messagemessage: non-null message to split into cached display linesparent: non-null overlay hostaccept: optional callback receiving this overlay when Confirm is pressed, before it closes
Fields
hcenter
hcenter: boolean#Whether each cached message line is horizontally centered; defaults to
true, while false places it at x + 3. Changing this affects placement on the next hook but does not rewrap the lines or recompute the cached vertical layout.Methods
extractRenderState
extractRenderState(GuiGraphicsExtractor drawContext, int mouseX, int mouseY, float delta): void#Submits the background, bottom separator and cached message lines, then forwards the hook to registered widgets and a child overlay. Placement reads the current position, width and alignment, but wrapping, selected line count and vertical offset remain cached until
setMessage is called. Lines start at y + 2 + vcenter and advance by the font line height. This method does not consult the inherited visibility flag.Parameters:
drawContext: graphics context receiving the drawing operationsmouseX: mouse x-coordinate in GUI coordinates, forwarded to widgets and child overlaymouseY: mouse y-coordinate in GUI coordinates, forwarded to widgets and child overlaydelta: frame value forwarded to widgets and child overlay
init
init(): void#Clears local button tracking and registers fresh Cancel and Confirm buttons with the host. This does not reset the cached message or alignment; repeated initialization does not remove earlier button registrations from the parent.
setMessage
Replaces the cached wrapped lines using the current font and width minus six, caching the line count and vertical offset. Only the leading lines selected by the current height are submitted. A nonempty split selects at least one line, even in a short overlay; this does not guarantee that the selected lines fit. Call again after changing bounds or font when the cached wrapping or vertical placement should be refreshed.
Parameters:
message: non-null message to wrap and display