AbstractWidgetBuilder
com.jsmacrosce.jsmacros.client.api.helper.screen.AbstractWidgetBuilder
Base builder for screen widgets, storing their position, size, label, state flags,
alpha, and z-index until build() creates and adds a widget to its screen.
Builders are obtained from their screen and setters return the builder for chaining.
Opening a screen clears elements added before its init callback, so build widgets inside the callback passed to IScreen.setOnInit.
Defaults are position and width zero, height 20, empty label, active and visible,
alpha 1.0, and z-index zero. Subclasses may constrain properties; for example,
button builders fix height at 20 and text-field builders use the screen font.
const screen = Hud.createScreen("a screen", true);
screen.setOnInit(JavaWrapper.methodToJava(function (self) {
// the shared half on its own: a label, a box and the flags
self.buttonBuilder()
.pos(10, 20)
.size(100, 20)
.message("a button")
.visible(true)
.active(true)
.alpha(0.8)
.zIndex(5)
.build();
}));
Hud.openScreen(screen);Type Parameters
B: the builder class itself, so a chain keeps its own typeT: the kind of game widget this builder makesU: the kind of widget helper this builder hands back
Methods
active
active(boolean active): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
active: whether the widget should be active or not
alpha
alpha(double alpha): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#0.0 (transparent) through 1.0 (opaque).Parameters:
alpha: the alpha value of the widget
build
getAlpha
0.0 (transparent) to 1.0 (opaque); the default is 1.0.getHeight
getMessage
getParentHeight
getParentWidth
getScaledHeight
getScaledLeft
getScaledTop
getScaledWidth
getWidth
getX
getY
getZIndex
height
height(int height): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
height: the height of the widget
isActive
true.true if the widget is active, false otherwise.isVisible
true. The built widget has no corresponding visibility reader.true if the widget is visible, false otherwise.message
message(String message): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#null leaves the label unchanged.Parameters:
message: the message of the widget
message(TextHelper message): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#null leaves the label unchanged.Parameters:
message: the message of the widget
moveTo
moveTo(int x, int y): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
x: the new x positiony: the new y position
pos
pos(int x, int y): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
x: the x position of the widgety: the y position of the widget
size
size(int width, int height): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
width: the width of the widgetheight: the height of the widget
visible
visible(boolean visible): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#active, this controls drawing. The value is applied during build() and has no built-widget setter.Parameters:
visible: whether the widget should be visible or not
width
width(int width): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
width: the width of the widget
x
x(int x): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
x: the x position of the widget
y
y(int y): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
y: the y position of the widget
zIndex
zIndex(int zIndex): B extends AbstractWidgetBuilder<B, T extends AbstractWidget, U extends ClickableWidgetHelper<U, T extends AbstractWidget>>Since1.8.4#Parameters:
zIndex: the z-index of the widget