Начинающий
- Статус
- Оффлайн
- Регистрация
- 23 Ноя 2025
- Сообщения
- 6
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
- OptiFine
сделал первую кликгуишку, ориентировался +- на монотон, под экспенсив 3.1
без оскорблений, пожалуйста. Если не нравится - скажите что переделать, буду знать как примерно переделывать.
ss прикреплен снизу
без оскорблений, пожалуйста. Если не нравится - скажите что переделать, буду знать как примерно переделывать.
ss прикреплен снизу
panel.java:
package flux.registry.ui.dropdown;
import java.util.ArrayList;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack;
import flux.registry.NukeDLC;
import flux.registry.functions.api.Category;
import flux.registry.functions.api.Function;
import flux.registry.ui.dropdown.components.ModuleComponent;
import flux.registry.ui.dropdown.impl.Component;
import flux.registry.ui.dropdown.impl.IBuilder;
import flux.registry.utils.math.MathUtil;
import flux.registry.utils.render.ColorUtils;
import flux.registry.utils.render.DisplayUtils;
import flux.registry.utils.render.Scissor;
import flux.registry.utils.render.font.Fonts;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
@Getter
@Setter
public class Panel implements IBuilder {
private final Category category;
protected float x;
protected float y;
protected final float width = 105f;
protected final float height = 220f;
private List<ModuleComponent> modules = new ArrayList<>();
private float scroll;
private float animatedScrool;
public Panel(Category category) {
this.category = category;
for (Function function : NukeDLC.getInstance().getFunctionRegistry().getFunctions()) {
if (function.getCategory() == category) {
ModuleComponent component = new ModuleComponent(function);
component.setPanel(this);
modules.add(component);
}
}
}
@Override
public void render(MatrixStack stack, float mouseX, float mouseY) {
animatedScrool = MathUtil.fast(animatedScrool, scroll, 10);
DisplayUtils.drawRoundedRect(x + 4.0F, y + 7.0F, width - 7.0F, height + 18.5F, 8.0F,
ColorUtils.rgba(24, 25, 32, 217));
DisplayUtils.drawRoundedRect(x + 4.0F, y + 7.0F, width - 7.0F, 18.0F, 8.0F,
ColorUtils.rgba(16, 17, 21, 230));
for(int i = 0; i < 3; ++i) {
DisplayUtils.drawCircle(x + 77.5F + 1.0F + (float)i * 3.5F, y + 11.5F + 1.0F, 1.0F,
ColorUtils.rgba(255, 255, 255, 120));
}
Fonts.montserrat.drawCenteredText(stack, category.name(),
x + width / 2f,
y + 7.0F + 9.0F - Fonts.montserrat.getHeight(8) / 2f,
ColorUtils.rgb(250, 250, 250), 8, 0.1f);
drawComponents(stack, mouseX, mouseY);
}
private void drawComponents(MatrixStack stack, float mouseX, float mouseY) {
float animationValue = (float) DropDown.getAnimation().getValue() * DropDown.scale;
float halfAnimationValueRest = (1 - animationValue) / 2f;
float panelHeight = getHeight();
float clipX = getX() + (getWidth() * halfAnimationValueRest);
float clipY = getY() + 25 + (panelHeight * halfAnimationValueRest);
float clipWidth = getWidth() * animationValue;
float clipHeight = panelHeight * animationValue - 33;
clipX = clipX * animationValue + ((Minecraft.getInstance().getMainWindow().getScaledWidth() - clipWidth) *
halfAnimationValueRest);
Scissor.push();
Scissor.setFromComponentCoordinates(clipX, clipY, clipWidth, clipHeight);
float header = 25;
float contentStartY = getY() + header + 6;
float maxHeight = calculateTotalHeight();
if (maxHeight > panelHeight - header - 10) {
scroll = MathHelper.clamp(scroll, -maxHeight + panelHeight - header - 10, 0);
animatedScrool = MathHelper.clamp(animatedScrool, -maxHeight + panelHeight - header - 10, 0);
} else {
scroll = 0;
animatedScrool = 0;
}
float currentY = contentStartY + animatedScrool;
for (ModuleComponent component : modules) {
component.setX(getX() + 5);
component.setY(currentY);
component.setWidth(getWidth() - 10);
component.getAnimation().update();
float baseHeight = 20;
if (component.getAnimation().getValue() > 0) {
float componentOffset = 0;
for (Component component2 : component.getComponents()) {
if (component2.isVisible())
componentOffset += component2.getHeight() + 2.0F;
}
componentOffset *= component.getAnimation().getValue();
baseHeight = 20 + componentOffset;
}
component.setHeight(baseHeight);
if (isComponentVisible(component, clipY, clipHeight)) {
renderModuleInMonotoneStyle(stack, component, mouseX, mouseY);
}
currentY += component.getHeight() + 3.5f;
}
Scissor.pop();
}
private boolean isComponentVisible(ModuleComponent component, float clipY, float clipHeight) {
float componentTop = component.getY();
float componentBottom = component.getY() + component.getHeight();
float clipBottom = clipY + clipHeight;
return componentBottom > clipY && componentTop < clipBottom;
}
private float calculateTotalHeight() {
float totalHeight = 0;
for (ModuleComponent component : modules) {
float componentHeight = 20;
if (component.isExpanded()) {
for (Component comp : component.getComponents()) {
if (comp.isVisible()) {
componentHeight += comp.getHeight() + 4.0F;
}
}
componentHeight += 6.0F;
}
totalHeight += componentHeight + 3.5f;
}
return totalHeight;
}
private void renderModuleInMonotoneStyle(MatrixStack stack, ModuleComponent component, float mouseX, float mouseY) {
boolean isExpanded = component.isExpanded();
boolean isEnabled = component.getFunction().isState();
DisplayUtils.drawRoundedRect(component.getX() + 2.7F, component.getY() + 0.1F,
component.getWidth() - 5.4F, 17.08F, 4.0F,
ColorUtils.rgba(35, 36, 42, isEnabled ? 180 : 120));
if (isExpanded && component.getAnimation().getValue() > 0) {
float expandedHeight = calculateExpandedHeight(component) - 17.08F;
DisplayUtils.drawRect(component.getX() + 2.7F, component.getY() + 17.08F,
component.getWidth() - 5.4F, 1.0F,
ColorUtils.rgba(35, 36, 42, 180));
DisplayUtils.drawRoundedRect(component.getX() + 2.7F, component.getY() + 18.08F,
component.getWidth() - 5.4F, expandedHeight, 4.0F,
ColorUtils.rgba(30, 31, 38, 200));
}
String functionName = component.getFunction().getName();
float textX = component.getX() + 8.5F;
float textY = component.getY() + 8.5F - Fonts.montserrat.getHeight(7) / 2f;
Fonts.montserrat.drawText(stack, functionName,
textX, textY,
ColorUtils.rgba(246, 246, 247, isEnabled ? 255 : 180), 7, 0.1f);
if (!component.getFunction().getSettings().isEmpty()) {
Fonts.montserrat.drawCenteredText(stack, "+",
component.getX() + component.getWidth() - 8.0F,
component.getY() + 8.5F - Fonts.montserrat.getHeight(7) / 2f,
ColorUtils.rgba(199, 200, 204, isEnabled ? 220 : 120), 7, 0.1f);
}
if (isExpanded && component.getAnimation().getValue() > 0.6) {
float settingsOffset = 22.0F;
for (Component comp : component.getComponents()) {
if (comp.isVisible()) {
comp.setX(component.getX() + 8.0F);
comp.setY(component.getY() + settingsOffset);
comp.setWidth(component.getWidth() - 16.0F);
comp.setHeight(15.0F);
comp.render(stack, mouseX, mouseY);
settingsOffset += comp.getHeight() + 4.0F;
}
}
}
}
private float calculateExpandedHeight(ModuleComponent component) {
float height = 17.08F;
if (component.isExpanded()) {
for (Component comp : component.getComponents()) {
if (comp.isVisible()) {
height += comp.getHeight() + 4.0F;
}
}
height += 6.0F;
}
return height;
}
@Override
public void mouseClick(float mouseX, float mouseY, int button) {
for (ModuleComponent component : modules) {
component.mouseClick(mouseX, mouseY, button);
}
}
@Override
public void keyPressed(int key, int scanCode, int modifiers) {
for (ModuleComponent component : modules) {
component.keyPressed(key, scanCode, modifiers);
}
}
@Override
public void charTyped(char codePoint, int modifiers) {
for (ModuleComponent component : modules) {
component.charTyped(codePoint, modifiers);
}
}
@Override
public void mouseRelease(float mouseX, float mouseY, int button) {
for (ModuleComponent component : modules) {
component.mouseRelease(mouseX, mouseY, button);
}
}
}