| @ -4,6 +4,7 @@ | ||||
| #include "AbilitySystemGlobals.h" | ||||
| #include "GameplayEffectTypes.h" | ||||
| #include "Gas/BusyGameAbility.h" | ||||
| #include "Level/Actor/BusyPawnBase.h" | ||||
|  | ||||
| UBusyAbilityDataAssetBase* UBusyAscLibrary::GetAbilityDataAssetByEffect(const FGameplayEffectSpec& Spec) | ||||
| { | ||||
| @ -28,3 +29,12 @@ FGameplayEffectSpecHandle UBusyAscLibrary::MakeGameplayEffectSpecHandle(const UA | ||||
| 	FGameplayEffectSpec* NewSpec = new FGameplayEffectSpec(Effect, ContextHandle, Level); | ||||
| 	return FGameplayEffectSpecHandle(NewSpec); | ||||
| } | ||||
|  | ||||
| FGameplayAttribute UBusyAscLibrary::GetAttribute(const UBusyPawnAttributeSet* AttributeSet, const FName& AttributeName) | ||||
| { | ||||
| 	if (FProperty* Prop = FindFieldChecked<FProperty>(AttributeSet->GetClass(), AttributeName)) | ||||
| 	{ | ||||
| 		return Prop; | ||||
| 	} | ||||
| 	return nullptr; | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,19 @@ | ||||
| #include "BlueprintLibrary/UIFunctionLibrary.h" | ||||
| #include "UIFramework/UIFrameworkHud.h" | ||||
|  | ||||
| UPW_UIController* UUIFunctionLibrary::GetUIController(const UObject* Object, const FName& Name) | ||||
| { | ||||
| 	if (Object == nullptr) return nullptr; | ||||
| 	const UWorld* World = Object->GetWorld(); | ||||
| 	if (World == nullptr) return nullptr; | ||||
| 	const APlayerController* PC = World->GetFirstPlayerController(); | ||||
| 	if (PC == nullptr) return nullptr; | ||||
|  | ||||
| 	if (APW_UIFrameworkHud* Hud = Cast<APW_UIFrameworkHud>(PC->GetHUD())) | ||||
| 	{ | ||||
| 		return Hud->GetUIController(Name); | ||||
| 	} | ||||
| 	 | ||||
| 	return nullptr; | ||||
| 	 | ||||
| } | ||||
| @ -1 +1,16 @@ | ||||
| #include "Level/Actor/Components/BusyAbilitySystemComponent.h" | ||||
|  | ||||
| void UBusyAbilitySystemComponent::BindEventToAttributeChange(const UClass* AttributeSetClass, const FName& AttributeName, FOnBusyAttributeChange Delegate) | ||||
| { | ||||
| 	FProperty* Prop = FindFieldChecked<FProperty>(AttributeSetClass, AttributeName); | ||||
| 	if (Prop == nullptr) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
| 	FOnGameplayAttributeValueChange &OnAttributeChange = GetGameplayAttributeValueChangeDelegate(Prop); | ||||
|  | ||||
| 	OnAttributeChange.AddLambda([AttributeName, Delegate](const FOnAttributeChangeData& Data) | ||||
| 	{ | ||||
| 		Delegate.ExecuteIfBound(AttributeName, Data.NewValue, Data.OldValue); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
							
								
								
									
										6
									
								
								Source/BusyRabbit/Private/UIFramework/MinimalWidget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								Source/BusyRabbit/Private/UIFramework/MinimalWidget.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| #include "UIFramework/MinimalWidget.h" | ||||
|  | ||||
| UWidget* UPW_MinimalWidget::GetWidget(const FName& Name)const | ||||
| { | ||||
| 	return GetWidgetFromName(Name); | ||||
| } | ||||
							
								
								
									
										22
									
								
								Source/BusyRabbit/Private/UIFramework/RootWidget.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Source/BusyRabbit/Private/UIFramework/RootWidget.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| #include "UIFramework/RootWidget.h" | ||||
| #include "Blueprint/WidgetTree.h" | ||||
| #include "UIFramework/WidgetPanel.h" | ||||
| #include "Components/Overlay.h" | ||||
| #include "Components/OverlaySlot.h" | ||||
|  | ||||
|  | ||||
| bool UPW_RootWidget::PushWidget(UPW_WidgetPanel* Widget)const | ||||
| { | ||||
| 	if (UOverlaySlot* OverlaySlot = Cast<UOverlaySlot>(MainOverlay->AddChild(Widget))) | ||||
| 	{ | ||||
| 		OverlaySlot->SetHorizontalAlignment(HAlign_Fill); | ||||
| 		OverlaySlot->SetVerticalAlignment(VAlign_Fill); | ||||
| 		return true; | ||||
| 	} | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| bool UPW_RootWidget::RemoveWidget(UPW_WidgetPanel* Widget)const | ||||
| { | ||||
| 	return MainOverlay->RemoveChild(Widget); | ||||
| } | ||||
							
								
								
									
										21
									
								
								Source/BusyRabbit/Private/UIFramework/UIController.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								Source/BusyRabbit/Private/UIFramework/UIController.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| #include "UIFramework/UIController.h" | ||||
|  | ||||
| void UPW_UIController::InitUIController(APW_UIFrameworkHud* UIHud) | ||||
| { | ||||
| 	Hud = UIHud; | ||||
| 	OnUIControllerInitialized(); | ||||
| } | ||||
|  | ||||
| void UPW_UIController::DestroyUIController() | ||||
| { | ||||
| 	OnUIControllerDestroy(); | ||||
| } | ||||
|  | ||||
| void UPW_UIController::OnUIControllerInitialized_Implementation() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void UPW_UIController::OnUIControllerDestroy_Implementation() | ||||
| { | ||||
| } | ||||
							
								
								
									
										83
									
								
								Source/BusyRabbit/Private/UIFramework/UIFrameworkHud.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								Source/BusyRabbit/Private/UIFramework/UIFrameworkHud.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,83 @@ | ||||
| #include "UIFramework/UIFrameworkHud.h" | ||||
| #include "UIFramework/RootWidget.h" | ||||
| #include "UIFramework/UIController.h" | ||||
|  | ||||
| DEFINE_LOG_CATEGORY(LogUIHud) | ||||
|  | ||||
|  | ||||
| APW_UIFrameworkHud::APW_UIFrameworkHud() | ||||
| { | ||||
| 	UIManager = CreateDefaultSubobject<UPW_UIManager>(TEXT("UIManager")); | ||||
| } | ||||
|  | ||||
| void APW_UIFrameworkHud::BeginPlay() | ||||
| { | ||||
| 	if (RootWidgetClass) | ||||
| 	{ | ||||
| 		UPW_RootWidget* Root = NewObject<UPW_RootWidget>(this, RootWidgetClass, FName("RootWidget")); | ||||
| 		UIManager->AttachUIDisplay(Root); | ||||
| 	} | ||||
|  | ||||
| 	for (const TPair Pair  : UIControllerClasses) | ||||
| 	{ | ||||
| 		TSoftClassPtr<UPW_UIController> ControllerClass = Pair.Value; | ||||
| 		if (ControllerClass.IsNull()) continue; | ||||
|  | ||||
| 		auto Delegate = FLoadSoftObjectPathAsyncDelegate::CreateLambda([this, Pair](const FSoftObjectPath& Path, UObject* Object) | ||||
| 		{ | ||||
| 			if (const UClass* UIControllerClass = Cast<UClass>(Object)) | ||||
| 			{ | ||||
| 				if (UPW_UIController* NewController = NewObject<UPW_UIController>(this, UIControllerClass)) | ||||
| 				{ | ||||
| 					UIControllers.Add(Pair.Key, NewController); | ||||
| 					NewController->InitUIController(this); | ||||
| 				} | ||||
| 			} | ||||
| 			TryNotifyResourceLoaded(); | ||||
| 		}); | ||||
|  | ||||
| 		if (ControllerClass.LoadAsync(Delegate) == -1) | ||||
| 		{ | ||||
| 			UE_LOG(LogUIHud, Error, TEXT("APW_UIFrameworkHud::BeginPlay can't load class: %s"), *ControllerClass.GetAssetName()); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	Super::BeginPlay(); | ||||
| } | ||||
|  | ||||
| void APW_UIFrameworkHud::EndPlay(const EEndPlayReason::Type EndPlayReason) | ||||
| { | ||||
| 	UIManager->DetachUIDisplay(); | ||||
|  | ||||
| 	for (const TPair Pair: UIControllers) | ||||
| 	{ | ||||
| 		if (UPW_UIController* Controller = Pair.Value) | ||||
| 		{ | ||||
| 			Controller->DestroyUIController(); | ||||
| 		} | ||||
| 	} | ||||
| 	UIControllers.Empty(); | ||||
| 	Super::EndPlay(EndPlayReason); | ||||
| } | ||||
|  | ||||
| UPW_UIController* APW_UIFrameworkHud::GetUIController(const FName& Name) | ||||
| { | ||||
| 	if (UPW_UIController** ControllerPtr =  UIControllers.Find(Name)) | ||||
| 	{ | ||||
| 		return *ControllerPtr; | ||||
| 	} | ||||
| 	return nullptr; | ||||
| } | ||||
|  | ||||
| void APW_UIFrameworkHud::TryNotifyResourceLoaded() | ||||
| { | ||||
| 	if (UIControllers.Num() == UIControllerClasses.Num()) | ||||
| 	{ | ||||
| 		OnResourceLoaded(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void APW_UIFrameworkHud::OnResourceLoaded_Implementation() | ||||
| { | ||||
| } | ||||
|  | ||||
							
								
								
									
										60
									
								
								Source/BusyRabbit/Private/UIFramework/UIManager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								Source/BusyRabbit/Private/UIFramework/UIManager.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,60 @@ | ||||
| #include "UIFramework/UIManager.h" | ||||
|  | ||||
| #include "Blueprint/UserWidget.h" | ||||
| #include "UIFramework/RootWidget.h" | ||||
| #include "UIFramework/UIFrameworkHud.h" | ||||
|  | ||||
|  | ||||
| bool UPW_UIManager::AttachUIDisplay(UPW_RootWidget* InRootWidget) | ||||
| { | ||||
| 	if (InRootWidget) | ||||
| 	{ | ||||
| 		RootWidget = InRootWidget; | ||||
| 		InRootWidget->AddToViewport(); | ||||
| 		return true; | ||||
| 	} | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| void UPW_UIManager::DetachUIDisplay()const | ||||
| { | ||||
| 	if (RootWidget.Get() != nullptr) | ||||
| 	{ | ||||
| 		RootWidget->RemoveFromParent(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void UPW_UIManager::SetRootWidget(UPW_RootWidget* NewRootWidget) | ||||
| { | ||||
| 	RootWidget = NewRootWidget; | ||||
| } | ||||
|  | ||||
| UPW_UIManager* UPW_UIManager::Get(UWorld* World) | ||||
| { | ||||
| 	if (World == nullptr) return nullptr; | ||||
| 	const APlayerController* PC = World->GetFirstPlayerController(); | ||||
| 	if (PC == nullptr) return nullptr; | ||||
|  | ||||
| 	if (const APW_UIFrameworkHud * Hud = Cast<APW_UIFrameworkHud>(PC->GetHUD())) | ||||
| 	{ | ||||
| 		return Hud->GetUIManager(); | ||||
| 	} | ||||
| 	return nullptr; | ||||
| } | ||||
|  | ||||
| bool UPW_UIManager::PushWidgetPanel(UPW_WidgetPanel* Panel) | ||||
| { | ||||
| 	if (RootWidget.Get() == nullptr) return false; | ||||
|  | ||||
| 	if (WidgetPanelStack.Contains(Panel)) | ||||
| 	{ | ||||
| 		WidgetPanelStack.Remove(Panel); | ||||
| 	} | ||||
| 	WidgetPanelStack.Push(Panel); | ||||
| 	RootWidget->PushWidget(Panel); | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| void UPW_UIManager::PopWidgetPanel(UPW_WidgetPanel* Panel) | ||||
| { | ||||
| } | ||||
							
								
								
									
										1
									
								
								Source/BusyRabbit/Private/UIFramework/WidgetPanel.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Source/BusyRabbit/Private/UIFramework/WidgetPanel.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| #include "UIFramework/WidgetPanel.h" | ||||
| @ -5,6 +5,7 @@ | ||||
|  | ||||
| class UGameplayEffect; | ||||
| struct FGameplayEffectSpec; | ||||
| class UBusyPawnAttributeSet; | ||||
| class UBusyAbilityDataAssetBase; | ||||
|  | ||||
| UCLASS() | ||||
| @ -20,4 +21,8 @@ public: | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	static FGameplayEffectSpecHandle MakeGameplayEffectSpecHandle(const UAbilitySystemComponent* Asc, const UGameplayEffect* Effect, const float Level); | ||||
|  | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	static FGameplayAttribute GetAttribute(const UBusyPawnAttributeSet* AttributeSet, const FName& AttributeName); | ||||
| }; | ||||
|  | ||||
| @ -0,0 +1,15 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "UIFunctionLibrary.generated.h" | ||||
|  | ||||
| class UPW_UIController; | ||||
|  | ||||
| UCLASS(BlueprintType) | ||||
| class UUIFunctionLibrary : public UBlueprintFunctionLibrary | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| 	UFUNCTION(BlueprintCallable, Category = "UIFunctionLibrary") | ||||
| 	static UPW_UIController* GetUIController(const UObject* Object, const FName& Name); | ||||
| 	  | ||||
| }; | ||||
| @ -70,7 +70,7 @@ public: | ||||
|  *  | ||||
|  */ | ||||
| UCLASS() | ||||
| class BUSYRABBIT_API UPW_UserWidget : public UPW_SimpleWidget{ | ||||
| class BUSYRABBIT_API UPW_UserWidget : public UUserWidget{ | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| // 	UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName="是否全局唯一") | ||||
|  | ||||
| @ -12,7 +12,7 @@ class UBusyPawnMovementComponent; | ||||
| DECLARE_DYNAMIC_DELEGATE_TwoParams(FGameplayTagAddOrRemoveDelegate, const FGameplayTag&, Tag, const int32, Value); | ||||
|  | ||||
|  | ||||
| #define MY_ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \ | ||||
| #define BUSY_ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \ | ||||
| GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \ | ||||
| GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \ | ||||
| GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \ | ||||
| @ -27,28 +27,29 @@ class UBusyPawnAttributeSet : public UAttributeSet | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
|  | ||||
| public: | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") | ||||
| 	FGameplayAttributeData Health; | ||||
| 	MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Health); | ||||
| 	BUSY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Health); | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") | ||||
| 	FGameplayAttributeData MaxHealth; | ||||
| 	MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, MaxHealth); | ||||
| 	BUSY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, MaxHealth); | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") | ||||
| 	FGameplayAttributeData MoveSpeed; | ||||
| 	MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, MoveSpeed); | ||||
| 	BUSY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, MoveSpeed); | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") | ||||
| 	FGameplayAttributeData Damage; | ||||
| 	MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Damage); | ||||
| 	BUSY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Damage); | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") | ||||
| 	FGameplayAttributeData Defense; | ||||
| 	MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Defense); | ||||
| 	BUSY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Defense); | ||||
| }; | ||||
|  | ||||
| #undef MY_ATTRIBUTE_ACCESSORS | ||||
| #undef BUSY_ATTRIBUTE_ACCESSORS | ||||
|  | ||||
|  | ||||
| UCLASS() | ||||
| @ -103,7 +104,7 @@ public: | ||||
| 	FName PawnName; | ||||
|  | ||||
|  | ||||
| protected: | ||||
| public: | ||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) | ||||
| 	TObjectPtr<UBusyPawnAttributeSet> Attributes = nullptr; | ||||
|  | ||||
|  | ||||
| @ -2,9 +2,13 @@ | ||||
| #include "AbilitySystemComponent.h" | ||||
| #include "BusyAbilitySystemComponent.generated.h" | ||||
|  | ||||
| DECLARE_DYNAMIC_DELEGATE_ThreeParams(FOnBusyAttributeChange, const FName&, AttributeName, float, NewValue, float, OldValue); | ||||
|  | ||||
| UCLASS() | ||||
| class UBusyAbilitySystemComponent : public UAbilitySystemComponent | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	void BindEventToAttributeChange(const UClass* AttributeSetClass, const FName& AttributeName, FOnBusyAttributeChange Delegate); | ||||
| }; | ||||
|  | ||||
							
								
								
									
										17
									
								
								Source/BusyRabbit/Public/UIFramework/MinimalWidget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Source/BusyRabbit/Public/UIFramework/MinimalWidget.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "Blueprint/UserWidget.h" | ||||
| #include "MinimalWidget.generated.h" | ||||
|  | ||||
|  | ||||
| UCLASS(Blueprintable, BlueprintType) | ||||
| class UPW_MinimalWidget : public UUserWidget | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| 	UFUNCTION(BlueprintCallable, Category = "Widget") | ||||
| 	UWidget* GetWidget(const FName& Name)const; | ||||
|  | ||||
| }; | ||||
|  | ||||
|  | ||||
							
								
								
									
										24
									
								
								Source/BusyRabbit/Public/UIFramework/RootWidget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								Source/BusyRabbit/Public/UIFramework/RootWidget.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "Blueprint/UserWidget.h" | ||||
| #include "RootWidget.generated.h" | ||||
|  | ||||
| class UOverlay; | ||||
| class UPW_WidgetPanel; | ||||
|  | ||||
| UCLASS() | ||||
| class UPW_RootWidget : public UUserWidget | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| public: | ||||
| 	bool PushWidget(UPW_WidgetPanel* Widget)const; | ||||
| 	bool RemoveWidget(UPW_WidgetPanel* Widget)const; | ||||
|  | ||||
| protected: | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Widget", meta=(BindWidget)) | ||||
| 	TObjectPtr<UOverlay> MainOverlay; | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										30
									
								
								Source/BusyRabbit/Public/UIFramework/UIController.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Source/BusyRabbit/Public/UIFramework/UIController.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "UIController.generated.h" | ||||
|  | ||||
| class APW_UIFrameworkHud; | ||||
|  | ||||
| UCLASS(Blueprintable, BlueprintType) | ||||
| class UPW_UIController : public UObject | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| 	 | ||||
| 	void InitUIController(APW_UIFrameworkHud* UIHud); | ||||
|  | ||||
| 	void DestroyUIController(); | ||||
|  | ||||
| protected: | ||||
| 	UFUNCTION(BlueprintNativeEvent) | ||||
| 	void OnUIControllerInitialized(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintNativeEvent) | ||||
| 	void OnUIControllerDestroy(); | ||||
| 	 | ||||
| protected: | ||||
| 	UPROPERTY() | ||||
| 	TObjectPtr<APW_UIFrameworkHud> Hud; | ||||
|  | ||||
| 	UPROPERTY() | ||||
| 	TObjectPtr<APlayerController> PC; | ||||
| }; | ||||
							
								
								
									
										55
									
								
								Source/BusyRabbit/Public/UIFramework/UIFrameworkHud.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								Source/BusyRabbit/Public/UIFramework/UIFrameworkHud.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,55 @@ | ||||
| #pragma once | ||||
| #include "GameFramework/HUD.h" | ||||
| #include "UIFramework/UIManager.h" | ||||
| #include "UIFrameworkHud.generated.h" | ||||
|  | ||||
|  | ||||
| DECLARE_LOG_CATEGORY_EXTERN(LogUIHud, Log, All); | ||||
|  | ||||
|  | ||||
| class UPW_UIController; | ||||
|  | ||||
|  | ||||
|  | ||||
| UCLASS(Blueprintable, BlueprintType) | ||||
| class APW_UIFrameworkHud : public AHUD | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| 	APW_UIFrameworkHud(); | ||||
| 	virtual void BeginPlay() override; | ||||
| 	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; | ||||
|  | ||||
| public: | ||||
| 	UPW_UIController* GetUIController(const FName& Name); | ||||
| 	 | ||||
|  | ||||
| public: | ||||
| 	UPW_UIManager* GetUIManager()const {return UIManager.Get();} | ||||
|  | ||||
|  | ||||
| protected: | ||||
| 	void TryNotifyResourceLoaded(); | ||||
|  | ||||
|  | ||||
| protected: | ||||
| 	UFUNCTION(BlueprintNativeEvent) | ||||
| 	void OnResourceLoaded(); | ||||
|  | ||||
| protected: | ||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) | ||||
| 	TSubclassOf<UPW_RootWidget> RootWidgetClass; | ||||
|  | ||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) | ||||
| 	TMap<FName, TSoftClassPtr<UPW_UIController>> UIControllerClasses; | ||||
|  | ||||
| protected: | ||||
| 	UPROPERTY() | ||||
| 	TObjectPtr<UPW_UIManager> UIManager; | ||||
|  | ||||
| 	UPROPERTY() | ||||
| 	TMap<FName, UPW_UIController*> UIControllers; | ||||
| }; | ||||
| 	 | ||||
|  | ||||
|  | ||||
							
								
								
									
										34
									
								
								Source/BusyRabbit/Public/UIFramework/UIManager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Source/BusyRabbit/Public/UIFramework/UIManager.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "UIManager.generated.h" | ||||
|  | ||||
| class UPW_RootWidget; | ||||
| class UPW_WidgetPanel; | ||||
|  | ||||
|  | ||||
| UCLASS(BlueprintType) | ||||
| class UPW_UIManager : public UObject | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| 	bool AttachUIDisplay(UPW_RootWidget* InRootWidget); | ||||
| 	void DetachUIDisplay()const; | ||||
| 	void SetRootWidget(UPW_RootWidget* NewRootWidget); | ||||
|  | ||||
| public: | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	static UPW_UIManager* Get(UWorld* World); | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	bool PushWidgetPanel(UPW_WidgetPanel* Panel); | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	void PopWidgetPanel(UPW_WidgetPanel* Panel); | ||||
|  | ||||
| protected: | ||||
| 	UPROPERTY() | ||||
| 	TArray<UPW_WidgetPanel*> WidgetPanelStack; | ||||
|  | ||||
| 	UPROPERTY() | ||||
| 	TObjectPtr<UPW_RootWidget> RootWidget; | ||||
| }; | ||||
							
								
								
									
										13
									
								
								Source/BusyRabbit/Public/UIFramework/WidgetPanel.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Source/BusyRabbit/Public/UIFramework/WidgetPanel.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | ||||
| #pragma once | ||||
| #include "UIFramework/MinimalWidget.h" | ||||
| #include "WidgetPanel.generated.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| UCLASS(BlueprintType, Blueprintable) | ||||
| class UPW_WidgetPanel : public UPW_MinimalWidget | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
|  | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user