Skip to content

Inventory Widget

Introduction

The widget responsible for displaying the inventory

Dependencies

The InventoryWidget relies on other components of this plugin to work:

  • Logger: Used to log useful information to help you debug any issues you might experience

Required Widgets

You need to add the following before you can compile the InventoryWidget widget:

Name Description Type
InventoryMenu The menu responsible for controlling all the menu items UMenu*

Optional Widgets

You can add the following widgets to enable extra functionality:

Name Description Type
NameText The widget responsible for displaying the highlighted item's name UTextBlock*
DescriptionText The widget responsible for displaying the highlighted item's description UTextBlock*
PreviewImage The widget responsible for displaying the highlighted item's image UImage*
AmountText The widget responsible for displaying the highlighted item's amount UTextBlock*

API Reference

Properties

Property Description Type Default Value
MenuItemClass The inventory menu item class used to display the inventory items TSubclassOf<UInventoryMenuItem>
ItemData The data table containing all the information about the inventory items UDataTable* nullptr
InventorySize The size restrictions of the inventory EInventorySize
Rows The amount of rows in the inventory int
Columns The amount of columns in the inventory int

Events

Name Description Params
OnInventoryItemSelected Event used to notify other classes every time an inventory item is selected Name (FName)
The ID of the selected inventory item

Functions

Name Description Params Return
LoadInventory Load a specific inventory InventoryComponent (UInventoryComponent*)
The inventory to load
UpdatePreview Update the preview of the inventory Item (FInventoryItem)
The item to preview
UpdateHighlightedIndex Update the highlighted index Column (int)
The column index of the item that is highlighted

Row (int)
The row index of the item that is highlighted
SelectItem Select an inventory item Id (FName)
The ID of the item to select
GetInventory Get the inventory managed by the widget UInventoryComponent*
The inventory managed by the widget
RefreshItem Refresh a specific item in the inventory Id (FName)
The ID of the item to refresh

Amount (int)
The amount of the item
RefreshInventory Refresh the entire inventory

Blueprint Usage

You can use the InventoryWidget using Blueprints by adding one of the following nodes:

  • Ultimate Starter Kit > Inventory > Load Inventory
  • Ultimate Starter Kit > Inventory > Update Preview
  • Ultimate Starter Kit > Inventory > Update Highlighted Index
  • Ultimate Starter Kit > Inventory > Select Item
  • Ultimate Starter Kit > Inventory > Get Inventory
  • Ultimate Starter Kit > Inventory > Refresh Item
  • Ultimate Starter Kit > Inventory > Refresh Inventory

C++ Usage

Before you can use the plugin, you first need to enable the plugin in your Build.cs file:

PublicDependencyModuleNames.Add("USK");

The InventoryWidget can now be used in any of your C++ files:

#include "USK/Inventory/InventoryWidget.h"

void ATestActor::Test()
{
    // InventoryWidget is a pointer to the UInventoryWidget
    InventoryWidget->LoadInventory(InventoryComponent);
    InventoryWidget->UpdatePreview(Item);
    InventoryWidget->UpdateHighlightedIndex(Column, Row);
    InventoryWidget->SelectItem(Id);
    UInventoryComponent* Inventory = InventoryWidget->GetInventory();
    InventoryWidget->RefreshItem(Id, Amount);
    InventoryWidget->RefreshInventory();
}