diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java | 12 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java | 24 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java b/src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java index f5153e7..219f576 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java @@ -338,23 +338,23 @@ public class CottonInventoryController extends ScreenHandler implements GuiDescr /** * Creates a player inventory widget from this panel's {@linkplain #playerInventory player inventory}. * - * @param hasTitle whether the "Inventory" title should be displayed + * @param hasLabel whether the "Inventory" label should be displayed * @return the created inventory widget * @since 2.0.0 */ - public WPlayerInvPanel createPlayerInventoryPanel(boolean hasTitle) { - return new WPlayerInvPanel(this.playerInventory, hasTitle); + public WPlayerInvPanel createPlayerInventoryPanel(boolean hasLabel) { + return new WPlayerInvPanel(this.playerInventory, hasLabel); } /** * Creates a player inventory widget from this panel's {@linkplain #playerInventory player inventory}. * - * @param title the inventory title widget + * @param label the inventory label widget * @return the created inventory widget * @since 2.0.0 */ - public WPlayerInvPanel createPlayerInventoryPanel(WWidget title) { - return new WPlayerInvPanel(this.playerInventory, title); + public WPlayerInvPanel createPlayerInventoryPanel(WWidget label) { + return new WPlayerInvPanel(this.playerInventory, label); } /** diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java index 198c708..c99793d 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java @@ -15,7 +15,7 @@ public class WPlayerInvPanel extends WPlainPanel { private final WItemSlot hotbar; /** - * Constructs a player inventory panel with a title. + * Constructs a player inventory panel with a label. * * @param playerInventory the player inventory */ @@ -27,26 +27,26 @@ public class WPlayerInvPanel extends WPlainPanel { * Constructs a player inventory panel. * * @param playerInventory the player inventory - * @param hasTitle whether there should be an "Inventory" title + * @param hasLabel whether there should be an "Inventory" label * @since 2.0.0 */ - public WPlayerInvPanel(PlayerInventory playerInventory, boolean hasTitle) { - this(playerInventory, hasTitle ? new WLabel(playerInventory.getDisplayName()) : null); + public WPlayerInvPanel(PlayerInventory playerInventory, boolean hasLabel) { + this(playerInventory, hasLabel ? createDefaultLabel(playerInventory) : null); } /** * Constructs a player inventory panel. * * @param playerInventory the player inventory - * @param title the title widget, can be null + * @param label the label widget, can be null * @since 2.0.0 */ - public WPlayerInvPanel(PlayerInventory playerInventory, @Nullable WWidget title) { + public WPlayerInvPanel(PlayerInventory playerInventory, @Nullable WWidget label) { int y = 0; - if (title != null) { - this.add(title, 0, 0, 9*18, 11); - y += title.getHeight(); + if (label != null) { + this.add(label, 0, 0); + y += label.getHeight(); } inv = WItemSlot.ofPlayerStorage(playerInventory); @@ -55,6 +55,12 @@ public class WPlayerInvPanel extends WPlainPanel { this.add(hotbar, 0, y + 58); } + private static WLabel createDefaultLabel(PlayerInventory playerInventory) { + WLabel label = new WLabel(playerInventory.getDisplayName()); + label.setSize(9*18, 11); + return label; + } + /** * Sets the background painter of this inventory widget's slots. * |