开始接入厨房

This commit is contained in:
2025-07-13 15:47:08 +08:00
parent d2e517b341
commit 608486444e
25 changed files with 92 additions and 17 deletions

Binary file not shown.

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -1,7 +1,7 @@
local HomeLandHud = {}
function HomeLandHud:ReceiveBeginPlay()
self:PushWidget("HomeLandMain")
self:ShowWidget("HomeLandMain")
end
return Class(nil, nil, HomeLandHud)

View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<UPW_UILayer> LayerClass;
UPROPERTY(EditAnywhere, Category = "UI Class Mapping")
UPROPERTY(EditAnywhere, Category = "UI配置")
TMap<FName, TSubclassOf<UPW_UserWidget>> UIClassMapping;
protected:

View File

@ -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);