2024-08-22 17:25:00 +08:00
|
|
|
|
using AxibugEmuOnline.Client.ClientCore;
|
2024-08-22 15:16:58 +08:00
|
|
|
|
using AxibugEmuOnline.Client.UI;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
namespace AxibugEmuOnline.Client
|
|
|
|
|
{
|
2024-09-11 16:33:48 +08:00
|
|
|
|
public class RomItem : MenuItem, IVirtualItem
|
2024-08-22 15:16:58 +08:00
|
|
|
|
{
|
|
|
|
|
[SerializeField]
|
|
|
|
|
Image m_romImage;
|
|
|
|
|
|
2024-09-11 16:33:48 +08:00
|
|
|
|
[SerializeField]
|
|
|
|
|
GameObject DownloadingFlag;
|
|
|
|
|
[SerializeField]
|
|
|
|
|
Slider DownProgress;
|
|
|
|
|
[SerializeField]
|
|
|
|
|
GameObject FileReadyFlag;
|
|
|
|
|
|
2024-08-22 15:16:58 +08:00
|
|
|
|
public int Index { get; set; }
|
|
|
|
|
|
2024-09-11 18:31:25 +08:00
|
|
|
|
private RomLib m_romlib => App.nesRomLib;
|
2024-08-22 15:16:58 +08:00
|
|
|
|
private RomFile m_romfile;
|
|
|
|
|
|
|
|
|
|
public void SetData(object data)
|
|
|
|
|
{
|
2024-09-11 16:33:48 +08:00
|
|
|
|
Reset();
|
|
|
|
|
|
2024-08-22 15:16:58 +08:00
|
|
|
|
m_romfile = (RomFile)data;
|
2024-08-22 17:25:00 +08:00
|
|
|
|
m_romfile.OnInfoFilled += OnRomInfoFilled;
|
|
|
|
|
m_romImage.sprite = null;
|
2024-08-22 15:16:58 +08:00
|
|
|
|
|
|
|
|
|
UpdateView();
|
|
|
|
|
|
|
|
|
|
if (!m_romfile.InfoReady)
|
|
|
|
|
{
|
|
|
|
|
m_romlib.BeginFetchRomInfo(m_romfile);
|
|
|
|
|
}
|
2024-08-30 16:28:05 +08:00
|
|
|
|
|
|
|
|
|
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
2024-08-22 15:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetDependencyProperty(object data)
|
|
|
|
|
{
|
2024-08-30 16:23:27 +08:00
|
|
|
|
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
2024-08-22 15:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Release()
|
|
|
|
|
{
|
|
|
|
|
m_romfile.OnInfoFilled -= OnRomInfoFilled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnRomInfoFilled()
|
|
|
|
|
{
|
|
|
|
|
UpdateView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateView()
|
|
|
|
|
{
|
|
|
|
|
if (!m_romfile.InfoReady)
|
|
|
|
|
{
|
2024-08-22 17:25:00 +08:00
|
|
|
|
SetBaseInfo(string.Empty, string.Empty);
|
2024-08-22 15:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-08-22 17:25:00 +08:00
|
|
|
|
SetBaseInfo(m_romfile.Alias, m_romfile.Descript);
|
2024-09-11 18:31:25 +08:00
|
|
|
|
App.CacheMgr.GetSpriteCache(m_romfile.ImageURL, (img, url) =>
|
2024-08-22 17:25:00 +08:00
|
|
|
|
{
|
|
|
|
|
if (url != m_romfile.ImageURL) return;
|
|
|
|
|
|
|
|
|
|
m_romImage.sprite = img;
|
|
|
|
|
});
|
2024-08-22 15:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-29 18:31:36 +08:00
|
|
|
|
|
2024-09-11 16:33:48 +08:00
|
|
|
|
public override bool OnEnterItem()
|
2024-08-29 18:31:36 +08:00
|
|
|
|
{
|
|
|
|
|
if (!m_romfile.RomReady)
|
2024-09-11 16:33:48 +08:00
|
|
|
|
{
|
2024-08-29 18:31:36 +08:00
|
|
|
|
m_romfile.BeginDownload();
|
2024-09-11 16:33:48 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-08-29 18:31:36 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2024-09-20 17:10:32 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>û<EFBFBD><C3BB>Լ<EFBFBD><D4BC>ṩ<EFBFBD><E1B9A9>Romʱ,ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//App.emu.BeginGame(App.nesRomLib.GetExistRom("bad_apple_2_5.nes"));
|
2024-09-13 13:28:33 +08:00
|
|
|
|
App.emu.BeginGame(m_romfile);
|
2024-09-11 16:33:48 +08:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
DownloadingFlag.SetActiveEx(false);
|
|
|
|
|
FileReadyFlag.SetActiveEx(false);
|
|
|
|
|
|
|
|
|
|
if (m_romfile == null) return;
|
|
|
|
|
if (!m_romfile.InfoReady) return;
|
|
|
|
|
|
|
|
|
|
if (m_romfile.IsDownloading)
|
|
|
|
|
{
|
|
|
|
|
DownloadingFlag.SetActiveEx(true);
|
|
|
|
|
DownProgress.value = m_romfile.Progress;
|
|
|
|
|
}
|
|
|
|
|
else if (m_romfile.RomReady)
|
|
|
|
|
{
|
|
|
|
|
FileReadyFlag.SetActiveEx(true);
|
2024-08-29 18:31:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-22 15:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|