using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.Event; using System; namespace AxibugEmuOnline.Client { public class RoomListMenuItem : VirtualSubMenuItem { bool m_entering; protected override void Awake() { Eventer.Instance.RegisterEvent(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll); Eventer.Instance.RegisterEvent(EEvent.OnRoomListSingleClose, OnRoomClosed); Eventer.Instance.RegisterEvent(EEvent.OnRoomListSingleAdd, OnRoomSingleAdd); base.Awake(); } protected override void OnDestroy() { Eventer.Instance.UnregisterEvent(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll); Eventer.Instance.UnregisterEvent(EEvent.OnRoomListSingleUpdate, OnRoomSingleAdd); Eventer.Instance.UnregisterEvent(EEvent.OnRoomListSingleClose, OnRoomClosed); } 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 OnRoomSingleAdd(int obj) { if (m_entering) { RefreshUI(); } } private void OnRoomListUpdateAll(int obj) { if (m_entering) { RefreshUI(); } } private void OnRoomClosed(int obj) { if (m_entering) { RefreshUI(); } } protected override void GetVirtualListDatas(Action datas) { var roomList = App.roomMgr.GetRoomList(); datas.Invoke(roomList); } } }