Refactor OptionsUI functionality into NakatomiInteractiveWidget

This commit is contained in:
baz 2024-05-23 23:27:13 +01:00
parent c941024ecf
commit 82d2c21721
5 changed files with 33 additions and 20 deletions

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

Binary file not shown.

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

@ -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();
};