MainMenu base, UI port

This commit is contained in:
Oleg Petruny 2024-08-23 12:43:58 +02:00
parent f1e6c37431
commit 1e277a3b5b
56 changed files with 285 additions and 10 deletions

View File

@ -174,3 +174,6 @@ AmbientLPFParameter=
bFMODAudioLinkEnabled=False bFMODAudioLinkEnabled=False
Platforms=() Platforms=()
[/Script/Engine.AudioSettings]
DefaultBaseSoundMix=/Game/Audio/SM_Mixer.SM_Mixer

BIN
Content/Audio/Classes/SC_Master.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Input/Actions/IA_OpenMenu.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/Levels/Test/L_Test.umap (Stored with Git LFS)

Binary file not shown.

BIN
Content/UI/Blueprints/MainMenu/E_MainMenuButtonNames.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/UI/Blueprints/MainMenu/E_MainMenuPages.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Blueprints/MainMenu/UI_MainMenu.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Blueprints/MainMenu/UI_MainMenuCredits.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Blueprints/MainMenu/UI_MainMenuOptions.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/UI/Blueprints/MainMenu/UI_MainMenuOptionsGame.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/UI/Blueprints/UI_Fade.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Blueprints/UI_Loading.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/Classes/UICC_Journal_Text.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/UI/Components/Classes/UICC_Slider.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/UIC_MainMenu_OptionsButton.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/UIC_MainMenu_OptionsCategory.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/UIC_MainMenu_OptionsSlider.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/UIC_MainMenu_PageButton.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/UIC_MainMenu_Title.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/UIC_OptionKeyselector.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Components/UIC_Slider.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/UI/Textures/T_Merge.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -7,6 +7,7 @@
#include "EnhancedInputSubsystems.h" #include "EnhancedInputSubsystems.h"
#include "InputMappingContext.h" #include "InputMappingContext.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "Kismet/KismetSystemLibrary.h"
#include "CommonFunctions.h" #include "CommonFunctions.h"
#include "ContentLoader.h" #include "ContentLoader.h"
@ -141,3 +142,8 @@ void UCustomGameInstanceBase::LoadGame()
UGameplayStatics::OpenLevel(this, saveData->level); UGameplayStatics::OpenLevel(this, saveData->level);
} }
void UCustomGameInstanceBase::ExitGame()
{
UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, true);
}

View File

@ -31,6 +31,8 @@ public:
void SaveGame(FName checkpointName); void SaveGame(FName checkpointName);
UFUNCTION(BlueprintCallable, Category = Save) UFUNCTION(BlueprintCallable, Category = Save)
void LoadGame(); void LoadGame();
UFUNCTION(BlueprintCallable)
void ExitGame();
static UCustomGameInstanceBase* instance; static UCustomGameInstanceBase* instance;

View File

@ -353,10 +353,36 @@ void APlayerBase::ShowInventory()
void APlayerBase::ShowJournal() void APlayerBase::ShowJournal()
{ {
if(GetWorld()->IsPaused())
return;
if(auto WM = AMainGameModeBase::GetWidgetsManager()) if(auto WM = AMainGameModeBase::GetWidgetsManager())
WM->ShowJournal(); WM->ShowJournal();
} }
void APlayerBase::ShowMenu()
{
if(auto WM = AMainGameModeBase::GetWidgetsManager())
{
if(GetWorld()->IsPaused())
{
WM->HideMainMenu();
playerController->SetShowMouseCursor(false);
playerController->SetInputMode(FInputModeGameOnly{});
UnlockPlayer(FPlayerLock::All());
UGameplayStatics::SetGamePaused(GetWorld(), false);
}
else
{
WM->ShowMainMenu();
playerController->SetShowMouseCursor(true);
playerController->SetInputMode(FInputModeGameAndUI{});
LockPlayer(FPlayerLock::All());
UGameplayStatics::SetGamePaused(GetWorld(), true);
}
}
}
FPlayerLock FPlayerLock::All() FPlayerLock FPlayerLock::All()
{ {
FPlayerLock lock; FPlayerLock lock;

View File

@ -94,6 +94,8 @@ protected:
UFUNCTION(BlueprintCallable, Category = Character) UFUNCTION(BlueprintCallable, Category = Character)
void ShowJournal(); void ShowJournal();
UFUNCTION(BlueprintCallable, Category = Character)
void ShowMenu();
class APlayerController* playerController; class APlayerController* playerController;
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)

View File

@ -0,0 +1,5 @@
// Oleg Petruny proprietary.
#include "MainMenuButtonWidget.h"

View File

@ -0,0 +1,16 @@
// Oleg Petruny proprietary.
#pragma once
#include "Blueprint/UserWidget.h"
#include "MainMenuButtonWidget.generated.h"
UCLASS(Blueprintable, Abstract)
class UMainMenuButtonWidget : public UUserWidget
{
GENERATED_BODY()
public:
};

View File

@ -0,0 +1,61 @@
// Oleg Petruny proprietary.
#include "MainMenuWidget.h"
#include "Animation/WidgetAnimation.h"
#include "CustomGameInstanceBase.h"
#include "MainGameModeBase.h"
#include "MainMenuButtonWidget.h"
#include "Widgets/WidgetsManager.h"
bool UMainMenuWidget::Initialize()
{
if(ButtonLoadLastSave)
{
if(auto GI = UCustomGameInstanceBase::GetGameInstance())
{
if(GI->saveData)
{
ButtonLoadLastSave->SetIsEnabled(true);
ButtonLoadLastSave->SetRenderOpacity(1.0f);
}
}
}
//FWidgetAnimationDynamicEvent closeFinished;
//closeFinished.BindDynamic(this, &UMainMenuWidget::Closed);
//BindToAnimationFinished(closeAnimation, closeFinished);
return UUserWidget::Initialize();
}
void UMainMenuWidget::Show(bool fast)
{
SetVisibility(ESlateVisibility::Visible);
//StopAnimation(closeAnimation);
//
//if(fast)
// PlayAnimation(showFastAnimation, 0, 1, EUMGSequencePlayMode::Forward, 1, false);
//else
// PlayAnimation(showFullAnimation, 0, 1, EUMGSequencePlayMode::Forward, 1, false);
//
//OnMainMenuOpeningDelegate.Broadcast();
}
void UMainMenuWidget::Hide()
{
//StopAnimation(showFastAnimation);
//StopAnimation(showFullAnimation);
//PlayAnimation(closeAnimation);
//OnMainMenuClosingDelegate.Broadcast();
SetVisibility(ESlateVisibility::Hidden);
}
void UMainMenuWidget::Closed()
{
SetVisibility(ESlateVisibility::Hidden);
//OnMainMenuClosedDelegate.Broadcast();
}

View File

@ -0,0 +1,56 @@
// Oleg Petruny proprietary.
#pragma once
#include "Widgets/ResolutionResponsiveUserWidget.h"
#include "MainMenuWidget.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FMainMenuOpeningDelegate);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FMainMenuClosingDelegate);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FMainMenuClosedDelegate);
UCLASS(Blueprintable, Abstract)
class UMainMenuWidget : public UUserWidget
{
GENERATED_BODY()
public:
virtual bool Initialize() override;
UFUNCTION(BlueprintCallable)
void Show(bool fast = true);
UFUNCTION(BlueprintCallable)
void Hide();
UPROPERTY(BlueprintAssignable)
FMainMenuOpeningDelegate OnMainMenuOpeningDelegate;
UPROPERTY(BlueprintAssignable)
FMainMenuClosedDelegate OnMainMenuClosingDelegate;
UPROPERTY(BlueprintAssignable)
FMainMenuClosedDelegate OnMainMenuClosedDelegate;
UPROPERTY(meta = (BindWidget))
class UMainMenuButtonWidget* ButtonContinue;
UPROPERTY(meta = (BindWidget))
class UMainMenuButtonWidget* ButtonLoadLastSave;
UPROPERTY(meta = (BindWidget))
class UMainMenuButtonWidget* ButtonNewGame;
UPROPERTY(meta = (BindWidget))
class UMainMenuButtonWidget* ButtonOptions;
UPROPERTY(meta = (BindWidget))
class UMainMenuButtonWidget* ButtonCredits;
UPROPERTY(meta = (BindWidget))
class UMainMenuButtonWidget* ButtonExit;
UPROPERTY(Transient, meta = (BindWidgetAnim))
class UWidgetAnimation* showFullAnimation;
UPROPERTY(Transient, meta = (BindWidgetAnim))
class UWidgetAnimation* showFastAnimation;
UPROPERTY(Transient, meta = (BindWidgetAnim))
class UWidgetAnimation* closeAnimation;
protected:
UFUNCTION()
void Closed();
};

View File

@ -21,6 +21,7 @@
#include "Widgets/InteractableHintWidgetManager.h" #include "Widgets/InteractableHintWidgetManager.h"
#include "Widgets/InventoryWidget.h" #include "Widgets/InventoryWidget.h"
#include "Widgets/JournalWidget.h" #include "Widgets/JournalWidget.h"
#include "Widgets/MainMenu/MainMenuWidget.h"
void UWidgetsManager::Init() void UWidgetsManager::Init()
{ {
@ -42,6 +43,12 @@ void UWidgetsManager::Init()
instance->AddToViewport(); instance->AddToViewport();
} }
} }
if(auto instance = CreateWidget<UMainMenuWidget>(PC, mainMenuWidgetClass))
{
mainMenuWidget = instance;
mainMenuWidget->SetVisibility(ESlateVisibility::Hidden);
mainMenuWidget->AddToViewport(8);
}
if(auto instance = CreateWidget<UInteractableHintWidgetManager>(PC, interactableHintWidgetManagerClass)) if(auto instance = CreateWidget<UInteractableHintWidgetManager>(PC, interactableHintWidgetManagerClass))
{ {
interactableHintWidgetManager = instance; interactableHintWidgetManager = instance;
@ -130,6 +137,18 @@ void UWidgetsManager::UpdateWidgetsOwner()
void UWidgetsManager::ShowMainMenu(bool pause)
{
mainMenuWidget->Show(pause);
}
void UWidgetsManager::HideMainMenu()
{
mainMenuWidget->Hide();
}
void UWidgetsManager::ShowInteractionHints(const UInteractableModificator* modificator) void UWidgetsManager::ShowInteractionHints(const UInteractableModificator* modificator)
{ {
if(interactableHintWidgetManager) if(interactableHintWidgetManager)

View File

@ -21,6 +21,9 @@ public:
void HideWidgets(); void HideWidgets();
void UpdateWidgetsOwner(); void UpdateWidgetsOwner();
void ShowMainMenu(bool pause = true);
void HideMainMenu();
UFUNCTION(BlueprintCallable, Category = WidgetsManager) UFUNCTION(BlueprintCallable, Category = WidgetsManager)
void ShowInteractionHints(const class UInteractableModificator* modificator = nullptr); void ShowInteractionHints(const class UInteractableModificator* modificator = nullptr);
UFUNCTION(BlueprintCallable, Category = WidgetsManager) UFUNCTION(BlueprintCallable, Category = WidgetsManager)
@ -53,6 +56,10 @@ protected:
TSet<TSubclassOf<class UUserWidget>> overlayWidgets; // hidden in pause, cutscene TSet<TSubclassOf<class UUserWidget>> overlayWidgets; // hidden in pause, cutscene
TArray<class UUserWidget*> overlayWidgetsInstances; TArray<class UUserWidget*> overlayWidgetsInstances;
UPROPERTY(EditDefaultsOnly)
TSubclassOf<class UMainMenuWidget> mainMenuWidgetClass;
class UMainMenuWidget* mainMenuWidget = nullptr;
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
TSubclassOf<class UInteractableHintWidgetManager> interactableHintWidgetManagerClass; // hidden in cutscene TSubclassOf<class UInteractableHintWidgetManager> interactableHintWidgetManagerClass; // hidden in cutscene
class UInteractableHintWidgetManager* interactableHintWidgetManager = nullptr; class UInteractableHintWidgetManager* interactableHintWidgetManager = nullptr;