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
FieldsModifier and TypeFieldDescriptionbooleanFlag variable used because positions are first set when the ui is first opened. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancharTyped(char character) protected booleanconsumeElementCharTyped(T element, char character) protected booleanconsumeElementKeyTyped(T element, int key, int scanCode, int modifiers) protected booleanconsumeElementMouseClick(T element, double mouseX, double mouseY, int button) protected booleanconsumeElementMouseMove(T element, double mouseX, double mouseY) protected booleanconsumeElementMouseRelease(T element, double mouseX, double mouseY, int button) protected booleanconsumeElementMouseScroll(T element, double mouseX, double mouseY, double delta) protected booleanconsumeMouseClick(double mouseX, double mouseY, int button) protected voidconsumeMouseMove(double mouseX, double mouseY) protected voidconsumeMouseRelease(double mouseX, double mouseY, int button) protected booleanconsumeMouseScroll(double mouseX, double mouseY, double delta) booleandeserialize(com.google.gson.JsonElement obj) getElement(String name) Finds an element given it's namefloatgetScale()abstract voidInitialize all of the elementsbooleanisElementHovered(T element, double mouseX, double mouseY) Checks if an element is hovered.protected booleanChecks if an element should have events sent to itbooleanisHovered(double mouseX, double mouseY) booleankeyTyped(int key, int scanCode, int modifiers) booleanmouseClicked(double mouseX, double mouseY, int button) voidmouseMoved(double mouseX, double mouseY) voidmouseReleased(double mouseX, double mouseY, int button) booleanmouseScrolled(double mouseX, double mouseY, double delta) abstract voidmoveElementToTop(T element) Moves the element to the topvoidrender(RenderContext context, double mouseX, double mouseY) voidrenderElements(RenderContext renderContext, double mouseX, double mouseY) com.google.gson.JsonElementabstract voidSets the default positions of the elementsbooleanshouldSerialize(boolean autosave) voidtick()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.rusherhack.core.interfaces.IDraggable
isDraggingMethods inherited from interface org.rusherhack.client.api.render.IRenderable2D
getFontRenderer, getRenderer, renderMethods 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:
renderin interfaceIRenderable2D
-
renderElements
-
tick
public void tick()- Specified by:
tickin interfaceorg.rusherhack.core.interfaces.ITickable
-
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button) - Specified by:
mouseClickedin interfaceorg.rusherhack.core.interfaces.IClickable
-
mouseReleased
public void mouseReleased(double mouseX, double mouseY, int button) - Specified by:
mouseReleasedin interfaceorg.rusherhack.core.interfaces.IClickable
-
mouseMoved
public void mouseMoved(double mouseX, double mouseY) - Specified by:
mouseMovedin interfaceorg.rusherhack.core.interfaces.IDraggable
-
mouseScrolled
public boolean mouseScrolled(double mouseX, double mouseY, double delta) - Specified by:
mouseScrolledin interfaceorg.rusherhack.core.interfaces.IScrollable
-
charTyped
public boolean charTyped(char character) - Specified by:
charTypedin interfaceorg.rusherhack.core.interfaces.ITypeable
-
keyTyped
public boolean keyTyped(int key, int scanCode, int modifiers) - Specified by:
keyTypedin interfaceorg.rusherhack.core.interfaces.ITypeable
-
isHovered
public boolean isHovered(double mouseX, double mouseY) - Specified by:
isHoveredin 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:
serializein interfaceorg.rusherhack.core.serialize.ISerializable<T extends ElementBase>
-
deserialize
public boolean deserialize(com.google.gson.JsonElement obj) - Specified by:
deserializein interfaceorg.rusherhack.core.serialize.ISerializable<T extends ElementBase>
-
shouldSerialize
public boolean shouldSerialize(boolean autosave) - Specified by:
shouldSerializein interfaceorg.rusherhack.core.serialize.ISerializable<T extends ElementBase>
-