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); SetIsFocusable(true);
} }
void UOptionsUIWidget::SetReturnScreen(UUserWidget* userWidget)
{
if (userWidget)
{
PreviousScreen = userWidget;
}
}
void UOptionsUIWidget::BackButtonOnClicked() void UOptionsUIWidget::BackButtonOnClicked()
{ {
// TODO: Implement Functionality ReturnToPreviousScreen();
GEngine->GameUserSettings->ApplySettings(false);
this->RemoveFromParent();
PreviousScreen->AddToViewport();
} }
void UOptionsUIWidget::ResetToDefaultsButtonOnClicked() void UOptionsUIWidget::ResetToDefaultsButtonOnClicked()

View File

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

View File

@ -3,6 +3,7 @@
#include "../UI/NakatomiInteractiveWidget.h" #include "../UI/NakatomiInteractiveWidget.h"
#include "GameFramework/GameUserSettings.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
void UNakatomiInteractiveWidget::PlayHoveredSound() void UNakatomiInteractiveWidget::PlayHoveredSound()
@ -38,3 +39,20 @@ void UNakatomiInteractiveWidget::PlayClickedSound()
UGameplayStatics::PlaySound2D(GetWorld(), ButtonUnhoveredSound); 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) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* ButtonClickedSound; USoundBase* ButtonClickedSound;
protected:
UUserWidget* PreviousScreen;
public:
UFUNCTION()
void SetReturnScreen(UUserWidget* userWidget);
protected: protected:
UFUNCTION() UFUNCTION()
void PlayHoveredSound(); void PlayHoveredSound();
@ -48,4 +56,6 @@ protected:
UFUNCTION() UFUNCTION()
void PlayClickedSound(); void PlayClickedSound();
UFUNCTION()
void ReturnToPreviousScreen();
}; };