Skip to content

Commit

Permalink
Adds quit button and its logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalfaro18 committed Aug 27, 2019
1 parent b559380 commit 1e3bd84
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Binary file not shown.
Binary file modified PuzzlePlatforms/Content/MenuSystem/WBP_MainMenu.uasset
Binary file not shown.
13 changes: 13 additions & 0 deletions PuzzlePlatforms/Source/PuzzlePlatforms/MenuSystem/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ bool UMainMenu::Initialize() {
if (!ensure(JoinButton != nullptr)) { return false; }
JoinButton->OnClicked.AddDynamic(this, &UMainMenu::OpenJoinMenu);

if (!ensure(QuitButton != nullptr)) { return false; }
QuitButton->OnClicked.AddDynamic(this, &UMainMenu::QuitPressed);

if (!ensure(CancelJoinMenuButton != nullptr)) { return false; }
CancelJoinMenuButton->OnClicked.AddDynamic(this, &UMainMenu::OpenMainMenu);

Expand Down Expand Up @@ -56,3 +59,13 @@ void UMainMenu::OpenMainMenu() {
if (!ensure(MainMenu != nullptr)) { return; }
MenuSwitcher->SetActiveWidget(MainMenu);
}

void UMainMenu::QuitPressed() {
UWorld* World = GetWorld();
if (!ensure(World != nullptr)) { return; }

APlayerController* PlayerController = World->GetFirstPlayerController();
if (!ensure(PlayerController != nullptr)) { return; }

PlayerController->ConsoleCommand("quit");
}
6 changes: 6 additions & 0 deletions PuzzlePlatforms/Source/PuzzlePlatforms/MenuSystem/MainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class PUZZLEPLATFORMS_API UMainMenu : public UMenuWidget

UPROPERTY(meta = (BindWidget))
class UButton* JoinButton;

UPROPERTY(meta = (BindWidget))
class UButton* QuitButton;

UPROPERTY(meta = (BindWidget))
class UButton* CancelJoinMenuButton;
Expand Down Expand Up @@ -56,5 +59,8 @@ class PUZZLEPLATFORMS_API UMainMenu : public UMenuWidget

UFUNCTION()
void OpenMainMenu();

UFUNCTION()
void QuitPressed();

};

0 comments on commit 1e3bd84

Please sign in to comment.