diff --git a/Source/Nakatomi/MainMenuUIWidget.cpp b/Source/Nakatomi/MainMenuUIWidget.cpp index 261b8c4..c3c9176 100644 --- a/Source/Nakatomi/MainMenuUIWidget.cpp +++ b/Source/Nakatomi/MainMenuUIWidget.cpp @@ -95,21 +95,3 @@ void UMainMenuUIWidget::QuitButtonOnClicked() // For some reason the generic version does not work the same as FWindowsPlatformMisc FWindowsPlatformMisc::RequestExit(false); } - -void UMainMenuUIWidget::PlayHoveredSound() -{ - if (ButtonHoveredSound) - { - UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound); - } -} - -void UMainMenuUIWidget::SetTextBlockHovered(UTextBlock* TextBlock) -{ - TextBlock->SetColorAndOpacity(FSlateColor(ButtonHoveredTextColor)); -} - -void UMainMenuUIWidget::SetTextBlockUnhovered(UTextBlock* TextBlock) -{ - TextBlock->SetColorAndOpacity(FSlateColor(ButtonUnhoveredTextColor)); -} diff --git a/Source/Nakatomi/MainMenuUIWidget.h b/Source/Nakatomi/MainMenuUIWidget.h index e7b87cf..f7a516a 100644 --- a/Source/Nakatomi/MainMenuUIWidget.h +++ b/Source/Nakatomi/MainMenuUIWidget.h @@ -54,15 +54,6 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) TSoftObjectPtr NewGameLevel; - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) - USoundBase* ButtonHoveredSound; - - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) - FLinearColor ButtonHoveredTextColor = {0, 1, 0, 1}; - - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) - FLinearColor ButtonUnhoveredTextColor = {1, 1, 1, 1}; - private: UUserWidget* currentNewGameWidget; @@ -86,15 +77,6 @@ private: UFUNCTION() void QuitButtonOnClicked(); - UFUNCTION() - void PlayHoveredSound(); - - UFUNCTION() - void SetTextBlockHovered(UTextBlock* TextBlock); - - UFUNCTION() - void SetTextBlockUnhovered(UTextBlock* TextBlock); - UFUNCTION() void NewGameTextBlockHoveredDelegate() { SetTextBlockHovered(NewGameTextBlock); } diff --git a/Source/Nakatomi/OptionsUIWidget.cpp b/Source/Nakatomi/OptionsUIWidget.cpp index 87f8301..27db8d8 100644 --- a/Source/Nakatomi/OptionsUIWidget.cpp +++ b/Source/Nakatomi/OptionsUIWidget.cpp @@ -200,11 +200,3 @@ void UOptionsUIWidget::OnDynamicResolutionCheckboxChanged(bool bIsChecked) GEngine->GameUserSettings->ApplySettings(true); this->PlayHoveredSound(); } - -void UOptionsUIWidget::PlayHoveredSound() -{ - if (ButtonHoveredSound) - { - UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound); - } -} diff --git a/Source/Nakatomi/OptionsUIWidget.h b/Source/Nakatomi/OptionsUIWidget.h index 9b23c65..751a187 100644 --- a/Source/Nakatomi/OptionsUIWidget.h +++ b/Source/Nakatomi/OptionsUIWidget.h @@ -46,9 +46,6 @@ public: UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UButton* ResetToDefaultsButton; - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) - USoundBase* ButtonHoveredSound; - private: UUserWidget* PreviousScreen; @@ -83,7 +80,4 @@ private: UFUNCTION() void OnDynamicResolutionCheckboxChanged(bool bIsChecked); - - UFUNCTION() - void PlayHoveredSound(); }; diff --git a/Source/Nakatomi/PauseUIWidget.cpp b/Source/Nakatomi/PauseUIWidget.cpp index 5c5218d..81bf5fa 100644 --- a/Source/Nakatomi/PauseUIWidget.cpp +++ b/Source/Nakatomi/PauseUIWidget.cpp @@ -92,11 +92,3 @@ void UPauseUIWidget::ExitGameButtonOnClicked() // For some reason the generic version does not work the same as FWindowsPlatformMisc FWindowsPlatformMisc::RequestExit(false); } - -void UPauseUIWidget::PlayHoveredSound() -{ - if (ButtonHoveredSound) - { - UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound); - } -} diff --git a/Source/Nakatomi/PauseUIWidget.h b/Source/Nakatomi/PauseUIWidget.h index 9ef5fa2..27398d3 100644 --- a/Source/Nakatomi/PauseUIWidget.h +++ b/Source/Nakatomi/PauseUIWidget.h @@ -36,9 +36,6 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) TSubclassOf OptionsMenuWidget; - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) - USoundBase* ButtonHoveredSound; - private: UOptionsUIWidget* currentOptionsMenuWidget; @@ -60,7 +57,4 @@ private: UFUNCTION() void ExitGameButtonOnClicked(); - - UFUNCTION() - void PlayHoveredSound(); }; diff --git a/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp b/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp index 915aee5..cf45776 100644 --- a/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp +++ b/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp @@ -3,3 +3,22 @@ #include "../UI/NakatomiInteractiveWidget.h" +#include "Kismet/GameplayStatics.h" + +void UNakatomiInteractiveWidget::PlayHoveredSound() +{ + if (ButtonHoveredSound) + { + UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound); + } +} + +void UNakatomiInteractiveWidget::SetTextBlockHovered(UTextBlock* TextBlock) +{ + TextBlock->SetColorAndOpacity(FSlateColor(ButtonHoveredTextColor)); +} + +void UNakatomiInteractiveWidget::SetTextBlockUnhovered(UTextBlock* TextBlock) +{ + TextBlock->SetColorAndOpacity(FSlateColor(ButtonUnhoveredTextColor)); +} diff --git a/Source/Nakatomi/UI/NakatomiInteractiveWidget.h b/Source/Nakatomi/UI/NakatomiInteractiveWidget.h index 66fd425..4c0971c 100644 --- a/Source/Nakatomi/UI/NakatomiInteractiveWidget.h +++ b/Source/Nakatomi/UI/NakatomiInteractiveWidget.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "Blueprint/UserWidget.h" +#include "Components/TextBlock.h" #include "NakatomiInteractiveWidget.generated.h" /** @@ -13,5 +14,26 @@ UCLASS() class NAKATOMI_API UNakatomiInteractiveWidget : public UUserWidget { GENERATED_BODY() + +public: + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + USoundBase* ButtonHoveredSound; + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + FLinearColor ButtonHoveredTextColor = {0, 1, 0, 1}; + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + FLinearColor ButtonUnhoveredTextColor = {1, 1, 1, 1}; + +protected: + UFUNCTION() + void PlayHoveredSound(); + + UFUNCTION() + void SetTextBlockHovered(UTextBlock* TextBlock); + + UFUNCTION() + void SetTextBlockUnhovered(UTextBlock* TextBlock); };