diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java index e613bfafd..a88afecd9 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java @@ -28,22 +28,22 @@ public class BaseConfigScreen extends ConfigScreen { widgets.clear(); super.init(); - TextStencilElement text = new TextStencilElement(client.fontRenderer, new StringTextComponent("CLIENT CONFIG").formatted(TextFormatting.BOLD)).centered(true, true); - widgets.add(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 50, 200, 30) + TextStencilElement text = new TextStencilElement(client.fontRenderer, new StringTextComponent("Client Settings").formatted(TextFormatting.BOLD)).centered(true, true); + widgets.add(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16) .showingElement(text) .withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.CLIENT, AllConfigs.CLIENT.specification))) ); text.withElementRenderer(BoxWidget.gradientFactory.apply(clientConfigWidget)); - TextStencilElement text2 = new TextStencilElement(client.fontRenderer, new StringTextComponent("COMMON CONFIG").formatted(TextFormatting.BOLD)).centered(true, true); - widgets.add(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 30) + TextStencilElement text2 = new TextStencilElement(client.fontRenderer, new StringTextComponent("World Generation Settings").formatted(TextFormatting.BOLD)).centered(true, true); + widgets.add(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16) .showingElement(text2) .withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.COMMON, AllConfigs.COMMON.specification))) ); text2.withElementRenderer(BoxWidget.gradientFactory.apply(commonConfigWidget)); - TextStencilElement text3 = new TextStencilElement(client.fontRenderer, new StringTextComponent("SERVER CONFIG").formatted(TextFormatting.BOLD)).centered(true, true); - widgets.add(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 50, 200, 30) + TextStencilElement text3 = new TextStencilElement(client.fontRenderer, new StringTextComponent("Gameplay Settings").formatted(TextFormatting.BOLD)).centered(true, true); + widgets.add(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16) .showingElement(text3) ); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java index a9c0190c6..c0c387afa 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreenList.java @@ -142,12 +142,12 @@ public class ConfigScreenList extends ExtendedList { @Override public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { - UIRenderHelper.streak(ms, 0, x, y + height / 2, height - 10, getLabelWidth(width) + ((width - getLabelWidth(width)) / 3), 0xdd_000000); + UIRenderHelper.streak(ms, 0, x, y + height / 2, height - 10, width, 0xdd_000000); IFormattableTextComponent component = label.getComponent(); if (Minecraft.getInstance().fontRenderer.getWidth(component) > getLabelWidth(width) - 10) { label.withText(Minecraft.getInstance().fontRenderer.trimToWidth(component, getLabelWidth(width) - 15).getString() + "..."); } - label.at(x + 5, y + height / 2 - 4, 0).render(ms); + label.at(x + 10, y + height / 2 - 4, 0).render(ms); if (mouseX > x && mouseX < x + getLabelWidth(width) && mouseY > y + 5 && mouseY < y + height - 5) { List tooltip = getLabelTooltip(); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java index ace8dc2c0..3a6b2285c 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java @@ -117,7 +117,7 @@ public class SubMenuConfigScreen extends ConfigScreen { super.init(); //leave 40px on either side and dont be wider than 500px - listWidth = Math.min(width - 80, 500); + listWidth = Math.min(width - 80, 300); int yCenter = height / 2; int listL = this.width / 2 - listWidth / 2; @@ -189,7 +189,7 @@ public class SubMenuConfigScreen extends ConfigScreen { widgets.add(discardChanges); widgets.add(goBack); - list = new ConfigScreenList(client, listWidth, height - 60, 45, height - 15, 50); + list = new ConfigScreenList(client, listWidth, height - 60, 45, height - 15, 40); list.setLeftPos(this.width / 2 - list.getWidth() / 2); children.add(list); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java index 59ffdd120..d7b9d6a98 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/BooleanEntry.java @@ -1,33 +1,42 @@ package com.simibubi.create.foundation.config.ui.entries; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.gui.TextStencilElement; +import com.simibubi.create.foundation.gui.AllIcons; +import com.simibubi.create.foundation.gui.RenderElement; import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.gui.widgets.BoxWidget; -import net.minecraft.client.Minecraft; import net.minecraftforge.common.ForgeConfigSpec; public class BooleanEntry extends ValueEntry { - TextStencilElement enabled; - TextStencilElement disabled; + RenderElement enabled; + RenderElement disabled; BoxWidget button; public BooleanEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); - enabled = new TextStencilElement(Minecraft.getInstance().fontRenderer, "Enabled") - .centered(true, true) - .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height/2, height, width, 0xff_88f788, 0xff_20cc20)); +// enabled = new TextStencilElement(Minecraft.getInstance().fontRenderer, "Enabled") +// .centered(true, true) +// .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height/2, height, width, 0xff_88f788, 0xff_20cc20)); +// +// disabled = new TextStencilElement(Minecraft.getInstance().fontRenderer, "Disabled") +// .centered(true, true) +// .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height/2, height, width, 0xff_f78888, 0xff_cc2020)); - disabled = new TextStencilElement(Minecraft.getInstance().fontRenderer, "Disabled") - .centered(true, true) - .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height/2, height, width, 0xff_f78888, 0xff_cc2020)); + enabled = AllIcons.I_CONFIRM.asStencil() + .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, + height, width, 0xff_88f788, 0xff_20cc20)) + .at(10, 0); + + disabled = AllIcons.I_DISABLE.asStencil() + .withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, + height, width, 0xff_f78888, 0xff_cc2020)) + .at(10, 0); - button = new BoxWidget() - .showingElement(enabled) - .withCallback(() -> setValue(!getValue())); + button = new BoxWidget().showingElement(enabled) + .withCallback(() -> setValue(!getValue())); listeners.add(button); onReset(); @@ -46,12 +55,13 @@ public class BooleanEntry extends ValueEntry { } @Override - public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { + public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, + boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); - button.x = x + getLabelWidth(width); + button.x = x + width - 80 - resetWidth; button.y = y + 10; - button.setWidth(width - getLabelWidth(width) - resetWidth - 4); + button.setWidth(35); button.setHeight(height - 20); button.render(ms, mouseX, mouseY, partialTicks); } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java index 73b03f892..7dcf9512d 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/EnumEntry.java @@ -13,7 +13,7 @@ import net.minecraftforge.common.ForgeConfigSpec; public class EnumEntry extends ValueEntry> { - protected static final int cycleWidth = 34;//including 2px offset on either side + protected static final int cycleWidth = 34;// including 2px offset on either side protected TextStencilElement valueText; protected BoxWidget cycleLeft; @@ -23,20 +23,20 @@ public class EnumEntry extends ValueEntry> { super(label, value, spec); valueText = new TextStencilElement(Minecraft.getInstance().fontRenderer, "YEP").centered(true, true); - valueText.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0 ,0, height/2, height, width, Theme.i(Theme.Key.TEXT_1), Theme.i(Theme.Key.TEXT_2))); + valueText.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, + height, width, Theme.i(Theme.Key.TEXT_1), Theme.i(Theme.Key.TEXT_2))); DelegatedStencilElement l = AllIcons.I_CONFIG_PREV.asStencil(); - cycleLeft = new BoxWidget(0, 0, 22, 22) - .showingElement(l) - .rescaleElement(16, 16) - .withCallback(() -> cycleValue(-1)); + cycleLeft = new BoxWidget(0, 0, cycleWidth + 8, 16).showingElement(l) +// .rescaleElement(16, 16) + .withCallback(() -> cycleValue(-1)); l.withElementRenderer(BoxWidget.gradientFactory.apply(cycleLeft)); DelegatedStencilElement r = AllIcons.I_CONFIG_NEXT.asStencil(); - cycleRight = new BoxWidget(0, 0, 22, 22) - .showingElement(r) - .rescaleElement(16, 16) - .withCallback(() -> cycleValue(1)); + cycleRight = new BoxWidget(0, 0, cycleWidth + 8, 16).showingElement(r) +// .rescaleElement(16, 16) + .withCallback(() -> cycleValue(1)); + r.at(cycleWidth - 8, 0); r.withElementRenderer(BoxWidget.gradientFactory.apply(cycleRight)); listeners.add(cycleLeft); @@ -47,7 +47,8 @@ public class EnumEntry extends ValueEntry> { protected void cycleValue(int direction) { Enum e = getValue(); - Enum[] options = e.getDeclaringClass().getEnumConstants(); + Enum[] options = e.getDeclaringClass() + .getEnumConstants(); e = options[Math.floorMod(e.ordinal() + direction, options.length)]; setValue(e); bumpCog(direction * 15f); @@ -70,22 +71,29 @@ public class EnumEntry extends ValueEntry> { } @Override - public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { + public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, + boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); - cycleLeft.x = x + getLabelWidth(width) + 2; - cycleLeft.y = y + 12; + cycleLeft.x = x + getLabelWidth(width) + 4; + cycleLeft.y = y + 10; cycleLeft.render(ms, mouseX, mouseY, partialTicks); - valueText - .at(cycleLeft.x - 4 + cycleWidth, y + 12, 0) - .withBounds(width - getLabelWidth(width) - 2 * cycleWidth - resetWidth - 4, 22) - .render(ms); + valueText.at(cycleLeft.x + cycleWidth - 8, y + 10, 200) + .withBounds(width - getLabelWidth(width) - 2 * cycleWidth - resetWidth - 4, 16) + .render(ms); - cycleRight.x = x + width - cycleWidth - resetWidth + 2; - cycleRight.y = y + 12; + cycleRight.x = x + width - cycleWidth * 2 - resetWidth + 10; + cycleRight.y = y + 10; cycleRight.render(ms, mouseX, mouseY, partialTicks); + BoxWidget boxWidget = new BoxWidget(0, 0, 10, 10); + boxWidget.x = cycleLeft.x + cycleWidth + 4; + boxWidget.y = cycleLeft.y + 3; + boxWidget.withBorderColors(java.awt.Color.black, java.awt.Color.black); + boxWidget.active = false; + boxWidget.render(ms, mouseX, mouseY, partialTicks); + } @Override diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java index 237cf8ff4..433d79b53 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/NumberEntry.java @@ -38,7 +38,7 @@ public abstract class NumberEntry extends ValueEntry { public NumberEntry(String label, ForgeConfigSpec.ConfigValue value, ForgeConfigSpec.ValueSpec spec) { super(label, value, spec); - textField = new ConfigTextField(Minecraft.getInstance().fontRenderer, 0, 0, 200, 26, unit); + textField = new ConfigTextField(Minecraft.getInstance().fontRenderer, 0, 0, 200, 20, unit); textField.setText(String.valueOf(getValue())); Object range = spec.getRange(); @@ -51,13 +51,13 @@ public abstract class NumberEntry extends ValueEntry { T max = (T) maxField.get(range); FontRenderer font = Minecraft.getInstance().fontRenderer; - if (!min.equals(getTypeMin())) { + if (min.doubleValue() > getTypeMin().doubleValue()) { StringTextComponent t = new StringTextComponent(formatBound(min) + " < "); minText = new TextStencilElement(font, t).centered(true, false); minText.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0 ,0, height/2, height, width, Theme.c(Theme.Key.TEXT_1).darker().getRGB(), Theme.c(Theme.Key.TEXT_2).darker().getRGB())); minOffset = font.getWidth(t); } - if (!max.equals(getTypeMax())) { + if (max.doubleValue() < getTypeMax().doubleValue()) { StringTextComponent t = new StringTextComponent(" < " + formatBound(max)); maxText = new TextStencilElement(font, t).centered(true, false); maxText.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0 ,0, height/2, height, width, Theme.c(Theme.Key.TEXT_1).darker().getRGB(), Theme.c(Theme.Key.TEXT_2).darker().getRGB())); @@ -123,10 +123,10 @@ public abstract class NumberEntry extends ValueEntry { public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); - textField.x = x + getLabelWidth(width) + minOffset; - textField.y = y + 10; - textField.setWidth(width - getLabelWidth(width) - resetWidth - minOffset - maxOffset); - textField.setHeight(26); + textField.x = x + width - 82 - resetWidth; + textField.y = y + 8; + textField.setWidth(Math.min(width - getLabelWidth(width) - resetWidth - minOffset - maxOffset, 40)); + textField.setHeight(20); textField.render(ms, mouseX, mouseY, partialTicks); if (minText != null) @@ -172,7 +172,7 @@ public abstract class NumberEntry extends ValueEntry { @Override protected Float getTypeMin() { - return Float.MIN_VALUE; + return -Float.MAX_VALUE; } @Override @@ -194,12 +194,12 @@ public abstract class NumberEntry extends ValueEntry { @Override protected Double getTypeMin() { - return Double.MIN_VALUE; + return (double) -Float.MAX_VALUE; } @Override protected Double getTypeMax() { - return Double.MAX_VALUE; + return (double) Float.MAX_VALUE; } @Override diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java index 0931587c7..adb1d05c6 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/SubMenuEntry.java @@ -4,11 +4,11 @@ import com.electronwill.nightconfig.core.UnmodifiableConfig; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.config.ui.ConfigScreenList; import com.simibubi.create.foundation.config.ui.SubMenuConfigScreen; +import com.simibubi.create.foundation.gui.AllIcons; +import com.simibubi.create.foundation.gui.DelegatedStencilElement; import com.simibubi.create.foundation.gui.ScreenOpener; -import com.simibubi.create.foundation.gui.TextStencilElement; import com.simibubi.create.foundation.gui.widgets.BoxWidget; -import net.minecraft.client.Minecraft; import net.minecraftforge.common.ForgeConfigSpec; public class SubMenuEntry extends ConfigScreenList.LabeledEntry { @@ -17,12 +17,13 @@ public class SubMenuEntry extends ConfigScreenList.LabeledEntry { public SubMenuEntry(SubMenuConfigScreen parent, String label, ForgeConfigSpec spec, UnmodifiableConfig config) { super(label); - TextStencilElement text = new TextStencilElement(Minecraft.getInstance().fontRenderer, "Click to open").centered(true, true); - + DelegatedStencilElement element = AllIcons.I_CONFIG_OPEN.asStencil(); + button = new BoxWidget() - .showingElement(text) + .showingElement(element) .withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(parent, label, parent.type, spec, config))); - text.withElementRenderer(BoxWidget.gradientFactory.apply(button)); + element.withElementRenderer(BoxWidget.gradientFactory.apply(button)); + element.at(10, 0); listeners.add(button); } @@ -37,15 +38,15 @@ public class SubMenuEntry extends ConfigScreenList.LabeledEntry { public void render(MatrixStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) { super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks); - button.x = x + getLabelWidth(width); + button.x = x + width - 108; button.y = y + 10; - button.setWidth(width - getLabelWidth(width) - 4); + button.setWidth(35); button.setHeight(height - 20); button.render(ms, mouseX, mouseY, partialTicks); } @Override protected int getLabelWidth(int totalWidth) { - return (int) (totalWidth * labelWidthMult); + return (int) (totalWidth * labelWidthMult) + 30; } } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java index 6c594cec3..3cba3a0cd 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java @@ -108,13 +108,13 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { } resetButton.x = x + width - resetWidth + 6; - resetButton.y = y + 15; + resetButton.y = y + 10; resetButton.render(ms, mouseX, mouseY, partialTicks); } @Override protected int getLabelWidth(int totalWidth) { - return (int) (totalWidth * labelWidthMult); + return (int) (totalWidth * labelWidthMult) + 30; } public void setValue(@Nonnull T value) { diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java index 99239b56f..e6b6cc573 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java @@ -134,7 +134,9 @@ public class AllIcons implements IScreenRenderable { I_CONFIG_RESET = next(), I_CONFIG_BACK = next(), I_CONFIG_PREV = next(), - I_CONFIG_NEXT = next(); + I_CONFIG_NEXT = next(), + I_DISABLE = next(), + I_CONFIG_OPEN = next(); public AllIcons(int x, int y) { iconX = x * 16; diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java index 96b05f45c..dc880c26f 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/ElementWidget.java @@ -119,8 +119,8 @@ public class ElementWidget extends AbstractSimiWidget { //element x/y get treated as a border around the element float eX = element.getX(); float eY = element.getY(); - float eWidth = width - 2 * eX; - float eHeight = height - 2 * eY; + float eWidth = width;// - 2 * eX; + float eHeight = height;// - 2 * eY; if (rescaleElement) { float xScale = eWidth / rescaleSizeX; float yScale = eHeight / rescaleSizeY; diff --git a/src/main/resources/assets/create/textures/gui/icons.png b/src/main/resources/assets/create/textures/gui/icons.png index e27a7e648..6d91e2386 100644 Binary files a/src/main/resources/assets/create/textures/gui/icons.png and b/src/main/resources/assets/create/textures/gui/icons.png differ