From a64e72034e240da9b81eab9e9160b3746c5f3169 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 21 Jun 2025 09:21:40 -0500 Subject: [PATCH] Fix UI text rendering --- .../common/wrappers/gui/ClassicConfigGUI.java | 21 ++++++++-- .../common/wrappers/gui/DhScreen.java | 38 +++++++++++++++---- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index f6bf328ed..7f3ca7a0d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -420,7 +420,13 @@ public class ClassicConfigGUI #endif this.list.render(matrices, mouseX, mouseY, delta); // Render buttons - DhDrawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title + // Render title + this.DhDrawCenteredString(matrices, this.font, this.title, this.width / 2, 15, + #if MC_VER < MC_1_21_6 + 0xFFFFFF // RGB white + #else + 0xFFFFFFFF // ARGB white + #endif); if (this.configBase.modID.equals("distanthorizons")) { @@ -429,7 +435,14 @@ public class ClassicConfigGUI // If the update is pending, display this message to inform the user that it will apply when the game restarts if (SelfUpdater.deleteOldJarOnJvmShutdown) - DhDrawString(matrices, font, Translatable(configBase.modID + ".updater.waitingForClose"), 4, height - 38, 0xFFFFFF); + { + this.DhDrawString(matrices, this.font, Translatable(this.configBase.modID + ".updater.waitingForClose"), 4, this.height - 38, + #if MC_VER < MC_1_21_6 + 0xFFFFFF // RGB white + #else + 0xFFFFFFFF // ARGB white + #endif); + } } @@ -659,8 +672,10 @@ public class ClassicConfigGUI if (text != null && (!text.getString().contains("spacer") || button != null)) #if MC_VER < MC_1_20_1 GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF); + #elif MC_VER < MC_1_21_6 + matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); #else - matrices.drawString(textRenderer, text, 12, y + 5, 0xFFFFFF); + matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFFFF); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java index 5309e6565..34ce892b1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreen.java @@ -52,6 +52,27 @@ public class DhScreen extends Screen { renderTooltip(guiStack, comp, x, y); } + #elif MC_VER < MC_1_21_6 + protected void DhDrawCenteredString(GuiGraphics guiStack, Font font, Component text, int x, int y, int color) + { + guiStack.drawCenteredString(font, text, x, y, color); + } + protected void DhDrawString(GuiGraphics guiStack, Font font, Component text, int x, int y, int color) + { + guiStack.drawString(font, text, x, y, color); + } + //protected void DhRenderTooltip(GuiGraphics guiStack, Font font, List text, int x, int y) + //{ + // guiStack.renderTooltip(font, text, x, y); + //} + protected void DhRenderComponentTooltip(GuiGraphics guiStack, Font font, List comp, int x, int y) + { + guiStack.renderComponentTooltip(font, comp, x, y); + } + protected void DhRenderTooltip(GuiGraphics guiStack, Font font, Component text, int x, int y) + { + guiStack.renderTooltip(font, text, x, y); + } #else protected void DhDrawCenteredString(GuiGraphics guiStack, Font font, Component text, int x, int y, int color) { @@ -61,17 +82,20 @@ public class DhScreen extends Screen { guiStack.drawString(font, text, x, y, color); } - protected void DhRenderTooltip(GuiGraphics guiStack, Font font, List text, int x, int y) - { - guiStack.renderTooltip(font, text, x, y); - } + //protected void DhRenderTooltip(GuiGraphics guiStack, Font font, List text, int x, int y) + //{ + // //guiStack.renderTooltip(font, text, x, y); + //} protected void DhRenderComponentTooltip(GuiGraphics guiStack, Font font, List comp, int x, int y) { - guiStack.renderComponentTooltip(font, comp, x, y); + guiStack.setComponentTooltipForNextFrame(font, comp, x, y); } protected void DhRenderTooltip(GuiGraphics guiStack, Font font, Component text, int x, int y) { - guiStack.renderTooltip(font, text, x, y); + guiStack.setTooltipForNextFrame(font, text, x, y); } - #endif + #endif + + + }