Compare commits

...

4 Commits

10 changed files with 112 additions and 24 deletions

BIN
Content/UI/LoadGame/BP_LoadGameUserWidget.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -5,6 +5,7 @@
#include "Blueprint/WidgetBlueprintLibrary.h"
#include "Kismet/GameplayStatics.h"
#include "UI/LoadGameUserWidget.h"
void UMainMenuUIWidget::NativeConstruct()
{
@ -84,7 +85,13 @@ void UMainMenuUIWidget::NewGameButtonOnClicked()
void UMainMenuUIWidget::LoadGameButtonOnClicked()
{
// TODO: Implement Functionality
if (LoadGameMenuWidget)
{
currentLoadGameWidget = CreateWidget<ULoadGameUserWidget>(GetWorld(), LoadGameMenuWidget);
currentLoadGameWidget->AddToViewport();
currentLoadGameWidget->SetReturnScreen(this);
this->RemoveFromParent();
}
}
void UMainMenuUIWidget::OptionsButtonOnClicked()

View File

@ -6,6 +6,7 @@
#include "OptionsUIWidget.h"
#include "Blueprint/UserWidget.h"
#include "Components/Button.h"
#include "UI/LoadGameUserWidget.h"
#include "UI/NakatomiInteractiveWidget.h"
#include "MainMenuUIWidget.generated.h"
@ -57,7 +58,7 @@ public:
private:
UUserWidget* currentNewGameWidget;
UUserWidget* currentLoadGameWidget;
ULoadGameUserWidget* currentLoadGameWidget;
UOptionsUIWidget* currentOptionsMenuWidget;

View File

@ -109,21 +109,9 @@ void UOptionsUIWidget::NativeConstruct()
SetIsFocusable(true);
}
void UOptionsUIWidget::SetReturnScreen(UUserWidget* userWidget)
{
if (userWidget)
{
PreviousScreen = userWidget;
}
}
void UOptionsUIWidget::BackButtonOnClicked()
{
// TODO: Implement Functionality
GEngine->GameUserSettings->ApplySettings(false);
this->RemoveFromParent();
PreviousScreen->AddToViewport();
ReturnToPreviousScreen();
}
void UOptionsUIWidget::ResetToDefaultsButtonOnClicked()

View File

@ -52,15 +52,9 @@ public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* ResetToDefaultsTextBlock;
private:
UUserWidget* PreviousScreen;
public:
virtual void NativeConstruct() override;
void SetReturnScreen(UUserWidget* userWidget);
private:
UFUNCTION()

View File

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "../UI/LoadGameUserWidget.h"
void ULoadGameUserWidget::NativeConstruct()
{
Super::NativeConstruct();
if (CancelButton)
{
CancelButton->OnClicked.AddUniqueDynamic(this, &ULoadGameUserWidget::CancelButtonOnClicked);
CancelButton->OnClicked.AddUniqueDynamic(this, &ULoadGameUserWidget::PlayClickedSound);
CancelButton->OnHovered.AddUniqueDynamic(this, &ULoadGameUserWidget::CancelButtonHoveredDelegate);
CancelButton->OnHovered.AddUniqueDynamic(this, &ULoadGameUserWidget::PlayHoveredSound);
CancelButton->OnUnhovered.AddUniqueDynamic(this, &ULoadGameUserWidget::CancelButtonUnhoveredDelegate);
CancelButton->OnUnhovered.AddUniqueDynamic(this, &ULoadGameUserWidget::PlayUnhoveredSound);
}
}
void ULoadGameUserWidget::CancelButtonOnClicked()
{
ReturnToPreviousScreen();
}

View File

@ -0,0 +1,41 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "NakatomiInteractiveWidget.h"
#include "Components/Button.h"
#include "Components/ScrollBox.h"
#include "LoadGameUserWidget.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API ULoadGameUserWidget : public UNakatomiInteractiveWidget
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* CancelButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* CancelButtonTextBlock;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UScrollBox* SavedGamesScrollBox;
public:
virtual void NativeConstruct() override;
private:
UFUNCTION()
void CancelButtonOnClicked();
UFUNCTION()
void CancelButtonHoveredDelegate() { SetTextBlockHovered(CancelButtonTextBlock); }
UFUNCTION()
void CancelButtonUnhoveredDelegate() { SetTextBlockUnhovered(CancelButtonTextBlock); }
};

View File

@ -3,6 +3,7 @@
#include "../UI/NakatomiInteractiveWidget.h"
#include "GameFramework/GameUserSettings.h"
#include "Kismet/GameplayStatics.h"
void UNakatomiInteractiveWidget::PlayHoveredSound()
@ -38,3 +39,20 @@ void UNakatomiInteractiveWidget::PlayClickedSound()
UGameplayStatics::PlaySound2D(GetWorld(), ButtonUnhoveredSound);
}
}
void UNakatomiInteractiveWidget::ReturnToPreviousScreen()
{
// TODO: Implement Functionality
GEngine->GameUserSettings->ApplySettings(false);
this->RemoveFromParent();
PreviousScreen->AddToViewport();
}
void UNakatomiInteractiveWidget::SetReturnScreen(UUserWidget* userWidget)
{
if (userWidget)
{
PreviousScreen = userWidget;
}
}

View File

@ -32,6 +32,14 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* ButtonClickedSound;
protected:
UUserWidget* PreviousScreen;
public:
UFUNCTION()
void SetReturnScreen(UUserWidget* userWidget);
protected:
UFUNCTION()
void PlayHoveredSound();
@ -48,4 +56,6 @@ protected:
UFUNCTION()
void PlayClickedSound();
UFUNCTION()
void ReturnToPreviousScreen();
};