aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-05-21 00:12:36 +0300
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-05-21 00:12:36 +0300
commita3dc916f77d756e31940ade94e0ab9b9f26c03ce (patch)
tree1c65394bb3b1e5366f3385dffeec03faaa9492bd /src/main/java/io
parentcf9323b4df45937f7e96fbe25151ee7f7ac6da36 (diff)
downloadLibGui-a3dc916f77d756e31940ade94e0ab9b9f26c03ce.tar.gz
LibGui-a3dc916f77d756e31940ade94e0ab9b9f26c03ce.tar.bz2
LibGui-a3dc916f77d756e31940ade94e0ab9b9f26c03ce.zip
WPlayerInvPanel: title -> label, don't resize other widgets than the default label
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/CottonInventoryController.java12
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java24
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.
*