Repository navigation
Player HUD Hotbar
Part of the Player HUD.
Shows the first row of the player's inventory as a row of item slots along the bottom edge of the screen. The selected slot has a brown border. Each slot is a Table with a rounded nine-patch background rather than an image atlas.

classDiagram
class UIComponent {
<<abstract>>
}
class InventoryBarDisplay {
-Table root
-Table table
+create()
-populateSlots()
-createSlot(ItemType item, int count, boolean selected) Table
-createEmptySlot(boolean selected) Table
-refresh()
-hideBar()
-showBar()
}
class InventoryComponent {
-List~InventorySlot~ slots
+getHotbarSlotCount() int
+getSelectedSlotIndex() int
+getSlot(int index) InventorySlot
}
UIComponent <|-- InventoryBarDisplay
InventoryBarDisplay --> InventoryComponent : reads (fetched live, not cached)
InventoryComponent ..> InventoryBarDisplay : "inventoryChanged" event
InventoryBarDisplay ..> InventorySlotStyle : styles slots

InventoryComponent and InventorySlot are the data model; see Player Inventory for how items are added, stacked and swapped. This page only covers how that state is drawn.
InventoryBarDisplay listens for these events on the player entity:
| Event | Effect |
|---|---|
inventoryChanged, inventorySelectionChanged
|
Full populateSlots() rebuild |
backpackOpened / backpackClosed
|
Hide / show the hotbar so it does not compete with the backpack grid |
dictionaryOpened / dictionaryClosed
|
Hide / show the hotbar while the item dictionary is open |
Unlike the heart row, the hotbar is rebuilt rather than updated in place. populateSlots() calls table.clearChildren() and recreates one slot per hotbar index (inventory.getHotbarSlotCount()), asking InventoryComponent for each slot instead of keeping its own copy of the state. This is simpler than the heart row's pool-and-hide approach, but a change to one slot redraws all of them (selecting a different item redraws every slot, not just the two whose selection changed).
Each slot's background comes from InventorySlotStyle, a shared, cached NinePatchDrawable per state (normal or selected). Occupied slots (createSlot) show the item icon (from ItemType.getTexturePath()) and an x<count> label; empty slots (createEmptySlot) are just the background.
The component is event-driven; there is nothing to call directly. To change what it shows, change the inventory:
| Call | Effect on the hotbar |
|---|---|
inventory.addItem(...) / removeItem(...)
|
Fires inventoryChanged, slots redraw |
inventory.selectSlot(index) |
Fires inventorySelectionChanged, border moves |
In InventoryBarDisplay:
| Constant | Value | Purpose |
|---|---|---|
SLOT_WIDTH / SLOT_HEIGHT
|
90px | Size of each slot |
SLOT_SPACING |
10px | Gap between slots |
ICON_SIZE |
56px | Size of the item icon inside a slot |
- Automated:
InventoryDisplayTest(core/src/test/.../components/inventory/). - Manual: Inventory Bar section of the Player HUD Test Plan (IB-1 to IB-5).
Entities and Components
Input Handling
Arrow Selection Wheel Arrow Selection Wheel — Sprint 3