Search in sources :

Example 1 with ModuleColorMode

use of mathax.client.utils.render.ModuleColorMode 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)

Aggregations

Module (mathax.client.systems.modules.Module)1 ModuleColorMode (mathax.client.utils.render.ModuleColorMode)1 Color (mathax.client.utils.render.color.Color)1 SettingColor (mathax.client.utils.render.color.SettingColor)1