aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2023-01-18 01:01:27 +1100
committerGitHub <noreply@github.com>2023-01-17 15:01:27 +0100
commit937e84822e298e3edbee4bb24775eb04f2770c4a (patch)
tree5185c6a0cf62704d9f09d9379605e632792f8ded /src/main
parenta86faac67f4125716562d16c951320356bf87c30 (diff)
downloadNotEnoughUpdates-937e84822e298e3edbee4bb24775eb04f2770c4a.tar.gz
NotEnoughUpdates-937e84822e298e3edbee4bb24775eb04f2770c4a.tar.bz2
NotEnoughUpdates-937e84822e298e3edbee4bb24775eb04f2770c4a.zip
Add tooltip resizing (#543)
add tooltip resizing
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java71
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java11
-rw-r--r--src/main/resources/mixins.notenoughupdates.json1
3 files changed, 83 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
new file mode 100644
index 00000000..0ad2a098
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.mixins;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraftforge.fml.client.config.GuiUtils;
+import org.lwjgl.input.Mouse;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.ModifyVariable;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.List;
+
+@Mixin(value = GuiUtils.class, remap = false)
+public class MixinGuiUtils {
+ @Inject(method = "drawHoveringText", at = @At("HEAD"))
+ private static void drawHoveringText_head(
+ List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font, CallbackInfo ci) {
+ Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale);
+ }
+
+ @ModifyVariable(method = "drawHoveringText", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true)
+ private static int drawHoveringText_modifyMouseX(int mouseX) {
+ return Mouse.getX() * Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale).getScaledWidth() / Minecraft.getMinecraft().displayWidth;
+ }
+
+ @ModifyVariable(method = "drawHoveringText", at = @At(value = "HEAD"), ordinal = 1, argsOnly = true)
+ private static int drawHoveringText_modifyMouseY(int mouseY) {
+ return Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale).getScaledHeight() -
+ Mouse.getY() * Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale).getScaledHeight() / Minecraft.getMinecraft().displayHeight;
+ }
+
+
+ @ModifyVariable(method = "drawHoveringText", at = @At(value = "HEAD"), ordinal = 2, argsOnly = true)
+ private static int drawHoveringText_modifyWidth(int width) {
+ return Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale).getScaledWidth();
+ }
+
+ @ModifyVariable(method = "drawHoveringText", at = @At(value = "HEAD"), ordinal = 3, argsOnly = true)
+ private static int drawHoveringText_modifyHeight(int height) {
+ return Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale).getScaledHeight();
+ }
+
+ @Inject(method = "drawHoveringText", at = @At("TAIL"))
+ private static void drawHoveringText_tail(
+ List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font, CallbackInfo ci) {
+ Utils.resetGuiScale();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java
index 8539c3c4..45a96577 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java
@@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccord
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
@@ -147,6 +148,16 @@ public class TooltipTweaks {
@Expose
@ConfigOption(
+ name = "Resize tooltips",
+ desc = "Resizes tooltips to make them readable"
+ )
+ @ConfigEditorDropdown(
+ values = {"Default", "Small", "Normal", "Large", "Auto"}
+ )
+ public int guiScale = 0;
+
+ @Expose
+ @ConfigOption(
name = "Expand Pet Exp Requirement",
desc = "Show which the full amount of pet xp required"
)
diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json
index d080d7f5..dbce787c 100644
--- a/src/main/resources/mixins.notenoughupdates.json
+++ b/src/main/resources/mixins.notenoughupdates.json
@@ -23,6 +23,7 @@
"MixinGuiIngame",
"MixinGuiInventory",
"MixinGuiScreen",
+ "MixinGuiUtils",
"MixinInventoryBasic",
"MixinInventoryEffectRenderer",
"MixinInventoryPlayer",