Compare commits

..

No commits in common. "71889f9578cd00696b45830897e6e307f5d75353" and "a86c56fccb0d51dd50bcd339bbd96facc81a71c8" have entirely different histories.

8 changed files with 67 additions and 69 deletions

View File

@ -95,3 +95,21 @@ 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,14 +6,13 @@
#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 UNakatomiInteractiveWidget
class NAKATOMI_API UMainMenuUIWidget : public UUserWidget
{
GENERATED_BODY()
public:
@ -54,6 +53,15 @@ 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;
@ -77,6 +85,15 @@ 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,3 +200,11 @@ void UOptionsUIWidget::OnDynamicResolutionCheckboxChanged(bool bIsChecked)
GEngine->GameUserSettings->ApplySettings(true);
this->PlayHoveredSound();
}
void UOptionsUIWidget::PlayHoveredSound()
{
if (ButtonHoveredSound)
{
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
}
}

View File

@ -7,14 +7,13 @@
#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 UNakatomiInteractiveWidget
class NAKATOMI_API UOptionsUIWidget : public UUserWidget
{
GENERATED_BODY()
@ -46,6 +45,9 @@ public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* ResetToDefaultsButton;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* ButtonHoveredSound;
private:
UUserWidget* PreviousScreen;
@ -80,4 +82,7 @@ private:
UFUNCTION()
void OnDynamicResolutionCheckboxChanged(bool bIsChecked);
UFUNCTION()
void PlayHoveredSound();
};

View File

@ -92,3 +92,11 @@ 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,14 +6,13 @@
#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 UNakatomiInteractiveWidget
class NAKATOMI_API UPauseUIWidget : public UUserWidget
{
GENERATED_BODY()
@ -36,6 +35,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> OptionsMenuWidget;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* ButtonHoveredSound;
private:
UOptionsUIWidget* currentOptionsMenuWidget;
@ -57,4 +59,7 @@ private:
UFUNCTION()
void ExitGameButtonOnClicked();
UFUNCTION()
void PlayHoveredSound();
};

View File

@ -1,24 +0,0 @@
// 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

@ -1,39 +0,0 @@
// 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);
};