第一次提交
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "GUIS_DetailSectionsBuilder.generated.h"
|
||||
|
||||
class UGUIS_ListEntryDetailSection;
|
||||
class UGUIS_ListEntry;
|
||||
|
||||
/**
|
||||
* Base class for customizing how detail sections are gathered for an object.
|
||||
* 自定义如何为对象收集细节部分的基类。
|
||||
*/
|
||||
UCLASS(Abstract, Blueprintable, meta = (Category = "Generic UI"))
|
||||
class GENERICUISYSTEM_API UGUIS_DetailSectionsBuilder : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gathers detail section classes for the specified data.
|
||||
* 为指定数据收集细节部分类。
|
||||
* @param Data The data object. 数据对象。
|
||||
* @return Array of detail section classes. 细节部分类数组。
|
||||
*/
|
||||
UFUNCTION(Blueprintable, BlueprintNativeEvent)
|
||||
TArray<TSoftClassPtr<UGUIS_ListEntryDetailSection>> GatherDetailSections(const UObject* Data);
|
||||
virtual TArray<TSoftClassPtr<UGUIS_ListEntryDetailSection>> GatherDetailSections_Implementation(const UObject* Data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Structure for mapping object classes to detail section classes.
|
||||
* 将对象类映射到细节部分类的结构。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICUISYSTEM_API FGUIS_EntryDetailsClassSections
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Array of detail section classes for an object class.
|
||||
* 对象类的细节部分类数组。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category="GUIS")
|
||||
TArray<TSoftClassPtr<UGUIS_ListEntryDetailSection>> Sections;
|
||||
};
|
||||
|
||||
/**
|
||||
* Concrete class for mapping object classes to detail sections.
|
||||
* 将对象类映射到细节部分的实体类。
|
||||
*/
|
||||
UCLASS(NotBlueprintable)
|
||||
class GENERICUISYSTEM_API UGUIS_DetailSectionBuilder_Class : public UGUIS_DetailSectionsBuilder
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gathers detail section classes for the specified data.
|
||||
* 为指定数据收集细节部分类。
|
||||
* @param Data The data object. 数据对象。
|
||||
* @return Array of detail section classes. 细节部分类数组。
|
||||
*/
|
||||
virtual TArray<TSoftClassPtr<UGUIS_ListEntryDetailSection>> GatherDetailSections_Implementation(const UObject* Data) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Mapping of object classes to their detail section configurations.
|
||||
* 对象类到其细节部分配置的映射。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category="GUIS", meta = (AllowAbstract))
|
||||
TMap<TSubclassOf<UObject>, FGUIS_EntryDetailsClassSections> SectionsForClasses;
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/IUserObjectListEntry.h"
|
||||
#include "UI/Foundation/GUIS_ButtonBase.h"
|
||||
#include "GUIS_ListEntry.generated.h"
|
||||
|
||||
class UGUIS_UIAction;
|
||||
|
||||
/**
|
||||
* List entry widget representing an item in a ListView or TileView.
|
||||
* 表示ListView或TileView中项的列表入口小部件。
|
||||
*/
|
||||
UCLASS(Abstract, meta = (Category = "Generic UI", DisableNativeTick))
|
||||
class GENERICUISYSTEM_API UGUIS_ListEntry : public UGUIS_ButtonBase, public IUserObjectListEntry
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CommonUserWidget.h"
|
||||
#include "GUIS_ListEntryDetailSection.generated.h"
|
||||
|
||||
/**
|
||||
* Detail section widget for composing a detail view.
|
||||
* 组成细节视图的细节部分小部件。
|
||||
*/
|
||||
UCLASS(Abstract, meta = (Category = "Generic UI"))
|
||||
class GENERICUISYSTEM_API UGUIS_ListEntryDetailSection : public UCommonUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Sets the object represented by this detail section.
|
||||
* 设置此细节部分表示的对象。
|
||||
* @param ListItemObject The object to display. 要显示的对象。
|
||||
*/
|
||||
void SetListItemObject(UObject* ListItemObject);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when the list item object is set.
|
||||
* 列表项对象设置时调用。
|
||||
* @param ListItemObject The object being set. 设置的对象。
|
||||
*/
|
||||
virtual void NativeOnListItemObjectSet(UObject* ListItemObject);
|
||||
|
||||
/**
|
||||
* Blueprint event for when the list item object is set.
|
||||
* 列表项对象设置时的蓝图事件。
|
||||
* @param ListItemObject The object being set. 设置的对象。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void OnListItemObjectSet(UObject* ListItemObject);
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CommonUserWidget.h"
|
||||
#include "Blueprint/UserWidgetPool.h"
|
||||
#include "GUIS_ListEntryDetailView.generated.h"
|
||||
|
||||
class UGUIS_DetailSectionsBuilder;
|
||||
class UGUIS_ListEntryDetailSection;
|
||||
class UVerticalBox;
|
||||
class UGUIS_WidgetFactory;
|
||||
struct FStreamableHandle;
|
||||
|
||||
/**
|
||||
* Detail view containing multiple sections to represent an item (any UObject).
|
||||
* 包含多个细节部分的视图,用于展示一个项(任意UObject类型)。
|
||||
*/
|
||||
UCLASS(Abstract, meta=(Category = "Generic UI"))
|
||||
class GENERICUISYSTEM_API UGUIS_ListEntryDetailView : public UCommonUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the detail view widget.
|
||||
* 细节视图小部件构造函数。
|
||||
*/
|
||||
UGUIS_ListEntryDetailView(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
/**
|
||||
* Sets the object represented by this detail view as data.
|
||||
* 设置此细节视图表示的对象作为数据。
|
||||
* @param InListItemObject The object to display. 要显示的对象。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="GUIS")
|
||||
void SetListItemObject(UObject* InListItemObject);
|
||||
|
||||
/**
|
||||
* Sets the associated detail sections builder.
|
||||
* 设置关联的细节部分构建器。
|
||||
* @param NewBuilder The detail sections builder. 细节部分构建器。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="GUIS")
|
||||
void SetSectionsBuilder(UGUIS_DetailSectionsBuilder* NewBuilder);
|
||||
|
||||
/**
|
||||
* Releases Slate resources.
|
||||
* 释放Slate资源。
|
||||
* @param bReleaseChildren Whether to release child resources. 是否释放子资源。
|
||||
*/
|
||||
virtual void ReleaseSlateResources(bool bReleaseChildren) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when the widget is constructed.
|
||||
* 小部件构造时调用。
|
||||
*/
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
/**
|
||||
* Called when the widget is initialized.
|
||||
* 小部件初始化时调用。
|
||||
*/
|
||||
virtual void NativeOnInitialized() override;
|
||||
|
||||
/**
|
||||
* Creates a detail section extension for the specified data.
|
||||
* 为指定数据创建细节部分扩展。
|
||||
* @param InData The data object. 数据对象。
|
||||
* @param SectionClass The section widget class. 部分小部件类。
|
||||
*/
|
||||
void CreateDetailsExtension(UObject* InData, TSubclassOf<UGUIS_ListEntryDetailSection> SectionClass);
|
||||
|
||||
/**
|
||||
* Detail sections builder for displaying data based on widget specifications.
|
||||
* 根据小部件规格显示数据的细节部分构建器。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category="GUIS", meta = (AllowAbstract = false))
|
||||
TObjectPtr<UGUIS_DetailSectionsBuilder> SectionsBuilder;
|
||||
|
||||
/**
|
||||
* Pool for managing extension widgets.
|
||||
* 管理扩展小部件的池。
|
||||
*/
|
||||
UPROPERTY(Transient)
|
||||
FUserWidgetPool ExtensionWidgetPool;
|
||||
|
||||
/**
|
||||
* Current object represented by the detail view.
|
||||
* 细节视图当前表示的对象。
|
||||
*/
|
||||
UPROPERTY(Transient)
|
||||
TObjectPtr<UObject> CurrentListItemObject;
|
||||
|
||||
/**
|
||||
* Handle for streaming assets.
|
||||
* 流式加载资产的句柄。
|
||||
*/
|
||||
TSharedPtr<FStreamableHandle> StreamingHandle;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Vertical box for detail sections.
|
||||
* 细节部分的垂直框。
|
||||
*/
|
||||
UPROPERTY(BlueprintReadOnly, Category="GUIS", meta = (BindWidget, BlueprintProtected = true, AllowPrivateAccess = true))
|
||||
TObjectPtr<UVerticalBox> Box_DetailSections;
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CommonListView.h"
|
||||
#include "GUIS_ListView.generated.h"
|
||||
|
||||
class UGUIS_WidgetFactory;
|
||||
|
||||
/**
|
||||
* Extended ListView allowing dynamic selection of entry widget class via data asset.
|
||||
* 通过数据资产动态选择入口小部件类的扩展ListView。
|
||||
*/
|
||||
UCLASS(Blueprintable, meta = (Category = "Generic UI"))
|
||||
class GENERICUISYSTEM_API UGUIS_ListView : public UCommonListView
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the ListView widget.
|
||||
* ListView小部件构造函数。
|
||||
*/
|
||||
UGUIS_ListView(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
#if WITH_EDITOR
|
||||
/**
|
||||
* Validates compiled defaults in the editor.
|
||||
* 在编辑器中验证编译默认值。
|
||||
* @param InCompileLog The widget compiler log. 小部件编译日志。
|
||||
*/
|
||||
virtual void ValidateCompiledDefaults(IWidgetCompilerLog& InCompileLog) const override;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sets the entry widget factories for dynamic widget selection.
|
||||
* 设置动态小部件选择的入口小部件工厂。
|
||||
* @param NewFactories The array of widget factories. 小部件工厂数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "ListEntries")
|
||||
void SetEntryWidgetFactories(TArray<UGUIS_WidgetFactory*> NewFactories);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Generates an entry widget for the specified item.
|
||||
* 为指定项生成入口小部件。
|
||||
* @param Item The item to generate a widget for. 要生成小部件的项。
|
||||
* @param DesiredEntryClass The desired entry widget class. 期望的入口小部件类。
|
||||
* @param OwnerTable The owning table view. 所属表格视图。
|
||||
* @return The generated widget. 生成的小部件。
|
||||
*/
|
||||
virtual UUserWidget& OnGenerateEntryWidgetInternal(UObject* Item, TSubclassOf<UUserWidget> DesiredEntryClass, const TSharedRef<STableViewBase>& OwnerTable) override;
|
||||
|
||||
/**
|
||||
* Array of widget factories for dynamic entry widget selection.
|
||||
* 动态入口小部件选择的小部件工厂数组。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ListEntries", meta = (IsBindableEvent = "True"))
|
||||
TArray<TObjectPtr<UGUIS_WidgetFactory>> EntryWidgetFactories;
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CommonTileView.h"
|
||||
#include "GUIS_TileView.generated.h"
|
||||
|
||||
class UGUIS_WidgetFactory;
|
||||
|
||||
/**
|
||||
* Extended TileView allowing dynamic selection of entry widget class via data asset.
|
||||
* 通过数据资产动态选择入口小部件类的扩展TileView。
|
||||
*/
|
||||
UCLASS(Blueprintable, meta = (Category = "Generic UI"))
|
||||
class GENERICUISYSTEM_API UGUIS_TileView : public UCommonTileView
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the TileView widget.
|
||||
* TileView小部件构造函数。
|
||||
*/
|
||||
UGUIS_TileView(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
#if WITH_EDITOR
|
||||
/**
|
||||
* Validates compiled defaults in the editor.
|
||||
* 在编辑器中验证编译默认值。
|
||||
* @param InCompileLog The widget compiler log. 小部件编译日志。
|
||||
*/
|
||||
virtual void ValidateCompiledDefaults(IWidgetCompilerLog& InCompileLog) const override;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sets the entry widget factories for dynamic widget selection.
|
||||
* 设置动态小部件选择的入口小部件工厂。
|
||||
* @param NewFactories The array of widget factories. 小部件工厂数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "ListEntries")
|
||||
void SetEntryWidgetFactories(TArray<UGUIS_WidgetFactory*> NewFactories);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Generates an entry widget for the specified item.
|
||||
* 为指定项生成入口小部件。
|
||||
* @param Item The item to generate a widget for. 要生成小部件的项。
|
||||
* @param DesiredEntryClass The desired entry widget class. 期望的入口小部件类。
|
||||
* @param OwnerTable The owning table view. 所属表格视图。
|
||||
* @return The generated widget. 生成的小部件。
|
||||
*/
|
||||
virtual UUserWidget& OnGenerateEntryWidgetInternal(UObject* Item, TSubclassOf<UUserWidget> DesiredEntryClass, const TSharedRef<STableViewBase>& OwnerTable) override;
|
||||
|
||||
/**
|
||||
* Array of widget factories for dynamic entry widget selection.
|
||||
* 动态入口小部件选择的小部件工厂数组。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ListEntries", meta = (IsBindableEvent = "True"))
|
||||
TArray<TObjectPtr<UGUIS_WidgetFactory>> EntryWidgetFactories;
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "GUIS_UserWidgetInterface.generated.h"
|
||||
|
||||
/**
|
||||
* Interface for UserWidget functionality.
|
||||
* 通用UserWidget功能的接口。
|
||||
* @note Designed for UserWidgets (except UCommonActivatableWidget and its derivatives).
|
||||
* @注意 专为UserWidget设计(不包括UCommonActivatableWidget及其派生类)。
|
||||
* @details Automatically called when used as an extension UI.
|
||||
* @细节 用作扩展UI时自动调用。
|
||||
*/
|
||||
UINTERFACE()
|
||||
class GENERICUISYSTEM_API UGUIS_UserWidgetInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation class for UserWidget interface.
|
||||
* UserWidget接口的实现类。
|
||||
*/
|
||||
class GENERICUISYSTEM_API IGUIS_UserWidgetInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves the owning actor of the UserWidget.
|
||||
* 获取UserWidget的所属演员。
|
||||
* @return The logical owning actor. 逻辑所属演员。
|
||||
* @note Tracks data for an actor in the game world.
|
||||
* @注意 跟踪游戏世界中演员的数据。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GUIS")
|
||||
AActor* GetOwningActor();
|
||||
|
||||
/**
|
||||
* Sets the owning actor of the UserWidget.
|
||||
* 设置UserWidget的所属演员。
|
||||
* @param NewOwningActor The new owning actor. 新的所属演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GUIS")
|
||||
void SetOwningActor(AActor* NewOwningActor);
|
||||
|
||||
/**
|
||||
* Called when the UserWidget is activated.
|
||||
* UserWidget激活时调用。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GUIS")
|
||||
void OnActivated();
|
||||
|
||||
/**
|
||||
* Called when the UserWidget is deactivated.
|
||||
* UserWidget禁用时调用。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GUIS")
|
||||
void OnDeactivated();
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "GUIS_WidgetFactory.generated.h"
|
||||
|
||||
class UUserWidget;
|
||||
|
||||
/**
|
||||
* Base class for selecting appropriate widget classes for objects.
|
||||
* 为对象选择合适小部件类的基类。
|
||||
*/
|
||||
UCLASS(Abstract, Blueprintable, BlueprintType, HideDropdown, Const)
|
||||
class GENERICUISYSTEM_API UGUIS_WidgetFactory : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
* 默认构造函数。
|
||||
*/
|
||||
UGUIS_WidgetFactory();
|
||||
|
||||
/**
|
||||
* Finds the appropriate widget class for the given data.
|
||||
* 为给定数据查找合适的小部件类。
|
||||
* @param Data The data object. 数据对象。
|
||||
* @return The widget class. 小部件类。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category="GUIS")
|
||||
TSubclassOf<UUserWidget> FindWidgetClassForData(const UObject *Data) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Validates the data for the widget factory.
|
||||
* 验证小部件工厂的数据。
|
||||
* @param ValidationMessage The validation message (output). 验证消息(输出)。
|
||||
* @return True if valid, false otherwise. 如果有效返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category="GUIS")
|
||||
bool OnDataValidation(FText &ValidationMessage) const;
|
||||
virtual bool OnDataValidation_Implementation(FText &ValidationMessage) const;
|
||||
|
||||
#if WITH_EDITOR
|
||||
/**
|
||||
* Validates data in the editor.
|
||||
* 在编辑器中验证数据。
|
||||
* @param Context The data validation context. 数据验证上下文。
|
||||
* @return The validation result. 验证结果。
|
||||
*/
|
||||
virtual EDataValidationResult IsDataValid(FDataValidationContext &Context) const override;
|
||||
#endif
|
||||
};
|
||||
Reference in New Issue
Block a user