optimization some umg

This commit is contained in:
martinluckyrobots
2025-04-14 19:36:02 +08:00
parent 6a50b86363
commit 144b3e3bce
27 changed files with 414 additions and 10 deletions

View File

@ -3,6 +3,10 @@
#include "UI/GameUserWidget.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "UI/Settings/CaptureSettingsUserWidget.h"
#include "UI/Settings/SelectGoalUserWidget.h"
#include "Kismet/GameplayStatics.h"
#include "Gameplay/NaviSplineCreator.h"
void UGameUserWidget::NativeConstruct()
{
@ -48,4 +52,105 @@ void UGameUserWidget::UpdateDownCount()
}
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
}
}
void UGameUserWidget::ToggleHide()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->bIsDebug = !GameInstance->bIsDebug;
}
}
void UGameUserWidget::ToggleTestMode()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->bIsWidgetTestMode = !GameInstance->bIsWidgetTestMode;
}
}
void UGameUserWidget::DoCapture()
{
if (GetCaptureSettingsUserWidget())
{
GetCaptureSettingsUserWidget()->ToggleMenu();
}
}
void UGameUserWidget::DoAutoConfirm()
{
USelectGoalUserWidget* SelectGoalUserWidget = GetSelectGoalUserWidget();
if (SelectGoalUserWidget)
{
SelectGoalUserWidget->DoAutoConfirm();
}
}
void UGameUserWidget::DoReset()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
if (GameInstance->bIsCapture)
{
if (GetCaptureSettingsUserWidget())
{
GetCaptureSettingsUserWidget()->BPChangeCaptureState();
}
}
}
OnReset.Broadcast();
}
void UGameUserWidget::DoExit()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
if (GameInstance->bIsCapture)
{
if (GetCaptureSettingsUserWidget())
{
GetCaptureSettingsUserWidget()->BPChangeCaptureState();
}
}
if (GameInstance->LobbyLevelObject)
{
UGameplayStatics::OpenLevelBySoftObjectPtr(this, GameInstance->LobbyLevelObject);
}
}
}
void UGameUserWidget::SwitchGamePaused()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->SwitchGamePaused();
}
}
void UGameUserWidget::ToggleShowPath()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->bIsShowPath = !GameInstance->bIsShowPath;
}
TArray<AActor*> AllNaviSplineCreator;
UGameplayStatics::GetAllActorsOfClass(this, ANaviSplineCreator::StaticClass(), AllNaviSplineCreator);
for (auto NaviSplineCreatorActor : AllNaviSplineCreator)
{
ANaviSplineCreator* NaviSplineCreator = Cast<ANaviSplineCreator>(NaviSplineCreatorActor);
if (NaviSplineCreator)
{
NaviSplineCreator->UpdateSplineVisibility();
}
}
}