master #40

Merged
sin365 merged 4 commits from Alienjack/AxibugEmuOnline:master into master 2024-11-07 19:42:15 +08:00
3 changed files with 56 additions and 19 deletions
Showing only changes of commit 12716c77c8 - Show all commits

View File

@ -204,12 +204,12 @@ namespace AxibugEmuOnline.Client.Manager
if (msg.UpdateType == 0)
{
AddOrUpdateRoomList(msg.RoomMiniInfo);
Eventer.Instance.PostEvent(EEvent.OnRoomListSingleUpdate, msg.RoomMiniInfo.GameRomID);
Eventer.Instance.PostEvent(EEvent.OnRoomListSingleUpdate, msg.RoomMiniInfo.RoomID);
}
else
{
RemoveRoomList(msg.RoomMiniInfo.GameRomID);
Eventer.Instance.PostEvent(EEvent.OnRoomListSingleClose, msg.RoomMiniInfo.GameRomID);
RemoveRoomList(msg.RoomMiniInfo.RoomID);
Eventer.Instance.PostEvent(EEvent.OnRoomListSingleClose, msg.RoomMiniInfo.RoomID);
}
}

View File

@ -1,7 +1,7 @@
using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.Event;
using AxibugEmuOnline.Client.UI;
using AxibugProtobuf;
using System;
using UnityEngine;
using UnityEngine.UI;
@ -21,28 +21,55 @@ namespace AxibugEmuOnline.Client
private RomFile m_romFile;
public int Index { get; set; }
public int roomID { get; private set; }
protected override void Awake()
{
base.Awake();
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListSingleUpdate, OnRoomSingleUpdate);
}
protected override void OnDestroy()
{
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomListSingleUpdate, OnRoomSingleUpdate);
}
private void OnRoomSingleUpdate(int roomId)
{
if (roomId != roomID) return;
if (App.roomMgr.GetRoomListMiniInfo(roomId, out var roomInfo))
{
UpdateUI(roomInfo);
}
}
public void SetData(object data)
{
if (data is Protobuf_Room_MiniInfo roomInfo)
var roomInfo = data as Protobuf_Room_MiniInfo;
roomID = roomInfo.RoomID;
UpdateUI(roomInfo);
}
private void UpdateUI(Protobuf_Room_MiniInfo roomInfo)
{
var hostNick = roomInfo.GetHostNickName();
roomInfo.GetRoomPlayers(out var cur, out var max);
SetBaseInfo(string.Empty, $"<b>{hostNick}</b>µÄ·¿¼ä - {cur}/{max}");
SetIcon(null);
roomInfo.FetchRomFileInRoomInfo(EnumPlatform.NES, (romFile) =>
{
var hostNick = roomInfo.GetHostNickName();
roomInfo.GetRoomPlayers(out var cur, out var max);
SetBaseInfo(string.Empty, $"<b>{hostNick}</b>ľÄˇżźä - {cur}/{max}");
SetIcon(null);
m_romFile = romFile;
roomInfo.FetchRomFileInRoomInfo(EnumPlatform.NES, (romFile) =>
{
m_romFile = romFile;
if (romFile.ID == roomInfo.GameRomID)
Txt.text = romFile.Alias;
if (romFile.ID == roomInfo.GameRomID)
Txt.text = romFile.Alias;
UpdateRomInfoView();
App.CacheMgr.GetSpriteCache(romFile.ImageURL, OnGetRomImage);
});
}
UpdateRomInfoView();
App.CacheMgr.GetSpriteCache(romFile.ImageURL, OnGetRomImage);
});
}
private void Update()

View File

@ -11,12 +11,15 @@ namespace AxibugEmuOnline.Client
protected override void Awake()
{
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll);
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomListSingleClose, OnRoomClosed);
base.Awake();
}
protected override void OnDestroy()
{
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomListAllUpdate, OnRoomListUpdateAll);
Eventer.Instance.UnregisterEvent<int>(EEvent.OnRoomListSingleClose, OnRoomClosed);
}
public override bool OnEnterItem()
@ -40,6 +43,13 @@ namespace AxibugEmuOnline.Client
RefreshUI();
}
}
private void OnRoomClosed(int obj)
{
if (m_entering)
{
RefreshUI();
}
}
protected override void GetVirtualListDatas(Action<object> datas)
{