Search in sources :

Example 1 with ClickGuiWindow

use of org.bleachhack.gui.clickgui.window.ClickGuiWindow in project BleachHack by BleachDrinker420.

the class BleachFileHelper method readClickGui.

public static void readClickGui() {
    JsonObject jo = BleachJsonHelper.readJsonFile("clickgui.json");
    if (jo == null)
        return;
    for (Entry<String, JsonElement> e : jo.entrySet()) {
        if (!e.getValue().isJsonObject())
            continue;
        for (Window w : ModuleClickGuiScreen.INSTANCE.getWindows()) {
            if (w.title.equals(e.getKey())) {
                JsonObject jw = e.getValue().getAsJsonObject();
                try {
                    w.x1 = jw.get("x").getAsInt();
                    w.y1 = jw.get("y").getAsInt();
                    if (w instanceof ClickGuiWindow && jw.has("hidden")) {
                        ((ClickGuiWindow) w).hiding = jw.get("hidden").getAsBoolean();
                    }
                } catch (Exception ex) {
                    BleachLogger.logger.error("Error trying to load clickgui window: " + e.getKey() + " with data: " + e.getValue());
                }
            }
        }
    }
}
Also used : UIWindow(org.bleachhack.gui.clickgui.window.UIWindow) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) Window(org.bleachhack.gui.window.Window) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject)

Example 2 with ClickGuiWindow

use of org.bleachhack.gui.clickgui.window.ClickGuiWindow in project BleachHack by BleachDrinker420.

the class BleachFileHelper method saveClickGui.

public static void saveClickGui() {
    JsonObject jo = new JsonObject();
    for (Window w : ModuleClickGuiScreen.INSTANCE.getWindows()) {
        JsonObject jw = new JsonObject();
        jw.addProperty("x", w.x1);
        jw.addProperty("y", w.y1);
        if (w instanceof ClickGuiWindow) {
            jw.addProperty("hidden", ((ClickGuiWindow) w).hiding);
        }
        jo.add(w.title, jw);
    }
    BleachJsonHelper.setJsonFile("clickgui.json", jo);
}
Also used : UIWindow(org.bleachhack.gui.clickgui.window.UIWindow) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) Window(org.bleachhack.gui.window.Window) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) JsonObject(com.google.gson.JsonObject)

Example 3 with ClickGuiWindow

use of org.bleachhack.gui.clickgui.window.ClickGuiWindow in project BleachHack by BleachDrinker420.

the class ClickGuiScreen method render.

public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    this.renderBackground(matrices);
    for (Window w : getWindows()) {
        if (w instanceof ClickGuiWindow) {
            ((ClickGuiWindow) w).updateKeys(mouseX, mouseY, keyDown, lmDown, rmDown, lmHeld, mwScroll);
        }
    }
    super.render(matrices, mouseX, mouseY, delta);
    matrices.push();
    matrices.translate(0, 0, 250);
    for (Window w : getWindows()) {
        if (w instanceof ClickGuiWindow) {
            Tooltip tooltip = ((ClickGuiWindow) w).getTooltip();
            if (tooltip != null) {
                int tooltipY = tooltip.y;
                String[] split = tooltip.text.split("\n", -1);
                ArrayUtils.reverse(split);
                for (String s : split) {
                    /* Match lines to end of words after it reaches 22 characters long */
                    Matcher mat = Pattern.compile(".{1,22}\\b\\W*").matcher(s);
                    List<String> lines = new ArrayList<>();
                    while (mat.find()) lines.add(mat.group().trim());
                    if (lines.isEmpty())
                        lines.add(s);
                    int start = tooltipY - lines.size() * 10;
                    for (int l = 0; l < lines.size(); l++) {
                        fill(matrices, tooltip.x, start + (l * 10) - 1, tooltip.x + textRenderer.getWidth(lines.get(l)) + 3, start + (l * 10) + 9, 0xff000000);
                        textRenderer.drawWithShadow(matrices, lines.get(l), tooltip.x + 2, start + (l * 10), -1);
                    }
                    tooltipY -= lines.size() * 10;
                }
            }
        }
    }
    Window.fill(matrices, width / 2 - 50, -1, width / 2 - 2, 12, mouseX >= width / 2 - 50 && mouseX <= width / 2 - 2 && mouseY >= 0 && mouseY <= 12 ? 0x60b070f0 : 0x60606090);
    Window.fill(matrices, width / 2 + 2, -1, width / 2 + 50, 12, mouseX >= width / 2 + 2 && mouseX <= width / 2 + 50 && mouseY >= 0 && mouseY <= 12 ? 0x60b070f0 : 0x60606090);
    drawCenteredText(matrices, textRenderer, "Modules", width / 2 - 26, 2, 0xf0f0f0);
    drawCenteredText(matrices, textRenderer, "UI", width / 2 + 26, 2, 0xf0f0f0);
    if (warningOpacity > 3) {
        drawCenteredText(matrices, textRenderer, "UI not available on the main menu!", width / 2, 17, warningOpacity > 255 ? 0xd14a3b : (warningOpacity << 24) | 0xd14a3b);
        warningOpacity -= 3;
    }
    matrices.pop();
    lmDown = false;
    rmDown = false;
    keyDown = -1;
    mwScroll = 0;
}
Also used : ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) Window(org.bleachhack.gui.window.Window) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) Matcher(java.util.regex.Matcher) Tooltip(org.bleachhack.gui.clickgui.window.ClickGuiWindow.Tooltip) ArrayList(java.util.ArrayList)

Example 4 with ClickGuiWindow

use of org.bleachhack.gui.clickgui.window.ClickGuiWindow in project BleachHack by BleachDrinker420.

the class CmdClickGui method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length != 1 && args.length != 2) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("reset")) {
        if (args.length == 1 || args[1].equalsIgnoreCase("closed")) {
            int y = 50;
            for (Window m : ModuleClickGuiScreen.INSTANCE.getWindows()) {
                if (m instanceof ClickGuiWindow) {
                    ((ClickGuiWindow) m).hiding = true;
                    m.x1 = 30;
                    m.y1 = y;
                    y += 16;
                }
            }
        } else if (args[1].equalsIgnoreCase("open")) {
            int x = 10;
            for (Window m : ModuleClickGuiScreen.INSTANCE.getWindows()) {
                if (m instanceof ClickGuiWindow) {
                    ((ClickGuiWindow) m).hiding = false;
                    m.x1 = x;
                    m.y1 = 35;
                    x += ModuleManager.getModule(ClickGui.class).getSetting(0).asSlider().getValueInt() + 5;
                }
            }
        } else {
            throw new CmdSyntaxException("Invalid reset mode!");
        }
        BleachFileHelper.SCHEDULE_SAVE_CLICKGUI.set(true);
        BleachLogger.info("Reset the clickgui!");
    } else if (args[0].equalsIgnoreCase("length")) {
        if (!NumberUtils.isCreatable(args[1])) {
            throw new CmdSyntaxException("Invalid clickgui length: " + args[1]);
        }
        ModuleManager.getModule(ClickGui.class).getSetting(0).asSlider().setValue(NumberUtils.createNumber(args[1]).doubleValue());
        BleachFileHelper.SCHEDULE_SAVE_MODULES.set(true);
        BleachLogger.info("Set the clickgui length to: " + args[1]);
    } else {
        throw new CmdSyntaxException();
    }
}
Also used : Window(org.bleachhack.gui.window.Window) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow)

Example 5 with ClickGuiWindow

use of org.bleachhack.gui.clickgui.window.ClickGuiWindow in project BleachHack by BleachDrinker420.

the class ModuleClickGuiScreen method initWindows.

public void initWindows() {
    int len = ModuleManager.getModule(ClickGui.class).getSetting(0).asSlider().getValueInt();
    int y = 50;
    for (ModuleCategory c : ModuleCategory.values()) {
        addWindow(new ModuleWindow(ModuleManager.getModulesInCat(c), 30, y, len, StringUtils.capitalize(c.name().toLowerCase()), c.getItem()));
        y += 16;
    }
    for (Window w : getWindows()) {
        if (w instanceof ClickGuiWindow) {
            ((ClickGuiWindow) w).hiding = true;
        }
    }
}
Also used : ModuleWindow(org.bleachhack.gui.clickgui.window.ModuleWindow) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) Window(org.bleachhack.gui.window.Window) ClickGui(org.bleachhack.module.mods.ClickGui) ModuleCategory(org.bleachhack.module.ModuleCategory) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) ModuleWindow(org.bleachhack.gui.clickgui.window.ModuleWindow)

Aggregations

ClickGuiWindow (org.bleachhack.gui.clickgui.window.ClickGuiWindow)5 Window (org.bleachhack.gui.window.Window)5 JsonObject (com.google.gson.JsonObject)2 UIWindow (org.bleachhack.gui.clickgui.window.UIWindow)2 JsonElement (com.google.gson.JsonElement)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 CmdSyntaxException (org.bleachhack.command.exception.CmdSyntaxException)1 Tooltip (org.bleachhack.gui.clickgui.window.ClickGuiWindow.Tooltip)1 ModuleWindow (org.bleachhack.gui.clickgui.window.ModuleWindow)1 ModuleCategory (org.bleachhack.module.ModuleCategory)1 ClickGui (org.bleachhack.module.mods.ClickGui)1