Add OnHovered Sound2D in OptionsUIWidget

This commit is contained in:
baz 2024-04-03 00:15:59 +01:00
parent 96c520a793
commit 16efcc8fd7
3 changed files with 23 additions and 2 deletions

BIN
Content/UI/Options/OptionsMenu.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -21,6 +21,7 @@ void UOptionsUIWidget::NativeConstruct()
}
ResolutionButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::OnResolutionSelectorChanged);
ResolutionButton->OnHovered.AddUniqueDynamic(this, &UOptionsUIWidget::PlayHoveredSound);
}
if (FullscreenCheckBox)
@ -41,6 +42,7 @@ void UOptionsUIWidget::NativeConstruct()
}
RefreshRateButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::OnRefreshRateSelectorChanged);
RefreshRateButton->OnHovered.AddUniqueDynamic(this, &UOptionsUIWidget::PlayHoveredSound);
}
if (VsyncCheckBox)
@ -65,11 +67,13 @@ void UOptionsUIWidget::NativeConstruct()
if (BackButton)
{
BackButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::BackButtonOnClicked);
BackButton->OnHovered.AddUniqueDynamic(this, &UOptionsUIWidget::PlayHoveredSound);
}
if (ResetToDefaultsButton)
{
ResetToDefaultsButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::ResetToDefaultsButtonOnClicked);
ResetToDefaultsButton->OnHovered.AddUniqueDynamic(this, &UOptionsUIWidget::PlayHoveredSound);
}
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
@ -156,6 +160,7 @@ void UOptionsUIWidget::OnFullscreenCheckboxChanged(bool bIsChecked)
}
GEngine->GameUserSettings->ApplySettings(true);
this->PlayHoveredSound();
}
void UOptionsUIWidget::OnRefreshRateSelectorChanged()
@ -186,10 +191,20 @@ void UOptionsUIWidget::OnVsyncCheckboxChanged(bool bIsChecked)
{
GEngine->GameUserSettings->SetVSyncEnabled(bIsChecked);
GEngine->GameUserSettings->ApplySettings(true);
this->PlayHoveredSound();
}
void UOptionsUIWidget::OnDynamicResolutionCheckboxChanged(bool bIsChecked)
{
GEngine->GameUserSettings->SetDynamicResolutionEnabled(bIsChecked);
GEngine->GameUserSettings->ApplySettings(true);
this->PlayHoveredSound();
}
void UOptionsUIWidget::PlayHoveredSound()
{
if (ButtonHoveredSound)
{
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
}
}

View File

@ -45,6 +45,9 @@ public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* ResetToDefaultsButton;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* ButtonHoveredSound;
private:
UUserWidget* PreviousScreen;
@ -79,4 +82,7 @@ private:
UFUNCTION()
void OnDynamicResolutionCheckboxChanged(bool bIsChecked);
UFUNCTION()
void PlayHoveredSound();
};