Add Quit Button functionality

This commit is contained in:
baz 2024-05-02 01:13:34 +01:00
parent 66367ca165
commit e50d8701fd
3 changed files with 18 additions and 3 deletions

BIN
Content/UI/Pause/PauseMenu.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -110,7 +110,19 @@ void UPauseUIWidget::SaveButtonOnClicked()
void UPauseUIWidget::QuitButtonOnClicked()
{
// TODO: Implement Functionality
// TODO: Replace this is a menu to confirm the user wants to start a new game
if (!MainMenuLevel.IsNull())
{
UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), MainMenuLevel);
}
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
{
UWidgetBlueprintLibrary::SetInputMode_UIOnlyEx(PlayerController, this, EMouseLockMode::LockAlways);
PlayerController->bShowMouseCursor = true;
}
SetIsFocusable(true);
}
void UPauseUIWidget::ExitGameButtonOnClicked()

View File

@ -51,6 +51,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> OptionsMenuWidget;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSoftObjectPtr<UWorld> MainMenuLevel;
private:
UOptionsUIWidget* currentOptionsMenuWidget;