From 9703a49ce7418a164323e4fd775ade1854b86887 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Tue, 16 Nov 2021 21:45:39 +0200 Subject: Fix title alignments when titleX is not 0 --- .../java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java | 4 +++- .../io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java index 331f68b..1751d4d 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java @@ -24,6 +24,7 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl { /** * The X coordinate of the screen title. + * This is relative to the root panel's top-left corner. * * @since 2.0.0 */ @@ -31,6 +32,7 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl { /** * The Y coordinate of the screen title. + * This is relative to the root panel's top-left corner. * * @since 2.0.0 */ @@ -126,7 +128,7 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl { if (getTitle() != null && description.isTitleVisible()) { int width = description.getRootPanel().getWidth(); - ScreenDrawing.drawString(matrices, getTitle().asOrderedText(), description.getTitleAlignment(), left + titleX, top + titleY, width, description.getTitleColor()); + ScreenDrawing.drawString(matrices, getTitle().asOrderedText(), description.getTitleAlignment(), left + titleX, top + titleY, width - titleX, description.getTitleColor()); } } } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java index 82d8d4b..96da107 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java @@ -276,7 +276,7 @@ public class CottonInventoryScreen extends Handl protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { if (description != null && description.isTitleVisible()) { int width = description.getRootPanel().getWidth(); - ScreenDrawing.drawString(matrices, getTitle().asOrderedText(), description.getTitleAlignment(), titleX, titleY, width, description.getTitleColor()); + ScreenDrawing.drawString(matrices, getTitle().asOrderedText(), description.getTitleAlignment(), titleX, titleY, width - titleX, description.getTitleColor()); } // Don't draw the player inventory label as it's drawn by the widget itself -- cgit