Search in sources :

Example 6 with GuiBlock

use of cc.hyperium.gui.GuiBlock in project Hyperium by HyperiumClient.

the class PlayerStatsGui method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    if (!texturesImage.isEmpty()) {
        texturesImage.forEach((s, value) -> {
            if (!logos.containsKey(s))
                logos.put(s, new DynamicTexture(value));
        });
    }
    super.drawScreen(mouseX, mouseY, partialTicks);
    ScaledResolution current = ResolutionUtil.current();
    HypixelApiGuild guild = player.getGuild();
    if (guild == null) {
        GeneralChatHandler.instance().sendMessage("Player not found!");
        mc.displayGuiScreen(null);
        return;
    }
    boolean isInGuild = guild.isLoaded() && guild.isValid();
    drawScaledText(player.getDisplayString() + (isInGuild ? " " + guild.getFormatedTag() : ""), current.getScaledWidth() / 2, 30, 2, -1, true, true);
    if (focused == null) {
        final int blockWidth = 64 + 32;
        int blocksPerLine = (int) (current.getScaledWidth() / (1.2D * blockWidth));
        if (blocksPerLine % 2 == 1) {
            blocksPerLine--;
        }
        final int startX = ResolutionUtil.current().getScaledWidth() / 2 - (blocksPerLine * blockWidth / 2);
        int x = -1;
        int y = 0;
        hovered = null;
        for (AbstractHypixelStats field : fields) {
            DynamicTexture dynamicTexture = logos.get(field);
            x++;
            if (x > blocksPerLine) {
                x = 0;
                y++;
            }
            if (dynamicTexture != null) {
                int y1 = 100 + y * blockWidth - 10 - offset;
                if (y1 < 70)
                    continue;
                GlStateManager.pushMatrix();
                GlStateManager.resetColor();
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                int y2 = 100 + y * blockWidth - offset;
                int x1 = startX + x * blockWidth;
                GuiBlock value = new GuiBlock(x1, x1 + blockWidth / 2, y2, y2 + blockWidth / 2);
                if (value.isMouseOver(mouseX, mouseY)) {
                    hovered = field;
                }
                location.put(field, value);
                GlStateManager.translate(x1, y2, 0);
                GlStateManager.bindTexture(dynamicTexture.getGlTextureId());
                GlStateManager.scale(.2, .2, .2);
                drawTexturedModalRect(0, 0, 0, 0, 128 * 2, 128 * 2);
                GlStateManager.popMatrix();
                GlStateManager.pushMatrix();
                GlStateManager.translate(startX + x * blockWidth + 24, y1, 0);
                drawScaledText(field.getName(), 0, 0, 1.0, Color.RED.getRGB(), true, true);
                GlStateManager.popMatrix();
            }
        }
        if (hovered != null) {
            List<StatsDisplayItem> preview = hovered.getPreview(player);
            int width = 0;
            int height = 0;
            for (StatsDisplayItem statsDisplayItem : preview) {
                width = Math.max(width, statsDisplayItem.width);
                height += statsDisplayItem.height;
            }
            GuiBlock block = location.get(hovered);
            int xOffset = 0;
            int yRenderOffset = 16;
            int rightSide = block.getRight() + (width + yRenderOffset) * 2;
            if (rightSide > current.getScaledWidth()) {
                xOffset = rightSide - current.getScaledWidth();
            }
            float scale = 1.0F;
            GlStateManager.scale(scale, scale, scale);
            int left = block.getRight() - xOffset + yRenderOffset - 8;
            int top = block.getTop();
            int printY = 0;
            if (top + height * 2 > current.getScaledHeight()) {
                top = current.getScaledHeight() - height * 2 - 50;
            }
            RenderUtils.drawRect((left - 3) / scale, (top - 3) / scale, (left + (width + 3) * scale) / scale, (top + (height + 3) * scale) / scale, new Color(0, 0, 0, 220).getRGB());
            for (StatsDisplayItem statsDisplayItem : preview) {
                statsDisplayItem.draw((int) (left / scale), (int) ((top) / scale) + printY);
                printY += statsDisplayItem.height;
            }
            GlStateManager.scale(1 / scale, 1 / scale, 1 / scale);
        }
    } else {
        DynamicTexture dynamicTexture = logos.get(focused);
        GlStateManager.resetColor();
        GlStateManager.pushMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.bindTexture(dynamicTexture.getGlTextureId());
        GlStateManager.translate((current.getScaledWidth() >> 1) - 24, 80, 0);
        GlStateManager.scale(.2, .2, .2);
        drawTexturedModalRect(0, 0, 0, 0, 128 * 2, 128 * 2);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        drawScaledText(focused.getName(), current.getScaledWidth() / 2, 60, 2.0, Color.RED.getRGB(), true, true);
        Icons.EXTENSION.bind();
        GlStateModifier.INSTANCE.reset();
        Icons.EXIT.bind();
        float scale = 2.0F;
        GlStateManager.scale(scale, scale, scale);
        GlStateManager.translate(current.getScaledWidth() / 2F / scale - 90 / scale, (73) / scale, 0);
        GlStateManager.rotate(180, 0.0F, 0.0F, 1.0F);
        GlStateManager.translate(-16, -16, 0);
        drawScaledCustomSizeModalRect(0, 0, 0, 0, 64, 64, 16, 16, 64, 64);
        GlStateManager.popMatrix();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) HypixelApiGuild(club.sk1er.website.api.requests.HypixelApiGuild) StatsDisplayItem(cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem) DynamicTexture(net.minecraft.client.renderer.texture.DynamicTexture) GuiBlock(cc.hyperium.gui.GuiBlock)

Aggregations

GuiBlock (cc.hyperium.gui.GuiBlock)6 ScaledResolution (net.minecraft.client.gui.ScaledResolution)3 GuiBoxItem (cc.hyperium.gui.GuiBoxItem)2 StatsDisplayItem (cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem)2 HypixelApiFriendObject (club.sk1er.website.api.requests.HypixelApiFriendObject)2 HypixelApiGuild (club.sk1er.website.api.requests.HypixelApiGuild)2 DynamicTexture (net.minecraft.client.renderer.texture.DynamicTexture)2 Hyperium (cc.hyperium.Hyperium)1 HyperiumGui (cc.hyperium.gui.HyperiumGui)1 Icons (cc.hyperium.gui.Icons)1 GeneralChatHandler (cc.hyperium.handlers.handlers.chat.GeneralChatHandler)1 cc.hyperium.handlers.handlers.stats.fields (cc.hyperium.handlers.handlers.stats.fields)1 Multithreading (cc.hyperium.mods.sk1ercommon.Multithreading)1 ResolutionUtil (cc.hyperium.mods.sk1ercommon.ResolutionUtil)1 GlStateModifier (cc.hyperium.utils.GlStateModifier)1 RenderUtils (cc.hyperium.utils.RenderUtils)1 SimpleAnimValue (cc.hyperium.utils.SimpleAnimValue)1 HypixelApiPlayer (club.sk1er.website.api.requests.HypixelApiPlayer)1 java.awt (java.awt)1 BufferedImage (java.awt.image.BufferedImage)1