2025-04-03 10:13:55 +08:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
2025-04-07 10:28:47 +08:00
|
|
|
#include "UI/GameUserWidget.h"
|
|
|
|
#include "Core/LuckyRobotsGameInstance.h"
|
2025-04-14 19:36:02 +08:00
|
|
|
#include "UI/Settings/CaptureSettingsUserWidget.h"
|
|
|
|
#include "UI/Settings/SelectGoalUserWidget.h"
|
|
|
|
#include "Kismet/GameplayStatics.h"
|
|
|
|
#include "Gameplay/NaviSplineCreator.h"
|
2025-04-03 10:13:55 +08:00
|
|
|
|
|
|
|
void UGameUserWidget::NativeConstruct()
|
|
|
|
{
|
|
|
|
Super::NativeConstruct();
|
2025-04-10 10:50:58 +08:00
|
|
|
|
|
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
|
|
if (GameInstance)
|
2025-04-03 10:13:55 +08:00
|
|
|
{
|
2025-04-07 11:32:45 +08:00
|
|
|
GameInstance->GameUserWidget = this;
|
2025-04-03 10:13:55 +08:00
|
|
|
}
|
2025-04-07 11:32:45 +08:00
|
|
|
}
|
2025-04-10 13:30:13 +08:00
|
|
|
|
|
|
|
void UGameUserWidget::DoWaitSecond()
|
|
|
|
{
|
|
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
|
|
if (GameInstance)
|
|
|
|
{
|
|
|
|
if (GameInstance->bIsFirstOpenGame)
|
|
|
|
{
|
|
|
|
DownCount = 3;
|
|
|
|
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
|
|
|
|
GetWorld()->GetTimerManager().SetTimer(UpdateDownCountTimerHandle, this, &UGameUserWidget::UpdateDownCount, 1.0f, true);
|
|
|
|
|
|
|
|
UpdateDownCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UGameUserWidget::UpdateDownCount()
|
|
|
|
{
|
|
|
|
if (DownCount > 0)
|
|
|
|
{
|
|
|
|
DownCountStr = FString::FromInt(DownCount);
|
|
|
|
DownCount--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DownCountStr = "";
|
|
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
|
|
if (GameInstance)
|
|
|
|
{
|
|
|
|
GameInstance->DoQualitySettings(0, true);
|
|
|
|
}
|
|
|
|
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
|
|
|
|
}
|
2025-04-14 19:36:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2025-04-10 13:30:13 +08:00
|
|
|
}
|