forked from sin365/AxibugEmuOnline
Merge pull request 'master' (#87) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: sin365/AxibugEmuOnline#87
This commit is contained in:
commit
85b175f831
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,249 +1,261 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using AxibugEmuOnline.Client.Network;
|
using AxibugEmuOnline.Client.Network;
|
||||||
using AxibugProtobuf;
|
using AxibugProtobuf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static AxibugEmuOnline.Client.HttpAPI;
|
using static AxibugEmuOnline.Client.HttpAPI;
|
||||||
using static AxibugEmuOnline.Client.Manager.LogManager;
|
using static AxibugEmuOnline.Client.Manager.LogManager;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client.ClientCore
|
namespace AxibugEmuOnline.Client.ClientCore
|
||||||
{
|
{
|
||||||
public static class App
|
public static class App
|
||||||
{
|
{
|
||||||
public static string TokenStr;
|
public static string TokenStr;
|
||||||
public static string IP;
|
public static string IP;
|
||||||
public static int Port;
|
public static int Port;
|
||||||
public static LogManager log;
|
public static LogManager log;
|
||||||
public static NetworkHelper network;
|
public static NetworkHelper network;
|
||||||
public static AppLogin login;
|
public static AppLogin login;
|
||||||
public static AppChat chat;
|
public static AppChat chat;
|
||||||
public static UserDataManager user;
|
public static UserDataManager user;
|
||||||
//public static AppNetGame netgame;
|
public static AppEmu emu;
|
||||||
public static AppEmu emu;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// nes Rom库
|
/// nes Rom库
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static RomLib nesRomLib;
|
public static RomLib nesRomLib;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收藏 Rom库
|
/// 收藏 Rom库
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static RomLib starRomLib;
|
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;
|
||||||
private static object gameSavMgr;
|
public static GamePadManager gamePadMgr;
|
||||||
static bool bTest;
|
private static object gameSavMgr;
|
||||||
static string mTestSrvIP;
|
static bool bTest;
|
||||||
#region Mono
|
static string mTestSrvIP;
|
||||||
public static TickLoop tickLoop;
|
#region Mono
|
||||||
private static CoroutineRunner coRunner;
|
public static TickLoop tickLoop;
|
||||||
|
private static CoroutineRunner coRunner;
|
||||||
#if UNITY_PSP2
|
|
||||||
public static SonyVitaCommonDialog sonyVitaCommonDialog;
|
#if UNITY_PSP2
|
||||||
#endif
|
public static SonyVitaCommonDialog sonyVitaCommonDialog;
|
||||||
|
#endif
|
||||||
#endregion
|
|
||||||
|
#endregion
|
||||||
#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机
|
|
||||||
public static string PersistentDataPath => "ux0:data/AxibugEmu";
|
|
||||||
#else
|
static string s_persistentRoot =
|
||||||
public static string PersistentDataPath => Application.persistentDataPath;
|
#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机
|
||||||
#endif
|
"ux0:data/AxibugEmu";
|
||||||
public static void Init(bool isTest = false, string testSrvIP = "", bool bUseLocalWebApi = false, string mLocalWebApi = "")
|
#else
|
||||||
{
|
Application.persistentDataPath;
|
||||||
log = new LogManager(OnLogOut);
|
#endif
|
||||||
|
public static string PersistentDataPath(RomPlatformType emuPlatform)
|
||||||
//其他平台必要的初始化
|
{
|
||||||
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
|
return s_persistentRoot + "/" + emuPlatform.ToString();
|
||||||
{
|
}
|
||||||
PSP2Init();
|
public static string PersistentDataRoot() => s_persistentRoot;
|
||||||
}
|
|
||||||
|
public static void Init(bool isTest = false, string testSrvIP = "", bool bUseLocalWebApi = false, string mLocalWebApi = "")
|
||||||
settings = new AppSettings();
|
{
|
||||||
network = new NetworkHelper();
|
log = new LogManager(OnLogOut);
|
||||||
login = new AppLogin();
|
|
||||||
chat = new AppChat();
|
//其他平台必要的初始化
|
||||||
user = new UserDataManager();
|
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
|
||||||
emu = new AppEmu();
|
{
|
||||||
//netgame = new AppNetGame();
|
PSP2Init();
|
||||||
httpAPI = new HttpAPI();
|
}
|
||||||
if (bUseLocalWebApi)
|
|
||||||
httpAPI.WebHost = mLocalWebApi;
|
settings = new AppSettings();
|
||||||
nesRomLib = new RomLib(RomPlatformType.Nes);
|
network = new NetworkHelper();
|
||||||
starRomLib = new RomLib();
|
login = new AppLogin();
|
||||||
CacheMgr = new CacheManager();
|
chat = new AppChat();
|
||||||
roomMgr = new AppRoom();
|
user = new UserDataManager();
|
||||||
share = new AppShare();
|
emu = new AppEmu();
|
||||||
gameSavMgr = new AppGameSavMgr();
|
httpAPI = new HttpAPI();
|
||||||
bTest = isTest;
|
if (bUseLocalWebApi)
|
||||||
mTestSrvIP = testSrvIP;
|
httpAPI.WebHost = mLocalWebApi;
|
||||||
var go = new GameObject("[AppAxibugEmuOnline]");
|
nesRomLib = new RomLib(RomPlatformType.Nes);
|
||||||
GameObject.DontDestroyOnLoad(go);
|
starRomLib = new RomLib();
|
||||||
tickLoop = go.AddComponent<TickLoop>();
|
CacheMgr = new CacheManager();
|
||||||
coRunner = go.AddComponent<CoroutineRunner>();
|
roomMgr = new AppRoom();
|
||||||
|
share = new AppShare();
|
||||||
|
gameSavMgr = new AppGameSavMgr();
|
||||||
var importNode = GameObject.Find("IMPORTENT");
|
gamePadMgr = new GamePadManager();
|
||||||
if (importNode != null) GameObject.DontDestroyOnLoad(importNode);
|
|
||||||
|
bTest = isTest;
|
||||||
StartCoroutine(AppTickFlow());
|
mTestSrvIP = testSrvIP;
|
||||||
RePullNetInfo();
|
var go = new GameObject("[AppAxibugEmuOnline]");
|
||||||
}
|
GameObject.DontDestroyOnLoad(go);
|
||||||
|
tickLoop = go.AddComponent<TickLoop>();
|
||||||
|
coRunner = go.AddComponent<CoroutineRunner>();
|
||||||
private static void PSP2Init()
|
|
||||||
{
|
|
||||||
//PSVita最好手动创建目录
|
var importNode = GameObject.Find("IMPORTENT");
|
||||||
if (!Directory.Exists(PersistentDataPath))
|
if (importNode != null) GameObject.DontDestroyOnLoad(importNode);
|
||||||
Directory.CreateDirectory(PersistentDataPath);
|
|
||||||
|
StartCoroutine(AppTickFlow());
|
||||||
#if UNITY_PSP2
|
RePullNetInfo();
|
||||||
//创建PSV弹窗UI
|
}
|
||||||
sonyVitaCommonDialog = new GameObject().AddComponent<SonyVitaCommonDialog>();
|
|
||||||
//释放解码 FMV的26M内存,一般游戏用不上(PSP才用那破玩意儿)
|
|
||||||
UnityEngine.PSVita.PSVitaVideoPlayer.TransferMemToMonoHeap();
|
private static void PSP2Init()
|
||||||
#endif
|
{
|
||||||
|
//PSVita最好手动创建目录
|
||||||
}
|
if (!Directory.Exists("ux0:data/AxibugEmu"))
|
||||||
|
Directory.CreateDirectory("ux0:data/AxibugEmu");
|
||||||
private static IEnumerator AppTickFlow()
|
|
||||||
{
|
#if UNITY_PSP2
|
||||||
while (true)
|
//创建PSV弹窗UI
|
||||||
{
|
sonyVitaCommonDialog = new GameObject().AddComponent<SonyVitaCommonDialog>();
|
||||||
Tick();
|
//释放解码 FMV的26M内存,一般游戏用不上(PSP才用那破玩意儿)
|
||||||
yield return null;
|
UnityEngine.PSVita.PSVitaVideoPlayer.TransferMemToMonoHeap();
|
||||||
}
|
#endif
|
||||||
}
|
|
||||||
|
}
|
||||||
public static void RePullNetInfo()
|
|
||||||
{
|
private static IEnumerator AppTickFlow()
|
||||||
StartCoroutine(StartNetInit());
|
{
|
||||||
}
|
while (true)
|
||||||
|
{
|
||||||
static IEnumerator StartNetInit()
|
Tick();
|
||||||
{
|
yield return null;
|
||||||
if (App.network.isConnected)
|
}
|
||||||
yield break;
|
}
|
||||||
|
|
||||||
int platform = 0;
|
public static void RePullNetInfo()
|
||||||
if (bTest)
|
{
|
||||||
{
|
StartCoroutine(StartNetInit());
|
||||||
yield return null;
|
}
|
||||||
Connect(mTestSrvIP, 10492);
|
|
||||||
yield break;
|
static IEnumerator StartNetInit()
|
||||||
}
|
{
|
||||||
|
if (App.network.isConnected)
|
||||||
bool bHttpCheckDone = false;
|
yield break;
|
||||||
Resp_CheckStandInfo resp = null;
|
|
||||||
while (true)
|
int platform = 0;
|
||||||
{
|
if (bTest)
|
||||||
AxiHttpProxy.SendWebRequestProxy request = AxiHttpProxy.Get($"{App.httpAPI.WebSiteApi}/CheckStandInfo?platform={platform}&version={Application.version}");
|
{
|
||||||
yield return request.SendWebRequest;
|
yield return null;
|
||||||
if (!request.downloadHandler.isDone)
|
Connect(mTestSrvIP, 10492);
|
||||||
{
|
yield break;
|
||||||
bHttpCheckDone = false;
|
}
|
||||||
}
|
|
||||||
else if (request.downloadHandler.bHadErr)
|
bool bHttpCheckDone = false;
|
||||||
{
|
Resp_CheckStandInfo resp = null;
|
||||||
bHttpCheckDone = false;
|
while (true)
|
||||||
App.log.Error(request.downloadHandler.ErrInfo);
|
{
|
||||||
}
|
AxiHttpProxy.SendWebRequestProxy request = AxiHttpProxy.Get($"{App.httpAPI.WebSiteApi}/CheckStandInfo?platform={platform}&version={Application.version}");
|
||||||
else
|
yield return request.SendWebRequest;
|
||||||
{
|
if (!request.downloadHandler.isDone)
|
||||||
try
|
{
|
||||||
{
|
bHttpCheckDone = false;
|
||||||
resp = JsonUtility.FromJson<Resp_CheckStandInfo>(request.downloadHandler.text);
|
}
|
||||||
bHttpCheckDone = true;
|
else if (request.downloadHandler.bHadErr)
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
bHttpCheckDone = false;
|
||||||
{
|
App.log.Error(request.downloadHandler.ErrInfo);
|
||||||
bHttpCheckDone = false;
|
}
|
||||||
App.log.Error(ex.ToString());
|
else
|
||||||
}
|
{
|
||||||
}
|
try
|
||||||
|
{
|
||||||
//请求成功
|
resp = JsonUtility.FromJson<Resp_CheckStandInfo>(request.downloadHandler.text);
|
||||||
if (bHttpCheckDone)
|
bHttpCheckDone = true;
|
||||||
{
|
}
|
||||||
break;
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
else
|
bHttpCheckDone = false;
|
||||||
{
|
App.log.Error(ex.ToString());
|
||||||
yield return new WaitForSeconds(1);
|
}
|
||||||
App.log.Debug("请求失败,重试请求API...");
|
}
|
||||||
}
|
|
||||||
}
|
//请求成功
|
||||||
|
if (bHttpCheckDone)
|
||||||
/*UnityWebRequest request = UnityWebRequest.Get($"{App.httpAPI.WebSiteApi}/CheckStandInfo?platform={platform}&version={Application.version}");
|
{
|
||||||
yield return request.SendWebRequest();
|
break;
|
||||||
|
}
|
||||||
if (request.result != UnityWebRequest.Result.Success)
|
else
|
||||||
yield break;
|
{
|
||||||
|
yield return new WaitForSeconds(1);
|
||||||
App.log.Debug($"ApiResp => {request.downloadHandler.text}");
|
App.log.Debug("请求失败,重试请求API...");
|
||||||
Resp_CheckStandInfo resp = JsonUtility.FromJson<Resp_CheckStandInfo>(request.downloadHandler.text);*/
|
}
|
||||||
|
}
|
||||||
//需要更新
|
|
||||||
if (resp.needUpdateClient == 1)
|
/*UnityWebRequest request = UnityWebRequest.Get($"{App.httpAPI.WebSiteApi}/CheckStandInfo?platform={platform}&version={Application.version}");
|
||||||
{
|
yield return request.SendWebRequest();
|
||||||
//TODO
|
|
||||||
}
|
if (request.result != UnityWebRequest.Result.Success)
|
||||||
|
yield break;
|
||||||
yield return null;
|
|
||||||
//Connect("127.0.0.1", 10492);
|
App.log.Debug($"ApiResp => {request.downloadHandler.text}");
|
||||||
Connect(resp.serverIp, resp.serverPort);
|
Resp_CheckStandInfo resp = JsonUtility.FromJson<Resp_CheckStandInfo>(request.downloadHandler.text);*/
|
||||||
}
|
|
||||||
|
//需要更新
|
||||||
private static void Tick()
|
if (resp.needUpdateClient == 1)
|
||||||
{
|
{
|
||||||
nesRomLib.ExecuteFetchRomInfo();
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Coroutine StartCoroutine(IEnumerator itor)
|
yield return null;
|
||||||
{
|
//Connect("127.0.0.1", 10492);
|
||||||
return coRunner.StartCoroutine(itor);
|
Connect(resp.serverIp, resp.serverPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopCoroutine(Coroutine cor)
|
private static void Tick()
|
||||||
{
|
{
|
||||||
coRunner.StopCoroutine(cor);
|
nesRomLib.ExecuteFetchRomInfo();
|
||||||
}
|
starRomLib.ExecuteFetchRomInfo();
|
||||||
|
|
||||||
public static void Connect(string IP, int port)
|
gamePadMgr.Update();
|
||||||
{
|
}
|
||||||
Task task = new Task(() =>
|
|
||||||
{
|
public static Coroutine StartCoroutine(IEnumerator itor)
|
||||||
network.Init(IP, port);
|
{
|
||||||
});
|
return coRunner.StartCoroutine(itor);
|
||||||
task.Start();
|
}
|
||||||
}
|
|
||||||
|
public static void StopCoroutine(Coroutine cor)
|
||||||
public static void Close()
|
{
|
||||||
{
|
coRunner.StopCoroutine(cor);
|
||||||
App.log.Info("停止");
|
}
|
||||||
}
|
|
||||||
static void OnLogOut(int LogLevel, string msg)
|
public static void Connect(string IP, int port)
|
||||||
{
|
{
|
||||||
E_LogType logType = (E_LogType)LogLevel;
|
Task task = new Task(() =>
|
||||||
switch (logType)
|
{
|
||||||
{
|
network.Init(IP, port);
|
||||||
case E_LogType.Debug:
|
});
|
||||||
case E_LogType.Info:
|
task.Start();
|
||||||
Debug.Log("[AxiNet]:" + msg);
|
}
|
||||||
break;
|
|
||||||
case E_LogType.Warning:
|
public static void Close()
|
||||||
Debug.LogWarning("[AxiNet]:" + msg);
|
{
|
||||||
break;
|
App.log.Info("停止");
|
||||||
case E_LogType.Error:
|
}
|
||||||
Debug.LogError("[AxiNet]:" + msg);
|
static void OnLogOut(int LogLevel, string msg)
|
||||||
break;
|
{
|
||||||
}
|
E_LogType logType = (E_LogType)LogLevel;
|
||||||
}
|
switch (logType)
|
||||||
|
{
|
||||||
}
|
case E_LogType.Debug:
|
||||||
|
case E_LogType.Info:
|
||||||
|
Debug.Log("[AxiNet]:" + msg);
|
||||||
|
break;
|
||||||
|
case E_LogType.Warning:
|
||||||
|
Debug.LogWarning("[AxiNet]:" + msg);
|
||||||
|
break;
|
||||||
|
case E_LogType.Error:
|
||||||
|
Debug.LogError("[AxiNet]:" + msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,50 +1,51 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using UnityEngine;
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
namespace AxibugEmuOnline.Client
|
|
||||||
{
|
namespace AxibugEmuOnline.Client
|
||||||
public class Initer : MonoBehaviour
|
{
|
||||||
{
|
public class Initer : MonoBehaviour
|
||||||
static GlobalRef m_refs;
|
{
|
||||||
public static CanvasGroup FilterPreview => m_refs.FilterPreview;
|
static GlobalRef m_refs;
|
||||||
public static CanvasGroup XMBBg => m_refs.XMBBg;
|
public static CanvasGroup FilterPreview => m_refs.FilterPreview;
|
||||||
|
public static CanvasGroup XMBBg => m_refs.XMBBg;
|
||||||
public static string dev_UUID;
|
|
||||||
|
public static string dev_UUID;
|
||||||
[SerializeField]
|
|
||||||
|
[SerializeField]
|
||||||
GameObject IMPORTENT;
|
GameObject IMPORTENT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
public bool bTestSkipWebApiToConServer = false;
|
public bool bTestSkipWebApiToConServer = false;
|
||||||
public string mTestSrvIP = "192.168.0.47";
|
public string mTestSrvIP = "192.168.0.47";
|
||||||
public bool bUseLocalWebApi = false;
|
public bool bUseLocalWebApi = false;
|
||||||
public string mLocalWebApi = "http://localhost:5051";
|
public string mLocalWebApi = "http://localhost:5051";
|
||||||
public bool bEditorUUID = false;
|
public bool bEditorUUID = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
dev_UUID += "_Editor";
|
dev_UUID += "_Editor";
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
App.Init(this);
|
App.Init(this);
|
||||||
dev_UUID = SystemInfo.deviceUniqueIdentifier;
|
dev_UUID = SystemInfo.deviceUniqueIdentifier;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_refs = Instantiate(IMPORTENT, transform).GetComponent<GlobalRef>();
|
m_refs = Instantiate(IMPORTENT, transform).GetComponent<GlobalRef>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
App.settings.Filter.ShutDownFilterPreview();
|
App.settings.Filter.ShutDownFilterPreview();
|
||||||
App.settings.Filter.ShutDownFilter();
|
App.settings.Filter.ShutDownFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,160 +1,160 @@
|
|||||||
using Assets.Script.AppMain.Filter;
|
using Assets.Script.AppMain.Filter;
|
||||||
using AxibugEmuOnline.Client;
|
using AxibugEmuOnline.Client;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Experimental.Rendering;
|
using UnityEngine.Experimental.Rendering;
|
||||||
|
|
||||||
public abstract class FilterChainEffect : FilterEffect
|
public abstract class FilterChainEffect : FilterEffect
|
||||||
{
|
{
|
||||||
#region SealedForDisable
|
#region SealedForDisable
|
||||||
protected sealed override string ShaderName => null;
|
protected sealed override string ShaderName => null;
|
||||||
protected sealed override void OnInit(Material renderMat) { }
|
protected sealed override void OnInit(Material renderMat) { }
|
||||||
|
|
||||||
public sealed override void Render(Texture src, RenderTexture result)
|
public sealed override void Render(Texture src, RenderTexture result)
|
||||||
{
|
{
|
||||||
OnRenderer(src, result);
|
OnRenderer(src, result);
|
||||||
}
|
}
|
||||||
protected sealed override void OnRenderer(Material renderMat, Texture src, RenderTexture result) { }
|
protected sealed override void OnRenderer(Material renderMat, Texture src, RenderTexture result) { }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
List<PassDefine> m_passes = new List<PassDefine>();
|
List<PassDefine> m_passes = new List<PassDefine>();
|
||||||
|
|
||||||
static int Original;
|
static int Original;
|
||||||
static int OriginalSize;
|
static int OriginalSize;
|
||||||
static int Source;
|
static int Source;
|
||||||
static int SourceSize;
|
static int SourceSize;
|
||||||
static int FrameCount;
|
static int FrameCount;
|
||||||
static int OutputSize;
|
static int OutputSize;
|
||||||
|
|
||||||
List<int> m_passOutputTexNames = new List<int>();
|
List<int> m_passOutputTexNames = new List<int>();
|
||||||
List<int> m_passOutputTexSizes = new List<int>();
|
List<int> m_passOutputTexSizes = new List<int>();
|
||||||
|
|
||||||
static FilterChainEffect()
|
static FilterChainEffect()
|
||||||
{
|
{
|
||||||
Original = Shader.PropertyToID(nameof(Original));
|
Original = Shader.PropertyToID(nameof(Original));
|
||||||
OriginalSize = Shader.PropertyToID(nameof(OriginalSize));
|
OriginalSize = Shader.PropertyToID(nameof(OriginalSize));
|
||||||
Source = Shader.PropertyToID(nameof(Source));
|
Source = Shader.PropertyToID(nameof(Source));
|
||||||
SourceSize = Shader.PropertyToID(nameof(SourceSize));
|
SourceSize = Shader.PropertyToID(nameof(SourceSize));
|
||||||
FrameCount = Shader.PropertyToID(nameof(FrameCount));
|
FrameCount = Shader.PropertyToID(nameof(FrameCount));
|
||||||
OutputSize = Shader.PropertyToID(nameof(OutputSize));
|
OutputSize = Shader.PropertyToID(nameof(OutputSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override void Init()
|
protected sealed override void Init()
|
||||||
{
|
{
|
||||||
DefinePasses(ref m_passes);
|
DefinePasses(ref m_passes);
|
||||||
for (int i = 0; i < m_passes.Count; i++)
|
for (int i = 0; i < m_passes.Count; i++)
|
||||||
{
|
{
|
||||||
m_passes[i].Init(i);
|
m_passes[i].Init(i);
|
||||||
m_passOutputTexNames.Add(Shader.PropertyToID(m_passes[i].NormalOutputTextureName));
|
m_passOutputTexNames.Add(Shader.PropertyToID(m_passes[i].NormalOutputTextureName));
|
||||||
m_passOutputTexSizes.Add(Shader.PropertyToID($"{m_passes[i].NormalOutputTextureName}Size"));
|
m_passOutputTexSizes.Add(Shader.PropertyToID($"{m_passes[i].NormalOutputTextureName}Size"));
|
||||||
if (m_passes[i].AliasOutputTextureName != null)
|
if (m_passes[i].AliasOutputTextureName != null)
|
||||||
{
|
{
|
||||||
m_passOutputTexNames.Add(Shader.PropertyToID(m_passes[i].AliasOutputTextureName));
|
m_passOutputTexNames.Add(Shader.PropertyToID(m_passes[i].AliasOutputTextureName));
|
||||||
m_passOutputTexSizes.Add(Shader.PropertyToID($"{m_passes[i].AliasOutputTextureName}Size"));
|
m_passOutputTexSizes.Add(Shader.PropertyToID($"{m_passes[i].AliasOutputTextureName}Size"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<int, RenderTexture> m_outputCaches = new Dictionary<int, RenderTexture>();
|
Dictionary<int, RenderTexture> m_outputCaches = new Dictionary<int, RenderTexture>();
|
||||||
private void OnRenderer(Texture input, RenderTexture finalOut)
|
private void OnRenderer(Texture input, RenderTexture finalOut)
|
||||||
{
|
{
|
||||||
m_outputCaches.Clear();
|
m_outputCaches.Clear();
|
||||||
|
|
||||||
Vector4 originalSize = new Vector4(input.width, input.height, 1f / input.width, 1f / input.height);
|
Vector4 originalSize = new Vector4(input.width, input.height, 1f / input.width, 1f / input.height);
|
||||||
|
|
||||||
Texture lastoutput = input;
|
Texture lastoutput = input;
|
||||||
for (int i = 0; i < m_passes.Count; i++)
|
for (int i = 0; i < m_passes.Count; i++)
|
||||||
{
|
{
|
||||||
var pass = m_passes[i];
|
var pass = m_passes[i];
|
||||||
pass.OnRender();
|
pass.OnRender();
|
||||||
|
|
||||||
pass.Mat.SetTexture(Original, input);
|
pass.Mat.SetTexture(Original, input);
|
||||||
pass.Mat.SetVector(OriginalSize, originalSize);
|
pass.Mat.SetVector(OriginalSize, originalSize);
|
||||||
pass.Mat.SetTexture(Source, lastoutput);
|
pass.Mat.SetTexture(Source, lastoutput);
|
||||||
pass.Mat.SetVector(SourceSize, new Vector4(lastoutput.width, lastoutput.height, 1f / lastoutput.width, 1f / lastoutput.height));
|
pass.Mat.SetVector(SourceSize, new Vector4(lastoutput.width, lastoutput.height, 1f / lastoutput.width, 1f / lastoutput.height));
|
||||||
pass.Mat.SetFloat(FrameCount, Time.frameCount);
|
pass.Mat.SetFloat(FrameCount, Time.frameCount);
|
||||||
|
|
||||||
for (int index = 0; index < m_passOutputTexNames.Count; index++)
|
for (int index = 0; index < m_passOutputTexNames.Count; index++)
|
||||||
{
|
{
|
||||||
var existoutput = m_passOutputTexNames[index];
|
var existoutput = m_passOutputTexNames[index];
|
||||||
var existoutputSize = m_passOutputTexSizes[index];
|
var existoutputSize = m_passOutputTexSizes[index];
|
||||||
if (m_outputCaches.TryGetValue(existoutput, out var passOutput))
|
if (m_outputCaches.TryGetValue(existoutput, out var passOutput))
|
||||||
{
|
{
|
||||||
if (pass.Mat.HasTexture(existoutput))
|
if (pass.Mat.HasTexture(existoutput))
|
||||||
pass.Mat.SetTexture(existoutput, passOutput);
|
pass.Mat.SetTexture(existoutput, passOutput);
|
||||||
if (pass.Mat.HasVector(existoutputSize))
|
if (pass.Mat.HasVector(existoutputSize))
|
||||||
pass.Mat.SetVector(existoutputSize, new Vector4(passOutput.width, passOutput.height, 1f / passOutput.width, 1f / passOutput.height));
|
pass.Mat.SetVector(existoutputSize, new Vector4(passOutput.width, passOutput.height, 1f / passOutput.width, 1f / passOutput.height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var output = pass.GetOutput(input, lastoutput, finalOut);
|
var output = pass.GetOutput(input, lastoutput, finalOut);
|
||||||
|
|
||||||
pass.Mat.SetVector(OutputSize, new Vector4(output.width, output.height, 1f / output.width, 1f / output.height));
|
pass.Mat.SetVector(OutputSize, new Vector4(output.width, output.height, 1f / output.width, 1f / output.height));
|
||||||
|
|
||||||
m_outputCaches[pass.NormalOutputTextureName_PID] = output;
|
m_outputCaches[pass.NormalOutputTextureName_PID] = output;
|
||||||
if (pass.AliasOutputTextureName != null) m_outputCaches[pass.AliasOutputTextureName_PID] = output;
|
if (pass.AliasOutputTextureName != null) m_outputCaches[pass.AliasOutputTextureName_PID] = output;
|
||||||
|
|
||||||
Graphics.Blit(lastoutput, output, pass.Mat);
|
Graphics.Blit(lastoutput, output, pass.Mat);
|
||||||
|
|
||||||
lastoutput = output;
|
lastoutput = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics.Blit(lastoutput, finalOut);
|
Graphics.Blit(lastoutput, finalOut);
|
||||||
|
|
||||||
foreach (var rt in m_outputCaches.Values)
|
foreach (var rt in m_outputCaches.Values)
|
||||||
RenderTexture.ReleaseTemporary(rt);
|
RenderTexture.ReleaseTemporary(rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void DefinePasses(ref List<PassDefine> passes);
|
protected abstract void DefinePasses(ref List<PassDefine> passes);
|
||||||
|
|
||||||
public class PassDefine
|
public class PassDefine
|
||||||
{
|
{
|
||||||
public string ShaderName { get; private set; }
|
public string ShaderName { get; private set; }
|
||||||
public FilterMode FilterMode { get; private set; }
|
public FilterMode FilterMode { get; private set; }
|
||||||
public TextureWrapMode WrapMode { get; private set; }
|
public TextureWrapMode WrapMode { get; private set; }
|
||||||
public EnumScaleMode ScaleModeX { get; private set; }
|
public EnumScaleMode ScaleModeX { get; private set; }
|
||||||
public EnumScaleMode ScaleModeY { get; private set; }
|
public EnumScaleMode ScaleModeY { get; private set; }
|
||||||
public float ScaleX { get; private set; }
|
public float ScaleX { get; private set; }
|
||||||
public float ScaleY { get; private set; }
|
public float ScaleY { get; private set; }
|
||||||
public string AliasOutputTextureName { get; private set; }
|
public string AliasOutputTextureName { get; private set; }
|
||||||
public int AliasOutputTextureName_PID { get; private set; }
|
public int AliasOutputTextureName_PID { get; private set; }
|
||||||
public string NormalOutputTextureName { get; private set; }
|
public string NormalOutputTextureName { get; private set; }
|
||||||
public int NormalOutputTextureName_PID { get; private set; }
|
public int NormalOutputTextureName_PID { get; private set; }
|
||||||
public bool sRGB { get; private set; }
|
public bool sRGB { get; private set; }
|
||||||
|
|
||||||
private PassDefine() { }
|
private PassDefine() { }
|
||||||
|
|
||||||
public static PassDefine Create(
|
public static PassDefine Create(
|
||||||
string shaderName,
|
string shaderName,
|
||||||
FilterMode filterMode = FilterMode.Point,
|
FilterMode filterMode = FilterMode.Point,
|
||||||
TextureWrapMode wrapMode = TextureWrapMode.Clamp,
|
TextureWrapMode wrapMode = TextureWrapMode.Clamp,
|
||||||
EnumScaleMode scaleModeX = EnumScaleMode.Source, EnumScaleMode scaleModeY = EnumScaleMode.Source, float scaleX = 1f, float scaleY = 1f,
|
EnumScaleMode scaleModeX = EnumScaleMode.Source, EnumScaleMode scaleModeY = EnumScaleMode.Source, float scaleX = 1f, float scaleY = 1f,
|
||||||
string outputAlias = null,
|
string outputAlias = null,
|
||||||
bool sRGB = false
|
bool sRGB = false
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return new PassDefine()
|
return new PassDefine()
|
||||||
{
|
{
|
||||||
ShaderName = shaderName,
|
ShaderName = shaderName,
|
||||||
FilterMode = filterMode,
|
FilterMode = filterMode,
|
||||||
WrapMode = wrapMode,
|
WrapMode = wrapMode,
|
||||||
ScaleModeX = scaleModeX,
|
ScaleModeX = scaleModeX,
|
||||||
ScaleModeY = scaleModeY,
|
ScaleModeY = scaleModeY,
|
||||||
ScaleX = scaleX,
|
ScaleX = scaleX,
|
||||||
ScaleY = scaleY,
|
ScaleY = scaleY,
|
||||||
AliasOutputTextureName = outputAlias,
|
AliasOutputTextureName = outputAlias,
|
||||||
sRGB = sRGB,
|
sRGB = sRGB,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, FilterParameter> m_linkingParams = new Dictionary<string, FilterParameter>();
|
private Dictionary<string, FilterParameter> m_linkingParams = new Dictionary<string, FilterParameter>();
|
||||||
public PassDefine SetParameters(string shaderValName, FilterParameter para)
|
public PassDefine SetParameters(string shaderValName, FilterParameter para)
|
||||||
{
|
{
|
||||||
m_linkingParams[shaderValName] = para;
|
m_linkingParams[shaderValName] = para;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int PassIndex { get; private set; }
|
public int PassIndex { get; private set; }
|
||||||
public Material Mat { get; private set; }
|
public Material Mat { get; private set; }
|
||||||
|
|
||||||
public void OnRender()
|
public void OnRender()
|
||||||
@ -167,63 +167,63 @@ public abstract class FilterChainEffect : FilterEffect
|
|||||||
if (valType == typeof(float))
|
if (valType == typeof(float))
|
||||||
Mat.SetFloat(paraName, (float)val);
|
Mat.SetFloat(paraName, (float)val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal void Init(int passIndex)
|
internal void Init(int passIndex)
|
||||||
{
|
{
|
||||||
Mat = new Material(Shader.Find(ShaderName));
|
Mat = new Material(Shader.Find(ShaderName));
|
||||||
PassIndex = passIndex;
|
PassIndex = passIndex;
|
||||||
NormalOutputTextureName = $"PassOutput{passIndex}";
|
NormalOutputTextureName = $"PassOutput{passIndex}";
|
||||||
NormalOutputTextureName_PID = Shader.PropertyToID(NormalOutputTextureName);
|
NormalOutputTextureName_PID = Shader.PropertyToID(NormalOutputTextureName);
|
||||||
|
|
||||||
if (AliasOutputTextureName != null) AliasOutputTextureName_PID = Shader.PropertyToID(AliasOutputTextureName);
|
if (AliasOutputTextureName != null) AliasOutputTextureName_PID = Shader.PropertyToID(AliasOutputTextureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal RenderTexture GetOutput(Texture original, Texture source, Texture final)
|
internal RenderTexture GetOutput(Texture original, Texture source, Texture final)
|
||||||
{
|
{
|
||||||
int width = 0;
|
int width = 0;
|
||||||
switch (ScaleModeX)
|
switch (ScaleModeX)
|
||||||
{
|
{
|
||||||
case EnumScaleMode.Viewport:
|
case EnumScaleMode.Viewport:
|
||||||
width = (int)(final.width * ScaleX);
|
width = (int)(final.width * ScaleX);
|
||||||
break;
|
break;
|
||||||
case EnumScaleMode.Source:
|
case EnumScaleMode.Source:
|
||||||
width = (int)(source.width * ScaleX);
|
width = (int)(source.width * ScaleX);
|
||||||
break;
|
break;
|
||||||
case EnumScaleMode.Absolute:
|
case EnumScaleMode.Absolute:
|
||||||
width = (int)ScaleX;
|
width = (int)ScaleX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int height = 0;
|
int height = 0;
|
||||||
switch (ScaleModeY)
|
switch (ScaleModeY)
|
||||||
{
|
{
|
||||||
case EnumScaleMode.Viewport:
|
case EnumScaleMode.Viewport:
|
||||||
height = (int)(final.height * ScaleY);
|
height = (int)(final.height * ScaleY);
|
||||||
break;
|
break;
|
||||||
case EnumScaleMode.Source:
|
case EnumScaleMode.Source:
|
||||||
height = (int)(source.height * ScaleY);
|
height = (int)(source.height * ScaleY);
|
||||||
break;
|
break;
|
||||||
case EnumScaleMode.Absolute:
|
case EnumScaleMode.Absolute:
|
||||||
height = (int)ScaleY;
|
height = (int)ScaleY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (sRGB) format = GraphicsFormat.R8G8B8A8_SRGB;
|
//if (sRGB) format = GraphicsFormat.R8G8B8A8_SRGB;
|
||||||
var rt = RenderTexture.GetTemporary(width, height, 0, GraphicsFormat.R8G8B8A8_UNorm, 1);
|
var rt = RenderTexture.GetTemporary(width, height, 0, GraphicsFormat.R8G8B8A8_UNorm, 1);
|
||||||
|
|
||||||
rt.wrapMode = WrapMode;
|
rt.wrapMode = WrapMode;
|
||||||
rt.filterMode = FilterMode;
|
rt.filterMode = FilterMode;
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EnumScaleMode
|
public enum EnumScaleMode
|
||||||
{
|
{
|
||||||
/// <summary> 以输入源为缩放基准 </summary
|
/// <summary> 以输入源为缩放基准 </summary
|
||||||
Source,
|
Source,
|
||||||
/// <summary> 以分辨率作为缩放基准 </summary
|
/// <summary> 以分辨率作为缩放基准 </summary
|
||||||
Viewport,
|
Viewport,
|
||||||
/// <summary> 以固定值定义尺寸 </summary
|
/// <summary> 以固定值定义尺寸 </summary
|
||||||
Absolute
|
Absolute
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Assets.Script.AppMain.Filter;
|
using Assets.Script.AppMain.Filter;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -53,12 +54,12 @@ namespace AxibugEmuOnline.Client
|
|||||||
var rangeAtt = param.GetCustomAttribute<RangeAttribute>();
|
var rangeAtt = param.GetCustomAttribute<RangeAttribute>();
|
||||||
float min = 0;
|
float min = 0;
|
||||||
float max = 10;
|
float max = 10;
|
||||||
if (rangeAtt != null)
|
if (rangeAtt != null) { min = rangeAtt.min; max = rangeAtt.max; }
|
||||||
{
|
|
||||||
min = rangeAtt.min; max = rangeAtt.max;
|
var descrip = param.GetCustomAttribute<DescriptionAttribute>();
|
||||||
}
|
string name = descrip != null ? descrip.Description : param.Name;
|
||||||
|
|
||||||
var editableParam = new EditableParamerter(param.Name, paramObj, min, max);
|
var editableParam = new EditableParamerter(name, paramObj, min, max);
|
||||||
m_editableParamList.Add(editableParam);
|
m_editableParamList.Add(editableParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,15 +87,23 @@ namespace AxibugEmuOnline.Client
|
|||||||
public object MinValue { get; private set; }
|
public object MinValue { get; private set; }
|
||||||
public object MaxValue { get; private set; }
|
public object MaxValue { get; private set; }
|
||||||
|
|
||||||
public EditableParamerter(string name, FilterParameter paramObject, object minValue, object maxValue)
|
public EditableParamerter(string name, FilterParameter paramObject, float minValue, float maxValue)
|
||||||
{
|
{
|
||||||
m_paramObject = paramObject;
|
m_paramObject = paramObject;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
||||||
var paramType = paramObject.GetType();
|
var paramType = paramObject.GetType();
|
||||||
|
|
||||||
MinValue = minValue;
|
if (paramObject.ValueType == typeof(int))
|
||||||
MaxValue = maxValue;
|
{
|
||||||
|
MinValue = (int)minValue;
|
||||||
|
MaxValue = (int)maxValue;
|
||||||
|
}
|
||||||
|
else if (paramObject.ValueType == typeof(float))
|
||||||
|
{
|
||||||
|
MinValue = minValue;
|
||||||
|
MaxValue = maxValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetToDefault() => m_paramObject.Value = null;
|
public void ResetToDefault() => m_paramObject.Value = null;
|
||||||
|
@ -331,6 +331,18 @@ namespace AxibugEmuOnline.Client
|
|||||||
float.TryParse(rawStr, out floatVal);
|
float.TryParse(rawStr, out floatVal);
|
||||||
return floatVal;
|
return floatVal;
|
||||||
}
|
}
|
||||||
|
else if (valueType == typeof(int))
|
||||||
|
{
|
||||||
|
int intVal;
|
||||||
|
int.TryParse(rawStr, out intVal);
|
||||||
|
return intVal;
|
||||||
|
}
|
||||||
|
else if (valueType == typeof(bool))
|
||||||
|
{
|
||||||
|
bool boolVal;
|
||||||
|
bool.TryParse(rawStr, out boolVal);
|
||||||
|
return boolVal;
|
||||||
|
}
|
||||||
else if (valueType.IsEnum)
|
else if (valueType.IsEnum)
|
||||||
{
|
{
|
||||||
var names = Enum.GetNames(valueType);
|
var names = Enum.GetNames(valueType);
|
||||||
|
@ -13,7 +13,7 @@ namespace Assets.Script.AppMain.Filter
|
|||||||
{
|
{
|
||||||
get => m_overrideValue ?? m_defaultValue;
|
get => m_overrideValue ?? m_defaultValue;
|
||||||
set => m_overrideValue = value;
|
set => m_overrideValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FilterParameter<T> : FilterParameter
|
public class FilterParameter<T> : FilterParameter
|
||||||
@ -28,21 +28,76 @@ namespace Assets.Script.AppMain.Filter
|
|||||||
public FilterParameter(T defaultValue)
|
public FilterParameter(T defaultValue)
|
||||||
{
|
{
|
||||||
m_defaultValue = defaultValue;
|
m_defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator T(FilterParameter<T> value)
|
||||||
|
{
|
||||||
|
return value.GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator FilterParameter<T>(T value)
|
||||||
|
{
|
||||||
|
return new FilterParameter<T>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BoolParameter : FilterParameter<bool>
|
public class BoolParameter : FilterParameter<bool>
|
||||||
{
|
{
|
||||||
public BoolParameter(bool defaultValue) : base(defaultValue) { }
|
public BoolParameter(bool defaultValue) : base(defaultValue) { }
|
||||||
|
|
||||||
|
public static implicit operator bool(BoolParameter value)
|
||||||
|
{
|
||||||
|
return value.GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator BoolParameter(bool value)
|
||||||
|
{
|
||||||
|
return new BoolParameter(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Vector2Parameter : FilterParameter<Vector2>
|
public class Vector2Parameter : FilterParameter<Vector2>
|
||||||
{
|
{
|
||||||
public Vector2Parameter(Vector2 defaultValue) : base(defaultValue) { }
|
public Vector2Parameter(Vector2 defaultValue) : base(defaultValue) { }
|
||||||
|
|
||||||
|
public static implicit operator Vector2(Vector2Parameter value)
|
||||||
|
{
|
||||||
|
return value.GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator Vector2Parameter(Vector2 value)
|
||||||
|
{
|
||||||
|
return new Vector2Parameter(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FloatParameter : FilterParameter<float>
|
public class FloatParameter : FilterParameter<float>
|
||||||
{
|
{
|
||||||
public FloatParameter(float defaultValue) : base(defaultValue) { }
|
public FloatParameter(float defaultValue) : base(defaultValue) { }
|
||||||
|
|
||||||
|
public static implicit operator float(FloatParameter value)
|
||||||
|
{
|
||||||
|
return value.GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator FloatParameter(float value)
|
||||||
|
{
|
||||||
|
return new FloatParameter(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class IntParameter : FilterParameter<int>
|
||||||
|
{
|
||||||
|
public IntParameter(int defaultValue) : base(defaultValue) { }
|
||||||
|
|
||||||
|
public static implicit operator int(IntParameter value)
|
||||||
|
{
|
||||||
|
return value.GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator IntParameter(int value)
|
||||||
|
{
|
||||||
|
return new IntParameter(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 36463068bd4c2274cb302669fa552345
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,173 @@
|
|||||||
|
using Assets.Script.AppMain.Filter;
|
||||||
|
using AxibugEmuOnline.Client;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using UnityEngine;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
|
|
||||||
|
public class SimpleCRT : FilterEffect
|
||||||
|
{
|
||||||
|
public override string Name => nameof(SimpleCRT);
|
||||||
|
|
||||||
|
protected override string ShaderName => "Filter/yunoda-3DCG/SimpleCRT";
|
||||||
|
|
||||||
|
[Range(0, 1000)][Description("White Noise Freq")] public IntParameter whiteNoiseFrequency = new IntParameter(1);
|
||||||
|
[Range(0, 1)][Description("White Noise Time Left (sec)")] public FloatParameter whiteNoiseLength = new FloatParameter(0.1f);
|
||||||
|
private float whiteNoiseTimeLeft;
|
||||||
|
|
||||||
|
[Range(0, 1000)][Description("Screen Jump Freq")] public IntParameter screenJumpFrequency = 1;
|
||||||
|
[Range(0, 1f)][Description("Screen Jump Length")] public FloatParameter screenJumpLength = 0.2f;
|
||||||
|
[Range(0, 1f)][Description("Jump Min")] public FloatParameter screenJumpMinLevel = 0.1f;
|
||||||
|
[Range(0, 1f)][Description("Jump Max")] public FloatParameter screenJumpMaxLevel = 0.9f;
|
||||||
|
private float screenJumpTimeLeft;
|
||||||
|
|
||||||
|
[Range(0, 1f)][Description("Flickering Strength")] public FloatParameter flickeringStrength = 0.002f;
|
||||||
|
[Range(0, 333f)][Description("Flickering Cycle")] public FloatParameter flickeringCycle = 111f;
|
||||||
|
|
||||||
|
[Description("Slip Page")] public BoolParameter isSlippage = true;
|
||||||
|
[Description("Slip Noise")] public BoolParameter isSlippageNoise = true;
|
||||||
|
[Range(0, 1)][Description("Slip Strength")] public FloatParameter slippageStrength = 0.005f;
|
||||||
|
[Range(0, 100)][Description("Slip Intervalw")] public float slippageInterval = 1f;
|
||||||
|
[Range(0, 330)][Description("Slip Scroll Speed")] public float slippageScrollSpeed = 33f;
|
||||||
|
[Range(0, 100f)][Description("Slip Size")] public FloatParameter slippageSize = 11f;
|
||||||
|
|
||||||
|
[Range(0, 1f)][Description("Chromatic Aberration Strength")] public FloatParameter chromaticAberrationStrength = 0.005f;
|
||||||
|
[Description("Chromatic Aberration")] public bool isChromaticAberration = true;
|
||||||
|
|
||||||
|
[Description("Multiple Ghost")] public BoolParameter isMultipleGhost = true;
|
||||||
|
[Range(0, 1f)][Description("Multiple Ghost Strength")] public FloatParameter multipleGhostStrength = 0.01f;
|
||||||
|
|
||||||
|
[Description("Scanline")] public BoolParameter isScanline = true;
|
||||||
|
[Description("Monochrome")] public BoolParameter isMonochrome = false;
|
||||||
|
|
||||||
|
[Description("Letter Box")] public bool isLetterBox = false;
|
||||||
|
public bool isLetterBoxEdgeBlur = false;
|
||||||
|
[Description("Letter Box Type")] public FilterParameter<LeterBoxType> letterBoxType = default(LeterBoxType);
|
||||||
|
public enum LeterBoxType
|
||||||
|
{
|
||||||
|
Black,
|
||||||
|
Blur
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties in shader
|
||||||
|
private int _WhiteNoiseOnOff;
|
||||||
|
private int _ScanlineOnOff;
|
||||||
|
private int _MonochormeOnOff;
|
||||||
|
private int _ScreenJumpLevel;
|
||||||
|
private int _FlickeringStrength;
|
||||||
|
private int _FlickeringCycle;
|
||||||
|
private int _SlippageStrength;
|
||||||
|
private int _SlippageSize;
|
||||||
|
private int _SlippageInterval;
|
||||||
|
private int _SlippageScrollSpeed;
|
||||||
|
private int _SlippageNoiseOnOff;
|
||||||
|
private int _SlippageOnOff;
|
||||||
|
private int _ChromaticAberrationStrength;
|
||||||
|
private int _ChromaticAberrationOnOff;
|
||||||
|
private int _MultipleGhostOnOff;
|
||||||
|
private int _MultipleGhostStrength;
|
||||||
|
private int _LetterBoxOnOff;
|
||||||
|
private int _LetterBoxType;
|
||||||
|
private int _LetterBoxEdgeBlurOnOff;
|
||||||
|
private int _DecalTex;
|
||||||
|
private int _DecalTexOnOff;
|
||||||
|
private int _DecalTexPos;
|
||||||
|
private int _DecalTexScale;
|
||||||
|
private int _FilmDirtOnOff;
|
||||||
|
private int _FilmDirtTex;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected override void OnInit(Material renderMat)
|
||||||
|
{
|
||||||
|
base.OnInit(renderMat);
|
||||||
|
|
||||||
|
_WhiteNoiseOnOff = Shader.PropertyToID("_WhiteNoiseOnOff");
|
||||||
|
_ScanlineOnOff = Shader.PropertyToID("_ScanlineOnOff");
|
||||||
|
_MonochormeOnOff = Shader.PropertyToID("_MonochormeOnOff");
|
||||||
|
_ScreenJumpLevel = Shader.PropertyToID("_ScreenJumpLevel");
|
||||||
|
_FlickeringStrength = Shader.PropertyToID("_FlickeringStrength");
|
||||||
|
_FlickeringCycle = Shader.PropertyToID("_FlickeringCycle");
|
||||||
|
_SlippageStrength = Shader.PropertyToID("_SlippageStrength");
|
||||||
|
_SlippageSize = Shader.PropertyToID("_SlippageSize");
|
||||||
|
_SlippageInterval = Shader.PropertyToID("_SlippageInterval");
|
||||||
|
_SlippageScrollSpeed = Shader.PropertyToID("_SlippageScrollSpeed");
|
||||||
|
_SlippageNoiseOnOff = Shader.PropertyToID("_SlippageNoiseOnOff");
|
||||||
|
_SlippageOnOff = Shader.PropertyToID("_SlippageOnOff");
|
||||||
|
_ChromaticAberrationStrength = Shader.PropertyToID("_ChromaticAberrationStrength");
|
||||||
|
_ChromaticAberrationOnOff = Shader.PropertyToID("_ChromaticAberrationOnOff");
|
||||||
|
_MultipleGhostOnOff = Shader.PropertyToID("_MultipleGhostOnOff");
|
||||||
|
_MultipleGhostStrength = Shader.PropertyToID("_MultipleGhostStrength");
|
||||||
|
_LetterBoxOnOff = Shader.PropertyToID("_LetterBoxOnOff");
|
||||||
|
_LetterBoxType = Shader.PropertyToID("_LetterBoxType");
|
||||||
|
_DecalTex = Shader.PropertyToID("_DecalTex");
|
||||||
|
_DecalTexOnOff = Shader.PropertyToID("_DecalTexOnOff");
|
||||||
|
_DecalTexPos = Shader.PropertyToID("_DecalTexPos");
|
||||||
|
_DecalTexScale = Shader.PropertyToID("_DecalTexScale");
|
||||||
|
_FilmDirtOnOff = Shader.PropertyToID("_FilmDirtOnOff");
|
||||||
|
_FilmDirtTex = Shader.PropertyToID("_FilmDirtTex");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result)
|
||||||
|
{
|
||||||
|
SetShaderParameter(renderMat);
|
||||||
|
|
||||||
|
Graphics.Blit(src, result, renderMat);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetShaderParameter(Material material)
|
||||||
|
{
|
||||||
|
///////White noise
|
||||||
|
whiteNoiseTimeLeft -= 0.01f;
|
||||||
|
if (whiteNoiseTimeLeft <= 0)
|
||||||
|
{
|
||||||
|
if (Random.Range(0, 1000) < whiteNoiseFrequency)
|
||||||
|
{
|
||||||
|
material.SetInteger(_WhiteNoiseOnOff, 1);
|
||||||
|
whiteNoiseTimeLeft = whiteNoiseLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
material.SetInteger(_WhiteNoiseOnOff, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//////
|
||||||
|
|
||||||
|
material.SetInteger(_LetterBoxOnOff, isLetterBox ? 0 : 1);
|
||||||
|
//material.SetInteger(_LetterBoxEdgeBlurOnOff, isLetterBoxEdgeBlur ? 0 : 1);
|
||||||
|
material.SetInteger(_LetterBoxType, (int)letterBoxType.GetValue());
|
||||||
|
|
||||||
|
material.SetInteger(_ScanlineOnOff, isScanline ? 1 : 0);
|
||||||
|
material.SetInteger(_MonochormeOnOff, isMonochrome ? 1 : 0);
|
||||||
|
material.SetFloat(_FlickeringStrength, flickeringStrength);
|
||||||
|
material.SetFloat(_FlickeringCycle, flickeringCycle);
|
||||||
|
material.SetFloat(_ChromaticAberrationStrength, chromaticAberrationStrength);
|
||||||
|
material.SetInteger(_ChromaticAberrationOnOff, isChromaticAberration ? 1 : 0);
|
||||||
|
material.SetInteger(_MultipleGhostOnOff, isMultipleGhost ? 1 : 0);
|
||||||
|
material.SetFloat(_MultipleGhostStrength, multipleGhostStrength);
|
||||||
|
|
||||||
|
//////Slippage
|
||||||
|
material.SetInteger(_SlippageOnOff, isSlippage ? 1 : 0);
|
||||||
|
material.SetFloat(_SlippageInterval, slippageInterval);
|
||||||
|
material.SetFloat(_SlippageNoiseOnOff, isSlippageNoise ? Random.Range(0, 1f) : 1);
|
||||||
|
material.SetFloat(_SlippageScrollSpeed, slippageScrollSpeed);
|
||||||
|
material.SetFloat(_SlippageStrength, slippageStrength);
|
||||||
|
material.SetFloat(_SlippageSize, slippageSize);
|
||||||
|
//////
|
||||||
|
|
||||||
|
//////Screen Jump Noise
|
||||||
|
screenJumpTimeLeft -= 0.01f;
|
||||||
|
if (screenJumpTimeLeft <= 0)
|
||||||
|
{
|
||||||
|
if (Random.Range(0, 1000) < screenJumpFrequency)
|
||||||
|
{
|
||||||
|
var level = Random.Range(screenJumpMinLevel, screenJumpMaxLevel);
|
||||||
|
material.SetFloat(_ScreenJumpLevel, level);
|
||||||
|
screenJumpTimeLeft = screenJumpLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
material.SetFloat(_ScreenJumpLevel, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d4ffc7492874c2241827f1d70c24a1e3
|
@ -0,0 +1,237 @@
|
|||||||
|
Shader "Filter/yunoda-3DCG/SimpleCRT"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
|
_DecalTex ("Decal Texture", 2D) = "white" {}
|
||||||
|
_FilmDirtTex ("Dirt Texture", 2D) = "white" {}
|
||||||
|
}
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
CGPROGRAM
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
|
||||||
|
struct appdata
|
||||||
|
{
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f
|
||||||
|
{
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
float2 decaluv : TEXCOORD1;
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
float4 _MainTex_TexelSize;
|
||||||
|
|
||||||
|
int _WhiteNoiseOnOff;
|
||||||
|
int _ScanlineOnOff;
|
||||||
|
int _MonochormeOnOff;
|
||||||
|
|
||||||
|
int _LetterBoxOnOff;
|
||||||
|
int _LetterBoxEdgeBlur;
|
||||||
|
int _LetterBoxType;
|
||||||
|
|
||||||
|
float _ScreenJumpLevel;
|
||||||
|
|
||||||
|
float _FlickeringStrength;
|
||||||
|
float _FlickeringCycle;
|
||||||
|
|
||||||
|
int _SlippageOnOff;
|
||||||
|
float _SlippageStrength;
|
||||||
|
float _SlippageInterval;
|
||||||
|
float _SlippageScrollSpeed;
|
||||||
|
float _SlippageNoiseOnOff;
|
||||||
|
float _SlippageSize;
|
||||||
|
|
||||||
|
float _ChromaticAberrationStrength;
|
||||||
|
int _ChromaticAberrationOnOff;
|
||||||
|
|
||||||
|
int _MultipleGhostOnOff;
|
||||||
|
float _MultipleGhostStrength;
|
||||||
|
|
||||||
|
sampler2D _DecalTex;
|
||||||
|
float4 _DecalTex_ST;
|
||||||
|
int _DecalTexOnOff;
|
||||||
|
float2 _DecalTexPos;
|
||||||
|
float2 _DecalTexScale;
|
||||||
|
|
||||||
|
int _FilmDirtOnOff;
|
||||||
|
sampler2D _FilmDirtTex;
|
||||||
|
float4 _FilmDirtTex_ST;
|
||||||
|
|
||||||
|
float GetRandom(float x);
|
||||||
|
float EaseIn(float t0, float t1, float t);
|
||||||
|
|
||||||
|
v2f vert (appdata v)
|
||||||
|
{
|
||||||
|
v2f o;
|
||||||
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||||
|
o.decaluv = TRANSFORM_TEX(v.uv, _DecalTex);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed4 frag (v2f i) : SV_Target
|
||||||
|
{
|
||||||
|
float2 uv = i.uv;
|
||||||
|
|
||||||
|
/////Jump noise
|
||||||
|
uv.y = frac(uv.y + _ScreenJumpLevel);
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////frickering
|
||||||
|
float flickeringNoise = GetRandom(_Time.y);
|
||||||
|
float flickeringMask = pow(abs(sin(i.uv.y * _FlickeringCycle + _Time.y)), 10);
|
||||||
|
uv.x = uv.x + (flickeringNoise * _FlickeringStrength * flickeringMask);
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////slippage
|
||||||
|
float scrollSpeed = _Time.x * _SlippageScrollSpeed;
|
||||||
|
float slippageMask = pow(abs(sin(i.uv.y * _SlippageInterval + scrollSpeed)), _SlippageSize);
|
||||||
|
float stepMask = round(sin(i.uv.y * _SlippageInterval + scrollSpeed - 1));
|
||||||
|
uv.x = uv.x + (_SlippageNoiseOnOff * _SlippageStrength * slippageMask * stepMask) * _SlippageOnOff;
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////Chromatic Aberration
|
||||||
|
float red = tex2D(_MainTex, float2(uv.x - _ChromaticAberrationStrength * _ChromaticAberrationOnOff, uv.y)).r;
|
||||||
|
float green = tex2D(_MainTex, float2(uv.x, uv.y)).g;
|
||||||
|
float blue = tex2D(_MainTex, float2(uv.x + _ChromaticAberrationStrength * _ChromaticAberrationOnOff, uv.y)).b;
|
||||||
|
float4 color = float4(red, green, blue, 1);
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////Multiple Ghost
|
||||||
|
float4 ghost1st = tex2D(_MainTex, uv - float2(1, 0) * _MultipleGhostStrength * _MultipleGhostOnOff);
|
||||||
|
float4 ghost2nd = tex2D(_MainTex, uv - float2(1, 0) * _MultipleGhostStrength * 2 * _MultipleGhostOnOff);
|
||||||
|
color = color * 0.8 + ghost1st * 0.15 + ghost2nd * 0.05;
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////File dirt
|
||||||
|
float2 pp = -1.0 + 2.0 * uv;
|
||||||
|
float time = _Time.x;
|
||||||
|
float aaRad = 0.1;
|
||||||
|
float2 nseLookup2 = pp + time * 1000;
|
||||||
|
float3 nse2 =
|
||||||
|
tex2D(_FilmDirtTex, 0.1 * nseLookup2.xy).xyz +
|
||||||
|
tex2D(_FilmDirtTex, 0.01 * nseLookup2.xy).xyz +
|
||||||
|
tex2D(_FilmDirtTex, 0.004 * nseLookup2.xy).xyz;
|
||||||
|
float thresh = 0.6;
|
||||||
|
float mul1 = smoothstep(thresh - aaRad, thresh + aaRad, nse2.x);
|
||||||
|
float mul2 = smoothstep(thresh - aaRad, thresh + aaRad, nse2.y);
|
||||||
|
float mul3 = smoothstep(thresh - aaRad, thresh + aaRad, nse2.z);
|
||||||
|
|
||||||
|
float seed = tex2D(_FilmDirtTex, float2(time * 0.35, time)).x;
|
||||||
|
|
||||||
|
float result = clamp(0, 1, seed + 0.7);
|
||||||
|
|
||||||
|
result += 0.06 * EaseIn(19.2, 19.4, time);
|
||||||
|
|
||||||
|
float band = 0.05;
|
||||||
|
if(_FilmDirtOnOff == 1)
|
||||||
|
{
|
||||||
|
if( 0.3 < seed && 0.3 + band > seed )
|
||||||
|
color *= mul1 * result;
|
||||||
|
else if( 0.6 < seed && 0.6 + band > seed )
|
||||||
|
color *= mul2 * result;
|
||||||
|
else if( 0.9 < seed && 0.9 + band > seed )
|
||||||
|
color *= mul3 * result;
|
||||||
|
}
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////Letter box
|
||||||
|
float band_uv = fmod(_MainTex_TexelSize.z, 640) / _MainTex_TexelSize.z / 2;
|
||||||
|
if(i.uv.x < band_uv || 1 - band_uv < i.uv.x)
|
||||||
|
{
|
||||||
|
float pi = 6.28318530718;
|
||||||
|
float directions = 16.0;
|
||||||
|
float quality = 3.0;
|
||||||
|
float size = 8.0;
|
||||||
|
|
||||||
|
float2 Radius = size * _MainTex_ST.zw;
|
||||||
|
float4 samplingColor = tex2D(_MainTex, uv);
|
||||||
|
|
||||||
|
for(float d = 0.0; d < pi; d += pi / directions)
|
||||||
|
{
|
||||||
|
for(float i = 1.0 / quality; i <= 1.0; i += 1.0 / quality)
|
||||||
|
{
|
||||||
|
samplingColor += tex2D(_MainTex, uv + float2(cos(d), sin(d)) * 0.015 * i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
samplingColor /= quality * directions - 15.0;
|
||||||
|
|
||||||
|
if(_LetterBoxOnOff == 1)
|
||||||
|
{
|
||||||
|
color = color;
|
||||||
|
}
|
||||||
|
else if(_LetterBoxType == 0) // LetterBox is Black
|
||||||
|
{
|
||||||
|
color = 0;
|
||||||
|
}
|
||||||
|
else if(_LetterBoxType == 1) // LetterBox is Blur
|
||||||
|
{
|
||||||
|
color = samplingColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////White noise
|
||||||
|
if(_WhiteNoiseOnOff == 1)
|
||||||
|
{
|
||||||
|
return frac(sin(dot(i.uv, float2(12.9898, 78.233)) + _Time.x) * 43758.5453);
|
||||||
|
}
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////Decal texture
|
||||||
|
float4 decal = tex2D(_DecalTex, (i.decaluv - _DecalTexPos) * _DecalTexScale) * _DecalTexOnOff;
|
||||||
|
color = color * (1 - decal.a) + decal;
|
||||||
|
/////
|
||||||
|
|
||||||
|
/////Scanline
|
||||||
|
float scanline = sin((i.uv.y + _Time.x) * 800.0) * 0.04;
|
||||||
|
color -= scanline * _ScanlineOnOff;
|
||||||
|
/////
|
||||||
|
|
||||||
|
//////scanline noise
|
||||||
|
float noiseAlpha = 1;
|
||||||
|
if(pow(sin(uv.y + _Time.y * 2), 200) >= 0.999)
|
||||||
|
{
|
||||||
|
noiseAlpha = GetRandom(uv.y);
|
||||||
|
//color *= noiseAlpha;
|
||||||
|
}
|
||||||
|
//////
|
||||||
|
|
||||||
|
//////Monochorome
|
||||||
|
if(_MonochormeOnOff == 1)
|
||||||
|
{
|
||||||
|
color.xyz = 0.299f * color.r + 0.587f * color.g + 0.114f * color.b;
|
||||||
|
}
|
||||||
|
//////
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetRandom(float x)
|
||||||
|
{
|
||||||
|
return frac(sin(dot(x, float2(12.9898, 78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
float EaseIn(float t0, float t1, float t)
|
||||||
|
{
|
||||||
|
return 2.0 * smoothstep(t0, 2.0 * t1 - t0, t);
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fdf9f1937116ab84c97a58a4cf82fbf8
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -9,7 +9,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
public class CacheManager
|
public class CacheManager
|
||||||
{
|
{
|
||||||
static readonly string CacheDirPath = $"{App.PersistentDataPath}/Caches";
|
static readonly string CacheDirPath = $"{App.PersistentDataRoot()}/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)
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5fe26f58ab822c44888b86305c5326e0
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,26 @@
|
|||||||
|
namespace AxibugEmuOnline.Client.Manager
|
||||||
|
{
|
||||||
|
public partial class GamePadManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 被Unity所识别的通用GamePad类
|
||||||
|
/// </summary>
|
||||||
|
public class GamePad
|
||||||
|
{
|
||||||
|
internal GamePadInfo m_info;
|
||||||
|
public int Index => m_info.Index;
|
||||||
|
public string Name => m_info.Name;
|
||||||
|
public bool Offline { get; internal set; }
|
||||||
|
|
||||||
|
internal GamePad(GamePadInfo info)
|
||||||
|
{
|
||||||
|
m_info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{Index}:{Name}{(Offline ? "(Offline)" : string.Empty)}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c2c0a06020f65a747af5490a6112361b
|
@ -0,0 +1,121 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace AxibugEmuOnline.Client.Manager
|
||||||
|
{
|
||||||
|
public partial class GamePadManager
|
||||||
|
{
|
||||||
|
#region Events
|
||||||
|
public delegate void GamePadConnectedHandle(GamePad newConnectGamePad);
|
||||||
|
/// <summary> 当一个手柄连接时触发 </summary>
|
||||||
|
public event GamePadConnectedHandle OnGamePadConnected;
|
||||||
|
|
||||||
|
public delegate void GamePadDisConnectedHandle(GamePad disConnectGamePad);
|
||||||
|
/// <summary> 当一个手柄断开时触发 </summary>
|
||||||
|
public event GamePadDisConnectedHandle OnGamePadDisConnected;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
Dictionary<GamePadInfo, GamePad> m_gamePads = new Dictionary<GamePadInfo, GamePad>();
|
||||||
|
HashSet<GamePadInfo> m_temp = new HashSet<GamePadInfo>();
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
m_temp.Clear();
|
||||||
|
foreach (var info in m_gamePads.Keys)
|
||||||
|
m_temp.Add(info); //记录需要被移除的手柄
|
||||||
|
|
||||||
|
var devices = Input.GetJoystickNames();
|
||||||
|
for (int i = 0; i < devices.Length; i++)
|
||||||
|
{
|
||||||
|
var info = new GamePadInfo { Index = i, Name = devices[i] };
|
||||||
|
m_temp.Remove(info);
|
||||||
|
|
||||||
|
if (!m_gamePads.ContainsKey(info))
|
||||||
|
{
|
||||||
|
m_gamePads[info] = new GamePad(info);
|
||||||
|
OnGamePadConnected?.Invoke(m_gamePads[info]);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var info in m_temp)
|
||||||
|
{
|
||||||
|
if (m_gamePads.TryGetValue(info, out GamePad gp))
|
||||||
|
{
|
||||||
|
m_gamePads.Remove(info);
|
||||||
|
gp.Offline = true;
|
||||||
|
OnGamePadDisConnected?.Invoke(gp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有已连接的手柄,返回的结果顺序与手柄序号无关
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public GamePad[] GetGamePads()
|
||||||
|
{
|
||||||
|
return m_gamePads.Values.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal struct GamePadInfo : IEquatable<GamePadInfo>, IComparable<GamePadInfo>
|
||||||
|
{
|
||||||
|
internal int Index;
|
||||||
|
internal string Name;
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj is GamePadInfo)
|
||||||
|
{
|
||||||
|
return Equals((GamePadInfo)obj);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(GamePadInfo other)
|
||||||
|
{
|
||||||
|
return Index == other.Index && Name == other.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
// Custom hash code implementation without HashCombine
|
||||||
|
int hash = 17;
|
||||||
|
hash = hash * 31 + Index.GetHashCode();
|
||||||
|
hash = hash * 31 + (Name != null ? Name.GetHashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(GamePadInfo other)
|
||||||
|
{
|
||||||
|
int indexComparison = Index.CompareTo(other.Index);
|
||||||
|
if (indexComparison != 0)
|
||||||
|
{
|
||||||
|
return indexComparison;
|
||||||
|
}
|
||||||
|
return string.Compare(Name, other.Name, StringComparison.Ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(GamePadInfo left, GamePadInfo right)
|
||||||
|
{
|
||||||
|
return left.Equals(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(GamePadInfo left, GamePadInfo right)
|
||||||
|
{
|
||||||
|
return !(left == right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator <(GamePadInfo left, GamePadInfo right)
|
||||||
|
{
|
||||||
|
return left.CompareTo(right) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator >(GamePadInfo left, GamePadInfo right)
|
||||||
|
{
|
||||||
|
return left.CompareTo(right) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ce4d215abea527e4a8cf1103cbfecf6b
|
@ -21,8 +21,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
/// <summary> 指示该Rom文件的存放路径 </summary>
|
/// <summary> 指示该Rom文件的存放路径 </summary>
|
||||||
public string LocalFilePath =>
|
public string LocalFilePath =>
|
||||||
IsUserRom ?
|
IsUserRom ?
|
||||||
$"{App.PersistentDataPath}/UserRoms/{Platform}/{FileName}" :
|
$"{App.PersistentDataPath(Platform)}/UserRoms/{FileName}" :
|
||||||
$"{App.PersistentDataPath}/RemoteRoms/{Platform}/{FileName}";
|
$"{App.PersistentDataPath(Platform)}/RemoteRoms/{FileName}";
|
||||||
|
|
||||||
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
||||||
public bool RomReady => hasLocalFile;
|
public bool RomReady => hasLocalFile;
|
||||||
|
@ -43,6 +43,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
private void OnRomStarStateChanged(int romID, bool star)
|
private void OnRomStarStateChanged(int romID, bool star)
|
||||||
{
|
{
|
||||||
|
if (nesRomFetchList == null) return;
|
||||||
|
|
||||||
var targetRom = nesRomFetchList.FirstOrDefault(rom => rom.ID == romID);
|
var targetRom = nesRomFetchList.FirstOrDefault(rom => rom.ID == romID);
|
||||||
if (targetRom == null) return;
|
if (targetRom == null) return;
|
||||||
|
|
||||||
@ -59,7 +61,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
/// <summary> 清除所有下载的Rom文件 </summary>
|
/// <summary> 清除所有下载的Rom文件 </summary>
|
||||||
public void ClearRomFile()
|
public void ClearRomFile()
|
||||||
{
|
{
|
||||||
var path = $"{App.PersistentDataPath}/RemoteRoms/{m_platform}";
|
var path = $"{App.PersistentDataPath(m_platform)}/RemoteRoms";
|
||||||
if (Directory.Exists(path)) Directory.Delete(path, true);
|
if (Directory.Exists(path)) Directory.Delete(path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void SaveSRAMToFile(byte[] sramContent, string romName)
|
public void SaveSRAMToFile(byte[] sramContent, string romName)
|
||||||
{
|
{
|
||||||
string sramDirectoryPath = $"{App.PersistentDataPath}/sav";
|
string sramDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{Config.path.szSavePath}";
|
||||||
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);
|
||||||
@ -56,7 +56,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void SaveDISKToFile(byte[] diskFileContent, string romName)
|
public void SaveDISKToFile(byte[] diskFileContent, string romName)
|
||||||
{
|
{
|
||||||
string diskFileDirectoryPath = $"{App.PersistentDataPath}/dsv";
|
string diskFileDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/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);
|
||||||
@ -65,14 +65,14 @@ namespace AxibugEmuOnline.Client
|
|||||||
public EmulatorConfig Config { get; private set; } = new EmulatorConfig();
|
public EmulatorConfig Config { get; private set; } = new EmulatorConfig();
|
||||||
public void PrepareDirectory(string directPath)
|
public void PrepareDirectory(string directPath)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory($"{App.PersistentDataPath}/{directPath}");
|
Directory.CreateDirectory($"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{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 = $"{App.PersistentDataPath}/{directPath}/{fileName}";
|
var fileFullpath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
|
||||||
File.WriteAllBytes(fileFullpath, fileData);
|
File.WriteAllBytes(fileFullpath, fileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = File.ReadAllBytes($"{App.PersistentDataPath}/{directPath}/{fileName}");
|
var path = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
|
||||||
|
var data = File.ReadAllBytes(path);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
}
|
}
|
||||||
@ -88,7 +89,6 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetMapperNo(ROM rom, out int mapperNo)
|
public bool TryGetMapperNo(ROM rom, out int mapperNo)
|
||||||
|
@ -5,7 +5,6 @@ using System.Diagnostics;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VirtualNes.Core;
|
using VirtualNes.Core;
|
||||||
using VirtualNes.Core.Debug;
|
using VirtualNes.Core.Debug;
|
||||||
@ -179,6 +178,17 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IControllerSetuper GetControllerSetuper()
|
||||||
|
{
|
||||||
|
return ControllerMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
StopGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@ -207,15 +217,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
db.AddInfo(new RomDB.RomInfo { CRC = crc, Mapper = mapper });
|
db.AddInfo(new RomDB.RomInfo { CRC = crc, Mapper = mapper });
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUtility.SetDirty(db);
|
UnityEditor.EditorUtility.SetDirty(db);
|
||||||
AssetDatabase.SaveAssets();
|
UnityEditor.AssetDatabase.SaveAssets();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
public IControllerSetuper GetControllerSetuper()
|
|
||||||
{
|
|
||||||
return ControllerMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -153,7 +153,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
private FilterEffect.EditableParamerter m_param;
|
private FilterEffect.EditableParamerter m_param;
|
||||||
private FilterPreset m_preset;
|
private FilterPreset m_preset;
|
||||||
|
|
||||||
public override bool Visible => m_param.ValueType.IsEnum || m_param.ValueType == typeof(float);
|
public override bool Visible => true;
|
||||||
|
|
||||||
public override string Name => m_param.Name;
|
public override string Name => m_param.Name;
|
||||||
public Opt_ParamEditor(Filter filter, FilterEffect.EditableParamerter editParam, FilterPreset preset)
|
public Opt_ParamEditor(Filter filter, FilterEffect.EditableParamerter editParam, FilterPreset preset)
|
||||||
|
@ -139,6 +139,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
DownloadingFlag.SetActiveEx(false);
|
DownloadingFlag.SetActiveEx(false);
|
||||||
FileReadyFlag.SetActiveEx(false);
|
FileReadyFlag.SetActiveEx(false);
|
||||||
|
Star.SetActiveEx(IsStar);
|
||||||
|
|
||||||
if (m_romfile == null) return;
|
if (m_romfile == null) return;
|
||||||
if (!m_romfile.InfoReady) return;
|
if (!m_romfile.InfoReady) return;
|
||||||
|
@ -8,6 +8,10 @@ namespace AxibugEmuOnline.Client
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
OptionUI_ValueEditItem_FloatEdit com_floatEdit;
|
OptionUI_ValueEditItem_FloatEdit com_floatEdit;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
|
OptionUI_ValueEditItem_IntEdit com_intEdit;
|
||||||
|
[SerializeField]
|
||||||
|
OptionUI_ValueEditItem_BoolEdit com_boolEdit;
|
||||||
|
[SerializeField]
|
||||||
OptionUI_ValueEditItem_EnumEdit com_enumEdit;
|
OptionUI_ValueEditItem_EnumEdit com_enumEdit;
|
||||||
|
|
||||||
IValueEditControl m_currentCom;
|
IValueEditControl m_currentCom;
|
||||||
@ -15,6 +19,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
protected override void OnSetData(OptionMenu menuData)
|
protected override void OnSetData(OptionMenu menuData)
|
||||||
{
|
{
|
||||||
com_floatEdit.gameObject.SetActive(false);
|
com_floatEdit.gameObject.SetActive(false);
|
||||||
|
com_intEdit.gameObject.SetActive(false);
|
||||||
|
com_boolEdit.gameObject.SetActive(false);
|
||||||
com_enumEdit.gameObject.SetActive(false);
|
com_enumEdit.gameObject.SetActive(false);
|
||||||
|
|
||||||
if (menuData is ValueSetMenu)
|
if (menuData is ValueSetMenu)
|
||||||
@ -24,13 +30,21 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
m_currentCom = com_floatEdit;
|
m_currentCom = com_floatEdit;
|
||||||
}
|
}
|
||||||
|
else if(valueMenu.ValueType == typeof(int))
|
||||||
|
{
|
||||||
|
m_currentCom = com_intEdit;
|
||||||
|
}
|
||||||
|
else if(valueMenu.ValueType == typeof(bool))
|
||||||
|
{
|
||||||
|
m_currentCom = com_boolEdit;
|
||||||
|
}
|
||||||
else if (valueMenu.ValueType.IsEnum)
|
else if (valueMenu.ValueType.IsEnum)
|
||||||
{
|
{
|
||||||
m_currentCom = com_enumEdit;
|
m_currentCom = com_enumEdit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App.log.Warning($"尚未支持的数据类型:{valueMenu.ValueType}");
|
App.log.Error($"尚未支持的数据类型:{valueMenu.ValueType}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace AxibugEmuOnline.Client
|
||||||
|
{
|
||||||
|
public class OptionUI_ValueEditItem_BoolEdit : MonoBehaviour, IValueEditControl
|
||||||
|
{
|
||||||
|
[SerializeField]
|
||||||
|
Text txt_value;
|
||||||
|
|
||||||
|
private ValueSetMenu m_valueMenu;
|
||||||
|
|
||||||
|
public void SetData(ValueSetMenu valueMenu)
|
||||||
|
{
|
||||||
|
m_valueMenu = valueMenu;
|
||||||
|
txt_value.text = valueMenu.ValueRaw.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnLeft()
|
||||||
|
{
|
||||||
|
OnExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnRight()
|
||||||
|
{
|
||||||
|
OnExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnExecute()
|
||||||
|
{
|
||||||
|
var value = (bool)m_valueMenu.ValueRaw;
|
||||||
|
value = !value;
|
||||||
|
txt_value.text = value.ToString();
|
||||||
|
m_valueMenu.OnValueChanged(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c864ef7d3920dfc4cb69a86ef3af426b
|
@ -0,0 +1,58 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace AxibugEmuOnline.Client
|
||||||
|
{
|
||||||
|
public class OptionUI_ValueEditItem_IntEdit : MonoBehaviour, IValueEditControl
|
||||||
|
{
|
||||||
|
[SerializeField]
|
||||||
|
Slider slider;
|
||||||
|
[SerializeField]
|
||||||
|
Text txt_value;
|
||||||
|
|
||||||
|
int m_step;
|
||||||
|
private ValueSetMenu m_valueMenu;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
slider.onValueChanged.AddListener(OnSliderValueChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSliderValueChanged(float value)
|
||||||
|
{
|
||||||
|
int intValue = (int)value;
|
||||||
|
txt_value.text = $"{intValue}";
|
||||||
|
|
||||||
|
if (!m_dataSetting) m_valueMenu.OnValueChanged(intValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool m_dataSetting;
|
||||||
|
public void SetData(ValueSetMenu valueMenu)
|
||||||
|
{
|
||||||
|
m_dataSetting = true;
|
||||||
|
m_valueMenu = valueMenu;
|
||||||
|
slider.minValue = (int)valueMenu.Min;
|
||||||
|
slider.maxValue = (int)valueMenu.Max;
|
||||||
|
slider.value = (int)valueMenu.ValueRaw;
|
||||||
|
slider.wholeNumbers = true;
|
||||||
|
m_step = 1;
|
||||||
|
m_dataSetting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnLeft()
|
||||||
|
{
|
||||||
|
var newValue = Mathf.Clamp(slider.value - m_step, slider.minValue, slider.maxValue);
|
||||||
|
slider.value = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnRight()
|
||||||
|
{
|
||||||
|
var newValue = Mathf.Clamp(slider.value + m_step, slider.minValue, slider.maxValue);
|
||||||
|
slider.value = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnExecute()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: abad743de1574354f99efc5054aa6b43
|
@ -319,6 +319,12 @@ namespace VirtualNes.Core
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void QueueClear()
|
||||||
|
{
|
||||||
|
queue.Clear();
|
||||||
|
exqueue.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void QueueFlush()
|
private void QueueFlush()
|
||||||
{
|
{
|
||||||
while (queue.wrptr != queue.rdptr)
|
while (queue.wrptr != queue.rdptr)
|
||||||
@ -651,5 +657,11 @@ namespace VirtualNes.Core
|
|||||||
public int rdptr;
|
public int rdptr;
|
||||||
public int wrptr;
|
public int wrptr;
|
||||||
public QUEUEDATA[] data = new QUEUEDATA[8192];
|
public QUEUEDATA[] data = new QUEUEDATA[8192];
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
rdptr = 0;wrptr = 0;
|
||||||
|
data = new QUEUEDATA[8192];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,6 +355,7 @@ namespace VirtualNes.Core
|
|||||||
private void LoadDISK()
|
private void LoadDISK()
|
||||||
{
|
{
|
||||||
//todo : 磁碟机读取支持
|
//todo : 磁碟机读取支持
|
||||||
|
Debuger.LogError($"磁碟机尚未支持");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSRAM()
|
private void LoadSRAM()
|
||||||
@ -1070,6 +1071,10 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
SaveSRAM();
|
||||||
|
SaveDISK();
|
||||||
|
SaveTurboFile();
|
||||||
|
|
||||||
cpu?.Dispose();
|
cpu?.Dispose();
|
||||||
ppu?.Dispose();
|
ppu?.Dispose();
|
||||||
apu?.Dispose();
|
apu?.Dispose();
|
||||||
@ -1081,7 +1086,7 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (rom.IsNSF()) return;
|
if (rom.IsNSF()) return;
|
||||||
if (rom.IsSAVERAM()) return;
|
if (!rom.IsSAVERAM()) return;
|
||||||
|
|
||||||
for (i = 0; i < SAVERAM_SIZE; i++)
|
for (i = 0; i < SAVERAM_SIZE; i++)
|
||||||
{
|
{
|
||||||
@ -1841,10 +1846,11 @@ namespace VirtualNes.Core
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
cpu.SetDmaCycles(state.reg.cpureg.DMA_cycles);
|
|
||||||
emul_cycles = state.reg.cpureg.emul_cycles;
|
emul_cycles = state.reg.cpureg.emul_cycles;
|
||||||
base_cycles = state.reg.cpureg.base_cycles;
|
base_cycles = state.reg.cpureg.base_cycles;
|
||||||
|
|
||||||
|
cpu.SetDmaCycles(state.reg.cpureg.DMA_cycles);
|
||||||
|
|
||||||
// LOAD PPU STATE
|
// LOAD PPU STATE
|
||||||
MMU.PPUREG[0] = state.reg.ppureg.reg0;
|
MMU.PPUREG[0] = state.reg.ppureg.reg0;
|
||||||
MMU.PPUREG[1] = state.reg.ppureg.reg1;
|
MMU.PPUREG[1] = state.reg.ppureg.reg1;
|
||||||
@ -1857,6 +1863,8 @@ namespace VirtualNes.Core
|
|||||||
MMU.PPU56Toggle = state.reg.ppureg.toggle56;
|
MMU.PPU56Toggle = state.reg.ppureg.toggle56;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apu.QueueClear();
|
||||||
|
|
||||||
//RAM STATE
|
//RAM STATE
|
||||||
{
|
{
|
||||||
// SAVE RAM STATE
|
// SAVE RAM STATE
|
||||||
|
@ -244,11 +244,11 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
FileNameCheck(fname);
|
FileNameCheck(fname);
|
||||||
|
|
||||||
if (Supporter.S.TryGetMapperNo(this, out int mapperNo))
|
//if (Supporter.S.TryGetMapperNo(this, out int mapperNo))
|
||||||
{
|
//{
|
||||||
Debuger.Log($"ROMDB Set Mapper #{mapper:000} to #{mapperNo:000}");
|
// Debuger.Log($"ROMDB Set Mapper #{mapper:000} to #{mapperNo:000}");
|
||||||
mapper = mapperNo;
|
// mapper = mapperNo;
|
||||||
}
|
//}
|
||||||
|
|
||||||
RomPatch.DoPatch(ref crc, ref lpPRG, ref lpCHR, ref mapper, ref header);
|
RomPatch.DoPatch(ref crc, ref lpPRG, ref lpCHR, ref mapper, ref header);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
public bool bIpsPath = true;
|
public bool bIpsPath = true;
|
||||||
|
|
||||||
public string szRomPath = "roms";
|
public string szRomPath = "roms";
|
||||||
public string szSavePath = "save";
|
public string szSavePath = "sav";
|
||||||
public string szStatePath = "state";
|
public string szStatePath = "state";
|
||||||
public string szSnapshotPath = "snapshot";
|
public string szSnapshotPath = "snapshot";
|
||||||
public string szMoviePath = "movie";
|
public string szMoviePath = "movie";
|
||||||
|
@ -12,7 +12,7 @@ PlayerSettings:
|
|||||||
targetDevice: 2
|
targetDevice: 2
|
||||||
useOnDemandResources: 0
|
useOnDemandResources: 0
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||
companyName: DefaultCompany
|
companyName: AlienTechnology
|
||||||
productName: AxibugEmuOnline.Client
|
productName: AxibugEmuOnline.Client
|
||||||
defaultCursor: {fileID: 0}
|
defaultCursor: {fileID: 0}
|
||||||
cursorHotspot: {x: 0, y: 0}
|
cursorHotspot: {x: 0, y: 0}
|
||||||
@ -164,7 +164,7 @@ PlayerSettings:
|
|||||||
androidMinAspectRatio: 1
|
androidMinAspectRatio: 1
|
||||||
applicationIdentifier:
|
applicationIdentifier:
|
||||||
Android: com.DefaultCompany.AxibugEmuOnline.Client
|
Android: com.DefaultCompany.AxibugEmuOnline.Client
|
||||||
Standalone: com.DefaultCompany.AxibugEmuOnline.Client
|
Standalone: com.AlienTechnology.AxibugEmuOnline.Client
|
||||||
buildNumber:
|
buildNumber:
|
||||||
Standalone: 0
|
Standalone: 0
|
||||||
VisionOS: 0
|
VisionOS: 0
|
||||||
|
Loading…
Reference in New Issue
Block a user