diff options
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java | 33 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java | 16 |
2 files changed, 44 insertions, 5 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 7c7d7d9..e10bd4c 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 @@ -17,6 +17,20 @@ public class CottonClientScreen extends Screen implements TextHoverRendererScree protected int left = 0; protected int top = 0; + /** + * The X coordinate of the screen title. + * + * @since 2.0.0 + */ + protected int titleX; + + /** + * The Y coordinate of the screen title. + * + * @since 2.0.0 + */ + protected int titleY; + protected WWidget lastResponder = null; public CottonClientScreen(GuiDescription description) { @@ -41,17 +55,30 @@ public class CottonClientScreen extends Screen implements TextHoverRendererScree description.addPainters(); reposition(screenWidth, screenHeight); } - - private void reposition(int screenWidth, int screenHeight) { + + /** + * Repositions the root panel. + * + * @param screenWidth the width of the screen + * @param screenHeight the height of the screen + */ + protected void reposition(int screenWidth, int screenHeight) { if (description!=null) { WPanel root = description.getRootPanel(); if (root!=null) { if (!description.isFullscreen()) { this.left = (screenWidth - root.getWidth()) / 2; this.top = (screenHeight - root.getHeight()) / 2; + this.titleX = this.left; + this.titleY = this.top; } else { this.left = 0; this.top = 0; + + // Offset the title coordinates a little from the edge + this.titleX = 10; + this.titleY = 10; + root.setSize(screenWidth, screenHeight); } } @@ -73,7 +100,7 @@ public class CottonClientScreen extends Screen implements TextHoverRendererScree } if (getTitle() != null) { - textRenderer.draw(matrices, getTitle(), left, top, description.getTitleColor()); + textRenderer.draw(matrices, getTitle(), titleX, titleY, 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 7ada7bd..dbc7404 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 @@ -68,8 +68,14 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl reposition(screenWidth, screenHeight); } - - private void reposition(int screenWidth, int screenHeight) { + + /** + * Repositions the root panel. + * + * @param screenWidth the width of the screen + * @param screenHeight the height of the screen + */ + protected void reposition(int screenWidth, int screenHeight) { WPanel basePanel = description.getRootPanel(); if (basePanel!=null) { basePanel.validate(description); @@ -85,10 +91,16 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl if (!description.isFullscreen()) { x = (width / 2) - (backgroundWidth / 2); y = (height / 2) - (backgroundHeight / 2); + titleX = x; + titleY = y; } else { x = 0; y = 0; + // Offset the title coordinates a little from the edge + titleX = 10; + titleY = 10; + if (basePanel != null) { basePanel.setSize(screenWidth, screenHeight); } |