diff options
author | isXander <xandersmith2008@gmail.com> | 2022-11-30 19:05:39 +0000 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2022-11-30 19:05:39 +0000 |
commit | 60a06e94e2fc176294f9ff426fee6d0621946c22 (patch) | |
tree | dc27e7a1d8d95b532ff669dde30ec918d6213f54 | |
parent | 2967e6bb7bc723e20a09ea8f9d81e380bfafe1a1 (diff) | |
download | YetAnotherConfigLib-60a06e94e2fc176294f9ff426fee6d0621946c22.tar.gz YetAnotherConfigLib-60a06e94e2fc176294f9ff426fee6d0621946c22.tar.bz2 YetAnotherConfigLib-60a06e94e2fc176294f9ff426fee6d0621946c22.zip |
fix button press
-rw-r--r-- | build.gradle.kts | 2 | ||||
-rw-r--r-- | src/client/java/dev/isxander/yacl/gui/AbstractWidget.java | 8 | ||||
-rw-r--r-- | src/client/java/dev/isxander/yacl/gui/YACLScreen.java | 25 |
3 files changed, 19 insertions, 16 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index e39c697..0fe9423 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -64,7 +64,7 @@ val fabricLoaderVersion: String by project dependencies { minecraft("com.mojang:minecraft:$minecraftVersion") - mappings("net.fabricmc:yarn:$minecraftVersion+build.+:v2") + mappings("net.fabricmc:yarn:$minecraftVersion+build.2:v2") modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") "modClientImplementation"(fabricApi.module("fabric-resource-loader-v0", "0.67.2+1.19.3")) diff --git a/src/client/java/dev/isxander/yacl/gui/AbstractWidget.java b/src/client/java/dev/isxander/yacl/gui/AbstractWidget.java index c4cfe08..8d38783 100644 --- a/src/client/java/dev/isxander/yacl/gui/AbstractWidget.java +++ b/src/client/java/dev/isxander/yacl/gui/AbstractWidget.java @@ -96,13 +96,13 @@ public abstract class AbstractWidget implements Element, Drawable, Selectable { protected int multiplyColor(int hex, float amount) { Color color = new Color(hex, true); - return new Color(Math.max((int)(color.getRed() *amount), 0), - Math.max((int)(color.getGreen()*amount), 0), - Math.max((int)(color.getBlue() *amount), 0), + return new Color(Math.max((int)(color.getRed() * amount), 0), + Math.max((int)(color.getGreen() * amount), 0), + Math.max((int)(color.getBlue() * amount), 0), color.getAlpha()).getRGB(); } public void playDownSound() { - MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK.value(), 1.0F)); + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.method_47978(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } } diff --git a/src/client/java/dev/isxander/yacl/gui/YACLScreen.java b/src/client/java/dev/isxander/yacl/gui/YACLScreen.java index e36c8e8..e700009 100644 --- a/src/client/java/dev/isxander/yacl/gui/YACLScreen.java +++ b/src/client/java/dev/isxander/yacl/gui/YACLScreen.java @@ -7,8 +7,10 @@ import dev.isxander.yacl.api.utils.MutableDimension; import dev.isxander.yacl.api.utils.OptionUtils; import net.minecraft.client.font.MultilineText; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.tooltip.TooltipBackgroundRenderer; import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; @@ -71,10 +73,10 @@ public class YACLScreen extends Screen { }); actionDim.expand(-actionDim.width() / 2 - 2, 0).move(-actionDim.width() / 2 - 2, -22); cancelResetButton = new TooltipButtonWidget(this, actionDim.x() - actionDim.width() / 2, actionDim.y(), actionDim.width(), actionDim.height(), Text.empty(), Text.empty(), (btn) -> { - if (pendingChanges()) { + if (pendingChanges()) { // if pending changes, button acts as a cancel button OptionUtils.forEachOptions(config, Option::forgetPendingValue); close(); - } else { + } else { // if not, button acts as a reset button OptionUtils.forEachOptions(config, Option::requestSetDefault); } @@ -243,15 +245,16 @@ public class YACLScreen extends Screen { RenderSystem.setShader(GameRenderer::getPositionColorProgram); bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); Matrix4f matrix4f = matrices.peek().getPositionMatrix(); - fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY - 4, drawX + maxWidth + 3, drawY - 3, 400, -267386864, -267386864); - fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY + height + 3, drawX + maxWidth + 3, drawY + height + 4, 400, -267386864, -267386864); - fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY - 3, drawX + maxWidth + 3, drawY + height + 3, 400, -267386864, -267386864); - fillGradient(matrix4f, bufferBuilder, drawX - 4, drawY - 3, drawX - 3, drawY + height + 3, 400, -267386864, -267386864); - fillGradient(matrix4f, bufferBuilder, drawX + maxWidth + 3, drawY - 3, drawX + maxWidth + 4, drawY + height + 3, 400, -267386864, -267386864); - fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY - 3 + 1, drawX - 3 + 1, drawY + height + 3 - 1, 400, 1347420415, 1344798847); - fillGradient(matrix4f, bufferBuilder, drawX + maxWidth + 2, drawY - 3 + 1, drawX + maxWidth + 3, drawY + height + 3 - 1, 400, 1347420415, 1344798847); - fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY - 3, drawX + maxWidth + 3, drawY - 3 + 1, 400, 1347420415, 1347420415); - fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY + height + 2, drawX + maxWidth + 3, drawY + height + 3, 400, 1344798847, 1344798847); + TooltipBackgroundRenderer.render( + DrawableHelper::fillGradient, + matrix4f, + bufferBuilder, + drawX, + drawY, + maxWidth, + height, + 400 + ); RenderSystem.enableDepthTest(); RenderSystem.disableTexture(); RenderSystem.enableBlend(); |