大厅接入
This commit is contained in:
		| @ -2,6 +2,7 @@ | ||||
|  | ||||
|  | ||||
| #include "BusyLevelLogicSubSystem.h" | ||||
| #include "Kismet/GameplayStatics.h" | ||||
|  | ||||
| UBusyLevelLogicSubSystem::UBusyLevelLogicSubSystem(){ | ||||
| 	 | ||||
| @ -12,6 +13,14 @@ void UBusyLevelLogicSubSystem::Initialize(FSubsystemCollectionBase& Collection){ | ||||
| 	ReceiveSubSystemInitialize(); | ||||
| } | ||||
|  | ||||
| bool UBusyLevelLogicSubSystem::ShouldCreateSubsystem(UObject* Outer) const{ | ||||
| 	if (!Super::ShouldCreateSubsystem(Outer)) { | ||||
| 		return false; | ||||
| 	} | ||||
| 	auto s = UGameplayStatics::GetCurrentLevelName(Outer); | ||||
| 	return UGameplayStatics::GetCurrentLevelName(Outer) != "HomeLand"; | ||||
| } | ||||
|  | ||||
| void UBusyLevelLogicSubSystem::Tick(float DeltaTime){ | ||||
| 	Super::Tick(DeltaTime); | ||||
| 	ReceiveSubSystemTick(DeltaTime); | ||||
|  | ||||
							
								
								
									
										37
									
								
								Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| #include "Core/UI/PW_UIHud.h" | ||||
| #include "Core/PW_UserWidget.h" | ||||
| #include "Core/UI/PW_UILayer.h" | ||||
|  | ||||
| FString APW_UIHud::GetLuaFilePath_Implementation() const { | ||||
| 	return LuaFilePath; | ||||
| } | ||||
|  | ||||
| void APW_UIHud::BeginPlay() { | ||||
| 	ensureMsgf(LayerClass, TEXT("LayerClass not be nullptr")); | ||||
| 	if ((UILayer = CreateWidget<UPW_UILayer>(GetWorld(), LayerClass))) { | ||||
| 		UILayer->AddToViewport(); | ||||
| 	} | ||||
| 	Super::BeginPlay(); | ||||
| } | ||||
|  | ||||
| UPW_UserWidget* APW_UIHud::PushWidget(const FName& WidgetName) { | ||||
| 	if (UILayer == nullptr) { | ||||
| 		return nullptr; | ||||
| 	} | ||||
| 	TSubclassOf<UPW_UserWidget>* WidgetClass = UIClassMapping.Find(WidgetName); | ||||
| 	if (WidgetClass == nullptr) { | ||||
| 		return nullptr; | ||||
| 	} | ||||
| 	UPW_UserWidget* Inst = CreateWidget<UPW_UserWidget>(GetWorld(), WidgetClass->Get()); | ||||
| 	if (Inst == nullptr) { | ||||
| 		return nullptr; | ||||
| 	} | ||||
|  | ||||
| 	if (UILayer->PushWidget(WidgetName, Inst)) { | ||||
| 		return Inst; | ||||
| 	} | ||||
| 	else { | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
|  | ||||
							
								
								
									
										53
									
								
								Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | ||||
| // Fill out your copyright notice in the Description page of Project Settings. | ||||
|  | ||||
|  | ||||
| #include "Core/UI/PW_UILayer.h" | ||||
| #include "Core/PW_UserWidget.h" | ||||
| #include "Components/Overlay.h" | ||||
| #include "Components/OverlaySlot.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| bool UPW_UILayer::ShowWidget(const FName& WidgetName){ | ||||
| 	UPW_UserWidget* Widget = *WidgetPool.Find(WidgetName); | ||||
| 	if (Widget == nullptr) { | ||||
| 		return false; | ||||
| 	} | ||||
| 	Widget->SetVisible(true); | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool UPW_UILayer::HideWidget(const FName& WidgetName){ | ||||
| 	UPW_UserWidget* Widget = *WidgetPool.Find(WidgetName); | ||||
| 	if (Widget == nullptr) { | ||||
| 		return false; | ||||
| 	} | ||||
| 	Widget->SetVisible(false); | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool UPW_UILayer::PushWidget(const FName& WidgetName, UPW_UserWidget* WidgetInst){ | ||||
| 	UOverlay* Overlay; | ||||
| 	UOverlaySlot* OverlaySlot; | ||||
| 	switch (WidgetInst->LayoutType) { | ||||
| 		case EWidgetLayoutType::MainLayer: Overlay = MainLayer; break; | ||||
| 		case EWidgetLayoutType::PopupLayer: Overlay = PopupLayer; break; | ||||
| 		case EWidgetLayoutType::FloatLayer: Overlay = FloatLayer; break; | ||||
| 		case EWidgetLayoutType::TopLayer: Overlay = TopLayer; break; | ||||
| 		default: return false; | ||||
| 	} | ||||
| 	Overlay->AddChild(WidgetInst); | ||||
| 	if ((OverlaySlot = Cast<UOverlaySlot>(WidgetInst->Slot))) { | ||||
| 		OverlaySlot->SetVerticalAlignment(EVerticalAlignment::VAlign_Fill); | ||||
| 		OverlaySlot->SetHorizontalAlignment(EHorizontalAlignment::HAlign_Fill); | ||||
| 		WidgetInst->SetVisible(true); | ||||
| 		WidgetPool.Add(WidgetName, WidgetInst); | ||||
| 		return true; | ||||
| 	} else { | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| bool UPW_UILayer::PopWidget(const FName& WidgetName){ | ||||
| 	return true; | ||||
| } | ||||
| @ -3,12 +3,8 @@ | ||||
|  | ||||
| #include "Hud/BusyGameHud.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| FString ABusyGameHud::GetLuaFilePath_Implementation() const{ | ||||
| 	return LuaFilePath; | ||||
| } | ||||
|  | ||||
| //void ABusyGameHud::PushWidget(const FName& WidgetName){ | ||||
| //	auto WidgetClass = UIClassMapping.Find(WidgetName); | ||||
| //	APlayerController* PC = GetOwningPlayerController(); | ||||
| //	CreateWidget<UUserWidget>(); | ||||
| //} | ||||
| } | ||||
| @ -39,6 +39,18 @@ void ABusyLevelItem::BeginPlay(){ | ||||
| 		PickBar->SetWidgetClass(cls); | ||||
| 	} | ||||
| 	Super::BeginPlay(); | ||||
| 	bIsBeginPlay = true; | ||||
| } | ||||
|  | ||||
| void ABusyLevelItem::EndPlay(const EEndPlayReason::Type EndPlayReason){ | ||||
| 	Super::EndPlay(EndPlayReason); | ||||
| 	bIsBeginPlay = false; | ||||
| } | ||||
|  | ||||
| void ABusyLevelItem::PostLuaHook(){ | ||||
| 	if (bIsBeginPlay) { | ||||
| 		CallLuaFunctionIfExist("TempSetting"); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void ABusyLevelItem::InitCapsule(){ | ||||
|  | ||||
| @ -23,6 +23,9 @@ public: | ||||
| public: | ||||
| 	virtual void Initialize(FSubsystemCollectionBase& Collection) override; | ||||
|  | ||||
| 	virtual bool ShouldCreateSubsystem(UObject* Outer) const override; | ||||
|  | ||||
|  | ||||
| 	virtual void Tick(float DeltaTime) override; | ||||
|  | ||||
| 	virtual FString GetLuaFilePath_Implementation() const override; | ||||
| @ -47,5 +50,4 @@ public:  //  | ||||
| 	UFUNCTION(BlueprintImplementableEvent) | ||||
| 	void ReceiveSubSystemTick(float DeltaTime); | ||||
|  | ||||
|  | ||||
| }; | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								Source/BusyRabbit/Public/BusyRabbit.lnk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Source/BusyRabbit/Public/BusyRabbit.lnk
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										34
									
								
								Source/BusyRabbit/Public/Core/UI/PW_UIHud.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Source/BusyRabbit/Public/Core/UI/PW_UIHud.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| #include "CoreMinimal.h" | ||||
| #include "GameFramework/HUD.h" | ||||
| #include "LuaOverriderInterface.h" | ||||
| #include "PW_UIHud.generated.h" | ||||
|  | ||||
| class UPW_UILayer; | ||||
| class UPW_UserWidget; | ||||
|  | ||||
| UCLASS() | ||||
| class BUSYRABBIT_API APW_UIHud : public AHUD, public ILuaOverriderInterface { | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| 	virtual FString GetLuaFilePath_Implementation() const override; | ||||
|  | ||||
| 	virtual void BeginPlay()override; | ||||
|  | ||||
| public: | ||||
| 	UFUNCTION(BlueprintCallable) | ||||
| 	UPW_UserWidget* PushWidget(const FName& WidgetName); | ||||
|  | ||||
| public: | ||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) | ||||
| 	FString LuaFilePath; | ||||
|  | ||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) | ||||
| 	TSubclassOf<UPW_UILayer> LayerClass; | ||||
|  | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, Category = "UI Class Mapping") | ||||
| 	TMap<FName, TSubclassOf<UPW_UserWidget>> UIClassMapping; | ||||
|  | ||||
| protected: | ||||
| 	TObjectPtr<UPW_UILayer> UILayer; | ||||
| }; | ||||
							
								
								
									
										48
									
								
								Source/BusyRabbit/Public/Core/UI/PW_UILayer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								Source/BusyRabbit/Public/Core/UI/PW_UILayer.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| // Fill out your copyright notice in the Description page of Project Settings. | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| #include "Core/PW_UserWidget.h" | ||||
| #include "PW_UILayer.generated.h" | ||||
|  | ||||
| class UOverlay; | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  */ | ||||
| UCLASS() | ||||
| class BUSYRABBIT_API UPW_UILayer : public UPW_UserWidget | ||||
| { | ||||
|     GENERATED_BODY() | ||||
|  | ||||
| public: | ||||
|     UFUNCTION(BlueprintCallable) | ||||
|     bool ShowWidget(const FName& WidgetName); | ||||
|  | ||||
|     UFUNCTION(BlueprintCallable) | ||||
|     bool HideWidget(const FName& WidgetName); | ||||
|  | ||||
|     UFUNCTION(BlueprintCallable) | ||||
|     bool PushWidget(const FName& WidgetName, UPW_UserWidget* WidgetInst); | ||||
|  | ||||
|     UFUNCTION(BlueprintCallable) | ||||
|     bool PopWidget(const FName& WidgetName); | ||||
|  | ||||
|  | ||||
| protected: | ||||
|     UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) | ||||
|     TObjectPtr<UOverlay> MainLayer; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) | ||||
|     TObjectPtr<UOverlay> PopupLayer; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) | ||||
|     TObjectPtr<UOverlay> FloatLayer; | ||||
|  | ||||
|     UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) | ||||
|     TObjectPtr<UOverlay> TopLayer; | ||||
|  | ||||
| protected: | ||||
|     TMap<FName, UPW_UserWidget*> WidgetPool; | ||||
| }; | ||||
| @ -29,6 +29,7 @@ public: | ||||
| 	virtual void PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue)override; | ||||
|  | ||||
| public: | ||||
| 	UPROPERTY(BlueprintReadWrite) | ||||
| 	FPW_OnAttributeChanged OnAttributeChanged; | ||||
|  | ||||
| protected: | ||||
|  | ||||
| @ -15,11 +15,6 @@ class BUSYRABBIT_API ABusyGameHud : public AHUD, public ILuaOverriderInterface{ | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| 	virtual FString GetLuaFilePath_Implementation() const override; | ||||
|  | ||||
| public: | ||||
| 	//UFUNCTION(BlueprintCallable) | ||||
| 	//void PushWidget(const FName& WidgetName); | ||||
|  | ||||
| public: | ||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) | ||||
| 	FString LuaFilePath; | ||||
|  | ||||
| @ -63,6 +63,10 @@ public: | ||||
|  | ||||
| 	virtual void BeginPlay() override; | ||||
|  | ||||
| 	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason)override; | ||||
|  | ||||
| 	virtual void PostLuaHook() override; | ||||
|  | ||||
| protected: | ||||
| 	void InitCapsule(); | ||||
| 	void InitSprite(); | ||||
| @ -102,6 +106,9 @@ protected: | ||||
| 	UPROPERTY() | ||||
| 	TObjectPtr<UBusyLevelItemAttributeSet> LevelItemAttribute; | ||||
|  | ||||
| protected: | ||||
| 	bool bIsBeginPlay; | ||||
|  | ||||
| public:  // 需要蓝图实现的函数 | ||||
| 	// LevelItem被设置时的回调 | ||||
| 	UFUNCTION(BlueprintImplementableEvent) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user