Search in sources :

Example 1 with GuiBoxItem

use of cc.hyperium.gui.GuiBoxItem 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 2 with GuiBoxItem

use of cc.hyperium.gui.GuiBoxItem 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)

Aggregations

GuiBlock (cc.hyperium.gui.GuiBlock)2 GuiBoxItem (cc.hyperium.gui.GuiBoxItem)2 HypixelApiFriendObject (club.sk1er.website.api.requests.HypixelApiFriendObject)2