Skip to content

Item Display Logic

PeterOu8 edited this page Oct 3, 2022 · 6 revisions

This wiki page will explain the implementation of the how each item in the inventory is displayed in the inventory pop-up and how can user interact with it.

Item buttons

Each item in the inventory will be displayed as buttons in the inventory pop-up. The texture of each item is used as button images.

public void displayItems() {
    InventoryComponent inventory = ServiceLocator.getGameArea().getPlayer().getComponent(InventoryComponent.class);
    items = inventory.getInventory();
    for (int i = 0; i < items.size(); ++i) {
        Entity currentItem = items.get(i);
        Texture itemTexture = new 
        Texture(currentItem.getComponent(TextureRenderComponent.class).getTexturePath());
        TextureRegion itemTextureRegion = new TextureRegion(itemTexture);
        TextureRegionDrawable itemTextureDrawable = new TextureRegionDrawable(itemTextureRegion);
        ImageButton item = new ImageButton(itemTextureDrawable);
    }
}

The image buttons have onClick event listener will change the states of button. When a button is clicked, a drop-down menu will show up and provide options for the player to select.
Based on the item type, the player will have different options to choose from.

Potion:
Add the potion to the quick bar for quick usage or drop the item

Weapon or Armour:
Equip the item or drop the item

Crafting materials:
Drop the item

Back to Inventory Page

Author

  • Li-Sung Ou
  • GitHub: @PeterOu8
  • Discord: Secret Agent Randy Beans#6754
  • Slack: Li-Sung Ou
Clone this wiki locally