Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Inventory class #157

Open
pavlicekdominik opened this issue Nov 4, 2023 · 0 comments
Open

UI Inventory class #157

pavlicekdominik opened this issue Nov 4, 2023 · 0 comments
Assignees
Milestone

Comments

@pavlicekdominik
Copy link
Member

pavlicekdominik commented Nov 4, 2023

Class: UInventoryUI

Inherits: UMounteaBaseUserWidget
Implements: IInventoryUI

Properties

InventorySlots: TArray<UInventorySlotUI*>

An array that stores references to slot UI elements within the inventory.

Functions:

Function: AddItemToInventory

**Purpose:** To add a new item or update an existing item in the inventory slots. **Inputs:** FInventorySlot SlotData: The data representing the item and its properties to be added. **Returns:** void **Detailed Behaviour:** This function takes an FInventorySlot which includes information about the item, such as ID, quantity, and other relevant metadata. It either updates an existing inventory slot with the new item details or creates a new slot if an appropriate one doesn't exist.

Function: RemoveItemFromInventory

**Purpose:** To remove an item from a specific inventory slot. **Inputs:** int32 SlotIndex: The index of the slot from which the item is to be removed. **Returns:** void **Detailed Behaviour:** This function removes the item information from the specified slot index, effectively clearing the slot for future use. If the index is out of range, the function should handle this gracefully.

Function: AddMultipleItems

**Purpose:** To add multiple items to the inventory, either by updating existing slots or creating new ones. **Inputs:** TArray SlotDataArray: An array of inventory slots data to be added. **Returns:** void **Detailed Behaviour:** This function iterates over the array of FInventorySlot, adding each item to the inventory by calling `AddItemToInventory` internally. It is optimized for bulk operations to reduce the number of UI updates required.

Function: RemoveMultipleItems

**Purpose:** To remove multiple items from the inventory using their slot indices. **Inputs:** TArray SlotIndices: An array of slot indices from which items are to be removed. **Returns:** void **Detailed Behaviour:** This function iterates over the array of indices and calls `RemoveItemFromInventory` for each one. This batch operation allows for efficient multiple item removals.

Function: ExecuteCommand

**Purpose:** To execute a specific command that affects the inventory UI, allowing for extensibility and custom operations. **Inputs:** FString Command: The command to be executed. FCommandParams Params: The parameters that provide context and arguments for the command. **Returns:** void **Detailed Behaviour:** This function interprets the command string and parameters, executing the corresponding operation. This could range from complex inventory organization commands to UI state changes, offering a flexible interface for various UI actions.

Usage and Logic Integration

  • UInventoryUI acts as the central hub for managing the inventory UI elements.
  • It responds to game events that necessitate adding or removing items, ensuring the UI reflects the current state of the player's inventory.
  • Batch operations allow for efficient processing of multiple inventory changes with minimal performance impact.
  • The ExecuteCommand function provides a hook for custom commands and advanced UI interactions that go beyond standard inventory management.

Usage Flow

  1. Game event triggers an inventory update.
  2. Relevant function (Add/Remove, Single/Batch) is called.
  3. UI is updated accordingly to reflect the current inventory state.
  4. Custom commands can be executed through ExecuteCommand for special cases.

This layout ensures that the UInventoryUI class is capable of handling inventory updates in a responsive and flexible manner, accommodating both typical inventory operations and more complex interactions as required by the game logic.

@pavlicekdominik pavlicekdominik self-assigned this Nov 4, 2023
@pavlicekdominik pavlicekdominik added this to the 1.0.0.X milestone Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant