Skip to content

Screen Class

wagyourtail edited this page Sep 20, 2020 · 23 revisions

The Screen Class, methods are as follows:

Screen(String, Bool) 1.0.5+

Example: new Screen("Title", dirtBackground)

Initialize, to call this it is easiest to refer to Hud.

onInit 1.0.5+

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!");
    });
}

onClose 1.1.9+

when the screen closes, this should be triggered. Example:

scr.onClose = (scr_obj) => {
    chat.log("screen closed");
}

onMouseDown 1.2.0+

put a js function here. Example:

scr.onMouseDown = (pos2D, m_btn) => {
    chat.log(`${pos2D.x} ${pos2D.y} ${m_btn}`);
}

onMouseDrag 1.2.0+

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}`);
}

onMouseUp 1.2.0+

put a js function here. Example:

scr.onMouseUp = (pos2D, m_btn) => {
    chat.log(`${pos2D.x} ${pos2D.y} ${m_btn}`);
}

onKeyPressed 1.2.0+

put a js function here. Example:

scr.onKeyPressed = (keycode, modifiers) => {
    chat.log(`${keycode} ${modifiers}`);
}

onScroll 1.2.0+

put a js function here. Example:

scr.onScroll = (pos2D, scrollAmmt) => {
    chat.log(`${pos2D.x} ${pos2D.y} ${scrollAmmt}`);
}

getWidth() 1.0.5+

Example: scr.getWidth()

returns the internal width of the window.

getHeight() 1.0.5+

Example: scr.getHeight()

returns the internal height of the window.

getTitleText() 1.0.5+

Example: scr.getTitleText()

returns the title of the window.

getButtonWidgets() 1.0.5+

Example: scr.getButtonWidgets()

returns an ArrayList of ButtonWidgetHelpers.

getTextFields() 1.0.5+

Example: scr.getButtonWidgets()

returns an ArrayList of TextFieldWidgetHelpers.

getTexts() 1.0.5+

Example: scr.getTexts()

returns an ArrayList of RenderCommon$text elements.

getRects() 1.2.0+

Example: overlay.getRects()

returns an ArrayList of RenderCommon$rect elements.

getImages() 1.2.3+

Example: overlay.getImages()

returns an ArrayList of RenderCommon$image elements.

getItems() 1.2.0+

Example: overlay.getItems()

returns an ArrayList of RenderCommon$item elements.

addButton(Int, Int, Int, Int, String, BiConsumer) 1.0.5+

Example: scr.addButton(x, y, width, height, "TextOnButton", (ButtonWidgetHelper, Screen) => {})

returns the generated ButtonWidgetHelper.

removeButton(ButtonWidgetHelper) 1.0.5+

Example: scr.removeButton(btn)

removes a ButtonWidgetHelper from the screen.

addTextInput(Int, Int, Int, Int, String, BiConsumer) 1.0.5+

Example: scr.addTextInput(x, y, width, height, "Name", (ChangedValue, Screen) => {})

returns the generated TextFieldWidgetHelper.

removeTextInput(TextFieldWidgetHelper) 1.0.5+

Example: scr.removeTextInput(inp)

removes a TextFieldWidgetHelper from the screen.

addText(String, Int, Int, Int, Bool, [double, float]) 1.0.5+

Example: overlay.addText("Text", x, y, rgbHex, shadow, scale, rotation)

  • scale/rotation optionals were added in 1.2.6+

returns the RenderCommon$text object.

removeText(RenderCommon$text) 1.0.5+

Example: scr.removeText(t)

removes a RenderCommon$text element from the screen.

addRect(Int, Int, Int, Int, Int, [int, [float]]) 1.2.0+

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.

removeRect(RenderCommon$rect) 1.2.0+

Example: overlay.removeRect(r)

removes a RenderCommon$rect element from the screen.

addImage(int, int, int, int, string, int, int, int, int, int, int, [float]) 1.2.3+

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.

removeImage(RenderCommon$image) 1.2.3+

Example: overlay.removeImage(image)

remove a RenderCommon$image element from the screen.

addItem(Int, Int, ItemStackHelper, boolean, [double, float]) 1.2.0+

Example: overlay.addItem(x, y, item, showOverlay, scale, rotation)

  • scale/rotation optionals were added in 1.2.6+

returns the RenderCommon$item object.

addItem(Int, Int, String, boolean, [double, float]) 1.2.0+

Example: overlay.addItem(x, y, itemid, showOverlay, scale, rotation)

  • scale/rotation optionals were added in 1.2.6+

returns the RenderCommon$item object.

removeItem(RenderCommon$item) 1.2.0+

Example: overlay.removeItem(i)

removes an RenderCommon$item element from the screen.

close() 1.1.9+

Example: scr.close()

closes the screen.

subclass Pos2D 1.2.0+

class Pos2D {
    this.x //double
    this.y //double
    constructor(x, y);
}

subclass Vec2D 1.2.0+

class Pos2D {
    this.x1 //double
    this.y1 //double
    this.x2
    this.y2
    constructor(x1, y1, x2, y2);
}
Clone this wiki locally