From 9f732c7719d09e732a7168b919b29ade2e060356 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Thu, 7 Nov 2024 19:18:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=88=97=E8=A1=A8=E8=8E=B7?= =?UTF-8?q?=E5=8F=96,=E8=B0=83=E7=94=A8=E5=AE=9E=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/Manager/AppRoom.cs | 2 +- .../Script/UI/InGameUI/InGameUI_LoadState.cs | 11 ++-- .../Script/UI/ItemPresent/ItemPresent.cs | 1 + .../Assets/Script/UI/RoomListMenuItem.cs | 53 +++++++++++-------- .../Assets/Script/UI/ThirdMenuRoot.cs | 9 ++-- .../Assets/Script/UI/VirtualSubMenuItem.cs | 21 ++++---- 6 files changed, 58 insertions(+), 39 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs index e779df2..ff47973 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs @@ -89,7 +89,7 @@ namespace AxibugEmuOnline.Client.Manager List result = new List(); foreach (var item in dictRoomListID2Info) { - result.Add(new Protobuf_Room_MiniInfo()); + result.Add(item.Value); } return result; } diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/InGameUI/InGameUI_LoadState.cs b/AxibugEmuOnline.Client/Assets/Script/UI/InGameUI/InGameUI_LoadState.cs index 9f33a2a..2c764ad 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/InGameUI/InGameUI_LoadState.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/InGameUI/InGameUI_LoadState.cs @@ -1,6 +1,5 @@ using AxibugEmuOnline.Client.ClientCore; using System.Diagnostics; -using VirtualNes.Core; namespace AxibugEmuOnline.Client { @@ -16,10 +15,14 @@ namespace AxibugEmuOnline.Client public override void OnExcute() { + object state = m_gameUI.GetQuickState(); Stopwatch sw = Stopwatch.StartNew(); - m_gameUI.Core.LoadState(m_gameUI.GetQuickState()); - sw.Stop(); - App.log.Info($"{m_gameUI.RomFile.Platform}====>快照加载耗时:{sw.Elapsed.TotalMilliseconds}ms"); + if (state != null) + { + m_gameUI.Core.LoadState(state); + sw.Stop(); + App.log.Info($"{m_gameUI.RomFile.Platform}====>快照加载耗时:{sw.Elapsed.TotalMilliseconds}ms"); + } } } } diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/ItemPresent/ItemPresent.cs b/AxibugEmuOnline.Client/Assets/Script/UI/ItemPresent/ItemPresent.cs index 6809350..93f3eb8 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/ItemPresent/ItemPresent.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/ItemPresent/ItemPresent.cs @@ -517,6 +517,7 @@ public class ItemPresent : GridLayoutGroup, IVirtualLayout } public RectTransform GetItemUIIfExist(int index) { + if (index < 0) return null; if (children.Count <= index) return null; var proxy = children[index]; diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/RoomListMenuItem.cs b/AxibugEmuOnline.Client/Assets/Script/UI/RoomListMenuItem.cs index a946a85..ee56588 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/RoomListMenuItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/RoomListMenuItem.cs @@ -1,34 +1,45 @@ using AxibugEmuOnline.Client.ClientCore; -using AxibugProtobuf; +using AxibugEmuOnline.Client.Event; using System; -using System.Collections; -using System.Collections.Generic; namespace AxibugEmuOnline.Client { public class RoomListMenuItem : VirtualSubMenuItem { + bool m_entering; + + protected override void Awake() + { + Eventer.Instance.RegisterEvent(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll); + } + + public override bool OnEnterItem() + { + var res = base.OnEnterItem(); + if (res) m_entering = true; + return res; + } + + public override bool OnExitItem() + { + var res = base.OnExitItem(); + if (res) m_entering = false; + return res; + } + + private void OnRoomListUpdateAll(int obj) + { + if (m_entering) + { + RefreshUI(); + } + } + protected override void GetVirtualListDatas(Action datas) { - App.StartCoroutine(Test(datas)); + var roomList = App.roomMgr.GetRoomList(); + datas.Invoke(roomList); } - private IEnumerator Test(Action datas) - { - yield return null; - - List fakeData = new List() - { - new Protobuf_Room_MiniInfo{ GameRomID = 1, RoomID = 1, HostPlayerUID = 1, Player1UID = 1, Player1NickName = "Test1"}, - new Protobuf_Room_MiniInfo{ GameRomID = 2, RoomID = 2, HostPlayerUID = 2, Player1UID = 2, Player1NickName = "Test2"}, - new Protobuf_Room_MiniInfo{ GameRomID = 3, RoomID = 3, HostPlayerUID = 3, Player1UID = 3, Player1NickName = "Test3"}, - new Protobuf_Room_MiniInfo{ GameRomID = 4, RoomID = 4, HostPlayerUID = 4, Player1UID = 4, Player1NickName = "Test4"}, - new Protobuf_Room_MiniInfo{ GameRomID = 5, RoomID = 5, HostPlayerUID = 5, Player1UID = 5, Player1NickName = "Test5"}, - }; - - datas.Invoke(fakeData); - - yield break; - } } } diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/ThirdMenuRoot.cs b/AxibugEmuOnline.Client/Assets/Script/UI/ThirdMenuRoot.cs index cee8137..5b7a3fb 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/ThirdMenuRoot.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/ThirdMenuRoot.cs @@ -47,7 +47,7 @@ namespace AxibugEmuOnline.Client protected override MenuItem GetItemUIByIndex(int index) { - return itemGroup.GetItemUIByDataIndex(index).GetComponent(); + return itemGroup.GetItemUIByDataIndex(index)?.GetComponent(); } protected override void Awake() @@ -63,13 +63,16 @@ namespace AxibugEmuOnline.Client protected override bool OnCmdEnter() { var item = GetItemUIByIndex(SelectIndex); - return item.OnEnterItem(); + if (item != null) + return item.OnEnterItem(); + else + return true; } protected override void OnCmdBack() { var item = GetItemUIByIndex(SelectIndex); - item.OnExitItem(); + item?.OnExitItem(); } private void LateUpdate() diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/VirtualSubMenuItem.cs b/AxibugEmuOnline.Client/Assets/Script/UI/VirtualSubMenuItem.cs index 9f91878..9721a82 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/VirtualSubMenuItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/VirtualSubMenuItem.cs @@ -3,11 +3,7 @@ using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using System; -using System.Collections; -using System.Collections.Generic; using UnityEngine; -using VirtualNes.Core; -using App = AxibugEmuOnline.Client.ClientCore.App; namespace AxibugEmuOnline.Client { @@ -15,7 +11,7 @@ namespace AxibugEmuOnline.Client { [SerializeField] protected CanvasGroup RomGroupRoot; - + private TweenerCore m_showTween; @@ -60,7 +56,16 @@ namespace AxibugEmuOnline.Client var thirdMenuGroup = SubMenuItemGroup as ThirdMenuRoot; thirdMenuGroup.itemGroup.Clear(); - + + RefreshUI(); + + if (SubMenuItemGroup != null) SubMenuItemGroup.SetSelect(true); + + return true; + } + + protected void RefreshUI() + { GetVirtualListDatas((datas) => { var thirdMenuGroup = SubMenuItemGroup as ThirdMenuRoot; @@ -69,10 +74,6 @@ namespace AxibugEmuOnline.Client thirdMenuGroup.itemGroup.UpdateProxyVisualState(); thirdMenuGroup.ResetToFirst(); }); - - if (SubMenuItemGroup != null) SubMenuItemGroup.SetSelect(true); - - return true; } protected abstract void GetVirtualListDatas(Action datas);