Move Generic Hovered functionality to InteractiveWidget class
This commit is contained in:
parent
4c795a3a27
commit
71889f9578
|
@ -95,21 +95,3 @@ void UMainMenuUIWidget::QuitButtonOnClicked()
|
||||||
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
||||||
FWindowsPlatformMisc::RequestExit(false);
|
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));
|
|
||||||
}
|
|
||||||
|
|
|
@ -54,15 +54,6 @@ public:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TSoftObjectPtr<UWorld> NewGameLevel;
|
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:
|
private:
|
||||||
UUserWidget* currentNewGameWidget;
|
UUserWidget* currentNewGameWidget;
|
||||||
|
|
||||||
|
@ -86,15 +77,6 @@ private:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void QuitButtonOnClicked();
|
void QuitButtonOnClicked();
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void PlayHoveredSound();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void SetTextBlockHovered(UTextBlock* TextBlock);
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void SetTextBlockUnhovered(UTextBlock* TextBlock);
|
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void NewGameTextBlockHoveredDelegate() { SetTextBlockHovered(NewGameTextBlock); }
|
void NewGameTextBlockHoveredDelegate() { SetTextBlockHovered(NewGameTextBlock); }
|
||||||
|
|
||||||
|
|
|
@ -200,11 +200,3 @@ void UOptionsUIWidget::OnDynamicResolutionCheckboxChanged(bool bIsChecked)
|
||||||
GEngine->GameUserSettings->ApplySettings(true);
|
GEngine->GameUserSettings->ApplySettings(true);
|
||||||
this->PlayHoveredSound();
|
this->PlayHoveredSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UOptionsUIWidget::PlayHoveredSound()
|
|
||||||
{
|
|
||||||
if (ButtonHoveredSound)
|
|
||||||
{
|
|
||||||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -46,9 +46,6 @@ public:
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||||
UButton* ResetToDefaultsButton;
|
UButton* ResetToDefaultsButton;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
USoundBase* ButtonHoveredSound;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UUserWidget* PreviousScreen;
|
UUserWidget* PreviousScreen;
|
||||||
|
@ -83,7 +80,4 @@ private:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void OnDynamicResolutionCheckboxChanged(bool bIsChecked);
|
void OnDynamicResolutionCheckboxChanged(bool bIsChecked);
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void PlayHoveredSound();
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -92,11 +92,3 @@ void UPauseUIWidget::ExitGameButtonOnClicked()
|
||||||
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
||||||
FWindowsPlatformMisc::RequestExit(false);
|
FWindowsPlatformMisc::RequestExit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPauseUIWidget::PlayHoveredSound()
|
|
||||||
{
|
|
||||||
if (ButtonHoveredSound)
|
|
||||||
{
|
|
||||||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -36,9 +36,6 @@ public:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TSubclassOf<class UUserWidget> OptionsMenuWidget;
|
TSubclassOf<class UUserWidget> OptionsMenuWidget;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
USoundBase* ButtonHoveredSound;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UOptionsUIWidget* currentOptionsMenuWidget;
|
UOptionsUIWidget* currentOptionsMenuWidget;
|
||||||
|
|
||||||
|
@ -60,7 +57,4 @@ private:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void ExitGameButtonOnClicked();
|
void ExitGameButtonOnClicked();
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void PlayHoveredSound();
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,3 +3,22 @@
|
||||||
|
|
||||||
#include "../UI/NakatomiInteractiveWidget.h"
|
#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));
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
|
#include "Components/TextBlock.h"
|
||||||
#include "NakatomiInteractiveWidget.generated.h"
|
#include "NakatomiInteractiveWidget.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,5 +14,26 @@ UCLASS()
|
||||||
class NAKATOMI_API UNakatomiInteractiveWidget : public UUserWidget
|
class NAKATOMI_API UNakatomiInteractiveWidget : public UUserWidget
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
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);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue