Improve investor visual recovery pass
This commit is contained in:
@@ -12,10 +12,13 @@
|
||||
#include "AgrarianPersistenceSubsystem.h"
|
||||
#include "AgrarianShelterActor.h"
|
||||
#include "AgrarianSurvivalComponent.h"
|
||||
#include "Camera/CameraActor.h"
|
||||
#include "Components/SkeletalMeshComponent.h"
|
||||
#include "Components/StaticMeshComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "Engine/SkeletalMesh.h"
|
||||
#include "Engine/StaticMesh.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "InputCoreTypes.h"
|
||||
@@ -92,6 +95,58 @@ namespace
|
||||
? TEXT("/Game/Agrarian/Characters/Materials/M_AGR_CharacterProxy_Workwear_Female.M_AGR_CharacterProxy_Workwear_Female")
|
||||
: TEXT("/Game/Agrarian/Characters/Materials/M_AGR_CharacterProxy_Workwear_Male.M_AGR_CharacterProxy_Workwear_Male");
|
||||
}
|
||||
|
||||
UStaticMeshComponent* EnsureMvpPresentationComponent(
|
||||
AAgrarianGameCharacter* Character,
|
||||
const FName ComponentName,
|
||||
UStaticMesh* Mesh,
|
||||
UMaterialInterface* Material,
|
||||
const FVector& RelativeLocation,
|
||||
const FRotator& RelativeRotation,
|
||||
const FVector& RelativeScale)
|
||||
{
|
||||
if (!Character || !Mesh)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UStaticMeshComponent* Component = nullptr;
|
||||
TArray<UStaticMeshComponent*> ExistingComponents;
|
||||
Character->GetComponents<UStaticMeshComponent>(ExistingComponents);
|
||||
for (UStaticMeshComponent* ExistingComponent : ExistingComponents)
|
||||
{
|
||||
if (ExistingComponent && ExistingComponent->GetFName() == ComponentName)
|
||||
{
|
||||
Component = ExistingComponent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Component)
|
||||
{
|
||||
Component = NewObject<UStaticMeshComponent>(Character, ComponentName);
|
||||
if (!Component)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
Component->SetupAttachment(Character->GetRootComponent());
|
||||
Component->RegisterComponent();
|
||||
Character->AddInstanceComponent(Component);
|
||||
}
|
||||
|
||||
Component->SetStaticMesh(Mesh);
|
||||
if (Material)
|
||||
{
|
||||
Component->SetMaterial(0, Material);
|
||||
}
|
||||
Component->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
Component->SetGenerateOverlapEvents(false);
|
||||
Component->SetRelativeLocation(RelativeLocation);
|
||||
Component->SetRelativeRotation(RelativeRotation);
|
||||
Component->SetRelativeScale3D(RelativeScale);
|
||||
Component->SetHiddenInGame(false);
|
||||
return Component;
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::BeginPlay()
|
||||
@@ -102,8 +157,7 @@ void AAgrarianGamePlayerController::BeginPlay()
|
||||
{
|
||||
if (MvpFrontendStartupDelaySeconds > 0.0f)
|
||||
{
|
||||
SetIgnoreMoveInput(true);
|
||||
SetIgnoreLookInput(true);
|
||||
SetMvpFrontendPresentationActive(true);
|
||||
SetInputMode(FInputModeUIOnly());
|
||||
bShowMouseCursor = false;
|
||||
GetWorldTimerManager().SetTimer(
|
||||
@@ -139,6 +193,22 @@ void AAgrarianGamePlayerController::BeginPlay()
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AcknowledgePossession(APawn* P)
|
||||
{
|
||||
Super::AcknowledgePossession(P);
|
||||
|
||||
if (!IsLocalPlayerController())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyMvpCharacterProxyToPawn();
|
||||
if (bMvpFrontendPresentationActive)
|
||||
{
|
||||
SetMvpFrontendPresentationActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
@@ -204,6 +274,7 @@ void AAgrarianGamePlayerController::ShowMvpFrontend()
|
||||
{
|
||||
MvpFrontendWidget->AddToPlayerScreen(10);
|
||||
}
|
||||
SetMvpFrontendPresentationActive(true);
|
||||
SetInputMode(FInputModeUIOnly().SetWidgetToFocus(MvpFrontendWidget->TakeWidget()).SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock));
|
||||
bShowMouseCursor = true;
|
||||
SetIgnoreMoveInput(true);
|
||||
@@ -241,6 +312,7 @@ void AAgrarianGamePlayerController::ShowMvpPauseMenu()
|
||||
}
|
||||
|
||||
MvpFrontendWidget->SetActiveScreen(EAgrarianMvpFrontendScreen::MainMenu);
|
||||
SetMvpFrontendPresentationActive(true);
|
||||
SetInputMode(FInputModeUIOnly().SetWidgetToFocus(MvpFrontendWidget->TakeWidget()).SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock));
|
||||
bShowMouseCursor = true;
|
||||
SetIgnoreMoveInput(true);
|
||||
@@ -275,6 +347,132 @@ void AAgrarianGamePlayerController::HandleMvpEscapeInput()
|
||||
ShowMvpPauseMenu();
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::SetMvpFrontendPresentationActive(bool bNewActive)
|
||||
{
|
||||
bMvpFrontendPresentationActive = bNewActive;
|
||||
|
||||
SetIgnoreMoveInput(bNewActive);
|
||||
SetIgnoreLookInput(bNewActive);
|
||||
|
||||
APawn* ControlledPawn = GetPawn();
|
||||
if (ControlledPawn)
|
||||
{
|
||||
ControlledPawn->SetActorHiddenInGame(bNewActive);
|
||||
ControlledPawn->SetActorEnableCollision(!bNewActive);
|
||||
|
||||
if (ACharacter* ControlledCharacter = Cast<ACharacter>(ControlledPawn))
|
||||
{
|
||||
if (UCharacterMovementComponent* MovementComponent = ControlledCharacter->GetCharacterMovement())
|
||||
{
|
||||
if (bNewActive)
|
||||
{
|
||||
MovementComponent->DisableMovement();
|
||||
}
|
||||
else
|
||||
{
|
||||
MovementComponent->SetMovementMode(MOVE_Walking);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CacheAndApplyMvpHudSuppression(bNewActive);
|
||||
|
||||
if (bNewActive)
|
||||
{
|
||||
CreateOrUpdateMvpFrontendCamera();
|
||||
if (MvpFrontendCameraActor)
|
||||
{
|
||||
SetViewTarget(MvpFrontendCameraActor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ControlledPawn)
|
||||
{
|
||||
SetViewTarget(ControlledPawn);
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::CreateOrUpdateMvpFrontendCamera()
|
||||
{
|
||||
UWorld* World = GetWorld();
|
||||
if (!World)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const APawn* ControlledPawn = GetPawn();
|
||||
const FVector TargetLocation = ControlledPawn
|
||||
? ControlledPawn->GetActorLocation() + FVector(0.0f, 0.0f, 95.0f)
|
||||
: GroundZeroDeveloperTravelHomeLocation;
|
||||
const FVector CameraLocation = TargetLocation + FVector(-620.0f, -520.0f, 260.0f);
|
||||
const FRotator CameraRotation = (TargetLocation - CameraLocation).Rotation();
|
||||
|
||||
if (!MvpFrontendCameraActor)
|
||||
{
|
||||
FActorSpawnParameters SpawnParameters;
|
||||
SpawnParameters.Owner = this;
|
||||
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
MvpFrontendCameraActor = World->SpawnActor<ACameraActor>(ACameraActor::StaticClass(), CameraLocation, CameraRotation, SpawnParameters);
|
||||
if (MvpFrontendCameraActor)
|
||||
{
|
||||
MvpFrontendCameraActor->SetActorHiddenInGame(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MvpFrontendCameraActor->SetActorLocationAndRotation(CameraLocation, CameraRotation);
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::CacheAndApplyMvpHudSuppression(bool bSuppress)
|
||||
{
|
||||
AAgrarianDebugHUD* AgrarianHUD = GetHUD<AAgrarianDebugHUD>();
|
||||
if (!AgrarianHUD)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (bSuppress)
|
||||
{
|
||||
if (!bCachedMvpHudState)
|
||||
{
|
||||
bCachedShowDebugHUD = AgrarianHUD->bShowDebugHUD;
|
||||
bCachedShowMvpHudFrame = AgrarianHUD->bShowMvpHudFrame;
|
||||
bCachedShowCriticalStatsHUD = AgrarianHUD->bShowCriticalStatsHUD;
|
||||
bCachedShowInventoryHUD = AgrarianHUD->bShowInventoryHUD;
|
||||
bCachedShowCraftingHUD = AgrarianHUD->bShowCraftingHUD;
|
||||
bCachedShowInteractionPrompt = AgrarianHUD->bShowInteractionPrompt;
|
||||
bCachedShowDeathRespawnUI = AgrarianHUD->bShowDeathRespawnUI;
|
||||
bCachedShowDebugDevMenu = AgrarianHUD->bShowDebugDevMenu;
|
||||
bCachedMvpHudState = true;
|
||||
}
|
||||
|
||||
AgrarianHUD->bShowDebugHUD = false;
|
||||
AgrarianHUD->bShowMvpHudFrame = false;
|
||||
AgrarianHUD->bShowCriticalStatsHUD = false;
|
||||
AgrarianHUD->bShowInventoryHUD = false;
|
||||
AgrarianHUD->bShowCraftingHUD = false;
|
||||
AgrarianHUD->bShowInteractionPrompt = false;
|
||||
AgrarianHUD->bShowDeathRespawnUI = false;
|
||||
AgrarianHUD->bShowDebugDevMenu = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bCachedMvpHudState)
|
||||
{
|
||||
AgrarianHUD->bShowDebugHUD = bCachedShowDebugHUD;
|
||||
AgrarianHUD->bShowMvpHudFrame = bCachedShowMvpHudFrame;
|
||||
AgrarianHUD->bShowCriticalStatsHUD = bCachedShowCriticalStatsHUD;
|
||||
AgrarianHUD->bShowInventoryHUD = bCachedShowInventoryHUD;
|
||||
AgrarianHUD->bShowCraftingHUD = bCachedShowCraftingHUD;
|
||||
AgrarianHUD->bShowInteractionPrompt = bCachedShowInteractionPrompt;
|
||||
AgrarianHUD->bShowDeathRespawnUI = bCachedShowDeathRespawnUI;
|
||||
AgrarianHUD->bShowDebugDevMenu = bCachedShowDebugDevMenu;
|
||||
bCachedMvpHudState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::ApplyMvpCharacterProxyToPawn()
|
||||
{
|
||||
AAgrarianGameCharacter* AgrarianCharacter = GetPawn<AAgrarianGameCharacter>();
|
||||
@@ -297,6 +495,61 @@ void AAgrarianGamePlayerController::ApplyMvpCharacterProxyToPawn()
|
||||
MeshComponent->SetMaterial(MaterialIndex, ProxyMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
UStaticMesh* ChamferMesh = LoadObject<UStaticMesh>(
|
||||
nullptr,
|
||||
TEXT("/Game/Agrarian/Environment/PlaceholderMeshes/SM_AGR_Placeholder_ChamferCube.SM_AGR_Placeholder_ChamferCube"));
|
||||
UStaticMesh* CubeMesh = LoadObject<UStaticMesh>(
|
||||
nullptr,
|
||||
TEXT("/Game/Agrarian/Environment/PlaceholderMeshes/SM_AGR_Placeholder_Cube.SM_AGR_Placeholder_Cube"));
|
||||
UStaticMesh* CylinderMesh = LoadObject<UStaticMesh>(
|
||||
nullptr,
|
||||
TEXT("/Game/Agrarian/Environment/PlaceholderMeshes/SM_AGR_Placeholder_Cylinder.SM_AGR_Placeholder_Cylinder"));
|
||||
UMaterialInterface* WorkwearMaterial = LoadObject<UMaterialInterface>(nullptr, GetMvpCharacterProxyMaterialPath(SelectedMvpCharacterProxyId));
|
||||
UMaterialInterface* PackMaterial = LoadObject<UMaterialInterface>(
|
||||
nullptr,
|
||||
TEXT("/Game/Agrarian/Materials/M_AGR_GZ_Fiber_Resource.M_AGR_GZ_Fiber_Resource"));
|
||||
UMaterialInterface* BootMaterial = LoadObject<UMaterialInterface>(
|
||||
nullptr,
|
||||
TEXT("/Game/Agrarian/Materials/M_AGR_GZ_Wood_Resource.M_AGR_GZ_Wood_Resource"));
|
||||
|
||||
const bool bFemaleProxy = SelectedMvpCharacterProxyId == TEXT("female");
|
||||
const float TorsoWidth = bFemaleProxy ? 0.33f : 0.38f;
|
||||
const float TorsoDepth = bFemaleProxy ? 0.18f : 0.22f;
|
||||
const float PackWidth = bFemaleProxy ? 0.24f : 0.28f;
|
||||
|
||||
EnsureMvpPresentationComponent(
|
||||
AgrarianCharacter,
|
||||
TEXT("MvpWorkwearTorsoProxy"),
|
||||
ChamferMesh,
|
||||
WorkwearMaterial,
|
||||
FVector(2.0f, 0.0f, 102.0f),
|
||||
FRotator(0.0f, 0.0f, 0.0f),
|
||||
FVector(TorsoWidth, TorsoDepth, 0.62f));
|
||||
EnsureMvpPresentationComponent(
|
||||
AgrarianCharacter,
|
||||
TEXT("MvpWorkwearBackpackProxy"),
|
||||
ChamferMesh,
|
||||
PackMaterial,
|
||||
FVector(-24.0f, 0.0f, 106.0f),
|
||||
FRotator(0.0f, 0.0f, 0.0f),
|
||||
FVector(PackWidth, 0.16f, 0.48f));
|
||||
EnsureMvpPresentationComponent(
|
||||
AgrarianCharacter,
|
||||
TEXT("MvpWorkwearBedrollProxy"),
|
||||
CylinderMesh,
|
||||
PackMaterial,
|
||||
FVector(-30.0f, 0.0f, 134.0f),
|
||||
FRotator(0.0f, 90.0f, 0.0f),
|
||||
FVector(0.12f, 0.12f, 0.58f));
|
||||
EnsureMvpPresentationComponent(
|
||||
AgrarianCharacter,
|
||||
TEXT("MvpWorkwearBootsProxy"),
|
||||
ChamferMesh,
|
||||
BootMaterial,
|
||||
FVector(0.0f, 0.0f, 26.0f),
|
||||
FRotator(0.0f, 0.0f, 0.0f),
|
||||
FVector(0.34f, 0.20f, 0.18f));
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AgrarianGrantItem(FName ItemId, int32 Quantity)
|
||||
@@ -558,6 +811,14 @@ void AAgrarianGamePlayerController::AgrarianSelectCharacter(FName Archetype)
|
||||
ClientMessage(TEXT("Usage: AgrarianSelectCharacter male|female"));
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AgrarianCompleteFrontend()
|
||||
{
|
||||
ApplyMvpCharacterProxyToPawn();
|
||||
SetMvpFrontendPresentationActive(false);
|
||||
SetInputMode(FInputModeGameOnly());
|
||||
bShowMouseCursor = false;
|
||||
}
|
||||
|
||||
void AAgrarianGamePlayerController::AgrarianShowMvpScreen(FName ScreenName)
|
||||
{
|
||||
if (!MvpFrontendWidget)
|
||||
|
||||
@@ -10,6 +10,7 @@ class UInputMappingContext;
|
||||
class UUserWidget;
|
||||
class UAgrarianMvpFrontendWidget;
|
||||
class AAgrarianShelterActor;
|
||||
class ACameraActor;
|
||||
|
||||
/**
|
||||
* Basic PlayerController class for a third person game
|
||||
@@ -67,9 +68,27 @@ protected:
|
||||
void HandleMvpBackInput();
|
||||
void HandleMvpEscapeInput();
|
||||
void ApplyMvpCharacterProxyToPawn();
|
||||
void SetMvpFrontendPresentationActive(bool bNewActive);
|
||||
void CreateOrUpdateMvpFrontendCamera();
|
||||
void CacheAndApplyMvpHudSuppression(bool bSuppress);
|
||||
virtual void AcknowledgePossession(APawn* P) override;
|
||||
|
||||
FName SelectedMvpCharacterProxyId = TEXT("male");
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<ACameraActor> MvpFrontendCameraActor;
|
||||
|
||||
bool bMvpFrontendPresentationActive = false;
|
||||
bool bCachedMvpHudState = false;
|
||||
bool bCachedShowDebugHUD = true;
|
||||
bool bCachedShowMvpHudFrame = true;
|
||||
bool bCachedShowCriticalStatsHUD = true;
|
||||
bool bCachedShowInventoryHUD = true;
|
||||
bool bCachedShowCraftingHUD = true;
|
||||
bool bCachedShowInteractionPrompt = true;
|
||||
bool bCachedShowDeathRespawnUI = true;
|
||||
bool bCachedShowDebugDevMenu = false;
|
||||
|
||||
public:
|
||||
UFUNCTION(Exec)
|
||||
void AgrarianGrantItem(FName ItemId, int32 Quantity);
|
||||
@@ -128,6 +147,9 @@ public:
|
||||
UFUNCTION(Exec)
|
||||
void AgrarianSelectCharacter(FName Archetype);
|
||||
|
||||
UFUNCTION(Exec)
|
||||
void AgrarianCompleteFrontend();
|
||||
|
||||
UFUNCTION(Exec)
|
||||
void AgrarianShowMvpScreen(FName ScreenName);
|
||||
|
||||
|
||||
@@ -9,13 +9,11 @@
|
||||
#include "Components/HorizontalBox.h"
|
||||
#include "Components/HorizontalBoxSlot.h"
|
||||
#include "Components/SizeBox.h"
|
||||
#include "Components/Slider.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "Components/VerticalBox.h"
|
||||
#include "Components/VerticalBoxSlot.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "InputCoreTypes.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Styling/CoreStyle.h"
|
||||
#include "TimerManager.h"
|
||||
|
||||
@@ -50,21 +48,18 @@ 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();
|
||||
}
|
||||
@@ -74,14 +69,12 @@ 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();
|
||||
}
|
||||
@@ -91,7 +84,6 @@ FReply UAgrarianMvpFrontendWidget::NativeOnKeyDown(const FGeometry& InGeometry,
|
||||
const FKey Key = InKeyEvent.GetKey();
|
||||
if (Key == EKeys::Enter || Key == EKeys::SpaceBar)
|
||||
{
|
||||
PlayUiSound(UiConfirmSound);
|
||||
ConfirmActiveScreen();
|
||||
return FReply::Handled();
|
||||
}
|
||||
@@ -101,14 +93,12 @@ 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();
|
||||
}
|
||||
@@ -211,6 +201,11 @@ void UAgrarianMvpFrontendWidget::ContinueFromActiveScreen()
|
||||
CompleteFrontendFlow();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveScreen == EAgrarianMvpFrontendScreen::SavingAndQuit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::ReturnFromActiveScreen()
|
||||
@@ -238,6 +233,7 @@ void UAgrarianMvpFrontendWidget::CompleteFrontendFlow()
|
||||
: TEXT("AgrarianSelectCharacter male"));
|
||||
}
|
||||
|
||||
PlayerController->ConsoleCommand(TEXT("AgrarianCompleteFrontend"));
|
||||
PlayerController->SetInputMode(FInputModeGameOnly());
|
||||
PlayerController->bShowMouseCursor = false;
|
||||
PlayerController->SetIgnoreMoveInput(false);
|
||||
@@ -299,31 +295,6 @@ void UAgrarianMvpFrontendWidget::RebuildFrontendTree()
|
||||
|
||||
UButton* QuitButton = AddButton(Panel, FText::FromString(TEXT("Save & Quit")), QuitButtonColor, FLinearColor(0.58f, 0.28f, 0.22f, 1.0f), 34.0f * Scale);
|
||||
QuitButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleSaveAndQuitClicked);
|
||||
AddText(Panel, FText::FromString(TEXT("Audio")), FMath::RoundToInt(18.0f * Scale), true, AccentColor, 8.0f * Scale);
|
||||
if (USlider* Slider = AddVolumeSlider(Panel, FText::FromString(TEXT("Master")), MasterVolume, 8.0f * Scale))
|
||||
{
|
||||
Slider->OnValueChanged.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleMasterVolumeChanged);
|
||||
}
|
||||
if (USlider* Slider = AddVolumeSlider(Panel, FText::FromString(TEXT("Ambient")), AmbientVolume, 8.0f * Scale))
|
||||
{
|
||||
Slider->OnValueChanged.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleAmbientVolumeChanged);
|
||||
}
|
||||
if (USlider* Slider = AddVolumeSlider(Panel, FText::FromString(TEXT("Weather")), WeatherVolume, 8.0f * Scale))
|
||||
{
|
||||
Slider->OnValueChanged.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleWeatherVolumeChanged);
|
||||
}
|
||||
if (USlider* Slider = AddVolumeSlider(Panel, FText::FromString(TEXT("Effects")), EffectsVolume, 8.0f * Scale))
|
||||
{
|
||||
Slider->OnValueChanged.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleEffectsVolumeChanged);
|
||||
}
|
||||
if (USlider* Slider = AddVolumeSlider(Panel, FText::FromString(TEXT("Wildlife")), WildlifeVolume, 8.0f * Scale))
|
||||
{
|
||||
Slider->OnValueChanged.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleWildlifeVolumeChanged);
|
||||
}
|
||||
if (USlider* Slider = AddVolumeSlider(Panel, FText::FromString(TEXT("UI")), UiVolume, 24.0f * Scale))
|
||||
{
|
||||
Slider->OnValueChanged.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleUiVolumeChanged);
|
||||
}
|
||||
AddText(Panel, FText::FromString(TEXT("Escape opens this menu. Save & Quit writes the current world save before closing.")), FMath::RoundToInt(16.0f * Scale), false, MutedTextColor, 0.0f);
|
||||
return;
|
||||
}
|
||||
@@ -496,78 +467,6 @@ UButton* UAgrarianMvpFrontendWidget::AddButton(UVerticalBox* Parent, const FText
|
||||
return Button;
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::PlayUiSound(USoundBase* Sound) const
|
||||
{
|
||||
if (Sound)
|
||||
{
|
||||
UGameplayStatics::PlaySound2D(this, Sound, FMath::Clamp(MasterVolume * UiVolume, 0.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
USlider* UAgrarianMvpFrontendWidget::AddVolumeSlider(UVerticalBox* Parent, const FText& Label, float Value, float BottomPadding)
|
||||
{
|
||||
if (!Parent || !WidgetTree)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UHorizontalBox* Row = WidgetTree->ConstructWidget<UHorizontalBox>(UHorizontalBox::StaticClass());
|
||||
if (UVerticalBoxSlot* RowSlot = Parent->AddChildToVerticalBox(Row))
|
||||
{
|
||||
RowSlot->SetPadding(FMargin(0.0f, 0.0f, 0.0f, BottomPadding));
|
||||
RowSlot->SetHorizontalAlignment(HAlign_Fill);
|
||||
}
|
||||
|
||||
UTextBlock* LabelText = AddText(nullptr, Label, 15, false, FLinearColor(0.82f, 0.90f, 0.76f, 1.0f), 0.0f);
|
||||
if (UHorizontalBoxSlot* LabelSlot = Row->AddChildToHorizontalBox(LabelText))
|
||||
{
|
||||
LabelSlot->SetSize(FSlateChildSize(ESlateSizeRule::Fill));
|
||||
LabelSlot->SetHorizontalAlignment(HAlign_Left);
|
||||
LabelSlot->SetVerticalAlignment(VAlign_Center);
|
||||
}
|
||||
|
||||
USlider* Slider = WidgetTree->ConstructWidget<USlider>(USlider::StaticClass());
|
||||
Slider->SetValue(FMath::Clamp(Value, 0.0f, 1.0f));
|
||||
if (UHorizontalBoxSlot* SliderSlot = Row->AddChildToHorizontalBox(Slider))
|
||||
{
|
||||
SliderSlot->SetSize(FSlateChildSize(ESlateSizeRule::Fill));
|
||||
SliderSlot->SetHorizontalAlignment(HAlign_Fill);
|
||||
SliderSlot->SetVerticalAlignment(VAlign_Center);
|
||||
}
|
||||
|
||||
return Slider;
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleMasterVolumeChanged(float Value)
|
||||
{
|
||||
MasterVolume = FMath::Clamp(Value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleAmbientVolumeChanged(float Value)
|
||||
{
|
||||
AmbientVolume = FMath::Clamp(Value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleWeatherVolumeChanged(float Value)
|
||||
{
|
||||
WeatherVolume = FMath::Clamp(Value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleEffectsVolumeChanged(float Value)
|
||||
{
|
||||
EffectsVolume = FMath::Clamp(Value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleWildlifeVolumeChanged(float Value)
|
||||
{
|
||||
WildlifeVolume = FMath::Clamp(Value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleUiVolumeChanged(float Value)
|
||||
{
|
||||
UiVolume = FMath::Clamp(Value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::FocusPrimaryButton()
|
||||
{
|
||||
if (PrimaryFocusButton)
|
||||
@@ -582,31 +481,26 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "AgrarianMvpFrontendWidget.generated.h"
|
||||
|
||||
class UButton;
|
||||
class USlider;
|
||||
class USoundBase;
|
||||
class UTextBlock;
|
||||
class UVerticalBox;
|
||||
|
||||
@@ -59,36 +57,6 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI")
|
||||
bool bUseHighContrast = false;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio")
|
||||
TObjectPtr<USoundBase> UiConfirmSound;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio")
|
||||
TObjectPtr<USoundBase> UiBackSound;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio")
|
||||
TObjectPtr<USoundBase> UiSelectionSound;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio")
|
||||
TObjectPtr<USoundBase> UiSaveQuitSound;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio", meta = (ClampMin = "0", ClampMax = "1"))
|
||||
float MasterVolume = 1.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio", meta = (ClampMin = "0", ClampMax = "1"))
|
||||
float AmbientVolume = 0.70f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio", meta = (ClampMin = "0", ClampMax = "1"))
|
||||
float WeatherVolume = 0.75f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio", meta = (ClampMin = "0", ClampMax = "1"))
|
||||
float EffectsVolume = 0.80f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio", meta = (ClampMin = "0", ClampMax = "1"))
|
||||
float WildlifeVolume = 0.70f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|MVP UI|Audio", meta = (ClampMin = "0", ClampMax = "1"))
|
||||
float UiVolume = 0.65f;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|MVP UI")
|
||||
void SetActiveScreen(EAgrarianMvpFrontendScreen NewScreen);
|
||||
|
||||
@@ -122,26 +90,6 @@ private:
|
||||
void RebuildFrontendTree();
|
||||
UTextBlock* AddText(UVerticalBox* Parent, const FText& Text, int32 FontSize, bool bBold, const FLinearColor& Color, float BottomPadding);
|
||||
UButton* AddButton(UVerticalBox* Parent, const FText& Text, const FLinearColor& NormalColor, const FLinearColor& HoveredColor, float BottomPadding);
|
||||
void PlayUiSound(USoundBase* Sound) const;
|
||||
USlider* AddVolumeSlider(UVerticalBox* Parent, const FText& Label, float Value, float BottomPadding);
|
||||
|
||||
UFUNCTION()
|
||||
void HandleMasterVolumeChanged(float Value);
|
||||
|
||||
UFUNCTION()
|
||||
void HandleAmbientVolumeChanged(float Value);
|
||||
|
||||
UFUNCTION()
|
||||
void HandleWeatherVolumeChanged(float Value);
|
||||
|
||||
UFUNCTION()
|
||||
void HandleEffectsVolumeChanged(float Value);
|
||||
|
||||
UFUNCTION()
|
||||
void HandleWildlifeVolumeChanged(float Value);
|
||||
|
||||
UFUNCTION()
|
||||
void HandleUiVolumeChanged(float Value);
|
||||
|
||||
UFUNCTION()
|
||||
void FocusPrimaryButton();
|
||||
|
||||
Reference in New Issue
Block a user