Files
BusyRabbit/Source/BusyRabbit/Private/UIFramework/UIManager.cpp
2025-10-28 23:51:17 +08:00

61 lines
1.2 KiB
C++

#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)
{
}