// Fill out your copyright notice in the Description page of Project Settings. #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() { Super::NativeConstruct(); ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); if (GameInstance) { GameInstance->GameUserWidget = this; } } void UGameUserWidget::DoWaitSecond() { ULuckyRobotsGameInstance* GameInstance = Cast(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(GetGameInstance()); if (GameInstance) { GameInstance->DoQualitySettings(0, true); } GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle); } } void UGameUserWidget::ToggleHide() { ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); if (GameInstance) { GameInstance->bIsDebug = !GameInstance->bIsDebug; } } void UGameUserWidget::ToggleTestMode() { ULuckyRobotsGameInstance* GameInstance = Cast(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(GetGameInstance()); if (GameInstance) { if (GameInstance->bIsCapture) { if (GetCaptureSettingsUserWidget()) { GetCaptureSettingsUserWidget()->BPChangeCaptureState(); } } } OnReset.Broadcast(); } void UGameUserWidget::DoExit() { ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); if (GameInstance) { if (GameInstance->bIsCapture) { if (GetCaptureSettingsUserWidget()) { GetCaptureSettingsUserWidget()->BPChangeCaptureState(); } } if (GameInstance->LobbyLevelObject) { UGameplayStatics::OpenLevelBySoftObjectPtr(this, GameInstance->LobbyLevelObject); } } } void UGameUserWidget::SwitchGamePaused() { ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); if (GameInstance) { GameInstance->SwitchGamePaused(); } } void UGameUserWidget::ToggleShowPath() { ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); if (GameInstance) { GameInstance->bIsShowPath = !GameInstance->bIsShowPath; } TArray AllNaviSplineCreator; UGameplayStatics::GetAllActorsOfClass(this, ANaviSplineCreator::StaticClass(), AllNaviSplineCreator); for (auto NaviSplineCreatorActor : AllNaviSplineCreator) { ANaviSplineCreator* NaviSplineCreator = Cast(NaviSplineCreatorActor); if (NaviSplineCreator) { NaviSplineCreator->UpdateSplineVisibility(); } } }