Compare commits

..

2 Commits

8 changed files with 69 additions and 67 deletions

View File

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

View File

@ -6,13 +6,14 @@
#include "OptionsUIWidget.h"
#include "Blueprint/UserWidget.h"
#include "Components/Button.h"
#include "UI/NakatomiInteractiveWidget.h"
#include "MainMenuUIWidget.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UMainMenuUIWidget : public UUserWidget
class NAKATOMI_API UMainMenuUIWidget : public UNakatomiInteractiveWidget
{
GENERATED_BODY()
public:
@ -53,15 +54,6 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSoftObjectPtr<UWorld> 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;
@ -85,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); }

View File

@ -200,11 +200,3 @@ void UOptionsUIWidget::OnDynamicResolutionCheckboxChanged(bool bIsChecked)
GEngine->GameUserSettings->ApplySettings(true);
this->PlayHoveredSound();
}
void UOptionsUIWidget::PlayHoveredSound()
{
if (ButtonHoveredSound)
{
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
}
}

View File

@ -7,13 +7,14 @@
#include "Components/CheckBox.h"
#include "Components/Button.h"
#include "Components/TextBlock.h"
#include "UI/NakatomiInteractiveWidget.h"
#include "OptionsUIWidget.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UOptionsUIWidget : public UUserWidget
class NAKATOMI_API UOptionsUIWidget : public UNakatomiInteractiveWidget
{
GENERATED_BODY()
@ -45,9 +46,6 @@ public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* ResetToDefaultsButton;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* ButtonHoveredSound;
private:
UUserWidget* PreviousScreen;
@ -82,7 +80,4 @@ private:
UFUNCTION()
void OnDynamicResolutionCheckboxChanged(bool bIsChecked);
UFUNCTION()
void PlayHoveredSound();
};

View File

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

View File

@ -6,13 +6,14 @@
#include "OptionsUIWidget.h"
#include "Blueprint/UserWidget.h"
#include "Components/Button.h"
#include "UI/NakatomiInteractiveWidget.h"
#include "PauseUIWidget.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UPauseUIWidget : public UUserWidget
class NAKATOMI_API UPauseUIWidget : public UNakatomiInteractiveWidget
{
GENERATED_BODY()
@ -35,9 +36,6 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> OptionsMenuWidget;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* ButtonHoveredSound;
private:
UOptionsUIWidget* currentOptionsMenuWidget;
@ -59,7 +57,4 @@ private:
UFUNCTION()
void ExitGameButtonOnClicked();
UFUNCTION()
void PlayHoveredSound();
};

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#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));
}

View File

@ -0,0 +1,39 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Components/TextBlock.h"
#include "NakatomiInteractiveWidget.generated.h"
/**
*
*/
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);
};