Add variables and functions to MainMenuUIWidget

This commit is contained in:
baz 2023-11-09 22:14:15 +00:00
parent 83178d863b
commit f87ec61ddb
2 changed files with 96 additions and 1 deletions

View File

@ -3,3 +3,52 @@
#include "MainMenuUIWidget.h"
void UMainMenuUIWidget::NativeConstruct()
{
Super::NativeConstruct();
if (NewGameButton)
{
NewGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::NewGameButtonOnClicked);
}
if (LoadGameButton)
{
LoadGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::LoadGameButtonOnClicked);
}
if (OptionsButton)
{
OptionsButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::OptionsButtonOnClicked);
}
if (QuitButton)
{
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::QuitButtonOnClicked);
}
}
void UMainMenuUIWidget::NewGameButtonOnClicked()
{
// TODO: Implement Functionality
}
void UMainMenuUIWidget::LoadGameButtonOnClicked()
{
// TODO: Implement Functionality
}
void UMainMenuUIWidget::OptionsButtonOnClicked()
{
// TODO: Implement Functionality
}
void UMainMenuUIWidget::QuitButtonOnClicked()
{
// 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);
}

View File

@ -3,7 +3,9 @@
#pragma once
#include "CoreMinimal.h"
#include "OptionsUIWidget.h"
#include "Blueprint/UserWidget.h"
#include "Components/Button.h"
#include "MainMenuUIWidget.generated.h"
/**
@ -13,5 +15,49 @@ UCLASS()
class NAKATOMI_API UMainMenuUIWidget : public UUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* NewGameButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* LoadGameButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* OptionsButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* QuitButton;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> NewGameMenuWidget;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> LoadGameMenuWidget;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> OptionsMenuWidget;
private:
UUserWidget* currentNewGameWidget;
UUserWidget* currentLoadGameWidget;
UOptionsUIWidget* currentOptionsMenuWidget;
public:
virtual void NativeConstruct() override;
private:
UFUNCTION()
void NewGameButtonOnClicked();
UFUNCTION()
void LoadGameButtonOnClicked();
UFUNCTION()
void OptionsButtonOnClicked();
UFUNCTION()
void QuitButtonOnClicked();
};