Search in sources :

Example 1 with HudElement

use of me.earth.earthhack.api.hud.HudElement in project 3arthh4ck by 3arthqu4ke.

the class HudValuePreset method apply.

@Override
public void apply() {
    HudElement module = this.getModule();
    Set<Setting<?>> generated = GeneratedSettings.getGenerated(module);
    for (Setting<?> setting : generated) {
        module.unregister(setting);
    }
    GeneratedSettings.clear(module);
    Map.Entry<String, JsonElement> enabled = null;
    for (Map.Entry<String, JsonElement> entry : values.entrySet()) {
        if (entry.getKey().equalsIgnoreCase("Enabled")) {
            enabled = entry;
            continue;
        }
        setSetting(module, entry);
    }
    // set enabled last, so all settings are to date when we enter onEnable.
    if (enabled != null) {
        setSetting(module, enabled);
    }
}
Also used : JsonElement(com.google.gson.JsonElement) BindSetting(me.earth.earthhack.api.setting.settings.BindSetting) Setting(me.earth.earthhack.api.setting.Setting) HudElement(me.earth.earthhack.api.hud.HudElement) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with HudElement

use of me.earth.earthhack.api.hud.HudElement in project 3arthh4ck by 3arthqu4ke.

the class HudElementManager method load.

public void load() {
    for (HudElement element : getRegistered()) {
        Earthhack.getLogger().info(element.getName());
        element.load();
    }
    registered.sort(Comparator.comparing(HudElement::getZ));
}
Also used : HudElement(me.earth.earthhack.api.hud.HudElement)

Example 3 with HudElement

use of me.earth.earthhack.api.hud.HudElement in project 3arthh4ck by 3arthqu4ke.

the class HudEditorGui method keyTyped.

@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    super.keyTyped(typedChar, keyCode);
    for (HudElement element : Managers.ELEMENTS.getRegistered()) {
        if (element.isEnabled()) {
            element.guiKeyPressed(typedChar, keyCode);
        }
    }
    panel.keyPressed(typedChar, keyCode);
}
Also used : HudElement(me.earth.earthhack.api.hud.HudElement)

Example 4 with HudElement

use of me.earth.earthhack.api.hud.HudElement in project 3arthh4ck by 3arthqu4ke.

the class HudEditorGui method mouseReleased.

@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
    super.mouseReleased(mouseX, mouseY, state);
    for (HudElement element : Managers.ELEMENTS.getRegistered()) {
        if (element.isEnabled()) {
            element.guiMouseReleased(mouseX, mouseY, state);
        }
    }
    panel.mouseReleased(mouseX, mouseY, state);
}
Also used : HudElement(me.earth.earthhack.api.hud.HudElement)

Example 5 with HudElement

use of me.earth.earthhack.api.hud.HudElement in project 3arthh4ck by 3arthqu4ke.

the class HudEditorGui method mouseClicked.

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    super.mouseClicked(mouseX, mouseY, mouseButton);
    List<HudElement> clicked = new ArrayList<>();
    boolean hasDragging = false;
    for (HudElement element : Managers.ELEMENTS.getRegistered()) {
        if (element.isEnabled() && GuiUtil.isHovered(element, mouseX, mouseY)) {
            clicked.add(element);
            if (element.isDragging())
                hasDragging = true;
        // element.guiMouseClicked(mouseX, mouseY, mouseButton);
        }
    }
    clicked.sort(Comparator.comparing(HudElement::getZ));
    if (!clicked.isEmpty()) {
        clicked.get(0).guiMouseClicked(mouseX, mouseY, mouseButton);
    } else {
        if (!GuiUtil.isHovered(frame, mouseX, mouseY) && !hasDragging) {
            selecting = true;
            mouseClickedX = mouseX;
            mouseClickedY = mouseY;
            return;
        }
    }
    frame.mouseClicked(mouseX, mouseY, mouseButton);
}
Also used : HudElement(me.earth.earthhack.api.hud.HudElement)

Aggregations

HudElement (me.earth.earthhack.api.hud.HudElement)15 JsonElement (com.google.gson.JsonElement)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 JsonObject (com.google.gson.JsonObject)1 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ElementConfig (me.earth.earthhack.api.config.preset.ElementConfig)1 HudValuePreset (me.earth.earthhack.api.config.preset.HudValuePreset)1 Setting (me.earth.earthhack.api.setting.Setting)1 BindSetting (me.earth.earthhack.api.setting.settings.BindSetting)1 Component (me.earth.earthhack.impl.gui.click.component.Component)1 ColorComponent (me.earth.earthhack.impl.gui.click.component.impl.ColorComponent)1 KeybindComponent (me.earth.earthhack.impl.gui.click.component.impl.KeybindComponent)1 ModuleComponent (me.earth.earthhack.impl.gui.click.component.impl.ModuleComponent)1 StringComponent (me.earth.earthhack.impl.gui.click.component.impl.StringComponent)1 HudElementComponent (me.earth.earthhack.impl.gui.hud.rewrite.component.HudElementComponent)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1