Исходник ClickGui expensive 3.1 | rework

Начинающий
Статус
Оффлайн
Регистрация
17 Ноя 2023
Сообщения
80
Реакции[?]
0
Поинты[?]
0

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

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

Спасибо!

1725632599662.png
Пожалуйста, авторизуйтесь для просмотра ссылки.
( Моя первая работа )




+ ModuleComponent

Код:
package im.expensive.ui.dropdown.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.functions.api.Function;
import im.expensive.functions.settings.Setting;
import im.expensive.functions.settings.impl.*;
import im.expensive.ui.dropdown.components.settings.*;
import im.expensive.ui.dropdown.impl.Component;
import im.expensive.utils.client.KeyStorage;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.Cursors;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
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;

@Getter
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 Function function;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

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

    public ModuleComponent(Function function) {
        this.function = function;
        for (Setting<?> setting : function.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();

        }
    }

    @Override
    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;

    @Override
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) function.getAnimation().getValue());

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

        drawOutlinedRect(mouseX, mouseY, color);


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

    @Override
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) function.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);
    }

    @Override
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    @Override
    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) {
                function.setBind(0);
            } else function.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(function.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * function.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
17 Ноя 2023
Сообщения
80
Реакции[?]
0
Поинты[?]
0
ебланоид? ты токо цвет поменял
? Rework так ещё modulecomponent если сделать что я сделал уже типо переделал то все ок... То что цвет то нет. Края меня по форме загругленности цвета 1 шадов удалил
Цену на русские клавы подняли или что>
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
25 Июл 2024
Сообщения
74
Реакции[?]
0
Поинты[?]
0
Посмотреть вложение 285029
Пожалуйста, авторизуйтесь для просмотра ссылки.
( Моя первая работа )




+ ModuleComponent

Код:
package im.expensive.ui.dropdown.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.functions.api.Function;
import im.expensive.functions.settings.Setting;
import im.expensive.functions.settings.impl.*;
import im.expensive.ui.dropdown.components.settings.*;
import im.expensive.ui.dropdown.impl.Component;
import im.expensive.utils.client.KeyStorage;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.Cursors;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
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;

@Getter
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 Function function;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

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

    public ModuleComponent(Function function) {
        this.function = function;
        for (Setting<?> setting : function.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();

        }
    }

    @Override
    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;

    @Override
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) function.getAnimation().getValue());

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

        drawOutlinedRect(mouseX, mouseY, color);


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

    @Override
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) function.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);
    }

    @Override
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    @Override
    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) {
                function.setBind(0);
            } else function.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(function.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * function.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}
цвет поменял и еще называет своей работой. тема (noad). /del
 
Начинающий
Статус
Оффлайн
Регистрация
19 Янв 2024
Сообщения
33
Реакции[?]
1
Поинты[?]
1K
? Rework так ещё modulecomponent если сделать что я сделал уже типо переделал то все ок... То что цвет то нет. Края меня по форме загругленности цвета 1 шадов удалил

Цену на русские клавы подняли или что>
da
 
Начинающий
Статус
Оффлайн
Регистрация
17 Ноя 2023
Сообщения
80
Реакции[?]
0
Поинты[?]
0
Начинающий
Статус
Оффлайн
Регистрация
26 Авг 2024
Сообщения
569
Реакции[?]
0
Поинты[?]
1K
Посмотреть вложение 285029
Пожалуйста, авторизуйтесь для просмотра ссылки.
( Моя первая работа )




+ ModuleComponent

Код:
package im.expensive.ui.dropdown.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.functions.api.Function;
import im.expensive.functions.settings.Setting;
import im.expensive.functions.settings.impl.*;
import im.expensive.ui.dropdown.components.settings.*;
import im.expensive.ui.dropdown.impl.Component;
import im.expensive.utils.client.KeyStorage;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.Cursors;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
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;

@Getter
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 Function function;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

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

    public ModuleComponent(Function function) {
        this.function = function;
        for (Setting<?> setting : function.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();

        }
    }

    @Override
    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;

    @Override
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) function.getAnimation().getValue());

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

        drawOutlinedRect(mouseX, mouseY, color);


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

    @Override
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) function.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);
    }

    @Override
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    @Override
    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) {
                function.setBind(0);
            } else function.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(function.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * function.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}
и нахуя дефолтный модуль компонент с 3.1? ты ебанат? пжжж ливни
 
Read Only
Статус
Оффлайн
Регистрация
31 Авг 2023
Сообщения
700
Реакции[?]
6
Поинты[?]
5K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Бро,я же дополнил + modulecomponent к нему и написал выше что сделал
всем поебать хватит засорять форум
и нахуя дефолтный модуль компонент с 3.1? ты ебанат? пжжж ливни
ты свое говно видел,молчи в тряпку
 
Начинающий
Статус
Оффлайн
Регистрация
21 Окт 2022
Сообщения
216
Реакции[?]
1
Поинты[?]
2K
Посмотреть вложение 285029
Пожалуйста, авторизуйтесь для просмотра ссылки.
( Моя первая работа )




+ ModuleComponent

Код:
package im.expensive.ui.dropdown.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.functions.api.Function;
import im.expensive.functions.settings.Setting;
import im.expensive.functions.settings.impl.*;
import im.expensive.ui.dropdown.components.settings.*;
import im.expensive.ui.dropdown.impl.Component;
import im.expensive.utils.client.KeyStorage;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.Cursors;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
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;

@Getter
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 Function function;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

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

    public ModuleComponent(Function function) {
        this.function = function;
        for (Setting<?> setting : function.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();

        }
    }

    @Override
    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;

    @Override
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) function.getAnimation().getValue());

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

        drawOutlinedRect(mouseX, mouseY, color);


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

    @Override
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) function.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);
    }

    @Override
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    @Override
    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) {
                function.setBind(0);
            } else function.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(function.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * function.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}
/del ливни с форума
 
Начинающий
Статус
Оффлайн
Регистрация
17 Ноя 2023
Сообщения
80
Реакции[?]
0
Поинты[?]
0
Начинающий
Статус
Оффлайн
Регистрация
26 Авг 2024
Сообщения
569
Реакции[?]
0
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
10 Июл 2023
Сообщения
149
Реакции[?]
0
Поинты[?]
0
Посмотреть вложение 285029
Пожалуйста, авторизуйтесь для просмотра ссылки.
( Моя первая работа )




+ ModuleComponent

Код:
package im.expensive.ui.dropdown.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.functions.api.Function;
import im.expensive.functions.settings.Setting;
import im.expensive.functions.settings.impl.*;
import im.expensive.ui.dropdown.components.settings.*;
import im.expensive.ui.dropdown.impl.Component;
import im.expensive.utils.client.KeyStorage;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.Cursors;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
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;

@Getter
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 Function function;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

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

    public ModuleComponent(Function function) {
        this.function = function;
        for (Setting<?> setting : function.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();

        }
    }

    @Override
    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;

    @Override
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) function.getAnimation().getValue());

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

        drawOutlinedRect(mouseX, mouseY, color);


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

    @Override
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) function.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);
    }

    @Override
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    @Override
    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) {
                function.setBind(0);
            } else function.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(function.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * function.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}
/del Ну и хуета зачем я это посмотрел вырвите мои глаза :sob:
 

Вложения

Начинающий
Статус
Оффлайн
Регистрация
26 Авг 2024
Сообщения
569
Реакции[?]
0
Поинты[?]
1K
Read Only
Статус
Оффлайн
Регистрация
31 Авг 2023
Сообщения
700
Реакции[?]
6
Поинты[?]
5K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Начинающий
Статус
Оффлайн
Регистрация
10 Июл 2023
Сообщения
149
Реакции[?]
0
Поинты[?]
0
Посмотреть вложение 285029
Пожалуйста, авторизуйтесь для просмотра ссылки.
( Моя первая работа )




+ ModuleComponent

Код:
package im.expensive.ui.dropdown.components;

import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.functions.api.Function;
import im.expensive.functions.settings.Setting;
import im.expensive.functions.settings.impl.*;
import im.expensive.ui.dropdown.components.settings.*;
import im.expensive.ui.dropdown.impl.Component;
import im.expensive.utils.client.KeyStorage;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.Cursors;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
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;

@Getter
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 Function function;
    public Animation animation = new Animation();
    public boolean open;
    private boolean bind;

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

    public ModuleComponent(Function function) {
        this.function = function;
        for (Setting<?> setting : function.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();

        }
    }

    @Override
    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;

    @Override
    public void render(MatrixStack stack, float mouseX, float mouseY) {
        int color = ColorUtils.interpolate(-1, ColorUtils.getColor(0), (float) function.getAnimation().getValue());

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

        drawOutlinedRect(mouseX, mouseY, color);


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

    @Override
    public void mouseClick(float mouseX, float mouseY, int button) {
        if (isHovered(mouseX, mouseY, 20)) {
            if (button == 0) function.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);
    }

    @Override
    public void charTyped(char codePoint, int modifiers) {
        for (Component component : components) {
            if (component.isVisible()) component.charTyped(codePoint, modifiers);
        }
        super.charTyped(codePoint, modifiers);
    }

    @Override
    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) {
                function.setBind(0);
            } else function.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(function.getName(), 7) + 3, Fonts.sfui.getHeight(7), 10, ColorUtils.setAlpha(ColorUtils.getColor(1), (int) (128 * function.getAnimation().getValue())));

        Fonts.sfbold.drawText(stack, function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.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, function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), getX() + getWidth() - 6 - Fonts.sfui.getWidth(function.getBind() == 0 ? "..." : KeyStorage.getReverseKey(function.getBind()), 6, 0.1f), getY() + Fonts.icons.getHeight(6) + 1, 6, 0.1f);
            }
        }
    }
}
Ливни с форума пжпжпж
 
Похожие темы
Сверху Снизу