Search in sources :

Example 1 with Module

use of com.tangykiwi.kiwiclient.modules.Module in project KiwiClient by TangyKiwi.

the class ModuleWindow method getHeight.

public int getHeight() {
    int h = 1;
    int count = 0;
    for (Entry<Module, Boolean> e : mods.entrySet()) {
        if (count >= start) {
            h += 12;
        }
        count++;
        if (count >= max) {
            return h;
        }
        if (e.getValue()) {
            for (Settings s : e.getKey().getSettings()) {
                if (count >= start) {
                    h += s.getHeight(len);
                }
                count++;
                try {
                    if (s.asToggle().isExpanded()) {
                        count += s.asToggle().getChildren().size();
                    }
                } catch (ClassCastException error) {
                }
                if (count >= max) {
                    return h;
                }
            }
        }
    }
    return h;
}
Also used : Module(com.tangykiwi.kiwiclient.modules.Module) Settings(com.tangykiwi.kiwiclient.modules.settings.Settings)

Example 2 with Module

use of com.tangykiwi.kiwiclient.modules.Module in project KiwiClient by TangyKiwi.

the class ModuleClickGuiScreen method render.

public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    searchField.visible = true;
    searchField.setSuggestion(searchField.getText().isEmpty() ? "Search here" : "");
    Set<Module> searchMods = new HashSet<>();
    if (!searchField.getText().isEmpty()) {
        for (Module m : KiwiClient.moduleManager.moduleList) {
            if (m.getName().toLowerCase(Locale.ENGLISH).contains(searchField.getText().toLowerCase(Locale.ENGLISH).replace(" ", ""))) {
                searchMods.add(m);
            }
        }
    }
    int len = 85;
    for (Window w : getWindows()) {
        if (w instanceof ModuleWindow) {
            ((ModuleWindow) w).setSearchedModule(searchMods);
            ((ModuleWindow) w).setLen(len);
        }
    }
    super.render(matrices, mouseX, mouseY, delta);
}
Also used : ModuleWindow(com.tangykiwi.kiwiclient.gui.clickgui.window.ModuleWindow) Window(com.tangykiwi.kiwiclient.gui.clickgui.window.Window) ClickGuiWindow(com.tangykiwi.kiwiclient.gui.clickgui.window.ClickGuiWindow) ModuleWindow(com.tangykiwi.kiwiclient.gui.clickgui.window.ModuleWindow) Module(com.tangykiwi.kiwiclient.modules.Module) HashSet(java.util.HashSet)

Example 3 with Module

use of com.tangykiwi.kiwiclient.modules.Module in project KiwiClient by TangyKiwi.

the class ModuleArgumentType method parse.

@Override
public Module parse(StringReader reader) throws CommandSyntaxException {
    String argument = reader.readString();
    Module module = KiwiClient.moduleManager.getModuleByName(argument);
    if (module == null)
        throw NO_SUCH_MODULE.create(argument);
    return module;
}
Also used : Module(com.tangykiwi.kiwiclient.modules.Module)

Example 4 with Module

use of com.tangykiwi.kiwiclient.modules.Module in project KiwiClient by TangyKiwi.

the class ActiveMods method onDrawOverlay.

@Subscribe
public void onDrawOverlay(DrawOverlayEvent e) {
    if (!mc.options.debugEnabled) {
        GlyphPageFontRenderer textRenderer = IFont.CONSOLAS;
        // TextRenderer textRenderer = mc.textRenderer;
        // DrawableHelper.fill(e.getMatrix(), 0, 60, textRenderer.getWidth(enabledMods.get(0).getName()) + 5, 62, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
        // for (Module m : enabledMods) {
        // 
        // int offset = count * (textRenderer.fontHeight + 1);
        // 
        // DrawableHelper.fill(e.getMatrix(), textRenderer.getWidth(m.getName()) + 3, 62 + offset, textRenderer.getWidth(m.getName()) + 5, 63 + textRenderer.fontHeight + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
        // DrawableHelper.fill(e.getMatrix(), 0, 62 + offset, textRenderer.getWidth(m.getName()) + 3, 63 + textRenderer.fontHeight + offset, 0x90000000);
        // textRenderer.draw(e.getMatrix(), m.getName(), 2, 63 + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
        // 
        // count++;
        // }
        int count = 0;
        ArrayList<Module> enabledMods = KiwiClient.moduleManager.getEnabledMods();
        boolean changed = false;
        if (!firstDraw && enabledMods.size() > currModules.size()) {
            for (int i = 0; i < currModules.size(); i++) {
                Module curMod = currModules.get(i);
                Module enaMod = enabledMods.get(i);
                if (!curMod.equals(enaMod)) {
                    changed = true;
                    if (disablingMods.containsKey(enaMod)) {
                        enablingMods.put(enaMod, disablingMods.get(enaMod));
                        disablingMods.remove(enaMod);
                    } else {
                        enablingMods.put(enaMod, -textRenderer.getStringWidth(enaMod.getName()));
                    }
                    break;
                }
            }
            if (!changed) {
                Module lastMod = enabledMods.get(currModules.size());
                if (disablingMods.containsKey(lastMod)) {
                    enablingMods.put(lastMod, disablingMods.get(lastMod));
                    disablingMods.remove(lastMod);
                } else {
                    enablingMods.put(enabledMods.get(currModules.size()), -textRenderer.getStringWidth(enabledMods.get(currModules.size()).getName()));
                }
            }
        }
        changed = false;
        if (enabledMods.size() < currModules.size()) {
            for (int i = 0; i < enabledMods.size(); i++) {
                Module curMod = currModules.get(i);
                Module enaMod = enabledMods.get(i);
                if (!curMod.equals(enaMod)) {
                    changed = true;
                    if (enablingMods.containsKey(curMod)) {
                        disablingMods.put(curMod, enablingMods.get(curMod));
                        enablingMods.remove(curMod);
                    } else {
                        disablingMods.put(curMod, 0);
                    }
                    break;
                }
            }
            if (!changed) {
                Module lastMod = currModules.get(enabledMods.size());
                if (enablingMods.containsKey(lastMod)) {
                    disablingMods.put(lastMod, enablingMods.get(lastMod));
                    enablingMods.remove(lastMod);
                } else {
                    disablingMods.put(currModules.get(enabledMods.size()), 0);
                }
            }
        }
        ArrayList<Module> display = KiwiClient.moduleManager.getEnabledMods();
        for (Module m : disablingMods.keySet()) {
            display.add(m);
        }
        display.sort(new ModuleManager.ModuleComparator());
        Module firstMod = display.get(0);
        if (!firstDraw && enablingMods.containsKey(firstMod)) {
            int displace = enablingMods.get(firstMod);
            DrawableHelper.fill(e.getMatrix(), displace, 60, textRenderer.getStringWidth(firstMod.getName()) + 5 + displace, 62, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
        } else if (disablingMods.containsKey(firstMod)) {
            int displace = disablingMods.get(firstMod);
            DrawableHelper.fill(e.getMatrix(), displace, 60, textRenderer.getStringWidth(firstMod.getName()) + 5 + displace, 62, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
        } else {
            DrawableHelper.fill(e.getMatrix(), 0, 60, textRenderer.getStringWidth(firstMod.getName()) + 5, 62, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
        }
        for (Module m : display) {
            int offset = count * 8;
            if (!firstDraw && enablingMods.containsKey(m)) {
                int displace = enablingMods.get(m);
                DrawableHelper.fill(e.getMatrix(), textRenderer.getStringWidth(m.getName()) + 3 + displace, 62 + offset, textRenderer.getStringWidth(m.getName()) + 5 + displace, 62 + 8 + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
                DrawableHelper.fill(e.getMatrix(), displace, 62 + offset, textRenderer.getStringWidth(m.getName()) + 3 + displace, 62 + 8 + offset, 0x90000000);
                textRenderer.drawString(e.getMatrix(), m.getName(), 0.2 + displace, 62.2 + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
                if (displace + 1 >= 0) {
                    enablingMods.remove(m);
                } else {
                    enablingMods.replace(m, enablingMods.get(m) + 1);
                }
            } else if (disablingMods.containsKey(m)) {
                int displace = disablingMods.get(m);
                DrawableHelper.fill(e.getMatrix(), textRenderer.getStringWidth(m.getName()) + 3 + displace, 62 + offset, textRenderer.getStringWidth(m.getName()) + 5 + displace, 62 + 8 + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
                DrawableHelper.fill(e.getMatrix(), displace, 62 + offset, textRenderer.getStringWidth(m.getName()) + 3 + displace, 62 + 8 + offset, 0x90000000);
                textRenderer.drawString(e.getMatrix(), m.getName(), 0.2 + displace, 62.2 + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
                if (displace - 2 <= -textRenderer.getStringWidth(m.getName())) {
                    disablingMods.remove(m);
                } else {
                    disablingMods.replace(m, disablingMods.get(m) - 2);
                }
            } else {
                DrawableHelper.fill(e.getMatrix(), textRenderer.getStringWidth(m.getName()) + 3, 62 + offset, textRenderer.getStringWidth(m.getName()) + 5, 62 + 8 + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
                DrawableHelper.fill(e.getMatrix(), 0, 62 + offset, textRenderer.getStringWidth(m.getName()) + 3, 62 + 8 + offset, 0x90000000);
                textRenderer.drawString(e.getMatrix(), m.getName(), 0.2, 62.2 + offset, ColorUtil.getRainbow(4, 0.8f, 1, count * 150));
            }
            count++;
        }
        currModules = enabledMods;
    }
    firstDraw = false;
}
Also used : GlyphPageFontRenderer(com.tangykiwi.kiwiclient.util.font.GlyphPageFontRenderer) Module(com.tangykiwi.kiwiclient.modules.Module) ModuleManager(com.tangykiwi.kiwiclient.modules.ModuleManager) Subscribe(com.google.common.eventbus.Subscribe)

Example 5 with Module

use of com.tangykiwi.kiwiclient.modules.Module in project KiwiClient by TangyKiwi.

the class ModuleWindow method render.

// numMods lines max
public void render(MatrixStack matrices, int mouseX, int mouseY) {
    int lines = getLines();
    boolean scrollable = lines > numMods;
    tooltip = null;
    int x = x1 + 1;
    int y = y1 + 13;
    x2 = x + len + 1;
    y2 = hiding ? y1 + 13 : y1 + 13 + getHeight();
    if (mwScroll != 0 && mouseOver(x, y, x2, y2) && !InputUtil.isKeyPressed(Utils.mc.getWindow().getHandle(), GLFW.GLFW_KEY_LEFT_CONTROL)) {
        start = MathHelper.clamp(start - mwScroll, 0, lines - numMods);
    }
    max = start + numMods;
    super.render(matrices, mouseX, mouseY);
    if (hiding)
        return;
    GlyphPageFontRenderer textRend = IFont.CONSOLAS;
    // TextRenderer textRend = mc.textRenderer;
    int curY = 0;
    int index = 0;
    boolean stopRender = false;
    for (Entry<Module, Boolean> m : mods.entrySet()) {
        if (index >= start) {
            if (mouseOver(x, y + curY, x + len, y + 12 + curY)) {
                DrawableHelper.fill(matrices, x, y + curY, x + len, y + 12 + curY, 0x70303070);
            }
            // If they match: Module gets marked red
            if (searchedModules != null && searchedModules.contains(m.getKey())) {
                DrawableHelper.fill(matrices, x, y + curY, x + len, y + 12 + curY, 0x50ff0000);
            }
            textRend.drawStringWithShadow(matrices, textRend.trimStringToWidth(m.getKey().getName(), len), x + 2, y + 2 + curY, m.getKey().isEnabled() ? 0x70efe0 : 0xc0c0c0);
            String color2 = m.getValue() ? "\u00a7a" : "\u00a7c";
            if (!m.getKey().getSettings().isEmpty()) {
                if (m.getValue()) {
                    IFont.CONSOLAS.drawString(matrices, color2 + "v", x + len - 8, y + 2 + curY, -1);
                } else if (m.getKey().getSettings().size() > 1) {
                    IFont.CONSOLAS.drawStringWithShadow(matrices, color2 + "\u00a7l>", x + len - 8, y + 2 + curY, -1);
                }
            }
            // Set which module settings show on
            if (mouseOver(x, y + curY, x + len, y + 12 + curY)) {
                tooltip = Triple.of(x + len + 2, y + curY, m.getKey().getDescription());
                if (lmDown)
                    m.getKey().toggle();
                if (rmDown)
                    mods.replace(m.getKey(), !m.getValue());
                if (lmDown || rmDown)
                    mc.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
            }
            curY += 12;
        }
        index++;
        if (index == max) {
            stopRender = true;
            break;
        }
        // draw settings
        if (m.getValue()) {
            for (Settings s : m.getKey().getSettings()) {
                if (index >= start) {
                    index = s.render(this, matrices, x + 1, y + curY, len - 1, index, max);
                    if (!s.getDesc().isEmpty() && mouseOver(x + 2, y + curY, x + len, y + s.getHeight(len) + curY)) {
                        tooltip = s.getGuiDesc(this, x + 1, y + curY, len - 1);
                    }
                    DrawableHelper.fill(matrices, x + 1, y + curY, x + 2, y + curY + s.getHeight(len), 0xff8070b0);
                    curY += s.getHeight(len);
                }
                index++;
                if (index >= max) {
                    stopRender = true;
                    break;
                }
            }
        }
        if (stopRender) {
            break;
        }
    }
    if (scrollable) {
        int scrollbarTop = y + (y2 - y - 2) * start / lines;
        int scrollbarBottom = y + (y2 - y - 2) * max / lines;
        DrawableHelper.fill(matrices, x2 - 2, scrollbarTop, x2 - 1, scrollbarBottom, Color.WHITE.getRGB());
    }
}
Also used : GlyphPageFontRenderer(com.tangykiwi.kiwiclient.util.font.GlyphPageFontRenderer) Module(com.tangykiwi.kiwiclient.modules.Module) Settings(com.tangykiwi.kiwiclient.modules.settings.Settings)

Aggregations

Module (com.tangykiwi.kiwiclient.modules.Module)6 Settings (com.tangykiwi.kiwiclient.modules.settings.Settings)2 GlyphPageFontRenderer (com.tangykiwi.kiwiclient.util.font.GlyphPageFontRenderer)2 Subscribe (com.google.common.eventbus.Subscribe)1 ClickGuiWindow (com.tangykiwi.kiwiclient.gui.clickgui.window.ClickGuiWindow)1 ModuleWindow (com.tangykiwi.kiwiclient.gui.clickgui.window.ModuleWindow)1 Window (com.tangykiwi.kiwiclient.gui.clickgui.window.Window)1 ModuleManager (com.tangykiwi.kiwiclient.modules.ModuleManager)1 HashSet (java.util.HashSet)1 LiteralText (net.minecraft.text.LiteralText)1