Merge pull request '重构一下' (#33) from Alienjack/AxibugEmuOnline:master into master

Reviewed-on: #33
This commit is contained in:
sin365 2024-09-11 18:32:23 +08:00
commit 8e61551d3d
21 changed files with 107 additions and 80 deletions

View File

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

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 45d5034162d6cf04dbe46da84fc7d074
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -6,7 +6,7 @@ using UnityEngine;
namespace AxibugEmuOnline.Client.ClientCore namespace AxibugEmuOnline.Client.ClientCore
{ {
public static class AppAxibugEmuOnline public static class App
{ {
public static string TokenStr; public static string TokenStr;
public static string IP; public static string IP;
@ -22,6 +22,7 @@ namespace AxibugEmuOnline.Client.ClientCore
public static HttpAPI httpAPI; public static HttpAPI httpAPI;
public static CacheManager CacheMgr; public static CacheManager CacheMgr;
public static AppSceneLoader SceneLoader; public static AppSceneLoader SceneLoader;
public static AppRoom roomMgr;
private static CoroutineRunner coRunner; private static CoroutineRunner coRunner;
@ -42,6 +43,7 @@ namespace AxibugEmuOnline.Client.ClientCore
nesRomLib = new RomLib(EnumPlatform.NES); nesRomLib = new RomLib(EnumPlatform.NES);
CacheMgr = new CacheManager(); CacheMgr = new CacheManager();
SceneLoader = new AppSceneLoader(); SceneLoader = new AppSceneLoader();
roomMgr = new AppRoom();
var go = new GameObject("[AppAxibugEmuOnline]"); var go = new GameObject("[AppAxibugEmuOnline]");
GameObject.DontDestroyOnLoad(go); GameObject.DontDestroyOnLoad(go);
@ -81,7 +83,7 @@ namespace AxibugEmuOnline.Client.ClientCore
public static void Close() public static void Close()
{ {
AppAxibugEmuOnline.log.Info("停止"); App.log.Info("停止");
} }
static void OnNoSugarNetLog(int LogLevel, string msg) static void OnNoSugarNetLog(int LogLevel, string msg)
{ {

View File

@ -137,7 +137,7 @@ namespace AxibugEmuOnline.Client.Event
} }
catch (Exception e) catch (Exception e)
{ {
AppAxibugEmuOnline.log.Error(e.Message); App.log.Error(e.Message);
} }
} }
} }
@ -156,7 +156,7 @@ namespace AxibugEmuOnline.Client.Event
} }
catch (Exception e) catch (Exception e)
{ {
AppAxibugEmuOnline.log.Error(e.Message); App.log.Error(e.Message);
} }
} }
} }
@ -175,7 +175,7 @@ namespace AxibugEmuOnline.Client.Event
} }
catch (Exception e) catch (Exception e)
{ {
AppAxibugEmuOnline.log.Error(e.Message); App.log.Error(e.Message);
} }
} }
} }
@ -194,7 +194,7 @@ namespace AxibugEmuOnline.Client.Event
} }
catch (Exception e) catch (Exception e)
{ {
AppAxibugEmuOnline.log.Error(e.Message + ", method name : " + callback.Method); App.log.Error(e.Message + ", method name : " + callback.Method);
} }
} }
} }
@ -214,7 +214,7 @@ namespace AxibugEmuOnline.Client.Event
} }
catch (Exception e) catch (Exception e)
{ {
AppAxibugEmuOnline.log.Error(e.Message); App.log.Error(e.Message);
} }
} }
} }

View File

@ -19,7 +19,7 @@ namespace AxibugEmuOnline.Client.Manager
{ {
ChatMsg = ChatMsg, ChatMsg = ChatMsg,
}; };
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg)); App.networkHelper.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg));
} }
public void RecvChatMsg(byte[] reqData) public void RecvChatMsg(byte[] reqData)

View File

@ -16,17 +16,17 @@ namespace AxibugEmuOnline.Client.Manager
public void Login() public void Login()
{ {
AppAxibugEmuOnline.log.Debug("-->Login"); App.log.Debug("-->Login");
if (string.IsNullOrEmpty(LastLoginGuid)) if (string.IsNullOrEmpty(LastLoginGuid))
LastLoginGuid = Guid.NewGuid().ToString(); LastLoginGuid = Guid.NewGuid().ToString();
AppAxibugEmuOnline.user.userdata.Account = LastLoginGuid; App.user.userdata.Account = LastLoginGuid;
Protobuf_Login msg = new Protobuf_Login() Protobuf_Login msg = new Protobuf_Login()
{ {
LoginType = 0, LoginType = 0,
Account = AppAxibugEmuOnline.user.userdata.Account, Account = App.user.userdata.Account,
}; };
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg)); App.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
} }
public void RecvLoginMsg(byte[] reqData) public void RecvLoginMsg(byte[] reqData)
@ -34,12 +34,12 @@ namespace AxibugEmuOnline.Client.Manager
Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Login_RESP>(reqData); Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Login_RESP>(reqData);
if (msg.Status == LoginResultStatus.Ok) if (msg.Status == LoginResultStatus.Ok)
{ {
AppAxibugEmuOnline.log.Info("登录成功"); App.log.Info("登录成功");
AppAxibugEmuOnline.user.InitMainUserData(AppAxibugEmuOnline.user.userdata.Account, msg.UID); App.user.InitMainUserData(App.user.userdata.Account, msg.UID);
} }
else else
{ {
AppAxibugEmuOnline.log.Info("登录失败"); App.log.Info("登录失败");
} }
} }
} }

View File

@ -24,7 +24,7 @@ namespace AxibugEmuOnline.Client.Manager
byte[] comData = Helper.CompressByteArray(RenderBuffer); byte[] comData = Helper.CompressByteArray(RenderBuffer);
_Protobuf_Screnn_Frame.FrameID = 0; _Protobuf_Screnn_Frame.FrameID = 0;
_Protobuf_Screnn_Frame.RawBitmap = ByteString.CopyFrom(comData); _Protobuf_Screnn_Frame.RawBitmap = ByteString.CopyFrom(comData);
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdScreen, ProtoBufHelper.Serizlize(_Protobuf_Screnn_Frame)); App.networkHelper.SendToServer((int)CommandID.CmdScreen, ProtoBufHelper.Serizlize(_Protobuf_Screnn_Frame));
} }
public void OnScreen(byte[] reqData) public void OnScreen(byte[] reqData)

View File

@ -14,7 +14,7 @@ namespace AxibugEmuOnline.Client.Manager
{ {
public Protobuf_Room_MiniInfo mineRoomMiniInfo { get; private set; } = null; public Protobuf_Room_MiniInfo mineRoomMiniInfo { get; private set; } = null;
public bool InRoom => mineRoomMiniInfo != null; public bool InRoom => mineRoomMiniInfo != null;
public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == AppAxibugEmuOnline.user.userdata.UID; public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == App.user.userdata.UID;
public RoomGameState RoomState => mineRoomMiniInfo.GameState; public RoomGameState RoomState => mineRoomMiniInfo.GameState;
public int MinePlayerIdx => GetMinePlayerIndex(); public int MinePlayerIdx => GetMinePlayerIndex();
public int WaitStep { get; private set; } = -1; public int WaitStep { get; private set; } = -1;
@ -100,9 +100,9 @@ namespace AxibugEmuOnline.Client.Manager
if (mineRoomMiniInfo == null) if (mineRoomMiniInfo == null)
return -1; return -1;
if (mineRoomMiniInfo.Player1UID == AppAxibugEmuOnline.user.userdata.UID) if (mineRoomMiniInfo.Player1UID == App.user.userdata.UID)
return 0; return 0;
if (mineRoomMiniInfo.Player2UID == AppAxibugEmuOnline.user.userdata.UID) if (mineRoomMiniInfo.Player2UID == App.user.userdata.UID)
return 1; return 1;
return -1; return -1;
} }
@ -115,7 +115,7 @@ namespace AxibugEmuOnline.Client.Manager
if (mineRoomMiniInfo.Player1UID > 0) if (mineRoomMiniInfo.Player1UID > 0)
result[0] = mineRoomMiniInfo.Player1UID; result[0] = mineRoomMiniInfo.Player1UID;
if (mineRoomMiniInfo.Player2UID == AppAxibugEmuOnline.user.userdata.UID) if (mineRoomMiniInfo.Player2UID == App.user.userdata.UID)
result[1] = mineRoomMiniInfo.Player2UID; result[1] = mineRoomMiniInfo.Player2UID;
return result; return result;
@ -129,8 +129,8 @@ namespace AxibugEmuOnline.Client.Manager
/// <param name="ChatMsg"></param> /// <param name="ChatMsg"></param>
public void SendGetRoomList() public void SendGetRoomList()
{ {
AppAxibugEmuOnline.log.Info("拉取房间列表"); App.log.Info("拉取房间列表");
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomList, ProtoBufHelper.Serizlize(_Protobuf_Room_List)); App.networkHelper.SendToServer((int)CommandID.CmdRoomList, ProtoBufHelper.Serizlize(_Protobuf_Room_List));
} }
/// <summary> /// <summary>
@ -139,7 +139,7 @@ namespace AxibugEmuOnline.Client.Manager
/// <param name="reqData"></param> /// <param name="reqData"></param>
void RecvGetRoomList(byte[] reqData) void RecvGetRoomList(byte[] reqData)
{ {
AppAxibugEmuOnline.log.Info("取得完整房间列表"); App.log.Info("取得完整房间列表");
Protobuf_Room_List_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_List_RESP>(reqData); Protobuf_Room_List_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_List_RESP>(reqData);
for (int i = 0; i < msg.RoomMiniInfoList.Count; i++) for (int i = 0; i < msg.RoomMiniInfoList.Count; i++)
AddOrUpdateRoomList(msg.RoomMiniInfoList[i]); AddOrUpdateRoomList(msg.RoomMiniInfoList[i]);
@ -152,7 +152,7 @@ namespace AxibugEmuOnline.Client.Manager
/// <param name="reqData"></param> /// <param name="reqData"></param>
void RecvGetRoomListUpdate(byte[] reqData) void RecvGetRoomListUpdate(byte[] reqData)
{ {
AppAxibugEmuOnline.log.Debug("单个房间状态更新"); App.log.Debug("单个房间状态更新");
Protobuf_Room_Update_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Update_RESP>(reqData); Protobuf_Room_Update_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Update_RESP>(reqData);
AddOrUpdateRoomList(msg.RoomMiniInfo); AddOrUpdateRoomList(msg.RoomMiniInfo);
EventSystem.Instance.PostEvent(EEvent.OnRoomListSingleUpdate, msg.RoomMiniInfo.GameRomID); EventSystem.Instance.PostEvent(EEvent.OnRoomListSingleUpdate, msg.RoomMiniInfo.GameRomID);
@ -169,8 +169,8 @@ namespace AxibugEmuOnline.Client.Manager
_Protobuf_Room_Create.JoinPlayerIdx = JoinPlayerIdx; _Protobuf_Room_Create.JoinPlayerIdx = JoinPlayerIdx;
_Protobuf_Room_Create.GameRomID = GameRomID; _Protobuf_Room_Create.GameRomID = GameRomID;
_Protobuf_Room_Create.GameRomHash = GameRomHash; _Protobuf_Room_Create.GameRomHash = GameRomHash;
AppAxibugEmuOnline.log.Info($"创建房间"); App.log.Info($"创建房间");
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomCreate, ProtoBufHelper.Serizlize(_Protobuf_Room_Create)); App.networkHelper.SendToServer((int)CommandID.CmdRoomCreate, ProtoBufHelper.Serizlize(_Protobuf_Room_Create));
} }
/// <summary> /// <summary>
@ -179,7 +179,7 @@ namespace AxibugEmuOnline.Client.Manager
/// <param name="reqData"></param> /// <param name="reqData"></param>
void RecvCreateRoom(byte[] reqData) void RecvCreateRoom(byte[] reqData)
{ {
AppAxibugEmuOnline.log.Debug("创建房间成功"); App.log.Debug("创建房间成功");
Protobuf_Room_Create_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Create_RESP>(reqData); Protobuf_Room_Create_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Create_RESP>(reqData);
mineRoomMiniInfo = msg.RoomMiniInfo; mineRoomMiniInfo = msg.RoomMiniInfo;
} }
@ -194,8 +194,8 @@ namespace AxibugEmuOnline.Client.Manager
{ {
_Protobuf_Room_Join.RoomID = RoomID; _Protobuf_Room_Join.RoomID = RoomID;
_Protobuf_Room_Join.PlayerNum = JoinPlayerIdx; _Protobuf_Room_Join.PlayerNum = JoinPlayerIdx;
AppAxibugEmuOnline.log.Info($"创建房间"); App.log.Info($"创建房间");
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomJoin, ProtoBufHelper.Serizlize(_Protobuf_Room_Join)); App.networkHelper.SendToServer((int)CommandID.CmdRoomJoin, ProtoBufHelper.Serizlize(_Protobuf_Room_Join));
} }
/// <summary> /// <summary>
@ -204,7 +204,7 @@ namespace AxibugEmuOnline.Client.Manager
/// <param name="reqData"></param> /// <param name="reqData"></param>
void RecvJoinRoom(byte[] reqData) void RecvJoinRoom(byte[] reqData)
{ {
AppAxibugEmuOnline.log.Debug("加入房间成功"); App.log.Debug("加入房间成功");
Protobuf_Room_Join_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Join_RESP>(reqData); Protobuf_Room_Join_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Join_RESP>(reqData);
mineRoomMiniInfo = msg.RoomMiniInfo; mineRoomMiniInfo = msg.RoomMiniInfo;
InitRePlay(); InitRePlay();
@ -218,8 +218,8 @@ namespace AxibugEmuOnline.Client.Manager
public void SendLeavnRoom(int RoomID) public void SendLeavnRoom(int RoomID)
{ {
_Protobuf_Room_Leave.RoomID = RoomID; _Protobuf_Room_Leave.RoomID = RoomID;
AppAxibugEmuOnline.log.Info($"创建房间"); App.log.Info($"创建房间");
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomLeave, ProtoBufHelper.Serizlize(_Protobuf_Room_Leave)); App.networkHelper.SendToServer((int)CommandID.CmdRoomLeave, ProtoBufHelper.Serizlize(_Protobuf_Room_Leave));
} }
/// <summary> /// <summary>
@ -228,7 +228,7 @@ namespace AxibugEmuOnline.Client.Manager
/// <param name="reqData"></param> /// <param name="reqData"></param>
void RecvLeavnRoom(byte[] reqData) void RecvLeavnRoom(byte[] reqData)
{ {
AppAxibugEmuOnline.log.Debug("加入房间成功"); App.log.Debug("加入房间成功");
Protobuf_Room_Leave_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Leave_RESP>(reqData); Protobuf_Room_Leave_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Leave_RESP>(reqData);
ReleaseRePlay(); ReleaseRePlay();
mineRoomMiniInfo = null; mineRoomMiniInfo = null;
@ -271,8 +271,8 @@ namespace AxibugEmuOnline.Client.Manager
{ {
LoadStateRaw = Google.Protobuf.ByteString.CopyFrom(compressRawData) LoadStateRaw = Google.Protobuf.ByteString.CopyFrom(compressRawData)
}; };
AppAxibugEmuOnline.log.Info($"上报即时存档数据 原数据大小:{RawData.Length},压缩后;{compressRawData.Length}"); App.log.Info($"上报即时存档数据 原数据大小:{RawData.Length},压缩后;{compressRawData.Length}");
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomHostPlayerUpdateStateRaw, ProtoBufHelper.Serizlize(msg)); App.networkHelper.SendToServer((int)CommandID.CmdRoomHostPlayerUpdateStateRaw, ProtoBufHelper.Serizlize(msg));
} }
void RecvRoom_WaitStep(byte[] reqData) void RecvRoom_WaitStep(byte[] reqData)
@ -285,7 +285,7 @@ namespace AxibugEmuOnline.Client.Manager
if (WaitStep == 1) if (WaitStep == 1)
{ {
byte[] decompressRawData = Helper.DecompressByteArray(msg.LoadStateRaw.ToByteArray()); byte[] decompressRawData = Helper.DecompressByteArray(msg.LoadStateRaw.ToByteArray());
AppAxibugEmuOnline.log.Info($"收到即时存档数据 解压后;{decompressRawData.Length}"); App.log.Info($"收到即时存档数据 解压后;{decompressRawData.Length}");
RawData = decompressRawData; RawData = decompressRawData;
} }
} }
@ -294,7 +294,7 @@ namespace AxibugEmuOnline.Client.Manager
void RecvHostPlayer_UpdateStateRaw(byte[] reqData) void RecvHostPlayer_UpdateStateRaw(byte[] reqData)
{ {
Protobuf_Room_HostPlayer_UpdateStateRaw_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_HostPlayer_UpdateStateRaw_RESP>(reqData); Protobuf_Room_HostPlayer_UpdateStateRaw_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_HostPlayer_UpdateStateRaw_RESP>(reqData);
AppAxibugEmuOnline.log.Info($"鸡翅孙当上报成功"); App.log.Info($"鸡翅孙当上报成功");
} }
/// <summary> /// <summary>
@ -302,8 +302,8 @@ namespace AxibugEmuOnline.Client.Manager
/// </summary> /// </summary>
public void SendRoomPlayerReady() public void SendRoomPlayerReady()
{ {
AppAxibugEmuOnline.log.Debug("上报准备完毕"); App.log.Debug("上报准备完毕");
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomPlayerReady, ProtoBufHelper.Serizlize(_Protobuf_Room_Player_Ready)); App.networkHelper.SendToServer((int)CommandID.CmdRoomPlayerReady, ProtoBufHelper.Serizlize(_Protobuf_Room_Player_Ready));
} }
/// <summary> /// <summary>
@ -313,7 +313,7 @@ namespace AxibugEmuOnline.Client.Manager
{ {
_Protobuf_Room_SinglePlayerInputData.FrameID = FrameID; _Protobuf_Room_SinglePlayerInputData.FrameID = FrameID;
_Protobuf_Room_SinglePlayerInputData.InputData = InputData; _Protobuf_Room_SinglePlayerInputData.InputData = InputData;
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomSingelPlayerInput, ProtoBufHelper.Serizlize(_Protobuf_Room_SinglePlayerInputData)); App.networkHelper.SendToServer((int)CommandID.CmdRoomSingelPlayerInput, ProtoBufHelper.Serizlize(_Protobuf_Room_SinglePlayerInputData));
} }

View File

@ -17,7 +17,7 @@ namespace AxibugEmuOnline.Client
{ {
m_tasks.Enqueue(new LoadTask(scenePath, callback)); m_tasks.Enqueue(new LoadTask(scenePath, callback));
if (m_coroutine == null) if (m_coroutine == null)
m_coroutine = AppAxibugEmuOnline.StartCoroutine(TaskFlow()); m_coroutine = App.StartCoroutine(TaskFlow());
} }
private IEnumerator TaskFlow() private IEnumerator TaskFlow()

View File

@ -10,7 +10,7 @@ namespace AxibugEmuOnline.Client
{ {
public class CacheManager public class CacheManager
{ {
static readonly string CacheDirPath = $"{AppAxibugEmuOnline.PersistentDataPath}/Caches"; static readonly string CacheDirPath = $"{App.PersistentDataPath}/Caches";
static readonly string TextureCacheDirPath = $"{CacheDirPath}/Texture"; static readonly string TextureCacheDirPath = $"{CacheDirPath}/Texture";
public void GetSpriteCache(string url, Action<Sprite, string> callback) public void GetSpriteCache(string url, Action<Sprite, string> callback)
@ -27,7 +27,7 @@ namespace AxibugEmuOnline.Client
IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback) IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback)
{ {
var request = UnityWebRequest.Get($"{AppAxibugEmuOnline.httpAPI.DownSite}/{url}"); var request = UnityWebRequest.Get($"{App.httpAPI.DownSite}/{url}");
yield return request.SendWebRequest(); yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success) if (request.result == UnityWebRequest.Result.Success)
@ -62,7 +62,7 @@ namespace AxibugEmuOnline.Client
} }
else else
{ {
AppAxibugEmuOnline.StartCoroutine(DownloadFromURL(url, path, (data) => App.StartCoroutine(DownloadFromURL(url, path, (data) =>
{ {
var @out = RawDataConvert<T>(data); var @out = RawDataConvert<T>(data);
cachesInMemory[url] = @out; cachesInMemory[url] = @out;

View File

@ -16,7 +16,7 @@ namespace AxibugEmuOnline.Client
public void GetNesRomList(Action<Resp_GameList> callback, int page, int pageSize = 10) public void GetNesRomList(Action<Resp_GameList> callback, int page, int pageSize = 10)
{ {
AppAxibugEmuOnline.StartCoroutine(GetNesRomListFlow(page, pageSize, callback)); App.StartCoroutine(GetNesRomListFlow(page, pageSize, callback));
} }
private IEnumerator GetNesRomListFlow(int page, int pageSize, Action<Resp_GameList> callback) private IEnumerator GetNesRomListFlow(int page, int pageSize, Action<Resp_GameList> callback)

View File

@ -16,7 +16,7 @@ namespace AxibugEmuOnline.Client
private UnityWebRequest downloadRequest; private UnityWebRequest downloadRequest;
/// <summary> 指示该Rom文件的存放路径 </summary> /// <summary> 指示该Rom文件的存放路径 </summary>
public string LocalFilePath => $"{AppAxibugEmuOnline.PersistentDataPath}/RemoteRoms/{platform}/{fileName}"; public string LocalFilePath => $"{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>
@ -57,7 +57,7 @@ namespace AxibugEmuOnline.Client
if (RomReady) return; if (RomReady) return;
if (IsDownloading) return; if (IsDownloading) return;
AppAxibugEmuOnline.StartCoroutine(DownloadRemoteRom((bytes) => App.StartCoroutine(DownloadRemoteRom((bytes) =>
{ {
if (bytes != null) if (bytes != null)
{ {
@ -106,7 +106,7 @@ namespace AxibugEmuOnline.Client
private IEnumerator DownloadRemoteRom(Action<byte[]> callback) private IEnumerator DownloadRemoteRom(Action<byte[]> callback)
{ {
downloadRequest = UnityWebRequest.Get($"{AppAxibugEmuOnline.httpAPI.DownSite}/{webData.url}"); downloadRequest = UnityWebRequest.Get($"{App.httpAPI.DownSite}/{webData.url}");
yield return downloadRequest.SendWebRequest(); yield return downloadRequest.SendWebRequest();
if (downloadRequest.result != UnityWebRequest.Result.Success) if (downloadRequest.result != UnityWebRequest.Result.Success)

View File

@ -26,7 +26,7 @@ namespace AxibugEmuOnline.Client
switch (platform) switch (platform)
{ {
case EnumPlatform.NES: case EnumPlatform.NES:
m_romGetFunc = AppAxibugEmuOnline.httpAPI.GetNesRomList; m_romGetFunc = App.httpAPI.GetNesRomList;
break; break;
} }
} }
@ -41,7 +41,7 @@ namespace AxibugEmuOnline.Client
/// <summary> 清除所有下载的Rom文件 </summary> /// <summary> 清除所有下载的Rom文件 </summary>
public void ClearRomFile() public void ClearRomFile()
{ {
var path = $"{AppAxibugEmuOnline.PersistentDataPath}/RemoteRoms/{m_platform}"; var path = $"{App.PersistentDataPath}/RemoteRoms/{m_platform}";
if (Directory.Exists(path)) Directory.Delete(path, true); if (Directory.Exists(path)) Directory.Delete(path, true);
} }

View File

@ -18,7 +18,7 @@ namespace AxibugEmuOnline.Client.Manager
public UserDataManager() public UserDataManager()
{ {
//注册重连成功事件,以便后续自动登录 //注册重连成功事件,以便后续自动登录
AppAxibugEmuOnline.networkHelper.OnReConnected += OnReConnected; App.networkHelper.OnReConnected += OnReConnected;
} }
public MainUserDataBase userdata { get; private set; } = new MainUserDataBase(); public MainUserDataBase userdata { get; private set; } = new MainUserDataBase();
public bool IsLoggedIn => userdata.IsLoggedIn; public bool IsLoggedIn => userdata.IsLoggedIn;
@ -50,7 +50,7 @@ namespace AxibugEmuOnline.Client.Manager
//如果之前已登录,则重新登录 //如果之前已登录,则重新登录
if (userdata.IsLoggedIn) if (userdata.IsLoggedIn)
{ {
AppAxibugEmuOnline.login.Login(); App.login.Login();
} }
} }
} }

View File

@ -12,7 +12,7 @@ namespace AxibugEmuOnline.Client
{ {
try try
{ {
var romFile = AppAxibugEmuOnline.nesRomLib.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);
@ -26,7 +26,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 = AppAxibugEmuOnline.nesRomLib.GetRomFile(fname); var romFile = App.nesRomLib.GetRomFile(fname);
UnityEngine.Debug.Assert(romFile != null); UnityEngine.Debug.Assert(romFile != null);
fullPath = romFile.LocalFilePath; fullPath = romFile.LocalFilePath;
@ -40,7 +40,7 @@ namespace AxibugEmuOnline.Client
public void SaveSRAMToFile(byte[] sramContent, string romName) public void SaveSRAMToFile(byte[] sramContent, string romName)
{ {
string sramDirectoryPath = $"{AppAxibugEmuOnline.PersistentDataPath}/sav"; string sramDirectoryPath = $"{App.PersistentDataPath}/sav";
Directory.CreateDirectory(sramDirectoryPath); Directory.CreateDirectory(sramDirectoryPath);
romName = Path.GetFileNameWithoutExtension(romName); romName = Path.GetFileNameWithoutExtension(romName);
File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent); File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent);
@ -48,7 +48,7 @@ namespace AxibugEmuOnline.Client
public void SaveDISKToFile(byte[] diskFileContent, string romName) public void SaveDISKToFile(byte[] diskFileContent, string romName)
{ {
string diskFileDirectoryPath = $"{AppAxibugEmuOnline.PersistentDataPath}/dsv"; string diskFileDirectoryPath = $"{App.PersistentDataPath}/dsv";
Directory.CreateDirectory(diskFileDirectoryPath); Directory.CreateDirectory(diskFileDirectoryPath);
romName = Path.GetFileNameWithoutExtension(romName); romName = Path.GetFileNameWithoutExtension(romName);
File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent); File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent);
@ -58,14 +58,14 @@ namespace AxibugEmuOnline.Client
public void PrepareDirectory(string directPath) public void PrepareDirectory(string directPath)
{ {
Directory.CreateDirectory($"{AppAxibugEmuOnline.PersistentDataPath}/{directPath}"); Directory.CreateDirectory($"{App.PersistentDataPath}/{directPath}");
} }
public void SaveFile(byte[] fileData, string directPath, string fileName) public void SaveFile(byte[] fileData, string directPath, string fileName)
{ {
PrepareDirectory(directPath); PrepareDirectory(directPath);
var fileFullpath = $"{AppAxibugEmuOnline.PersistentDataPath}/{directPath}/{fileName}"; var fileFullpath = $"{App.PersistentDataPath}/{directPath}/{fileName}";
File.WriteAllBytes(fileFullpath, fileData); File.WriteAllBytes(fileFullpath, fileData);
} }
@ -73,7 +73,7 @@ namespace AxibugEmuOnline.Client
{ {
try try
{ {
var data = File.ReadAllBytes($"{AppAxibugEmuOnline.PersistentDataPath}/{directPath}/{fileName}"); var data = File.ReadAllBytes($"{App.PersistentDataPath}/{directPath}/{fileName}");
if (data == null) return null; if (data == null) return null;
return new MemoryStream(data); return new MemoryStream(data);
} }

View File

@ -8,7 +8,7 @@ namespace AxibugEmuOnline.Client
{ {
public class NesControllerMapper public class NesControllerMapper
{ {
private static readonly string ConfigFilePath = $"{AppAxibugEmuOnline.PersistentDataPath}/NES/ControllerMapper.json"; private static readonly string ConfigFilePath = $"{App.PersistentDataPath}/NES/ControllerMapper.json";
public MapperSetter Player1 = new MapperSetter(); public MapperSetter Player1 = new MapperSetter();
public MapperSetter Player2 = new MapperSetter(); public MapperSetter Player2 = new MapperSetter();
@ -50,7 +50,7 @@ namespace AxibugEmuOnline.Client
{ {
try try
{ {
var json = File.ReadAllText($"{AppAxibugEmuOnline.PersistentDataPath}/Nes/ControllerMapper.json"); var json = File.ReadAllText($"{App.PersistentDataPath}/Nes/ControllerMapper.json");
s_setting = JsonUtility.FromJson<NesControllerMapper>(json); s_setting = JsonUtility.FromJson<NesControllerMapper>(json);
} }
catch catch

View File

@ -70,7 +70,7 @@ namespace AxibugEmuOnline.Client.Network
} }
catch (Exception e) catch (Exception e)
{ {
AppAxibugEmuOnline.log.Error(e.Message); App.log.Error(e.Message);
} }
} }
} }

View File

@ -41,10 +41,10 @@ namespace AxibugEmuOnline.Client.Network
if (IsConnect) if (IsConnect)
{ {
//从未登录过 //从未登录过
if (!AppAxibugEmuOnline.user.IsLoggedIn) if (!App.user.IsLoggedIn)
{ {
//首次登录 //首次登录
AppAxibugEmuOnline.login.Login(); App.login.Login();
} }
} }
else else
@ -63,7 +63,7 @@ namespace AxibugEmuOnline.Client.Network
{ {
//用于Unity内的输出 //用于Unity内的输出
//Debug.Log("NetCoreDebug >> "+str); //Debug.Log("NetCoreDebug >> "+str);
AppAxibugEmuOnline.log.Info("NetCoreDebug >> " + str); App.log.Info("NetCoreDebug >> " + str);
} }
/// <summary> /// <summary>
@ -115,13 +115,13 @@ namespace AxibugEmuOnline.Client.Network
{ {
//等待时间 //等待时间
Thread.Sleep(ReConnectTryTime); Thread.Sleep(ReConnectTryTime);
AppAxibugEmuOnline.log.Info($"尝试自动重连{LastConnectIP}:{LastConnectPort}……"); App.log.Info($"尝试自动重连{LastConnectIP}:{LastConnectPort}……");
//第一步 //第一步
if (Init(LastConnectIP, LastConnectPort)) if (Init(LastConnectIP, LastConnectPort))
{ {
AppAxibugEmuOnline.log.Info($"自动重连成功!"); App.log.Info($"自动重连成功!");
bflagDone = true; bflagDone = true;
AppAxibugEmuOnline.log.Info($"触发重连后的自动逻辑!"); App.log.Info($"触发重连后的自动逻辑!");
OnReConnected?.Invoke(); OnReConnected?.Invoke();
} }
} while (!bflagDone); } while (!bflagDone);

View File

@ -3,7 +3,7 @@ using DG.Tweening;
using DG.Tweening.Core; using DG.Tweening.Core;
using DG.Tweening.Plugins.Options; using DG.Tweening.Plugins.Options;
using UnityEngine; using UnityEngine;
using App = AxibugEmuOnline.Client.ClientCore.AppAxibugEmuOnline; using App = AxibugEmuOnline.Client.ClientCore.App;
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client
{ {

View File

@ -19,7 +19,7 @@ namespace AxibugEmuOnline.Client
public int Index { get; set; } public int Index { get; set; }
private RomLib m_romlib => AppAxibugEmuOnline.nesRomLib; private RomLib m_romlib => App.nesRomLib;
private RomFile m_romfile; private RomFile m_romfile;
public void SetData(object data) public void SetData(object data)
@ -64,7 +64,7 @@ namespace AxibugEmuOnline.Client
else else
{ {
SetBaseInfo(m_romfile.Alias, m_romfile.Descript); SetBaseInfo(m_romfile.Alias, m_romfile.Descript);
AppAxibugEmuOnline.CacheMgr.GetSpriteCache(m_romfile.ImageURL, (img, url) => App.CacheMgr.GetSpriteCache(m_romfile.ImageURL, (img, url) =>
{ {
if (url != m_romfile.ImageURL) return; if (url != m_romfile.ImageURL) return;
@ -82,7 +82,7 @@ namespace AxibugEmuOnline.Client
} }
else else
{ {
AppAxibugEmuOnline.BeginGame(m_romfile); App.BeginGame(m_romfile);
return false; return false;
} }