Forráskód Böngészése

Simple UI improvements

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 5 éve
szülő
commit
742468895e

+ 1 - 1
gradle.properties

@@ -3,6 +3,6 @@ minecraft_version=20w18a
 yarn_mappings=20w18a+build.1
 loader_version=0.8.2+build.194
 fabric_version=0.7.1+build.331-1.16
-mod_version=4.0.7-unstable
+mod_version=4.0.8-unstable
 modmenu_version=1.11.2+build.6
 nec_version=1.2.3+1.15.1

+ 1 - 1
src/main/java/me/shedaniel/clothconfig2/gui/entries/ColorEntry.java

@@ -33,7 +33,7 @@ public class ColorEntry extends TextFieldListEntry<Integer> {
         this.alpha = false;
         this.saveConsumer = saveConsumer;
         this.textFieldWidget.setText(getHexColorString(value));
-        this.colorDisplayWidget = new ColorDisplayWidget(0, 0, 20, getColorValueColor(textFieldWidget.getText()));
+        this.colorDisplayWidget = new ColorDisplayWidget(textFieldWidget, 0, 0, 20, getColorValueColor(textFieldWidget.getText()));
         this.original = value;
         ((ButtonWidgetHooks) this.resetButton).setOnPress(button -> {
             this.textFieldWidget.setText(getHexColorString(original));

+ 2 - 2
src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java

@@ -160,7 +160,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         
         @Override
         public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
-            fill(matrices, bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, -6250336);
+            fill(matrices, bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, topRenderer.isSelected ? -1 : -6250336);
             fill(matrices, bounds.x + 1, bounds.y + 1, bounds.x + bounds.width - 1, bounds.y + bounds.height - 1, -16777216);
             topRenderer.render(matrices, mouseX, mouseY, bounds.x, bounds.y, bounds.width, bounds.height, delta);
             if (menu.isExpanded())
@@ -362,7 +362,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         public void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
             int last10Height = getHeight();
             int cWidth = getCellCreator().getCellWidth();
-            fill(matrices, lastRectangle.x, lastRectangle.y + lastRectangle.height, lastRectangle.x + cWidth, lastRectangle.y + lastRectangle.height + last10Height + 1, -6250336);
+            fill(matrices, lastRectangle.x, lastRectangle.y + lastRectangle.height, lastRectangle.x + cWidth, lastRectangle.y + lastRectangle.height + last10Height + 1, isExpanded() ? -1 : -6250336);
             fill(matrices, lastRectangle.x + 1, lastRectangle.y + lastRectangle.height + 1, lastRectangle.x + cWidth - 1, lastRectangle.y + lastRectangle.height + last10Height, -16777216);
             RenderSystem.pushMatrix();
             RenderSystem.translatef(0, 0, 300f);

+ 1 - 3
src/main/java/me/shedaniel/clothconfig2/gui/entries/TextFieldListEntry.java

@@ -48,11 +48,9 @@ public abstract class TextFieldListEntry<T> extends TooltipListEntry<T> {
         this.textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 0, 0, 148, 18, NarratorManager.EMPTY) {
             @Override
             public void render(MatrixStack matrices, int int_1, int int_2, float float_1) {
-//                boolean f = isFocused();
-                setFocused(isSelected);
+                setFocused(isSelected && TextFieldListEntry.this.getFocused() == this);
                 textFieldPreRender(this);
                 super.render(matrices, int_1, int_2, float_1);
-//                setFocused(f);
             }
             
             @Override

+ 5 - 2
src/main/java/me/shedaniel/clothconfig2/gui/widget/ColorDisplayWidget.java

@@ -1,23 +1,26 @@
 package me.shedaniel.clothconfig2.gui.widget;
 
 import net.minecraft.client.gui.widget.AbstractButtonWidget;
+import net.minecraft.client.gui.widget.TextFieldWidget;
 import net.minecraft.client.util.NarratorManager;
 import net.minecraft.client.util.math.MatrixStack;
 
 public class ColorDisplayWidget extends AbstractButtonWidget {
     
+    protected TextFieldWidget textFieldWidget;
     protected int color;
     protected int size;
     
-    public ColorDisplayWidget(int x, int y, int size, int color) {
+    public ColorDisplayWidget(TextFieldWidget textFieldWidget, int x, int y, int size, int color) {
         super(x, y, size, size, NarratorManager.EMPTY);
+        this.textFieldWidget = textFieldWidget;
         this.color = color;
         this.size = size;
     }
     
     @Override
     public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
-        fillGradient(matrices, this.x, this.y, this.x + size, this.y + size, -0x5F5F60, -0x5F5F60);
+        fillGradient(matrices, this.x, this.y, this.x + size, this.y + size, textFieldWidget.isFocused() ? -1 : -6250336, textFieldWidget.isFocused() ? -1 : -6250336);
         fillGradient(matrices, this.x + 1, this.y + 1, this.x + size - 1, this.y + size - 1, 0xffffffff, 0xffffffff);
         fillGradient(matrices, this.x + 1, this.y + 1, this.x + size - 1, this.y + size - 1, color, color);
     }