diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuButtonNames.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuButtonNames.uasset index 38dd715..5fc0b85 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuButtonNames.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/E_MainMenuButtonNames.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ef4f7af31939d83d337b5e3664f3c6c3dda992897b3dc77895f1c98456083420 -size 4447 +oid sha256:116dc3eda9899a70ce02396ea2b15067238e5cf710ecec9d6738151c50a1f6dd +size 4059 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenu.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenu.uasset index 22d4b4f..5bba889 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenu.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/UI_MainMenu.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ae4f8d697d46434366827562a388480f4b09f9fe022e12ba3b5f7aade8ffbc4 -size 174730 +oid sha256:c8e834d1b704d2cf4587441001e9f1022d12dcc607e19141e7abed76e2e47adf +size 192994 diff --git a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_MainMenu_PageButton.uasset b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_MainMenu_PageButton.uasset index 994ba3e..56e6256 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_MainMenu_PageButton.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_MainMenu_PageButton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f3ca9755fe19acf488007b1ed6ca99f8ef93f8bfce932d0939fab5502b136e55 +oid sha256:ec23b255a074720b88a6fde5b0a4fca89ea04488704494abefe09cd88f11241c size 358593 diff --git a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset index 38918f0..eae415d 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Components/UIC_Slider.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5932ca564d4f73b9e5c0b3e22a096cf0ce974808343bbb40ced10fe79414de99 -size 86177 +oid sha256:e9b29efef1b67fb199f51f19c9f9e44d47079aa0342840d5dc902ff7a944d70b +size 86429 diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp index cfe6c93..b606fb4 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp @@ -10,6 +10,12 @@ #include "PlayerBase.h" #include "SaveData.h" +namespace +{ + constexpr auto saveName = TEXT("Save"); + constexpr int32 saveIndex = 0; +} + UCustomGameInstance* UCustomGameInstance::instance = nullptr; void UCustomGameInstance::Init() @@ -18,7 +24,11 @@ void UCustomGameInstance::Init() instance = this; contentLoader = NewObject(this); - saveData = Cast(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass())); + + if(auto save = UGameplayStatics::LoadGameFromSlot(saveName, saveIndex)) + saveData = Cast(save); + else + saveData = Cast(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass())); } UCustomGameInstance* UCustomGameInstance::Get() @@ -34,6 +44,14 @@ UContentLoader* UCustomGameInstance::GetContentLoader() return nullptr; } +bool UCustomGameInstance::IsGameSaved() +{ + if(auto GI = Get()) + return GI->saveData != nullptr; + + return false; +} + void UCustomGameInstance::SaveGame(FName checkpointName) { auto levelScript = ALevelBase::Get(); @@ -56,12 +74,12 @@ void UCustomGameInstance::SaveGame(FName checkpointName) else saveData->playerRightPocketItem = FName(TEXT("")); - UGameplayStatics::SaveGameToSlot(saveData, TEXT("Save"), 0); + UGameplayStatics::SaveGameToSlot(saveData, saveName, saveIndex); } void UCustomGameInstance::LoadGame() { - saveData = Cast(UGameplayStatics::LoadGameFromSlot(TEXT("Save"), 0)); + saveData = Cast(UGameplayStatics::LoadGameFromSlot(saveName, saveIndex)); if(!saveData) return; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h index a810e77..1d3b441 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h @@ -23,9 +23,11 @@ public: UFUNCTION(BlueprintPure, meta = (DisplayName = "Get Custom Game Instance")) static UCustomGameInstance* Get(); - UFUNCTION(BlueprintPure) static class UContentLoader* GetContentLoader(); + /** Return true is save data are present and valid */ + UFUNCTION(BlueprintPure) + static bool IsGameSaved(); UFUNCTION(BlueprintCallable, Category = Save) void SaveGame(FName checkpointName); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp index f9c190c..acff3d2 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.cpp @@ -11,16 +11,6 @@ bool UMainMenuWidget::Initialize() { - if(ButtonLoadLastSave) - { - auto GI = UCustomGameInstance::Get(); - if(GI && GI->saveData) - { - ButtonLoadLastSave->SetIsEnabled(true); - ButtonLoadLastSave->SetRenderOpacity(1.0f); - } - } - //FWidgetAnimationDynamicEvent closeFinished; //closeFinished.BindDynamic(this, &UMainMenuWidget::Closed); //BindToAnimationFinished(closeAnimation, closeFinished); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.h index a5bccff..2c97df6 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Widgets/MainMenu/MainMenuWidget.h @@ -30,13 +30,9 @@ public: UPROPERTY(BlueprintAssignable) FMainMenuClosedDelegate OnMainMenuClosedDelegate; - UPROPERTY(meta = (BindWidget)) + UPROPERTY(BlueprintReadWrite, 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;