Fix Main menu
This commit is contained in:
parent
ae0fad52a2
commit
498dc7ec8e
BIN
UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuButtonNames.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuButtonNames.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenu.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenu.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/UI/Components/UIC_MainMenu_PageButton.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/UI/Components/UIC_MainMenu_PageButton.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset
(Stored with Git LFS)
Binary file not shown.
@ -10,6 +10,12 @@
|
|||||||
#include "PlayerBase.h"
|
#include "PlayerBase.h"
|
||||||
#include "SaveData.h"
|
#include "SaveData.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
constexpr auto saveName = TEXT("Save");
|
||||||
|
constexpr int32 saveIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
UCustomGameInstance* UCustomGameInstance::instance = nullptr;
|
UCustomGameInstance* UCustomGameInstance::instance = nullptr;
|
||||||
|
|
||||||
void UCustomGameInstance::Init()
|
void UCustomGameInstance::Init()
|
||||||
@ -18,6 +24,10 @@ void UCustomGameInstance::Init()
|
|||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
contentLoader = NewObject<UContentLoader>(this);
|
contentLoader = NewObject<UContentLoader>(this);
|
||||||
|
|
||||||
|
if(auto save = UGameplayStatics::LoadGameFromSlot(saveName, saveIndex))
|
||||||
|
saveData = Cast<USaveData>(save);
|
||||||
|
else
|
||||||
saveData = Cast<USaveData>(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass()));
|
saveData = Cast<USaveData>(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +44,14 @@ UContentLoader* UCustomGameInstance::GetContentLoader()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UCustomGameInstance::IsGameSaved()
|
||||||
|
{
|
||||||
|
if(auto GI = Get())
|
||||||
|
return GI->saveData != nullptr;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void UCustomGameInstance::SaveGame(FName checkpointName)
|
void UCustomGameInstance::SaveGame(FName checkpointName)
|
||||||
{
|
{
|
||||||
auto levelScript = ALevelBase::Get();
|
auto levelScript = ALevelBase::Get();
|
||||||
@ -56,12 +74,12 @@ void UCustomGameInstance::SaveGame(FName checkpointName)
|
|||||||
else
|
else
|
||||||
saveData->playerRightPocketItem = FName(TEXT(""));
|
saveData->playerRightPocketItem = FName(TEXT(""));
|
||||||
|
|
||||||
UGameplayStatics::SaveGameToSlot(saveData, TEXT("Save"), 0);
|
UGameplayStatics::SaveGameToSlot(saveData, saveName, saveIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UCustomGameInstance::LoadGame()
|
void UCustomGameInstance::LoadGame()
|
||||||
{
|
{
|
||||||
saveData = Cast<USaveData>(UGameplayStatics::LoadGameFromSlot(TEXT("Save"), 0));
|
saveData = Cast<USaveData>(UGameplayStatics::LoadGameFromSlot(saveName, saveIndex));
|
||||||
if(!saveData)
|
if(!saveData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -23,9 +23,11 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "Get Custom Game Instance"))
|
UFUNCTION(BlueprintPure, meta = (DisplayName = "Get Custom Game Instance"))
|
||||||
static UCustomGameInstance* Get();
|
static UCustomGameInstance* Get();
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
static class UContentLoader* GetContentLoader();
|
static class UContentLoader* GetContentLoader();
|
||||||
|
/** Return true is save data are present and valid */
|
||||||
|
UFUNCTION(BlueprintPure)
|
||||||
|
static bool IsGameSaved();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = Save)
|
UFUNCTION(BlueprintCallable, Category = Save)
|
||||||
void SaveGame(FName checkpointName);
|
void SaveGame(FName checkpointName);
|
||||||
|
@ -11,16 +11,6 @@
|
|||||||
|
|
||||||
bool UMainMenuWidget::Initialize()
|
bool UMainMenuWidget::Initialize()
|
||||||
{
|
{
|
||||||
if(ButtonLoadLastSave)
|
|
||||||
{
|
|
||||||
auto GI = UCustomGameInstance::Get();
|
|
||||||
if(GI && GI->saveData)
|
|
||||||
{
|
|
||||||
ButtonLoadLastSave->SetIsEnabled(true);
|
|
||||||
ButtonLoadLastSave->SetRenderOpacity(1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//FWidgetAnimationDynamicEvent closeFinished;
|
//FWidgetAnimationDynamicEvent closeFinished;
|
||||||
//closeFinished.BindDynamic(this, &UMainMenuWidget::Closed);
|
//closeFinished.BindDynamic(this, &UMainMenuWidget::Closed);
|
||||||
//BindToAnimationFinished(closeAnimation, closeFinished);
|
//BindToAnimationFinished(closeAnimation, closeFinished);
|
||||||
|
@ -30,13 +30,9 @@ public:
|
|||||||
UPROPERTY(BlueprintAssignable)
|
UPROPERTY(BlueprintAssignable)
|
||||||
FMainMenuClosedDelegate OnMainMenuClosedDelegate;
|
FMainMenuClosedDelegate OnMainMenuClosedDelegate;
|
||||||
|
|
||||||
UPROPERTY(meta = (BindWidget))
|
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||||
class UMainMenuButtonWidget* ButtonContinue;
|
class UMainMenuButtonWidget* ButtonContinue;
|
||||||
UPROPERTY(meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
class UMainMenuButtonWidget* ButtonLoadLastSave;
|
|
||||||
UPROPERTY(meta = (BindWidget))
|
|
||||||
class UMainMenuButtonWidget* ButtonNewGame;
|
|
||||||
UPROPERTY(meta = (BindWidget))
|
|
||||||
class UMainMenuButtonWidget* ButtonOptions;
|
class UMainMenuButtonWidget* ButtonOptions;
|
||||||
UPROPERTY(meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
class UMainMenuButtonWidget* ButtonCredits;
|
class UMainMenuButtonWidget* ButtonCredits;
|
||||||
|
Loading…
Reference in New Issue
Block a user