-
-
Notifications
You must be signed in to change notification settings - Fork 39
Screen Class
The Screen Class, methods are as follows:
Example: new Screen("Title", dirtBackground)
Initialize, to call this it is easiest to refer to Hud.
put a js function here for initializing elements. Example:
scr.onInit = (screen_obj) => {
screen_obj.addButton(Math.floor(screen_obj.getWidth() / 2 - 100), Math.floor(screen_obj.getHeight() / 2 - 10), 200, 10, "Hello, World!", () => {
chat.log("Hello, World!");
});
}
when the screen closes, this should be triggered. Example:
scr.onClose = (scr_obj) => {
chat.log("screen closed");
}
put a js function here. Example:
scr.onMouseDown = (pos2D, m_btn) => {
chat.log(`${pos2D.x} ${pos2D.y} ${m_btn}`);
}
put a js function here. Example:
scr.onMouseDown = (vec2D, m_btn) => {
chat.log(`x:${vec2D.x1} y:${vec2D.y1} dx:${vec2d.x2} dy:${vec2d.y2} ${m_btn}`);
}
put a js function here. Example:
scr.onMouseUp = (pos2D, m_btn) => {
chat.log(`${pos2D.x} ${pos2D.y} ${m_btn}`);
}
put a js function here. Example:
scr.onKeyPressed = (keycode, modifiers) => {
chat.log(`${keycode} ${modifiers}`);
}
put a js function here. Example:
scr.onScroll = (pos2D, scrollAmmt) => {
chat.log(`${pos2D.x} ${pos2D.y} ${scrollAmmt}`);
}
Example: scr.getWidth()
returns the internal width of the window.
Example: scr.getHeight()
returns the internal height of the window.
Example: scr.getTitleText()
returns the title of the window.
Example: scr.getButtonWidgets()
returns an ArrayList
of ButtonWidgetHelpers.
Example: scr.getButtonWidgets()
returns an ArrayList
of TextFieldWidgetHelpers.
Example: scr.getTexts()
returns an ArrayList
of RenderCommon$text elements.
Example: overlay.getRects()
returns an ArrayList
of RenderCommon$rect elements.
Example: overlay.getImages()
returns an ArrayList
of RenderCommon$image elements.
Example: overlay.getItems()
returns an ArrayList
of RenderCommon$item elements.
Example: scr.addButton(x, y, width, height, "TextOnButton", (ButtonWidgetHelper, Screen) => {})
returns the generated ButtonWidgetHelper.
Example: scr.removeButton(btn)
removes a ButtonWidgetHelper from the screen.
Example: scr.addTextInput(x, y, width, height, "Name", (ChangedValue, Screen) => {})
returns the generated TextFieldWidgetHelper.
Example: scr.removeTextInput(inp)
removes a TextFieldWidgetHelper from the screen.
Example: overlay.addText("Text", x, y, rgbHex, shadow, scale, rotation)
-
scale
/rotation
optionals were added in 1.2.6+
returns the RenderCommon$text object.
Example: scr.removeText(t)
removes a RenderCommon$text element from the screen.
Example: overlay.addRect(x1, y1, x2, y2, argbHex, alpha, rotation)
- alpha is optional and can just be in the
argbHex
field. - rotation was added in version 1.2.6+
- alpha is required to use rotation.
returns the RenderCommon$rect object.
Example: overlay.removeRect(r)
removes a RenderCommon$rect element from the screen.
Example: overlay.addImage(x, y, width, height, id, imageX, imageY, regionWidth, regionHeight, textureWidth, textureHeight, rotation)
-
rotation
was added in 1.2.6+
returns the RenderCommon$image object.
Example: overlay.removeImage(image)
remove a RenderCommon$image element from the screen.
Example: overlay.addItem(x, y, item, showOverlay, scale, rotation)
-
scale
/rotation
optionals were added in 1.2.6+
returns the RenderCommon$item object.
Example: overlay.addItem(x, y, itemid, showOverlay, scale, rotation)
-
scale
/rotation
optionals were added in 1.2.6+
returns the RenderCommon$item object.
Example: overlay.removeItem(i)
removes an RenderCommon$item element from the screen.
Example: scr.close()
closes the screen.
class Pos2D {
this.x //double
this.y //double
constructor(x, y);
}
class Pos2D {
this.x1 //double
this.y1 //double
this.x2
this.y2
constructor(x1, y1, x2, y2);
}