Files
PHY/Plugins/GGS/Source/GenericUISystem/Public/UI/Actions/GUIS_UIActionWidget.h
2026-03-03 01:23:02 +08:00

79 lines
2.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "CommonUserWidget.h"
#include "GameplayTagContainer.h"
#include "GUIS_UIAction.h"
#include "GUIS_UIActionWidget.generated.h"
class UGUIS_AsyncAction_ShowModel;
class UGUIS_UIActionFactory;
/**
* A widget which can associate data with register ui action dynamically based on passed-in data.
* @attention There's no visual for this widget.
* 此Widget可以关联一个数据并为其自动注册可用的输入事件。
*/
UCLASS(ClassGroup = GUIS, meta=(Category="Generic UI System"), AutoExpandCategories=("GUIS"))
class GENERICUISYSTEM_API UGUIS_UIActionWidget : public UCommonUserWidget
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category="GUIS|UIAction")
void SetAssociatedData(UObject* Data);
UFUNCTION(BlueprintCallable, Category="GUIS|UIAction")
void RegisterActions();
UFUNCTION(BlueprintCallable, Category="GUIS|UIAction")
virtual void RegisterActionsWithFactory(TSoftObjectPtr<UGUIS_UIActionFactory> InActionFactory);
UFUNCTION(BlueprintCallable, Category="GUIS|UIAction")
virtual void UnregisterActions();
UFUNCTION(BlueprintCallable, Category="GUIS|UIAction")
virtual void CancelAction();
//~ Begin UWidget
#if WITH_EDITOR
virtual const FText GetPaletteCategory() override;
#endif
//~ End UWidget interface
protected:
UFUNCTION()
virtual void HandleUIAction(const UGUIS_UIAction* Action);
UFUNCTION()
virtual void HandleModalAction(FGameplayTag ActionTag);
UPROPERTY()
TWeakObjectPtr<UObject> AssociatedData;
/**
* A factory to get available ui actions for associated data.
* 该数据资产用于针对关联数据返回所有可用的ui操作。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="UIAction")
TObjectPtr<UGUIS_UIActionFactory> ActionFactory;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FGUIS_HandleUIActionSignature, const UGUIS_UIAction*, ActionReference);
UPROPERTY(BlueprintAssignable, Category="UIAction")
FGUIS_HandleUIActionSignature OnHandleUIAction;
private:
TArray<FUIActionBindingHandle> ActionBindings;
UPROPERTY()
TObjectPtr<const UGUIS_UIAction> CurrentAction{nullptr};
UPROPERTY()
TObjectPtr<UGUIS_AsyncAction_ShowModel> ModalTask{nullptr};
};