Segment MVP startup and pause flow

This commit is contained in:
2026-05-19 10:20:12 -07:00
parent af1edb51bc
commit de02b20786
7 changed files with 136 additions and 10 deletions
@@ -87,6 +87,7 @@ void AAgrarianGamePlayerController::BeginPlay()
{
SetIgnoreMoveInput(true);
SetIgnoreLookInput(true);
SetInputMode(FInputModeUIOnly());
bShowMouseCursor = false;
GetWorldTimerManager().SetTimer(
MvpFrontendStartupTimerHandle,
@@ -186,7 +187,7 @@ void AAgrarianGamePlayerController::ShowMvpFrontend()
{
MvpFrontendWidget->AddToPlayerScreen(10);
}
SetInputMode(FInputModeGameAndUI().SetWidgetToFocus(MvpFrontendWidget->TakeWidget()).SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock));
SetInputMode(FInputModeUIOnly().SetWidgetToFocus(MvpFrontendWidget->TakeWidget()).SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock));
bShowMouseCursor = true;
SetIgnoreMoveInput(true);
SetIgnoreLookInput(true);
@@ -223,7 +224,7 @@ void AAgrarianGamePlayerController::ShowMvpPauseMenu()
}
MvpFrontendWidget->SetActiveScreen(EAgrarianMvpFrontendScreen::MainMenu);
SetInputMode(FInputModeGameAndUI().SetWidgetToFocus(MvpFrontendWidget->TakeWidget()).SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock));
SetInputMode(FInputModeUIOnly().SetWidgetToFocus(MvpFrontendWidget->TakeWidget()).SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock));
bShowMouseCursor = true;
SetIgnoreMoveInput(true);
SetIgnoreLookInput(true);
@@ -548,7 +549,14 @@ void AAgrarianGamePlayerController::AgrarianShowMvpScreen(FName ScreenName)
return;
}
ClientMessage(TEXT("Usage: AgrarianShowMvpScreen main|character|join|loading"));
if (ScreenName == TEXT("saving") || ScreenName == TEXT("SavingAndQuit"))
{
MvpFrontendWidget->SetActiveScreen(EAgrarianMvpFrontendScreen::SavingAndQuit);
ClientMessage(TEXT("MVP frontend screen: saving and quit."));
return;
}
ClientMessage(TEXT("Usage: AgrarianShowMvpScreen main|character|join|loading|saving"));
}
void AAgrarianGamePlayerController::AgrarianTravel(float X, float Y, float Z)
@@ -15,6 +15,7 @@
#include "GameFramework/PlayerController.h"
#include "InputCoreTypes.h"
#include "Styling/CoreStyle.h"
#include "TimerManager.h"
namespace
{
@@ -102,6 +103,10 @@ FReply UAgrarianMvpFrontendWidget::NativeOnKeyDown(const FGeometry& InGeometry,
return FReply::Handled();
}
}
else if (ActiveScreen == EAgrarianMvpFrontendScreen::SavingAndQuit)
{
return FReply::Handled();
}
return Super::NativeOnKeyDown(InGeometry, InKeyEvent);
}
@@ -145,6 +150,19 @@ void UAgrarianMvpFrontendWidget::BackFromActiveScreen()
}
void UAgrarianMvpFrontendWidget::SaveAndQuit()
{
SetActiveScreen(EAgrarianMvpFrontendScreen::SavingAndQuit);
if (UWorld* World = GetWorld())
{
FTimerHandle SaveAndQuitTimerHandle;
World->GetTimerManager().SetTimer(SaveAndQuitTimerHandle, this, &UAgrarianMvpFrontendWidget::ExecuteSaveAndQuit, 0.35f, false);
return;
}
ExecuteSaveAndQuit();
}
void UAgrarianMvpFrontendWidget::ExecuteSaveAndQuit()
{
if (APlayerController* PlayerController = GetOwningPlayer())
{
@@ -173,9 +191,20 @@ void UAgrarianMvpFrontendWidget::ContinueFromActiveScreen()
return;
}
if (ActiveScreen == EAgrarianMvpFrontendScreen::SavingAndQuit)
{
return;
}
if (ActiveScreen == EAgrarianMvpFrontendScreen::MainMenu)
{
CompleteFrontendFlow();
return;
}
if (ActiveScreen == EAgrarianMvpFrontendScreen::SavingAndQuit)
{
return;
}
}
@@ -249,8 +278,9 @@ void UAgrarianMvpFrontendWidget::RebuildFrontendTree()
if (ActiveScreen == EAgrarianMvpFrontendScreen::MainMenu)
{
AddText(Panel, FText::FromString(TEXT("Pause Menu")), FMath::RoundToInt(20.0f * Scale), true, AccentColor, 6.0f * Scale);
AddText(Panel, MainMenuTitle, FMath::RoundToInt(54.0f * Scale), true, TextColor, 6.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Game menu")), FMath::RoundToInt(22.0f * Scale), false, MutedTextColor, 72.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Gameplay is paused while this menu is active.")), FMath::RoundToInt(22.0f * Scale), false, MutedTextColor, 72.0f * Scale);
PrimaryFocusButton = AddButton(Panel, FText::FromString(TEXT("Resume")), ButtonColor, ButtonHoverColor, 16.0f * Scale);
PrimaryFocusButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandlePrimaryActionClicked);
PrimaryFocusButton->OnHovered.AddDynamic(this, &UAgrarianMvpFrontendWidget::FocusPrimaryButton);
@@ -263,6 +293,7 @@ void UAgrarianMvpFrontendWidget::RebuildFrontendTree()
if (ActiveScreen == EAgrarianMvpFrontendScreen::CharacterSelection)
{
AddText(Panel, FText::FromString(TEXT("Character Selection")), FMath::RoundToInt(18.0f * Scale), true, AccentColor, 6.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Choose your first pioneer")), FMath::RoundToInt(34.0f * Scale), true, TextColor, 6.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Select the person who will step into Ground Zero.")), FMath::RoundToInt(18.0f * Scale), false, MutedTextColor, 24.0f * Scale);
@@ -311,6 +342,7 @@ void UAgrarianMvpFrontendWidget::RebuildFrontendTree()
if (ActiveScreen == EAgrarianMvpFrontendScreen::JoinServer)
{
AddText(Panel, FText::FromString(TEXT("Server Join")), FMath::RoundToInt(18.0f * Scale), true, AccentColor, 6.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Join MVP server")), FMath::RoundToInt(34.0f * Scale), true, TextColor, 8.0f * Scale);
AddText(Panel, FText::Format(FText::FromString(TEXT("{0}: {1}")), GetSelectedRoleLabel(), GetSelectedCharacterLabel()), FMath::RoundToInt(18.0f * Scale), false, MutedTextColor, 36.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Server address")), FMath::RoundToInt(15.0f * Scale), false, MutedTextColor, 4.0f * Scale);
@@ -359,6 +391,15 @@ void UAgrarianMvpFrontendWidget::RebuildFrontendTree()
return;
}
if (ActiveScreen == EAgrarianMvpFrontendScreen::SavingAndQuit)
{
AddText(Panel, FText::FromString(TEXT("Saving World")), FMath::RoundToInt(20.0f * Scale), true, AccentColor, 6.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Writing the current world state")), FMath::RoundToInt(34.0f * Scale), true, TextColor, 8.0f * Scale);
AddText(Panel, FText::FromString(TEXT("The demo will close after the save command is issued.")), FMath::RoundToInt(18.0f * Scale), false, MutedTextColor, 0.0f);
return;
}
AddText(Panel, FText::FromString(TEXT("Loading Segment")), FMath::RoundToInt(18.0f * Scale), true, AccentColor, 6.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Preparing Ground Zero")), FMath::RoundToInt(34.0f * Scale), true, TextColor, 8.0f * Scale);
AddText(Panel, FText::FromString(TEXT("Loading terrain, weather, survival state, and server session data.")), FMath::RoundToInt(18.0f * Scale), false, MutedTextColor, 70.0f * Scale);
AddText(Panel, FText::Format(FText::FromString(TEXT("{0}: {1} | Server: {2}")), GetSelectedRoleLabel(), GetSelectedCharacterLabel(), JoinServerAddress), FMath::RoundToInt(18.0f * Scale), false, TextColor, 34.0f * Scale);
@@ -16,7 +16,8 @@ enum class EAgrarianMvpFrontendScreen : uint8
MainMenu,
CharacterSelection,
JoinServer,
Loading
Loading,
SavingAndQuit
};
UENUM(BlueprintType)
@@ -93,6 +94,9 @@ private:
UFUNCTION()
void FocusPrimaryButton();
UFUNCTION()
void ExecuteSaveAndQuit();
UFUNCTION()
void HandlePrimaryActionClicked();