Исходник Old-style gui | EvaWare

Начинающий
Статус
Оффлайн
Регистрация
9 Авг 2024
Сообщения
21
Реакции[?]
0
Поинты[?]
0

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

Сливаю свою гуишку в старом стиле
1730466270418.png


ModuleComponent.java:
package hacks.dev.vzmah.ui.clickgui.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.modules.settings.Setting;
import hacks.dev.vzmah.modules.settings.impl.*;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.settings.*;
import hacks.dev.vzmah.utils.client.KeyStorage;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.Cursors;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Stencil;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.vector.Vector4f;
import org.lwjgl.glfw.GLFW;
import ru.hogoshi.Animation;
import ru.hogoshi.util.Easings;

[USER=270918]@Getter[/USER]
public class ModuleComponent extends Component {
    private final Vector4f ROUNDING_VECTOR = new Vector4f(5, 5, 5, 5);
    private final Vector4i BORDER_COLOR = new Vector4i(ColorUtils.rgb(82, 82, 82), ColorUtils.rgb(25, 26, 31), ColorUtils.rgb(45, 46, 53), ColorUtils.rgb(25, 26, 31));

    private final Module module;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

    private final ObjectArrayList<Component> components = new ObjectArrayList<>();

    public ModuleComponent(Module module) {
        this.module = module;
        for (Setting<?> setting : module.getSettings()) {
            if (setting instanceof BooleanSetting bool) {
                components.add(new BooleanComponent(bool));
            }
            if (setting instanceof SliderSetting slider) {
                components.add(new SliderComponent(slider));
            }
            if (setting instanceof BindSetting bind) {
                components.add(new BindComponent(bind));
            }
            if (setting instanceof ModeSetting mode) {
                components.add(new ModeComponent(mode));
            }
            if (setting instanceof ModeListSetting mode) {
                components.add(new MultiBoxComponent(mode));
            }
            if (setting instanceof StringSetting string) {
                components.add(new StringComponent(string));
            }

        }
        animation = animation.animate(open ? 1 : 0, 0.3);
    }

    // draw components
    public void drawComponents(MatrixStack stack, float mouseX, float mouseY) {
        if (animation.getValue() > 0) {
            if (animation.getValue() > 0.1 && components.stream().filter(Component::isVisible).count() >= 1) {
                DisplayUtils.drawRectVerticalW(getX() + 5, getY() + 20, getWidth() - 10, 0.5f, ColorUtils.rgb(42, 44, 50), ColorUtils.rgb(28, 28, 33));
            }
            Stencil.initStencilToWrite();
            DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(23, 23, 23, (int) (255 * 0.33)));
            Stencil.readStencilBuffer(1);
            float y = getY() + 20;
            for (Component component : components) {
                if (component.isVisible()) {
                    component.setX(getX());
                    component.setY(y);
                    component.setWidth(getWidth());
                    component.render(stack, mouseX, mouseY);
                    y += component.getHeight();
                }
            }
            Stencil.uninitStencilBuffer();

        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int mouse) {
        // TODO Auto-generated method stub

        for (Component component : components) {
            component.mouseRelease(mouseX, mouseY, mouse);
        }

        super.mouseRelease(mouseX, mouseY, mouse);
    }

    private boolean hovered = false;

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) module.getAnimation().getValue());

        module.getAnimation().update();
        super.render(stack, mouseX, mouseY);

        drawOutlinedRect(mouseX, mouseY, color);


        drawText(stack, color);
        drawComponents(stack, mouseX, mouseY);
    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) module.toggle();
            if (button == 1) {
                open = !open;
                animation = animation.animate(open ? 1 : 0, 0.2, Easings.CIRC_OUT);
            }
            if (button == 2) {
                bind = !bind;
            }
        }
        if (isHovered(mouseX, mouseY)) {
            if (open) {
                for (Component component : components) {
                    if (component.isVisible()) component.mouseClick(mouseX, mouseY, button);
                }
            }
        }
        super.mouseClick(mouseX, mouseY, button);
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.keyPressed(key, scanCode, modifiers);
        }
        if (bind) {
            if (key == GLFW.GLFW_KEY_DELETE) {
                module.setBind(0);
            } else module.setBind(key);
            bind = false;
        }
        super.keyPressed(key, scanCode, modifiers);
    }

    private void drawOutlinedRect(float mouseX, float mouseY, int color) {
        Stencil.initStencilToWrite();
        //   DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 255));

        Stencil.readStencilBuffer(0);
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, BORDER_COLOR);
        Stencil.uninitStencilBuffer();
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, new Vector4i(ColorUtils.rgba(0, 0, 0, 127), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110)));
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 64));

        if (MathUtil.isHovered(mouseX, mouseY, getX(), getY(), getWidth(), 20)) {
            if (!hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.HAND);
                hovered = true;
            }
        } else {
            if (hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.ARROW);
                hovered = false;
            }
        }

    }

    private void drawText(MatrixStack stack, int color) {
        DisplayUtils.drawShadow(getX() + 6, getY() + 6.5f, Fonts.sfui.getWidth(module.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * module.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, module.getName(), getX() + 6, getY() + 6.5f, ColorUtils.rgba(255,255,255,155), 7, 0.1f);
        if (components.stream().filter(Component::isVisible).count() >= 1) {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            } else
                Fonts.icons.drawText(stack, !open ? "B" : "C", getX() + getWidth() - 6 - Fonts.icons.getWidth(!open ? "B" : "C", 6), getY() + Fonts.icons.getHeight(6) + 1, ColorUtils.rgb(161, 164, 177), 6);
        } else {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}

Panel.java:
package hacks.dev.vzmah.ui.clickgui;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.Vzmah;
import hacks.dev.vzmah.modules.api.Category;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.ui.clickgui.components.builder.IBuilder;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.ModuleComponent;
import hacks.dev.vzmah.ui.themes.Theme;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Scissor;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import hacks.dev.vzmah.utils.text.font.ClientFonts;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector4f;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

[USER=270918]@Getter[/USER]
[USER=1132491]@setter[/USER]
public class Panel implements IBuilder {

    private final Category category;
    protected float x;
    protected float y;
    protected final float width = 120;
    protected float height;

    private List<ModuleComponent> modules = new ArrayList<>();
    private float scroll, animatedScrool;

    public Panel(Category category) {
        this.category = category;

        for (Module module : Vzmah.getInstance().getModuleManager().getModules()) {
            if (module.getCategory() == category) {
                ModuleComponent component = new ModuleComponent(module);
                component.setPanel(this);
                modules.add(component);
            }
        }

        updateHeight();
    }

    public void updateHeight() {
        float dynamicHeight = 20;

        for (ModuleComponent component : modules) {
            if (component.isOpen()) {
                dynamicHeight += component.getHeight() + 0.5f;
            }
        }

        dynamicHeight += 10;
        this.height = Math.max(25f, dynamicHeight);
    }

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {

        animatedScrool = MathUtil.fast(animatedScrool, scroll, 10);
        float headerFont = 9;

        updateHeight();

        float dynamicHeight = 20;
        for (ModuleComponent component : modules) {
            dynamicHeight += component.getHeight() + 0.5f;
        }
        dynamicHeight += 10;
        height = Math.max(height, dynamicHeight);
        int oc = new Color(12,14,29,225).darker().getRGB();
        DisplayUtils.drawShadow(x - 1, y - 1, width + 2, height + 2, 25, oc);
        DisplayUtils.drawRoundedRect(x, y, width, height, 1, new Color(12,14,29,200).getRGB(), new Vector4f(4, 4, 4, 4), new Vector4i(oc, oc, oc, oc));
        Fonts.montserrat.drawCenteredText(stack, category.name(), x + width / 2f, y + 11 - Fonts.montserrat.getHeight(headerFont) / 2f, ColorUtils.rgb(255, 255, 255), headerFont, 0.1f);
        drawComponents(stack, mouseX, mouseY);
    }

    float max = 0;

    private void drawComponents(MatrixStack stack, float mouseX, float mouseY) {

        float animationValue = (float) DropDown.getAnimation().getValue() * DropDown.scale;

        float halfAnimationValueRest = (1 - animationValue) / 2f;
        float height = getHeight();
        float testX = getX() + (getWidth() * halfAnimationValueRest);
        float testY = getY() + (height * halfAnimationValueRest);
        float testW = getWidth() * animationValue;
        float testH = height * animationValue;

        testX = testX * animationValue + ((Minecraft.getInstance().getMainWindow().getScaledWidth() - testW) * halfAnimationValueRest);

        Scissor.push();
        Scissor.setFromComponentCoordinates(testX, testY, testW, testH);
        float offset = -1;
        float header = 25;

        if (max > height - header - 10) {
            scroll = MathHelper.clamp(scroll, -max + height - header - 10, 0);
            animatedScrool = MathHelper.clamp(animatedScrool, -max + height - header - 10, 0);
        } else {
            scroll = 0;
            animatedScrool = 0;
        }

        for (ModuleComponent component : modules) {
            component.setX(getX() + 2);
            component.setY(getY() + header + offset + 3 + animatedScrool);
            component.setWidth(getWidth() - 4);
            component.setHeight(20);
            component.animation.update();
            if (component.animation.getValue() > 0) {
                float componentOffset = 0;
                for (Component component2 : component.getComponents()) {
                    if (component2.isVisible())
                        componentOffset += component2.getHeight();
                }
                componentOffset *= component.animation.getValue();
                component.setHeight(component.getHeight() + componentOffset);
            }
            component.render(stack, mouseX, mouseY);
            offset += component.getHeight() + 0.5f;
        }
        max = offset;

        Scissor.unset();
        Scissor.pop();

    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseClick(mouseX, mouseY, button);
        }
    }


    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (ModuleComponent component : modules) {
            component.keyPressed(key, scanCode, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (ModuleComponent component : modules) {
            component.charTyped(codePoint, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseRelease(mouseX, mouseY, button);
        }
    }
}
 
Начинающий
Статус
Онлайн
Регистрация
26 Янв 2023
Сообщения
259
Реакции[?]
1
Поинты[?]
1K
Сливаю свою гуишку в старом стиле
Посмотреть вложение 289235


ModuleComponent.java:
package hacks.dev.vzmah.ui.clickgui.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.modules.settings.Setting;
import hacks.dev.vzmah.modules.settings.impl.*;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.settings.*;
import hacks.dev.vzmah.utils.client.KeyStorage;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.Cursors;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Stencil;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.vector.Vector4f;
import org.lwjgl.glfw.GLFW;
import ru.hogoshi.Animation;
import ru.hogoshi.util.Easings;

[USER=270918]@Getter[/USER]
public class ModuleComponent extends Component {
    private final Vector4f ROUNDING_VECTOR = new Vector4f(5, 5, 5, 5);
    private final Vector4i BORDER_COLOR = new Vector4i(ColorUtils.rgb(82, 82, 82), ColorUtils.rgb(25, 26, 31), ColorUtils.rgb(45, 46, 53), ColorUtils.rgb(25, 26, 31));

    private final Module module;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

    private final ObjectArrayList<Component> components = new ObjectArrayList<>();

    public ModuleComponent(Module module) {
        this.module = module;
        for (Setting<?> setting : module.getSettings()) {
            if (setting instanceof BooleanSetting bool) {
                components.add(new BooleanComponent(bool));
            }
            if (setting instanceof SliderSetting slider) {
                components.add(new SliderComponent(slider));
            }
            if (setting instanceof BindSetting bind) {
                components.add(new BindComponent(bind));
            }
            if (setting instanceof ModeSetting mode) {
                components.add(new ModeComponent(mode));
            }
            if (setting instanceof ModeListSetting mode) {
                components.add(new MultiBoxComponent(mode));
            }
            if (setting instanceof StringSetting string) {
                components.add(new StringComponent(string));
            }

        }
        animation = animation.animate(open ? 1 : 0, 0.3);
    }

    // draw components
    public void drawComponents(MatrixStack stack, float mouseX, float mouseY) {
        if (animation.getValue() > 0) {
            if (animation.getValue() > 0.1 && components.stream().filter(Component::isVisible).count() >= 1) {
                DisplayUtils.drawRectVerticalW(getX() + 5, getY() + 20, getWidth() - 10, 0.5f, ColorUtils.rgb(42, 44, 50), ColorUtils.rgb(28, 28, 33));
            }
            Stencil.initStencilToWrite();
            DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(23, 23, 23, (int) (255 * 0.33)));
            Stencil.readStencilBuffer(1);
            float y = getY() + 20;
            for (Component component : components) {
                if (component.isVisible()) {
                    component.setX(getX());
                    component.setY(y);
                    component.setWidth(getWidth());
                    component.render(stack, mouseX, mouseY);
                    y += component.getHeight();
                }
            }
            Stencil.uninitStencilBuffer();

        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int mouse) {
        // TODO Auto-generated method stub

        for (Component component : components) {
            component.mouseRelease(mouseX, mouseY, mouse);
        }

        super.mouseRelease(mouseX, mouseY, mouse);
    }

    private boolean hovered = false;

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) module.getAnimation().getValue());

        module.getAnimation().update();
        super.render(stack, mouseX, mouseY);

        drawOutlinedRect(mouseX, mouseY, color);


        drawText(stack, color);
        drawComponents(stack, mouseX, mouseY);
    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) module.toggle();
            if (button == 1) {
                open = !open;
                animation = animation.animate(open ? 1 : 0, 0.2, Easings.CIRC_OUT);
            }
            if (button == 2) {
                bind = !bind;
            }
        }
        if (isHovered(mouseX, mouseY)) {
            if (open) {
                for (Component component : components) {
                    if (component.isVisible()) component.mouseClick(mouseX, mouseY, button);
                }
            }
        }
        super.mouseClick(mouseX, mouseY, button);
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.keyPressed(key, scanCode, modifiers);
        }
        if (bind) {
            if (key == GLFW.GLFW_KEY_DELETE) {
                module.setBind(0);
            } else module.setBind(key);
            bind = false;
        }
        super.keyPressed(key, scanCode, modifiers);
    }

    private void drawOutlinedRect(float mouseX, float mouseY, int color) {
        Stencil.initStencilToWrite();
        //   DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 255));

        Stencil.readStencilBuffer(0);
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, BORDER_COLOR);
        Stencil.uninitStencilBuffer();
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, new Vector4i(ColorUtils.rgba(0, 0, 0, 127), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110)));
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 64));

        if (MathUtil.isHovered(mouseX, mouseY, getX(), getY(), getWidth(), 20)) {
            if (!hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.HAND);
                hovered = true;
            }
        } else {
            if (hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.ARROW);
                hovered = false;
            }
        }

    }

    private void drawText(MatrixStack stack, int color) {
        DisplayUtils.drawShadow(getX() + 6, getY() + 6.5f, Fonts.sfui.getWidth(module.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * module.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, module.getName(), getX() + 6, getY() + 6.5f, ColorUtils.rgba(255,255,255,155), 7, 0.1f);
        if (components.stream().filter(Component::isVisible).count() >= 1) {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            } else
                Fonts.icons.drawText(stack, !open ? "B" : "C", getX() + getWidth() - 6 - Fonts.icons.getWidth(!open ? "B" : "C", 6), getY() + Fonts.icons.getHeight(6) + 1, ColorUtils.rgb(161, 164, 177), 6);
        } else {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}

Panel.java:
package hacks.dev.vzmah.ui.clickgui;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.Vzmah;
import hacks.dev.vzmah.modules.api.Category;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.ui.clickgui.components.builder.IBuilder;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.ModuleComponent;
import hacks.dev.vzmah.ui.themes.Theme;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Scissor;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import hacks.dev.vzmah.utils.text.font.ClientFonts;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector4f;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

[USER=270918]@Getter[/USER]
[USER=1132491]@setter[/USER]
public class Panel implements IBuilder {

    private final Category category;
    protected float x;
    protected float y;
    protected final float width = 120;
    protected float height;

    private List<ModuleComponent> modules = new ArrayList<>();
    private float scroll, animatedScrool;

    public Panel(Category category) {
        this.category = category;

        for (Module module : Vzmah.getInstance().getModuleManager().getModules()) {
            if (module.getCategory() == category) {
                ModuleComponent component = new ModuleComponent(module);
                component.setPanel(this);
                modules.add(component);
            }
        }

        updateHeight();
    }

    public void updateHeight() {
        float dynamicHeight = 20;

        for (ModuleComponent component : modules) {
            if (component.isOpen()) {
                dynamicHeight += component.getHeight() + 0.5f;
            }
        }

        dynamicHeight += 10;
        this.height = Math.max(25f, dynamicHeight);
    }

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {

        animatedScrool = MathUtil.fast(animatedScrool, scroll, 10);
        float headerFont = 9;

        updateHeight();

        float dynamicHeight = 20;
        for (ModuleComponent component : modules) {
            dynamicHeight += component.getHeight() + 0.5f;
        }
        dynamicHeight += 10;
        height = Math.max(height, dynamicHeight);
        int oc = new Color(12,14,29,225).darker().getRGB();
        DisplayUtils.drawShadow(x - 1, y - 1, width + 2, height + 2, 25, oc);
        DisplayUtils.drawRoundedRect(x, y, width, height, 1, new Color(12,14,29,200).getRGB(), new Vector4f(4, 4, 4, 4), new Vector4i(oc, oc, oc, oc));
        Fonts.montserrat.drawCenteredText(stack, category.name(), x + width / 2f, y + 11 - Fonts.montserrat.getHeight(headerFont) / 2f, ColorUtils.rgb(255, 255, 255), headerFont, 0.1f);
        drawComponents(stack, mouseX, mouseY);
    }

    float max = 0;

    private void drawComponents(MatrixStack stack, float mouseX, float mouseY) {

        float animationValue = (float) DropDown.getAnimation().getValue() * DropDown.scale;

        float halfAnimationValueRest = (1 - animationValue) / 2f;
        float height = getHeight();
        float testX = getX() + (getWidth() * halfAnimationValueRest);
        float testY = getY() + (height * halfAnimationValueRest);
        float testW = getWidth() * animationValue;
        float testH = height * animationValue;

        testX = testX * animationValue + ((Minecraft.getInstance().getMainWindow().getScaledWidth() - testW) * halfAnimationValueRest);

        Scissor.push();
        Scissor.setFromComponentCoordinates(testX, testY, testW, testH);
        float offset = -1;
        float header = 25;

        if (max > height - header - 10) {
            scroll = MathHelper.clamp(scroll, -max + height - header - 10, 0);
            animatedScrool = MathHelper.clamp(animatedScrool, -max + height - header - 10, 0);
        } else {
            scroll = 0;
            animatedScrool = 0;
        }

        for (ModuleComponent component : modules) {
            component.setX(getX() + 2);
            component.setY(getY() + header + offset + 3 + animatedScrool);
            component.setWidth(getWidth() - 4);
            component.setHeight(20);
            component.animation.update();
            if (component.animation.getValue() > 0) {
                float componentOffset = 0;
                for (Component component2 : component.getComponents()) {
                    if (component2.isVisible())
                        componentOffset += component2.getHeight();
                }
                componentOffset *= component.animation.getValue();
                component.setHeight(component.getHeight() + componentOffset);
            }
            component.render(stack, mouseX, mouseY);
            offset += component.getHeight() + 0.5f;
        }
        max = offset;

        Scissor.unset();
        Scissor.pop();

    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseClick(mouseX, mouseY, button);
        }
    }


    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (ModuleComponent component : modules) {
            component.keyPressed(key, scanCode, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (ModuleComponent component : modules) {
            component.charTyped(codePoint, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseRelease(mouseX, mouseY, button);
        }
    }
}
Говно
 
Начинающий
Статус
Оффлайн
Регистрация
30 Окт 2024
Сообщения
63
Реакции[?]
0
Поинты[?]
0
а в чем прикол етава я чот ну в тх красивее даж
 
Начинающий
Статус
Оффлайн
Регистрация
22 Май 2023
Сообщения
92
Реакции[?]
0
Поинты[?]
0
Сливаю свою гуишку в старом стиле
Посмотреть вложение 289235


ModuleComponent.java:
package hacks.dev.vzmah.ui.clickgui.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.modules.settings.Setting;
import hacks.dev.vzmah.modules.settings.impl.*;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.settings.*;
import hacks.dev.vzmah.utils.client.KeyStorage;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.Cursors;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Stencil;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.vector.Vector4f;
import org.lwjgl.glfw.GLFW;
import ru.hogoshi.Animation;
import ru.hogoshi.util.Easings;

[USER=270918]@Getter[/USER]
public class ModuleComponent extends Component {
    private final Vector4f ROUNDING_VECTOR = new Vector4f(5, 5, 5, 5);
    private final Vector4i BORDER_COLOR = new Vector4i(ColorUtils.rgb(82, 82, 82), ColorUtils.rgb(25, 26, 31), ColorUtils.rgb(45, 46, 53), ColorUtils.rgb(25, 26, 31));

    private final Module module;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

    private final ObjectArrayList<Component> components = new ObjectArrayList<>();

    public ModuleComponent(Module module) {
        this.module = module;
        for (Setting<?> setting : module.getSettings()) {
            if (setting instanceof BooleanSetting bool) {
                components.add(new BooleanComponent(bool));
            }
            if (setting instanceof SliderSetting slider) {
                components.add(new SliderComponent(slider));
            }
            if (setting instanceof BindSetting bind) {
                components.add(new BindComponent(bind));
            }
            if (setting instanceof ModeSetting mode) {
                components.add(new ModeComponent(mode));
            }
            if (setting instanceof ModeListSetting mode) {
                components.add(new MultiBoxComponent(mode));
            }
            if (setting instanceof StringSetting string) {
                components.add(new StringComponent(string));
            }

        }
        animation = animation.animate(open ? 1 : 0, 0.3);
    }

    // draw components
    public void drawComponents(MatrixStack stack, float mouseX, float mouseY) {
        if (animation.getValue() > 0) {
            if (animation.getValue() > 0.1 && components.stream().filter(Component::isVisible).count() >= 1) {
                DisplayUtils.drawRectVerticalW(getX() + 5, getY() + 20, getWidth() - 10, 0.5f, ColorUtils.rgb(42, 44, 50), ColorUtils.rgb(28, 28, 33));
            }
            Stencil.initStencilToWrite();
            DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(23, 23, 23, (int) (255 * 0.33)));
            Stencil.readStencilBuffer(1);
            float y = getY() + 20;
            for (Component component : components) {
                if (component.isVisible()) {
                    component.setX(getX());
                    component.setY(y);
                    component.setWidth(getWidth());
                    component.render(stack, mouseX, mouseY);
                    y += component.getHeight();
                }
            }
            Stencil.uninitStencilBuffer();

        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int mouse) {
        // TODO Auto-generated method stub

        for (Component component : components) {
            component.mouseRelease(mouseX, mouseY, mouse);
        }

        super.mouseRelease(mouseX, mouseY, mouse);
    }

    private boolean hovered = false;

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) module.getAnimation().getValue());

        module.getAnimation().update();
        super.render(stack, mouseX, mouseY);

        drawOutlinedRect(mouseX, mouseY, color);


        drawText(stack, color);
        drawComponents(stack, mouseX, mouseY);
    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) module.toggle();
            if (button == 1) {
                open = !open;
                animation = animation.animate(open ? 1 : 0, 0.2, Easings.CIRC_OUT);
            }
            if (button == 2) {
                bind = !bind;
            }
        }
        if (isHovered(mouseX, mouseY)) {
            if (open) {
                for (Component component : components) {
                    if (component.isVisible()) component.mouseClick(mouseX, mouseY, button);
                }
            }
        }
        super.mouseClick(mouseX, mouseY, button);
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.keyPressed(key, scanCode, modifiers);
        }
        if (bind) {
            if (key == GLFW.GLFW_KEY_DELETE) {
                module.setBind(0);
            } else module.setBind(key);
            bind = false;
        }
        super.keyPressed(key, scanCode, modifiers);
    }

    private void drawOutlinedRect(float mouseX, float mouseY, int color) {
        Stencil.initStencilToWrite();
        //   DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 255));

        Stencil.readStencilBuffer(0);
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, BORDER_COLOR);
        Stencil.uninitStencilBuffer();
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, new Vector4i(ColorUtils.rgba(0, 0, 0, 127), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110)));
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 64));

        if (MathUtil.isHovered(mouseX, mouseY, getX(), getY(), getWidth(), 20)) {
            if (!hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.HAND);
                hovered = true;
            }
        } else {
            if (hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.ARROW);
                hovered = false;
            }
        }

    }

    private void drawText(MatrixStack stack, int color) {
        DisplayUtils.drawShadow(getX() + 6, getY() + 6.5f, Fonts.sfui.getWidth(module.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * module.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, module.getName(), getX() + 6, getY() + 6.5f, ColorUtils.rgba(255,255,255,155), 7, 0.1f);
        if (components.stream().filter(Component::isVisible).count() >= 1) {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            } else
                Fonts.icons.drawText(stack, !open ? "B" : "C", getX() + getWidth() - 6 - Fonts.icons.getWidth(!open ? "B" : "C", 6), getY() + Fonts.icons.getHeight(6) + 1, ColorUtils.rgb(161, 164, 177), 6);
        } else {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}

Panel.java:
package hacks.dev.vzmah.ui.clickgui;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.Vzmah;
import hacks.dev.vzmah.modules.api.Category;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.ui.clickgui.components.builder.IBuilder;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.ModuleComponent;
import hacks.dev.vzmah.ui.themes.Theme;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Scissor;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import hacks.dev.vzmah.utils.text.font.ClientFonts;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector4f;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

[USER=270918]@Getter[/USER]
[USER=1132491]@setter[/USER]
public class Panel implements IBuilder {

    private final Category category;
    protected float x;
    protected float y;
    protected final float width = 120;
    protected float height;

    private List<ModuleComponent> modules = new ArrayList<>();
    private float scroll, animatedScrool;

    public Panel(Category category) {
        this.category = category;

        for (Module module : Vzmah.getInstance().getModuleManager().getModules()) {
            if (module.getCategory() == category) {
                ModuleComponent component = new ModuleComponent(module);
                component.setPanel(this);
                modules.add(component);
            }
        }

        updateHeight();
    }

    public void updateHeight() {
        float dynamicHeight = 20;

        for (ModuleComponent component : modules) {
            if (component.isOpen()) {
                dynamicHeight += component.getHeight() + 0.5f;
            }
        }

        dynamicHeight += 10;
        this.height = Math.max(25f, dynamicHeight);
    }

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {

        animatedScrool = MathUtil.fast(animatedScrool, scroll, 10);
        float headerFont = 9;

        updateHeight();

        float dynamicHeight = 20;
        for (ModuleComponent component : modules) {
            dynamicHeight += component.getHeight() + 0.5f;
        }
        dynamicHeight += 10;
        height = Math.max(height, dynamicHeight);
        int oc = new Color(12,14,29,225).darker().getRGB();
        DisplayUtils.drawShadow(x - 1, y - 1, width + 2, height + 2, 25, oc);
        DisplayUtils.drawRoundedRect(x, y, width, height, 1, new Color(12,14,29,200).getRGB(), new Vector4f(4, 4, 4, 4), new Vector4i(oc, oc, oc, oc));
        Fonts.montserrat.drawCenteredText(stack, category.name(), x + width / 2f, y + 11 - Fonts.montserrat.getHeight(headerFont) / 2f, ColorUtils.rgb(255, 255, 255), headerFont, 0.1f);
        drawComponents(stack, mouseX, mouseY);
    }

    float max = 0;

    private void drawComponents(MatrixStack stack, float mouseX, float mouseY) {

        float animationValue = (float) DropDown.getAnimation().getValue() * DropDown.scale;

        float halfAnimationValueRest = (1 - animationValue) / 2f;
        float height = getHeight();
        float testX = getX() + (getWidth() * halfAnimationValueRest);
        float testY = getY() + (height * halfAnimationValueRest);
        float testW = getWidth() * animationValue;
        float testH = height * animationValue;

        testX = testX * animationValue + ((Minecraft.getInstance().getMainWindow().getScaledWidth() - testW) * halfAnimationValueRest);

        Scissor.push();
        Scissor.setFromComponentCoordinates(testX, testY, testW, testH);
        float offset = -1;
        float header = 25;

        if (max > height - header - 10) {
            scroll = MathHelper.clamp(scroll, -max + height - header - 10, 0);
            animatedScrool = MathHelper.clamp(animatedScrool, -max + height - header - 10, 0);
        } else {
            scroll = 0;
            animatedScrool = 0;
        }

        for (ModuleComponent component : modules) {
            component.setX(getX() + 2);
            component.setY(getY() + header + offset + 3 + animatedScrool);
            component.setWidth(getWidth() - 4);
            component.setHeight(20);
            component.animation.update();
            if (component.animation.getValue() > 0) {
                float componentOffset = 0;
                for (Component component2 : component.getComponents()) {
                    if (component2.isVisible())
                        componentOffset += component2.getHeight();
                }
                componentOffset *= component.animation.getValue();
                component.setHeight(component.getHeight() + componentOffset);
            }
            component.render(stack, mouseX, mouseY);
            offset += component.getHeight() + 0.5f;
        }
        max = offset;

        Scissor.unset();
        Scissor.pop();

    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseClick(mouseX, mouseY, button);
        }
    }


    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (ModuleComponent component : modules) {
            component.keyPressed(key, scanCode, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (ModuleComponent component : modules) {
            component.charTyped(codePoint, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseRelease(mouseX, mouseY, button);
        }
    }
}
щас переделаю пусть будет похож на арбуз
 
Забаненный
Статус
Оффлайн
Регистрация
26 Окт 2024
Сообщения
125
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Начинающий
Статус
Онлайн
Регистрация
26 Дек 2023
Сообщения
496
Реакции[?]
2
Поинты[?]
1K
Сливаю свою гуишку в старом стиле
Посмотреть вложение 289235


ModuleComponent.java:
package hacks.dev.vzmah.ui.clickgui.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.modules.settings.Setting;
import hacks.dev.vzmah.modules.settings.impl.*;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.settings.*;
import hacks.dev.vzmah.utils.client.KeyStorage;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.Cursors;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Stencil;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.vector.Vector4f;
import org.lwjgl.glfw.GLFW;
import ru.hogoshi.Animation;
import ru.hogoshi.util.Easings;

[USER=270918]@Getter[/USER]
public class ModuleComponent extends Component {
    private final Vector4f ROUNDING_VECTOR = new Vector4f(5, 5, 5, 5);
    private final Vector4i BORDER_COLOR = new Vector4i(ColorUtils.rgb(82, 82, 82), ColorUtils.rgb(25, 26, 31), ColorUtils.rgb(45, 46, 53), ColorUtils.rgb(25, 26, 31));

    private final Module module;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

    private final ObjectArrayList<Component> components = new ObjectArrayList<>();

    public ModuleComponent(Module module) {
        this.module = module;
        for (Setting<?> setting : module.getSettings()) {
            if (setting instanceof BooleanSetting bool) {
                components.add(new BooleanComponent(bool));
            }
            if (setting instanceof SliderSetting slider) {
                components.add(new SliderComponent(slider));
            }
            if (setting instanceof BindSetting bind) {
                components.add(new BindComponent(bind));
            }
            if (setting instanceof ModeSetting mode) {
                components.add(new ModeComponent(mode));
            }
            if (setting instanceof ModeListSetting mode) {
                components.add(new MultiBoxComponent(mode));
            }
            if (setting instanceof StringSetting string) {
                components.add(new StringComponent(string));
            }

        }
        animation = animation.animate(open ? 1 : 0, 0.3);
    }

    // draw components
    public void drawComponents(MatrixStack stack, float mouseX, float mouseY) {
        if (animation.getValue() > 0) {
            if (animation.getValue() > 0.1 && components.stream().filter(Component::isVisible).count() >= 1) {
                DisplayUtils.drawRectVerticalW(getX() + 5, getY() + 20, getWidth() - 10, 0.5f, ColorUtils.rgb(42, 44, 50), ColorUtils.rgb(28, 28, 33));
            }
            Stencil.initStencilToWrite();
            DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(23, 23, 23, (int) (255 * 0.33)));
            Stencil.readStencilBuffer(1);
            float y = getY() + 20;
            for (Component component : components) {
                if (component.isVisible()) {
                    component.setX(getX());
                    component.setY(y);
                    component.setWidth(getWidth());
                    component.render(stack, mouseX, mouseY);
                    y += component.getHeight();
                }
            }
            Stencil.uninitStencilBuffer();

        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int mouse) {
        // TODO Auto-generated method stub

        for (Component component : components) {
            component.mouseRelease(mouseX, mouseY, mouse);
        }

        super.mouseRelease(mouseX, mouseY, mouse);
    }

    private boolean hovered = false;

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) module.getAnimation().getValue());

        module.getAnimation().update();
        super.render(stack, mouseX, mouseY);

        drawOutlinedRect(mouseX, mouseY, color);


        drawText(stack, color);
        drawComponents(stack, mouseX, mouseY);
    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) module.toggle();
            if (button == 1) {
                open = !open;
                animation = animation.animate(open ? 1 : 0, 0.2, Easings.CIRC_OUT);
            }
            if (button == 2) {
                bind = !bind;
            }
        }
        if (isHovered(mouseX, mouseY)) {
            if (open) {
                for (Component component : components) {
                    if (component.isVisible()) component.mouseClick(mouseX, mouseY, button);
                }
            }
        }
        super.mouseClick(mouseX, mouseY, button);
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.keyPressed(key, scanCode, modifiers);
        }
        if (bind) {
            if (key == GLFW.GLFW_KEY_DELETE) {
                module.setBind(0);
            } else module.setBind(key);
            bind = false;
        }
        super.keyPressed(key, scanCode, modifiers);
    }

    private void drawOutlinedRect(float mouseX, float mouseY, int color) {
        Stencil.initStencilToWrite();
        //   DisplayUtils.drawRoundedRect(getX() + 0.5f, getY() + 0.5f, getWidth() - 1, getHeight() - 1, ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 255));

        Stencil.readStencilBuffer(0);
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, BORDER_COLOR);
        Stencil.uninitStencilBuffer();
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, new Vector4i(ColorUtils.rgba(0, 0, 0, 127), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110), ColorUtils.rgba(30, 30, 30, 110)));
        DisplayUtils.drawRoundedRect(getX(), getY(), getWidth(), getHeight(), ROUNDING_VECTOR, ColorUtils.rgba(0, 0, 0, 64));

        if (MathUtil.isHovered(mouseX, mouseY, getX(), getY(), getWidth(), 20)) {
            if (!hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.HAND);
                hovered = true;
            }
        } else {
            if (hovered) {
                GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.ARROW);
                hovered = false;
            }
        }

    }

    private void drawText(MatrixStack stack, int color) {
        DisplayUtils.drawShadow(getX() + 6, getY() + 6.5f, Fonts.sfui.getWidth(module.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * module.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, module.getName(), getX() + 6, getY() + 6.5f, ColorUtils.rgba(255,255,255,155), 7, 0.1f);
        if (components.stream().filter(Component::isVisible).count() >= 1) {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            } else
                Fonts.icons.drawText(stack, !open ? "B" : "C", getX() + getWidth() - 6 - Fonts.icons.getWidth(!open ? "B" : "C", 6), getY() + Fonts.icons.getHeight(6) + 1, ColorUtils.rgb(161, 164, 177), 6);
        } else {
            if (bind) {
                Fonts.sfui.drawText(stack, module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(module.getBind() == 0 ? "..." : KeyStorage.getReverseKey(module.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}

Panel.java:
package hacks.dev.vzmah.ui.clickgui;

import com.mojang.blaze3d.matrix.MatrixStack;
import hacks.dev.vzmah.Vzmah;
import hacks.dev.vzmah.modules.api.Category;
import hacks.dev.vzmah.modules.api.Module;
import hacks.dev.vzmah.ui.clickgui.components.builder.IBuilder;
import hacks.dev.vzmah.ui.clickgui.components.builder.Component;
import hacks.dev.vzmah.ui.clickgui.components.ModuleComponent;
import hacks.dev.vzmah.ui.themes.Theme;
import hacks.dev.vzmah.utils.math.MathUtil;
import hacks.dev.vzmah.utils.math.Vector4i;
import hacks.dev.vzmah.utils.render.color.ColorUtils;
import hacks.dev.vzmah.utils.render.font.Fonts;
import hacks.dev.vzmah.utils.render.gl.Scissor;
import hacks.dev.vzmah.utils.render.rect.DisplayUtils;
import hacks.dev.vzmah.utils.text.font.ClientFonts;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector4f;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

[USER=270918]@Getter[/USER]
[USER=1132491]@setter[/USER]
public class Panel implements IBuilder {

    private final Category category;
    protected float x;
    protected float y;
    protected final float width = 120;
    protected float height;

    private List<ModuleComponent> modules = new ArrayList<>();
    private float scroll, animatedScrool;

    public Panel(Category category) {
        this.category = category;

        for (Module module : Vzmah.getInstance().getModuleManager().getModules()) {
            if (module.getCategory() == category) {
                ModuleComponent component = new ModuleComponent(module);
                component.setPanel(this);
                modules.add(component);
            }
        }

        updateHeight();
    }

    public void updateHeight() {
        float dynamicHeight = 20;

        for (ModuleComponent component : modules) {
            if (component.isOpen()) {
                dynamicHeight += component.getHeight() + 0.5f;
            }
        }

        dynamicHeight += 10;
        this.height = Math.max(25f, dynamicHeight);
    }

    [USER=1367676]@override[/USER]
    public void render(MatrixStack stack, float mouseX, float mouseY) {

        animatedScrool = MathUtil.fast(animatedScrool, scroll, 10);
        float headerFont = 9;

        updateHeight();

        float dynamicHeight = 20;
        for (ModuleComponent component : modules) {
            dynamicHeight += component.getHeight() + 0.5f;
        }
        dynamicHeight += 10;
        height = Math.max(height, dynamicHeight);
        int oc = new Color(12,14,29,225).darker().getRGB();
        DisplayUtils.drawShadow(x - 1, y - 1, width + 2, height + 2, 25, oc);
        DisplayUtils.drawRoundedRect(x, y, width, height, 1, new Color(12,14,29,200).getRGB(), new Vector4f(4, 4, 4, 4), new Vector4i(oc, oc, oc, oc));
        Fonts.montserrat.drawCenteredText(stack, category.name(), x + width / 2f, y + 11 - Fonts.montserrat.getHeight(headerFont) / 2f, ColorUtils.rgb(255, 255, 255), headerFont, 0.1f);
        drawComponents(stack, mouseX, mouseY);
    }

    float max = 0;

    private void drawComponents(MatrixStack stack, float mouseX, float mouseY) {

        float animationValue = (float) DropDown.getAnimation().getValue() * DropDown.scale;

        float halfAnimationValueRest = (1 - animationValue) / 2f;
        float height = getHeight();
        float testX = getX() + (getWidth() * halfAnimationValueRest);
        float testY = getY() + (height * halfAnimationValueRest);
        float testW = getWidth() * animationValue;
        float testH = height * animationValue;

        testX = testX * animationValue + ((Minecraft.getInstance().getMainWindow().getScaledWidth() - testW) * halfAnimationValueRest);

        Scissor.push();
        Scissor.setFromComponentCoordinates(testX, testY, testW, testH);
        float offset = -1;
        float header = 25;

        if (max > height - header - 10) {
            scroll = MathHelper.clamp(scroll, -max + height - header - 10, 0);
            animatedScrool = MathHelper.clamp(animatedScrool, -max + height - header - 10, 0);
        } else {
            scroll = 0;
            animatedScrool = 0;
        }

        for (ModuleComponent component : modules) {
            component.setX(getX() + 2);
            component.setY(getY() + header + offset + 3 + animatedScrool);
            component.setWidth(getWidth() - 4);
            component.setHeight(20);
            component.animation.update();
            if (component.animation.getValue() > 0) {
                float componentOffset = 0;
                for (Component component2 : component.getComponents()) {
                    if (component2.isVisible())
                        componentOffset += component2.getHeight();
                }
                componentOffset *= component.animation.getValue();
                component.setHeight(component.getHeight() + componentOffset);
            }
            component.render(stack, mouseX, mouseY);
            offset += component.getHeight() + 0.5f;
        }
        max = offset;

        Scissor.unset();
        Scissor.pop();

    }

    [USER=1367676]@override[/USER]
    public void mouseClick(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseClick(mouseX, mouseY, button);
        }
    }


    [USER=1367676]@override[/USER]
    public void keyPressed(int key, int scanCode, int modifiers) {
        for (ModuleComponent component : modules) {
            component.keyPressed(key, scanCode, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void charTyped(char codePoint, int modifiers) {
        for (ModuleComponent component : modules) {
            component.charTyped(codePoint, modifiers);
        }
    }

    [USER=1367676]@override[/USER]
    public void mouseRelease(float mouseX, float mouseY, int button) {
        for (ModuleComponent component : modules) {
            component.mouseRelease(mouseX, mouseY, button);
        }
    }
}
говно
 
Забаненный
Статус
Оффлайн
Регистрация
26 Окт 2024
Сообщения
125
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Сверху Снизу