Compare commits
No commits in common. "20e277f6a2f6f59d866ea8e8eef90557774f1bc8" and "9ceb66a3d57b185e2fea914dddfb7ede5b659f0e" have entirely different histories.
20e277f6a2
...
9ceb66a3d5
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ae0d9b04c112f5b4c98feb0af7ed5676
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: cf3c029a754c0dc40b15ce6b1962e31f
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c4467b8175b4db64093d603a93775dff
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7478117b6f7d6cb4cb8c0f5d56205ea1
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -738,7 +738,6 @@ MonoBehaviour:
|
|||||||
m_downloadProgress: {fileID: 1484915906009859069}
|
m_downloadProgress: {fileID: 1484915906009859069}
|
||||||
m_downloadingFlag: {fileID: 1252956242765037133}
|
m_downloadingFlag: {fileID: 1252956242765037133}
|
||||||
m_romReadyFlag: {fileID: 6316945668089981796}
|
m_romReadyFlag: {fileID: 6316945668089981796}
|
||||||
DownloadComplete: {fileID: 8449502431356192113}
|
|
||||||
--- !u!114 &5700455559359757662
|
--- !u!114 &5700455559359757662
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -889,7 +888,6 @@ GameObject:
|
|||||||
- component: {fileID: 8105925540140519754}
|
- component: {fileID: 8105925540140519754}
|
||||||
- component: {fileID: 1377401926964550360}
|
- component: {fileID: 1377401926964550360}
|
||||||
- component: {fileID: 67125096702760250}
|
- component: {fileID: 67125096702760250}
|
||||||
- component: {fileID: 8449502431356192113}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: PreviewImg
|
m_Name: PreviewImg
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -957,39 +955,6 @@ MonoBehaviour:
|
|||||||
m_FillOrigin: 0
|
m_FillOrigin: 0
|
||||||
m_UseSpriteMesh: 0
|
m_UseSpriteMesh: 0
|
||||||
m_PixelsPerUnitMultiplier: 1
|
m_PixelsPerUnitMultiplier: 1
|
||||||
--- !u!114 &8449502431356192113
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 4643603390456494410}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: f19b7e2285c104f6ca47d583f3e5444f, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Version: 300
|
|
||||||
m_EffectMaterial: {fileID: 2100000, guid: 9dc7e810a87b444ab96919f3215c2fe5, type: 2}
|
|
||||||
m_EffectFactor: 0
|
|
||||||
m_Width: 0.25
|
|
||||||
m_Rotation: -41
|
|
||||||
m_Softness: 1
|
|
||||||
m_Brightness: 1
|
|
||||||
m_Gloss: 1
|
|
||||||
m_EffectArea: 0
|
|
||||||
m_Player:
|
|
||||||
play: 0
|
|
||||||
initialPlayDelay: 0
|
|
||||||
duration: 0.5
|
|
||||||
loop: 0
|
|
||||||
loopDelay: 1
|
|
||||||
updateMode: 0
|
|
||||||
m_Play: 0
|
|
||||||
m_Loop: 0
|
|
||||||
m_Duration: 1
|
|
||||||
m_LoopDelay: 1
|
|
||||||
m_UpdateMode: 0
|
|
||||||
--- !u!1 &5340761592919397836
|
--- !u!1 &5340761592919397836
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -3,7 +3,6 @@ using AxibugEmuOnline.Client.Network;
|
|||||||
using AxibugProtobuf;
|
using AxibugProtobuf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -23,22 +22,23 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
public static AppChat chat;
|
public static AppChat chat;
|
||||||
public static UserDataManager user;
|
public static UserDataManager user;
|
||||||
public static AppEmu emu;
|
public static AppEmu emu;
|
||||||
|
/// <summary>
|
||||||
|
/// nes Rom库
|
||||||
|
/// </summary>
|
||||||
|
public static RomLib nesRomLib;
|
||||||
|
/// <summary>
|
||||||
|
/// 收藏 Rom库
|
||||||
|
/// </summary>
|
||||||
|
public static RomLib starRomLib;
|
||||||
public static HttpAPI httpAPI;
|
public static HttpAPI httpAPI;
|
||||||
public static CacheManager CacheMgr;
|
public static CacheManager CacheMgr;
|
||||||
public static AppRoom roomMgr;
|
public static AppRoom roomMgr;
|
||||||
public static AppSettings settings;
|
public static AppSettings settings;
|
||||||
public static AppShare share;
|
public static AppShare share;
|
||||||
public static GamePadManager gamePadMgr;
|
public static GamePadManager gamePadMgr;
|
||||||
public static SaveSlotManager SavMgr;
|
private static object gameSavMgr;
|
||||||
public static FileDownloader FileDownloader;
|
|
||||||
static bool bTest;
|
static bool bTest;
|
||||||
static string mTestSrvIP;
|
static string mTestSrvIP;
|
||||||
|
|
||||||
|
|
||||||
/// <summary> 收藏 Rom库 </summary>
|
|
||||||
public static RomLib starRomLib;
|
|
||||||
private static Dictionary<RomPlatformType, RomLib> s_romLibs = new Dictionary<RomPlatformType, RomLib>();
|
|
||||||
|
|
||||||
#region Mono
|
#region Mono
|
||||||
public static TickLoop tickLoop;
|
public static TickLoop tickLoop;
|
||||||
private static CoroutineRunner coRunner;
|
private static CoroutineRunner coRunner;
|
||||||
@ -62,11 +62,6 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
}
|
}
|
||||||
public static string PersistentDataRoot() => s_persistentRoot;
|
public static string PersistentDataRoot() => s_persistentRoot;
|
||||||
|
|
||||||
public static RomLib GetRomLib(RomPlatformType platform)
|
|
||||||
{
|
|
||||||
return s_romLibs[platform];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Init(bool isTest = false, string testSrvIP = "", bool bUseLocalWebApi = false, string mLocalWebApi = "")
|
public static void Init(bool isTest = false, string testSrvIP = "", bool bUseLocalWebApi = false, string mLocalWebApi = "")
|
||||||
{
|
{
|
||||||
log = new LogManager(OnLogOut);
|
log = new LogManager(OnLogOut);
|
||||||
@ -76,7 +71,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
{
|
{
|
||||||
PSP2Init();
|
PSP2Init();
|
||||||
}
|
}
|
||||||
FileDownloader = new FileDownloader();
|
|
||||||
settings = new AppSettings();
|
settings = new AppSettings();
|
||||||
network = new NetworkHelper();
|
network = new NetworkHelper();
|
||||||
login = new AppLogin();
|
login = new AppLogin();
|
||||||
@ -86,22 +81,14 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
httpAPI = new HttpAPI();
|
httpAPI = new HttpAPI();
|
||||||
if (bUseLocalWebApi)
|
if (bUseLocalWebApi)
|
||||||
httpAPI.WebHost = mLocalWebApi;
|
httpAPI.WebHost = mLocalWebApi;
|
||||||
|
nesRomLib = new RomLib(RomPlatformType.Nes);
|
||||||
foreach (RomPlatformType plat in Enum.GetValues(typeof(RomPlatformType)))
|
|
||||||
{
|
|
||||||
if (plat == RomPlatformType.All || plat == RomPlatformType.Invalid) continue;
|
|
||||||
|
|
||||||
s_romLibs[plat] = new RomLib(plat);
|
|
||||||
}
|
|
||||||
|
|
||||||
starRomLib = new RomLib();
|
starRomLib = new RomLib();
|
||||||
CacheMgr = new CacheManager();
|
CacheMgr = new CacheManager();
|
||||||
roomMgr = new AppRoom();
|
roomMgr = new AppRoom();
|
||||||
share = new AppShare();
|
share = new AppShare();
|
||||||
SavMgr = new SaveSlotManager();
|
gameSavMgr = new AppGameSavMgr();
|
||||||
gamePadMgr = new GamePadManager();
|
gamePadMgr = new GamePadManager();
|
||||||
|
|
||||||
|
|
||||||
bTest = isTest;
|
bTest = isTest;
|
||||||
mTestSrvIP = testSrvIP;
|
mTestSrvIP = testSrvIP;
|
||||||
var go = new GameObject("[AppAxibugEmuOnline]");
|
var go = new GameObject("[AppAxibugEmuOnline]");
|
||||||
@ -133,7 +120,6 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static IEnumerator AppTickFlow()
|
private static IEnumerator AppTickFlow()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@ -224,9 +210,8 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
|
|
||||||
private static void Tick()
|
private static void Tick()
|
||||||
{
|
{
|
||||||
foreach (var romLib in s_romLibs.Values) romLib.ExecuteFetchRomInfo();
|
nesRomLib.ExecuteFetchRomInfo();
|
||||||
starRomLib.ExecuteFetchRomInfo();
|
starRomLib.ExecuteFetchRomInfo();
|
||||||
FileDownloader.Update();
|
|
||||||
|
|
||||||
gamePadMgr.Update();
|
gamePadMgr.Update();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
using System;
|
using NUnit.Framework;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using System.Security.Policy;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Unity.Android.Gradle.Manifest;
|
||||||
|
using static UnityEngine.Analytics.IAnalytic;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client.Common
|
namespace AxibugEmuOnline.Client.Common
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
@ -27,7 +28,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
App.Init(bTestSkipWebApiToConServer, mTestSrvIP, bUseLocalWebApi, mLocalWebApi);
|
App.Init(bTestSkipWebApiToConServer, mTestSrvIP, bUseLocalWebApi,mLocalWebApi);
|
||||||
dev_UUID = SystemInfo.deviceUniqueIdentifier;
|
dev_UUID = SystemInfo.deviceUniqueIdentifier;
|
||||||
if (bEditorUUID)
|
if (bEditorUUID)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -32,7 +32,7 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
if (!m_emuCore.IsNull()) StopGame();
|
if (!m_emuCore.IsNull()) StopGame();
|
||||||
|
|
||||||
var roomInfo = App.roomMgr.mineRoomMiniInfo;
|
var roomInfo = App.roomMgr.mineRoomMiniInfo;
|
||||||
roomInfo.FetchRomFileInRoomInfo((_, romFile) =>
|
roomInfo.FetchRomFileInRoomInfo(RomPlatformType.Nes, (_, romFile) =>
|
||||||
{
|
{
|
||||||
if (!romFile.RomReady) //这个rom并没有下载,所以取消进入房间
|
if (!romFile.RomReady) //这个rom并没有下载,所以取消进入房间
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,14 +5,11 @@ using AxibugEmuOnline.Client.Network;
|
|||||||
using AxibugProtobuf;
|
using AxibugProtobuf;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client.Manager
|
||||||
{
|
{
|
||||||
/// <summary>
|
public class AppGameSavMgr
|
||||||
/// 负责存档的云端保存和获取功能
|
|
||||||
/// </summary>
|
|
||||||
public class SavCloudApi
|
|
||||||
{
|
{
|
||||||
public SavCloudApi()
|
public AppGameSavMgr()
|
||||||
{
|
{
|
||||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavGetGameSavList, RecvGetGameSavList);
|
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavGetGameSavList, RecvGetGameSavList);
|
||||||
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavDelGameSav, RecvDelGameSavList);
|
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavDelGameSav, RecvDelGameSavList);
|
||||||
@ -98,7 +95,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
void RecvUpLoadGameSav(byte[] reqData)
|
void RecvUpLoadGameSav(byte[] reqData)
|
||||||
{
|
{
|
||||||
Protobuf_Mine_UpLoadGameSav_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Mine_UpLoadGameSav_RESP>(reqData);
|
Protobuf_Mine_UpLoadGameSav_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Mine_UpLoadGameSav_RESP>(reqData);
|
||||||
Eventer.Instance.PostEvent(EEvent.OnNetUploaded, msg.RomID, msg.SavDataIdx, msg.UploadSevInfo);
|
Eventer.Instance.PostEvent(EEvent.OnNetUploaded, msg.RomID,msg.SavDataIdx, msg.UploadSevInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -498,7 +498,7 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
/// <param name="LoadStateNeedTimeUs">加载即时存档所需平均时间(微秒)</param>
|
/// <param name="LoadStateNeedTimeUs">加载即时存档所需平均时间(微秒)</param>
|
||||||
/// <param name="VideoFrameShowNeedTimeUs">视频一帧所需时间(微秒)</param>
|
/// <param name="VideoFrameShowNeedTimeUs">视频一帧所需时间(微秒)</param>
|
||||||
/// <param name="AudioFramePlayNeedTimeUs">音频处理一帧所需时间(微秒)</param>
|
/// <param name="AudioFramePlayNeedTimeUs">音频处理一帧所需时间(微秒)</param>
|
||||||
public void SendRoomPlayerReady(float PushFrameNeedTimeUs, float LoadStateNeedTimeUs, float VideoFrameShowNeedTimeUs, float AudioFramePlayNeedTimeUs)
|
public void SendRoomPlayerReady(float PushFrameNeedTimeUs,float LoadStateNeedTimeUs,float VideoFrameShowNeedTimeUs,float AudioFramePlayNeedTimeUs)
|
||||||
{
|
{
|
||||||
App.log.Debug("上报准备完毕");
|
App.log.Debug("上报准备完毕");
|
||||||
_Protobuf_Room_Player_Ready.PushFrameNeedTimeUs = PushFrameNeedTimeUs;
|
_Protobuf_Room_Player_Ready.PushFrameNeedTimeUs = PushFrameNeedTimeUs;
|
||||||
|
|||||||
@ -1,61 +0,0 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
|
||||||
{
|
|
||||||
public class FileDownloader
|
|
||||||
{
|
|
||||||
Dictionary<string, AxiHttpProxy.SendDownLoadProxy> m_downloadingTasks = new Dictionary<string, AxiHttpProxy.SendDownLoadProxy>();
|
|
||||||
Dictionary<string, Action<byte[]>> m_completeCallback = new Dictionary<string, Action<byte[]>>();
|
|
||||||
public void BeginDownload(string url, Action<byte[]> callback)
|
|
||||||
{
|
|
||||||
if (m_downloadingTasks.TryGetValue(url, out var downloadProxy)) return;
|
|
||||||
|
|
||||||
m_completeCallback[url] = callback;
|
|
||||||
var downloadRequest = AxiHttpProxy.GetDownLoad($"{App.httpAPI.WebHost}/{url}");
|
|
||||||
m_downloadingTasks[url] = downloadRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float? GetDownloadProgress(string url)
|
|
||||||
{
|
|
||||||
m_downloadingTasks.TryGetValue(url, out var proxy);
|
|
||||||
if (proxy == null) return null;
|
|
||||||
|
|
||||||
return Mathf.Clamp01(proxy.downloadHandler.DownLoadPr);
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<string> temp = new HashSet<string>();
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
temp.Clear();
|
|
||||||
|
|
||||||
foreach (var item in m_downloadingTasks)
|
|
||||||
{
|
|
||||||
var url = item.Key;
|
|
||||||
var proxy = item.Value;
|
|
||||||
if (proxy.downloadHandler.isDone)
|
|
||||||
{
|
|
||||||
temp.Add(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var url in temp)
|
|
||||||
{
|
|
||||||
var overTask = m_downloadingTasks[url];
|
|
||||||
m_downloadingTasks.Remove(url);
|
|
||||||
|
|
||||||
if (!overTask.downloadHandler.bHadErr)
|
|
||||||
{
|
|
||||||
m_completeCallback[url].Invoke(overTask.downloadHandler.data);
|
|
||||||
m_completeCallback.Remove(url);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError(overTask.downloadHandler.ErrInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 86823d6828e1cf24da330443483b060b
|
|
||||||
@ -4,7 +4,6 @@ using AxibugProtobuf;
|
|||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -13,131 +12,42 @@ namespace AxibugEmuOnline.Client
|
|||||||
public class RomFile
|
public class RomFile
|
||||||
{
|
{
|
||||||
private HttpAPI.Resp_RomInfo webData;
|
private HttpAPI.Resp_RomInfo webData;
|
||||||
/// <summary> 依赖的Rom文件 </summary>
|
private bool hasLocalFile;
|
||||||
private List<RomFile> dependencies = new List<RomFile>();
|
//private UnityWebRequest downloadRequest;
|
||||||
RomPlatformType m_defaultPlatform;
|
private AxiHttpProxy.SendDownLoadProxy downloadRequest;
|
||||||
|
|
||||||
/// <summary> 指示该Rom是否是多文件Rom </summary>
|
public bool IsUserRom { get; private set; }
|
||||||
public bool MultiFileRom
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch (Platform)
|
|
||||||
{
|
|
||||||
case RomPlatformType.Nes: return false;
|
|
||||||
case RomPlatformType.Igs:
|
|
||||||
case RomPlatformType.Cps1:
|
|
||||||
case RomPlatformType.Cps2:
|
|
||||||
case RomPlatformType.Neogeo:
|
|
||||||
return true;
|
|
||||||
default: throw new NotImplementedException($"未实现的平台{Platform}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool m_hasLocalFile;
|
|
||||||
public bool HasLocalFile
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!m_hasLocalFile) return false;
|
|
||||||
|
|
||||||
foreach (var depRom in dependencies)
|
|
||||||
{
|
|
||||||
if (!depRom.HasLocalFile) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 指示该Rom文件的存放路径 </summary>
|
/// <summary> 指示该Rom文件的存放路径 </summary>
|
||||||
public string LocalFilePath => $"{App.PersistentDataPath(Platform)}/RemoteRoms/{FileName}";
|
public string LocalFilePath =>
|
||||||
|
IsUserRom ?
|
||||||
|
$"{App.PersistentDataPath(Platform)}/UserRoms/{FileName}" :
|
||||||
|
$"{App.PersistentDataPath(Platform)}/RemoteRoms/{FileName}";
|
||||||
|
|
||||||
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
||||||
public bool RomReady
|
public bool RomReady => hasLocalFile;
|
||||||
{
|
///// <summary> 指示是否正在下载Rom文件 </summary>
|
||||||
get
|
//public bool IsDownloading => downloadRequest != null && downloadRequest.result == UnityWebRequest.Result.InProgress;
|
||||||
{
|
//public float Progress => IsDownloading ? downloadRequest.downloadProgress : 0;
|
||||||
if (!HasLocalFile) return false;
|
|
||||||
|
|
||||||
foreach (var depRom in dependencies)
|
|
||||||
{
|
|
||||||
if (!depRom.RomReady) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary> 指示是否正在下载Rom文件 </summary>
|
/// <summary> 指示是否正在下载Rom文件 </summary>
|
||||||
public bool IsDownloading
|
public bool IsDownloading => downloadRequest != null && !downloadRequest.downloadHandler.isDone;
|
||||||
{
|
public float Progress => IsDownloading ? downloadRequest.downloadHandler.DownLoadPr : 0;
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!InfoReady) return false;
|
|
||||||
|
|
||||||
var progress = App.FileDownloader.GetDownloadProgress(webData.url);
|
|
||||||
if (progress.HasValue) return true;
|
|
||||||
|
|
||||||
foreach (var depRom in dependencies)
|
public RomPlatformType Platform => webData != null ? (RomPlatformType)webData.ptype : RomPlatformType.Invalid;
|
||||||
{
|
|
||||||
if (depRom.IsDownloading) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Progress
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!IsDownloading) return 0;
|
|
||||||
|
|
||||||
float progress = 0f;
|
|
||||||
|
|
||||||
if (HasLocalFile) progress = 1f;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var downloadProgress = App.FileDownloader.GetDownloadProgress(webData.url);
|
|
||||||
progress = downloadProgress.HasValue ? downloadProgress.Value : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var depRom in dependencies)
|
|
||||||
{
|
|
||||||
progress += depRom.Progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
return progress / (dependencies.Count + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RomPlatformType Platform => webData != null ? (RomPlatformType)webData.ptype : m_defaultPlatform;
|
|
||||||
/// <summary> 指示该Rom信息是否已填充 </summary>
|
/// <summary> 指示该Rom信息是否已填充 </summary>
|
||||||
public bool InfoReady
|
public bool InfoReady => webData != null;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (webData == null) return false;
|
|
||||||
|
|
||||||
foreach (var depRom in dependencies)
|
|
||||||
{
|
|
||||||
if (!depRom.InfoReady) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary> 唯一标识 </summary>
|
/// <summary> 唯一标识 </summary>
|
||||||
public int ID => webData != null ? webData.id : -1;
|
public int ID => webData != null ? webData.id : -1;
|
||||||
/// <summary> 别名 </summary>
|
/// <summary> 别名 </summary>
|
||||||
public string Alias => webData.romName;
|
public string Alias => IsUserRom ? Path.GetFileNameWithoutExtension(FileName) : webData.romName;
|
||||||
/// <summary> 描述 </summary>
|
/// <summary> 描述 </summary>
|
||||||
public string Descript => webData.desc;
|
public string Descript => IsUserRom ? string.Empty : webData.desc;
|
||||||
/// <summary> 游戏类型 </summary>
|
/// <summary> 游戏类型 </summary>
|
||||||
public string GameTypeDes => webData.gType;
|
public string GameTypeDes => IsUserRom ? string.Empty : webData.gType;
|
||||||
/// <summary> 小图URL </summary>
|
/// <summary> 小图URL </summary>
|
||||||
public string ImageURL => webData.imgUrl;
|
public string ImageURL => IsUserRom ? string.Empty : webData.imgUrl;
|
||||||
|
|
||||||
/// <summary> 文件名 </summary>
|
/// <summary> 文件名 </summary>
|
||||||
public string FileName { get; private set; }
|
public string FileName { get; private set; }
|
||||||
@ -145,7 +55,6 @@ namespace AxibugEmuOnline.Client
|
|||||||
public int Index { get; private set; }
|
public int Index { get; private set; }
|
||||||
/// <summary> 在查询结果中的所在页 </summary>
|
/// <summary> 在查询结果中的所在页 </summary>
|
||||||
public int Page { get; private set; }
|
public int Page { get; private set; }
|
||||||
|
|
||||||
public string Hash => webData != null ? webData.hash : string.Empty;
|
public string Hash => webData != null ? webData.hash : string.Empty;
|
||||||
/// <summary> 标记是否收藏 </summary>
|
/// <summary> 标记是否收藏 </summary>
|
||||||
public bool Star
|
public bool Star
|
||||||
@ -161,29 +70,10 @@ namespace AxibugEmuOnline.Client
|
|||||||
public event Action<RomFile> OnDownloadOver;
|
public event Action<RomFile> OnDownloadOver;
|
||||||
public event Action OnInfoFilled;
|
public event Action OnInfoFilled;
|
||||||
|
|
||||||
public RomFile(int index, int insidePage, RomPlatformType defaultPlatform)
|
public RomFile(int index, int insidePage)
|
||||||
{
|
{
|
||||||
Index = index;
|
Index = index;
|
||||||
Page = insidePage;
|
Page = insidePage;
|
||||||
m_defaultPlatform = defaultPlatform;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckLocalFileState()
|
|
||||||
{
|
|
||||||
if (webData == null) m_hasLocalFile = false;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (App.FileDownloader.GetDownloadProgress(webData.url) == null)
|
|
||||||
{
|
|
||||||
if (MultiFileRom)
|
|
||||||
m_hasLocalFile = Directory.Exists(LocalFilePath);
|
|
||||||
else
|
|
||||||
m_hasLocalFile = File.Exists(LocalFilePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var depRom in dependencies)
|
|
||||||
depRom.CheckLocalFileState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginDownload()
|
public void BeginDownload()
|
||||||
@ -191,78 +81,25 @@ namespace AxibugEmuOnline.Client
|
|||||||
if (RomReady) return;
|
if (RomReady) return;
|
||||||
if (IsDownloading) return;
|
if (IsDownloading) return;
|
||||||
|
|
||||||
//检查依赖Rom的下载情况
|
App.StartCoroutine(DownloadRemoteRom((bytes) =>
|
||||||
foreach (var depRom in dependencies)
|
|
||||||
{
|
{
|
||||||
depRom.BeginDownload();
|
if (bytes != null)
|
||||||
}
|
|
||||||
App.FileDownloader.BeginDownload(webData.url, (bytes) =>
|
|
||||||
{
|
|
||||||
HandleRomFilePostProcess(bytes);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleRomFilePostProcess(byte[] bytes)
|
|
||||||
{
|
|
||||||
if (bytes == null) return;
|
|
||||||
|
|
||||||
if (MultiFileRom)
|
|
||||||
{
|
|
||||||
Dictionary<string, byte[]> unzipFiles = new Dictionary<string, byte[]>();
|
|
||||||
//多rom文件的平台,下载下来的数据直接解压放入文件夹内
|
|
||||||
var zip = new ZipInputStream(new MemoryStream(bytes));
|
|
||||||
|
|
||||||
List<string> depth0Files = new List<string>();
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var currentEntry = zip.GetNextEntry();
|
|
||||||
if (currentEntry == null) break;
|
|
||||||
|
|
||||||
if (currentEntry.IsDirectory) continue;
|
|
||||||
|
|
||||||
var buffer = new byte[1024];
|
|
||||||
MemoryStream output = new MemoryStream();
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var size = zip.Read(buffer, 0, buffer.Length);
|
|
||||||
if (size == 0) break;
|
|
||||||
else output.Write(buffer, 0, size);
|
|
||||||
}
|
|
||||||
output.Flush();
|
|
||||||
unzipFiles[$"{LocalFilePath}/{currentEntry.Name}"] = output.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
string rootDirName = null;
|
|
||||||
//如果第一层目录只有一个文件并且是文件夹,则所有文件层级外提一层
|
|
||||||
if (depth0Files.Count == 1 && depth0Files[0].Contains('.'))
|
|
||||||
{
|
|
||||||
rootDirName = depth0Files[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in unzipFiles)
|
|
||||||
{
|
|
||||||
var path = rootDirName != null ? item.Key.Substring(0, rootDirName.Length + 1) : item.Key;
|
|
||||||
var data = item.Value;
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
||||||
File.WriteAllBytes(path, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
var directPath = Path.GetDirectoryName(LocalFilePath);
|
var directPath = Path.GetDirectoryName(LocalFilePath);
|
||||||
Directory.CreateDirectory(directPath);
|
Directory.CreateDirectory(directPath);
|
||||||
|
|
||||||
File.WriteAllBytes(LocalFilePath, bytes);
|
File.WriteAllBytes(LocalFilePath, bytes);
|
||||||
}
|
hasLocalFile = true;
|
||||||
|
|
||||||
Eventer.Instance.PostEvent(EEvent.OnRomFileDownloaded, ID);
|
Eventer.Instance.PostEvent(EEvent.OnRomFileDownloaded, ID);
|
||||||
|
}
|
||||||
OnDownloadOver?.Invoke(this);
|
OnDownloadOver?.Invoke(this);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] GetRomFileData()
|
public byte[] GetRomFileData()
|
||||||
{
|
{
|
||||||
Debug.Assert(!MultiFileRom, "仅供单文件Rom使用的接口");
|
if (!IsUserRom && webData == null) throw new Exception("Not Valid Rom");
|
||||||
|
|
||||||
if (webData == null) throw new Exception("Not Valid Rom");
|
|
||||||
if (!RomReady) throw new Exception("Rom File Not Downloaded");
|
if (!RomReady) throw new Exception("Rom File Not Downloaded");
|
||||||
|
|
||||||
var bytes = File.ReadAllBytes(LocalFilePath);
|
var bytes = File.ReadAllBytes(LocalFilePath);
|
||||||
@ -296,37 +133,63 @@ namespace AxibugEmuOnline.Client
|
|||||||
throw new Exception("Not Valid Rom Data");
|
throw new Exception("Not Valid Rom Data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerator DownloadRemoteRom(Action<byte[]> callback)
|
||||||
|
{
|
||||||
|
downloadRequest = AxiHttpProxy.GetDownLoad($"{App.httpAPI.WebHost}/{webData.url}");
|
||||||
|
|
||||||
|
while (!downloadRequest.downloadHandler.isDone)
|
||||||
|
{
|
||||||
|
yield return null;
|
||||||
|
Debug.Log($"下载进度:{downloadRequest.downloadHandler.DownLoadPr} ->{downloadRequest.downloadHandler.loadedLenght}/{downloadRequest.downloadHandler.NeedloadedLenght}");
|
||||||
|
}
|
||||||
|
AxiHttpProxy.ShowAxiHttpDebugInfo(downloadRequest.downloadHandler);
|
||||||
|
|
||||||
|
var request = downloadRequest;
|
||||||
|
downloadRequest = null;
|
||||||
|
|
||||||
|
if (!request.downloadHandler.bHadErr)
|
||||||
|
callback(request.downloadHandler.data);
|
||||||
|
else
|
||||||
|
callback(null);
|
||||||
|
|
||||||
|
//downloadRequest = UnityWebRequest.Get($"{App.httpAPI.WebHost}/{webData.url}");
|
||||||
|
//yield return downloadRequest.SendWebRequest();
|
||||||
|
|
||||||
|
//var request = downloadRequest;
|
||||||
|
//downloadRequest = null;
|
||||||
|
|
||||||
|
//if (request.result != UnityWebRequest.Result.Success)
|
||||||
|
//{
|
||||||
|
// callback(null);
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// callback(request.downloadHandler.data);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetWebData(HttpAPI.Resp_RomInfo resp_RomInfo)
|
public void SetWebData(HttpAPI.Resp_RomInfo resp_RomInfo)
|
||||||
{
|
{
|
||||||
webData = resp_RomInfo;
|
webData = resp_RomInfo;
|
||||||
FileName = MultiFileRom ? Path.GetFileNameWithoutExtension(webData.url) : Path.GetFileName(webData.url);
|
FileName = Path.GetFileName(webData.url);
|
||||||
FileName = System.Net.WebUtility.UrlDecode(FileName);
|
FileName = System.Net.WebUtility.UrlDecode(FileName);
|
||||||
|
|
||||||
//收集依赖Rom
|
if (File.Exists(LocalFilePath))
|
||||||
if (webData.parentRomIdsList != null)
|
|
||||||
{
|
{
|
||||||
dependencies.Clear();
|
var fileBytes = File.ReadAllBytes(LocalFilePath);
|
||||||
foreach (var romID in webData.parentRomIdsList)
|
var localHash = RomLib.CalcHash(fileBytes);
|
||||||
{
|
|
||||||
var romFile = new RomFile(Index, Page, m_defaultPlatform);
|
|
||||||
dependencies.Add(romFile);
|
|
||||||
App.StartCoroutine(App.httpAPI.GetRomInfo(romID, (romInfo) =>
|
|
||||||
{
|
|
||||||
romFile.SetWebData(romInfo);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckLocalFileState();
|
hasLocalFile = localHash == webData.hash;
|
||||||
|
if (!hasLocalFile)
|
||||||
App.StartCoroutine(WaitInfoReady());
|
File.Delete(LocalFilePath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private IEnumerator WaitInfoReady()
|
|
||||||
{
|
{
|
||||||
while (!InfoReady) yield return null;
|
hasLocalFile = false;
|
||||||
|
}
|
||||||
|
|
||||||
OnInfoFilled?.Invoke();
|
OnInfoFilled?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,9 +17,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
/// <summary> 请求指令 </summary>
|
/// <summary> 请求指令 </summary>
|
||||||
private HashSet<int> FetchPageCmd = new HashSet<int>();
|
private HashSet<int> FetchPageCmd = new HashSet<int>();
|
||||||
private RomFile[] RomFetchList;
|
private RomFile[] nesRomFetchList;
|
||||||
private Dictionary<int, RomFile> RomFileIdMapper = new Dictionary<int, RomFile>();
|
private Dictionary<int, RomFile> nesRomFileIdMapper = new Dictionary<int, RomFile>();
|
||||||
private Dictionary<string, RomFile> RomFileNameMapper = new Dictionary<string, RomFile>();
|
private Dictionary<string, RomFile> nesRomFileNameMapper = new Dictionary<string, RomFile>();
|
||||||
private HttpAPI.GetRomListAPI m_romGetFunc;
|
private HttpAPI.GetRomListAPI m_romGetFunc;
|
||||||
private HttpAPI.SearchRomListAPI m_romSearchFunc;
|
private HttpAPI.SearchRomListAPI m_romSearchFunc;
|
||||||
private RomPlatformType m_platform;
|
private RomPlatformType m_platform;
|
||||||
@ -43,9 +43,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
private void OnRomStarStateChanged(int romID, bool star)
|
private void OnRomStarStateChanged(int romID, bool star)
|
||||||
{
|
{
|
||||||
if (RomFetchList == null) return;
|
if (nesRomFetchList == null) return;
|
||||||
|
|
||||||
var targetRom = RomFetchList.FirstOrDefault(rom => rom.ID == romID);
|
var targetRom = nesRomFetchList.FirstOrDefault(rom => rom.ID == romID);
|
||||||
if (targetRom == null) return;
|
if (targetRom == null) return;
|
||||||
|
|
||||||
targetRom.Star = star;
|
targetRom.Star = star;
|
||||||
@ -54,7 +54,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
public RomFile GetRomFile(string romFileName)
|
public RomFile GetRomFile(string romFileName)
|
||||||
{
|
{
|
||||||
RomFile romFile;
|
RomFile romFile;
|
||||||
RomFileNameMapper.TryGetValue(romFileName, out romFile);
|
nesRomFileNameMapper.TryGetValue(romFileName, out romFile);
|
||||||
return romFile;
|
return romFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,22 +83,22 @@ namespace AxibugEmuOnline.Client
|
|||||||
m_romGetFunc((page, romList) =>
|
m_romGetFunc((page, romList) =>
|
||||||
{
|
{
|
||||||
FetchPageCmd.Clear();
|
FetchPageCmd.Clear();
|
||||||
RomFileIdMapper.Clear();
|
nesRomFileIdMapper.Clear();
|
||||||
RomFileNameMapper.Clear();
|
nesRomFileNameMapper.Clear();
|
||||||
|
|
||||||
if (romList != null)
|
if (romList != null)
|
||||||
RomFetchList = new RomFile[romList.resultAllCount];
|
nesRomFetchList = new RomFile[romList.resultAllCount];
|
||||||
else
|
else
|
||||||
RomFetchList = new RomFile[0];
|
nesRomFetchList = new RomFile[0];
|
||||||
|
|
||||||
for (int i = 0; i < RomFetchList.Length; i++)
|
for (int i = 0; i < nesRomFetchList.Length; i++)
|
||||||
{
|
{
|
||||||
//以后考虑用对象池实例化RomFile
|
//以后考虑用对象池实例化RomFile
|
||||||
RomFetchList[i] = new RomFile(i, i / PAGE_SIZE, m_platform);
|
nesRomFetchList[i] = new RomFile(i, i / PAGE_SIZE);
|
||||||
}
|
}
|
||||||
SaveRomInfoFromWeb(romList);
|
SaveRomInfoFromWeb(romList);
|
||||||
|
|
||||||
callback.Invoke(RomFetchList);
|
callback.Invoke(nesRomFetchList);
|
||||||
}, m_platform, 0, PAGE_SIZE);
|
}, m_platform, 0, PAGE_SIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -106,22 +106,22 @@ namespace AxibugEmuOnline.Client
|
|||||||
m_romSearchFunc((page, romList) =>
|
m_romSearchFunc((page, romList) =>
|
||||||
{
|
{
|
||||||
FetchPageCmd.Clear();
|
FetchPageCmd.Clear();
|
||||||
RomFileIdMapper.Clear();
|
nesRomFileIdMapper.Clear();
|
||||||
RomFileNameMapper.Clear();
|
nesRomFileNameMapper.Clear();
|
||||||
|
|
||||||
if (romList != null)
|
if (romList != null)
|
||||||
RomFetchList = new RomFile[romList.resultAllCount];
|
nesRomFetchList = new RomFile[romList.resultAllCount];
|
||||||
else
|
else
|
||||||
RomFetchList = new RomFile[0];
|
nesRomFetchList = new RomFile[0];
|
||||||
|
|
||||||
for (int i = 0; i < RomFetchList.Length; i++)
|
for (int i = 0; i < nesRomFetchList.Length; i++)
|
||||||
{
|
{
|
||||||
//以后考虑用对象池实例化RomFile
|
//以后考虑用对象池实例化RomFile
|
||||||
RomFetchList[i] = new RomFile(i, i / PAGE_SIZE, m_platform);
|
nesRomFetchList[i] = new RomFile(i, i / PAGE_SIZE);
|
||||||
}
|
}
|
||||||
SaveRomInfoFromWeb(romList);
|
SaveRomInfoFromWeb(romList);
|
||||||
|
|
||||||
callback.Invoke(RomFetchList);
|
callback.Invoke(nesRomFetchList);
|
||||||
}, m_platform, searchKey, 0, PAGE_SIZE);
|
}, m_platform, searchKey, 0, PAGE_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,11 +170,11 @@ namespace AxibugEmuOnline.Client
|
|||||||
for (int i = 0; i < resp.gameList.Count; i++)
|
for (int i = 0; i < resp.gameList.Count; i++)
|
||||||
{
|
{
|
||||||
var webData = resp.gameList[i];
|
var webData = resp.gameList[i];
|
||||||
RomFile targetRomFile = RomFetchList[webData.orderid];
|
RomFile targetRomFile = nesRomFetchList[webData.orderid];
|
||||||
|
|
||||||
targetRomFile.SetWebData(webData);
|
targetRomFile.SetWebData(webData);
|
||||||
RomFileIdMapper[webData.id] = RomFetchList[webData.orderid];
|
nesRomFileIdMapper[webData.id] = nesRomFetchList[webData.orderid];
|
||||||
RomFileNameMapper[targetRomFile.FileName] = targetRomFile;
|
nesRomFileNameMapper[targetRomFile.FileName] = targetRomFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void AddRomFile(RomFile rom)
|
public void AddRomFile(RomFile rom)
|
||||||
{
|
{
|
||||||
RomFileNameMapper[rom.FileName] = rom;
|
nesRomFileNameMapper[rom.FileName] = rom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3e7c8882fb03206478af7524574d39ed
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -1,118 +0,0 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
|
||||||
using AxibugProtobuf;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
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; }
|
|
||||||
/// <summary> 指示该存档是否为空 </summary>
|
|
||||||
public bool IsEmpty { get; }
|
|
||||||
|
|
||||||
/// <summary> 存档文件路径 </summary>
|
|
||||||
public string FilePath
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var path = App.PersistentDataPath(EmuPlatform);
|
|
||||||
path = $"{path}/Slot/{EmuPlatform}/{RomID}";
|
|
||||||
|
|
||||||
Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
var filePath = $"{path}/slot{SlotIndex}.SlotSav";
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaveFile(int romID, RomPlatformType platform, int slotIndex)
|
|
||||||
{
|
|
||||||
RomID = romID;
|
|
||||||
EmuPlatform = platform;
|
|
||||||
SlotIndex = slotIndex;
|
|
||||||
|
|
||||||
IsEmpty = File.Exists(FilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe void GetSavData(out byte[] savData, out byte[] screenShotData)
|
|
||||||
{
|
|
||||||
savData = null;
|
|
||||||
screenShotData = null;
|
|
||||||
|
|
||||||
if (!File.Exists(FilePath)) return;
|
|
||||||
|
|
||||||
var raw = File.ReadAllBytes(FilePath);
|
|
||||||
int headerSize = Marshal.SizeOf(typeof(Header));
|
|
||||||
|
|
||||||
if (raw.Length < headerSize)
|
|
||||||
{
|
|
||||||
App.log.Warning("无效存档");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var header = new Header();
|
|
||||||
IntPtr ptr = Marshal.AllocHGlobal(headerSize);
|
|
||||||
Marshal.StructureToPtr(header, ptr, false);
|
|
||||||
Marshal.Copy(raw, 0, ptr, headerSize);
|
|
||||||
Marshal.FreeHGlobal(ptr);
|
|
||||||
|
|
||||||
savData = new byte[header.DataLength];
|
|
||||||
Array.Copy(raw, headerSize, savData, 0, savData.Length);
|
|
||||||
screenShotData = new byte[header.ScreenShotLength];
|
|
||||||
Array.Copy(raw, headerSize + savData.Length, screenShotData, 0, screenShotData.Length);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe void Save(byte[] savData, byte[] screenShotData)
|
|
||||||
{
|
|
||||||
var filePath = FilePath;
|
|
||||||
|
|
||||||
var header = new Header { EmuPlatform = (byte)EmuPlatform, SlotIndex = (byte)SlotIndex, RomID = RomID, DataLength = savData.Length, ScreenShotLength = screenShotData.Length };
|
|
||||||
int headerSize = Marshal.SizeOf(typeof(Header));
|
|
||||||
IntPtr ptr = Marshal.AllocHGlobal(headerSize);
|
|
||||||
|
|
||||||
var totalSize = headerSize + savData.Length + screenShotData.Length;
|
|
||||||
byte[] raw = new byte[totalSize];
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Marshal.StructureToPtr(header, ptr, false);
|
|
||||||
Marshal.Copy(ptr, raw, 0, headerSize);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal.FreeHGlobal(ptr);
|
|
||||||
}
|
|
||||||
Array.Copy(savData, 0, raw, headerSize, savData.Length);
|
|
||||||
Array.Copy(screenShotData, 0, raw, headerSize + savData.Length, screenShotData.Length);
|
|
||||||
|
|
||||||
File.WriteAllBytes(filePath, raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit, Size = 14)]
|
|
||||||
struct Header
|
|
||||||
{
|
|
||||||
[FieldOffset(0)]
|
|
||||||
public byte EmuPlatform;
|
|
||||||
[FieldOffset(1)]
|
|
||||||
public byte SlotIndex;
|
|
||||||
[FieldOffset(2)]
|
|
||||||
public int RomID;
|
|
||||||
[FieldOffset(6)]
|
|
||||||
public int DataLength;
|
|
||||||
[FieldOffset(10)]
|
|
||||||
public int ScreenShotLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7ff9dcbecc3c563449013ccad984780b
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
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 List<SaveFile> GetSlotSaves(int romID, RomPlatformType platform)
|
|
||||||
{
|
|
||||||
List<SaveFile> result = new List<SaveFile>();
|
|
||||||
for (int i = 0; i < MAX_SLOT_COUNT; i++)
|
|
||||||
{
|
|
||||||
result.Add(GetSaveFile(romID, platform, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8544202e7fcd25643a144eb2cab2f0da
|
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using AxibugProtobuf;
|
|
||||||
using AxiReplay;
|
using AxiReplay;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -21,7 +20,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var romFile = App.GetRomLib(RomPlatformType.Nes).GetRomFile(fname);
|
var romFile = App.nesRomLib.GetRomFile(fname);
|
||||||
var bytes = romFile.GetRomFileData();
|
var bytes = romFile.GetRomFileData();
|
||||||
Debug.Log($"Open {romFile.Alias}");
|
Debug.Log($"Open {romFile.Alias}");
|
||||||
return new MemoryStream(bytes);
|
return new MemoryStream(bytes);
|
||||||
@ -35,7 +34,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void GetRomPathInfo(string fname, out string fullPath, out string directPath)
|
public void GetRomPathInfo(string fname, out string fullPath, out string directPath)
|
||||||
{
|
{
|
||||||
var romFile = App.GetRomLib(RomPlatformType.Nes).GetRomFile(fname);
|
var romFile = App.nesRomLib.GetRomFile(fname);
|
||||||
UnityEngine.Debug.Assert(romFile != null);
|
UnityEngine.Debug.Assert(romFile != null);
|
||||||
|
|
||||||
fullPath = romFile.LocalFilePath;
|
fullPath = romFile.LocalFilePath;
|
||||||
|
|||||||
@ -70,7 +70,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
Supporter.Setup(m_coreSupporter);
|
Supporter.Setup(m_coreSupporter);
|
||||||
Debuger.Setup(new CoreDebuger());
|
Debuger.Setup(new CoreDebuger());
|
||||||
|
|
||||||
App.GetRomLib(RomPlatformType.Nes).AddRomFile(rom);
|
App.nesRomLib.AddRomFile(rom);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using AxibugEmuOnline.Client.Event;
|
using AxibugEmuOnline.Client.Event;
|
||||||
using AxibugEmuOnline.Client.UI;
|
using AxibugEmuOnline.Client.UI;
|
||||||
using Coffee.UIExtensions;
|
using Coffee.UIExtensions;
|
||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
}
|
}
|
||||||
public int RomID { get { return m_romfile != null && m_romfile.InfoReady ? m_romfile.ID : -1; } }
|
public int RomID { get { return m_romfile != null && m_romfile.InfoReady ? m_romfile.ID : -1; } }
|
||||||
|
|
||||||
private RomLib m_romlib => App.GetRomLib(m_romfile.Platform);
|
private RomLib m_romlib => App.nesRomLib;
|
||||||
|
|
||||||
public bool RomInfoReady => m_romfile != null && m_romfile.InfoReady;
|
public bool RomInfoReady => m_romfile != null && m_romfile.InfoReady;
|
||||||
|
|
||||||
@ -52,10 +53,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
private void OnRomDownloaded(int romID)
|
private void OnRomDownloaded(int romID)
|
||||||
{
|
{
|
||||||
if (m_romfile == null) return;
|
if (m_romfile == null || m_romfile.ID != romID) return;
|
||||||
|
|
||||||
m_romfile.CheckLocalFileState();
|
|
||||||
if (m_romfile.RomReady)
|
|
||||||
DownloadComplete.Play();
|
DownloadComplete.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,16 @@ namespace AxibugEmuOnline.Client
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (StarRom) return App.starRomLib;
|
if (StarRom) return App.starRomLib;
|
||||||
else return App.GetRomLib(Platform);
|
else
|
||||||
|
{
|
||||||
|
switch (Platform)
|
||||||
|
{
|
||||||
|
case RomPlatformType.Nes:
|
||||||
|
return App.nesRomLib;
|
||||||
|
default:
|
||||||
|
throw new System.NotImplementedException($"未实现的平台 {Platform}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
Debug.Log($"快照加载:{Helper.FileMD5Hash(App.roomMgr.RawData)}");
|
Debug.Log($"快照加载:{Helper.FileMD5Hash(App.roomMgr.RawData)}");
|
||||||
m_inGameUI.Core.LoadStateFromBytes(App.roomMgr.RawData);
|
m_inGameUI.Core.LoadStateFromBytes(App.roomMgr.RawData);
|
||||||
//TODO ready时上报性能指标
|
//TODO ready时上报性能指标
|
||||||
App.roomMgr.SendRoomPlayerReady(0, 0, 0, 0);
|
App.roomMgr.SendRoomPlayerReady(0,0,0,0);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
m_step = -1;
|
m_step = -1;
|
||||||
|
|||||||
@ -30,11 +30,11 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
m_currentCom = com_floatEdit;
|
m_currentCom = com_floatEdit;
|
||||||
}
|
}
|
||||||
else if (valueMenu.ValueType == typeof(int))
|
else if(valueMenu.ValueType == typeof(int))
|
||||||
{
|
{
|
||||||
m_currentCom = com_intEdit;
|
m_currentCom = com_intEdit;
|
||||||
}
|
}
|
||||||
else if (valueMenu.ValueType == typeof(bool))
|
else if(valueMenu.ValueType == typeof(bool))
|
||||||
{
|
{
|
||||||
m_currentCom = com_boolEdit;
|
m_currentCom = com_boolEdit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using UnityEngine;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using AxibugEmuOnline.Client.Event;
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using AxibugEmuOnline.Client.UI;
|
using AxibugEmuOnline.Client.UI;
|
||||||
using AxibugProtobuf;
|
using AxibugProtobuf;
|
||||||
using Coffee.UIExtensions;
|
using Sony.Vita.Dialog;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -17,8 +17,6 @@ namespace AxibugEmuOnline.Client
|
|||||||
[SerializeField] Slider m_downloadProgress;
|
[SerializeField] Slider m_downloadProgress;
|
||||||
[SerializeField] GameObject m_downloadingFlag;
|
[SerializeField] GameObject m_downloadingFlag;
|
||||||
[SerializeField] GameObject m_romReadyFlag;
|
[SerializeField] GameObject m_romReadyFlag;
|
||||||
[SerializeField]
|
|
||||||
UIShiny DownloadComplete;
|
|
||||||
|
|
||||||
private RomFile m_romFile;
|
private RomFile m_romFile;
|
||||||
|
|
||||||
@ -32,25 +30,6 @@ namespace AxibugEmuOnline.Client
|
|||||||
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListSingleUpdate, OnRoomSignelUpdate);
|
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListSingleUpdate, OnRoomSignelUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEnable()
|
|
||||||
{
|
|
||||||
Eventer.Instance.RegisterEvent<int>(EEvent.OnRomFileDownloaded, OnRomDownloaded);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnDisable()
|
|
||||||
{
|
|
||||||
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRomFileDownloaded, OnRomDownloaded);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRomDownloaded(int romID)
|
|
||||||
{
|
|
||||||
if (m_romFile == null) return;
|
|
||||||
|
|
||||||
m_romFile.CheckLocalFileState();
|
|
||||||
if (m_romFile.RomReady)
|
|
||||||
DownloadComplete.Play();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRoomSignelUpdate(int roomID)
|
private void OnRoomSignelUpdate(int roomID)
|
||||||
{
|
{
|
||||||
if (this.RoomID != roomID) return;
|
if (this.RoomID != roomID) return;
|
||||||
@ -116,7 +95,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}");
|
SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}");
|
||||||
SetIcon(null);
|
SetIcon(null);
|
||||||
|
|
||||||
roomInfo.FetchRomFileInRoomInfo((room, romFile) =>
|
roomInfo.FetchRomFileInRoomInfo(roomInfo.GamePlatformType, (room, romFile) =>
|
||||||
{
|
{
|
||||||
if (room.RoomID != RoomID) return;
|
if (room.RoomID != RoomID) return;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using AxibugEmuOnline.Client.Event;
|
using AxibugEmuOnline.Client.Event;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
|
|||||||
@ -34,7 +34,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
|
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
|
||||||
public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, Action<Protobuf_Room_MiniInfo, RomFile> callback)
|
public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, RomPlatformType platform, Action<Protobuf_Room_MiniInfo, RomFile> callback)
|
||||||
{
|
{
|
||||||
RomFile romFile;
|
RomFile romFile;
|
||||||
|
|
||||||
@ -43,15 +43,19 @@ namespace AxibugEmuOnline.Client
|
|||||||
callback.Invoke(roomInfo, romFile);
|
callback.Invoke(roomInfo, romFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
switch (platform)
|
||||||
|
{
|
||||||
|
case RomPlatformType.Nes:
|
||||||
App.StartCoroutine(App.httpAPI.GetRomInfo(roomInfo.GameRomID, (romWebData) =>
|
App.StartCoroutine(App.httpAPI.GetRomInfo(roomInfo.GameRomID, (romWebData) =>
|
||||||
{
|
{
|
||||||
RomFile _romFile = new RomFile(0, 0, (RomPlatformType)romWebData.ptype);
|
RomFile _romFile = new RomFile(0, 0);
|
||||||
_romFile.SetWebData(romWebData);
|
_romFile.SetWebData(romWebData);
|
||||||
s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile;
|
s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile;
|
||||||
|
|
||||||
callback.Invoke(roomInfo, _romFile);
|
callback.Invoke(roomInfo, _romFile);
|
||||||
}));
|
}));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user