forked from sin365/AxibugEmuOnline
Compare commits
No commits in common. "c147e1dd91c801ba5033108657c2289d167ddc92" and "4af2168748c650cd0b07000196ff2246473ead9f" have entirely different histories.
c147e1dd91
...
4af2168748
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:
|
||||
@ -3,7 +3,6 @@ using AxibugEmuOnline.Client.Network;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
@ -23,6 +22,14 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
public static AppChat chat;
|
||||
public static UserDataManager user;
|
||||
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 CacheManager CacheMgr;
|
||||
public static AppRoom roomMgr;
|
||||
@ -32,12 +39,6 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
public static SaveSlotManager SavMgr;
|
||||
static bool bTest;
|
||||
static string mTestSrvIP;
|
||||
|
||||
|
||||
/// <summary> 收藏 Rom库 </summary>
|
||||
public static RomLib starRomLib;
|
||||
private static Dictionary<RomPlatformType, RomLib> s_romLibs = new Dictionary<RomPlatformType, RomLib>();
|
||||
|
||||
#region Mono
|
||||
public static TickLoop tickLoop;
|
||||
private static CoroutineRunner coRunner;
|
||||
@ -61,11 +62,6 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
}
|
||||
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 = "")
|
||||
{
|
||||
log = new LogManager(OnLogOut);
|
||||
@ -85,14 +81,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
httpAPI = new HttpAPI();
|
||||
if (bUseLocalWebApi)
|
||||
httpAPI.WebHost = mLocalWebApi;
|
||||
|
||||
foreach (RomPlatformType plat in Enum.GetValues(typeof(RomPlatformType)))
|
||||
{
|
||||
if (plat == RomPlatformType.All || plat == RomPlatformType.Invalid) continue;
|
||||
|
||||
s_romLibs[plat] = new RomLib(plat);
|
||||
}
|
||||
|
||||
nesRomLib = new RomLib(RomPlatformType.Nes);
|
||||
starRomLib = new RomLib();
|
||||
CacheMgr = new CacheManager();
|
||||
roomMgr = new AppRoom();
|
||||
@ -132,7 +121,6 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static IEnumerator AppTickFlow()
|
||||
{
|
||||
while (true)
|
||||
@ -223,7 +211,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
|
||||
private static void Tick()
|
||||
{
|
||||
foreach (var romLib in s_romLibs.Values) romLib.ExecuteFetchRomInfo();
|
||||
nesRomLib.ExecuteFetchRomInfo();
|
||||
starRomLib.ExecuteFetchRomInfo();
|
||||
|
||||
gamePadMgr.Update();
|
||||
|
||||
@ -32,7 +32,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
if (!m_emuCore.IsNull()) StopGame();
|
||||
|
||||
var roomInfo = App.roomMgr.mineRoomMiniInfo;
|
||||
roomInfo.FetchRomFileInRoomInfo((_, romFile) =>
|
||||
roomInfo.FetchRomFileInRoomInfo(RomPlatformType.Nes, (_, romFile) =>
|
||||
{
|
||||
if (!romFile.RomReady) //这个rom并没有下载,所以取消进入房间
|
||||
{
|
||||
|
||||
@ -282,8 +282,7 @@ namespace AxibugEmuOnline.Client
|
||||
/// <summary>
|
||||
/// 是否收藏
|
||||
/// </summary>
|
||||
public int isStar;
|
||||
public List<int> parentRomIdsList;
|
||||
public int isStar;
|
||||
}
|
||||
[Serializable]
|
||||
public class Resp_CheckStandInfo
|
||||
|
||||
@ -4,7 +4,6 @@ using AxibugProtobuf;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
@ -14,103 +13,41 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
private HttpAPI.Resp_RomInfo webData;
|
||||
private bool hasLocalFile;
|
||||
//private UnityWebRequest downloadRequest;
|
||||
private AxiHttpProxy.SendDownLoadProxy downloadRequest;
|
||||
/// <summary> 依赖的Rom文件 </summary>
|
||||
private List<RomFile> dependencies = new List<RomFile>();
|
||||
|
||||
/// <summary> 指示该Rom是否是多文件Rom </summary>
|
||||
public bool MultiFileRom
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Platform)
|
||||
{
|
||||
case RomPlatformType.Nes: return false;
|
||||
case RomPlatformType.Cps1: return true;
|
||||
default: throw new NotImplementedException($"未实现的平台{Platform}");
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool IsUserRom { get; private set; }
|
||||
|
||||
/// <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>
|
||||
public bool RomReady
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!hasLocalFile) return false;
|
||||
|
||||
foreach (var depRom in dependencies)
|
||||
{
|
||||
if (!depRom.RomReady) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool RomReady => hasLocalFile;
|
||||
///// <summary> 指示是否正在下载Rom文件 </summary>
|
||||
//public bool IsDownloading => downloadRequest != null && downloadRequest.result == UnityWebRequest.Result.InProgress;
|
||||
//public float Progress => IsDownloading ? downloadRequest.downloadProgress : 0;
|
||||
|
||||
/// <summary> 指示是否正在下载Rom文件 </summary>
|
||||
public bool IsDownloading
|
||||
{
|
||||
get
|
||||
{
|
||||
var selfDownloading = downloadRequest != null && !downloadRequest.downloadHandler.isDone;
|
||||
if (selfDownloading) return true;
|
||||
|
||||
foreach (var depRom in dependencies)
|
||||
{
|
||||
if (depRom.IsDownloading) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsDownloading) return 0;
|
||||
|
||||
float total = 0f;
|
||||
|
||||
total += downloadRequest != null ? downloadRequest.downloadHandler.DownLoadPr : 0;
|
||||
foreach (var depRom in dependencies)
|
||||
{
|
||||
total += depRom.Progress;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
public bool IsDownloading => downloadRequest != null && !downloadRequest.downloadHandler.isDone;
|
||||
public float Progress => IsDownloading ? downloadRequest.downloadHandler.DownLoadPr : 0;
|
||||
|
||||
|
||||
public RomPlatformType Platform => webData != null ? (RomPlatformType)webData.ptype : RomPlatformType.Invalid;
|
||||
/// <summary> 指示该Rom信息是否已填充 </summary>
|
||||
public bool InfoReady
|
||||
{
|
||||
get
|
||||
{
|
||||
if (webData == null) return false;
|
||||
|
||||
foreach (var depRom in dependencies)
|
||||
{
|
||||
if (!depRom.InfoReady) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool InfoReady => webData != null;
|
||||
/// <summary> 唯一标识 </summary>
|
||||
public int ID => webData != null ? webData.id : -1;
|
||||
/// <summary> 别名 </summary>
|
||||
public string Alias => webData.romName;
|
||||
public string Alias => IsUserRom ? Path.GetFileNameWithoutExtension(FileName) : webData.romName;
|
||||
/// <summary> 描述 </summary>
|
||||
public string Descript => webData.desc;
|
||||
public string Descript => IsUserRom ? string.Empty : webData.desc;
|
||||
/// <summary> 游戏类型 </summary>
|
||||
public string GameTypeDes => webData.gType;
|
||||
public string GameTypeDes => IsUserRom ? string.Empty : webData.gType;
|
||||
/// <summary> 小图URL </summary>
|
||||
public string ImageURL => webData.imgUrl;
|
||||
public string ImageURL => IsUserRom ? string.Empty : webData.imgUrl;
|
||||
|
||||
/// <summary> 文件名 </summary>
|
||||
public string FileName { get; private set; }
|
||||
@ -144,67 +81,25 @@ namespace AxibugEmuOnline.Client
|
||||
if (RomReady) return;
|
||||
if (IsDownloading) return;
|
||||
|
||||
//检查依赖Rom的下载情况
|
||||
|
||||
App.StartCoroutine(DownloadRemoteRom((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));
|
||||
while (true)
|
||||
{
|
||||
if (bytes != null)
|
||||
{
|
||||
var currentEntry = zip.GetNextEntry();
|
||||
if (currentEntry == null) break;
|
||||
var directPath = Path.GetDirectoryName(LocalFilePath);
|
||||
Directory.CreateDirectory(directPath);
|
||||
|
||||
if (currentEntry.IsDirectory) continue;
|
||||
File.WriteAllBytes(LocalFilePath, bytes);
|
||||
hasLocalFile = true;
|
||||
|
||||
Eventer.Instance.PostEvent(EEvent.OnRomFileDownloaded, ID);
|
||||
}
|
||||
OnDownloadOver?.Invoke(this);
|
||||
}));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
foreach (var item in unzipFiles)
|
||||
{
|
||||
var path = item.Key;
|
||||
var data = item.Value;
|
||||
File.WriteAllBytes(path, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var directPath = Path.GetDirectoryName(LocalFilePath);
|
||||
Directory.CreateDirectory(directPath);
|
||||
|
||||
File.WriteAllBytes(LocalFilePath, bytes);
|
||||
hasLocalFile = true;
|
||||
|
||||
Eventer.Instance.PostEvent(EEvent.OnRomFileDownloaded, ID);
|
||||
}
|
||||
OnDownloadOver?.Invoke(this);
|
||||
}
|
||||
|
||||
public byte[] GetRomFileData()
|
||||
{
|
||||
Debug.Assert(!MultiFileRom, "仅供单文件Rom使用的接口");
|
||||
|
||||
if (webData == null) throw new Exception("Not Valid Rom");
|
||||
if (!IsUserRom && webData == null) throw new Exception("Not Valid Rom");
|
||||
if (!RomReady) throw new Exception("Rom File Not Downloaded");
|
||||
|
||||
var bytes = File.ReadAllBytes(LocalFilePath);
|
||||
@ -251,45 +146,50 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
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)
|
||||
{
|
||||
webData = resp_RomInfo;
|
||||
FileName = MultiFileRom ? Path.GetFileNameWithoutExtension(webData.url) : Path.GetFileName(webData.url);
|
||||
FileName = Path.GetFileName(webData.url);
|
||||
FileName = System.Net.WebUtility.UrlDecode(FileName);
|
||||
|
||||
if (MultiFileRom)
|
||||
hasLocalFile = Directory.Exists(LocalFilePath);
|
||||
else
|
||||
hasLocalFile = File.Exists(LocalFilePath);
|
||||
|
||||
//收集依赖Rom
|
||||
if (webData.parentRomIdsList != null)
|
||||
{
|
||||
foreach (var romID in webData.parentRomIdsList)
|
||||
{
|
||||
var romFile = new RomFile(Index, Page);
|
||||
dependencies.Add(romFile);
|
||||
App.StartCoroutine(App.httpAPI.GetRomInfo(romID, (romInfo) =>
|
||||
{
|
||||
romFile.SetWebData(romInfo);
|
||||
}));
|
||||
}
|
||||
if (File.Exists(LocalFilePath))
|
||||
{
|
||||
var fileBytes = File.ReadAllBytes(LocalFilePath);
|
||||
var localHash = RomLib.CalcHash(fileBytes);
|
||||
|
||||
hasLocalFile = localHash == webData.hash;
|
||||
if (!hasLocalFile)
|
||||
File.Delete(LocalFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
hasLocalFile = false;
|
||||
}
|
||||
|
||||
App.StartCoroutine(WaitInfoReady());
|
||||
}
|
||||
|
||||
private IEnumerator WaitInfoReady()
|
||||
{
|
||||
while (!InfoReady) yield return null;
|
||||
|
||||
OnInfoFilled?.Invoke();
|
||||
OnInfoFilled?.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugProtobuf;
|
||||
using AxiReplay;
|
||||
using System;
|
||||
using System.IO;
|
||||
@ -21,7 +20,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
try
|
||||
{
|
||||
var romFile = App.GetRomLib(RomPlatformType.Nes).GetRomFile(fname);
|
||||
var romFile = App.nesRomLib.GetRomFile(fname);
|
||||
var bytes = romFile.GetRomFileData();
|
||||
Debug.Log($"Open {romFile.Alias}");
|
||||
return new MemoryStream(bytes);
|
||||
@ -35,7 +34,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
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);
|
||||
|
||||
fullPath = romFile.LocalFilePath;
|
||||
|
||||
@ -70,7 +70,7 @@ namespace AxibugEmuOnline.Client
|
||||
Supporter.Setup(m_coreSupporter);
|
||||
Debuger.Setup(new CoreDebuger());
|
||||
|
||||
App.GetRomLib(RomPlatformType.Nes).AddRomFile(rom);
|
||||
App.nesRomLib.AddRomFile(rom);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@ -157,16 +157,15 @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Pbmx5SG9zdBABEhEKDVdhaXRSYXdVcGRhdGUQAhIN",
|
||||
"CglXYWl0UmVhZHkQAxIJCgVQYXVzZRAEEhAKDEluT25saW5lR2FtZRAFKk4K",
|
||||
"EUxvZ2luUmVzdWx0U3RhdHVzEiEKHUxvZ2luUmVzdWx0U3RhdHVzX0Jhc2VE",
|
||||
"ZWZhdWx0EAASBgoCT0sQARIOCgpBY2NvdW50RXJyEAJCAkgBYgZwcm90bzM="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.GamePadType), typeof(global::AxibugProtobuf.RomPlatformType), typeof(global::AxibugProtobuf.RoomGameState), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
@ -474,10 +473,6 @@ namespace AxibugProtobuf {
|
||||
[pbr::OriginalName("Coleco_Vision")] ColecoVision = 6,
|
||||
[pbr::OriginalName("SC_3000")] Sc3000 = 7,
|
||||
[pbr::OriginalName("SG_1000")] Sg1000 = 8,
|
||||
[pbr::OriginalName("NEOGEO")] Neogeo = 20,
|
||||
[pbr::OriginalName("IGS")] Igs = 21,
|
||||
[pbr::OriginalName("CPS1")] Cps1 = 22,
|
||||
[pbr::OriginalName("CPS2")] Cps2 = 23,
|
||||
[pbr::OriginalName("All")] All = 999,
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using AxibugEmuOnline.Client.UI;
|
||||
using AxibugProtobuf;
|
||||
using Coffee.UIExtensions;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@ -36,7 +35,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
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;
|
||||
|
||||
|
||||
@ -17,7 +17,16 @@ namespace AxibugEmuOnline.Client
|
||||
get
|
||||
{
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ namespace AxibugEmuOnline.Client
|
||||
SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}");
|
||||
SetIcon(null);
|
||||
|
||||
roomInfo.FetchRomFileInRoomInfo((room, romFile) =>
|
||||
roomInfo.FetchRomFileInRoomInfo(roomInfo.GamePlatformType, (room, romFile) =>
|
||||
{
|
||||
if (room.RoomID != RoomID) return;
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -42,16 +42,20 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
callback.Invoke(roomInfo, romFile);
|
||||
return;
|
||||
}
|
||||
|
||||
App.StartCoroutine(App.httpAPI.GetRomInfo(roomInfo.GameRomID, (romWebData) =>
|
||||
{
|
||||
RomFile _romFile = new RomFile(0, 0);
|
||||
_romFile.SetWebData(romWebData);
|
||||
s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile;
|
||||
|
||||
callback.Invoke(roomInfo, _romFile);
|
||||
}));
|
||||
}
|
||||
switch (platform)
|
||||
{
|
||||
case RomPlatformType.Nes:
|
||||
App.StartCoroutine(App.httpAPI.GetRomInfo(roomInfo.GameRomID, (romWebData) =>
|
||||
{
|
||||
RomFile _romFile = new RomFile(0, 0);
|
||||
_romFile.SetWebData(romWebData);
|
||||
s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile;
|
||||
|
||||
callback.Invoke(roomInfo, _romFile);
|
||||
}));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,8 @@ using AxibugEmuOnline.Web.Common;
|
||||
using AxibugProtobuf;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MySql.Data.MySqlClient;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using Mysqlx.Crud;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
namespace AxibugEmuOnline.Web.Controllers
|
||||
{
|
||||
@ -15,7 +16,7 @@ namespace AxibugEmuOnline.Web.Controllers
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
static bool TryDecrypToken(string tokenStr, out Protobuf_Token_Struct tokenData)
|
||||
static bool TryDecrypToken(string tokenStr,out Protobuf_Token_Struct tokenData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tokenStr) || string.IsNullOrEmpty(tokenStr.Trim()))
|
||||
{
|
||||
@ -52,7 +53,7 @@ namespace AxibugEmuOnline.Web.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult RomList(string SearchKey, int Ptype, int GType, int Page, int PageSize, string Token)
|
||||
public JsonResult RomList(string SearchKey, int Ptype, int GType, int Page, int PageSize,string Token)
|
||||
{
|
||||
long UID = 0;
|
||||
if (TryDecrypToken(Token, out Protobuf_Token_Struct tokenData))
|
||||
@ -98,10 +99,7 @@ namespace AxibugEmuOnline.Web.Controllers
|
||||
{
|
||||
resp.resultAllCount = reader.GetInt32(0);
|
||||
resp.page = Page;
|
||||
if (PageSize > 0)
|
||||
resp.maxPage = (int)Math.Ceiling((float)resp.resultAllCount / PageSize);
|
||||
else
|
||||
resp.maxPage = 0;
|
||||
resp.maxPage = (int)Math.Ceiling((float)resp.resultAllCount / PageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,7 +107,7 @@ namespace AxibugEmuOnline.Web.Controllers
|
||||
|
||||
string HotOrderBy = "ORDER BY playcount DESC, id ASC";
|
||||
|
||||
query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash`,`playcount`,`stars`,`PlatformType`,`parentids` FROM romlist where `Name` like ?searchPattern {platformCond} {GameTypeCond} {HotOrderBy} LIMIT ?offset, ?pageSize;";
|
||||
query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash`,`playcount`,`stars`,`PlatformType` FROM romlist where `Name` like ?searchPattern {platformCond} {GameTypeCond} {HotOrderBy} LIMIT ?offset, ?pageSize;";
|
||||
using (var command = new MySqlCommand(query, conn))
|
||||
{
|
||||
// 设置参数值
|
||||
@ -136,15 +134,7 @@ namespace AxibugEmuOnline.Web.Controllers
|
||||
stars = reader.GetInt32(8),
|
||||
ptype = reader.GetInt32(9),
|
||||
};
|
||||
string parentsStr = !reader.IsDBNull(10) ? reader.GetString(10) : string.Empty;
|
||||
if (!string.IsNullOrEmpty(parentsStr))
|
||||
{
|
||||
int[] arr = Array.ConvertAll(parentsStr.Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s));
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
data.parentRomIdsList.Add(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (UID > 0)
|
||||
{
|
||||
if (CheckIsRomStar(data.id, UID))
|
||||
@ -209,10 +199,7 @@ namespace AxibugEmuOnline.Web.Controllers
|
||||
{
|
||||
resp.resultAllCount = reader.GetInt32(0);
|
||||
resp.page = Page;
|
||||
if (PageSize > 0)
|
||||
resp.maxPage = (int)Math.Ceiling((float)resp.resultAllCount / PageSize);
|
||||
else
|
||||
resp.maxPage = 0;
|
||||
resp.maxPage = (int)Math.Ceiling((float)resp.resultAllCount / PageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -220,7 +207,7 @@ namespace AxibugEmuOnline.Web.Controllers
|
||||
|
||||
string HotOrderBy = "ORDER BY playcount DESC, id ASC";
|
||||
|
||||
query = @$"SELECT romlist.id,romlist.`Name`,romlist.GameType,romlist.Note,romlist.RomUrl,romlist.ImgUrl,romlist.`Hash`,romlist.`playcount`,romlist.`stars`,romlist.`PlatformType` ,mlist.`parentids`
|
||||
query = @$"SELECT romlist.id,romlist.`Name`,romlist.GameType,romlist.Note,romlist.RomUrl,romlist.ImgUrl,romlist.`Hash`,romlist.`playcount`,romlist.`stars`,romlist.`PlatformType`
|
||||
from rom_stars
|
||||
LEFT JOIN romlist on romlist.Id = rom_stars.romid
|
||||
where rom_stars.uid = ?uid
|
||||
@ -253,15 +240,6 @@ LIMIT ?offset, ?pageSize;";
|
||||
stars = reader.GetInt32(8),
|
||||
ptype = reader.GetInt32(9),
|
||||
};
|
||||
string parentsStr = !reader.IsDBNull(10) ? reader.GetString(10) : string.Empty;
|
||||
if (!string.IsNullOrEmpty(parentsStr))
|
||||
{
|
||||
int[] arr = Array.ConvertAll(parentsStr.Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s));
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
data.parentRomIdsList.Add(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//毕竟都是已经收藏了的
|
||||
data.isStar = 1;
|
||||
@ -288,7 +266,7 @@ LIMIT ?offset, ?pageSize;";
|
||||
Resp_RomInfo resp = new Resp_RomInfo();
|
||||
MySqlConnection conn = SQLPool.DequeueSQLConn("NesRomList");
|
||||
{
|
||||
string query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash`,`playcount`,`stars`,`PlatformType`,mlist.`parentids` FROM romlist where id = ?romid;";
|
||||
string query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash`,`playcount`,`stars`,`PlatformType` FROM romlist where id = ?romid;";
|
||||
using (var command = new MySqlCommand(query, conn))
|
||||
{
|
||||
// 设置参数值
|
||||
@ -308,15 +286,6 @@ LIMIT ?offset, ?pageSize;";
|
||||
resp.playcount = reader.GetInt32(7);
|
||||
resp.stars = reader.GetInt32(8);
|
||||
resp.ptype = reader.GetInt32(9);
|
||||
string parentsStr = !reader.IsDBNull(10) ? reader.GetString(10) : string.Empty;
|
||||
if (!string.IsNullOrEmpty(parentsStr))
|
||||
{
|
||||
int[] arr = Array.ConvertAll(parentsStr.Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s));
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
resp.parentRomIdsList.Add(arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -419,7 +388,7 @@ LIMIT ?offset, ?pageSize;";
|
||||
public int stars { get; set; }
|
||||
public int playcount { get; set; }
|
||||
public int isStar { get; set; }
|
||||
public List<int> parentRomIdsList { get; set; } = new List<int>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,16 +157,15 @@ namespace AxibugProtobuf {
|
||||
"bBAFEhQKEFN3aXRjaFByb0NvbnRyb2wQBhIQCgxTd2l0Y2hKb3lDb24QBxIS",
|
||||
"Cg5YQk9YMzYwQ29udHJvbBAIEhIKDlhCT1hPTkVDb250cm9sEAkSEQoNUFNW",
|
||||
"aXRhQ29udHJvbBAKEhIKDldpaVVQYWRDb250cm9sEAsSFAoQV2l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IOCgpBY2NvdW50RXJyEAJCAkgBYgZwcm90bzM="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.GamePadType), typeof(global::AxibugProtobuf.RomPlatformType), typeof(global::AxibugProtobuf.RoomGameState), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
@ -474,10 +473,6 @@ namespace AxibugProtobuf {
|
||||
[pbr::OriginalName("Coleco_Vision")] ColecoVision = 6,
|
||||
[pbr::OriginalName("SC_3000")] Sc3000 = 7,
|
||||
[pbr::OriginalName("SG_1000")] Sg1000 = 8,
|
||||
[pbr::OriginalName("NEOGEO")] Neogeo = 20,
|
||||
[pbr::OriginalName("IGS")] Igs = 21,
|
||||
[pbr::OriginalName("CPS1")] Cps1 = 22,
|
||||
[pbr::OriginalName("CPS2")] Cps2 = 23,
|
||||
[pbr::OriginalName("All")] All = 999,
|
||||
}
|
||||
|
||||
|
||||
@ -143,10 +143,6 @@ enum RomPlatformType
|
||||
Coleco_Vision = 6;
|
||||
SC_3000 = 7;
|
||||
SG_1000 = 8;
|
||||
NEOGEO = 20;
|
||||
IGS = 21;
|
||||
CPS1 = 22;
|
||||
CPS2 = 23;
|
||||
All = 999;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user