(Feat) Add MainMenu
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "PauseMenuWidget.h"
|
||||
|
||||
#include "Components/Button.h"
|
||||
#include "FpsPlayerController.h"
|
||||
|
||||
void UPauseMenuWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
if (ResumeButton)
|
||||
{
|
||||
ResumeButton->OnClicked.AddDynamic(this, &UPauseMenuWidget::HandleResumeClicked);
|
||||
}
|
||||
|
||||
if (QuitToMenuButton)
|
||||
{
|
||||
QuitToMenuButton->OnClicked.AddDynamic(this, &UPauseMenuWidget::HandleQuitToMenuClicked);
|
||||
}
|
||||
|
||||
if (SettingsButton)
|
||||
{
|
||||
SettingsButton->OnClicked.AddDynamic(this, &UPauseMenuWidget::HandleSettingsClicked);
|
||||
}
|
||||
}
|
||||
|
||||
void UPauseMenuWidget::NativeDestruct()
|
||||
{
|
||||
if (ResumeButton)
|
||||
{
|
||||
ResumeButton->OnClicked.RemoveDynamic(this, &UPauseMenuWidget::HandleResumeClicked);
|
||||
}
|
||||
|
||||
if (SettingsButton)
|
||||
{
|
||||
SettingsButton->OnClicked.RemoveDynamic(this, &UPauseMenuWidget::HandleSettingsClicked);
|
||||
}
|
||||
|
||||
if (QuitToMenuButton)
|
||||
{
|
||||
QuitToMenuButton->OnClicked.RemoveDynamic(this, &UPauseMenuWidget::HandleQuitToMenuClicked);
|
||||
}
|
||||
|
||||
Super::NativeDestruct();
|
||||
}
|
||||
|
||||
void UPauseMenuWidget::HandleSettingsClicked()
|
||||
{
|
||||
if (AFpsPlayerController* Controller = GetOwningPlayer<AFpsPlayerController>())
|
||||
{
|
||||
Controller->OpenSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void UPauseMenuWidget::HandleResumeClicked()
|
||||
{
|
||||
if (AFpsPlayerController* Controller = GetOwningPlayer<AFpsPlayerController>())
|
||||
{
|
||||
Controller->ResumeGame();
|
||||
}
|
||||
}
|
||||
|
||||
void UPauseMenuWidget::HandleQuitToMenuClicked()
|
||||
{
|
||||
if (AFpsPlayerController* Controller = GetOwningPlayer<AFpsPlayerController>())
|
||||
{
|
||||
Controller->RequestQuitToMainMenu();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user