master #39
@ -57,7 +57,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
coRunner = go.AddComponent<CoroutineRunner>();
|
coRunner = go.AddComponent<CoroutineRunner>();
|
||||||
|
|
||||||
var importNode = GameObject.Find("IMPORTENT");
|
var importNode = GameObject.Find("IMPORTENT");
|
||||||
GameObject.DontDestroyOnLoad(importNode);
|
if (importNode != null) GameObject.DontDestroyOnLoad(importNode);
|
||||||
|
|
||||||
StartCoroutine(AppTickFlow());
|
StartCoroutine(AppTickFlow());
|
||||||
RePullNetInfo();
|
RePullNetInfo();
|
||||||
@ -79,7 +79,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
|
|
||||||
static IEnumerator StartNetInit()
|
static IEnumerator StartNetInit()
|
||||||
{
|
{
|
||||||
if (App.network.isConnected)
|
if (App.network.isConnected)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
int platform = 0;
|
int platform = 0;
|
||||||
|
@ -11,12 +11,17 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
private HttpAPI.Resp_RomInfo webData;
|
private HttpAPI.Resp_RomInfo webData;
|
||||||
private bool hasLocalFile;
|
private bool hasLocalFile;
|
||||||
private string fileName;
|
|
||||||
private EnumPlatform platform;
|
private EnumPlatform platform;
|
||||||
private UnityWebRequest downloadRequest;
|
private UnityWebRequest downloadRequest;
|
||||||
|
|
||||||
|
public bool IsUserRom { get; private set; }
|
||||||
|
|
||||||
/// <summary> 指示该Rom文件的存放路径 </summary>
|
/// <summary> 指示该Rom文件的存放路径 </summary>
|
||||||
public string LocalFilePath => $"{App.PersistentDataPath}/RemoteRoms/{platform}/{fileName}";
|
public string LocalFilePath =>
|
||||||
|
IsUserRom ?
|
||||||
|
$"{App.PersistentDataPath}/UserRoms/{platform}/{FileName}" :
|
||||||
|
$"{App.PersistentDataPath}/RemoteRoms/{platform}/{FileName}";
|
||||||
|
|
||||||
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
||||||
public bool RomReady => hasLocalFile;
|
public bool RomReady => hasLocalFile;
|
||||||
/// <summary> 指示是否正在下载Rom文件 </summary>
|
/// <summary> 指示是否正在下载Rom文件 </summary>
|
||||||
@ -29,14 +34,14 @@ namespace AxibugEmuOnline.Client
|
|||||||
/// <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> 小图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 => fileName;
|
public string FileName { get; private set; }
|
||||||
/// <summary> 在查询结果中的索引 </summary>
|
/// <summary> 在查询结果中的索引 </summary>
|
||||||
public int Index { get; private set; }
|
public int Index { get; private set; }
|
||||||
/// <summary> 在查询结果中的所在页 </summary>
|
/// <summary> 在查询结果中的所在页 </summary>
|
||||||
@ -74,7 +79,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public byte[] GetRomFileData()
|
public byte[] GetRomFileData()
|
||||||
{
|
{
|
||||||
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");
|
if (!RomReady) throw new Exception("Rom File Not Downloaded");
|
||||||
|
|
||||||
var bytes = File.ReadAllBytes(LocalFilePath);
|
var bytes = File.ReadAllBytes(LocalFilePath);
|
||||||
@ -123,8 +128,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
public void SetWebData(HttpAPI.Resp_RomInfo resp_RomInfo)
|
public void SetWebData(HttpAPI.Resp_RomInfo resp_RomInfo)
|
||||||
{
|
{
|
||||||
webData = resp_RomInfo;
|
webData = resp_RomInfo;
|
||||||
fileName = Path.GetFileName(webData.url);
|
FileName = Path.GetFileName(webData.url);
|
||||||
fileName = System.Net.WebUtility.UrlDecode(fileName);
|
FileName = System.Net.WebUtility.UrlDecode(FileName);
|
||||||
|
|
||||||
if (File.Exists(LocalFilePath))
|
if (File.Exists(LocalFilePath))
|
||||||
{
|
{
|
||||||
@ -142,5 +147,15 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
OnInfoFilled?.Invoke();
|
OnInfoFilled?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RomFile() { }
|
||||||
|
public static RomFile CreateExistRom(EnumPlatform platform, string fileName)
|
||||||
|
{
|
||||||
|
var res = new RomFile();
|
||||||
|
res.IsUserRom = true;
|
||||||
|
res.FileName = fileName;
|
||||||
|
res.hasLocalFile = File.Exists(res.LocalFilePath);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,15 @@ namespace AxibugEmuOnline.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RomFile GetExistRom(string fileName)
|
||||||
|
{
|
||||||
|
var res = RomFile.CreateExistRom(m_platform, fileName);
|
||||||
|
|
||||||
|
nesRomFileNameMapper[res.FileName] = res;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public RomFile GetRomFile(string romFileName)
|
public RomFile GetRomFile(string romFileName)
|
||||||
{
|
{
|
||||||
RomFile romFile;
|
RomFile romFile;
|
||||||
|
@ -82,6 +82,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//加载一个用户自己提供的Rom时,使用这个方法
|
||||||
|
//App.emu.BeginGame(App.nesRomLib.GetExistRom("bad_apple_2_5.nes"));
|
||||||
App.emu.BeginGame(m_romfile);
|
App.emu.BeginGame(m_romfile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user