You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rnx #rb none #ROBOMERGE-OWNER: ryan.durand #ROBOMERGE-AUTHOR: ryan.durand #ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900 #ROBOMERGE-BOT: (v613-10869866) [CL 10870549 by ryan durand in Main branch]
80 lines
2.1 KiB
C++
80 lines
2.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "IOSSaveGameSystem.h"
|
|
#include "GameDelegates.h"
|
|
|
|
DEFINE_LOG_CATEGORY_STATIC(LogIOSSaveGame, Log, All);
|
|
|
|
//
|
|
// Implementation members
|
|
//
|
|
|
|
FIOSSaveGameSystem::FIOSSaveGameSystem()
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
FIOSSaveGameSystem::~FIOSSaveGameSystem()
|
|
{
|
|
Shutdown();
|
|
}
|
|
|
|
void FIOSSaveGameSystem::Initialize()
|
|
{
|
|
}
|
|
|
|
void FIOSSaveGameSystem::Shutdown()
|
|
{
|
|
}
|
|
|
|
ISaveGameSystem::ESaveExistsResult FIOSSaveGameSystem::DoesSaveGameExistWithResult(const TCHAR* Name, const int32 UserIndex)
|
|
{
|
|
if (IFileManager::Get().FileSize(*GetSaveGamePath(Name)) >= 0)
|
|
{
|
|
return ESaveExistsResult::OK;
|
|
}
|
|
return ESaveExistsResult::DoesNotExist;
|
|
}
|
|
|
|
bool FIOSSaveGameSystem::SaveGameNoCloud(const TCHAR* Name, const TArray<uint8>& Data)
|
|
{
|
|
return FFileHelper::SaveArrayToFile(Data, *GetSaveGamePath(Name));
|
|
}
|
|
|
|
bool FIOSSaveGameSystem::SaveGame(bool bAttemptToUseUI, const TCHAR* Name, const int32 UserIndex, const TArray<uint8>& Data)
|
|
{
|
|
// send to the iCloud, if enabled
|
|
OnWriteUserCloudFileBeginDelegate.ExecuteIfBound(FString(Name), Data);
|
|
|
|
return FFileHelper::SaveArrayToFile(Data, *GetSaveGamePath(Name));
|
|
}
|
|
|
|
bool FIOSSaveGameSystem::LoadGame(bool bAttemptToUseUI, const TCHAR* Name, const int32 UserIndex, TArray<uint8>& Data)
|
|
{
|
|
// try to read it from the iCloud, if enabled
|
|
OnReadUserCloudFileBeginDelegate.ExecuteIfBound(FString(Name), Data);
|
|
|
|
if (Data.Num() > 0)
|
|
{
|
|
// we've received data from the iCloud, the save file was overwritten
|
|
return true;
|
|
}
|
|
|
|
// no iCloud data, read from the local storage
|
|
return FFileHelper::LoadFileToArray(Data, *GetSaveGamePath(Name));
|
|
}
|
|
|
|
bool FIOSSaveGameSystem::DeleteGame(bool bAttemptToUseUI, const TCHAR* Name, const int32 UserIndex)
|
|
{
|
|
// delete the file from the iCloud
|
|
OnDeleteUserCloudFileBeginDelegate.ExecuteIfBound(FString(Name));
|
|
|
|
// delete the file from the local storage
|
|
return IFileManager::Get().Delete(*GetSaveGamePath(Name), true, false, !bAttemptToUseUI);
|
|
}
|
|
|
|
FString FIOSSaveGameSystem::GetSaveGamePath(const TCHAR* Name)
|
|
{
|
|
return FString::Printf(TEXT("%s""SaveGames/%s.sav"), *FPaths::ProjectSavedDir(), Name);
|
|
}
|