diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-09-10 21:03:20 +0300 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-09-10 21:03:20 +0300 |
commit | 475f080e9786d5ee56acc227c1d72bb6fc4f122a (patch) | |
tree | f1efc1c9835028964bdef19958dcec8b69f6f123 /src | |
parent | 48a165f113fbfa1d1075665087a40b56a458ce8e (diff) | |
download | LibGui-475f080e9786d5ee56acc227c1d72bb6fc4f122a.tar.gz LibGui-475f080e9786d5ee56acc227c1d72bb6fc4f122a.tar.bz2 LibGui-475f080e9786d5ee56acc227c1d72bb6fc4f122a.zip |
WItemSlot.getExtraNarrationMessage -> getNarrationName, make public API
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java | 15 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WPlayerInvPanel.java | 2 |
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; } }; |