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 "SaveData.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto saveName = TEXT("Save");
|
||||
constexpr int32 saveIndex = 0;
|
||||
}
|
||||
|
||||
UCustomGameInstance* UCustomGameInstance::instance = nullptr;
|
||||
|
||||
void UCustomGameInstance::Init()
|
||||
@ -18,6 +24,10 @@ void UCustomGameInstance::Init()
|
||||
|
||||
instance = this;
|
||||
contentLoader = NewObject<UContentLoader>(this);
|
||||
|
||||
if(auto save = UGameplayStatics::LoadGameFromSlot(saveName, saveIndex))
|
||||
saveData = Cast<USaveData>(save);
|
||||
else
|
||||
saveData = Cast<USaveData>(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass()));
|
||||
}
|
||||
|
||||
@ -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<USaveData>(UGameplayStatics::LoadGameFromSlot(TEXT("Save"), 0));
|
||||
saveData = Cast<USaveData>(UGameplayStatics::LoadGameFromSlot(saveName, saveIndex));
|
||||
if(!saveData)
|
||||
return;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user