diff options
author | nopo <nopotheemail@gmail.com> | 2023-02-13 23:00:32 +1100 |
---|---|---|
committer | nopo <nopotheemail@gmail.com> | 2023-02-13 23:00:32 +1100 |
commit | eea3dd8dcb3e754072a9ec050c9db31326d6dda9 (patch) | |
tree | ea5573ca140e81e09bf60918f859ad8743b47c7f | |
parent | 9d47f294fded28cc4a2b6cd1db72ee3fa13b35ce (diff) | |
download | NotEnoughUpdates-eea3dd8dcb3e754072a9ec050c9db31326d6dda9.tar.gz NotEnoughUpdates-eea3dd8dcb3e754072a9ec050c9db31326d6dda9.tar.bz2 NotEnoughUpdates-eea3dd8dcb3e754072a9ec050c9db31326d6dda9.zip |
Added the ability to use neu's tooltips instead of vanilla
3 files changed, 34 insertions, 21 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 index 6176b22f..004cfdfb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java @@ -36,10 +36,15 @@ import java.util.List; @Mixin(value = GuiUtils.class, remap = false) public class MixinGuiUtils { - @Inject(method = "drawHoveringText", at = @At("HEAD")) + @Inject(method = "drawHoveringText", at = @At("HEAD"), cancellable = true) 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); + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.customTooltips) { + Utils.drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font); + ci.cancel(); + } else if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale != 0) { + Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale); + } } @ModifyVariable(method = "drawHoveringText", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) 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 45a96577..db300520 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 @@ -158,6 +158,14 @@ public class TooltipTweaks { @Expose @ConfigOption( + name = "Custom tooltips", + desc = "Replace tooltips with neu's custom tooltips" + ) + @ConfigEditorBoolean + public boolean customTooltips = false; + + @Expose + @ConfigOption( name = "Expand Pet Exp Requirement", desc = "Show which the full amount of pet xp required" ) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index d5abcb77..3c856dea 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1419,18 +1419,6 @@ public class Utils { GlStateManager.enableTexture2D(); } - public static void drawHoveringText( - List<String> textLines, - final int mouseX, - final int mouseY, - final int screenWidth, - final int screenHeight, - final int maxTextWidth, - FontRenderer font - ) { - drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true); - } - public static JsonObject getConstant(String constant, Gson gson) { return getConstant(constant, gson, JsonObject.class); } @@ -1566,15 +1554,26 @@ public class Utils { public static void drawHoveringText( List<String> textLines, - final int mouseX, - final int mouseY, - final int screenWidth, - final int screenHeight, + int mouseX, + int mouseY, + int screenWidth, + int screenHeight, final int maxTextWidth, - FontRenderer font, - boolean coloured + FontRenderer font ) { if (!textLines.isEmpty()) { + ScaledResolution scaledResolution = Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale); + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale != 0) { + mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth; + + mouseY = scaledResolution.getScaledHeight() - + Mouse.getY() * scaledResolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight; + + screenWidth = scaledResolution.getScaledWidth(); + + screenHeight = scaledResolution.getScaledHeight(); + } + GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableLighting(); @@ -1717,7 +1716,7 @@ public class Utils { ); //TODO: Coloured Borders int borderColorStart = 0x505000FF; - if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderColours && coloured) { + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderColours) { if (textLines.size() > 0) { String first = textLines.get(0); borderColorStart = getPrimaryColour(first).getRGB() & 0x00FFFFFF | @@ -1778,6 +1777,7 @@ public class Utils { GlStateManager.enableDepth(); RenderHelper.enableStandardItemLighting(); GlStateManager.enableRescaleNormal(); + Utils.resetGuiScale(); } GlStateManager.disableLighting(); } |