From 7c89dee5624e7c2fc907181271320273370cf612 Mon Sep 17 00:00:00 2001 From: Martin Prokoph Date: Thu, 2 May 2024 20:47:54 +0200 Subject: [PATCH] Finishing touches - Correctly scale gradients - Updated German translations --- src/main/java/eu/midnightdust/blur/Blur.java | 18 +++++++------- .../blur/mixin/MixinInGameHud.java | 3 +-- .../midnightdust/blur/mixin/MixinScreen.java | 23 ++++-------------- .../midnightdust/blur/util/RainbowColor.java | 2 +- .../resources/assets/blur/lang/de_de.json | 24 ++++++++++++++----- src/main/resources/fabric.mod.json | 4 ++-- 6 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/main/java/eu/midnightdust/blur/Blur.java b/src/main/java/eu/midnightdust/blur/Blur.java index fb1ed76..c4936e3 100644 --- a/src/main/java/eu/midnightdust/blur/Blur.java +++ b/src/main/java/eu/midnightdust/blur/Blur.java @@ -87,14 +87,14 @@ public static int getRotation() { if (BlurConfig.rainbowMode) return RainbowColor.rotation; return BlurConfig.gradientRotation; } - public static boolean renderRotatedGradient(DrawContext context, int width, int height) { - if (getRotation() > 0) { - context.getMatrices().peek().getPositionMatrix().rotationZ(Math.toRadians(getRotation())); - context.getMatrices().peek().getPositionMatrix().setTranslation(width / 2f, height / 2f, 0); // Make the gradient's center the pivot point - context.getMatrices().peek().getPositionMatrix().scale(Math.sqrt((float) width*width + height*height) / height); // Scales the gradient to the maximum diagonal value needed - context.fillGradient(-width / 2, -height / 2, width / 2, height / 2, Blur.getBackgroundColor(false), Blur.getBackgroundColor(true)); // Actually draw the gradient - context.getMatrices().peek().getPositionMatrix().rotationZ(0); - return true; - } return false; + public static void renderRotatedGradient(DrawContext context, int width, int height) { + float diagonal = Math.sqrt((float) width*width + height*height); + int smallestDimension = Math.min(width, height); + + context.getMatrices().peek().getPositionMatrix().rotationZ(Math.toRadians(getRotation())); + context.getMatrices().peek().getPositionMatrix().setTranslation(width / 2f, height / 2f, 0); // Make the gradient's center the pivot point + context.getMatrices().peek().getPositionMatrix().scale(diagonal / smallestDimension); // Scales the gradient to the maximum diagonal value needed + context.fillGradient(-width / 2, -height / 2, width / 2, height / 2, Blur.getBackgroundColor(false), Blur.getBackgroundColor(true)); // Actually draw the gradient + context.getMatrices().peek().getPositionMatrix().rotationZ(0); } } diff --git a/src/main/java/eu/midnightdust/blur/mixin/MixinInGameHud.java b/src/main/java/eu/midnightdust/blur/mixin/MixinInGameHud.java index 7cff0a4..3150c83 100644 --- a/src/main/java/eu/midnightdust/blur/mixin/MixinInGameHud.java +++ b/src/main/java/eu/midnightdust/blur/mixin/MixinInGameHud.java @@ -23,8 +23,7 @@ public class MixinInGameHud { this.client.gameRenderer.renderBlur(delta); this.client.getFramebuffer().beginWrite(false); - if (Blur.prevScreenHasBackground && !Blur.renderRotatedGradient(context, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight())) - context.fillGradient(0, 0, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight(), Blur.getBackgroundColor(false), Blur.getBackgroundColor(true)); + if (Blur.prevScreenHasBackground) Blur.renderRotatedGradient(context, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight()); } } } diff --git a/src/main/java/eu/midnightdust/blur/mixin/MixinScreen.java b/src/main/java/eu/midnightdust/blur/mixin/MixinScreen.java index 88f4919..12ebd4b 100755 --- a/src/main/java/eu/midnightdust/blur/mixin/MixinScreen.java +++ b/src/main/java/eu/midnightdust/blur/mixin/MixinScreen.java @@ -8,9 +8,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyConstant; import eu.midnightdust.blur.Blur; @@ -41,7 +39,7 @@ public abstract class MixinScreen { this.client.gameRenderer.renderBlur(delta); this.client.getFramebuffer().beginWrite(false); - if (Blur.prevScreenHasBackground && !Blur.renderRotatedGradient(context, width, height)) context.fillGradient(0, 0, width, height, Blur.getBackgroundColor(false), Blur.getBackgroundColor(true)); + if (Blur.prevScreenHasBackground) Blur.renderRotatedGradient(context, width, height); } Blur.doTest = false; // Set the test state to completed, as tests will happen in the same tick. } @@ -62,22 +60,9 @@ public abstract class MixinScreen { } } - @ModifyConstant( - method = "renderInGameBackground", - constant = @Constant(intValue = -1072689136)) - private int blur$getFirstBackgroundColor(int color) { - return Blur.getBackgroundColor(false); - } - - @ModifyConstant( - method = "renderInGameBackground", - constant = @Constant(intValue = -804253680)) - private int blur$getSecondBackgroundColor(int color) { - return Blur.getBackgroundColor(true); - } - @Inject(at = @At("HEAD"), method = "renderInGameBackground", cancellable = true) - public void blur$rotatedGradient(DrawContext context, CallbackInfo ci) { - if (Blur.renderRotatedGradient(context, width, height)) ci.cancel(); + public void blur$rotatedGradient(DrawContext context, CallbackInfo ci) { // Replaces the default gradient with our rotated one + Blur.renderRotatedGradient(context, width, height); + ci.cancel(); } } diff --git a/src/main/java/eu/midnightdust/blur/util/RainbowColor.java b/src/main/java/eu/midnightdust/blur/util/RainbowColor.java index d3129fc..57ced40 100644 --- a/src/main/java/eu/midnightdust/blur/util/RainbowColor.java +++ b/src/main/java/eu/midnightdust/blur/util/RainbowColor.java @@ -8,7 +8,7 @@ public class RainbowColor { public static float hue; public static float hue2 = 0.35f; - public static void tick(MinecraftClient client) { + public static void tick(MinecraftClient ignoredClient) { if (BlurConfig.rainbowMode) { if (hue >= 1) hue = 0f; hue += 0.01f; diff --git a/src/main/resources/assets/blur/lang/de_de.json b/src/main/resources/assets/blur/lang/de_de.json index 53ada1d..b20250f 100644 --- a/src/main/resources/assets/blur/lang/de_de.json +++ b/src/main/resources/assets/blur/lang/de_de.json @@ -1,15 +1,27 @@ { - "blur.midnightconfig.title": "Blur Konfiguration", - "blur.midnightconfig.blurExclusions": "Blur-Ausnahmen", + "blur.midnightconfig.title": "Blur+ Konfiguration", + "blur.midnightconfig.category.animations": "Animationen", "blur.midnightconfig.category.style": "Stil", - "blur.midnightconfig.category.screens": "Bildschirme", + "blur.midnightconfig.blurContainers": "Unschärfe in Containern", "blur.midnightconfig.fadeTimeMillis": "Überblendzeit (in Millisekunden)", - "blur.midnightconfig.fadeOutTimeMillis": "Ausblendzeit (in milliseconds)", - "blur.midnightconfig.ease": "Geschmeidige Animation", + "blur.midnightconfig.fadeOutTimeMillis": "Ausblendzeit (in Millisekunden)", + "blur.midnightconfig.animationCurve": "Animationskurve", + "blur.midnightconfig.enum.Easing.FLAT": "Flach", + "blur.midnightconfig.enum.Easing.SINE": "Sinus", + "blur.midnightconfig.enum.Easing.QUAD": "Quadriert", + "blur.midnightconfig.enum.Easing.CUBIC": "Kubiert", + "blur.midnightconfig.enum.Easing.QUART": "Quart", + "blur.midnightconfig.enum.Easing.QUINT": "Quint", + "blur.midnightconfig.enum.Easing.EXPO": "Expo", + "blur.midnightconfig.enum.Easing.CIRC": "Kreis", + "blur.midnightconfig.enum.Easing.BACK": "Zurück", + "blur.midnightconfig.enum.Easing.ELASTIC": "Elastisch", "blur.midnightconfig.radius": "Radius", + "blur.midnightconfig.rainbowMode": "Regenbogenmodus \uD83C\uDF08", + "blur.midnightconfig.useGradient": "Farbverlauf im Hintergrund", "blur.midnightconfig.gradientStart": "Farbverlauf-Anfangsfarbe", "blur.midnightconfig.gradientEnd": "Farbverlauf-Endfarbe", "blur.midnightconfig.gradientStartAlpha": "Farbverlauf-Anfangstransparenz", "blur.midnightconfig.gradientEndAlpha": "Farbverlauf-Endstransparenz", - "blur.midnightconfig.showScreenTitle": "Logge Bildschirmtitel" + "blur.midnightconfig.gradientRotation": "Farbverlauf-Rotation" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2f4f59b..35eab58 100755 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,11 +23,11 @@ "backryun", "byquanton" ], - "description": "Various Enhancements to the blur effect behind Minecraft GUIs", + "description": "Various enhancements for the blur effect behind Minecraft GUIs", "mixins": [ "mixins.blur.json" ], "depends": { - "minecraft": ">1.20.4" + "minecraft": ">=1.20.5" } }