Add Basic Pause functionality
This commit is contained in:
parent
149de8788f
commit
da1fcc15bd
Binary file not shown.
|
@ -3,21 +3,58 @@
|
|||
|
||||
#include "PauseUIWidget.h"
|
||||
|
||||
#include "Blueprint/WidgetBlueprintLibrary.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
|
||||
void UPauseUIWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
if (ResumeButton)
|
||||
{
|
||||
ResumeButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ResumeButtonOnClicked);
|
||||
}
|
||||
|
||||
if (OptionsButton)
|
||||
{
|
||||
OptionsButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::OptionsButtonOnClicked);
|
||||
}
|
||||
|
||||
if (SaveButton)
|
||||
{
|
||||
SaveButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::SaveButtonOnClicked);
|
||||
}
|
||||
|
||||
if (QuitButton)
|
||||
{
|
||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::QuitButtonOnClicked);
|
||||
CloseApplicationButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::CloseApplicationButtonOnClicked);
|
||||
}
|
||||
|
||||
if (ExitGameButton)
|
||||
{
|
||||
ExitGameButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ExitGameButtonOnClicked);
|
||||
}
|
||||
|
||||
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
|
||||
{
|
||||
UWidgetBlueprintLibrary::SetInputMode_UIOnlyEx(PlayerController, this, EMouseLockMode::LockAlways);
|
||||
PlayerController->bShowMouseCursor = true;
|
||||
}
|
||||
|
||||
SetIsFocusable(true);
|
||||
}
|
||||
|
||||
void UPauseUIWidget::ResumeButtonOnClicked()
|
||||
{
|
||||
// TODO: Implement Functionality
|
||||
this->RemoveFromParent();
|
||||
|
||||
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
|
||||
{
|
||||
UWidgetBlueprintLibrary::SetInputMode_GameOnly(PlayerController);
|
||||
PlayerController->bShowMouseCursor = false;
|
||||
PlayerController->SetPause(false);
|
||||
}
|
||||
}
|
||||
|
||||
void UPauseUIWidget::OptionsButtonOnClicked()
|
||||
|
@ -35,7 +72,12 @@ void UPauseUIWidget::QuitButtonOnClicked()
|
|||
// TODO: Implement Functionality
|
||||
}
|
||||
|
||||
void UPauseUIWidget::CloseApplicationButtonOnClicked()
|
||||
void UPauseUIWidget::ExitGameButtonOnClicked()
|
||||
{
|
||||
// TODO: Implement Functionality
|
||||
// TODO: We probably want to do an autosave here.
|
||||
|
||||
// TODO: Add platform specific Exit requests
|
||||
// This is not a bit deal for the moment as we are only building for windows
|
||||
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
||||
FWindowsPlatformMisc::RequestExit(false);
|
||||
}
|
||||
|
|
|
@ -33,19 +33,24 @@ public:
|
|||
UButton* QuitButton;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UButton* CloseApplicationButton;
|
||||
UButton* ExitGameButton;
|
||||
|
||||
public:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
private:
|
||||
UFUNCTION()
|
||||
void ResumeButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void OptionsButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void SaveButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void QuitButtonOnClicked();
|
||||
|
||||
void CloseApplicationButtonOnClicked();
|
||||
UFUNCTION()
|
||||
void ExitGameButtonOnClicked();
|
||||
};
|
||||
|
|
|
@ -494,9 +494,15 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
|
|||
|
||||
void APlayerCharacter::PauseCallback(const FInputActionInstance& Instance)
|
||||
{
|
||||
APlayerController* PlayerController = Cast<APlayerController>(GetController());
|
||||
|
||||
if (PlayerController->SetPause(true))
|
||||
{
|
||||
if (PauseMenuWidget)
|
||||
{
|
||||
// TODO: Add pause functionality
|
||||
currentPauseMenuWidget->AddToViewport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue