aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CREDITS.txt2
-rw-r--r--build.gradle4
-rw-r--r--gradle.properties8
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin59536 -> 61574 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties3
-rwxr-xr-xgradlew28
-rw-r--r--gradlew.bat181
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java24
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java17
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java12
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/MouseInputHandler.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/WidgetTextures.java56
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/PressableWidgetAccessor.java15
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/SliderWidgetAccessor.java25
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java6
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java33
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java33
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java43
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java13
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java9
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/data/InputResult.java12
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.pngbin0 -> 3228 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.pngbin0 -> 2107 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.pngbin0 -> 3233 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png (renamed from src/main/resources/assets/libgui/textures/widget/panel_dark.png)bin1644 -> 1644 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png (renamed from src/main/resources/assets/libgui/textures/widget/panel_light.png)bin650 -> 650 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/background_dark.png)bin165 -> 165 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/background_light.png)bin159 -> 159 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/focus.png)bin156 -> 156 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_dark.png)bin164 -> 164 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_dark.png)bin164 -> 164 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_light.png)bin164 -> 164 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_light.png)bin162 -> 162 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_dark.png)bin164 -> 164 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png (renamed from src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_light.png)bin161 -> 161 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png.mcmeta10
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.pngbin0 -> 748 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png.mcmeta15
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.pngbin0 -> 748 bytes
-rw-r--r--src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png.mcmeta15
-rw-r--r--src/main/resources/assets/libgui/textures/widget/dark_widgets.pngbin5798 -> 0 bytes
-rw-r--r--src/main/resources/fabric.mod.json6
-rw-r--r--src/main/resources/mixins.libgui.json4
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java1
58 files changed, 488 insertions, 225 deletions
diff --git a/CREDITS.txt b/CREDITS.txt
index a8bfbd8..439466e 100644
--- a/CREDITS.txt
+++ b/CREDITS.txt
@@ -1 +1 @@
-- Dark-mode button textures (dark_widgets.png) are adapted from Roughly Enough Items by shedaniel, licensed under MIT
+- Dark-mode button textures (button*_dark.png) are adapted from Roughly Enough Items by shedaniel, licensed under MIT
diff --git a/build.gradle b/build.gradle
index 24bc15c..6c4e13f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
plugins {
- id 'fabric-loom' version '1.1.+'
- id 'io.github.juuxel.loom-quiltflower' version '1.8.0'
+ id 'fabric-loom' version '1.3.+'
+ id 'io.github.juuxel.loom-vineflower' version '1.11.0'
id 'maven-publish'
id 'checkstyle'
}
diff --git a/gradle.properties b/gradle.properties
index f2c6280..8d625e1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
- minecraft_version=1.20.1
- yarn_mappings=1.20.1+build.10
- loader_version=0.14.21
+ minecraft_version=1.20.2-pre2
+ yarn_mappings=1.20.2-pre2+build.3
+ loader_version=0.14.22
# Mod Properties
mod_version = 8.1.0
@@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx1G
archives_base_name = LibGui
# Dependencies
- fabric_version=0.86.1+1.20.1
+ fabric_version=0.88.3+1.20.2
jankson_version=6.0.0+j1.2.3
modmenu_version=7.0.1
libninepatch_version=1.2.0
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 7454180..943f0cb 100644
--- a/gradle/wrapper/gradle-wrapper.jar
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 070cb70..c30b486 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
+networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index c53aefa..65dcd68 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
-# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
-# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
-# * compound commands having a testable exit status, especially «case»;
-# * various built-in commands including «command», «set», and «ulimit».
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,10 +80,10 @@ do
esac
done
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-APP_NAME="Gradle"
+# This is normally unused
+# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
diff --git a/gradlew.bat b/gradlew.bat
index 107acd3..6689b85 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,89 +1,92 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
index f3df523..52bd317 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
@@ -10,6 +10,7 @@ import io.github.cottonmc.cotton.gui.widget.data.Texture;
import juuxel.libninepatch.NinePatch;
import juuxel.libninepatch.TextureRegion;
+import java.util.Objects;
import java.util.function.Consumer;
/**
@@ -31,8 +32,8 @@ public interface BackgroundPainter {
/**
* The {@code VANILLA} background painter draws a vanilla-like GUI panel using nine-patch textures.
*
- * <p>This background painter uses {@code libgui:textures/widget/panel_light.png} as the light texture and
- * {@code libgui:textures/widget/panel_dark.png} as the dark texture.
+ * <p>This background painter uses {@code libgui:textures/gui/sprites/widget/panel_light.png} as the light texture and
+ * {@code libgui:textures/gui/sprites/widget/panel_dark.png} as the dark texture.
*
* <p>This background painter is the default painter for root panels.
* * You can override {@link io.github.cottonmc.cotton.gui.GuiDescription#addPainters()} to customize the painter yourself.
@@ -40,8 +41,8 @@ public interface BackgroundPainter {
* @since 1.5.0
*/
public static BackgroundPainter VANILLA = createLightDarkVariants(
- createNinePatch(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/panel_light.png")),
- createNinePatch(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/panel_dark.png"))
+ createGuiSprite(new Identifier(LibGuiCommon.MOD_ID, "widget/panel_light")),
+ createGuiSprite(new Identifier(LibGuiCommon.MOD_ID, "widget/panel_dark"))
);
/**
@@ -158,4 +159,19 @@ public interface BackgroundPainter {
else light.paintBackground(context, left, top, panel);
};
}
+
+ /**
+ * Creates a background painter that uses a texture from the GUI atlas.
+ *
+ * <p>This method can be used to draw tiled or nine-slice GUI sprites from resource packs
+ * as a simpler and more data-driven alternative to {@link #createNinePatch(Identifier)}.
+ *
+ * @param texture the texture ID
+ * @return a new background painter that uses a GUI sprite
+ * @since 9.0.0
+ */
+ static BackgroundPainter createGuiSprite(Identifier texture) {
+ Objects.requireNonNull(texture, "Texture cannot be null");
+ return (context, left, top, panel) -> context.drawGuiTexture(texture, left, top, panel.getWidth(), panel.getHeight());
+ }
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
index 877528c..071bb39 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
@@ -123,10 +123,13 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
}
}
- private void paint(DrawContext context, int mouseX, int mouseY) {
- renderBackground(context);
+ private void paint(DrawContext context, int mouseX, int mouseY, float delta) {
+ renderBackground(context, mouseX, mouseY, delta);
if (description!=null) {
+ context.getMatrices().push();
+ context.getMatrices().translate(0f, 0f, 0.01f);
+
WPanel root = description.getRootPanel();
if (root!=null) {
GL11.glEnable(GL11.GL_SCISSOR_TEST);
@@ -140,12 +143,14 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
int width = description.getRootPanel().getWidth();
ScreenDrawing.drawString(context, getTitle().asOrderedText(), description.getTitleAlignment(), left + titleX, top + titleY, width - 2 * titleX, description.getTitleColor());
}
+
+ context.getMatrices().pop();
}
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
- paint(context, mouseX, mouseY);
+ paint(context, mouseX, mouseY, partialTicks);
super.render(context, mouseX, mouseY, partialTicks);
@@ -207,12 +212,12 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
}
@Override
- public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
- super.mouseScrolled(mouseX, mouseY, amount);
+ public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
+ super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
int containerX = (int)mouseX-left;
int containerY = (int)mouseY-top;
- mouseInputHandler.onMouseScroll(containerX, containerY, amount);
+ mouseInputHandler.onMouseScroll(containerX, containerY, horizontalAmount, verticalAmount);
return true;
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
index b1ed4ce..3d807e0 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
@@ -223,12 +223,12 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
}
@Override
- public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
- super.mouseScrolled(mouseX, mouseY, amount);
+ public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
+ super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
int containerX = (int)mouseX-x;
int containerY = (int)mouseY-y;
- mouseInputHandler.onMouseScroll(containerX, containerY, amount);
+ mouseInputHandler.onMouseScroll(containerX, containerY, horizontalAmount, verticalAmount);
return true;
}
@@ -275,8 +275,8 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
@Override
protected void drawBackground(DrawContext context, float partialTicks, int mouseX, int mouseY) {} //This is just an AbstractContainerScreen thing; most Screens don't work this way.
- private void paint(DrawContext context, int mouseX, int mouseY) {
- renderBackground(context);
+ private void paint(DrawContext context, int mouseX, int mouseY, float delta) {
+ renderBackground(context, mouseX, mouseY, delta);
if (description!=null) {
WPanel root = description.getRootPanel();
@@ -292,7 +292,7 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
@Override
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
- paint(context, mouseX, mouseY);
+ paint(context, mouseX, mouseY, partialTicks);
super.render(context, mouseX, mouseY, partialTicks);
DiffuseLighting.disableGuiDepthLighting(); //Needed because super.render leaves dirty state
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/MouseInputHandler.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/MouseInputHandler.java
index 0814e16..15aa875 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/MouseInputHandler.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/MouseInputHandler.java
@@ -85,10 +85,10 @@ public final class MouseInputHandler<S extends Screen & CottonScreenImpl> {
}
}
- public void onMouseScroll(int containerX, int containerY, double amount) {
+ public void onMouseScroll(int containerX, int containerY, double horizontalAmount, double verticalAmount) {
runTree(
screen.getDescription().getRootPanel().hit(containerX, containerY),
- widget -> widget.onMouseScroll(containerX - widget.getAbsoluteX(), containerY - widget.getAbsoluteY(), amount)
+ widget -> widget.onMouseScroll(containerX - widget.getAbsoluteX(), containerY - widget.getAbsoluteY(), horizontalAmount, verticalAmount)
);
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/WidgetTextures.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/WidgetTextures.java
new file mode 100644
index 0000000..75975b2
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/WidgetTextures.java
@@ -0,0 +1,56 @@
+package io.github.cottonmc.cotton.gui.impl.client;
+
+import net.minecraft.client.gui.screen.ButtonTextures;
+import net.minecraft.util.Identifier;
+
+import io.github.cottonmc.cotton.gui.impl.LibGuiCommon;
+import io.github.cottonmc.cotton.gui.impl.mixin.client.PressableWidgetAccessor;
+import io.github.cottonmc.cotton.gui.impl.mixin.client.SliderWidgetAccessor;
+
+public final class WidgetTextures {
+ private static final ButtonTextures LIGHT_LABELED_SLIDER_HANDLE = new ButtonTextures(
+ SliderWidgetAccessor.libgui$getHandleTexture(),
+ SliderWidgetAccessor.libgui$getHandleHighlightedTexture()
+ );
+ private static final ButtonTextures DARK_LABELED_SLIDER_HANDLE = new ButtonTextures(
+ id("widget/slider_handle_dark"),
+ id("widget/slider_handle_highlighted_dark")
+ );
+ private static final ButtonTextures DARK_BUTTON = new ButtonTextures(
+ id("widget/button_dark"),
+ id("widget/button_disabled_dark"),
+ id("widget/button_highlighted_dark")
+ );
+ private static final ScrollBarTextures LIGHT_SCROLL_BAR = new ScrollBarTextures(
+ id("widget/scroll_bar/background_light"),
+ id("widget/scroll_bar/thumb_light"),
+ id("widget/scroll_bar/thumb_pressed_light"),
+ id("widget/scroll_bar/thumb_hovered_light")
+ );
+ private static final ScrollBarTextures DARK_SCROLL_BAR = new ScrollBarTextures(
+ id("widget/scroll_bar/background_dark"),
+ id("widget/scroll_bar/thumb_dark"),
+ id("widget/scroll_bar/thumb_pressed_dark"),
+ id("widget/scroll_bar/thumb_hovered_dark")
+ );
+
+ public static ButtonTextures getButtonTextures(boolean dark) {
+ return dark ? DARK_BUTTON : PressableWidgetAccessor.libgui$getTextures();
+ }
+
+ public static ButtonTextures getLabeledSliderHandleTextures(boolean dark) {
+ return dark ? DARK_LABELED_SLIDER_HANDLE : LIGHT_LABELED_SLIDER_HANDLE;
+ }
+
+ public static ScrollBarTextures getScrollBarTextures(boolean dark) {
+ return dark ? DARK_SCROLL_BAR : LIGHT_SCROLL_BAR;
+ }
+
+ private static Identifier id(String path) {
+ return new Identifier(LibGuiCommon.MOD_ID, path);
+ }
+
+ public record ScrollBarTextures(Identifier background, Identifier thumb, Identifier thumbPressed,
+ Identifier thumbHovered) {
+ }
+}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/PressableWidgetAccessor.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/PressableWidgetAccessor.java
new file mode 100644
index 0000000..b984af1
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/PressableWidgetAccessor.java
@@ -0,0 +1,15 @@
+package io.github.cottonmc.cotton.gui.impl.mixin.client;
+
+import net.minecraft.client.gui.screen.ButtonTextures;
+import net.minecraft.client.gui.widget.PressableWidget;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(PressableWidget.class)
+public interface PressableWidgetAccessor {
+ @Accessor("TEXTURES")
+ static ButtonTextures libgui$getTextures() {
+ throw new AssertionError();
+ }
+}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/SliderWidgetAccessor.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/SliderWidgetAccessor.java
new file mode 100644
index 0000000..ce9ea1a
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/SliderWidgetAccessor.java
@@ -0,0 +1,25 @@
+package io.github.cottonmc.cotton.gui.impl.mixin.client;
+
+import net.minecraft.client.gui.widget.SliderWidget;
+import net.minecraft.util.Identifier;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(SliderWidget.class)
+public interface SliderWidgetAccessor {
+ @Accessor("TEXTURE")
+ static Identifier libgui$getTexture() {
+ throw new AssertionError();
+ }
+
+ @Accessor("HANDLE_TEXTURE")
+ static Identifier libgui$getHandleTexture() {
+ throw new AssertionError();
+ }
+
+ @Accessor("HANDLE_HIGHLIGHTED_TEXTURE")
+ static Identifier libgui$getHandleHighlightedTexture() {
+ throw new AssertionError();
+ }
+}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java
index 945c121..3621233 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java
@@ -183,13 +183,13 @@ public abstract class WAbstractSlider extends WWidget {
@Environment(EnvType.CLIENT)
@Override
- public InputResult onMouseScroll(int x, int y, double amount) {
+ public InputResult onMouseScroll(int x, int y, double horizontalAmount, double verticalAmount) {
if (direction == Direction.LEFT || direction == Direction.DOWN) {
- amount = -amount;
+ verticalAmount = -verticalAmount;
}
int previous = value;
- value = MathHelper.clamp(value + (int) Math.signum(amount) * MathHelper.ceil(valueToCoordRatio * Math.abs(amount) * 2), min, max);
+ value = MathHelper.clamp(value + (int) Math.signum(verticalAmount) * MathHelper.ceil(valueToCoordRatio * Math.abs(verticalAmount) * 2), min, max);
if (previous != value) {
onValueChanged(value);
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
index 1230905..5367483 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
@@ -4,23 +4,23 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
+import net.minecraft.client.gui.screen.ButtonTextures;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.screen.narration.NarrationPart;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.impl.client.NarrationMessages;
+import io.github.cottonmc.cotton.gui.impl.client.WidgetTextures;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
import io.github.cottonmc.cotton.gui.widget.data.InputResult;
import io.github.cottonmc.cotton.gui.widget.icon.Icon;
import org.jetbrains.annotations.Nullable;
public class WButton extends WWidget {
- private static final Identifier DARK_WIDGETS_LOCATION = new Identifier("libgui", "textures/widget/dark_widgets.png");
private static final int BUTTON_HEIGHT = 20;
private static final int ICON_SPACING = 2;
@@ -89,27 +89,9 @@ public class WButton extends WWidget {
@Environment(EnvType.CLIENT)
@Override
public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
- boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX<getWidth() && mouseY<getHeight());
- int state = 1; //1=regular. 2=hovered. 0=disabled.
- if (!enabled) {
- state = 0;
- } else if (hovered || isFocused()) {
- state = 2;
- }
-
- float px = 1/256f;
- float buttonLeft = 0 * px;
- float buttonTop = (46 + (state*20)) * px;
- int halfWidth = getWidth()/2;
- if (halfWidth>198) halfWidth=198;
- float buttonWidth = halfWidth*px;
- float buttonHeight = 20*px;
-
- float buttonEndLeft = (200-(getWidth()/2)) * px;
-
- Identifier texture = getTexture(this);
- ScreenDrawing.texturedRect(context, x, y, getWidth()/2, 20, texture, buttonLeft, buttonTop, buttonLeft+buttonWidth, buttonTop+buttonHeight, 0xFFFFFFFF);
- ScreenDrawing.texturedRect(context, x+(getWidth()/2), y, getWidth()/2, 20, texture, buttonEndLeft, buttonTop, 200*px, buttonTop+buttonHeight, 0xFFFFFFFF);
+ boolean hovered = isWithinBounds(mouseX, mouseY);
+ ButtonTextures textures = WidgetTextures.getButtonTextures(shouldRenderInDarkMode());
+ context.drawGuiTexture(textures.get(enabled, hovered || isFocused()), x, y, getWidth(), getHeight());
if (icon != null) {
icon.paint(context, x+ICON_SPACING, y+(BUTTON_HEIGHT-iconSize)/2, iconSize);
@@ -266,9 +248,4 @@ public class WButton extends WWidget {
}
}
}
-
- @Environment(EnvType.CLIENT)
- static Identifier getTexture(WWidget widget) {
- return widget.shouldRenderInDarkMode() ? DARK_WIDGETS_LOCATION : ClickableWidget.WIDGETS_TEXTURE;
- }
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
index d8cca29..3a2f967 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
@@ -6,11 +6,12 @@ import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.screen.narration.NarrationPart;
import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.impl.client.NarrationMessages;
+import io.github.cottonmc.cotton.gui.impl.client.WidgetTextures;
+import io.github.cottonmc.cotton.gui.impl.mixin.client.SliderWidgetAccessor;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
import org.jetbrains.annotations.Nullable;
@@ -175,22 +176,17 @@ public class WLabeledSlider extends WAbstractSlider {
matrices.translate(0, height, 0);
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(270));
}
- drawButton(context, 0, 0, 0, aWidth);
+ context.drawGuiTexture(SliderWidgetAccessor.libgui$getTexture(), 0, 0, aWidth, aHeight);
- // 1: regular, 2: hovered, 0: disabled/dragging
int thumbX = Math.round(coordToValueRatio * (value - min));
int thumbY = 0;
int thumbWidth = getThumbWidth();
int thumbHeight = aHeight;
boolean hovering = rotMouseX >= thumbX && rotMouseX <= thumbX + thumbWidth && rotMouseY >= thumbY && rotMouseY <= thumbY + thumbHeight;
- int thumbState = dragging || hovering ? 2 : 1;
- drawButton(context, thumbX, thumbY, thumbState, thumbWidth);
-
- if (thumbState == 1 && isFocused()) {
- float px = 1 / 32f;
- ScreenDrawing.texturedRect(context, thumbX, thumbY, thumbWidth, thumbHeight, WSlider.LIGHT_TEXTURE, 24*px, 0*px, 32*px, 20*px, 0xFFFFFFFF);
- }
+ var thumbTextures = WidgetTextures.getLabeledSliderHandleTextures(shouldRenderInDarkMode());
+ var thumbTexture = thumbTextures.get(true, dragging || hovering);
+ context.drawGuiTexture(thumbTexture, thumbX, thumbY, thumbWidth, thumbHeight);
if (label != null) {
int color = isMouseInsideBounds(mouseX, mouseY) ? 0xFFFFA0 : 0xE0E0E0;
@@ -199,23 +195,6 @@ public class WLabeledSlider extends WAbstractSlider {
matrices.pop();
}
- // state = 1: regular, 2: hovered, 0: disabled/dragging
- @Environment(EnvType.CLIENT)
- private void drawButton(DrawContext context, int x, int y, int state, int width) {
- float px = 1 / 256f;
- float buttonLeft = 0 * px;
- float buttonTop = (46 + (state * 20)) * px;
- int halfWidth = width / 2;
- if (halfWidth > 198) halfWidth = 198;
- float buttonWidth = halfWidth * px;
- float buttonHeight = 20 * px;
- float buttonEndLeft = (200 - halfWidth) * px;
-
- Identifier texture = WButton.getTexture(this);
- ScreenDrawing.texturedRect(context, x, y, halfWidth, 20, texture, buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight, 0xFFFFFFFF);
- ScreenDrawing.texturedRect(context, x + halfWidth, y, halfWidth, 20, texture, buttonEndLeft, buttonTop, 200 * px, buttonTop + buttonHeight, 0xFFFFFFFF);
- }
-
@Environment(EnvType.CLIENT)
@Override
public void addNarrations(NarrationMessageBuilder builder) {
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java
index 06db362..9b0bc58 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java
@@ -226,8 +226,8 @@ public class WListPanel<D, W extends WWidget> extends WClippedPanel {
}
@Override
- public InputResult onMouseScroll(int x, int y, double amount) {
- return scrollBar.onMouseScroll(0, 0, amount);
+ public InputResult onMouseScroll(int x, int y, double horizontalAmount, double verticalAmount) {
+ return scrollBar.onMouseScroll(0, 0, horizontalAmount, verticalAmount);
}
/**
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
index 2b7bb0c..add8688 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
@@ -7,17 +7,14 @@ import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.screen.narration.NarrationPart;
import net.minecraft.util.Identifier;
-import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
import io.github.cottonmc.cotton.gui.impl.LibGuiCommon;
import io.github.cottonmc.cotton.gui.impl.client.NarrationMessages;
-import io.github.cottonmc.cotton.gui.impl.client.NinePatchTextureRendererImpl;
+import io.github.cottonmc.cotton.gui.impl.client.WidgetTextures;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.InputResult;
-import juuxel.libninepatch.NinePatch;
-
-import static io.github.cottonmc.cotton.gui.client.BackgroundPainter.createNinePatch;
public class WScrollBar extends WWidget {
+ private static final Identifier FOCUS_TEXTURE = new Identifier(LibGuiCommon.MOD_ID, "widget/scroll_bar/focus");
private static final int SCROLLING_SPEED = 4;
protected Axis axis = Axis.HORIZONTAL;
@@ -49,34 +46,35 @@ public class WScrollBar extends WWidget {
public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
var matrices = context.getMatrices();
boolean darkMode = shouldRenderInDarkMode();
+ var textures = WidgetTextures.getScrollBarTextures(darkMode);
- Painters.BACKGROUND.paintBackground(context, x, y, this);
+ context.drawGuiTexture(textures.background(), x, y, getWidth(), getHeight());
- NinePatch<Identifier> painter = (darkMode ? Painters.SCROLL_BAR_DARK : Painters.SCROLL_BAR);
+ Identifier thumbTexture = textures.thumb();
if (maxValue <= 0) return;
if (sliding) {
- painter = (darkMode ? Painters.SCROLL_BAR_PRESSED_DARK : Painters.SCROLL_BAR_PRESSED);
+ thumbTexture = textures.thumbPressed();
} else if (isWithinBounds(mouseX, mouseY)) {
- painter = (darkMode ? Painters.SCROLL_BAR_HOVERED_DARK : Painters.SCROLL_BAR_HOVERED);
+ thumbTexture = textures.thumbHovered();
}
matrices.push();
if (axis == Axis.HORIZONTAL) {
matrices.translate(x + 1 + getHandlePosition(), y + 1, 0);
- painter.draw(NinePatchTextureRendererImpl.INSTANCE, context, getHandleSize(), height - 2);
+ context.drawGuiTexture(thumbTexture, 0, 0, getHandleSize(), getHeight() - 2);
if (isFocused()) {
- Painters.FOCUS.draw(NinePatchTextureRendererImpl.INSTANCE, context, getHandleSize(), height - 2);
+ context.drawGuiTexture(FOCUS_TEXTURE, 0, 0, getHandleSize(), getHeight() - 2);
}
} else {
matrices.translate(x + 1, y + 1 + getHandlePosition(), 0);
- painter.draw(NinePatchTextureRendererImpl.INSTANCE, context, width - 2, getHandleSize());
+ context.drawGuiTexture(thumbTexture, 0, 0, getWidth() - 2, getHandleSize());
if (isFocused()) {
- Painters.FOCUS.draw(NinePatchTextureRendererImpl.INSTANCE, context, width - 2, getHandleSize());
+ context.drawGuiTexture(FOCUS_TEXTURE, 0, 0, getWidth() - 2, getHandleSize());
}
}
@@ -204,8 +202,8 @@ public class WScrollBar extends WWidget {
@Environment(EnvType.CLIENT)
@Override
- public InputResult onMouseScroll(int x, int y, double amount) {
- setValue(getValue() + (int) -amount * SCROLLING_SPEED);
+ public InputResult onMouseScroll(int x, int y, double horizontalAmount, double verticalAmount) {
+ setValue(getValue() + (int) (horizontalAmount - verticalAmount) * SCROLLING_SPEED);
return InputResult.PROCESSED;
}
@@ -255,19 +253,4 @@ public class WScrollBar extends WWidget {
builder.put(NarrationPart.TITLE, NarrationMessages.SCROLL_BAR_TITLE);
builder.put(NarrationPart.USAGE, NarrationMessages.SLIDER_USAGE);
}
-
- @Environment(EnvType.CLIENT)
- static final class Painters {
- static final NinePatch<Identifier> SCROLL_BAR = NinePatch.builder(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/scroll_bar_light.png")).cornerSize(4).cornerUv(0.25f).build();
- static final NinePatch<Identifier> SCROLL_BAR_DARK = NinePatch.builder(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/scroll_bar_dark.png")).cornerSize(4).cornerUv(0.25f).build();
- static final NinePatch<Identifier> SCROLL_BAR_PRESSED = NinePatch.builder(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/scroll_bar_pressed_light.png")).cornerSize(4).cornerUv(0.25f).build();
- static final NinePatch<Identifier> SCROLL_BAR_PRESSED_DARK = NinePatch.builder(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/scroll_bar_pressed_dark.png")).cornerSize(4).cornerUv(0.25f).build();
- static final NinePatch<Identifier> SCROLL_BAR_HOVERED = NinePatch.builder(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/scroll_bar_hovered_light.png")).cornerSize(4).cornerUv(0.25f).build();
- static final NinePatch<Identifier> SCROLL_BAR_HOVERED_DARK = NinePatch.builder(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/scroll_bar_hovered_dark.png")).cornerSize(4).cornerUv(0.25f).build();
- static final BackgroundPainter BACKGROUND = BackgroundPainter.createLightDarkVariants(
- createNinePatch(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/background_light.png")),
- createNinePatch(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/background_dark.png"))
- );
- static final NinePatch<Identifier> FOCUS = NinePatch.builder(new Identifier(LibGuiCommon.MOD_ID, "textures/widget/scroll_bar/focus.png")).cornerSize(4).cornerUv(0.25f).build();
- }
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java
index facac1b..620adc8 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java
@@ -143,12 +143,19 @@ public class WScrollPanel extends WClippedPanel {
}
@Override
- public InputResult onMouseScroll(int x, int y, double amount) {
+ public InputResult onMouseScroll(int x, int y, double horizontalAmount, double verticalAmount) {
+ var horizontalResult = InputResult.IGNORED;
+ var verticalResult = InputResult.IGNORED;
+
+ if (hasHorizontalScrollbar()) {
+ horizontalResult = horizontalScrollBar.onMouseScroll(x, y, horizontalAmount, 0);
+ }
+
if (hasVerticalScrollbar()) {
- return verticalScrollBar.onMouseScroll(0, 0, amount);
+ verticalResult = verticalScrollBar.onMouseScroll(0, 0, 0, verticalAmount);
}
- return InputResult.IGNORED;
+ return horizontalResult.or(verticalResult);
}
@Override
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java
index 1486928..e8c3908 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java
@@ -212,13 +212,14 @@ public class WWidget {
/**
* Notifies this widget that the mouse has been scrolled inside its bounds.
*
- * @param x The X coordinate of the event, in widget-space (0 is the left edge of this widget)
- * @param y The Y coordinate of the event, in widget-space (0 is the top edge of this widget)
- * @param amount The scrolled amount. Positive values are up and negative values are down.
+ * @param x The X coordinate of the event, in widget-space (0 is the left edge of this widget)
+ * @param y The Y coordinate of the event, in widget-space (0 is the top edge of this widget)
+ * @param horizontalAmount The scrolled horizontal amount. Positive values are right and negative values are left.
+ * @param verticalAmount The scrolled vertical amount. Positive values are up and negative values are down.
* @return {@link InputResult#PROCESSED} if the event is handled, {@link InputResult#IGNORED} otherwise.
*/
@Environment(EnvType.CLIENT)
- public InputResult onMouseScroll(int x, int y, double amount) {
+ public InputResult onMouseScroll(int x, int y, double horizontalAmount, double verticalAmount) {
return InputResult.IGNORED;
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/InputResult.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/InputResult.java
index 4fed438..479977e 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/InputResult.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/InputResult.java
@@ -11,6 +11,18 @@ public enum InputResult {
IGNORED;
/**
+ * Combines this input result with another.
+ * The combination is {@link #PROCESSED} is at least one of the inputs is.
+ *
+ * @param other the other input result
+ * @return the combined input result
+ * @since 9.0.0
+ */
+ public InputResult or(InputResult other) {
+ return this == IGNORED && other == IGNORED ? IGNORED : PROCESSED;
+ }
+
+ /**
* Gets the corresponding input result for a {@code processed} boolean.
*
* @param processed whether an input event was processed
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png
new file mode 100644
index 0000000..437de7c
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png.mcmeta
new file mode 100644
index 0000000..287153a
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 200,
+ "height": 20,
+ "border": 3
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png
new file mode 100644
index 0000000..83e5146
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png.mcmeta
new file mode 100644
index 0000000..287153a
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 200,
+ "height": 20,
+ "border": 3
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png
new file mode 100644
index 0000000..59f0561
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png.mcmeta
new file mode 100644
index 0000000..287153a
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 200,
+ "height": 20,
+ "border": 3
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/panel_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png
index c4e643f..c4e643f 100644
--- a/src/main/resources/assets/libgui/textures/widget/panel_dark.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png.mcmeta
new file mode 100644
index 0000000..628f1c7
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 4
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/panel_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png
index 8bb50a8..8bb50a8 100644
--- a/src/main/resources/assets/libgui/textures/widget/panel_light.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png.mcmeta
new file mode 100644
index 0000000..628f1c7
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 4
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png
index 3df12e3..3df12e3 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_dark.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png
index 38c6ef8..38c6ef8 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_light.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/focus.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png
index 955aa7e..955aa7e 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/focus.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png
index 4c2aab0..4c2aab0 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_dark.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png
index 472db90..472db90 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_dark.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png
index b0695ed..b0695ed 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_light.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png
index 6d802e7..6d802e7 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_light.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png
index 8835712..8835712 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_dark.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png
index 9df19b0..9df19b0 100644
--- a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_light.png
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png.mcmeta
new file mode 100644
index 0000000..83b4877
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png.mcmeta
@@ -0,0 +1,10 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 16,
+ "height": 16,
+ "border": 1
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png
new file mode 100644
index 0000000..f843714
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png.mcmeta
new file mode 100644
index 0000000..2024b86
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png.mcmeta
@@ -0,0 +1,15 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 8,
+ "height": 20,
+ "border": {
+ "left": 2,
+ "top": 2,
+ "right": 2,
+ "bottom": 3
+ }
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png
new file mode 100644
index 0000000..dff8794
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png
Binary files differ
diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png.mcmeta
new file mode 100644
index 0000000..2024b86
--- /dev/null
+++ b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png.mcmeta
@@ -0,0 +1,15 @@
+{
+ "gui": {
+ "scaling": {
+ "type": "nine_slice",
+ "width": 8,
+ "height": 20,
+ "border": {
+ "left": 2,
+ "top": 2,
+ "right": 2,
+ "bottom": 3
+ }
+ }
+ }
+}
diff --git a/src/main/resources/assets/libgui/textures/widget/dark_widgets.png b/src/main/resources/assets/libgui/textures/widget/dark_widgets.png
deleted file mode 100644
index 8482d76..0000000
--- a/src/main/resources/assets/libgui/textures/widget/dark_widgets.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 0076160..bbd2386 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -25,12 +25,12 @@
"mixins": ["mixins.libgui.json"],
"depends": {
"java": ">=17",
- "fabricloader": ">=0.14.21",
+ "fabricloader": ">=0.14.22",
"fabric-api-base": ">=0.4.4",
"fabric-lifecycle-events-v1": "^2.0.2",
- "fabric-networking-api-v1": "^1.0.21",
+ "fabric-networking-api-v1": "^3.0.5",
"fabric-rendering-v1": "^3.0.6",
- "minecraft": "=1.20.1",
+ "minecraft": ">=1.20.2-beta.2",
"jankson": "^6.0.0",
"libninepatch": "^1.2.0"
},
diff --git a/src/main/resources/mixins.libgui.json b/src/main/resources/mixins.libgui.json
index 6698d08..d72e129 100644
--- a/src/main/resources/mixins.libgui.json
+++ b/src/main/resources/mixins.libgui.json
@@ -7,7 +7,9 @@
"client": [
"client.MinecraftClientMixin",
- "client.ScreenAccessor"
+ "client.PressableWidgetAccessor",
+ "client.ScreenAccessor",
+ "client.SliderWidgetAccessor"
],
"injectors": {
diff --git a/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java
index 2caea5c..f9012d7 100644
--- a/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java
+++ b/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java
@@ -28,6 +28,7 @@ public final class DarkModeTestGui extends LightweightGuiDescription {
root.add(new WButton(Text.literal("Button B")), 0, 1, 3, 1);
root.add(new WText(Text.literal("Text")), 0, 2, 3, 1);
root.add(new WLabeledSlider(1, 100, Text.literal("Slider A")), 3, 0, 3, 1);
+ root.add(new WLabeledSlider(1, 100, Axis.VERTICAL, Text.literal("Slider B")), 6, 0, 1, 3);
root.add(new WSlider(1, 100, Axis.HORIZONTAL), 3, 1, 3, 1);
root.add(new WLabel(Text.literal("Label")), 3, 2, 3, 1);
root.add(new WScrollBar(Axis.HORIZONTAL), 0, 3, 3, 1);