Search in sources :

Example 26 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class ActiveModulesHud method update.

@Override
public void update(HudRenderer renderer) {
    if (Modules.get() == null) {
        box.setSize(renderer.textWidth("Active Modules"), renderer.textHeight());
        return;
    }
    modules.clear();
    for (Module module : Modules.get().getActive()) {
        if (module.isVisible())
            modules.add(module);
    }
    modules.sort((o1, o2) -> {
        double _1 = getModuleWidth(renderer, o1);
        double _2 = getModuleWidth(renderer, o2);
        if (sort.get() == Sort.Smallest) {
            double temp = _1;
            _1 = _2;
            _2 = temp;
        }
        int a = Double.compare(_1, _2);
        if (a == 0)
            return 0;
        return a < 0 ? 1 : -1;
    });
    double width = 0;
    double height = 0;
    for (int i = 0; i < modules.size(); i++) {
        Module module = modules.get(i);
        width = Math.max(width, getModuleWidth(renderer, module));
        height += renderer.textHeight();
        if (i > 0)
            height += 2;
    }
    box.setSize(width, height);
}
Also used : Module(mathax.client.systems.modules.Module)

Example 27 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class ActiveModulesHud method renderModule.

private void renderModule(HudRenderer renderer, List<Module> modules, int index, double x, double y) {
    Module module = modules.get(index);
    Color color = flatColor.get();
    ModuleColorMode colorMode = this.colorMode.get();
    if (colorMode == ModuleColorMode.Random)
        color = module.color;
    else if (colorMode == ModuleColorMode.Rainbow) {
        rainbowHue2 += rainbowSpread.get();
        int c = java.awt.Color.HSBtoRGB((float) rainbowHue2, rainbowSaturation.get().floatValue(), 1);
        rainbow.r = Color.toRGBAR(c);
        rainbow.g = Color.toRGBAG(c);
        rainbow.b = Color.toRGBAB(c);
        color = rainbow;
    } else if (colorMode == ModuleColorMode.Category)
        color = new Color(module.category.color);
    renderer.text(module.title, x, y, color);
    double textLength = renderer.textWidth(module.title);
    if (activeInfo.get()) {
        String info = module.getInfoString();
        if (info != null) {
            renderer.text(info, x + renderer.textWidth(module.title) + renderer.textWidth(" "), y, hud.secondaryColor.get());
            textLength += renderer.textWidth(" ") + renderer.textWidth(info);
        }
    }
    if (outlines.get()) {
        if (index == 0) {
            // Left quad
            Renderer2D.COLOR.quad(x - 2 - outlineWidth.get(), y - 2, outlineWidth.get(), renderer.textHeight() + 4, prevColor, prevColor, color, color);
            // Right quad
            Renderer2D.COLOR.quad(x + textLength + 2, y - 2, outlineWidth.get(), renderer.textHeight() + 4, prevColor, prevColor, color, color);
            // Top quad
            Renderer2D.COLOR.quad(x - 2 - outlineWidth.get(), y - 2 - outlineWidth.get(), textLength + 4 + (outlineWidth.get() * 2), outlineWidth.get(), prevColor, prevColor, color, color);
        } else if (index == modules.size() - 1) {
            // Left quad
            Renderer2D.COLOR.quad(x - 2 - outlineWidth.get(), y, outlineWidth.get(), renderer.textHeight() + 2 + outlineWidth.get(), prevColor, prevColor, color, color);
            // Right quad
            Renderer2D.COLOR.quad(x + textLength + 2, y, outlineWidth.get(), renderer.textHeight() + 2 + outlineWidth.get(), prevColor, prevColor, color, color);
            // Bottom quad
            Renderer2D.COLOR.quad(x - 2 - outlineWidth.get(), y + renderer.textHeight() + 2, textLength + 4 + (outlineWidth.get() * 2), outlineWidth.get(), prevColor, prevColor, color, color);
        }
        if (index > 0) {
            if (index < modules.size() - 1) {
                // Left quad
                Renderer2D.COLOR.quad(x - 2 - outlineWidth.get(), y, outlineWidth.get(), renderer.textHeight() + 2, prevColor, prevColor, color, color);
                // Right quad
                Renderer2D.COLOR.quad(x + textLength + 2, y, outlineWidth.get(), renderer.textHeight() + 2, prevColor, prevColor, color, color);
            }
            // Left inbetween quad
            Renderer2D.COLOR.quad(Math.min(prevX, x) - 2 - outlineWidth.get(), Math.max(prevX, x) == x ? y : y - outlineWidth.get(), (Math.max(prevX, x) - 2) - (Math.min(prevX, x) - 2 - outlineWidth.get()), outlineWidth.get(), prevColor, prevColor, color, color);
            // Right inbetween quad
            Renderer2D.COLOR.quad(Math.min(prevX + prevTextLength, x + textLength) + 2, Math.min(prevX + prevTextLength, x + textLength) == x + textLength ? y : y - outlineWidth.get(), (Math.max(prevX + prevTextLength, x + textLength) + 2 + outlineWidth.get()) - (Math.min(prevX + prevTextLength, x + textLength) + 2), outlineWidth.get(), prevColor, prevColor, color, color);
        }
    }
    prevTextLength = textLength;
    prevColor = color;
}
Also used : ModuleColorMode(mathax.client.utils.render.ModuleColorMode) SettingColor(mathax.client.utils.render.color.SettingColor) Color(mathax.client.utils.render.color.Color) Module(mathax.client.systems.modules.Module)

Example 28 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class ModuleInfoHud method render.

@Override
public void render(HudRenderer renderer) {
    double x = box.getX();
    double y = box.getY();
    if (Modules.get() == null || modules.get().isEmpty()) {
        renderer.text("Module Info", x, y, hud.primaryColor.get());
        return;
    }
    for (Module module : modules.get()) {
        renderModule(renderer, module, x + box.alignX(getModuleWidth(renderer, module)), y);
        y += 2 + renderer.textHeight();
    }
}
Also used : Module(mathax.client.systems.modules.Module)

Example 29 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class ModuleInfoHud method update.

@Override
public void update(HudRenderer renderer) {
    if (Modules.get() == null || modules.get().isEmpty()) {
        box.setSize(renderer.textWidth("Module Info"), renderer.textHeight());
        return;
    }
    double width = 0;
    double height = 0;
    int i = 0;
    for (Module module : modules.get()) {
        width = Math.max(width, getModuleWidth(renderer, module));
        height += renderer.textHeight();
        if (i > 0)
            height += 2;
        i++;
    }
    box.setSize(width, height);
}
Also used : Module(mathax.client.systems.modules.Module)

Aggregations

Module (mathax.client.systems.modules.Module)29 Modules (mathax.client.systems.modules.Modules)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)4 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)4 WSection (mathax.client.gui.widgets.containers.WSection)4 Command (mathax.client.systems.commands.Command)4 Category (mathax.client.systems.modules.Category)4 CommandSource (net.minecraft.command.CommandSource)4 Set (java.util.Set)3 GuiTheme (mathax.client.gui.GuiTheme)3 TabScreen (mathax.client.gui.tabs.TabScreen)3 Tabs (mathax.client.gui.tabs.Tabs)3 Cell (mathax.client.gui.utils.Cell)3 WContainer (mathax.client.gui.widgets.containers.WContainer)3 WVerticalList (mathax.client.gui.widgets.containers.WVerticalList)3 WWindow (mathax.client.gui.widgets.containers.WWindow)3 WTextBox (mathax.client.gui.widgets.input.WTextBox)3 ModuleArgumentType (mathax.client.systems.commands.arguments.ModuleArgumentType)3