Class PlayerInventoryDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.player.PlayerInventoryDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
The UI component of the inventory.
Use the triggers: "add item," "remove item," "remove all items", "focus item"
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerInventoryDisplay
(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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInventoryItem
(String texturePath) Add an item to the first empty slot.void
Put an item in a specific slot.void
clearAll()
Remove everything (backgrounds remain visible).void
clearSlot
(int index) Clear a specific slot (keeps background square, hides item).void
create()
Called when the entity is created and registered.void
dispose()
Called when the component is disposed.protected void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.void
setFocusedIndex
(int index) Focus a specific slot; pass -1 to clear focus.void
updateCount
(int index, int count) Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndex
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, disableComponent, enableComponent, isDisabled, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.csse3200.game.rendering.Renderable
render
-
Constructor Details
-
PlayerInventoryDisplay
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 classUIComponent
-
addInventoryItem
Add an item to the first empty slot. -
addItem
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 classRenderComponent
- 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 interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-