Class InventoryTab
java.lang.Object
com.csse3200.game.ui.inventoryscreen.InventoryTab
- All Implemented Interfaces:
InventoryTabInterface
UI tab that renders the player's inventory within the pause menu
This tab shows a 4x4 grid of item slots. Each unique item present in the player's
InventoryComponent
occupies one "filled" slot, which renders a slot border and,
if available, an item image. Remaining cells render as empty slots. The tab also provides
a close hotspot (positioned with PixelPerfectPlacer
) which unpauses the game and
hides the pause screen when clicked.-
Constructor Summary
ConstructorsConstructorDescriptionInventoryTab
(Entity player, MainGameScreen gameScreen) Creates an Inventory tab bound to the given main game screen. -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.scenes.scene2d.Actor
build
(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Builds the Scene2D Actor representing this inventory tab The returned actor contains the background-aligned layout via PixelPerfectPlacer, an invisible close hotspot at #CLOSE_BUTTON_POS, and a grid region at #GRID_PX populated from the player's InventoryComponentvoid
dispose()
Disposes all textures owned by this tabgetItemAt
(int slotIndex) Gets the item ID at a specific slot indexgetItemAt
(int row, int col) Gets the item ID in a specific slotgetItemDescriptionAt
(int slotIndex) Gets the item description for a specific slot indexvoid
Refreshes the current grid displayvoid
refreshGrid
(com.badlogic.gdx.scenes.scene2d.ui.Table gridTable) Refreshes the grid display to update selection highlightingvoid
setNavigationComponent
(InventoryNavigationComponent navigationComponent) Sets the navigation component that provides selection state
-
Constructor Details
-
InventoryTab
Creates an Inventory tab bound to the given main game screen.- Parameters:
player
- entity holding upgrades informationgameScreen
- main game screen used to unpause and hide the pause menu
-
-
Method Details
-
getItemDescriptionAt
Gets the item description for a specific slot index- Parameters:
slotIndex
- the slot index (0-based, row-major order)- Returns:
- the item description or "Empty Slot" if no item
-
getItemAt
Gets the item ID at a specific slot index- Parameters:
slotIndex
- the slot index (0-based, row-major order)- Returns:
- the item ID or null if slot is empty
-
getItemAt
Gets the item ID in a specific slot- Parameters:
row
- the row index (0-3)col
- the column index (0-3)- Returns:
- the item ID or null if slot is empty or coordinates are invalid
-
refreshGrid
public void refreshGrid(com.badlogic.gdx.scenes.scene2d.ui.Table gridTable) Refreshes the grid display to update selection highlighting -
refreshGrid
public void refreshGrid()Refreshes the current grid display -
build
public com.badlogic.gdx.scenes.scene2d.Actor build(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Builds the Scene2D Actor representing this inventory tab The returned actor contains the background-aligned layout via PixelPerfectPlacer, an invisible close hotspot at #CLOSE_BUTTON_POS, and a grid region at #GRID_PX populated from the player's InventoryComponent- Specified by:
build
in interfaceInventoryTabInterface
- Parameters:
skin
- the UI skin used for widgets and layout- Returns:
- a centered container wrapping the
PixelPerfectPlacer
contents
-
dispose
public void dispose()Disposes all textures owned by this tab
-