aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2021-09-10 21:03:20 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2021-09-10 21:03:20 +0300
commit475f080e9786d5ee56acc227c1d72bb6fc4f122a (patch)
treef1efc1c9835028964bdef19958dcec8b69f6f123
parent48a165f113fbfa1d1075665087a40b56a458ce8e (diff)
downloadLibGui-475f080e9786d5ee56acc227c1d72bb6fc4f122a.tar.gz
LibGui-475f080e9786d5ee56acc227c1d72bb6fc4f122a.tar.bz2
LibGui-475f080e9786d5ee56acc227c1d72bb6fc4f122a.zip
WItemSlot.getExtraNarrationMessage -> getNarrationName, make public API
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java15
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java2
2 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
index 9ce37fa..a05b364 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
@@ -140,7 +140,7 @@ public class WItemSlot extends WWidget {
public static WItemSlot ofPlayerStorage(Inventory inventory) {
WItemSlot w = new WItemSlot() {
@Override
- Text getExtraNarrationMessage() {
+ protected Text getNarrationName() {
return inventory instanceof PlayerInventory inv ? inv.getDisplayName() : NarrationMessages.Vanilla.INVENTORY;
}
};
@@ -460,8 +460,8 @@ public class WItemSlot extends WWidget {
@Override
public void addNarrations(NarrationMessageBuilder builder) {
List<Text> parts = new ArrayList<>();
- Text extra = getExtraNarrationMessage();
- if (extra != null) parts.add(extra);
+ Text name = getNarrationName();
+ if (name != null) parts.add(name);
if (focusedSlot >= 0) {
parts.add(new TranslatableText(NarrationMessages.ITEM_SLOT_TITLE_KEY, focusedSlot + 1, slotsWide * slotsHigh));
@@ -472,8 +472,15 @@ public class WItemSlot extends WWidget {
builder.put(NarrationPart.TITLE, parts.toArray(new Text[0]));
}
+ /**
+ * Returns a "narration name" for this slot.
+ * It's narrated before the slot index. One example of a narration name would be "hotbar" for the player's hotbar.
+ *
+ * @return the narration name, or null if there's none for this slot
+ * @since 4.2.0
+ */
@Nullable
- Text getExtraNarrationMessage() {
+ protected Text getNarrationName() {
return null;
}
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 d86e40a..af4a159 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
@@ -58,7 +58,7 @@ public class WPlayerInvPanel extends WPlainPanel {
inv = WItemSlot.ofPlayerStorage(playerInventory);
hotbar = new WItemSlot(playerInventory, 0, 9, 1, false) {
@Override
- Text getExtraNarrationMessage() {
+ protected Text getNarrationName() {
return NarrationMessages.PLAYER_INVENTORY_HOTBAR;
}
};