AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/UI/RoomListMenuItem.cs

62 lines
1.6 KiB
C#
Raw Normal View History

2024-09-18 15:53:58 +08:00
using AxibugEmuOnline.Client.ClientCore;
2024-11-07 19:18:50 +08:00
using AxibugEmuOnline.Client.Event;
2024-09-18 15:53:58 +08:00
using System;
namespace AxibugEmuOnline.Client
{
public class RoomListMenuItem : VirtualSubMenuItem
{
2024-11-07 19:18:50 +08:00
bool m_entering;
protected override void Awake()
2024-09-18 15:53:58 +08:00
{
2024-11-07 19:18:50 +08:00
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll);
2024-11-07 19:38:48 +08:00
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListSingleClose, OnRoomClosed);
2024-11-07 19:23:59 +08:00
base.Awake();
}
2024-11-07 19:38:48 +08:00
2024-11-07 19:23:59 +08:00
protected override void OnDestroy()
{
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll);
2024-11-07 19:38:48 +08:00
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomListSingleClose, OnRoomClosed);
2024-09-18 15:53:58 +08:00
}
2024-11-07 19:18:50 +08:00
public override bool OnEnterItem()
2024-09-18 15:53:58 +08:00
{
2024-11-07 19:18:50 +08:00
var res = base.OnEnterItem();
if (res) m_entering = true;
return res;
}
2024-09-18 15:53:58 +08:00
2024-11-07 19:18:50 +08:00
public override bool OnExitItem()
{
var res = base.OnExitItem();
if (res) m_entering = false;
return res;
}
2024-09-18 15:53:58 +08:00
2024-11-07 19:18:50 +08:00
private void OnRoomListUpdateAll(int obj)
{
if (m_entering)
{
RefreshUI();
}
}
2024-11-07 19:38:48 +08:00
private void OnRoomClosed(int obj)
{
if (m_entering)
{
RefreshUI();
}
}
2024-09-18 15:53:58 +08:00
2024-11-07 19:18:50 +08:00
protected override void GetVirtualListDatas(Action<object> datas)
{
var roomList = App.roomMgr.GetRoomList();
datas.Invoke(roomList);
2024-09-18 15:53:58 +08:00
}
2024-11-07 19:18:50 +08:00
2024-09-18 15:53:58 +08:00
}
}