Compare commits

..

No commits in common. "f705b947c3595a29e3c01ac6c8fd5ff5be1dabbc" and "7c1a2af6f06ebf7c1e4942f08af27fe43f0cbf0f" have entirely different histories.

31 changed files with 596 additions and 673 deletions

View File

@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client.ClientCore
private static CoroutineRunner coRunner;
#endregion
#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机
#if UNITY_PSP2
public static string PersistentDataPath => "ux0:data/AxibugEmu";
#else
public static string PersistentDataPath => Application.persistentDataPath;
@ -45,12 +45,6 @@ namespace AxibugEmuOnline.Client.ClientCore
{
PlayerPrefs.DeleteAll();
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
{
//PSV 等平台需要手动创建目录
PSP2Init();
}
settings = new AppSettings();
log = new LogManager();
@ -74,6 +68,11 @@ namespace AxibugEmuOnline.Client.ClientCore
tickLoop = go.AddComponent<TickLoop>();
coRunner = go.AddComponent<CoroutineRunner>();
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
{
//PSV 等平台需要手动创建目录
PersistentDataPathDir();
}
var importNode = GameObject.Find("IMPORTENT");
if (importNode != null) GameObject.DontDestroyOnLoad(importNode);
@ -82,17 +81,12 @@ namespace AxibugEmuOnline.Client.ClientCore
RePullNetInfo();
}
private static void PSP2Init()
private static void PersistentDataPathDir()
{
//PSVita最好手动创建目录
if (!Directory.Exists(PersistentDataPath))
{
Directory.CreateDirectory(PersistentDataPath);
#if UNITY_PSP2
//释放解码 FMV的26M内存一般游戏用不上PSP才用那破玩意儿
UnityEngine.PSVita.PSVitaVideoPlayer.TransferMemToMonoHeap();
#endif
}
}
private static IEnumerator AppTickFlow()

View File

@ -1,12 +1,19 @@
{
"name": "AxibugEmuOnline.Client",
"rootNamespace": "AxibugEmuOnline.Client",
"references": [
"VirtualNes.Core",
"UIEffect",
"AxiReplay",
"Unity.Postprocessing.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -249,18 +249,6 @@ Shader "PostEffect/FixingPixcelArtGrille"
else if(pos.x<0.666)mask.g=_maskLight;
else mask.b=_maskLight;
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

View File

@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client.Manager
/// </summary>
private IEmuCore m_emuCore;
private VirtualNes.Core.IControllerSetuper m_controllerSetuper;
private IControllerSetuper m_controllerSetuper;
/// <summary>
/// unity的c#实现有bug,以接口类型保存的monobehaviour引用,!=和==运算符没有调用到monobehaviour重写过的运算符
@ -84,15 +84,10 @@ namespace AxibugEmuOnline.Client.Manager
else //在房间中则使用服务器下发的手柄槽位信息分配本地手柄
{
long selfUID = App.user.userdata.UID;
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);
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);
m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot);
}

View File

@ -63,11 +63,8 @@ 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)
if (cachesInMemory.TryGetValue(url, out var cacheObj) && cacheObj is T obj)
{
T obj = (T)cacheObj;
callback.Invoke(obj, url);
return;
}

View File

@ -22,8 +22,6 @@ 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));
@ -88,37 +86,20 @@ namespace AxibugEmuOnline.Client
/// </summary>
/// <param name="rom">rom对象</param>
/// <returns>此元组任意内任意成员都有可能为空</returns>
public GetFilterSetting_result GetFilterSetting(RomFile rom)
public (Filter filter, FilterPreset preset) 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.Item1);
filter = Filters.FirstOrDefault(f => f.Name == value.filterName);
if (filter != null)
{
string presetName = value.Item2;
string presetName = value.presetName;
preset = filter.Presets.FirstOrDefault(p => p.Name == presetName);
}
return new GetFilterSetting_result()
{
filter = filter,
preset = preset
};
}
public struct GetFilterSetting_result
{
public Filter filter;
public FilterPreset preset;
return (filter, preset);
}
public class Filter
@ -242,8 +223,8 @@ namespace AxibugEmuOnline.Client
public string GetParamValueJson(string paramName)
{
prepareCache();
string value;
m_paramName2ValueJson.TryGetValue(paramName, out value);
m_paramName2ValueJson.TryGetValue(paramName, out var value);
return value;
}
@ -254,8 +235,7 @@ namespace AxibugEmuOnline.Client
if (valueType == typeof(float))
{
float floatVal;
float.TryParse(rawStr, out floatVal);
float.TryParse(rawStr, out var floatVal);
return floatVal;
}
else if (valueType.IsEnum)
@ -329,13 +309,12 @@ namespace AxibugEmuOnline.Client
return JsonUtility.ToJson(this);
}
public ValueTuple<string,string> Get(RomFile rom)
public (string filterName, string presetName) Get(RomFile rom)
{
prepareCache();
Item item;
m_cache.TryGetValue(rom.ID, out item);
return new ValueTuple<string, string>(item.FilterName, item.PresetName);
m_cache.TryGetValue(rom.ID, out var item);
return (item.FilterName, item.PresetName);
}
private void prepareCache()

View File

@ -5,7 +5,6 @@ using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using static UnityEngine.EventSystems.EventTrigger;
namespace AxibugEmuOnline.Client
{
@ -96,9 +95,7 @@ namespace AxibugEmuOnline.Client
if (Path.GetExtension(LocalFilePath).ToLower() == ".zip")
{
var zip = new ZipInputStream(new MemoryStream(bytes));
var entry = zip.GetNextEntry() as ZipEntry;
while (entry != null)
while (zip.GetNextEntry() is ZipEntry entry)
{
if (!entry.Name.ToLower().EndsWith(".nes")) continue;

View File

@ -154,16 +154,14 @@ namespace AxibugEmuOnline.Client.Manager
for (int i = 0; i < msg.UserList.Count; i++)
{
UserMiniInfo mi = msg.UserList[i];
bool isNewUser;
UpdateOrAddUser(mi, out isNewUser);
UpdateOrAddUser(mi, out bool 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);
UpdateOrAddUser(msg.UserInfo, out bool isNewUser);
if (isNewUser)
{
Eventer.Instance.PostEvent(EEvent.OnUserLogin, msg.UserInfo.UID, msg.UserInfo.NickName);

View File

@ -6,7 +6,7 @@ public struct MsgBool
public string ErrorMsg;
public bool Value;
public override string ToString()
public override readonly 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)
{

View File

@ -1,5 +1,4 @@
using AxibugEmuOnline.Client.ClientCore;
using AxiReplay;
using System;
using System.IO;
using System.Runtime.InteropServices;
@ -103,8 +102,7 @@ namespace AxibugEmuOnline.Client
{
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 (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out var replayData, out int frameDiff, out bool inputDiff))
{
if (inputDiff)
{
@ -114,7 +112,7 @@ namespace AxibugEmuOnline.Client
m_sampledState = FromNet(replayData);
}
else m_sampledState = default(ControllerState);
else m_sampledState = default;
var localState = ControllerMapper.CreateState();
var rawData = ToNet(localState);

View File

@ -5,10 +5,10 @@ namespace AxibugEmuOnline.Client
{
public class NesControllerMapper : IControllerSetuper
{
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);
public Controller Controller0 { get; } = new(0);
public Controller Controller1 { get; } = new(1);
public Controller Controller2 { get; } = new(2);
public Controller Controller3 { get; } = new(3);
private readonly EnumButtonType[] m_states = new EnumButtonType[4];
@ -138,7 +138,7 @@ namespace AxibugEmuOnline.Client
}
}
public struct KeyListener
public readonly struct KeyListener
{
private readonly KeyCode m_key;
@ -152,8 +152,7 @@ namespace AxibugEmuOnline.Client
{
m_key = KeyCode.None;
int result;
if (int.TryParse(confStr, out result))
if (int.TryParse(confStr, out int result))
m_key = (KeyCode)result;
}
@ -221,7 +220,7 @@ namespace AxibugEmuOnline.Client
break;
}
return default(KeyListener);
return default;
}
}

View File

@ -2,19 +2,24 @@
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: NesEmulator_Screen
m_Shader: {fileID: 4800000, guid: b351396ff606116478d7f4412abe4e2e, type: 3}
m_ShaderKeywords:
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@ -58,6 +63,7 @@ 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
@ -85,3 +91,5 @@ 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

View File

@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client.Network
private Dictionary<int, List<Delegate>> netEventDic = new Dictionary<int, List<Delegate>>(128);
private Queue<ValueTuple<int, int, byte[]>> queueNetMsg = new Queue<ValueTuple<int, int, byte[]>>();
private Queue<(int, int, byte[])> queueNetMsg = new Queue<(int, int, byte[])>();
private NetMsg() { }
@ -66,7 +66,7 @@ namespace AxibugEmuOnline.Client.Network
{
lock (lockQueueObj)
{
queueNetMsg.Enqueue(new ValueTuple<int,int,byte[]>(cmd, ERRCODE, arg));
queueNetMsg.Enqueue((cmd, ERRCODE, arg));
}
}
@ -76,8 +76,7 @@ namespace AxibugEmuOnline.Client.Network
{
while (queueNetMsg.Count > 0)
{
var msgData = queueNetMsg.Dequeue();
(int, int, byte[]) msgData = queueNetMsg.Dequeue();
PostNetMsgEvent(msgData.Item1, msgData.Item2, msgData.Item3);
}
}

View File

@ -39,7 +39,7 @@ namespace AxibugEmuOnline.Client
public void SetDependencyProperty(object data)
{
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
}
public void Release()

View File

@ -33,7 +33,7 @@ namespace AxibugEmuOnline.Client
public void SetDependencyProperty(object data)
{
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
if (m_select)
{
@ -87,8 +87,7 @@ namespace AxibugEmuOnline.Client
OverlayManager.Input((presetName) =>
{
FilterPreset newPreset;
var result = m_filter.CreatePreset(presetName, out newPreset);
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);

View File

@ -37,12 +37,12 @@ namespace AxibugEmuOnline.Client
m_romlib.BeginFetchRomInfo(m_romfile);
}
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
}
public void SetDependencyProperty(object data)
{
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
}
public void Release()

View File

@ -11,7 +11,7 @@ namespace AxibugEmuOnline.Client
private object m_state;
private StepPerformer m_stepPerformer;
private readonly List<OptionMenu> menus = new List<OptionMenu>();
private readonly List<OptionMenu> menus = new();
public static InGameUI Instance { get; private set; }
public RomFile RomFile { get; private set; }

View File

@ -1,6 +1,9 @@
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

View File

@ -39,10 +39,8 @@ public static class GameObjectPool
public static void Release(GameObject instance)
{
GameObject src;
Queue<GameObject> pool;
s_instanceToSrc.TryGetValue(instance, out src);
if (src != null && s_poolMap.TryGetValue(src, out pool))
s_instanceToSrc.TryGetValue(instance, out var src);
if (src != null && s_poolMap.TryGetValue(src, out var pool))
{
pool.Enqueue(instance);
//instance.SetActive(false);

View File

@ -480,9 +480,8 @@ public class ItemPresent : GridLayoutGroup, IVirtualLayout
if (_dataList != null)
_dataList.Clear();
}
else if (dataList is IEnumerable)
else if (dataList is IEnumerable ienumrable)
{
var ienumrable = (IEnumerable)dataList;
List<object> temp = new List<object>();
foreach (var item in ienumrable)
{

View File

@ -7,17 +7,17 @@ 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);
public List<object> 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);
void UpdateProxyVisualState();
void UpdateDependencyProperty(object dp);
void SetData(object dataList);
void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex);
public void UpdateProxyVisualState();
public void UpdateDependencyProperty(object dp);
public void SetData(object dataList);
public void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex);
}
public class ItemProxy
@ -65,9 +65,7 @@ public class ItemProxy
{
if (_runtimeInstance == null) return null;
ScripteInterface lfi;
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out lfi);
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface lfi);
return lfi;
}
@ -161,9 +159,7 @@ public class ItemProxy
_parent.CacheItemScripts[_runtimeInstance.gameObject] = newSI;
}
ScripteInterface si;
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface si);
si.SetDataList(_parent.DataList[Index], Index);
if (_parent.DependencyProperty != null)
si.SetDependencyProperty(_parent.DependencyProperty);
@ -173,8 +169,8 @@ public class ItemProxy
public void UpdateDP()
{
if (_runtimeInstance == null) return;
ScripteInterface luaInterface;
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out luaInterface);
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface luaInterface);
if (luaInterface == null) return;
if (_parent.DependencyProperty != null)
@ -195,8 +191,7 @@ public class ItemProxy
if (Application.isPlaying)
{
ScripteInterface si;
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface si);
if (si != null) si.Release();
GameObjectPool.Release(_runtimeInstance.gameObject);
_runtimeInstance = null;

View File

@ -269,17 +269,15 @@ namespace AxibugEmuOnline.Client
private void CreateRuntimeMenuItem(OptionMenu menuData)
{
if (menuData is ExecuteMenu)
if (menuData is ExecuteMenu executeMenu)
{
ExecuteMenu executeMenu = (ExecuteMenu)menuData;
var menuUI = Instantiate(TEMPLATE_EXECUTEITEM.gameObject, TEMPLATE_EXECUTEITEM.transform.parent).GetComponent<OptionUI_ExecuteItem>();
menuUI.gameObject.SetActive(true);
menuUI.SetData(this, executeMenu);
m_runtimeMenuItems.Add(menuUI);
}
else if (menuData is ValueSetMenu)
else if (menuData is ValueSetMenu valueSetMenu)
{
var valueSetMenu = (ValueSetMenu)menuData;
var menuUI = Instantiate(TEMPLATE_VALUEEDITITEM.gameObject, TEMPLATE_VALUEEDITITEM.transform.parent).GetComponent<OptionUI_ValueEditItem>();
menuUI.gameObject.SetActive(true);
menuUI.SetData(this, valueSetMenu);

View File

@ -17,9 +17,8 @@ namespace AxibugEmuOnline.Client
com_floatEdit.gameObject.SetActive(false);
com_enumEdit.gameObject.SetActive(false);
if (menuData is ValueSetMenu)
if (menuData is ValueSetMenu valueMenu)
{
var valueMenu = (ValueSetMenu)menuData;
if (valueMenu.ValueType == typeof(float))
{
m_currentCom = com_floatEdit;

View File

@ -18,11 +18,11 @@ namespace AxibugEmuOnline.Client
protected override void OnShow(object param)
{
ValueTuple<Action<string>, string, string> t = (ValueTuple<Action<string>, string, string>)param;
(Action<string> callback, string placeHolder, string defaultText) t = ((Action<string> callback, string placeHolder, string defaultText))param;
OnCommit = t.Item1;
(m_input.placeholder as Text).text = t.Item2;
m_input.text = t.Item3;
OnCommit = t.callback;
(m_input.placeholder as Text).text = t.placeHolder;
m_input.text = t.defaultText;
}
protected override void Update()

View File

@ -22,7 +22,7 @@ namespace AxibugEmuOnline.Client
public static InputUI Input(Action<string> callback, string placeHolder, string defaultText)
{
s_ins.m_InputUI.Show(new ValueTuple<Action<string>, string, string>(callback, placeHolder, defaultText));
s_ins.m_InputUI.Show((callback, placeHolder, defaultText));
return s_ins.m_InputUI;
}

View File

@ -32,8 +32,7 @@ namespace AxibugEmuOnline.Client
{
if (this.RoomID != roomID) return;
Protobuf_Room_MiniInfo roomInfo;
if (App.roomMgr.GetRoomListMiniInfo(roomID, out roomInfo))
if (App.roomMgr.GetRoomListMiniInfo(roomID, out var roomInfo))
UpdateUI(roomInfo);
}
@ -58,14 +57,13 @@ namespace AxibugEmuOnline.Client
}
else
{
Protobuf_Room_MiniInfo MiniInfo;
if (!App.roomMgr.GetRoomListMiniInfo(RoomID, out MiniInfo))
if (!App.roomMgr.GetRoomListMiniInfo(RoomID, out Protobuf_Room_MiniInfo MiniInfo))
{
OverlayManager.PopTip("房间不存在");
return false;
}
int[] freeSlots;
if (!MiniInfo.GetFreeSlot(out freeSlots))
if (!MiniInfo.GetFreeSlot(out var freeSlots))
{
OverlayManager.PopTip("无空闲位置");
return false;
@ -79,9 +77,7 @@ namespace AxibugEmuOnline.Client
private void UpdateUI(Protobuf_Room_MiniInfo roomInfo)
{
var hostNick = roomInfo.GetHostNickName();
int cur; int max;
roomInfo.GetRoomPlayers(out cur, out max);
roomInfo.GetRoomPlayers(out var cur, out var max);
SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}");
SetIcon(null);
@ -133,7 +129,7 @@ namespace AxibugEmuOnline.Client
public void SetDependencyProperty(object data)
{
SetSelectState((data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index));
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
}
public void Release()

View File

@ -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;
}
}

View File

@ -184,10 +184,6 @@ namespace AxibugEmuOnline.Client
private MenuItem Clone(MenuItem template, Transform parent)
{
#if UNITY_EDITOR
//========================套娃宏========================
#if UNITY_2019_1_OR_NEWER //新版Unity因UNITY2018.2用不了这玩意儿,编辑器也罢
if (Application.isPlaying)
{
var item = GameObject.Instantiate(template.gameObject, parent).GetComponent<MenuItem>();
@ -200,15 +196,6 @@ namespace AxibugEmuOnline.Client
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========================
#else
return GameObject.Instantiate(SubMenuItemTemplate.gameObject, parent).GetComponent<MenuItem>();
#endif

View File

@ -9,8 +9,7 @@ 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))
if (_caches.TryGetValue(graphic, out var material))
{
return material;
}

View File

@ -34,10 +34,7 @@ public class XMBInfoBar : MonoBehaviour
RefreshFps();
}
/// <summary>
/// (uint lastFrame, float lastTime)
/// </summary>
ValueTuple<uint,float> m_lastFrameInfo;
(uint lastFrame, float lastTime) m_lastFrameInfo;
private void RefreshFps()
{
if (App.emu.Core.IsNull())
@ -45,17 +42,13 @@ 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 gap = App.emu.Core.Frame - m_lastFrameInfo.Item1;
var time = Time.realtimeSinceStartup - m_lastFrameInfo.Item2;
var gap = App.emu.Core.Frame - m_lastFrameInfo.lastFrame;
var time = Time.realtimeSinceStartup - m_lastFrameInfo.lastTime;
var fps = gap / time;
FPS.text = $"FPS:{fps:.#}";
//m_lastFrameInfo.lastFrame = App.emu.Core.Frame;
//m_lastFrameInfo.lastTime = Time.realtimeSinceStartup;
m_lastFrameInfo.Item1 = App.emu.Core.Frame;
m_lastFrameInfo.Item2 = Time.realtimeSinceStartup;
m_lastFrameInfo.lastFrame = App.emu.Core.Frame;
m_lastFrameInfo.lastTime = Time.realtimeSinceStartup;
}
}

View File

@ -36,9 +36,7 @@ namespace AxibugEmuOnline.Client
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, EnumPlatform platform, Action<Protobuf_Room_MiniInfo, RomFile> callback)
{
RomFile romFile;
if (s_RomFileCahcesInRoomInfo.TryGetValue(roomInfo.GameRomID, out romFile))
if (s_RomFileCahcesInRoomInfo.TryGetValue(roomInfo.GameRomID, out RomFile romFile))
{
callback.Invoke(roomInfo, romFile);
return;
@ -48,11 +46,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;
}