Search in sources :

Example 1 with GuiBlock

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

the class PurchaseCarousel method render.

public void render(int centerX, int centerY, int mouseX, int mouseY) {
    activeBlock = null;
    ScaledResolution current = ResolutionUtil.current();
    int totalWidth = current.getScaledWidth() / 3;
    int panel = totalWidth / 5;
    int mainWidth = panel * 3;
    int sideHeight = current.getScaledHeight() / 5 * 2;
    int mainHeight = current.getScaledHeight() / 5 * 3;
    int objLeft = centerX - mainWidth / 2;
    int objBottom = centerY + mainHeight / 2;
    int objRight = centerX + mainWidth / 2;
    if (index > 0) {
        // Draw left side
        RenderUtils.drawSmoothRect(centerX - panel * 2, centerY - sideHeight / 2, centerX, centerY + sideHeight / 2, 4, new Color(23, 23, 23, 100).getRGB());
    }
    if (index < items.length - 1) {
        RenderUtils.drawSmoothRect(centerX, centerY - sideHeight / 2, centerX + panel * 2, centerY + sideHeight / 2, 4, new Color(23, 23, 23, 100).getRGB());
    }
    RenderUtils.drawSmoothRect(objLeft, centerY - mainHeight / 2, objRight, objBottom, 10, new Color(23, 23, 23, 255).getRGB());
    CarouselItem item = items[index];
    GlStateManager.scale(.5, .5, .5);
    int barHeight = 16;
    fr.drawString(item.getName(), (objLeft + 5) * 2, (objBottom - 50) * 2, Color.WHITE.getRGB());
    int purchaseRight = (objLeft + 50) * 2;
    RenderUtils.drawSmoothRect((objLeft + 5) * 2, (objBottom - 20) * 2, purchaseRight, (objBottom - 20 + barHeight) * 2, 10, Color.WHITE.getRGB());
    GlStateManager.scale(2 / 3F, 2 / 3F, 2 / 3F);
    fr.drawString(item.isPurchased() ? I18n.format("gui.purchase.purchased") : I18n.format("gui.purchase.purchase"), (objLeft + 5) * 3, (objBottom - 18) * 3, new Color(23, 23, 23, 255).getRGB());
    GlStateManager.scale(3 / 2F, 3 / 2f, 3 / 2F);
    RenderUtils.drawFilledCircle(purchaseRight + barHeight * 2, (objBottom - 12) * 2, barHeight, Color.WHITE.getRGB());
    GlStateManager.color(0, 0, 0);
    Icons.SETTINGS.bind();
    Gui.drawScaledCustomSizeModalRect(purchaseRight + barHeight, (objBottom - 20) * 2, 0, 0, 144, 144, barHeight * 2, barHeight * 2, 144, 144);
    GlStateManager.scale(2.0, 2.0, 2.0);
    if (mouseX >= objLeft - 8 && mouseX <= objLeft && mouseY >= centerY - 5 && mouseY <= centerY + 5) {
        if (!lhover) {
            lhover = true;
            larrow = new SimpleAnimValue(500L, larrow.getValue(), 0.3f);
        }
    } else if (lhover) {
        lhover = false;
        larrow = new SimpleAnimValue(500L, larrow.getValue(), 0.5f);
    }
    float v = larrow.getValue();
    GlStateManager.scale(v, v, v);
    fr.drawCenteredString("<", (objLeft - 5) / v, centerY / v - 10, 0xffffff);
    GlStateManager.scale(1 / v, 1 / v, 1 / v);
    if (mouseX >= objRight && mouseX <= objRight + 8 && mouseY >= centerY - 5 && mouseY <= centerY + 5) {
        if (!rhover) {
            rhover = true;
            rarrow = new SimpleAnimValue(500L, rarrow.getValue(), 0.3f);
        }
    } else if (rhover) {
        rhover = false;
        rarrow = new SimpleAnimValue(500L, rarrow.getValue(), 0.5f);
    }
    v = rarrow.getValue();
    GlStateManager.scale(v, v, v);
    fr.drawCenteredString(">", (objRight + 5) / v, centerY / v - 10, 0xffffff);
    GlStateManager.scale(1 / v, 1 / v, 1 / v);
    String s = I18n.format("gui.purchase.state") + ": " + (getCurrent().isPurchased() ? (getCurrent().isActive() ? I18n.format("gui.purchase.active") : I18n.format("gui.purchase.inactive")) : I18n.format("gui.purchase.notpurchased"));
    float e = .5F;
    GlStateManager.scale(e, e, e);
    fr.drawString(s, (centerX - fr.getWidth(s) / 4) / e, (centerY - mainHeight / 2f + 15) / e, Color.GREEN.getRGB());
    if (getCurrent().isPurchased() && !getCurrent().isActive()) {
        s = I18n.format("gui.purchase.clicktouse");
        float width = fr.getWidth(s);
        float x = centerX - width / 4;
        int i = centerY - mainHeight / 2 + 35;
        activeBlock = new GuiBlock((int) x, (int) (x + width * 2), i, i + 10);
        fr.drawString(s, x / e, i / e, Color.GREEN.getRGB());
    }
    GlStateManager.scale(1 / e, 1 / e, 1 / e);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) SimpleAnimValue(cc.hyperium.utils.SimpleAnimValue) GuiBlock(cc.hyperium.gui.GuiBlock)

Example 2 with GuiBlock

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

the class HypixelFriendsGui method mouseClicked.

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    super.mouseClicked(mouseX, mouseY, mouseButton);
    textField.mouseClicked(mouseX, mouseY, mouseButton);
    selectedItem = null;
    GuiBoxItem<HypixelApiFriendObject> remove = null;
    for (GuiBoxItem<HypixelApiFriendObject> selectedBox : selectedBoxes) {
        if (selectedBox.getBox().isMouseOver(mouseX, mouseY)) {
            if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
                selected.remove(selectedBox.getObject());
                remove = selectedBox;
            } else
                selectedItem = selectedBox;
        }
    }
    if (remove != null) {
        selectedBoxes.remove(remove);
    }
    for (GuiBoxItem<HypixelApiFriendObject> selectedBox : friendListBoxes) {
        if (selectedBox.getBox().isMouseOver(mouseX, mouseY)) {
            if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
                if (selected.contains(selectedBox.getObject()))
                    continue;
                selected.add(selectedBox.getObject());
                GuiBoxItem<HypixelApiFriendObject> e = new GuiBoxItem<>(new GuiBlock(2 + 5, columnWidth + 5, topRenderBound + 1 + (selected.size()) * 11, topRenderBound + 1 + (selected.size() + 1) * 11), selectedBox.getObject());
                selectedBoxes.add(e);
                selectedItem = e;
            } else
                selectedItem = selectedBox;
        }
    }
}
Also used : GuiBoxItem(cc.hyperium.gui.GuiBoxItem) HypixelApiFriendObject(club.sk1er.website.api.requests.HypixelApiFriendObject) GuiBlock(cc.hyperium.gui.GuiBlock)

Example 3 with GuiBlock

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

the class GuiScreenEditKeys method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    super.drawDefaultBackground();
    delete.enabled = (selected != null);
    changeType.enabled = (selected != null);
    changeKey.enabled = (selected != null);
    if (selected != null) {
        GuiBlock hitbox = selected.getKey().getHitbox().multiply(mod.getSettings().getScale());
        drawRect(hitbox.getLeft(), hitbox.getTop(), hitbox.getRight(), hitbox.getBottom(), Color.WHITE.getRGB());
        mod.getSettings().setKeyBackgroundOpacity(120);
    }
    mod.getRenderer().renderKeystrokes();
    super.drawScreen(mouseX, mouseY, partialTicks);
    if (selected != null && Mouse.isButtonDown(0) && currentlyDragging == null && selected.getKey().getHitbox().multiply(mod.getSettings().getScale()).isMouseOver(mouseX, mouseY)) {
        currentlyDragging = selected;
    }
}
Also used : GuiBlock(cc.hyperium.gui.GuiBlock)

Example 4 with GuiBlock

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

the class HypixelFriendsGui method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    selectedBoxes.clear();
    friendListBoxes.clear();
    friends.removeIf(hypixelApiFriendObject -> !hypixelApiFriendObject.getDisplay().toLowerCase().contains(textField.getText().toLowerCase()));
    super.drawScreen(mouseX, mouseY, partialTicks);
    textField.drawTextBox();
    // Some long name
    final int bottomRenderBound = ResolutionUtil.current().getScaledHeight() / 9 * 8;
    if (selectedItem != null) {
        GuiBlock box = selectedItem.getBox();
        int left = box.getLeft() - 2;
        int right = box.getLeft() + fontRendererObj.getStringWidth(selectedItem.getObject().getDisplay()) + 2;
        int top = box.getTop() - 2;
        int bottom = top + 10;
        if (top >= topRenderBound && bottom <= bottomRenderBound) {
            Gui.drawRect(left, top, right, top + 1, Color.RED.getRGB());
            Gui.drawRect(left, bottom, right, bottom + 1, Color.RED.getRGB());
            Gui.drawRect(right, top, right - 1, bottom, Color.RED.getRGB());
            Gui.drawRect(left, top, left + 1, bottom, Color.RED.getRGB());
        }
    }
    GuiBlock namesBlock = new GuiBlock(2, columnWidth, topRenderBound, topRenderBound);
    int row = 1;
    namesBlock.drawString("Currently selected: ", fontRendererObj, false, true, namesBlock.getWidth() / 2, 1, true, true, Color.RED.getRGB(), true);
    for (HypixelApiFriendObject object : selected) {
        namesBlock.drawString(object.getDisplay(), fontRendererObj, false, false, 5, 1 + row * 11, true, true, Color.WHITE.getRGB(), true);
        selectedBoxes.add(new GuiBoxItem<>(new GuiBlock(2 + 5, namesBlock.getRight() + 5, namesBlock.getTop() + 1 + row * 11, namesBlock.getTop() + 1 + (row + 1) * 11), object));
        row++;
    }
    GuiBlock friendsBlock = new GuiBlock(namesBlock.getRight() + 15, ResolutionUtil.current().getScaledWidth() - 100, topRenderBound, bottomRenderBound);
    int drawX = friendsBlock.getLeft();
    int drawY = friendsBlock.getTop() - offset;
    if (drawY > bottomRenderBound) {
        offset = 0;
    }
    int cols = 1;
    while (drawX + columnWidth * cols < friendsBlock.getRight()) {
        cols++;
    }
    cols -= 1;
    if (cols <= 0)
        return;
    for (HypixelApiFriendObject object : friends.get()) {
        if (drawX + columnWidth > friendsBlock.getRight()) {
            drawX = friendsBlock.getLeft();
            drawY += 11;
        }
        if (selectedItem != null && selectedItem.getObject().equals(object) && !selected.contains(selectedItem.getObject())) {
            selectedItem = new GuiBoxItem<>(new GuiBlock(drawX, drawX + columnWidth, drawY + friendsBlock.getTop(), drawY + friendsBlock.getTop() + 11), object);
        }
        if (friendsBlock.drawString(object.getDisplay(), fontRendererObj, false, false, drawX - friendsBlock.getLeft(), drawY, false, false, Color.WHITE.getRGB(), true)) {
            GuiBoxItem<HypixelApiFriendObject> e = new GuiBoxItem<>(new GuiBlock(drawX, drawX + columnWidth, drawY + friendsBlock.getTop(), drawY + friendsBlock.getTop() + 11), object);
            friendListBoxes.add(e);
        }
        drawX += columnWidth;
    }
    // After first wave, if bottom of people is still not on screen, fix
    if (drawY < topRenderBound)
        offset = 0;
}
Also used : GuiBoxItem(cc.hyperium.gui.GuiBoxItem) HypixelApiFriendObject(club.sk1er.website.api.requests.HypixelApiFriendObject) GuiBlock(cc.hyperium.gui.GuiBlock)

Example 5 with GuiBlock

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

the class PlayerStatsGui method mouseClicked.

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    super.mouseClicked(mouseX, mouseY, mouseButton);
    boolean flag = false;
    for (GuiButton guiButton : buttonList) {
        if (guiButton.isMouseOver())
            flag = true;
    }
    boolean flag2 = focused == null;
    if (!flag && flag2)
        focused = null;
    ScaledResolution current = ResolutionUtil.current();
    if (focused != null && new GuiBlock((current.getScaledWidth() / 2 - 22 - 64), (current.getScaledWidth() / 2 - 22), 73, 73 + 64).isMouseOver(mouseX, mouseY)) {
        focused = null;
        offset = 0;
    }
    if (flag2 && mouseButton == 0) {
        location.keySet().stream().filter(abstractHypixelStats -> location.get(abstractHypixelStats).isMouseOver(mouseX, mouseY)).forEach(abstractHypixelStats -> {
            focused = abstractHypixelStats;
            hovered = null;
            offset = 0;
        });
    }
}
Also used : DynamicTexture(net.minecraft.client.renderer.texture.DynamicTexture) HttpURLConnection(java.net.HttpURLConnection) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) RenderUtils(cc.hyperium.utils.RenderUtils) HypixelApiGuild(club.sk1er.website.api.requests.HypixelApiGuild) HashMap(java.util.HashMap) cc.hyperium.handlers.handlers.stats.fields(cc.hyperium.handlers.handlers.stats.fields) ArrayList(java.util.ArrayList) HyperiumGui(cc.hyperium.gui.HyperiumGui) Multithreading(cc.hyperium.mods.sk1ercommon.Multithreading) Map(java.util.Map) ImageIO(javax.imageio.ImageIO) GlStateModifier(cc.hyperium.utils.GlStateModifier) Hyperium(cc.hyperium.Hyperium) HypixelApiPlayer(club.sk1er.website.api.requests.HypixelApiPlayer) Icons(cc.hyperium.gui.Icons) GeneralChatHandler(cc.hyperium.handlers.handlers.chat.GeneralChatHandler) ResolutionUtil(cc.hyperium.mods.sk1ercommon.ResolutionUtil) GuiButton(net.minecraft.client.gui.GuiButton) BufferedImage(java.awt.image.BufferedImage) ScaledResolution(net.minecraft.client.gui.ScaledResolution) StatsDisplayItem(cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem) GlStateManager(net.minecraft.client.renderer.GlStateManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IOException(java.io.IOException) GuiBlock(cc.hyperium.gui.GuiBlock) java.awt(java.awt) List(java.util.List) InputStream(java.io.InputStream) ScaledResolution(net.minecraft.client.gui.ScaledResolution) GuiButton(net.minecraft.client.gui.GuiButton) 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