forked from sin365/AxibugEmuOnline
Merge pull request 'master' (#84) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: sin365/AxibugEmuOnline#84
This commit is contained in:
commit
ba93b5747b
@ -6,7 +6,6 @@ using System.Collections;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using static AxibugEmuOnline.Client.HttpAPI;
|
||||
using static AxibugEmuOnline.Client.Manager.LogManager;
|
||||
|
||||
@ -47,7 +46,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
#else
|
||||
public static string PersistentDataPath => Application.persistentDataPath;
|
||||
#endif
|
||||
public static void Init( bool isTest = false, string testSrvIP = "")
|
||||
public static void Init(bool isTest = false, string testSrvIP = "")
|
||||
{
|
||||
log = new LogManager(OnLogOut);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,76 +1,76 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using static AxiHttp;
|
||||
|
||||
public static class AxiHttpProxy
|
||||
{
|
||||
public static SendWebRequestProxy Get(string url)
|
||||
{
|
||||
return new SendWebRequestProxy(AxiRequestAsync(url));
|
||||
}
|
||||
|
||||
public static SendDownLoadProxy GetDownLoad(string url)
|
||||
{
|
||||
return new SendDownLoadProxy(AxiDownloadAsync(url));
|
||||
}
|
||||
|
||||
|
||||
public class SendWebRequestProxy
|
||||
{
|
||||
public WaitAxiRequest SendWebRequest;
|
||||
public AxiRespInfo downloadHandler => SendWebRequest.mReqAsync;
|
||||
public SendWebRequestProxy(WaitAxiRequest request)
|
||||
{
|
||||
SendWebRequest = request;
|
||||
}
|
||||
~SendWebRequestProxy()
|
||||
{
|
||||
SendWebRequest = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SendDownLoadProxy
|
||||
{
|
||||
public AxiRespInfo downloadHandler;
|
||||
public SendDownLoadProxy(AxiRespInfo re)
|
||||
{
|
||||
downloadHandler = re;
|
||||
}
|
||||
~SendDownLoadProxy()
|
||||
{
|
||||
downloadHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void ShowAxiHttpDebugInfo(AxiRespInfo resp)
|
||||
{
|
||||
|
||||
{
|
||||
public static SendWebRequestProxy Get(string url)
|
||||
{
|
||||
return new SendWebRequestProxy(AxiRequestAsync(url));
|
||||
}
|
||||
|
||||
public static SendDownLoadProxy GetDownLoad(string url)
|
||||
{
|
||||
return new SendDownLoadProxy(AxiDownloadAsync(url));
|
||||
}
|
||||
|
||||
|
||||
public class SendWebRequestProxy
|
||||
{
|
||||
public WaitAxiRequest SendWebRequest;
|
||||
public AxiRespInfo downloadHandler => SendWebRequest.mReqAsync;
|
||||
public SendWebRequestProxy(WaitAxiRequest request)
|
||||
{
|
||||
SendWebRequest = request;
|
||||
}
|
||||
~SendWebRequestProxy()
|
||||
{
|
||||
SendWebRequest = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SendDownLoadProxy
|
||||
{
|
||||
public AxiRespInfo downloadHandler;
|
||||
public SendDownLoadProxy(AxiRespInfo re)
|
||||
{
|
||||
downloadHandler = re;
|
||||
}
|
||||
~SendDownLoadProxy()
|
||||
{
|
||||
downloadHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void ShowAxiHttpDebugInfo(AxiRespInfo resp)
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== request ====");
|
||||
Debug.Log($"url =>{resp.url}");
|
||||
Debug.Log($"Raw =>{resp.requestRaw}");
|
||||
Debug.Log($"code =>{resp.code}");
|
||||
Debug.Log($"respInfo.bTimeOut =>{resp.bTimeOut}");
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== response ====");
|
||||
Debug.Log($"==== header ====");
|
||||
Debug.Log($"header =>{resp.header}");
|
||||
Debug.Log($"HeadersCount =>{resp.headers.Count}");
|
||||
foreach (var kv in resp.headers)
|
||||
Debug.Log($"{kv.Key} => {kv.Value}");
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== body ====");
|
||||
Debug.Log($"body_text =>{resp.body}");
|
||||
Debug.Log($"body_text.Length =>{resp.body.Length}");
|
||||
Debug.Log($"bodyRaw.Length =>{resp.bodyRaw?.Length}");
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== download ====");
|
||||
Debug.Log($"downloadMode =>{resp.downloadMode}");
|
||||
Debug.Log($"respInfo.fileName =>{resp.fileName}");
|
||||
Debug.Log($"respInfo.NeedloadedLenght =>{resp.NeedloadedLenght}");
|
||||
Debug.Log($"respInfo.loadedLenght =>{resp.loadedLenght}");
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== request ====");
|
||||
Debug.Log($"url =>{resp.url}");
|
||||
Debug.Log($"Raw =>{resp.requestRaw}");
|
||||
Debug.Log($"code =>{resp.code}");
|
||||
Debug.Log($"respInfo.bTimeOut =>{resp.bTimeOut}");
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== response ====");
|
||||
Debug.Log($"==== header ====");
|
||||
Debug.Log($"header =>{resp.header}");
|
||||
Debug.Log($"HeadersCount =>{resp.headers.Count}");
|
||||
foreach (var kv in resp.headers)
|
||||
Debug.Log($"{kv.Key} => {kv.Value}");
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== body ====");
|
||||
Debug.Log($"body_text =>{resp.body}");
|
||||
Debug.Log($"body_text.Length =>{resp.body.Length}");
|
||||
Debug.Log($"bodyRaw.Length =>{resp.bodyRaw?.Length}");
|
||||
Debug.Log($"");
|
||||
Debug.Log($"==== download ====");
|
||||
Debug.Log($"downloadMode =>{resp.downloadMode}");
|
||||
Debug.Log($"respInfo.fileName =>{resp.fileName}");
|
||||
Debug.Log($"respInfo.NeedloadedLenght =>{resp.NeedloadedLenght}");
|
||||
Debug.Log($"respInfo.loadedLenght =>{resp.loadedLenght}");
|
||||
#else
|
||||
Debug.Log($"==== request url => { resp.url}");
|
||||
Debug.Log($"code =>{resp.code}");
|
||||
@ -87,33 +87,33 @@ public static class AxiHttpProxy
|
||||
Debug.Log($"respInfo.loadedLenght =>{resp.loadedLenght}");
|
||||
}
|
||||
#endif
|
||||
|
||||
//if (resp.downloadMode == AxiDownLoadMode.DownLoadBytes)
|
||||
//{
|
||||
// if (resp.bTimeOut)
|
||||
// {
|
||||
// Debug.Log($"DownLoad Timeout!");
|
||||
// return;
|
||||
// }
|
||||
// string downloadSavePath;
|
||||
// if (Application.platform == RuntimePlatform.PSP2)
|
||||
// {
|
||||
// downloadSavePath = dataAxibugPath + "/" + resp.fileName;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// downloadSavePath = persistentDataPath + "/" + resp.fileName;
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// File.WriteAllBytes(downloadSavePath, resp.bodyRaw);
|
||||
// Debug.Log($"DownLoad OK");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Debug.Log($"DownLoad Err {ex.ToString()}");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
//if (resp.downloadMode == AxiDownLoadMode.DownLoadBytes)
|
||||
//{
|
||||
// if (resp.bTimeOut)
|
||||
// {
|
||||
// Debug.Log($"DownLoad Timeout!");
|
||||
// return;
|
||||
// }
|
||||
// string downloadSavePath;
|
||||
// if (Application.platform == RuntimePlatform.PSP2)
|
||||
// {
|
||||
// downloadSavePath = dataAxibugPath + "/" + resp.fileName;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// downloadSavePath = persistentDataPath + "/" + resp.fileName;
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// File.WriteAllBytes(downloadSavePath, resp.bodyRaw);
|
||||
// Debug.Log($"DownLoad OK");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Debug.Log($"DownLoad Err {ex.ToString()}");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
@ -12,10 +12,10 @@ namespace AxibugEmuOnline.Client
|
||||
public static string dev_UUID;
|
||||
|
||||
[SerializeField]
|
||||
GameObject IMPORTENT;
|
||||
|
||||
|
||||
|
||||
GameObject IMPORTENT;
|
||||
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public bool bTest = false;
|
||||
public string mTestSrvIP = "192.168.0.47";
|
||||
|
@ -432,7 +432,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// 发送修改玩家槽位,全量
|
||||
/// </summary>
|
||||
/// <param name="dictSlotIdx2LocalJoyIdx">玩家占用房间GamePlaySlot和LocalJoyIdx字典</param>
|
||||
public void SendChangePlaySlotIdxWithJoyIdx(Dictionary<uint, ValueTuple<uint,GamePadType>> dictSlotIdx2LocalJoyIdx)
|
||||
public void SendChangePlaySlotIdxWithJoyIdx(Dictionary<uint, ValueTuple<uint, GamePadType>> dictSlotIdx2LocalJoyIdx)
|
||||
{
|
||||
if (!InRoom)
|
||||
return;
|
||||
@ -617,7 +617,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
public static bool GetPlayerGamePadTypeByPlayerIdx(this Protobuf_Room_MiniInfo roomMiniInfo, uint GameSlotIdx, out GamePadType gamePadType)
|
||||
{
|
||||
if (roomMiniInfo.GamePlaySlotList[(int)GameSlotIdx].PlayerUID > 0)
|
||||
{
|
||||
{
|
||||
gamePadType = roomMiniInfo.GamePlaySlotList[(int)GameSlotIdx].PlayerLocalGamePadType;
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using AxibugEmuOnline.Client;
|
||||
using AxibugEmuOnline.Client;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class Filter1990_esque : FilterEffect
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Assets.Script.AppMain.Filter;
|
||||
using AxibugEmuOnline.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Script.AppMain.Filter
|
||||
|
@ -1,10 +1,9 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
@ -26,8 +25,8 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
|
||||
IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback)
|
||||
{
|
||||
AxiHttpProxy.SendDownLoadProxy request = AxiHttpProxy.GetDownLoad($"{App.httpAPI.WebHost}/{url}");
|
||||
{
|
||||
AxiHttpProxy.SendDownLoadProxy request = AxiHttpProxy.GetDownLoad($"{App.httpAPI.WebHost}/{url}");
|
||||
|
||||
while (!request.downloadHandler.isDone)
|
||||
{
|
||||
@ -61,14 +60,14 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
|
||||
private Dictionary<string, object> cachesInMemory = new Dictionary<string, object>();
|
||||
void GetCacheData<T>(string url, string path, Action<T, string> callback) where T : class
|
||||
{
|
||||
object cacheObj;
|
||||
|
||||
if (cachesInMemory.TryGetValue(url, out cacheObj) && cacheObj is T)
|
||||
void GetCacheData<T>(string url, string path, Action<T, string> callback) where T : class
|
||||
{
|
||||
object cacheObj;
|
||||
|
||||
if (cachesInMemory.TryGetValue(url, out cacheObj) && cacheObj is T)
|
||||
{
|
||||
T obj = (T)cacheObj;
|
||||
callback.Invoke(obj, url);
|
||||
T obj = (T)cacheObj;
|
||||
callback.Invoke(obj, url);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
@ -18,14 +16,14 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void GetNesRomList(Action<int, Resp_GameList> callback, AxibugProtobuf.RomPlatformType platform, int page, int pageSize = 10)
|
||||
{
|
||||
App.StartCoroutine(GetRomListFlow(platform,page, pageSize, callback));
|
||||
App.StartCoroutine(GetRomListFlow(platform, page, pageSize, callback));
|
||||
}
|
||||
|
||||
public void SearchNesRomList(Action<int, Resp_GameList> callback, AxibugProtobuf.RomPlatformType platform, string searchKey, int page, int pageSize = 10)
|
||||
{
|
||||
App.StartCoroutine(SearchNesRomListFlow(platform,searchKey, page, pageSize, callback));
|
||||
App.StartCoroutine(SearchNesRomListFlow(platform, searchKey, page, pageSize, callback));
|
||||
}
|
||||
private IEnumerator SearchNesRomListFlow(AxibugProtobuf.RomPlatformType platform,string searchKey, int page, int pageSize, Action<int, Resp_GameList> callback)
|
||||
private IEnumerator SearchNesRomListFlow(AxibugProtobuf.RomPlatformType platform, string searchKey, int page, int pageSize, Action<int, Resp_GameList> callback)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(searchKey))
|
||||
{
|
||||
|
@ -154,18 +154,18 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
for (int i = 0; i < msg.UserList.Count; i++)
|
||||
{
|
||||
UserMiniInfo mi = msg.UserList[i];
|
||||
bool isNewUser;
|
||||
UpdateOrAddUser(mi, out isNewUser);
|
||||
bool isNewUser;
|
||||
UpdateOrAddUser(mi, out isNewUser);
|
||||
}
|
||||
Eventer.Instance.PostEvent(EEvent.OnUserListAllUpdate);
|
||||
}
|
||||
public void RecvCmdUserJoin(byte[] reqData)
|
||||
{
|
||||
Protobuf_UserJoin_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_UserJoin_RESP>(reqData);
|
||||
bool isNewUser;
|
||||
UpdateOrAddUser(msg.UserInfo, out isNewUser);
|
||||
bool isNewUser;
|
||||
UpdateOrAddUser(msg.UserInfo, out isNewUser);
|
||||
if (isNewUser)
|
||||
{
|
||||
{
|
||||
Eventer.Instance.PostEvent(EEvent.OnUserLogin, msg.UserInfo.UID, msg.UserInfo.NickName);
|
||||
OverlayManager.PopTip($"玩家[{msg.UserInfo.NickName}]上线了");
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
/// <summary>
|
||||
/// StringºÍBoolµÄ·ìºÏ¹Ö
|
||||
/// <summary>
|
||||
/// String和Bool的缝合怪
|
||||
/// </summary>
|
||||
public struct MsgBool
|
||||
{
|
||||
public string ErrorMsg;
|
||||
public bool Value;
|
||||
|
||||
//low C# readonly
|
||||
//public override readonly string ToString()
|
||||
|
||||
public override string ToString()
|
||||
public bool Value;
|
||||
|
||||
//low C# readonly
|
||||
//public override readonly string ToString()
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Value)
|
||||
{
|
||||
@ -34,15 +34,15 @@ public struct MsgBool
|
||||
public static implicit operator bool(MsgBool msgBool)
|
||||
{
|
||||
return msgBool.Value;
|
||||
}
|
||||
|
||||
//low C#
|
||||
//public static implicit operator (bool, string)(MsgBool msgBool)
|
||||
//{
|
||||
// return (msgBool.Value, msgBool.ErrorMsg);
|
||||
//}
|
||||
|
||||
public static implicit operator string(MsgBool msgBool)
|
||||
}
|
||||
|
||||
//low C#
|
||||
//public static implicit operator (bool, string)(MsgBool msgBool)
|
||||
//{
|
||||
// return (msgBool.Value, msgBool.ErrorMsg);
|
||||
//}
|
||||
|
||||
public static implicit operator string(MsgBool msgBool)
|
||||
{
|
||||
return msgBool.ToString();
|
||||
}
|
||||
|
@ -106,10 +106,10 @@ namespace AxibugEmuOnline.Client
|
||||
uint LastTestInput = 0;
|
||||
public void SampleInput(uint frameIndex)
|
||||
{
|
||||
if (InGameUI.Instance.IsNetPlay)
|
||||
{
|
||||
int targetFrame; ReplayStep replayData; int frameDiff; bool inputDiff;
|
||||
if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out replayData, out frameDiff, out inputDiff))
|
||||
if (InGameUI.Instance.IsNetPlay)
|
||||
{
|
||||
int targetFrame; ReplayStep replayData; int frameDiff; bool inputDiff;
|
||||
if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out replayData, out frameDiff, out inputDiff))
|
||||
{
|
||||
if (inputDiff)
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Common;
|
||||
using AxibugEmuOnline.Client.Common;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -91,7 +90,7 @@ namespace AxibugEmuOnline.Client
|
||||
Controller targetController;
|
||||
switch (conIndex)
|
||||
{
|
||||
case 0: targetController = Controller0;break;
|
||||
case 0: targetController = Controller0; break;
|
||||
case 1: targetController = Controller1; break;
|
||||
case 2: targetController = Controller2; break;
|
||||
case 3: targetController = Controller3; break;
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugProtobuf;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VirtualNes.Core;
|
||||
|
@ -1,6 +1,4 @@
|
||||
using VirtualNes.Core;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public static class PaletteDefine
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ namespace AxibugEmuOnline.Client.Network
|
||||
{
|
||||
lock (lockQueueObj)
|
||||
{
|
||||
queueNetMsg.Enqueue(new ValueTuple<int,int,byte[]>(cmd, ERRCODE, arg));
|
||||
queueNetMsg.Enqueue(new ValueTuple<int, int, byte[]>(cmd, ERRCODE, arg));
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,9 +75,9 @@ namespace AxibugEmuOnline.Client.Network
|
||||
lock (lockQueueObj)
|
||||
{
|
||||
while (queueNetMsg.Count > 0)
|
||||
{
|
||||
|
||||
var msgData = queueNetMsg.Dequeue();
|
||||
{
|
||||
|
||||
var msgData = queueNetMsg.Dequeue();
|
||||
PostNetMsgEvent(msgData.Item1, msgData.Item2, msgData.Item3);
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ namespace AxibugEmuOnline.Client.Network
|
||||
ErrorCode err = ((ErrorCode)ERRCODE);
|
||||
if (err != ErrorCode.ErrorOk)
|
||||
{
|
||||
OverlayManager.PopTip("错误:"+err.ToString());
|
||||
OverlayManager.PopTip("错误:" + err.ToString());
|
||||
}
|
||||
|
||||
List<Delegate> eventList = GetNetEventDicList(cmd);
|
||||
|
@ -1,5 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
@ -1,5 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -8,191 +8,191 @@ using static AxibugEmuOnline.Client.FilterManager;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// 滤镜预览UI
|
||||
/// </summary>
|
||||
public class UI_FilterItem : MenuItem, IVirtualItem
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public Filter Datacontext { get; private set; }
|
||||
/// <summary>
|
||||
/// 滤镜预览UI
|
||||
/// </summary>
|
||||
public class UI_FilterItem : MenuItem, IVirtualItem
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public Filter Datacontext { get; private set; }
|
||||
|
||||
public void SetData(object data)
|
||||
{
|
||||
Datacontext = data as Filter;
|
||||
public void SetData(object data)
|
||||
{
|
||||
Datacontext = data as Filter;
|
||||
|
||||
UpdateView();
|
||||
}
|
||||
UpdateView();
|
||||
}
|
||||
|
||||
private void UpdateView()
|
||||
{
|
||||
if (Datacontext == null)
|
||||
SetBaseInfo("无", null, null);
|
||||
else
|
||||
SetBaseInfo(Datacontext.Name, $"参数数量:{Datacontext.Paramerters.Count}", null);
|
||||
}
|
||||
private void UpdateView()
|
||||
{
|
||||
if (Datacontext == null)
|
||||
SetBaseInfo("无", null, null);
|
||||
else
|
||||
SetBaseInfo(Datacontext.Name, $"参数数量:{Datacontext.Paramerters.Count}", null);
|
||||
}
|
||||
|
||||
public void SetDependencyProperty(object data)
|
||||
{
|
||||
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
|
||||
public void SetDependencyProperty(object data)
|
||||
{
|
||||
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
|
||||
|
||||
if (m_select)
|
||||
{
|
||||
App.settings.Filter.EnableFilterPreview();
|
||||
if (App.settings.Filter != null)
|
||||
App.settings.Filter.EnableFilter(Datacontext);
|
||||
else
|
||||
App.settings.Filter.ShutDownFilter();
|
||||
}
|
||||
}
|
||||
if (m_select)
|
||||
{
|
||||
App.settings.Filter.EnableFilterPreview();
|
||||
if (App.settings.Filter != null)
|
||||
App.settings.Filter.EnableFilter(Datacontext);
|
||||
else
|
||||
App.settings.Filter.ShutDownFilter();
|
||||
}
|
||||
}
|
||||
|
||||
public void Release() { }
|
||||
public void Release() { }
|
||||
|
||||
public override bool OnEnterItem()
|
||||
{
|
||||
if (Datacontext != null && Datacontext.Paramerters.Count > 0)
|
||||
{
|
||||
var opts = new List<OptionMenu>();
|
||||
opts.Add(new Opt_CreatePreset(Datacontext));
|
||||
opts.AddRange(Datacontext.Presets.Select(p => new Opt_Presets(Datacontext, p)));
|
||||
public override bool OnEnterItem()
|
||||
{
|
||||
if (Datacontext != null && Datacontext.Paramerters.Count > 0)
|
||||
{
|
||||
var opts = new List<OptionMenu>();
|
||||
opts.Add(new Opt_CreatePreset(Datacontext));
|
||||
opts.AddRange(Datacontext.Presets.Select(p => new Opt_Presets(Datacontext, p)));
|
||||
|
||||
OverlayManager.PopSideBar(opts, onClose: () =>
|
||||
{
|
||||
App.settings.Filter.EnableFilterPreview();
|
||||
Datacontext.ResetPreset();
|
||||
App.settings.Filter.EnableFilter(Datacontext);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
OverlayManager.PopSideBar(opts, onClose: () =>
|
||||
{
|
||||
App.settings.Filter.EnableFilterPreview();
|
||||
Datacontext.ResetPreset();
|
||||
App.settings.Filter.EnableFilter(Datacontext);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public class Opt_CreatePreset : ExecuteMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
public class Opt_CreatePreset : ExecuteMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
|
||||
public Opt_CreatePreset(Filter filter) : base("创建滤镜预设", Resources.LoadAll<Sprite>("Icons/XMB-Icons/misc")[0])
|
||||
{
|
||||
m_filter = filter;
|
||||
}
|
||||
public Opt_CreatePreset(Filter filter) : base("创建滤镜预设", Resources.LoadAll<Sprite>("Icons/XMB-Icons/misc")[0])
|
||||
{
|
||||
m_filter = filter;
|
||||
}
|
||||
|
||||
public override void OnFocus()
|
||||
{
|
||||
m_filter.ResetPreset();
|
||||
App.settings.Filter.EnableFilter(m_filter);
|
||||
}
|
||||
public override void OnFocus()
|
||||
{
|
||||
m_filter.ResetPreset();
|
||||
App.settings.Filter.EnableFilter(m_filter);
|
||||
}
|
||||
|
||||
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
|
||||
{
|
||||
cancelHide = true;
|
||||
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
|
||||
{
|
||||
cancelHide = true;
|
||||
|
||||
OverlayManager.Input((presetName) =>
|
||||
{
|
||||
FilterPreset newPreset;
|
||||
var result = m_filter.CreatePreset(presetName, out newPreset);
|
||||
if (!result) OverlayManager.PopTip(result);
|
||||
else optionUI.AddOptionMenuWhenPoping(new Opt_Presets(m_filter, newPreset));
|
||||
}, "为预设设置一个名称", string.Empty);
|
||||
}
|
||||
}
|
||||
public class Opt_Presets : ExpandMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
private FilterPreset m_preset;
|
||||
private OptionUI_MenuItem m_ui;
|
||||
private List<OptionMenu> m_menu;
|
||||
OverlayManager.Input((presetName) =>
|
||||
{
|
||||
FilterPreset newPreset;
|
||||
var result = m_filter.CreatePreset(presetName, out newPreset);
|
||||
if (!result) OverlayManager.PopTip(result);
|
||||
else optionUI.AddOptionMenuWhenPoping(new Opt_Presets(m_filter, newPreset));
|
||||
}, "为预设设置一个名称", string.Empty);
|
||||
}
|
||||
}
|
||||
public class Opt_Presets : ExpandMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
private FilterPreset m_preset;
|
||||
private OptionUI_MenuItem m_ui;
|
||||
private List<OptionMenu> m_menu;
|
||||
|
||||
public Opt_Presets(Filter filter, FilterPreset preset) : base(preset.Name, null)
|
||||
{
|
||||
m_filter = filter;
|
||||
m_preset = preset;
|
||||
public Opt_Presets(Filter filter, FilterPreset preset) : base(preset.Name, null)
|
||||
{
|
||||
m_filter = filter;
|
||||
m_preset = preset;
|
||||
|
||||
m_menu = new List<OptionMenu>();
|
||||
m_menu.Add(new Opt_Delete(m_filter, m_preset));
|
||||
foreach (var p in m_filter.Paramerters)
|
||||
{
|
||||
m_menu.Add(new Opt_ParamEditor(m_filter, p, m_preset));
|
||||
}
|
||||
}
|
||||
m_menu = new List<OptionMenu>();
|
||||
m_menu.Add(new Opt_Delete(m_filter, m_preset));
|
||||
foreach (var p in m_filter.Paramerters)
|
||||
{
|
||||
m_menu.Add(new Opt_ParamEditor(m_filter, p, m_preset));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnShow(OptionUI_MenuItem ui)
|
||||
{
|
||||
EventInvoker.OnFilterPresetRemoved += EventInvoker_OnFilterPresetRemoved;
|
||||
m_ui = ui;
|
||||
base.OnShow(ui);
|
||||
}
|
||||
public override void OnShow(OptionUI_MenuItem ui)
|
||||
{
|
||||
EventInvoker.OnFilterPresetRemoved += EventInvoker_OnFilterPresetRemoved;
|
||||
m_ui = ui;
|
||||
base.OnShow(ui);
|
||||
}
|
||||
|
||||
public override void OnHide()
|
||||
{
|
||||
EventInvoker.OnFilterPresetRemoved -= EventInvoker_OnFilterPresetRemoved;
|
||||
}
|
||||
public override void OnHide()
|
||||
{
|
||||
EventInvoker.OnFilterPresetRemoved -= EventInvoker_OnFilterPresetRemoved;
|
||||
}
|
||||
|
||||
private void EventInvoker_OnFilterPresetRemoved(Filter filter, FilterPreset removedPreset)
|
||||
{
|
||||
if (filter != m_filter || m_preset != removedPreset) return;
|
||||
m_ui.OptionUI.RemoveItem(m_ui);
|
||||
}
|
||||
private void EventInvoker_OnFilterPresetRemoved(Filter filter, FilterPreset removedPreset)
|
||||
{
|
||||
if (filter != m_filter || m_preset != removedPreset) return;
|
||||
m_ui.OptionUI.RemoveItem(m_ui);
|
||||
}
|
||||
|
||||
public override void OnFocus()
|
||||
{
|
||||
m_filter.ApplyPreset(m_preset);
|
||||
App.settings.Filter.EnableFilter(m_filter);
|
||||
}
|
||||
public override void OnFocus()
|
||||
{
|
||||
m_filter.ApplyPreset(m_preset);
|
||||
App.settings.Filter.EnableFilter(m_filter);
|
||||
}
|
||||
|
||||
protected override List<OptionMenu> GetOptionMenus()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
protected override List<OptionMenu> GetOptionMenus()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
public class Opt_ParamEditor : ValueSetMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
private FilterEffect.EditableParamerter m_param;
|
||||
private FilterPreset m_preset;
|
||||
public class Opt_ParamEditor : ValueSetMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
private FilterEffect.EditableParamerter m_param;
|
||||
private FilterPreset m_preset;
|
||||
|
||||
public override bool Visible => m_param.ValueType.IsEnum || m_param.ValueType == typeof(float);
|
||||
public override bool Visible => m_param.ValueType.IsEnum || m_param.ValueType == typeof(float);
|
||||
|
||||
public Opt_ParamEditor(Filter filter, FilterEffect.EditableParamerter editParam, FilterPreset preset)
|
||||
: base(editParam.Name)
|
||||
{
|
||||
m_filter = filter;
|
||||
m_param = editParam;
|
||||
m_preset = preset;
|
||||
}
|
||||
public Opt_ParamEditor(Filter filter, FilterEffect.EditableParamerter editParam, FilterPreset preset)
|
||||
: base(editParam.Name)
|
||||
{
|
||||
m_filter = filter;
|
||||
m_param = editParam;
|
||||
m_preset = preset;
|
||||
}
|
||||
|
||||
public override Type ValueType => m_param.ValueType;
|
||||
public override Type ValueType => m_param.ValueType;
|
||||
|
||||
public override object ValueRaw => m_preset.GetParamValue(m_param.Name, ValueType) ?? m_param.Value;
|
||||
public override object ValueRaw => m_preset.GetParamValue(m_param.Name, ValueType) ?? m_param.Value;
|
||||
|
||||
public override void OnValueChanged(object newValue)
|
||||
{
|
||||
m_preset.SetParamValue(m_param.Name, ValueType, newValue);
|
||||
m_filter.SavePresets();
|
||||
m_param.Apply(newValue);
|
||||
}
|
||||
public override void OnValueChanged(object newValue)
|
||||
{
|
||||
m_preset.SetParamValue(m_param.Name, ValueType, newValue);
|
||||
m_filter.SavePresets();
|
||||
m_param.Apply(newValue);
|
||||
}
|
||||
|
||||
public override object Min => m_param.MinValue;
|
||||
public override object Min => m_param.MinValue;
|
||||
|
||||
public override object Max => m_param.MaxValue;
|
||||
}
|
||||
public override object Max => m_param.MaxValue;
|
||||
}
|
||||
|
||||
public class Opt_Delete : ExecuteMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
private FilterPreset m_preset;
|
||||
public class Opt_Delete : ExecuteMenu
|
||||
{
|
||||
private Filter m_filter;
|
||||
private FilterPreset m_preset;
|
||||
|
||||
public Opt_Delete(Filter filter, FilterPreset preset) : base("删除预设", null)
|
||||
{
|
||||
m_filter = filter;
|
||||
m_preset = preset;
|
||||
}
|
||||
public Opt_Delete(Filter filter, FilterPreset preset) : base("删除预设", null)
|
||||
{
|
||||
m_filter = filter;
|
||||
m_preset = preset;
|
||||
}
|
||||
|
||||
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
|
||||
{
|
||||
m_filter.RemovePreset(m_preset);
|
||||
}
|
||||
}
|
||||
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
|
||||
{
|
||||
m_filter.RemovePreset(m_preset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using static AxibugEmuOnline.Client.ScreenScaler;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class GameObjectPool
|
||||
@ -40,8 +40,8 @@ public static class GameObjectPool
|
||||
public static void Release(GameObject instance)
|
||||
{
|
||||
GameObject src;
|
||||
Queue<GameObject> pool;
|
||||
s_instanceToSrc.TryGetValue(instance, out src);
|
||||
Queue<GameObject> pool;
|
||||
s_instanceToSrc.TryGetValue(instance, out src);
|
||||
if (src != null && s_poolMap.TryGetValue(src, out pool))
|
||||
{
|
||||
pool.Enqueue(instance);
|
||||
|
@ -482,8 +482,8 @@ public class ItemPresent : GridLayoutGroup, IVirtualLayout
|
||||
}
|
||||
else if (dataList is IEnumerable)
|
||||
{
|
||||
var ienumrable = (IEnumerable)dataList;
|
||||
List<object> temp = new List<object>();
|
||||
var ienumrable = (IEnumerable)dataList;
|
||||
List<object> temp = new List<object>();
|
||||
foreach (var item in ienumrable)
|
||||
{
|
||||
temp.Add(item);
|
||||
|
@ -6,246 +6,246 @@ using UnityEngine.UI;
|
||||
|
||||
|
||||
public interface IVirtualLayout
|
||||
{
|
||||
Dictionary<GameObject, ScripteInterface> CacheItemScripts { get; }
|
||||
List<object> DataList { get; }
|
||||
object DependencyProperty { get; }
|
||||
RectTransform RectTransform { get; }
|
||||
RectTransform GetTemplate(object data);
|
||||
Vector2 GetItemAnchorePos(int index);
|
||||
RectTransform GetItemUIIfExist(int index);
|
||||
|
||||
void UpdateProxyVisualState();
|
||||
void UpdateDependencyProperty(object dp);
|
||||
void SetData(IEnumerable dataList);
|
||||
void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex);
|
||||
{
|
||||
Dictionary<GameObject, ScripteInterface> CacheItemScripts { get; }
|
||||
List<object> DataList { get; }
|
||||
object DependencyProperty { get; }
|
||||
RectTransform RectTransform { get; }
|
||||
RectTransform GetTemplate(object data);
|
||||
Vector2 GetItemAnchorePos(int index);
|
||||
RectTransform GetItemUIIfExist(int index);
|
||||
|
||||
void UpdateProxyVisualState();
|
||||
void UpdateDependencyProperty(object dp);
|
||||
void SetData(IEnumerable dataList);
|
||||
void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex);
|
||||
}
|
||||
|
||||
public class ItemProxy
|
||||
{
|
||||
public bool IsDestroyed;
|
||||
public bool Visible = true;
|
||||
public int Index;
|
||||
public bool IsInViewRect;
|
||||
|
||||
public Vector2 Pivot => _template.pivot;
|
||||
public Vector2 AnchoredPosition;
|
||||
|
||||
public float Width;
|
||||
public float Height;
|
||||
|
||||
private IVirtualLayout _parent;
|
||||
|
||||
private RectTransform _template => _parent.GetTemplate(_parent.DataList[Index]);
|
||||
private RectTransform _runtimeInstance;
|
||||
private LayoutGroup _layoutElement;
|
||||
|
||||
public RectTransform RuntimeItemUI => _runtimeInstance;
|
||||
public bool firstShow { get; private set; } = true;
|
||||
|
||||
public float PreferredWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_layoutElement == null) return 0;
|
||||
|
||||
return _layoutElement.preferredWidth;
|
||||
}
|
||||
}
|
||||
public float PreferredHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_layoutElement == null) return 0;
|
||||
|
||||
return _layoutElement.preferredHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public ScripteInterface GetLuaObj()
|
||||
{
|
||||
if (_runtimeInstance == null) return null;
|
||||
|
||||
ScripteInterface lfi;
|
||||
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out lfi);
|
||||
|
||||
return lfi;
|
||||
}
|
||||
|
||||
public ItemProxy(IVirtualLayout parent)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_runtimeInstance != null)
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GameObjectPool.Release(_runtimeInstance.gameObject);
|
||||
}
|
||||
else
|
||||
GameObject.DestroyImmediate(_runtimeInstance.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public bool NeedShow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsInViewRect && _runtimeInstance == null) return true;
|
||||
else
|
||||
{
|
||||
if (_runtimeInstance != null && IsInViewRect && _runtimeInstance.anchoredPosition != AnchoredPosition)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public bool NeedHide => !IsInViewRect && _runtimeInstance != null;
|
||||
|
||||
public void UpdateView(bool force = false)
|
||||
{
|
||||
if (IsInViewRect)
|
||||
{
|
||||
if (_runtimeInstance == null)
|
||||
{
|
||||
_runtimeInstance = GetInstance();
|
||||
_layoutElement = _runtimeInstance.GetComponent<LayoutGroup>();
|
||||
UpdateViewData();
|
||||
}
|
||||
else if (force)
|
||||
{
|
||||
UpdateViewData();
|
||||
}
|
||||
|
||||
UpdateLayout();
|
||||
}
|
||||
else
|
||||
{
|
||||
ReleaseInstance();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLayout()
|
||||
{
|
||||
if (_runtimeInstance != null)
|
||||
{
|
||||
_runtimeInstance.gameObject.SetActive(true);
|
||||
_runtimeInstance.anchorMax = Vector2.up;
|
||||
_runtimeInstance.anchorMin = Vector2.up;
|
||||
_runtimeInstance.anchoredPosition = AnchoredPosition;
|
||||
_runtimeInstance.sizeDelta = new Vector2(Width, Height);
|
||||
}
|
||||
if (_layoutElement != null)
|
||||
{
|
||||
_layoutElement.CalculateLayoutInputHorizontal();
|
||||
_layoutElement.CalculateLayoutInputVertical();
|
||||
_layoutElement.SetLayoutHorizontal();
|
||||
_layoutElement.SetLayoutVertical();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void UpdateViewData()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (!_parent.CacheItemScripts.ContainsKey(_runtimeInstance.gameObject))
|
||||
{
|
||||
var vItem = _runtimeInstance.gameObject.GetComponent<IVirtualItem>();
|
||||
ScripteInterface newSI = new ScripteInterface(vItem);
|
||||
_parent.CacheItemScripts[_runtimeInstance.gameObject] = newSI;
|
||||
}
|
||||
|
||||
ScripteInterface si;
|
||||
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
|
||||
si.SetDataList(_parent.DataList[Index], Index);
|
||||
if (_parent.DependencyProperty != null)
|
||||
si.SetDependencyProperty(_parent.DependencyProperty);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateDP()
|
||||
{
|
||||
if (_runtimeInstance == null) return;
|
||||
ScripteInterface luaInterface;
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out luaInterface);
|
||||
if (luaInterface == null) return;
|
||||
|
||||
if (_parent.DependencyProperty != null)
|
||||
luaInterface.SetDependencyProperty(_parent.DependencyProperty);
|
||||
}
|
||||
|
||||
private RectTransform GetInstance()
|
||||
{
|
||||
var res = GameObjectPool.GetInstance(_template.gameObject, _parent.RectTransform).GetComponent<RectTransform>();
|
||||
return res;
|
||||
}
|
||||
|
||||
private void ReleaseInstance()
|
||||
{
|
||||
if (_runtimeInstance == null) return;
|
||||
|
||||
_layoutElement = null;
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
ScripteInterface si;
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
|
||||
if (si != null) si.Release();
|
||||
GameObjectPool.Release(_runtimeInstance.gameObject);
|
||||
_runtimeInstance = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject.DestroyImmediate(_runtimeInstance.gameObject);
|
||||
_runtimeInstance = null;
|
||||
}
|
||||
}
|
||||
{
|
||||
public bool IsDestroyed;
|
||||
public bool Visible = true;
|
||||
public int Index;
|
||||
public bool IsInViewRect;
|
||||
|
||||
public Vector2 Pivot => _template.pivot;
|
||||
public Vector2 AnchoredPosition;
|
||||
|
||||
public float Width;
|
||||
public float Height;
|
||||
|
||||
private IVirtualLayout _parent;
|
||||
|
||||
private RectTransform _template => _parent.GetTemplate(_parent.DataList[Index]);
|
||||
private RectTransform _runtimeInstance;
|
||||
private LayoutGroup _layoutElement;
|
||||
|
||||
public RectTransform RuntimeItemUI => _runtimeInstance;
|
||||
public bool firstShow { get; private set; } = true;
|
||||
|
||||
public float PreferredWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_layoutElement == null) return 0;
|
||||
|
||||
return _layoutElement.preferredWidth;
|
||||
}
|
||||
}
|
||||
public float PreferredHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_layoutElement == null) return 0;
|
||||
|
||||
return _layoutElement.preferredHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public ScripteInterface GetLuaObj()
|
||||
{
|
||||
if (_runtimeInstance == null) return null;
|
||||
|
||||
ScripteInterface lfi;
|
||||
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out lfi);
|
||||
|
||||
return lfi;
|
||||
}
|
||||
|
||||
public ItemProxy(IVirtualLayout parent)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_runtimeInstance != null)
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GameObjectPool.Release(_runtimeInstance.gameObject);
|
||||
}
|
||||
else
|
||||
GameObject.DestroyImmediate(_runtimeInstance.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public bool NeedShow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsInViewRect && _runtimeInstance == null) return true;
|
||||
else
|
||||
{
|
||||
if (_runtimeInstance != null && IsInViewRect && _runtimeInstance.anchoredPosition != AnchoredPosition)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public bool NeedHide => !IsInViewRect && _runtimeInstance != null;
|
||||
|
||||
public void UpdateView(bool force = false)
|
||||
{
|
||||
if (IsInViewRect)
|
||||
{
|
||||
if (_runtimeInstance == null)
|
||||
{
|
||||
_runtimeInstance = GetInstance();
|
||||
_layoutElement = _runtimeInstance.GetComponent<LayoutGroup>();
|
||||
UpdateViewData();
|
||||
}
|
||||
else if (force)
|
||||
{
|
||||
UpdateViewData();
|
||||
}
|
||||
|
||||
UpdateLayout();
|
||||
}
|
||||
else
|
||||
{
|
||||
ReleaseInstance();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLayout()
|
||||
{
|
||||
if (_runtimeInstance != null)
|
||||
{
|
||||
_runtimeInstance.gameObject.SetActive(true);
|
||||
_runtimeInstance.anchorMax = Vector2.up;
|
||||
_runtimeInstance.anchorMin = Vector2.up;
|
||||
_runtimeInstance.anchoredPosition = AnchoredPosition;
|
||||
_runtimeInstance.sizeDelta = new Vector2(Width, Height);
|
||||
}
|
||||
if (_layoutElement != null)
|
||||
{
|
||||
_layoutElement.CalculateLayoutInputHorizontal();
|
||||
_layoutElement.CalculateLayoutInputVertical();
|
||||
_layoutElement.SetLayoutHorizontal();
|
||||
_layoutElement.SetLayoutVertical();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void UpdateViewData()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (!_parent.CacheItemScripts.ContainsKey(_runtimeInstance.gameObject))
|
||||
{
|
||||
var vItem = _runtimeInstance.gameObject.GetComponent<IVirtualItem>();
|
||||
ScripteInterface newSI = new ScripteInterface(vItem);
|
||||
_parent.CacheItemScripts[_runtimeInstance.gameObject] = newSI;
|
||||
}
|
||||
|
||||
ScripteInterface si;
|
||||
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
|
||||
si.SetDataList(_parent.DataList[Index], Index);
|
||||
if (_parent.DependencyProperty != null)
|
||||
si.SetDependencyProperty(_parent.DependencyProperty);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateDP()
|
||||
{
|
||||
if (_runtimeInstance == null) return;
|
||||
ScripteInterface luaInterface;
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out luaInterface);
|
||||
if (luaInterface == null) return;
|
||||
|
||||
if (_parent.DependencyProperty != null)
|
||||
luaInterface.SetDependencyProperty(_parent.DependencyProperty);
|
||||
}
|
||||
|
||||
private RectTransform GetInstance()
|
||||
{
|
||||
var res = GameObjectPool.GetInstance(_template.gameObject, _parent.RectTransform).GetComponent<RectTransform>();
|
||||
return res;
|
||||
}
|
||||
|
||||
private void ReleaseInstance()
|
||||
{
|
||||
if (_runtimeInstance == null) return;
|
||||
|
||||
_layoutElement = null;
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
ScripteInterface si;
|
||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
|
||||
if (si != null) si.Release();
|
||||
GameObjectPool.Release(_runtimeInstance.gameObject);
|
||||
_runtimeInstance = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject.DestroyImmediate(_runtimeInstance.gameObject);
|
||||
_runtimeInstance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ScripteInterface
|
||||
{
|
||||
private IVirtualItem _itemInstance;
|
||||
public IVirtualItem ItemInstance => _itemInstance;
|
||||
|
||||
public ScripteInterface(IVirtualItem lc)
|
||||
{
|
||||
_itemInstance = lc;
|
||||
}
|
||||
|
||||
public void SetDataList(object dataItem, int index)
|
||||
{
|
||||
if (_itemInstance == null) return;
|
||||
_itemInstance.Index = index;
|
||||
_itemInstance.SetData(dataItem);
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
if (_itemInstance == null) return;
|
||||
_itemInstance.Release();
|
||||
}
|
||||
|
||||
public void SetDependencyProperty(object dependencyProperty)
|
||||
{
|
||||
if (_itemInstance == null) return;
|
||||
|
||||
_itemInstance.SetDependencyProperty(dependencyProperty);
|
||||
}
|
||||
{
|
||||
private IVirtualItem _itemInstance;
|
||||
public IVirtualItem ItemInstance => _itemInstance;
|
||||
|
||||
public ScripteInterface(IVirtualItem lc)
|
||||
{
|
||||
_itemInstance = lc;
|
||||
}
|
||||
|
||||
public void SetDataList(object dataItem, int index)
|
||||
{
|
||||
if (_itemInstance == null) return;
|
||||
_itemInstance.Index = index;
|
||||
_itemInstance.SetData(dataItem);
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
if (_itemInstance == null) return;
|
||||
_itemInstance.Release();
|
||||
}
|
||||
|
||||
public void SetDependencyProperty(object dependencyProperty)
|
||||
{
|
||||
if (_itemInstance == null) return;
|
||||
|
||||
_itemInstance.SetDependencyProperty(dependencyProperty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface IVirtualItem
|
||||
{
|
||||
GameObject gameObject { get; }
|
||||
int Index { get; set; }
|
||||
void SetData(object data);
|
||||
void SetDependencyProperty(object data);
|
||||
void Release();
|
||||
{
|
||||
GameObject gameObject { get; }
|
||||
int Index { get; set; }
|
||||
void SetData(object data);
|
||||
void SetDependencyProperty(object data);
|
||||
void Release();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
@ -19,8 +19,8 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
if (menuData is ValueSetMenu)
|
||||
{
|
||||
var valueMenu = (ValueSetMenu)menuData;
|
||||
if (valueMenu.ValueType == typeof(float))
|
||||
var valueMenu = (ValueSetMenu)menuData;
|
||||
if (valueMenu.ValueType == typeof(float))
|
||||
{
|
||||
m_currentCom = com_floatEdit;
|
||||
}
|
||||
@ -30,7 +30,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
else
|
||||
{
|
||||
App.log.Warning($"尚未支持的数据类型:{valueMenu.ValueType}");
|
||||
App.log.Warning($"尚未支持的数据类型:{valueMenu.ValueType}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
@ -1,5 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using DG.Tweening;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -22,7 +22,7 @@ namespace AxibugEmuOnline.Client
|
||||
m_msgText.text = msg;
|
||||
Canvas.ForceUpdateCanvases();
|
||||
|
||||
var targetPos = new Vector2(-RectTransform.rect.width - 20 , RectTransform.anchoredPosition.y);
|
||||
var targetPos = new Vector2(-RectTransform.rect.width - 20, RectTransform.anchoredPosition.y);
|
||||
DOTween.To(
|
||||
() => RectTransform.anchoredPosition,
|
||||
(value) => RectTransform.anchoredPosition = value,
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
@ -1,6 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using System;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using AxibugEmuOnline.Client.UI;
|
||||
using AxibugEmuOnline.Client.UI;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
@ -182,12 +182,12 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
|
||||
private MenuItem Clone(MenuItem template, Transform parent)
|
||||
{
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
//========================套娃宏========================
|
||||
#if UNITY_2019_1_OR_NEWER //新版Unity,因UNITY2018.2用不了这玩意儿,编辑器也罢
|
||||
|
||||
|
||||
//========================套娃宏========================
|
||||
#if UNITY_2019_1_OR_NEWER //新版Unity,因UNITY2018.2用不了这玩意儿,编辑器也罢
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
var item = GameObject.Instantiate(template.gameObject, parent).GetComponent<MenuItem>();
|
||||
@ -199,19 +199,19 @@ namespace AxibugEmuOnline.Client
|
||||
var clone = UnityEditor.PrefabUtility.InstantiatePrefab(template.gameObject, parent) as GameObject;
|
||||
clone.transform.localPosition = Vector3.zero;
|
||||
return clone.GetComponent<MenuItem>();
|
||||
}
|
||||
}
|
||||
#else
|
||||
var item = GameObject.Instantiate(template.gameObject, parent).GetComponent<MenuItem>();
|
||||
item.transform.localPosition = Vector3.zero;
|
||||
return item;
|
||||
#endif
|
||||
//========================套娃宏 End========================
|
||||
|
||||
|
||||
|
||||
//========================套娃宏 End========================
|
||||
|
||||
|
||||
|
||||
#else
|
||||
return GameObject.Instantiate(SubMenuItemTemplate.gameObject, parent).GetComponent<MenuItem>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -9,8 +9,8 @@ namespace AxibugEmuOnline.Client
|
||||
private static Dictionary<Graphic, Material> _caches = new Dictionary<Graphic, Material>();
|
||||
public static Material GetMaterial(this Graphic graphic)
|
||||
{
|
||||
Material material;
|
||||
if (_caches.TryGetValue(graphic, out material))
|
||||
Material material;
|
||||
if (_caches.TryGetValue(graphic, out material))
|
||||
{
|
||||
return material;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
@ -13,7 +12,6 @@ namespace AxibugEmuOnline.Client
|
||||
[SerializeField]
|
||||
protected CanvasGroup RomGroupRoot;
|
||||
|
||||
|
||||
private TweenerCore<float, float, FloatOptions> m_showTween;
|
||||
|
||||
protected override void Awake()
|
||||
|
@ -2,10 +2,8 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using VirtualNes.Core;
|
||||
|
||||
public class ControllerInfo : MonoBehaviour
|
||||
{
|
||||
|
@ -3,10 +3,8 @@ using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VirtualNes.Core;
|
||||
|
||||
public class ControllerInfoPanel : MonoBehaviour
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user