InventoryUI ​
Clean and Simple Universal Inventory UI - Refactored to extend PanelUI Updated to remove VENDOR_INVENTORY logic (now handled by dedicated VendorSlotUI)
Description ​
PLAYER_INVENTORY: Player's inventory
- Drag & Drop: Move items around freely
- Right-click: Use/Equip items (ItemInstance.use() handles everything)
EXTERNAL_INVENTORY: Loot containers, corpses, etc.
- Drag & Drop: Move items in/out freely (loot <-> inventory)
- Right-click: Auto-loot item to player inventory
PLAYER_VENDOR_INVENTORY: Player inventory in shop context
- Right-click: Sell item to vendor (instead of use)
- Shows vendor buy price in tooltips
READONLY: Display only, no interactions
- No interactions allowed
- Used for crafting material displays, quest rewards, etc.
Properties ​
InventoryContext | context | InventoryContext.PLAYER_INVENTORY |
String | title | "" |
bool | show_currency | true |
bool | allow_drag_and_drop | true |
bool | show_kept_aside | true |
int | grid_columns | 4 |
PackedScene | inventory_slot_scene | |
PackedScene | currency_display_scene |
Variables ​
InventoryComponent | inventory_data | |
Variant | inventory_owner | |
VendorInventoryComponent | vendor_data | |
Array[Control] | slot_uis | [] |
Methods ​
void | initialize_ui( system_hub: GameHost.SystemHub ) |
void | setup_player_inventory( inventory: InventoryComponent, window_title: String = "" ) |
void | setup_external_inventory( inventory: InventoryComponent, inv_owner: Variant, window_title: String = "" ) |
void | setup_player_vendor_inventory( inventory: InventoryComponent, vendor: VendorInventoryComponent, window_title: String = "" ) |
InventoryContext | get_context() |
InventoryComponent | get_inventory_data() |
VendorInventoryComponent | get_vendor_data() |
Entity | get_inventory_owner() |
void | set_title( new_title: String ) |
void | refresh() |
void | cleanup() |
Enumerations ​
enum InventoryContext ​
The options of inventory context: player inventory, external inventory, player vendor inventory, readonly.
- PLAYER_INVENTORY =
0- Player's main inventory - EXTERNAL_INVENTORY =
1- Containers, loot, etc. - PLAYER_VENDOR_INVENTORY =
2- Player inventory while in shop - READONLY =
3- No interactions allowed
Constants ​
intGRID_CELL_SIZE =44- The size of one slot in pixels.
Property descriptions ​
InventoryContext context = InventoryContext.PLAYER_INVENTORY ​
Whose inventory the window shows (the player, a container, a vendor ...).
String title = "" ​
The title of the window.
bool show_currency = true ​
True shows the currencies.
bool allow_drag_and_drop = true ​
True lets the player drag items.
bool show_kept_aside = true ​
Lists the items that are kept aside (quest items that take no space) under the slots, as "Quest items". Off = the window does not show them at all (they stay in the bag)
int grid_columns = 4 ​
How many slots are in a row.
PackedScene inventory_slot_scene ​
The scene of one slot.
PackedScene currency_display_scene ​
The scene of one currency display.
Variable descriptions ​
InventoryComponent inventory_data ​
The inventory shown.
Variant inventory_owner ​
Who owns the inventory.
VendorInventoryComponent vendor_data ​
The stock of the vendor, when it shows one.
Array[Control] slot_uis = [] ​
The slots shown.
Method descriptions ​
void initialize_ui( system_hub: GameHost.SystemHub ) ​
Sets the part up with the hub of the game systems: connects the signals it listens to and fills it.
void setup_player_inventory( inventory: InventoryComponent, window_title: String = "" ) ​
Setup player inventory (normal or vendor context)
void setup_external_inventory( inventory: InventoryComponent, inv_owner: Variant, window_title: String = "" ) ​
Setup external inventory (containers, loot, etc.)
void setup_player_vendor_inventory( inventory: InventoryComponent, vendor: VendorInventoryComponent, window_title: String = "" ) ​
Setup player inventory in vendor context (for selling to vendor)
InventoryContext get_context() ​
Whose inventory the window shows.
InventoryComponent get_inventory_data() ​
The inventory shown.
VendorInventoryComponent get_vendor_data() ​
The stock of the vendor, when it shows one.
Entity get_inventory_owner() ​
Who owns the inventory.
void set_title( new_title: String ) ​
Sets the title of the window.
void refresh() ​
Fills the grid and the currencies again.
void cleanup() ​
Disconnects the inventory and clears the grid.