diff --git a/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset b/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset index e047d3d..782bd11 100644 Binary files a/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset and b/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset differ diff --git a/Content/Level/FalconPlain.umap b/Content/Level/FalconPlain.umap index 3a538b0..27a48ed 100644 Binary files a/Content/Level/FalconPlain.umap and b/Content/Level/FalconPlain.umap differ diff --git a/Content/Lua/HomeLand/UI/Hearth/HearthMain.lua b/Content/Lua/HomeLand/UI/Hearth/HearthMain.lua new file mode 100644 index 0000000..3045612 --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/HearthMain.lua @@ -0,0 +1,11 @@ +local WidgetUtils = require("Utils.UI.WidgetUtils") +local HearthMain = {} + +function HearthMain:OnInitialized() + self.BtnBack.OnClicked:Add(function() + WidgetUtils.Hide(self, "HearthMain") + end) + +end + +return Class(nil, nil, HearthMain) \ No newline at end of file diff --git a/Content/Lua/HomeLand/UI/HomeLandMainUI.lua b/Content/Lua/HomeLand/UI/HomeLandMainUI.lua index c53f604..0924691 100644 --- a/Content/Lua/HomeLand/UI/HomeLandMainUI.lua +++ b/Content/Lua/HomeLand/UI/HomeLandMainUI.lua @@ -1,11 +1,14 @@ local GameplayStatics = import("GameplayStatics") +local WidgetUtils = require("Utils.UI.WidgetUtils") local HomeLandMainUI = {} -function HomeLandMainUI:Construct() +function HomeLandMainUI:OnInitialized() self.Gateway.OnClicked:Add(function() GameplayStatics.OpenLevel(self, "FalconPlain", false, "") end) - + self.Hearth.OnClicked:Add(function() + WidgetUtils.Show(self, "HearthMain") + end) end return Class(nil, nil, HomeLandMainUI) \ No newline at end of file diff --git a/Content/Lua/UI/SettingPanel.lua b/Content/Lua/UI/SettingPanel.lua index 55e117a..da45b04 100644 --- a/Content/Lua/UI/SettingPanel.lua +++ b/Content/Lua/UI/SettingPanel.lua @@ -4,7 +4,7 @@ local GameplayStatics = import("GameplayStatics") function SettingPanel:OnInitialized() self.BtnContinue.OnClicked:Add(function() self:BackToGame() end) - self.BtnExitLevel.OnClicked:Add(function() end) + self.BtnExitLevel.OnClicked:Add(function() self:BackHomeland() end) self.BtnExitGame.OnClicked:Add(function() self:ExitGame() end) self.BtnClose.OnClicked:Add(function() self:BackToGame() end) end @@ -19,6 +19,10 @@ function SettingPanel:BackToGame() UIUtils.CloseWidget(self) end +function SettingPanel:BackHomeland() + GameplayStatics.OpenLevel(self, "HomeLand", false, "") +end + function SettingPanel:ExitGame() local pc = GameplayStatics.GetPlayerController(self, 0) pc:QuitGame() diff --git a/Content/Lua/UI/UIHud/HomeLandHud.lua b/Content/Lua/UI/UIHud/HomeLandHud.lua index 4b48add..dd39872 100644 --- a/Content/Lua/UI/UIHud/HomeLandHud.lua +++ b/Content/Lua/UI/UIHud/HomeLandHud.lua @@ -1,7 +1,7 @@ local HomeLandHud = {} function HomeLandHud:ReceiveBeginPlay() - self:PushWidget("HomeLandMain") + self:ShowWidget("HomeLandMain") end return Class(nil, nil, HomeLandHud) \ No newline at end of file diff --git a/Content/Lua/Utils/UI/WidgetUtils.lua b/Content/Lua/Utils/UI/WidgetUtils.lua new file mode 100644 index 0000000..1a9f3e4 --- /dev/null +++ b/Content/Lua/Utils/UI/WidgetUtils.lua @@ -0,0 +1,23 @@ +local GameplayStatics = import("GameplayStatics") +local WidgetUtils = {} + +local function GetHud(wco) + local pc = GameplayStatics.GetPlayerController(wco, 0) + if pc == nil then return end + return pc:GetHud() +end + +function WidgetUtils.Show(wco, widget_name) + local hud = GetHud(wco) + if not hud then return end + return hud:ShowWidget(widget_name) +end + +function WidgetUtils.Hide(wco, widget_name) + local hud = GetHud(wco) + if not hud then return end + return hud:PopWidget(widget_name) +end + + +return WidgetUtils \ No newline at end of file diff --git a/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Left.uasset b/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Left.uasset index ba93ee4..9e7d5da 100644 Binary files a/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Left.uasset and b/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Left.uasset differ diff --git a/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Right.uasset b/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Right.uasset index edb723f..5b000d1 100644 Binary files a/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Right.uasset and b/Content/Resource/Animation/Character/Idle/Rabbit/Rabbit_Idle_Right.uasset differ diff --git a/Content/Resource/Animation/Character/Move/Rabbit_Move_Left.uasset b/Content/Resource/Animation/Character/Move/Rabbit_Move_Left.uasset index 3092b52..1c24b79 100644 Binary files a/Content/Resource/Animation/Character/Move/Rabbit_Move_Left.uasset and b/Content/Resource/Animation/Character/Move/Rabbit_Move_Left.uasset differ diff --git a/Content/Resource/Animation/Character/Move/Rabbit_Move_Right.uasset b/Content/Resource/Animation/Character/Move/Rabbit_Move_Right.uasset index 490ced4..c03018f 100644 Binary files a/Content/Resource/Animation/Character/Move/Rabbit_Move_Right.uasset and b/Content/Resource/Animation/Character/Move/Rabbit_Move_Right.uasset differ diff --git a/Content/Resource/Animation/Character/Move/RabitMoveLeft.uasset b/Content/Resource/Animation/Character/Move/RabitMoveLeft.uasset index 20d839b..06e4b3c 100644 Binary files a/Content/Resource/Animation/Character/Move/RabitMoveLeft.uasset and b/Content/Resource/Animation/Character/Move/RabitMoveLeft.uasset differ diff --git a/Content/Resource/Animation/Character/Move/RabitMoveRight.uasset b/Content/Resource/Animation/Character/Move/RabitMoveRight.uasset index c6b1018..1e7e3b4 100644 Binary files a/Content/Resource/Animation/Character/Move/RabitMoveRight.uasset and b/Content/Resource/Animation/Character/Move/RabitMoveRight.uasset differ diff --git a/Content/Resource/Map/FalconPlain/Test.uasset b/Content/Resource/Map/FalconPlain/Test.uasset new file mode 100644 index 0000000..4fb0822 Binary files /dev/null and b/Content/Resource/Map/FalconPlain/Test.uasset differ diff --git a/Content/Resource/Map/FalconPlain/lack-tilemap.uasset b/Content/Resource/Map/FalconPlain/lack-tilemap.uasset new file mode 100644 index 0000000..19b0ab0 Binary files /dev/null and b/Content/Resource/Map/FalconPlain/lack-tilemap.uasset differ diff --git a/Content/Resource/Map/FalconPlain/lack-tilemap_TileSet.uasset b/Content/Resource/Map/FalconPlain/lack-tilemap_TileSet.uasset new file mode 100644 index 0000000..5768f0e Binary files /dev/null and b/Content/Resource/Map/FalconPlain/lack-tilemap_TileSet.uasset differ diff --git a/Content/Resource/Texture/Character/Move/Rabit/Rabbit01_Sprite.uasset b/Content/Resource/Texture/Character/Move/Rabit/Rabbit01_Sprite.uasset index 4a6ca46..6aacfb1 100644 Binary files a/Content/Resource/Texture/Character/Move/Rabit/Rabbit01_Sprite.uasset and b/Content/Resource/Texture/Character/Move/Rabit/Rabbit01_Sprite.uasset differ diff --git a/Content/Resource/Texture/Character/Move/Rabit/Rabbit02_Sprite.uasset b/Content/Resource/Texture/Character/Move/Rabit/Rabbit02_Sprite.uasset index 56311b9..db4a51f 100644 Binary files a/Content/Resource/Texture/Character/Move/Rabit/Rabbit02_Sprite.uasset and b/Content/Resource/Texture/Character/Move/Rabit/Rabbit02_Sprite.uasset differ diff --git a/Content/Resource/Texture/Character/Move/Rabit/Rabbit03_Sprite.uasset b/Content/Resource/Texture/Character/Move/Rabit/Rabbit03_Sprite.uasset index d1b3fea..98e67cb 100644 Binary files a/Content/Resource/Texture/Character/Move/Rabit/Rabbit03_Sprite.uasset and b/Content/Resource/Texture/Character/Move/Rabit/Rabbit03_Sprite.uasset differ diff --git a/Content/Resource/Texture/Character/Move/Rabit/Rabbit04_Sprite.uasset b/Content/Resource/Texture/Character/Move/Rabit/Rabbit04_Sprite.uasset index 3257fa3..556275c 100644 Binary files a/Content/Resource/Texture/Character/Move/Rabit/Rabbit04_Sprite.uasset and b/Content/Resource/Texture/Character/Move/Rabit/Rabbit04_Sprite.uasset differ diff --git a/Content/UI/HomeLand/Hearth/WBP_HearthMain.uasset b/Content/UI/HomeLand/Hearth/WBP_HearthMain.uasset new file mode 100644 index 0000000..94a4c84 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/WBP_HearthMain.uasset differ diff --git a/Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp b/Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp index 392ad73..a8fcaab 100644 --- a/Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp +++ b/Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp @@ -35,3 +35,28 @@ UPW_UserWidget* APW_UIHud::PushWidget(const FName& WidgetName) { } } +bool APW_UIHud::PopWidget(const FName& WidgetName){ + if (UILayer == nullptr) { + return false; + } + return UILayer->PopWidget(WidgetName); +} + +UPW_UserWidget* APW_UIHud::ShowWidget(const FName& WidgetName){ + UPW_UserWidget* Widget; + if (!UILayer) { + return nullptr; + } + if ((Widget = UILayer->ShowWidget(WidgetName))) { + return Widget; + } + return PushWidget(WidgetName); +} + +bool APW_UIHud::HideWidget(const FName& WidgetName){ + if (UILayer == nullptr) { + return false; + } + return UILayer->PopWidget(WidgetName); +} + diff --git a/Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp b/Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp index d985df4..e2506fc 100644 --- a/Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp +++ b/Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp @@ -8,13 +8,17 @@ -bool UPW_UILayer::ShowWidget(const FName& WidgetName){ - UPW_UserWidget* Widget = *WidgetPool.Find(WidgetName); +UPW_UserWidget* UPW_UILayer::ShowWidget(const FName& WidgetName){ + UPW_UserWidget **result = WidgetPool.Find(WidgetName); + if (result == nullptr) { + return nullptr; + } + UPW_UserWidget* Widget = *result; if (Widget == nullptr) { - return false; + return nullptr; } Widget->SetVisible(true); - return true; + return Widget; } bool UPW_UILayer::HideWidget(const FName& WidgetName){ @@ -49,5 +53,5 @@ bool UPW_UILayer::PushWidget(const FName& WidgetName, UPW_UserWidget* WidgetInst } bool UPW_UILayer::PopWidget(const FName& WidgetName){ - return true; + return HideWidget(WidgetName); } diff --git a/Source/BusyRabbit/Public/Core/UI/PW_UIHud.h b/Source/BusyRabbit/Public/Core/UI/PW_UIHud.h index ac4eaec..cdaaea6 100644 --- a/Source/BusyRabbit/Public/Core/UI/PW_UIHud.h +++ b/Source/BusyRabbit/Public/Core/UI/PW_UIHud.h @@ -1,3 +1,4 @@ +#pragma once #include "CoreMinimal.h" #include "GameFramework/HUD.h" #include "LuaOverriderInterface.h" @@ -18,15 +19,23 @@ public: UFUNCTION(BlueprintCallable) UPW_UserWidget* PushWidget(const FName& WidgetName); + UFUNCTION(BlueprintCallable) + bool PopWidget(const FName& WidgetName); + + UFUNCTION(BlueprintCallable) + UPW_UserWidget* ShowWidget(const FName& WidgetName); + + UFUNCTION(BlueprintCallable) + bool HideWidget(const FName& WidgetName); + public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) FString LuaFilePath; - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="UI配置") TSubclassOf LayerClass; - - UPROPERTY(EditAnywhere, Category = "UI Class Mapping") + UPROPERTY(EditAnywhere, Category = "UI配置") TMap> UIClassMapping; protected: diff --git a/Source/BusyRabbit/Public/Core/UI/PW_UILayer.h b/Source/BusyRabbit/Public/Core/UI/PW_UILayer.h index 12fd8d4..6efc4d9 100644 --- a/Source/BusyRabbit/Public/Core/UI/PW_UILayer.h +++ b/Source/BusyRabbit/Public/Core/UI/PW_UILayer.h @@ -17,16 +17,12 @@ class BUSYRABBIT_API UPW_UILayer : public UPW_UserWidget GENERATED_BODY() public: - UFUNCTION(BlueprintCallable) - bool ShowWidget(const FName& WidgetName); + UPW_UserWidget* 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);