Add pause save exit settings shell
This commit is contained in:
@@ -87,6 +87,33 @@ FReply UAgrarianMvpFrontendWidget::NativeOnKeyDown(const FGeometry& InGeometry,
|
||||
SaveAndQuit();
|
||||
return FReply::Handled();
|
||||
}
|
||||
|
||||
if (Key == EKeys::S)
|
||||
{
|
||||
SaveGame();
|
||||
return FReply::Handled();
|
||||
}
|
||||
|
||||
if (Key == EKeys::O)
|
||||
{
|
||||
SetActiveScreen(EAgrarianMvpFrontendScreen::Settings);
|
||||
return FReply::Handled();
|
||||
}
|
||||
|
||||
if (Key == EKeys::X)
|
||||
{
|
||||
QuitWithoutSaving();
|
||||
return FReply::Handled();
|
||||
}
|
||||
}
|
||||
else if (ActiveScreen == EAgrarianMvpFrontendScreen::Settings || ActiveScreen == EAgrarianMvpFrontendScreen::GameSaved)
|
||||
{
|
||||
const FKey Key = InKeyEvent.GetKey();
|
||||
if (Key == EKeys::Escape || Key == EKeys::BackSpace || Key == EKeys::Enter || Key == EKeys::SpaceBar)
|
||||
{
|
||||
SetActiveScreen(EAgrarianMvpFrontendScreen::MainMenu);
|
||||
return FReply::Handled();
|
||||
}
|
||||
}
|
||||
else if (ActiveScreen == EAgrarianMvpFrontendScreen::SavingAndQuit)
|
||||
{
|
||||
@@ -147,6 +174,17 @@ void UAgrarianMvpFrontendWidget::SaveAndQuit()
|
||||
ExecuteSaveAndQuit();
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::SaveGame()
|
||||
{
|
||||
ExecuteSaveGame();
|
||||
SetActiveScreen(EAgrarianMvpFrontendScreen::GameSaved);
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::QuitWithoutSaving()
|
||||
{
|
||||
ExecuteQuitWithoutSaving();
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::ExecuteSaveAndQuit()
|
||||
{
|
||||
if (APlayerController* PlayerController = GetOwningPlayer())
|
||||
@@ -156,6 +194,22 @@ void UAgrarianMvpFrontendWidget::ExecuteSaveAndQuit()
|
||||
}
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::ExecuteSaveGame()
|
||||
{
|
||||
if (APlayerController* PlayerController = GetOwningPlayer())
|
||||
{
|
||||
PlayerController->ConsoleCommand(TEXT("AgrarianSaveWorld"));
|
||||
}
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::ExecuteQuitWithoutSaving()
|
||||
{
|
||||
if (APlayerController* PlayerController = GetOwningPlayer())
|
||||
{
|
||||
PlayerController->ConsoleCommand(TEXT("quit"));
|
||||
}
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::ContinueFromActiveScreen()
|
||||
{
|
||||
if (ActiveScreen == EAgrarianMvpFrontendScreen::CharacterSelection)
|
||||
@@ -181,6 +235,12 @@ void UAgrarianMvpFrontendWidget::ContinueFromActiveScreen()
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveScreen == EAgrarianMvpFrontendScreen::Settings || ActiveScreen == EAgrarianMvpFrontendScreen::GameSaved)
|
||||
{
|
||||
SetActiveScreen(EAgrarianMvpFrontendScreen::MainMenu);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveScreen == EAgrarianMvpFrontendScreen::MainMenu)
|
||||
{
|
||||
CompleteFrontendFlow();
|
||||
@@ -200,6 +260,11 @@ void UAgrarianMvpFrontendWidget::ReturnFromActiveScreen()
|
||||
{
|
||||
CompleteFrontendFlow();
|
||||
}
|
||||
|
||||
if (ActiveScreen == EAgrarianMvpFrontendScreen::Settings || ActiveScreen == EAgrarianMvpFrontendScreen::GameSaved)
|
||||
{
|
||||
SetActiveScreen(EAgrarianMvpFrontendScreen::MainMenu);
|
||||
}
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::CompleteFrontendFlow()
|
||||
@@ -274,13 +339,23 @@ void UAgrarianMvpFrontendWidget::RebuildFrontendTree()
|
||||
{
|
||||
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("Gameplay is paused while this menu is active.")), 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, 34.0f * Scale);
|
||||
PrimaryFocusButton = AddButton(Panel, FText::FromString(TEXT("Resume")), ButtonColor, ButtonHoverColor, 16.0f * Scale);
|
||||
PrimaryFocusButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandlePrimaryActionClicked);
|
||||
|
||||
UButton* QuitButton = AddButton(Panel, FText::FromString(TEXT("Save & Quit")), QuitButtonColor, FLinearColor(0.58f, 0.28f, 0.22f, 1.0f), 34.0f * Scale);
|
||||
UButton* SaveButton = AddButton(Panel, FText::FromString(TEXT("Save Game")), SecondaryButtonColor, ButtonHoverColor, 12.0f * Scale);
|
||||
SaveButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleSaveGameClicked);
|
||||
|
||||
UButton* SettingsButton = AddButton(Panel, FText::FromString(TEXT("Settings")), SecondaryButtonColor, ButtonHoverColor, 12.0f * Scale);
|
||||
SettingsButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleSettingsClicked);
|
||||
|
||||
UButton* QuitButton = AddButton(Panel, FText::FromString(TEXT("Save & Exit")), QuitButtonColor, FLinearColor(0.58f, 0.28f, 0.22f, 1.0f), 12.0f * Scale);
|
||||
QuitButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleSaveAndQuitClicked);
|
||||
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);
|
||||
|
||||
UButton* QuitWithoutSavingButton = AddButton(Panel, FText::FromString(TEXT("Quit Without Saving")), SecondaryButtonColor, FLinearColor(0.46f, 0.20f, 0.16f, 1.0f), 28.0f * Scale);
|
||||
QuitWithoutSavingButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleQuitWithoutSavingClicked);
|
||||
|
||||
AddText(Panel, FText::FromString(TEXT("Esc resumes. S saves. O opens settings. Q saves and exits. X exits without saving.")), FMath::RoundToInt(16.0f * Scale), false, MutedTextColor, 0.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -390,6 +465,26 @@ void UAgrarianMvpFrontendWidget::RebuildFrontendTree()
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveScreen == EAgrarianMvpFrontendScreen::GameSaved)
|
||||
{
|
||||
AddText(Panel, FText::FromString(TEXT("Game Saved")), FMath::RoundToInt(20.0f * Scale), true, AccentColor, 6.0f * Scale);
|
||||
AddText(Panel, FText::FromString(TEXT("World state saved")), FMath::RoundToInt(34.0f * Scale), true, TextColor, 8.0f * Scale);
|
||||
AddText(Panel, FText::FromString(TEXT("Return to the pause menu before resuming or exiting.")), FMath::RoundToInt(18.0f * Scale), false, MutedTextColor, 28.0f * Scale);
|
||||
PrimaryFocusButton = AddButton(Panel, FText::FromString(TEXT("Back to Pause Menu")), ButtonColor, ButtonHoverColor, 0.0f);
|
||||
PrimaryFocusButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleBackClicked);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActiveScreen == EAgrarianMvpFrontendScreen::Settings)
|
||||
{
|
||||
AddText(Panel, FText::FromString(TEXT("Settings")), FMath::RoundToInt(20.0f * Scale), true, AccentColor, 6.0f * Scale);
|
||||
AddText(Panel, FText::FromString(TEXT("Player Options")), FMath::RoundToInt(34.0f * Scale), true, TextColor, 8.0f * Scale);
|
||||
AddText(Panel, FText::FromString(TEXT("Interface scale and high contrast are available now through tester commands. Units, controls, hardware, audio, and accessibility options are queued for the settings roadmap.")), FMath::RoundToInt(18.0f * Scale), false, MutedTextColor, 28.0f * Scale);
|
||||
PrimaryFocusButton = AddButton(Panel, FText::FromString(TEXT("Back to Pause Menu")), ButtonColor, ButtonHoverColor, 0.0f);
|
||||
PrimaryFocusButton->OnClicked.AddDynamic(this, &UAgrarianMvpFrontendWidget::HandleBackClicked);
|
||||
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);
|
||||
@@ -485,6 +580,30 @@ void UAgrarianMvpFrontendWidget::HandleSaveAndQuitClicked()
|
||||
});
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleSaveGameClicked()
|
||||
{
|
||||
DeferFrontendAction([this]()
|
||||
{
|
||||
SaveGame();
|
||||
});
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleSettingsClicked()
|
||||
{
|
||||
DeferFrontendAction([this]()
|
||||
{
|
||||
SetActiveScreen(EAgrarianMvpFrontendScreen::Settings);
|
||||
});
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleQuitWithoutSavingClicked()
|
||||
{
|
||||
DeferFrontendAction([this]()
|
||||
{
|
||||
QuitWithoutSaving();
|
||||
});
|
||||
}
|
||||
|
||||
void UAgrarianMvpFrontendWidget::HandleMaleCharacterClicked()
|
||||
{
|
||||
DeferFrontendAction([this]()
|
||||
|
||||
@@ -17,6 +17,8 @@ enum class EAgrarianMvpFrontendScreen : uint8
|
||||
CharacterSelection,
|
||||
JoinServer,
|
||||
Loading,
|
||||
Settings,
|
||||
GameSaved,
|
||||
SavingAndQuit
|
||||
};
|
||||
|
||||
@@ -75,9 +77,15 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|MVP UI")
|
||||
void BackFromActiveScreen();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|MVP UI")
|
||||
void SaveGame();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|MVP UI")
|
||||
void SaveAndQuit();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|MVP UI")
|
||||
void QuitWithoutSaving();
|
||||
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
@@ -96,6 +104,8 @@ private:
|
||||
|
||||
UFUNCTION()
|
||||
void ExecuteSaveAndQuit();
|
||||
void ExecuteSaveGame();
|
||||
void ExecuteQuitWithoutSaving();
|
||||
|
||||
UFUNCTION()
|
||||
void HandlePrimaryActionClicked();
|
||||
@@ -106,6 +116,15 @@ private:
|
||||
UFUNCTION()
|
||||
void HandleSaveAndQuitClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void HandleSaveGameClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void HandleSettingsClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void HandleQuitWithoutSavingClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void HandleMaleCharacterClicked();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user