diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs index 239549f..f7abd1f 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs @@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client.ClientCore private static CoroutineRunner coRunner; #endregion -#if UNITY_PSP2 +#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机 public static string PersistentDataPath => "ux0:data/AxibugEmu"; #else public static string PersistentDataPath => Application.persistentDataPath; @@ -45,7 +45,13 @@ namespace AxibugEmuOnline.Client.ClientCore { PlayerPrefs.DeleteAll(); - settings = new AppSettings(); + if (UnityEngine.Application.platform == RuntimePlatform.PSP2) + { + //PSV 等平台需要手动创建目录 + PSP2Init(); + } + + settings = new AppSettings(); log = new LogManager(); LogManager.OnLog += OnNoSugarNetLog; @@ -68,11 +74,6 @@ namespace AxibugEmuOnline.Client.ClientCore tickLoop = go.AddComponent(); coRunner = go.AddComponent(); - if (UnityEngine.Application.platform == RuntimePlatform.PSP2) - { - //PSV 等平台需要手动创建目录 - PersistentDataPathDir(); - } var importNode = GameObject.Find("IMPORTENT"); if (importNode != null) GameObject.DontDestroyOnLoad(importNode); @@ -81,12 +82,17 @@ namespace AxibugEmuOnline.Client.ClientCore RePullNetInfo(); } - private static void PersistentDataPathDir() + + private static void PSP2Init() { + //PSVita最好手动创建目录 if (!Directory.Exists(PersistentDataPath)) - { Directory.CreateDirectory(PersistentDataPath); - } + +#if UNITY_PSP2 + //释放解码 FMV的26M内存,一般游戏用不上(PSP才用那破玩意儿) + UnityEngine.PSVita.PSVitaVideoPlayer.TransferMemToMonoHeap(); +#endif } private static IEnumerator AppTickFlow() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef index 3710c91..565fecf 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef @@ -1,19 +1,12 @@ { "name": "AxibugEmuOnline.Client", - "rootNamespace": "AxibugEmuOnline.Client", "references": [ - "VirtualNes.Core", "UIEffect", "AxiReplay", "Unity.Postprocessing.Runtime" ], + "optionalUnityReferences": [], "includePlatforms": [], "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false + "allowUnsafeCode": true } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.shader b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.shader index 2a3a68d..c83e589 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.shader +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.shader @@ -248,7 +248,19 @@ Shader "PostEffect/FixingPixcelArtGrille" if(pos.x<0.333)mask.r=_maskLight; else if(pos.x<0.666)mask.g=_maskLight; else mask.b=_maskLight; - return mask;} + return mask;} + #else + // VGA style shadow mask. + float3 Mask(float2 pos){ + pos.xy=floor(pos.xy*float2(1.0,0.5)); + pos.x+=pos.y*3.0; + float3 mask=float3(_maskDark,_maskDark,_maskDark); + pos.x=fract(pos.x/6.0); + if(pos.x<0.333)mask.r=_maskLight; + else if(pos.x<0.666)mask.g=_maskLight; + else mask.b=_maskLight; + return mask;} + #endif diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs index a2decba..8000a1f 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs @@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client.Manager /// private IEmuCore m_emuCore; - private IControllerSetuper m_controllerSetuper; + private VirtualNes.Core.IControllerSetuper m_controllerSetuper; /// /// unity的c#实现有bug,以接口类型保存的monobehaviour引用,!=和==运算符没有调用到monobehaviour重写过的运算符 @@ -84,10 +84,15 @@ namespace AxibugEmuOnline.Client.Manager else //在房间中则使用服务器下发的手柄槽位信息分配本地手柄 { long selfUID = App.user.userdata.UID; - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out var con0Slot); - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out var con1Slot); - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out var con2Slot); - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out var con3Slot); + uint? con0Slot; + uint? con1Slot; + uint? con2Slot; + uint? con3Slot; + + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out con0Slot); + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out con1Slot); + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out con2Slot); + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out con3Slot); m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs index 1ccf46c..c2ce0b6 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs @@ -62,10 +62,13 @@ namespace AxibugEmuOnline.Client private Dictionary cachesInMemory = new Dictionary(); void GetCacheData(string url, string path, Action callback) where T : class - { - if (cachesInMemory.TryGetValue(url, out var cacheObj) && cacheObj is T obj) + { + object cacheObj; + + if (cachesInMemory.TryGetValue(url, out cacheObj) && cacheObj is T) { - callback.Invoke(obj, url); + T obj = (T)cacheObj; + callback.Invoke(obj, url); return; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/FilterManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/FilterManager.cs index dffc6fb..d38e10b 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/FilterManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/FilterManager.cs @@ -22,6 +22,8 @@ namespace AxibugEmuOnline.Client public FilterManager(PostProcessVolume filterVolume, CanvasGroup filterPreview, CanvasGroup mainBg) { + if (filterVolume == null) + return; m_filterPorfile = filterVolume.profile; m_filters = m_filterPorfile.settings.Where(setting => setting is FilterEffect).Select(setting => new Filter(setting as FilterEffect)).ToList(); var json = PlayerPrefs.GetString(nameof(FilterRomSetting)); @@ -86,23 +88,40 @@ namespace AxibugEmuOnline.Client /// /// rom对象 /// 此元组任意内任意成员都有可能为空 - public (Filter filter, FilterPreset preset) GetFilterSetting(RomFile rom) + public GetFilterSetting_result GetFilterSetting(RomFile rom) { var value = m_filterRomSetting.Get(rom); Filter filter = null; FilterPreset preset = null; - filter = Filters.FirstOrDefault(f => f.Name == value.filterName); - if (filter != null) - { - string presetName = value.presetName; - preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); - } + //filter = Filters.FirstOrDefault(f => f.Name == value.filterName); + //if (filter != null) + //{ + // string presetName = value.presetName; + // preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); + //} - return (filter, preset); + filter = Filters.FirstOrDefault(f => f.Name == value.Item1); + if (filter != null) + { + string presetName = value.Item2; + preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); + } + + return new GetFilterSetting_result() + { + filter = filter, + preset = preset + }; } - public class Filter + public struct GetFilterSetting_result + { + public Filter filter; + public FilterPreset preset; + } + + public class Filter { public string Name => m_setting.Name; public IReadOnlyCollection Paramerters => m_setting.EditableParam; @@ -223,8 +242,8 @@ namespace AxibugEmuOnline.Client public string GetParamValueJson(string paramName) { prepareCache(); - - m_paramName2ValueJson.TryGetValue(paramName, out var value); + string value; + m_paramName2ValueJson.TryGetValue(paramName, out value); return value; } @@ -234,8 +253,9 @@ namespace AxibugEmuOnline.Client if (rawStr == null) return null; if (valueType == typeof(float)) - { - float.TryParse(rawStr, out var floatVal); + { + float floatVal; + float.TryParse(rawStr, out floatVal); return floatVal; } else if (valueType.IsEnum) @@ -309,12 +329,13 @@ namespace AxibugEmuOnline.Client return JsonUtility.ToJson(this); } - public (string filterName, string presetName) Get(RomFile rom) + public ValueTuple Get(RomFile rom) { prepareCache(); - m_cache.TryGetValue(rom.ID, out var item); - return (item.FilterName, item.PresetName); + Item item; + m_cache.TryGetValue(rom.ID, out item); + return new ValueTuple(item.FilterName, item.PresetName); } private void prepareCache() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs index e64a895..d932481 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs @@ -5,6 +5,7 @@ using System.Collections; using System.IO; using UnityEngine; using UnityEngine.Networking; +using static UnityEngine.EventSystems.EventTrigger; namespace AxibugEmuOnline.Client { @@ -95,9 +96,11 @@ namespace AxibugEmuOnline.Client if (Path.GetExtension(LocalFilePath).ToLower() == ".zip") { var zip = new ZipInputStream(new MemoryStream(bytes)); - while (zip.GetNextEntry() is ZipEntry entry) + var entry = zip.GetNextEntry() as ZipEntry; + + while (entry != null) { - if (!entry.Name.ToLower().EndsWith(".nes")) continue; + if (!entry.Name.ToLower().EndsWith(".nes")) continue; var buffer = new byte[1024]; MemoryStream output = new MemoryStream(); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/UserDataManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/UserDataManager.cs index e59935a..da91a8d 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/UserDataManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/UserDataManager.cs @@ -154,14 +154,16 @@ namespace AxibugEmuOnline.Client.Manager for (int i = 0; i < msg.UserList.Count; i++) { UserMiniInfo mi = msg.UserList[i]; - UpdateOrAddUser(mi, out bool isNewUser); + bool isNewUser; + UpdateOrAddUser(mi, out isNewUser); } Eventer.Instance.PostEvent(EEvent.OnUserListAllUpdate); } public void RecvCmdUserJoin(byte[] reqData) { Protobuf_UserJoin_RESP msg = ProtoBufHelper.DeSerizlize(reqData); - UpdateOrAddUser(msg.UserInfo, out bool isNewUser); + bool isNewUser; + UpdateOrAddUser(msg.UserInfo, out isNewUser); if (isNewUser) { Eventer.Instance.PostEvent(EEvent.OnUserLogin, msg.UserInfo.UID, msg.UserInfo.NickName); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/MsgBool.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/MsgBool.cs index d7d6f5a..e3e9d3a 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/MsgBool.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/MsgBool.cs @@ -6,7 +6,7 @@ public struct MsgBool public string ErrorMsg; public bool Value; - public override readonly string ToString() + public override string ToString() { if (Value) { @@ -33,10 +33,10 @@ public struct MsgBool return msgBool.Value; } - public static implicit operator (bool, string)(MsgBool msgBool) - { - return (msgBool.Value, msgBool.ErrorMsg); - } + //public static implicit operator (bool, string)(MsgBool msgBool) + //{ + // return (msgBool.Value, msgBool.ErrorMsg); + //} public static implicit operator string(MsgBool msgBool) { diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/CoreSupporter.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/CoreSupporter.cs index 19c381d..e5db677 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/CoreSupporter.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/CoreSupporter.cs @@ -1,4 +1,5 @@ using AxibugEmuOnline.Client.ClientCore; +using AxiReplay; using System; using System.IO; using System.Runtime.InteropServices; @@ -101,8 +102,9 @@ namespace AxibugEmuOnline.Client public void SampleInput(uint frameIndex) { if (InGameUI.Instance.IsNetPlay) - { - if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out var replayData, out int frameDiff, out bool inputDiff)) + { + int targetFrame; ReplayStep replayData; int frameDiff; bool inputDiff; + if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out replayData, out frameDiff, out inputDiff)) { if (inputDiff) { @@ -112,7 +114,7 @@ namespace AxibugEmuOnline.Client m_sampledState = FromNet(replayData); } - else m_sampledState = default; + else m_sampledState = default(ControllerState); var localState = ControllerMapper.CreateState(); var rawData = ToNet(localState); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs index 742ac01..461a11f 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs @@ -5,10 +5,10 @@ namespace AxibugEmuOnline.Client { public class NesControllerMapper : IControllerSetuper { - public Controller Controller0 { get; } = new(0); - public Controller Controller1 { get; } = new(1); - public Controller Controller2 { get; } = new(2); - public Controller Controller3 { get; } = new(3); + public Controller Controller0 { get; } = new Controller(0); + public Controller Controller1 { get; } = new Controller(1); + public Controller Controller2 { get; } = new Controller(2); + public Controller Controller3 { get; } = new Controller(3); private readonly EnumButtonType[] m_states = new EnumButtonType[4]; @@ -138,7 +138,7 @@ namespace AxibugEmuOnline.Client } } - public readonly struct KeyListener + public struct KeyListener { private readonly KeyCode m_key; @@ -152,7 +152,8 @@ namespace AxibugEmuOnline.Client { m_key = KeyCode.None; - if (int.TryParse(confStr, out int result)) + int result; + if (int.TryParse(confStr, out result)) m_key = (KeyCode)result; } @@ -220,7 +221,7 @@ namespace AxibugEmuOnline.Client break; } - return default; + return default(KeyListener); } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator_Screen.mat b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator_Screen.mat index d581fae..1eb2c7a 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator_Screen.mat +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator_Screen.mat @@ -2,24 +2,19 @@ %TAG !u! tag:unity3d.com,2011: --- !u!21 &2100000 Material: - serializedVersion: 8 + serializedVersion: 6 m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} + m_PrefabInternal: {fileID: 0} m_Name: NesEmulator_Screen m_Shader: {fileID: 4800000, guid: b351396ff606116478d7f4412abe4e2e, type: 3} - m_Parent: {fileID: 0} - m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] - m_InvalidKeywords: [] + m_ShaderKeywords: m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 stringTagMap: {} disabledShaderPasses: [] - m_LockedProperties: m_SavedProperties: serializedVersion: 3 m_TexEnvs: @@ -63,7 +58,6 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - m_Ints: [] m_Floats: - _BumpScale: 1 - _ColorMask: 15 @@ -91,5 +85,3 @@ Material: m_Colors: - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - m_BuildTextureStacks: [] - m_AllowLocking: 1 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs index 235bab1..b4087dd 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs @@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client.Network private Dictionary> netEventDic = new Dictionary>(128); - private Queue<(int, int, byte[])> queueNetMsg = new Queue<(int, int, byte[])>(); + private Queue> queueNetMsg = new Queue>(); private NetMsg() { } @@ -66,7 +66,7 @@ namespace AxibugEmuOnline.Client.Network { lock (lockQueueObj) { - queueNetMsg.Enqueue((cmd, ERRCODE, arg)); + queueNetMsg.Enqueue(new ValueTuple(cmd, ERRCODE, arg)); } } @@ -76,7 +76,8 @@ namespace AxibugEmuOnline.Client.Network { while (queueNetMsg.Count > 0) { - (int, int, byte[]) msgData = queueNetMsg.Dequeue(); + + var msgData = queueNetMsg.Dequeue(); PostNetMsgEvent(msgData.Item1, msgData.Item2, msgData.Item3); } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_BgSettingItem_Color.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_BgSettingItem_Color.cs index 7664a22..2676a2d 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_BgSettingItem_Color.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_BgSettingItem_Color.cs @@ -39,7 +39,7 @@ namespace AxibugEmuOnline.Client public void SetDependencyProperty(object data) { - SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index); + SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index); } public void Release() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_FilterItem.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_FilterItem.cs index ad20700..a8df117 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_FilterItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/BgSettingsUI/UI_FilterItem.cs @@ -7,191 +7,192 @@ using UnityEngine; using static AxibugEmuOnline.Client.FilterManager; namespace AxibugEmuOnline.Client -{ - /// - /// 背景颜色设置UI - /// - 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; - - UpdateView(); - } - - 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 tr && tr.SelectIndex == Index); - - if (m_select) - { - App.filter.EnableFilterPreview(); - if (App.filter != null) - App.filter.EnableFilter(Datacontext); - else - App.filter.ShutDownFilter(); - } - } - - public void Release() { } - - public override bool OnEnterItem() - { - if (Datacontext != null && Datacontext.Paramerters.Count > 0) - { - var opts = new List(); - opts.Add(new Opt_CreatePreset(Datacontext)); - opts.AddRange(Datacontext.Presets.Select(p => new Opt_Presets(Datacontext, p))); +{ + /// + /// 背景颜色设置UI + /// + public class UI_FilterItem : MenuItem, IVirtualItem + { + public int Index { get; set; } + public Filter Datacontext { get; private set; } - OverlayManager.PopSideBar(opts, onClose: () => - { - App.filter.EnableFilterPreview(); - Datacontext.ResetPreset(); - App.filter.EnableFilter(Datacontext); - }); - } - return false; - } - - - public class Opt_CreatePreset : ExecuteMenu - { - private Filter m_filter; - - public Opt_CreatePreset(Filter filter) : base("创建滤镜预设", Resources.LoadAll("Icons/XMB-Icons/misc")[0]) - { - m_filter = filter; - } - - public override void OnFocus() - { - m_filter.ResetPreset(); - App.filter.EnableFilter(m_filter); - } - - public override void OnExcute(OptionUI optionUI, ref bool cancelHide) - { - cancelHide = true; - - OverlayManager.Input((presetName) => - { - var result = m_filter.CreatePreset(presetName, out var 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 m_menu; - - public Opt_Presets(Filter filter, FilterPreset preset) : base(preset.Name, null) - { - m_filter = filter; - m_preset = preset; - - m_menu = new List(); - 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 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); - } - - public override void OnFocus() - { - m_filter.ApplyPreset(m_preset); - App.filter.EnableFilter(m_filter); - } - - protected override List GetOptionMenus() - { - return m_menu; - } - - 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 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 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 object Min => m_param.MinValue; - - public override object Max => m_param.MaxValue; - } - - 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 override void OnExcute(OptionUI optionUI, ref bool cancelHide) - { - m_filter.RemovePreset(m_preset); - } - } - - - } - } + public void SetData(object data) + { + Datacontext = data as Filter; + + UpdateView(); + } + + 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); + + if (m_select) + { + App.filter.EnableFilterPreview(); + if (App.filter != null) + App.filter.EnableFilter(Datacontext); + else + App.filter.ShutDownFilter(); + } + } + + public void Release() { } + + public override bool OnEnterItem() + { + if (Datacontext != null && Datacontext.Paramerters.Count > 0) + { + var opts = new List(); + opts.Add(new Opt_CreatePreset(Datacontext)); + opts.AddRange(Datacontext.Presets.Select(p => new Opt_Presets(Datacontext, p))); + + OverlayManager.PopSideBar(opts, onClose: () => + { + App.filter.EnableFilterPreview(); + Datacontext.ResetPreset(); + App.filter.EnableFilter(Datacontext); + }); + } + return false; + } + + + public class Opt_CreatePreset : ExecuteMenu + { + private Filter m_filter; + + public Opt_CreatePreset(Filter filter) : base("创建滤镜预设", Resources.LoadAll("Icons/XMB-Icons/misc")[0]) + { + m_filter = filter; + } + + public override void OnFocus() + { + m_filter.ResetPreset(); + App.filter.EnableFilter(m_filter); + } + + 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 m_menu; + + public Opt_Presets(Filter filter, FilterPreset preset) : base(preset.Name, null) + { + m_filter = filter; + m_preset = preset; + + m_menu = new List(); + 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 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); + } + + public override void OnFocus() + { + m_filter.ApplyPreset(m_preset); + App.filter.EnableFilter(m_filter); + } + + protected override List GetOptionMenus() + { + return m_menu; + } + + 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 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 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 object Min => m_param.MinValue; + + public override object Max => m_param.MaxValue; + } + + 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 override void OnExcute(OptionUI optionUI, ref bool cancelHide) + { + m_filter.RemovePreset(m_preset); + } + } + + + } + } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomItem.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomItem.cs index e047221..dba3f0f 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomItem.cs @@ -37,12 +37,12 @@ namespace AxibugEmuOnline.Client m_romlib.BeginFetchRomInfo(m_romfile); } - SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index); + SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index); } public void SetDependencyProperty(object data) { - SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index); + SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index); } public void Release() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs index 4f0465f..dc772b0 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs @@ -11,7 +11,7 @@ namespace AxibugEmuOnline.Client private object m_state; private StepPerformer m_stepPerformer; - private readonly List menus = new(); + private readonly List menus = new List(); public static InGameUI Instance { get; private set; } public RomFile RomFile { get; private set; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_FilterSetting.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_FilterSetting.cs index dcfa000..0e99ba7 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_FilterSetting.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_FilterSetting.cs @@ -1,14 +1,11 @@ using AxibugEmuOnline.Client.ClientCore; using System.Collections.Generic; using System.Linq; -using UnityEditor.Presets; -using UnityEngine; -using VirtualNes.Core; using static AxibugEmuOnline.Client.FilterManager; namespace AxibugEmuOnline.Client -{ - public class InGameUI_FilterSetting : ExpandMenu +{ + public class InGameUI_FilterSetting : ExpandMenu { private InGameUI m_gameUI; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/GameObjectPool.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/GameObjectPool.cs index 7d2a496..f0ee729 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/GameObjectPool.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/GameObjectPool.cs @@ -39,8 +39,10 @@ public static class GameObjectPool public static void Release(GameObject instance) { - s_instanceToSrc.TryGetValue(instance, out var src); - if (src != null && s_poolMap.TryGetValue(src, out var pool)) + GameObject src; + Queue pool; + s_instanceToSrc.TryGetValue(instance, out src); + if (src != null && s_poolMap.TryGetValue(src, out pool)) { pool.Enqueue(instance); //instance.SetActive(false); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemPresent.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemPresent.cs index af37d14..e270899 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemPresent.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemPresent.cs @@ -480,9 +480,10 @@ public class ItemPresent : GridLayoutGroup, IVirtualLayout if (_dataList != null) _dataList.Clear(); } - else if (dataList is IEnumerable ienumrable) + else if (dataList is IEnumerable) { - List temp = new List(); + var ienumrable = (IEnumerable)dataList; + List temp = new List(); foreach (var item in ienumrable) { temp.Add(item); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemProxy.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemProxy.cs index b91d692..1a43d62 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemProxy.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/ItemPresent/ItemProxy.cs @@ -6,240 +6,245 @@ using UnityEngine.UI; public interface IVirtualLayout { - Dictionary CacheItemScripts { get; } - public List DataList { get; } - public object DependencyProperty { get; } - public RectTransform RectTransform { get; } - public RectTransform GetTemplate(object data); - public Vector2 GetItemAnchorePos(int index); - public RectTransform GetItemUIIfExist(int index); + Dictionary CacheItemScripts { get; } + List DataList { get; } + object DependencyProperty { get; } + RectTransform RectTransform { get; } + RectTransform GetTemplate(object data); + Vector2 GetItemAnchorePos(int index); + RectTransform GetItemUIIfExist(int index); - public void UpdateProxyVisualState(); - public void UpdateDependencyProperty(object dp); - public void SetData(object dataList); - public void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex); + void UpdateProxyVisualState(); + void UpdateDependencyProperty(object dp); + void SetData(object dataList); + void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex); } public class ItemProxy { - public bool IsDestroyed; - public bool Visible = true; - public int Index; - public bool IsInViewRect; + public bool IsDestroyed; + public bool Visible = true; + public int Index; + public bool IsInViewRect; - public Vector2 Pivot => _template.pivot; - public Vector2 AnchoredPosition; + public Vector2 Pivot => _template.pivot; + public Vector2 AnchoredPosition; - public float Width; - public float Height; + public float Width; + public float Height; - private IVirtualLayout _parent; + private IVirtualLayout _parent; - private RectTransform _template => _parent.GetTemplate(_parent.DataList[Index]); - private RectTransform _runtimeInstance; - private LayoutGroup _layoutElement; + 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 RectTransform RuntimeItemUI => _runtimeInstance; + public bool firstShow { get; private set; } = true; - public float PreferredWidth - { - get - { - if (_layoutElement == null) return 0; + public float PreferredWidth + { + get + { + if (_layoutElement == null) return 0; - return _layoutElement.preferredWidth; - } - } - public float PreferredHeight - { - get - { - if (_layoutElement == null) return 0; + return _layoutElement.preferredWidth; + } + } + public float PreferredHeight + { + get + { + if (_layoutElement == null) return 0; - return _layoutElement.preferredHeight; - } - } + return _layoutElement.preferredHeight; + } + } - public ScripteInterface GetLuaObj() - { - if (_runtimeInstance == null) return null; + public ScripteInterface GetLuaObj() + { + if (_runtimeInstance == null) return null; - _parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface lfi); + ScripteInterface lfi; - return lfi; - } + _parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out lfi); - public ItemProxy(IVirtualLayout parent) - { - _parent = parent; - } + return lfi; + } - public void Dispose() - { - if (_runtimeInstance != null) - { - if (Application.isPlaying) - { - GameObjectPool.Release(_runtimeInstance.gameObject); - } - else - GameObject.DestroyImmediate(_runtimeInstance.gameObject); - } - } + public ItemProxy(IVirtualLayout parent) + { + _parent = parent; + } - public bool NeedShow - { - get - { - if (IsInViewRect && _runtimeInstance == null) return true; - else - { - if (_runtimeInstance != null && IsInViewRect && _runtimeInstance.anchoredPosition != AnchoredPosition) - return true; - else - return false; - } - } + public void Dispose() + { + if (_runtimeInstance != null) + { + if (Application.isPlaying) + { + GameObjectPool.Release(_runtimeInstance.gameObject); + } + else + GameObject.DestroyImmediate(_runtimeInstance.gameObject); + } + } - } - public bool NeedHide => !IsInViewRect && _runtimeInstance != null; + public bool NeedShow + { + get + { + if (IsInViewRect && _runtimeInstance == null) return true; + else + { + if (_runtimeInstance != null && IsInViewRect && _runtimeInstance.anchoredPosition != AnchoredPosition) + return true; + else + return false; + } + } - public void UpdateView(bool force = false) - { - if (IsInViewRect) - { - if (_runtimeInstance == null) - { - _runtimeInstance = GetInstance(); - _layoutElement = _runtimeInstance.GetComponent(); - UpdateViewData(); - } - else if (force) - { - UpdateViewData(); - } + } + public bool NeedHide => !IsInViewRect && _runtimeInstance != null; - UpdateLayout(); - } - else - { - ReleaseInstance(); - } - } + public void UpdateView(bool force = false) + { + if (IsInViewRect) + { + if (_runtimeInstance == null) + { + _runtimeInstance = GetInstance(); + _layoutElement = _runtimeInstance.GetComponent(); + UpdateViewData(); + } + else if (force) + { + UpdateViewData(); + } - 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(); - } + 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(); - ScripteInterface newSI = new ScripteInterface(vItem); - _parent.CacheItemScripts[_runtimeInstance.gameObject] = newSI; - } + } - _parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface si); - si.SetDataList(_parent.DataList[Index], Index); - if (_parent.DependencyProperty != null) - si.SetDependencyProperty(_parent.DependencyProperty); - } - } + private void UpdateViewData() + { + if (Application.isPlaying) + { + if (!_parent.CacheItemScripts.ContainsKey(_runtimeInstance.gameObject)) + { + var vItem = _runtimeInstance.gameObject.GetComponent(); + ScripteInterface newSI = new ScripteInterface(vItem); + _parent.CacheItemScripts[_runtimeInstance.gameObject] = newSI; + } - public void UpdateDP() - { - if (_runtimeInstance == null) return; + ScripteInterface si; - _parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface luaInterface); - if (luaInterface == null) return; + _parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si); + si.SetDataList(_parent.DataList[Index], Index); + if (_parent.DependencyProperty != null) + si.SetDependencyProperty(_parent.DependencyProperty); + } + } - if (_parent.DependencyProperty != null) - luaInterface.SetDependencyProperty(_parent.DependencyProperty); - } + public void UpdateDP() + { + if (_runtimeInstance == null) return; + ScripteInterface luaInterface; + _parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out luaInterface); + if (luaInterface == null) return; - private RectTransform GetInstance() - { - var res = GameObjectPool.GetInstance(_template.gameObject, _parent.RectTransform).GetComponent(); - return res; - } + if (_parent.DependencyProperty != null) + luaInterface.SetDependencyProperty(_parent.DependencyProperty); + } - private void ReleaseInstance() - { - if (_runtimeInstance == null) return; + private RectTransform GetInstance() + { + var res = GameObjectPool.GetInstance(_template.gameObject, _parent.RectTransform).GetComponent(); + return res; + } - _layoutElement = null; + private void ReleaseInstance() + { + if (_runtimeInstance == null) return; - if (Application.isPlaying) - { - _parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface si); - if (si != null) si.Release(); - GameObjectPool.Release(_runtimeInstance.gameObject); - _runtimeInstance = null; - } - else - { - GameObject.DestroyImmediate(_runtimeInstance.gameObject); - _runtimeInstance = null; - } - } + _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; + private IVirtualItem _itemInstance; + public IVirtualItem ItemInstance => _itemInstance; - public ScripteInterface(IVirtualItem lc) - { - _itemInstance = lc; - } + 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 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; + public void SetDependencyProperty(object dependencyProperty) + { + if (_itemInstance == null) return; - _itemInstance.SetDependencyProperty(dependencyProperty); - } + _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(); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs index 74c7d28..b439972 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs @@ -269,16 +269,18 @@ namespace AxibugEmuOnline.Client private void CreateRuntimeMenuItem(OptionMenu menuData) { - if (menuData is ExecuteMenu executeMenu) + if (menuData is ExecuteMenu) { - var menuUI = Instantiate(TEMPLATE_EXECUTEITEM.gameObject, TEMPLATE_EXECUTEITEM.transform.parent).GetComponent(); + ExecuteMenu executeMenu = (ExecuteMenu)menuData; + var menuUI = Instantiate(TEMPLATE_EXECUTEITEM.gameObject, TEMPLATE_EXECUTEITEM.transform.parent).GetComponent(); menuUI.gameObject.SetActive(true); menuUI.SetData(this, executeMenu); m_runtimeMenuItems.Add(menuUI); } - else if (menuData is ValueSetMenu valueSetMenu) + else if (menuData is ValueSetMenu) { - var menuUI = Instantiate(TEMPLATE_VALUEEDITITEM.gameObject, TEMPLATE_VALUEEDITITEM.transform.parent).GetComponent(); + var valueSetMenu = (ValueSetMenu)menuData; + var menuUI = Instantiate(TEMPLATE_VALUEEDITITEM.gameObject, TEMPLATE_VALUEEDITITEM.transform.parent).GetComponent(); menuUI.gameObject.SetActive(true); menuUI.SetData(this, valueSetMenu); m_runtimeMenuItems.Add(menuUI); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem.cs index 8d63570..fce4e73 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem.cs @@ -17,9 +17,10 @@ namespace AxibugEmuOnline.Client com_floatEdit.gameObject.SetActive(false); com_enumEdit.gameObject.SetActive(false); - if (menuData is ValueSetMenu valueMenu) + if (menuData is ValueSetMenu) { - if (valueMenu.ValueType == typeof(float)) + var valueMenu = (ValueSetMenu)menuData; + if (valueMenu.ValueType == typeof(float)) { m_currentCom = com_floatEdit; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/InputUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/InputUI.cs index 1eebe31..a91b7c5 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/InputUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/InputUI.cs @@ -18,11 +18,11 @@ namespace AxibugEmuOnline.Client protected override void OnShow(object param) { - (Action callback, string placeHolder, string defaultText) t = ((Action callback, string placeHolder, string defaultText))param; + ValueTuple, string, string> t = (ValueTuple, string, string>)param; - OnCommit = t.callback; - (m_input.placeholder as Text).text = t.placeHolder; - m_input.text = t.defaultText; + OnCommit = t.Item1; + (m_input.placeholder as Text).text = t.Item2; + m_input.text = t.Item3; } protected override void Update() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/OverlayManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/OverlayManager.cs index b5c5d4c..a882544 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/OverlayManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OverlayUI/OverlayManager.cs @@ -22,7 +22,7 @@ namespace AxibugEmuOnline.Client public static InputUI Input(Action callback, string placeHolder, string defaultText) { - s_ins.m_InputUI.Show((callback, placeHolder, defaultText)); + s_ins.m_InputUI.Show(new ValueTuple, string, string>(callback, placeHolder, defaultText)); return s_ins.m_InputUI; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/RoomUI/RoomItem.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/RoomUI/RoomItem.cs index 5cc8555..1a04dbf 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/RoomUI/RoomItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/RoomUI/RoomItem.cs @@ -9,132 +9,136 @@ using Debug = System.Diagnostics.Debug; namespace AxibugEmuOnline.Client { - public class RoomItem : MenuItem, IVirtualItem - { - [SerializeField] Image m_roomPreview; - [SerializeField] Slider m_downloadProgress; - [SerializeField] GameObject m_downloadingFlag; - [SerializeField] GameObject m_romReadyFlag; + public class RoomItem : MenuItem, IVirtualItem + { + [SerializeField] Image m_roomPreview; + [SerializeField] Slider m_downloadProgress; + [SerializeField] GameObject m_downloadingFlag; + [SerializeField] GameObject m_romReadyFlag; - private RomFile m_romFile; + private RomFile m_romFile; - public int Index { get; set; } - public int RoomID { get; private set; } + public int Index { get; set; } + public int RoomID { get; private set; } - protected override void Awake() - { - base.Awake(); + protected override void Awake() + { + base.Awake(); - Eventer.Instance.RegisterEvent(EEvent.OnRoomListSingleUpdate, OnRoomSignelUpdate); - } + Eventer.Instance.RegisterEvent(EEvent.OnRoomListSingleUpdate, OnRoomSignelUpdate); + } - private void OnRoomSignelUpdate(int roomID) - { - if (this.RoomID != roomID) return; + private void OnRoomSignelUpdate(int roomID) + { + if (this.RoomID != roomID) return; - if (App.roomMgr.GetRoomListMiniInfo(roomID, out var roomInfo)) - UpdateUI(roomInfo); - } + Protobuf_Room_MiniInfo roomInfo; + if (App.roomMgr.GetRoomListMiniInfo(roomID, out roomInfo)) + UpdateUI(roomInfo); + } - public void SetData(object data) - { - Debug.Assert(data is Protobuf_Room_MiniInfo); + public void SetData(object data) + { + Debug.Assert(data is Protobuf_Room_MiniInfo); - var roomInfo = (Protobuf_Room_MiniInfo)data; - RoomID = roomInfo.RoomID; + var roomInfo = (Protobuf_Room_MiniInfo)data; + RoomID = roomInfo.RoomID; - UpdateUI(roomInfo); - } + UpdateUI(roomInfo); + } - public override bool OnEnterItem() - { - if (m_romFile == null) return false; + public override bool OnEnterItem() + { + if (m_romFile == null) return false; - if (!m_romFile.RomReady) - { - m_romFile.BeginDownload(); - return false; - } - else - { - if (!App.roomMgr.GetRoomListMiniInfo(RoomID, out Protobuf_Room_MiniInfo MiniInfo)) - { - OverlayManager.PopTip("房间不存在"); - return false; - } + if (!m_romFile.RomReady) + { + m_romFile.BeginDownload(); + return false; + } + else + { + Protobuf_Room_MiniInfo MiniInfo; + if (!App.roomMgr.GetRoomListMiniInfo(RoomID, out MiniInfo)) + { + OverlayManager.PopTip("房间不存在"); + return false; + } + int[] freeSlots; + if (!MiniInfo.GetFreeSlot(out freeSlots)) + { + OverlayManager.PopTip("无空闲位置"); + return false; + } - if (!MiniInfo.GetFreeSlot(out var freeSlots)) - { - OverlayManager.PopTip("无空闲位置"); - return false; - } + App.roomMgr.SendJoinRoom(RoomID); + return true; + } + } - App.roomMgr.SendJoinRoom(RoomID); - return true; - } - } + private void UpdateUI(Protobuf_Room_MiniInfo roomInfo) + { + var hostNick = roomInfo.GetHostNickName(); + int cur; int max; - private void UpdateUI(Protobuf_Room_MiniInfo roomInfo) - { - var hostNick = roomInfo.GetHostNickName(); - roomInfo.GetRoomPlayers(out var cur, out var max); - SetBaseInfo("--", $"{hostNick}的房间", $"{cur}/{max}"); - SetIcon(null); + roomInfo.GetRoomPlayers(out cur, out max); + SetBaseInfo("--", $"{hostNick}的房间", $"{cur}/{max}"); + SetIcon(null); - roomInfo.FetchRomFileInRoomInfo(EnumPlatform.NES, (room, romFile) => - { - if (room.RoomID != RoomID) return; + roomInfo.FetchRomFileInRoomInfo(EnumPlatform.NES, (room, romFile) => + { + if (room.RoomID != RoomID) return; - m_romFile = romFile; - Txt.text = romFile.Alias; + m_romFile = romFile; + Txt.text = romFile.Alias; - UpdateRomInfoView(); - App.CacheMgr.GetSpriteCache(romFile.ImageURL, OnGetRomImage); - }); - } + UpdateRomInfoView(); + App.CacheMgr.GetSpriteCache(romFile.ImageURL, OnGetRomImage); + }); + } - protected override void Update() - { - UpdateRomInfoView(); - base.Update(); - } + protected override void Update() + { + UpdateRomInfoView(); + base.Update(); + } - private void UpdateRomInfoView() - { - float? downloadingProgress = null; - bool romReady = false; + private void UpdateRomInfoView() + { + float? downloadingProgress = null; + bool romReady = false; - if (m_romFile != null) - { - if (m_romFile.IsDownloading) - downloadingProgress = m_romFile.Progress; - if (m_romFile.RomReady) - romReady = true; - } + if (m_romFile != null) + { + if (m_romFile.IsDownloading) + downloadingProgress = m_romFile.Progress; + if (m_romFile.RomReady) + romReady = true; + } - m_downloadingFlag.SetActiveEx(downloadingProgress.HasValue); - if (downloadingProgress.HasValue) - m_downloadProgress.value = downloadingProgress.Value; + m_downloadingFlag.SetActiveEx(downloadingProgress.HasValue); + if (downloadingProgress.HasValue) + m_downloadProgress.value = downloadingProgress.Value; - m_romReadyFlag.SetActiveEx(romReady); - } + m_romReadyFlag.SetActiveEx(romReady); + } - private void OnGetRomImage(Sprite sprite, string url) - { - if (m_romFile == null) return; - if (m_romFile.ImageURL != url) return; + private void OnGetRomImage(Sprite sprite, string url) + { + if (m_romFile == null) return; + if (m_romFile.ImageURL != url) return; - SetIcon(sprite); - } + SetIcon(sprite); + } - public void SetDependencyProperty(object data) - { - SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index); - } + public void SetDependencyProperty(object data) + { + SetSelectState((data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index)); + } - public void Release() - { - Reset(); - } - } + public void Release() + { + Reset(); + } + } } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/Selector.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/Selector.cs index 2fbe407..78b9e2f 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/Selector.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/Selector.cs @@ -44,7 +44,7 @@ namespace AxibugEmuOnline.Client m_trackTween.Kill(); m_trackTween = null; } - m_trackTween = DOTween.To(() => m_rect.position, (value) => m_rect.position = value, itemUIRect.position, 0.125f); + m_trackTween = DOTween.To(() => m_rect.position, (_value) => m_rect.position = _value, itemUIRect.position, 0.125f); m_trackTween.onComplete = () => m_trackTween = null; } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/SubMenuItemGroup.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/SubMenuItemGroup.cs index d749d4c..fa62a93 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/SubMenuItemGroup.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/SubMenuItemGroup.cs @@ -184,6 +184,10 @@ namespace AxibugEmuOnline.Client private MenuItem Clone(MenuItem template, Transform parent) { #if UNITY_EDITOR + + //========================޺======================== +#if UNITY_2019_1_OR_NEWER //°UnityUNITY2018.2ò༭Ҳ + if (Application.isPlaying) { var item = GameObject.Instantiate(template.gameObject, parent).GetComponent(); @@ -197,8 +201,17 @@ namespace AxibugEmuOnline.Client return clone.GetComponent(); } #else - return GameObject.Instantiate(SubMenuItemTemplate.gameObject, parent).GetComponent(); + var item = GameObject.Instantiate(template.gameObject, parent).GetComponent(); + item.transform.localPosition = Vector3.zero; + return item; #endif - } - } + //========================޺ End======================== + + + +#else + return GameObject.Instantiate(SubMenuItemTemplate.gameObject, parent).GetComponent(); +#endif + } + } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/UITool.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/UITool.cs index 483cd02..813659a 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/UITool.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/UITool.cs @@ -9,7 +9,8 @@ namespace AxibugEmuOnline.Client private static Dictionary _caches = new Dictionary(); public static Material GetMaterial(this Graphic graphic) { - if (_caches.TryGetValue(graphic, out var material)) + Material material; + if (_caches.TryGetValue(graphic, out material)) { return material; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/XMBTopGroupUI/XMBInfoBar.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/XMBTopGroupUI/XMBInfoBar.cs index 7281a23..264881f 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/XMBTopGroupUI/XMBInfoBar.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/XMBTopGroupUI/XMBInfoBar.cs @@ -34,7 +34,10 @@ public class XMBInfoBar : MonoBehaviour RefreshFps(); } - (uint lastFrame, float lastTime) m_lastFrameInfo; + /// + /// (uint lastFrame, float lastTime) + /// + ValueTuple m_lastFrameInfo; private void RefreshFps() { if (App.emu.Core.IsNull()) @@ -42,14 +45,18 @@ public class XMBInfoBar : MonoBehaviour else { FPS.gameObject.SetActiveEx(true); - var gap = App.emu.Core.Frame - m_lastFrameInfo.lastFrame; - var time = Time.realtimeSinceStartup - m_lastFrameInfo.lastTime; - var fps = gap / time; + //var gap = App.emu.Core.Frame - m_lastFrameInfo.lastFrame; + //var time = Time.realtimeSinceStartup - m_lastFrameInfo.lastTime; + var gap = App.emu.Core.Frame - m_lastFrameInfo.Item1; + var time = Time.realtimeSinceStartup - m_lastFrameInfo.Item2; + var fps = gap / time; FPS.text = $"FPS:{fps:.#}"; - m_lastFrameInfo.lastFrame = App.emu.Core.Frame; - m_lastFrameInfo.lastTime = Time.realtimeSinceStartup; - } + //m_lastFrameInfo.lastFrame = App.emu.Core.Frame; + //m_lastFrameInfo.lastTime = Time.realtimeSinceStartup; + m_lastFrameInfo.Item1 = App.emu.Core.Frame; + m_lastFrameInfo.Item2 = Time.realtimeSinceStartup; + } } private void RefreshDelay() diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Utility.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Utility.cs index ecda140..f8f76b1 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Utility.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Utility.cs @@ -36,7 +36,9 @@ namespace AxibugEmuOnline.Client private static Dictionary s_RomFileCahcesInRoomInfo = new Dictionary(); public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, EnumPlatform platform, Action callback) { - if (s_RomFileCahcesInRoomInfo.TryGetValue(roomInfo.GameRomID, out RomFile romFile)) + RomFile romFile; + + if (s_RomFileCahcesInRoomInfo.TryGetValue(roomInfo.GameRomID, out romFile)) { callback.Invoke(roomInfo, romFile); return; @@ -46,11 +48,11 @@ namespace AxibugEmuOnline.Client case EnumPlatform.NES: App.StartCoroutine(App.httpAPI.GetNesRomInfo(roomInfo.GameRomID, (romWebData) => { - RomFile romFile = new RomFile(EnumPlatform.NES, 0, 0); - romFile.SetWebData(romWebData); - s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = romFile; + RomFile _romFile = new RomFile(EnumPlatform.NES, 0, 0); + _romFile.SetWebData(romWebData); + s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile; - callback.Invoke(roomInfo, romFile); + callback.Invoke(roomInfo, _romFile); })); break; }