From 5c66af7bd411c7caa3f2e4cc4f754066fe37eae3 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:38:24 +0300 Subject: Update Gradle, Loom and VFL --- build.gradle | 4 +- gradle/wrapper/gradle-wrapper.jar | Bin 59536 -> 61574 bytes gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew | 28 +++-- gradlew.bat | 181 ++++++++++++++++--------------- 5 files changed, 115 insertions(+), 101 deletions(-) diff --git a/build.gradle b/build.gradle index 0234a4d..2791cf1 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/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..943f0cb 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar 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 -- cgit From 2a05170b93d9522cc9d54d954a783dd6a7f01c1c Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 13:59:24 +0300 Subject: Initial port to 1.20.2 --- CREDITS.txt | 2 +- gradle.properties | 8 ++--- .../cotton/gui/client/CottonClientScreen.java | 17 ++++++---- .../cotton/gui/client/CottonInventoryScreen.java | 12 +++---- .../cotton/gui/impl/client/MouseInputHandler.java | 4 +-- .../cotton/gui/impl/client/WidgetTextures.java | 37 +++++++++++++++++++++ .../impl/mixin/client/PressableWidgetAccessor.java | 15 +++++++++ .../impl/mixin/client/SliderWidgetAccessor.java | 25 ++++++++++++++ .../cotton/gui/widget/WAbstractSlider.java | 6 ++-- .../github/cottonmc/cotton/gui/widget/WButton.java | 33 +++--------------- .../cottonmc/cotton/gui/widget/WLabeledSlider.java | 33 ++++-------------- .../cottonmc/cotton/gui/widget/WListPanel.java | 4 +-- .../cottonmc/cotton/gui/widget/WScrollBar.java | 4 +-- .../cottonmc/cotton/gui/widget/WScrollPanel.java | 13 ++++++-- .../github/cottonmc/cotton/gui/widget/WWidget.java | 9 ++--- .../cotton/gui/widget/data/InputResult.java | 12 +++++++ .../textures/gui/sprites/widget/button_dark.png | Bin 0 -> 3228 bytes .../gui/sprites/widget/button_dark.png.mcmeta | 10 ++++++ .../gui/sprites/widget/button_disabled_dark.png | Bin 0 -> 2107 bytes .../sprites/widget/button_disabled_dark.png.mcmeta | 10 ++++++ .../gui/sprites/widget/button_highlighted_dark.png | Bin 0 -> 3233 bytes .../widget/button_highlighted_dark.png.mcmeta | 10 ++++++ .../gui/sprites/widget/slider_handle_dark.png | Bin 0 -> 748 bytes .../sprites/widget/slider_handle_dark.png.mcmeta | 15 +++++++++ .../widget/slider_handle_highlighted_dark.png | Bin 0 -> 748 bytes .../slider_handle_highlighted_dark.png.mcmeta | 15 +++++++++ .../assets/libgui/textures/widget/dark_widgets.png | Bin 5798 -> 0 bytes src/main/resources/fabric.mod.json | 6 ++-- src/main/resources/mixins.libgui.json | 4 ++- .../cottonmc/test/client/DarkModeTestGui.java | 1 + 30 files changed, 214 insertions(+), 91 deletions(-) create mode 100644 src/main/java/io/github/cottonmc/cotton/gui/impl/client/WidgetTextures.java create mode 100644 src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/PressableWidgetAccessor.java create mode 100644 src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/SliderWidgetAccessor.java create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png.mcmeta delete mode 100644 src/main/resources/assets/libgui/textures/widget/dark_widgets.png 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/gradle.properties b/gradle.properties index 949a79a..bea13b9 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.0.2 @@ -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/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 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 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 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 { } } - 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..86a2630 --- /dev/null +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/WidgetTextures.java @@ -0,0 +1,37 @@ +package io.github.cottonmc.cotton.gui.impl.client; + +import io.github.cottonmc.cotton.gui.impl.mixin.client.SliderWidgetAccessor; + +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; + +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") + ); + + 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; + } + + private static Identifier id(String path) { + return new Identifier(LibGuiCommon.MOD_ID, path); + } +} 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 && mouseX198) 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..467a634 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 @@ -1,5 +1,8 @@ package io.github.cottonmc.cotton.gui.widget; +import io.github.cottonmc.cotton.gui.impl.client.WidgetTextures; +import io.github.cottonmc.cotton.gui.impl.mixin.client.SliderWidgetAccessor; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.DrawContext; @@ -175,22 +178,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 +197,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 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 0846d68..0c1af59 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 @@ -228,8 +228,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; } 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 @@ -10,6 +10,18 @@ public enum InputResult { PROCESSED, 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. * 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 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_dark.png 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..bcf5fc2 --- /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 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png 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..bcf5fc2 --- /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 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png 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..bcf5fc2 --- /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/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 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png 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..dab004a --- /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 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png 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..dab004a --- /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 Binary files a/src/main/resources/assets/libgui/textures/widget/dark_widgets.png and /dev/null differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9a59c86..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-rc.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); -- cgit From b5ab318efb559da0e7b8d3272fd18a2c38655c7d Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 14:07:20 +0300 Subject: Add BackgroundPainter.createGuiSprite --- .../cottonmc/cotton/gui/client/BackgroundPainter.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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..7831f33 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; /** @@ -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. + * + *

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()); + } } -- cgit From c891cde665a8f10c9264951085173c37e7aad9fe Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 14:07:49 +0300 Subject: Use GUI sprites for panel textures --- .../cottonmc/cotton/gui/client/BackgroundPainter.java | 4 ++-- .../libgui/textures/gui/sprites/widget/panel_dark.png | Bin 0 -> 1644 bytes .../textures/gui/sprites/widget/panel_dark.png.mcmeta | 10 ++++++++++ .../libgui/textures/gui/sprites/widget/panel_light.png | Bin 0 -> 650 bytes .../textures/gui/sprites/widget/panel_light.png.mcmeta | 10 ++++++++++ .../assets/libgui/textures/widget/panel_dark.png | Bin 1644 -> 0 bytes .../assets/libgui/textures/widget/panel_light.png | Bin 650 -> 0 bytes 7 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png.mcmeta delete mode 100644 src/main/resources/assets/libgui/textures/widget/panel_dark.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/panel_light.png 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 7831f33..a709b64 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 @@ -41,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")) ); /** diff --git a/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png new file mode 100644 index 0000000..c4e643f Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_dark.png 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..0f75440 --- /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/gui/sprites/widget/panel_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png new file mode 100644 index 0000000..8bb50a8 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/panel_light.png 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..0f75440 --- /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/panel_dark.png b/src/main/resources/assets/libgui/textures/widget/panel_dark.png deleted file mode 100644 index c4e643f..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/panel_dark.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/panel_light.png b/src/main/resources/assets/libgui/textures/widget/panel_light.png deleted file mode 100644 index 8bb50a8..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/panel_light.png and /dev/null differ -- cgit From 9f810d320dbdb9c58f5f8b6807c24cff9715fe5a Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 14:09:53 +0300 Subject: BackgroundPainter: Update texture paths in javadoc --- .../java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 a709b64..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 @@ -32,8 +32,8 @@ public interface BackgroundPainter { /** * The {@code VANILLA} background painter draws a vanilla-like GUI panel using nine-patch textures. * - *

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. + *

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. * *

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. -- cgit From 8d1d2442866b3bb3a4b1d098add0ccb65343cd60 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 22:19:41 +0300 Subject: Move scroll bar textures to GUI sprites --- .../cotton/gui/impl/client/WidgetTextures.java | 19 ++++++++++ .../cottonmc/cotton/gui/widget/WScrollBar.java | 39 ++++++--------------- .../sprites/widget/scroll_bar/background_dark.png | Bin 0 -> 165 bytes .../widget/scroll_bar/background_dark.png.mcmeta | 10 ++++++ .../sprites/widget/scroll_bar/background_light.png | Bin 0 -> 159 bytes .../widget/scroll_bar/background_light.png.mcmeta | 10 ++++++ .../gui/sprites/widget/scroll_bar/focus.png | Bin 0 -> 156 bytes .../gui/sprites/widget/scroll_bar/focus.png.mcmeta | 10 ++++++ .../gui/sprites/widget/scroll_bar/thumb_dark.png | Bin 0 -> 164 bytes .../widget/scroll_bar/thumb_dark.png.mcmeta | 10 ++++++ .../widget/scroll_bar/thumb_hovered_dark.png | Bin 0 -> 164 bytes .../scroll_bar/thumb_hovered_dark.png.mcmeta | 10 ++++++ .../widget/scroll_bar/thumb_hovered_light.png | Bin 0 -> 164 bytes .../scroll_bar/thumb_hovered_light.png.mcmeta | 10 ++++++ .../gui/sprites/widget/scroll_bar/thumb_light.png | Bin 0 -> 162 bytes .../widget/scroll_bar/thumb_light.png.mcmeta | 10 ++++++ .../widget/scroll_bar/thumb_pressed_dark.png | Bin 0 -> 164 bytes .../scroll_bar/thumb_pressed_dark.png.mcmeta | 10 ++++++ .../widget/scroll_bar/thumb_pressed_light.png | Bin 0 -> 161 bytes .../scroll_bar/thumb_pressed_light.png.mcmeta | 10 ++++++ .../textures/widget/scroll_bar/background_dark.png | Bin 165 -> 0 bytes .../widget/scroll_bar/background_light.png | Bin 159 -> 0 bytes .../libgui/textures/widget/scroll_bar/focus.png | Bin 156 -> 0 bytes .../textures/widget/scroll_bar/scroll_bar_dark.png | Bin 164 -> 0 bytes .../widget/scroll_bar/scroll_bar_hovered_dark.png | Bin 164 -> 0 bytes .../widget/scroll_bar/scroll_bar_hovered_light.png | Bin 164 -> 0 bytes .../widget/scroll_bar/scroll_bar_light.png | Bin 162 -> 0 bytes .../widget/scroll_bar/scroll_bar_pressed_dark.png | Bin 164 -> 0 bytes .../widget/scroll_bar/scroll_bar_pressed_light.png | Bin 161 -> 0 bytes 29 files changed, 120 insertions(+), 28 deletions(-) create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png.mcmeta create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png create mode 100644 src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png.mcmeta delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/background_dark.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/background_light.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/focus.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_dark.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_dark.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_light.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_light.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_dark.png delete mode 100644 src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_light.png 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 index 86a2630..fd5a806 100644 --- 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 @@ -22,6 +22,18 @@ public final class WidgetTextures { 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(); @@ -31,7 +43,14 @@ public final class WidgetTextures { 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/widget/WScrollBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java index a0c04be..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 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()); } } @@ -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 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 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 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 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 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 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 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/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png new file mode 100644 index 0000000..3df12e3 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_dark.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/background_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png new file mode 100644 index 0000000..38c6ef8 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/background_light.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/focus.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png new file mode 100644 index 0000000..955aa7e Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/focus.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/thumb_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png new file mode 100644 index 0000000..4c2aab0 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_dark.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png new file mode 100644 index 0000000..472db90 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_dark.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/thumb_hovered_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png new file mode 100644 index 0000000..b0695ed Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_hovered_light.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/thumb_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png new file mode 100644 index 0000000..6d802e7 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_light.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png new file mode 100644 index 0000000..8835712 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_dark.png 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..731ee64 --- /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/gui/sprites/widget/scroll_bar/thumb_pressed_light.png b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png new file mode 100644 index 0000000..9df19b0 Binary files /dev/null and b/src/main/resources/assets/libgui/textures/gui/sprites/widget/scroll_bar/thumb_pressed_light.png 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..731ee64 --- /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/widget/scroll_bar/background_dark.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_dark.png deleted file mode 100644 index 3df12e3..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_dark.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_light.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_light.png deleted file mode 100644 index 38c6ef8..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/background_light.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/focus.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/focus.png deleted file mode 100644 index 955aa7e..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/focus.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_dark.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_dark.png deleted file mode 100644 index 4c2aab0..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_dark.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_dark.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_dark.png deleted file mode 100644 index 472db90..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_dark.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_light.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_light.png deleted file mode 100644 index b0695ed..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_hovered_light.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_light.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_light.png deleted file mode 100644 index 6d802e7..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_light.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_dark.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_dark.png deleted file mode 100644 index 8835712..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_dark.png and /dev/null differ diff --git a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_light.png b/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_light.png deleted file mode 100644 index 9df19b0..0000000 Binary files a/src/main/resources/assets/libgui/textures/widget/scroll_bar/scroll_bar_pressed_light.png and /dev/null differ -- cgit From 5741cdd02b7b7b304bb44fb788900f1cf0097fc2 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 22:25:51 +0300 Subject: Fix messed up mcmeta formatting --- .../gui/sprites/widget/button_dark.png.mcmeta | 14 ++++++------- .../sprites/widget/button_disabled_dark.png.mcmeta | 14 ++++++------- .../widget/button_highlighted_dark.png.mcmeta | 14 ++++++------- .../gui/sprites/widget/panel_dark.png.mcmeta | 14 ++++++------- .../gui/sprites/widget/panel_light.png.mcmeta | 14 ++++++------- .../widget/scroll_bar/background_dark.png.mcmeta | 14 ++++++------- .../widget/scroll_bar/background_light.png.mcmeta | 14 ++++++------- .../gui/sprites/widget/scroll_bar/focus.png.mcmeta | 14 ++++++------- .../widget/scroll_bar/thumb_dark.png.mcmeta | 14 ++++++------- .../scroll_bar/thumb_hovered_dark.png.mcmeta | 14 ++++++------- .../scroll_bar/thumb_hovered_light.png.mcmeta | 14 ++++++------- .../widget/scroll_bar/thumb_light.png.mcmeta | 14 ++++++------- .../scroll_bar/thumb_pressed_dark.png.mcmeta | 14 ++++++------- .../scroll_bar/thumb_pressed_light.png.mcmeta | 14 ++++++------- .../sprites/widget/slider_handle_dark.png.mcmeta | 24 +++++++++++----------- .../slider_handle_highlighted_dark.png.mcmeta | 24 +++++++++++----------- 16 files changed, 122 insertions(+), 122 deletions(-) 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 index bcf5fc2..287153a 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 200, - "height": 20, - "border": 3 + "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.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_disabled_dark.png.mcmeta index bcf5fc2..287153a 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 200, - "height": 20, - "border": 3 + "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.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/button_highlighted_dark.png.mcmeta index bcf5fc2..287153a 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 200, - "height": 20, - "border": 3 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 200, + "height": 20, + "border": 3 + } } - } } 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 index 0f75440..628f1c7 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 4 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 4 + } } - } } 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 index 0f75440..628f1c7 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 4 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 4 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "gui": { + "scaling": { + "type": "nine_slice", + "width": 16, + "height": 16, + "border": 1 + } } - } } 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 index 731ee64..83b4877 100644 --- 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 @@ -1,10 +1,10 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 16, - "height": 16, - "border": 1 + "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.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_dark.png.mcmeta index dab004a..2024b86 100644 --- 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 @@ -1,15 +1,15 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 8, - "height": 20, - "border": { - "left": 2, - "top": 2, - "right": 2, - "bottom": 3 - } + "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.mcmeta b/src/main/resources/assets/libgui/textures/gui/sprites/widget/slider_handle_highlighted_dark.png.mcmeta index dab004a..2024b86 100644 --- 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 @@ -1,15 +1,15 @@ { - "gui": { - "scaling": { - "type": "nine_slice", - "width": 8, - "height": 20, - "border": { - "left": 2, - "top": 2, - "right": 2, - "bottom": 3 - } + "gui": { + "scaling": { + "type": "nine_slice", + "width": 8, + "height": 20, + "border": { + "left": 2, + "top": 2, + "right": 2, + "bottom": 3 + } + } } - } } -- cgit From d25b9444c277461c0d2effdff72d2d70d7792b6f Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 9 Sep 2023 22:28:53 +0300 Subject: Fix code style --- .../cotton/gui/impl/client/WidgetTextures.java | 36 +++++++++++----------- .../cottonmc/cotton/gui/widget/WLabeledSlider.java | 6 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) 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 index fd5a806..75975b2 100644 --- 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 @@ -1,38 +1,37 @@ package io.github.cottonmc.cotton.gui.impl.client; -import io.github.cottonmc.cotton.gui.impl.mixin.client.SliderWidgetAccessor; - 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() + 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") + 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") + 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") + 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") + 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) { @@ -51,6 +50,7 @@ public final class WidgetTextures { return new Identifier(LibGuiCommon.MOD_ID, path); } - public record ScrollBarTextures(Identifier background, Identifier thumb, Identifier thumbPressed, Identifier thumbHovered) { + public record ScrollBarTextures(Identifier background, Identifier thumb, Identifier thumbPressed, + Identifier thumbHovered) { } } 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 467a634..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 @@ -1,19 +1,17 @@ package io.github.cottonmc.cotton.gui.widget; -import io.github.cottonmc.cotton.gui.impl.client.WidgetTextures; -import io.github.cottonmc.cotton.gui.impl.mixin.client.SliderWidgetAccessor; - import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; 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; -- cgit