Ein neues modulares Inventar- und Ausrüstungs-UI-System wurde implementiert, das folgende Hauptfunktionen bietet: - Unterstützung für Ausrüstungs-Slots (`UEquipmentWidget`, `UEquipmentSlotWidget`). - Darstellung von Inventargegenständen in Listen- oder Rasteransicht (`UInventoryItemListWidget`, `UInventoryGridWidget`). - Schnellzugriffsleiste für große und kleine Slots (`UQuickSlotListWidget`). - Verwaltung von Inventarbehältern mit zusammenklappbaren Bereichen (`UInventoryContainerListWidget`). Neue Datenstrukturen (`InventoryTypes.h`) definieren Enums und Strukturen für Gegenstände, Ausrüstungs-Slots und Behälter. Der `PlayerController` wurde erweitert, um das Inventar-UI zu öffnen/schließen (`ToggleInventory`). Neue `.uasset`-Dateien wurden hinzugefügt, um die UI-Komponenten zu unterstützen.
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Blueprint/UserWidget.h"
|
|
#include "Inventory/InventoryTypes.h"
|
|
#include "InventoryContainerListWidget.generated.h"
|
|
|
|
class UInventoryGridWidget;
|
|
class UTextBlock;
|
|
|
|
/**
|
|
* A labeled, collapsible view of one inventory container (the player's own bag, a chest being
|
|
* looted, ...):
|
|
*
|
|
* WBP_InventoryContainerList
|
|
* |-- Container Label
|
|
* `-- Collapsible Inventory Grid
|
|
* `-- WBP_InventoryGrid
|
|
* `-- WBP_Item
|
|
*
|
|
* Name a TextBlock exactly "ContainerLabel" in the Designer, and nest a WBP subclass of
|
|
* UInventoryGridWidget named exactly "WBP_InventoryGrid". SetContainerData populates the label
|
|
* and forwards the container's items to the nested grid; SetExpanded/ToggleExpanded show or
|
|
* collapse it. Wire an expand/collapse button to ToggleExpanded in the Designer/event graph.
|
|
*/
|
|
UCLASS(abstract)
|
|
class UInventoryContainerListWidget : public UUserWidget
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Inventory")
|
|
void SetContainerData(const FInventoryContainerInfo& InContainerData);
|
|
|
|
UFUNCTION(BlueprintPure, Category = "Inventory")
|
|
const FInventoryContainerInfo& GetContainerData() const { return ContainerData; }
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Inventory")
|
|
void SetExpanded(bool bInExpanded);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Inventory")
|
|
void ToggleExpanded();
|
|
|
|
UFUNCTION(BlueprintPure, Category = "Inventory")
|
|
bool IsExpanded() const { return bExpanded; }
|
|
|
|
protected:
|
|
|
|
virtual void NativeConstruct() override;
|
|
|
|
/** Named exactly "ContainerLabel" in the Designer. */
|
|
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true))
|
|
TObjectPtr<UTextBlock> ContainerLabel;
|
|
|
|
/** Nested WBP_InventoryGrid instance - named exactly "WBP_InventoryGrid" in the Designer tree, reparented to a UInventoryGridWidget subclass. Collapsed/shown by SetExpanded. */
|
|
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true))
|
|
TObjectPtr<UInventoryGridWidget> WBP_InventoryGrid;
|
|
|
|
UPROPERTY(BlueprintReadOnly, Category = "Inventory")
|
|
FInventoryContainerInfo ContainerData;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Inventory")
|
|
bool bExpanded = true;
|
|
};
|