Class PlayerInventoryDisplay

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class PlayerInventoryDisplay extends UIComponent
The UI component of the inventory. Use the triggers: "add item," "remove item," "remove all items", "focus item"
  • Constructor Details

    • PlayerInventoryDisplay

      public PlayerInventoryDisplay(InventoryComponent inventory)
      TODO what happens if this is gone, along with the Constructs the PlayerInventory display, takes in an InventoryComponent so that it can handle displaying the item textures etc.
      Parameters:
      inventory - An already initialised InventoryComponent
  • Method Details

    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class UIComponent
    • addInventoryItem

      public void addInventoryItem(String texturePath)
      Add an item to the first empty slot.
    • addItem

      public void addItem(int index, String texturePath)
      Put an item in a specific slot.
    • clearSlot

      public void clearSlot(int index)
      Clear a specific slot (keeps background square, hides item).
    • clearAll

      public void clearAll()
      Remove everything (backgrounds remain visible).
    • setFocusedIndex

      public void setFocusedIndex(int index)
      Focus a specific slot; pass -1 to clear focus.
    • updateCount

      public void updateCount(int index, int count)
    • draw

      protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Description copied from class: RenderComponent
      Draw the renderable. Should be called only by the renderer, not manually.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - Batch to render to.
    • dispose

      public void dispose()
      Description copied from class: Component
      Called when the component is disposed. Dispose of any internal resources here.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent