Add MVP frontend audio hooks

This commit is contained in:
2026-05-19 12:35:30 -07:00
parent f6e126aabb
commit d0ad64418d
5 changed files with 99 additions and 1 deletions
@@ -14,6 +14,7 @@
#include "Components/VerticalBoxSlot.h"
#include "GameFramework/PlayerController.h"
#include "InputCoreTypes.h"
#include "Kismet/GameplayStatics.h"
#include "Styling/CoreStyle.h"
#include "TimerManager.h"
@@ -48,18 +49,21 @@ FReply UAgrarianMvpFrontendWidget::NativeOnKeyDown(const FGeometry& InGeometry,
const FKey Key = InKeyEvent.GetKey();
if (Key == EKeys::Left || Key == EKeys::A)
{
PlayUiSound(UiSelectionSound);
SetSelectedCharacterArchetype(EAgrarianMvpCharacterArchetype::YoungAdultMale);
return FReply::Handled();
}
if (Key == EKeys::Right || Key == EKeys::D)
{
PlayUiSound(UiSelectionSound);
SetSelectedCharacterArchetype(EAgrarianMvpCharacterArchetype::YoungAdultFemale);
return FReply::Handled();
}
if (Key == EKeys::Enter || Key == EKeys::SpaceBar)
{
PlayUiSound(UiConfirmSound);
ConfirmActiveScreen();
return FReply::Handled();
}
@@ -69,12 +73,14 @@ FReply UAgrarianMvpFrontendWidget::NativeOnKeyDown(const FGeometry& InGeometry,
const FKey Key = InKeyEvent.GetKey();
if (Key == EKeys::Enter || Key == EKeys::SpaceBar)
{
PlayUiSound(UiConfirmSound);
ConfirmActiveScreen();
return FReply::Handled();
}
if (Key == EKeys::BackSpace || Key == EKeys::Escape)
{
PlayUiSound(UiBackSound);
BackFromActiveScreen();
return FReply::Handled();
}
@@ -84,6 +90,7 @@ FReply UAgrarianMvpFrontendWidget::NativeOnKeyDown(const FGeometry& InGeometry,
const FKey Key = InKeyEvent.GetKey();
if (Key == EKeys::Enter || Key == EKeys::SpaceBar)
{
PlayUiSound(UiConfirmSound);
ConfirmActiveScreen();
return FReply::Handled();
}
@@ -93,12 +100,14 @@ FReply UAgrarianMvpFrontendWidget::NativeOnKeyDown(const FGeometry& InGeometry,
const FKey Key = InKeyEvent.GetKey();
if (Key == EKeys::Enter || Key == EKeys::SpaceBar || Key == EKeys::Escape)
{
PlayUiSound(UiConfirmSound);
ConfirmActiveScreen();
return FReply::Handled();
}
if (Key == EKeys::Q)
{
PlayUiSound(UiSaveQuitSound);
SaveAndQuit();
return FReply::Handled();
}
@@ -466,6 +475,14 @@ UButton* UAgrarianMvpFrontendWidget::AddButton(UVerticalBox* Parent, const FText
return Button;
}
void UAgrarianMvpFrontendWidget::PlayUiSound(USoundBase* Sound) const
{
if (Sound)
{
UGameplayStatics::PlaySound2D(this, Sound);
}
}
void UAgrarianMvpFrontendWidget::FocusPrimaryButton()
{
if (PrimaryFocusButton)
@@ -480,26 +497,31 @@ void UAgrarianMvpFrontendWidget::FocusPrimaryButton()
void UAgrarianMvpFrontendWidget::HandlePrimaryActionClicked()
{
PlayUiSound(UiConfirmSound);
ConfirmActiveScreen();
}
void UAgrarianMvpFrontendWidget::HandleBackClicked()
{
PlayUiSound(UiBackSound);
BackFromActiveScreen();
}
void UAgrarianMvpFrontendWidget::HandleSaveAndQuitClicked()
{
PlayUiSound(UiSaveQuitSound);
SaveAndQuit();
}
void UAgrarianMvpFrontendWidget::HandleMaleCharacterClicked()
{
PlayUiSound(UiSelectionSound);
SetSelectedCharacterArchetype(EAgrarianMvpCharacterArchetype::YoungAdultMale);
}
void UAgrarianMvpFrontendWidget::HandleFemaleCharacterClicked()
{
PlayUiSound(UiSelectionSound);
SetSelectedCharacterArchetype(EAgrarianMvpCharacterArchetype::YoungAdultFemale);
}