2025-01-07 11:23:10 +08:00
|
|
|
|
using AxibugEmuOnline.Client.ClientCore;
|
2024-12-11 21:21:27 +08:00
|
|
|
|
using AxibugEmuOnline.Client.Event;
|
2025-01-08 13:30:58 +08:00
|
|
|
|
using UnityEngine;
|
2024-12-11 21:21:27 +08:00
|
|
|
|
|
|
|
|
|
namespace AxibugEmuOnline.Client
|
|
|
|
|
{
|
|
|
|
|
public class RoomListMenuItem : VirtualSubMenuItem
|
|
|
|
|
{
|
|
|
|
|
bool m_entering;
|
|
|
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
{
|
|
|
|
|
Eventer.Instance.RegisterEvent(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll);
|
|
|
|
|
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListSingleClose, OnRoomClosed);
|
|
|
|
|
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListSingleAdd, OnRoomSingleAdd);
|
|
|
|
|
base.Awake();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
Eventer.Instance.UnregisterEvent(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll);
|
|
|
|
|
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomListSingleUpdate, OnRoomSingleAdd);
|
|
|
|
|
Eventer.Instance.UnregisterEvent<int>(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()
|
|
|
|
|
{
|
|
|
|
|
if (m_entering)
|
|
|
|
|
{
|
|
|
|
|
RefreshUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void OnRoomClosed(int obj)
|
|
|
|
|
{
|
|
|
|
|
if (m_entering)
|
|
|
|
|
{
|
|
|
|
|
RefreshUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-07 11:23:10 +08:00
|
|
|
|
protected override void GetVirtualListDatas(VirtualListDataHandle callback)
|
2024-12-11 21:21:27 +08:00
|
|
|
|
{
|
|
|
|
|
var roomList = App.roomMgr.GetRoomList();
|
2025-01-07 11:23:10 +08:00
|
|
|
|
callback.Invoke(roomList, 0);
|
2024-12-11 21:21:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|