AppGameSavMgr更名为SavCloudApi,负责存档的云端同步功能

新增SaveSlotManager,用于游戏存档功能
This commit is contained in:
ALIENJACK\alien 2025-01-17 11:35:05 +08:00
parent 94cd346c66
commit 67617057ed
8 changed files with 88 additions and 5 deletions

View File

@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client.ClientCore
public static AppSettings settings;
public static AppShare share;
public static GamePadManager gamePadMgr;
private static object gameSavMgr;
public static SaveSlotManager SavMgr;
static bool bTest;
static string mTestSrvIP;
#region Mono
@ -86,9 +86,10 @@ namespace AxibugEmuOnline.Client.ClientCore
CacheMgr = new CacheManager();
roomMgr = new AppRoom();
share = new AppShare();
gameSavMgr = new AppGameSavMgr();
SavMgr = new SaveSlotManager();
gamePadMgr = new GamePadManager();
bTest = isTest;
mTestSrvIP = testSrvIP;
var go = new GameObject("[AppAxibugEmuOnline]");

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3e7c8882fb03206478af7524574d39ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -5,11 +5,14 @@ using AxibugEmuOnline.Client.Network;
using AxibugProtobuf;
using System.Linq;
namespace AxibugEmuOnline.Client.Manager
namespace AxibugEmuOnline.Client
{
public class AppGameSavMgr
/// <summary>
/// 负责存档的云端保存和获取功能
/// </summary>
public class SavCloudApi
{
public AppGameSavMgr()
public SavCloudApi()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavGetGameSavList, RecvGetGameSavList);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavDelGameSav, RecvDelGameSavList);

View File

@ -0,0 +1,30 @@
using AxibugProtobuf;
using System;
namespace AxibugEmuOnline.Client
{
/// <summary> 存档文件类 </summary>
public class SaveFile
{
/// <summary> 指示该存档是否是自动存档 </summary>
public bool AutoSave => SlotIndex == 0;
/// <summary> 指示该存档所在槽位 </summary>
public int SlotIndex { get; private set; }
/// <summary> 指示该存档所属Rom的ID </summary>
public int RomID { get; private set; }
/// <summary> 指示该存档所属模拟器平台 </summary>
public RomPlatformType EmuPlatform { get; private set; }
public SaveFile(int romID, RomPlatformType platform, int slotIndex)
{
RomID = romID;
EmuPlatform = platform;
SlotIndex = slotIndex;
}
internal void Save(byte[] savData, byte[] screenShotData)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7ff9dcbecc3c563449013ccad984780b

View File

@ -0,0 +1,37 @@
using AxibugProtobuf;
using System.Collections.Generic;
namespace AxibugEmuOnline.Client
{
/// <summary>
/// 游戏存档管理器
/// </summary>
public class SaveSlotManager
{
const int MAX_SLOT_COUNT = 4;
SavCloudApi m_cloudApi = new SavCloudApi();
Dictionary<int, SaveFile[]> m_saveFileDict = new Dictionary<int, SaveFile[]>();
public void Save(int romID, RomPlatformType platform, int slotIndex, byte[] savData, byte[] screenShotData)
{
var fileIns = GetSaveFile(romID, platform, slotIndex);
fileIns.Save(savData, screenShotData);
}
SaveFile GetSaveFile(int romID, RomPlatformType platform, int slotIndex)
{
if (!m_saveFileDict.TryGetValue(romID, out SaveFile[] files))
{
if (files == null) files = new SaveFile[MAX_SLOT_COUNT];
for (int i = 0; i < files.Length; i++)
{
files[i] = new SaveFile(romID, platform, i);
}
m_saveFileDict[romID] = files;
}
return files[slotIndex];
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8544202e7fcd25643a144eb2cab2f0da