Package org.rusherhack.client.api.ui
Class ElementHandlerBase<T extends ElementBase>
java.lang.Object
org.rusherhack.client.api.ui.ElementHandlerBase<T>
- All Implemented Interfaces:
Globals
,IRenderable2D
,org.rusherhack.core.interfaces.IClickable
,org.rusherhack.core.interfaces.IDraggable
,org.rusherhack.core.interfaces.IHoverable
,org.rusherhack.core.interfaces.IScrollable
,org.rusherhack.core.interfaces.ITickable
,org.rusherhack.core.interfaces.ITypeable
,org.rusherhack.core.serialize.ISerializable<com.google.gson.JsonElement>
,org.rusherhack.core.serialize.JsonSerializable
- Direct Known Subclasses:
HudHandlerBase
,PanelHandlerBase
,WindowHandlerBase
public abstract class ElementHandlerBase<T extends ElementBase>
extends Object
implements Globals, IRenderable2D, org.rusherhack.core.interfaces.IDraggable, org.rusherhack.core.interfaces.IScrollable, org.rusherhack.core.interfaces.ITypeable, org.rusherhack.core.interfaces.ITickable, org.rusherhack.core.serialize.JsonSerializable
A handler for managing multiple elements on screen.
-
Field Summary
Modifier and TypeFieldDescriptionboolean
Flag variable used because positions are first set when the ui is first opened. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
charTyped
(char character) protected boolean
consumeElementCharTyped
(T element, char character) protected boolean
consumeElementKeyTyped
(T element, int key, int scanCode, int modifiers) protected boolean
consumeElementMouseClick
(T element, double mouseX, double mouseY, int button) protected boolean
consumeElementMouseMove
(T element, double mouseX, double mouseY) protected boolean
consumeElementMouseRelease
(T element, double mouseX, double mouseY, int button) protected boolean
consumeElementMouseScroll
(T element, double mouseX, double mouseY, double delta) protected boolean
consumeMouseClick
(double mouseX, double mouseY, int button) protected void
consumeMouseMove
(double mouseX, double mouseY) protected void
consumeMouseRelease
(double mouseX, double mouseY, int button) protected boolean
consumeMouseScroll
(double mouseX, double mouseY, double delta) boolean
deserialize
(com.google.gson.JsonElement obj) getElement
(String name) Finds an element given it's namefloat
getScale()
abstract void
Initialize all of the elementsboolean
isElementHovered
(T element, double mouseX, double mouseY) Checks if an element is hovered.protected boolean
Checks if an element should have events sent to itboolean
isHovered
(double mouseX, double mouseY) boolean
keyTyped
(int key, int scanCode, int modifiers) boolean
mouseClicked
(double mouseX, double mouseY, int button) void
mouseMoved
(double mouseX, double mouseY) void
mouseReleased
(double mouseX, double mouseY, int button) boolean
mouseScrolled
(double mouseX, double mouseY, double delta) abstract void
moveElementToTop
(T element) Moves the element to the topvoid
render
(RenderContext context, double mouseX, double mouseY) void
renderElements
(RenderContext renderContext, double mouseX, double mouseY) com.google.gson.JsonElement
abstract void
Sets the default positions of the elementsboolean
shouldSerialize
(boolean autosave) void
tick()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.rusherhack.core.interfaces.IDraggable
isDragging
Methods inherited from interface org.rusherhack.client.api.render.IRenderable2D
getFontRenderer, getRenderer, render
Methods inherited from interface org.rusherhack.core.serialize.ISerializable
shouldAutoSave
-
Field Details
-
positionsInitialized
public boolean positionsInitializedFlag variable used because positions are first set when the ui is first opened.Afterwards, the positions are saved to the config and will load from there.
-
-
Constructor Details
-
ElementHandlerBase
public ElementHandlerBase(boolean scaledWithMinecraftGui) - Parameters:
scaledWithMinecraftGui
- sets whether elements should be scaled with the minecraft gui
-
-
Method Details
-
getElements
- Returns:
- elements to be handled by this handler
-
getElement
Finds an element given it's name- Parameters:
name
- name of the element- Returns:
- the element with the name or null if not found
-
initialize
public abstract void initialize()Initialize all of the elements -
setDefaultPositions
public abstract void setDefaultPositions()Sets the default positions of the elements -
moveElementToTop
Moves the element to the top- Parameters:
element
- element to move to the top
-
render
- Specified by:
render
in interfaceIRenderable2D
-
renderElements
-
tick
public void tick()- Specified by:
tick
in interfaceorg.rusherhack.core.interfaces.ITickable
-
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button) - Specified by:
mouseClicked
in interfaceorg.rusherhack.core.interfaces.IClickable
-
mouseReleased
public void mouseReleased(double mouseX, double mouseY, int button) - Specified by:
mouseReleased
in interfaceorg.rusherhack.core.interfaces.IClickable
-
mouseMoved
public void mouseMoved(double mouseX, double mouseY) - Specified by:
mouseMoved
in interfaceorg.rusherhack.core.interfaces.IDraggable
-
mouseScrolled
public boolean mouseScrolled(double mouseX, double mouseY, double delta) - Specified by:
mouseScrolled
in interfaceorg.rusherhack.core.interfaces.IScrollable
-
charTyped
public boolean charTyped(char character) - Specified by:
charTyped
in interfaceorg.rusherhack.core.interfaces.ITypeable
-
keyTyped
public boolean keyTyped(int key, int scanCode, int modifiers) - Specified by:
keyTyped
in interfaceorg.rusherhack.core.interfaces.ITypeable
-
isHovered
public boolean isHovered(double mouseX, double mouseY) - Specified by:
isHovered
in interfaceorg.rusherhack.core.interfaces.IHoverable
-
consumeMouseClick
protected boolean consumeMouseClick(double mouseX, double mouseY, int button) -
consumeElementMouseClick
-
consumeMouseRelease
protected void consumeMouseRelease(double mouseX, double mouseY, int button) -
consumeElementMouseRelease
-
consumeMouseMove
protected void consumeMouseMove(double mouseX, double mouseY) -
consumeElementMouseMove
-
consumeMouseScroll
protected boolean consumeMouseScroll(double mouseX, double mouseY, double delta) -
consumeElementMouseScroll
-
consumeElementCharTyped
-
consumeElementKeyTyped
-
getScale
public float getScale() -
isEnabled
Checks if an element should have events sent to it- Parameters:
element
- element to check- Returns:
-
isElementHovered
Checks if an element is hovered. Can be overridden to change the hover behavior.- Parameters:
element
- the elementmouseX
- the x-coordinate of the mousemouseY
- the y-coordinate of the mouse- Returns:
- true if the window is hovered
-
serialize
public com.google.gson.JsonElement serialize()- Specified by:
serialize
in interfaceorg.rusherhack.core.serialize.ISerializable<T extends ElementBase>
-
deserialize
public boolean deserialize(com.google.gson.JsonElement obj) - Specified by:
deserialize
in interfaceorg.rusherhack.core.serialize.ISerializable<T extends ElementBase>
-
shouldSerialize
public boolean shouldSerialize(boolean autosave) - Specified by:
shouldSerialize
in interfaceorg.rusherhack.core.serialize.ISerializable<T extends ElementBase>
-