Inventory UI (Team Five) - UQcsse3200/2026-studio-4 GitHub Wiki
Overview
This page describes how Team Five consumables and charms are displayed and equipped through the existing inventory book, and where the shared Gold balance is shown.
The integration uses InventoryDisplay and InventoryActions with the player's existing InventoryComponent. The book presents inventory state and delegates equipment changes to that component; it does not create a second inventory.
Usage
- Press I during gameplay to open the book.
- Select Consumables or Charms using the page tabs, or press Q / E to move between pages.
- Click an item to equip or unequip it. For keyboard control, select a cell with WASD / arrows, then press Space.
- Drag a consumable onto a particular equipped slot to choose its position.
- Press I or Escape to close the book.
The book also contains an Achievements page. It starts on Charms and retains the current page when closed and reopened. Changing pages resets the item-selection index.
While open, the book captures gameplay keys. Q and E navigate the book; Q does not consume an item and Tab does not cycle the gameplay consumable selection.
Consumables page
The page separates Equipped assignments from the Backpack:
| Area | Contents |
|---|---|
| Equipped | The four consumable positions used by the gameplay slots. Empty positions remain visible. The book arranges these cells in a three-column grid, with the fourth position on the next row. |
| Backpack | Owned consumable types that are not assigned to an equipped slot, ordered by item ID. |
Each type has one item icon and its real inventory quantity. Individual bottles do not occupy separate cells. A selected cell is highlighted and its item details are displayed; hovering also provides a tooltip.
Equipping and rearranging
Clicking or pressing Space on a Backpack item equips it into the first empty position. When all four positions are occupied, this action leaves the assignments unchanged. Dragging onto a specific equipped position can replace its assignment instead.
Dragging an equipped type to another equipped position swaps the assignments. Dropping it into the Backpack clears its assignment without removing stock. Replacing a type does not delete it: its quantity remains in inventory and it becomes available in the Backpack.
Backpack ordering follows the inventory's sorted ID list; dragging within the Backpack does not provide a persistent custom order. A type is assigned to at most one equipped position.
The book manages equipment. To use an item, close it and use the controls described in Consumable Slots. Unequipping does not consume, sell or drop an item into the world.
Acquiring stock
Picking up a newly owned consumable type fills the first empty slot when available; otherwise it remains in the Backpack. More copies of an owned type increase its count without changing equipment. Purchases and Item Draw rewards add stock without automatically assigning a slot.
Using the final copy removes that type's assignment. See Consumables for use validation and effects.
Charms page
Charms are divided into Equipped and Backpack lists according to each instance's equipment state. Multiple copies of the same charm type remain separate items.
Clicking or pressing Space changes the selected charm's equipped state. Dragging between Equipped and Backpack does the same. Unlike consumable assignments, charm dragging does not preserve a requested cell position or rearrange charm slots.
InventoryComponent.setCharmEquipped(Charm charm, boolean equipped) delegates to the owned charm's state transition. Equipping applies its bonus; unequipping removes that bonus while retaining the item. Repeating the same state does not apply the bonus again.
Ground charms are equipped when picked up. Charms purchased from the Merchant start unequipped. The book draws at least five charm cells, but that visual minimum is not a five-charm equipment limit.
Gold display
Gold is a balance in InventoryComponent, not an equippable item in the book's grid. The current total is shown by the Gold label above the gameplay consumable slots. The merchant uses the same balance for purchases and rewards.
getGold() returns the balance. goldChanged reports a changed total, while goldPickedUp reports the amount gained through the pickup path. Neither event creates a Gold equipment cell in the book.
Component responsibilities
| Component | Responsibility |
|---|---|
InventoryDisplay |
Build the book pages, handle selection and input, display item details, and request equipment changes. |
InventoryActions |
Handle page and equipment events, then delegate mutations to inventory. |
InventoryComponent |
Store quantities, consumable assignments, charm instances and Gold; validate equipment updates. |
ConsumableHotbarDisplay |
Display the same consumable assignments and quantities during gameplay. |
Inventory interfaces
| Interface | Purpose |
|---|---|
getConsumableCount(String id) |
Read the owned quantity of a consumable. |
getConsumableIds() |
Obtain owned types in sorted ID order. |
getConsumableSlot(int index) |
Read an equipped position, using indices 0–3. |
equipConsumable(String type, int index) |
Assign an owned type to a position, swapping or replacing assignments as needed. |
unequipConsumable(int index) |
Clear a position without reducing its quantity. |
getCharms() |
Read owned charm instances. |
setCharmEquipped(Charm charm, boolean equipped) |
Change an owned charm's equipment state. |
getGold() |
Read the shared currency balance. |
UI events
InventoryDisplay and InventoryActions communicate on the UI entity, using the current page's item indices:
| Event | Parameters | Action |
|---|---|---|
nextPage |
None | Change to the next book page. |
previousPage |
None | Change to the previous book page. |
moveActiveToInactiveItem |
int fromIndex, int toIndex |
Unequip the source item. |
moveInactiveToActiveItem |
int fromIndex, int toIndex |
Equip the source item. For consumables, a negative destination requests the first empty position. |
moveActiveItem |
int fromIndex, int toIndex |
Move an equipped consumable to another equipped position. |
InventoryActions resolves the selected item through InventoryDisplay.getPageItems(boolean equipped) before updating inventory. After a successful equipment action, it calls refreshPage() to rebuild the display. Opening or changing the book page also refreshes its contents.
Inventory notifications use the player entity, rather than the UI entity. consumableInventoryChanged(String itemId, Integer count) reports quantity and assignment changes, even when equipment changes leave the count unchanged. charmAdded and charmRemoved report ownership changes; changing a charm's equipment state does not itself emit those two events.
The gameplay slots listen for inventory changes. The book refreshes through its own page and action flow; it does not directly subscribe to those inventory notifications to rebuild every page.
Testing
InventoryDisplayTestInventoryDisplayLayeringTestInventoryComponentTestConsumableHotbarDisplayTestConsumableSelectionComponentTestCharmPurchaseEffectTest