SLimenGridInventory
Overview
SLimenGridInventory is a Slate compound widget that visualizes an inventory grid. It handles drag-and-drop operations, updates the UI based on inventory changes, and manages cell highlighting during interactions.
Properties
Type | Name | Access | Description |
|---|---|---|---|
| InventoryComponent | Private | Weak pointer to the inventory component. |
| InventorySize | Private | Size of the inventory grid. |
| CellSize | Public | Size of each cell in the grid. |
| CellWidget | Public | Class type for individual grid cells. |
| GridPanel | Private | Slate grid panel widget that holds the inventory cells. |
| CellUpdateDelegateHandle | Private | Delegate handle for handling cell updates from the inventory component. |
| HighlightedCells | Private | Set of highlighted cells during drag-and-drop operations. |
| GridCellWidgets | Private | Array of Slate widgets representing individual grid cells. |
Functions
Return Type | Signature | Description |
|---|---|---|
| Construct(const FArguments& InArgs) | Initializes the widget with arguments and sets up the inventory grid. |
| SetInventory(ULimenGridInventoryComponent* InInventory) | Sets the inventory component and updates the grid accordingly. |
| OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) | Handles drag-over events to highlight potential drop cells. |
| OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) | Handles drop events to place items in the inventory grid. |
| OnDragLeave(const FDragDropEvent& DragDropEvent) | Clears highlighted cells when drag leaves the widget area. |
| InventoryCellUpdate(const TArray & Updates) | Updates the grid based on cell updates from the inventory component. |
| CursorPositionToCellCoordinate(const FGeometry& MyGeometry, const FVector2D& ScreenCursorPosition) const | Converts screen cursor position to grid cell coordinates. |
| GetRootCellCoordinates(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) const | Calculates the root cell coordinates for drag-and-drop operations. |
| GetPlacementCells(const FIntVector2& RootCell, const FDragDropEvent& DragDropEvent) | Determines the set of cells where an item can be placed during a drag-and-drop operation. |
| CreateInventoryGrid() | Creates and updates the grid based on the current inventory state. |
| ClearHighlightedCells() | Clears all highlighted cells in the grid. |
Usage & Implementation Notes
The widget handles drag-and-drop operations to allow items to be placed in the inventory grid.
It uses a
SGridPanelto layout individual grid cells.Cell highlighting is managed during drag-and-drop events to indicate valid and invalid placement areas.
The widget updates its display based on changes from an associated
ULimenGridInventoryComponent.