Class InventoryTab

java.lang.Object
com.csse3200.game.ui.inventoryscreen.InventoryTab
All Implemented Interfaces:
InventoryTabInterface

public class InventoryTab extends Object implements 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

    Constructors
    Constructor
    Description
    InventoryTab(Entity player, MainGameScreen gameScreen)
    Creates an Inventory tab bound to the given main game screen.
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    void
    Disposes all textures owned by this tab
    getItemAt(int slotIndex)
    Gets the item ID at a specific slot index
    getItemAt(int row, int col)
    Gets the item ID in a specific slot
    getItemDescriptionAt(int slotIndex)
    Gets the item description for a specific slot index
    void
    Refreshes the current grid display
    void
    refreshGrid(com.badlogic.gdx.scenes.scene2d.ui.Table gridTable)
    Refreshes the grid display to update selection highlighting
    void
    Sets the navigation component that provides selection state

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InventoryTab

      public InventoryTab(Entity player, MainGameScreen gameScreen)
      Creates an Inventory tab bound to the given main game screen.
      Parameters:
      player - entity holding upgrades information
      gameScreen - main game screen used to unpause and hide the pause menu
  • Method Details

    • getItemDescriptionAt

      public String getItemDescriptionAt(int slotIndex)
      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

      public String getItemAt(int slotIndex)
      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

      public String getItemAt(int row, int col)
      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
    • setNavigationComponent

      public void setNavigationComponent(InventoryNavigationComponent navigationComponent)
      Sets the navigation component that provides selection state
    • 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 interface InventoryTabInterface
      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