diff options
11 files changed, 51 insertions, 20 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 1ece3df..7fa93c3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { java id("fabric-loom") version "1.0.+" - id("io.github.juuxel.loom-quiltflower") version "1.7.+" + id("io.github.juuxel.loom-quiltflower") version "1.8.+" id("com.modrinth.minotaur") version "2.4.+" id("me.hypherionmc.cursegradle") version "2.+" @@ -61,10 +61,11 @@ repositories { val minecraftVersion: String by project val fabricLoaderVersion: String by project +val yarnBuild: String by project dependencies { minecraft("com.mojang:minecraft:$minecraftVersion") - mappings("net.fabricmc:yarn:$minecraftVersion+build.2:v2") + mappings("net.fabricmc:yarn:$minecraftVersion+build.$yarnBuild:v2") modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") "modClientImplementation"(fabricApi.module("fabric-resource-loader-v0", "0.68.1+1.19.3")) diff --git a/changelogs/2.0.0.md b/changelogs/2.0.0.md index 2c8cd6e..b56d0b1 100644 --- a/changelogs/2.0.0.md +++ b/changelogs/2.0.0.md @@ -1,2 +1,7 @@ - Update to 1.19.3 +- Colour field controllers +- Better carot positioning when clicking in text fields +- Better text selection for text fields +- Smooth scrolling for category list +- Fix category list scrollbar appearing under option list background in-game - Fix tick box name text length limiting diff --git a/gradle.properties b/gradle.properties index 60ed355..9e7b2dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,8 @@ org.gradle.jvmargs=-Xmx3G -minecraftVersion=1.19.3-rc1 -fabricLoaderVersion=0.14.10 +minecraftVersion=1.19.3-rc3 +fabricLoaderVersion=0.14.11 +yarnBuild=1 modId=yet-another-config-lib modName=YetAnotherConfigLib diff --git a/src/client/java/dev/isxander/yacl/api/OptionFlag.java b/src/client/java/dev/isxander/yacl/api/OptionFlag.java index 203a674..7a5c23f 100644 --- a/src/client/java/dev/isxander/yacl/api/OptionFlag.java +++ b/src/client/java/dev/isxander/yacl/api/OptionFlag.java @@ -11,14 +11,10 @@ import java.util.function.Consumer; */ @FunctionalInterface public interface OptionFlag extends Consumer<MinecraftClient> { - /** - * Warns the user that a game restart is required for the changes to take effect - */ + /** Warns the user that a game restart is required for the changes to take effect */ OptionFlag GAME_RESTART = client -> client.setScreen(new RequireRestartScreen(client.currentScreen)); - /** - * Reloads chunks upon applying (F3+A) - */ + /** Reloads chunks upon applying (F3+A) */ OptionFlag RELOAD_CHUNKS = client -> client.worldRenderer.reload(); OptionFlag WORLD_RENDER_UPDATE = client -> client.worldRenderer.scheduleTerrainUpdate(); diff --git a/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java b/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java index 785f4e2..7ea275b 100644 --- a/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java +++ b/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java @@ -317,7 +317,7 @@ public class OptionListWidget extends ElementListWidgetExt<OptionListWidget.Entr } private void updateExpandMinimizeText() { - expandMinimizeButton.setMessage(Text.of(isExpanded() ? "\u25BC" : "\u25B6")); + expandMinimizeButton.setMessage(Text.of(isExpanded() ? "▼" : "▶")); } public void setOptionEntries(List<OptionEntry> optionEntries) { diff --git a/src/client/java/dev/isxander/yacl/gui/controllers/ColorController.java b/src/client/java/dev/isxander/yacl/gui/controllers/ColorController.java index 6853a03..b8e1942 100644 --- a/src/client/java/dev/isxander/yacl/gui/controllers/ColorController.java +++ b/src/client/java/dev/isxander/yacl/gui/controllers/ColorController.java @@ -183,11 +183,13 @@ public class ColorController implements IStringController<Color> { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + int prevSelectionLength = selectionLength; + selectionLength = 0; if (super.keyPressed(keyCode, scanCode, modifiers)) { caretPos = Math.max(1, caretPos); setSelectionLength(); return true; - } + } else selectionLength = prevSelectionLength; return false; } diff --git a/src/client/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java b/src/client/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java index bce6906..47a4c96 100644 --- a/src/client/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java +++ b/src/client/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java @@ -41,7 +41,7 @@ public class StringControllerElement extends ControllerWidget<IStringController< protected void drawHoveredControl(MatrixStack matrices, int mouseX, int mouseY, float delta) { ticks += delta; - String text = instantApply ? control.getString() : inputField; + String text = getValueText().getString(); DrawableHelper.fill(matrices, inputFieldBounds.x(), inputFieldBounds.yLimit(), inputFieldBounds.xLimit(), inputFieldBounds.yLimit() + 1, -1); DrawableHelper.fill(matrices, inputFieldBounds.x() + 1, inputFieldBounds.yLimit() + 1, inputFieldBounds.xLimit() + 1, inputFieldBounds.yLimit() + 2, 0xFF404040); @@ -64,13 +64,29 @@ public class StringControllerElement extends ControllerWidget<IStringController< @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (isAvailable() && inputFieldBounds.isPointInside((int) mouseX, (int) mouseY)) { - if (!inputFieldFocused) { - inputFieldFocused = true; + if (isAvailable() && getDimension().isPointInside((int) mouseX, (int) mouseY)) { + inputFieldFocused = true; + + if (!inputFieldBounds.isPointInside((int) mouseX, (int) mouseY)) { caretPos = getDefaultCarotPos(); } else { - int textWidth = (int) mouseX - inputFieldBounds.x(); - caretPos = textRenderer.trimToWidth(control.getString(), textWidth).length(); + // gets the appropriate carot position for where you click + int textX = (int) mouseX - inputFieldBounds.x(); + int pos = -1; + int currentWidth = 0; + for (char ch : inputField.toCharArray()) { + pos++; + int charLength = textRenderer.getWidth(String.valueOf(ch)); + if (currentWidth + charLength / 2 > textX) { // if more than half way past the characters select in front of that char + caretPos = pos; + break; + } else if (pos == inputField.length() - 1) { + // if we have reached the end and no matches, it must be the second half of the char so the last position + caretPos = pos + 1; + } + currentWidth += charLength; + } + selectionLength = 0; } return true; diff --git a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/DoubleFieldController.java b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/DoubleFieldController.java index 1dbd7c0..8933df3 100644 --- a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/DoubleFieldController.java +++ b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/DoubleFieldController.java @@ -84,7 +84,7 @@ public class DoubleFieldController extends NumberFieldController<Double> { */ @Override public String getString() { - return BigDecimal.valueOf(option().pendingValue()).stripTrailingZeros().toPlainString(); + return String.valueOf(option().pendingValue()); } /** diff --git a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/FloatFieldController.java b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/FloatFieldController.java index 4b34d7f..b1eb3a2 100644 --- a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/FloatFieldController.java +++ b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/FloatFieldController.java @@ -84,7 +84,7 @@ public class FloatFieldController extends NumberFieldController<Float> { */ @Override public String getString() { - return BigDecimal.valueOf(option().pendingValue()).stripTrailingZeros().toPlainString(); + return String.valueOf(option().pendingValue()); } /** diff --git a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/IntegerFieldController.java b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/IntegerFieldController.java index 5f0121a..50eecec 100644 --- a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/IntegerFieldController.java +++ b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/IntegerFieldController.java @@ -62,6 +62,11 @@ public class IntegerFieldController extends NumberFieldController<Integer> { this(option, -Integer.MAX_VALUE, Integer.MAX_VALUE, IntegerSliderController.DEFAULT_FORMATTER); } + @Override + public boolean isInputValid(String input) { + return input.matches("\\d+|-|"); + } + /** * {@inheritDoc} */ diff --git a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/LongFieldController.java b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/LongFieldController.java index 713d39f..516de74 100644 --- a/src/client/java/dev/isxander/yacl/gui/controllers/string/number/LongFieldController.java +++ b/src/client/java/dev/isxander/yacl/gui/controllers/string/number/LongFieldController.java @@ -62,6 +62,11 @@ public class LongFieldController extends NumberFieldController<Long> { this(option, -Long.MAX_VALUE, Long.MAX_VALUE, LongSliderController.DEFAULT_FORMATTER); } + @Override + public boolean isInputValid(String input) { + return input.matches("\\d+|-|"); + } + /** * {@inheritDoc} */ |