The version 1.1 offers you the ability to give some contexts to inventories.
Problematic :
Remember that an inventory can be displayed at multiple position into the screen due to the Model-View design pattern I use of the UI.
That said, not all the representation of the Inventory on screen have the same usage and context. For example the inventory which is displayed near the equipment panel may act differently than the one in the "Inventory" tab.
The idea is to change the behavior of an inventory based on its usage and its usage context. Especialy when using the right click on inventory slots. If we take the example below, we may want to automatically equip/unequip items if we right click on a slots if the inventory is in the "Equipment" tab.
Solution :
The solution is handled with two new concepts :
- Inventory Usage Context : The context in which the inventory is used. The context is determined by the place where we are using the inventory (where we are displaying it in the HUD).
- Inventory Usage : The intrinsic usage of the inventory. This one determine the role of the Inventory Component. This might be a Chest inventory if the Inventory component is placed in a chest, or a Player inventory is the inventory component is placed in the player...
That's why I created the following :
- A InventoryUsageContext Enum, which describes the context in which this inventory is used (i.e : displayed) (Values : Default, EquipmentPanel, ChestLookupPanel)
- A InventoryUsage Enum, which describes the intrinsic usage of the inventory (Values : PlayerInventory, ChestInventory, EquipmentInventory)
- A InventoryUsageContext Structure, storing both the InventoryUsageContext and a reference to another inventory with which the current inventory will interact.
Check the BP_InventoryComponent::OnSlotRightClick() function to see an example of how I use these values.
Note : The InventoryUsageContext value is passed to this function from the UI. I setup the context of Inventory widgets inside PlayerMenu::InitClient() and PlayerMenu::TabDisplayed() functions