diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs index acc9f9b0..2ccfcb3b 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs @@ -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]"); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager.meta new file mode 100644 index 00000000..696f1bc8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e7c8882fb03206478af7524574d39ed +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppGameSavMgr.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SavCloudApi.cs similarity index 95% rename from AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppGameSavMgr.cs rename to AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SavCloudApi.cs index 217cb15d..bb3adb24 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppGameSavMgr.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SavCloudApi.cs @@ -5,11 +5,14 @@ using AxibugEmuOnline.Client.Network; using AxibugProtobuf; using System.Linq; -namespace AxibugEmuOnline.Client.Manager +namespace AxibugEmuOnline.Client { - public class AppGameSavMgr + /// + /// 负责存档的云端保存和获取功能 + /// + public class SavCloudApi { - public AppGameSavMgr() + public SavCloudApi() { NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavGetGameSavList, RecvGetGameSavList); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavDelGameSav, RecvDelGameSavList); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppGameSavMgr.cs.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SavCloudApi.cs.meta similarity index 100% rename from AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppGameSavMgr.cs.meta rename to AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SavCloudApi.cs.meta diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs new file mode 100644 index 00000000..8e7a340c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs @@ -0,0 +1,30 @@ +using AxibugProtobuf; +using System; + +namespace AxibugEmuOnline.Client +{ + /// 存档文件类 + public class SaveFile + { + /// 指示该存档是否是自动存档 + public bool AutoSave => SlotIndex == 0; + /// 指示该存档所在槽位 + public int SlotIndex { get; private set; } + /// 指示该存档所属Rom的ID + public int RomID { get; private set; } + /// 指示该存档所属模拟器平台 + 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(); + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs.meta new file mode 100644 index 00000000..ef7a9d57 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 7ff9dcbecc3c563449013ccad984780b \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveSlotManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveSlotManager.cs new file mode 100644 index 00000000..8a0bfb65 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveSlotManager.cs @@ -0,0 +1,37 @@ +using AxibugProtobuf; +using System.Collections.Generic; + +namespace AxibugEmuOnline.Client +{ + /// + /// 游戏存档管理器 + /// + public class SaveSlotManager + { + const int MAX_SLOT_COUNT = 4; + + SavCloudApi m_cloudApi = new SavCloudApi(); + Dictionary m_saveFileDict = new Dictionary(); + + 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]; + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveSlotManager.cs.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveSlotManager.cs.meta new file mode 100644 index 00000000..8cf44083 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveSlotManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8544202e7fcd25643a144eb2cab2f0da \ No newline at end of file