2024-09-18 15:53:58 +08:00
|
|
|
|
using AxibugEmuOnline.Client.ClientCore;
|
|
|
|
|
using System;
|
2024-11-13 13:55:36 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-08-22 15:16:58 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace AxibugEmuOnline.Client
|
|
|
|
|
{
|
2024-09-18 15:53:58 +08:00
|
|
|
|
public class RomListMenuItem : VirtualSubMenuItem
|
2024-08-22 15:16:58 +08:00
|
|
|
|
{
|
|
|
|
|
[SerializeField]
|
2024-09-18 15:53:58 +08:00
|
|
|
|
protected EnumPlatform Platform;
|
2024-08-22 15:16:58 +08:00
|
|
|
|
|
2024-09-12 11:34:32 +08:00
|
|
|
|
private RomLib RomLib
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
switch (Platform)
|
|
|
|
|
{
|
|
|
|
|
case EnumPlatform.NES:
|
|
|
|
|
return App.nesRomLib;
|
|
|
|
|
default:
|
|
|
|
|
throw new System.NotImplementedException($"δʵ<CEB4>ֵ<EFBFBD>ƽ̨ {Platform}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-13 13:55:36 +08:00
|
|
|
|
private List<OptionMenu> m_options;
|
|
|
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
{
|
|
|
|
|
base.Awake();
|
|
|
|
|
|
|
|
|
|
m_options = new List<OptionMenu>()
|
|
|
|
|
{
|
|
|
|
|
new OptMenu_Search(this),
|
|
|
|
|
new OptMenu_ShowAll(this),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SearchKey;
|
2024-09-18 15:53:58 +08:00
|
|
|
|
protected override void GetVirtualListDatas(Action<object> datas)
|
2024-08-22 15:16:58 +08:00
|
|
|
|
{
|
2024-11-13 13:55:36 +08:00
|
|
|
|
RomLib.FetchRomCount((roms) => datas.Invoke(roms), SearchKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnEnterItem()
|
|
|
|
|
{
|
|
|
|
|
var res = base.OnEnterItem();
|
|
|
|
|
if (res) CommandDispatcher.Instance.RegistController(this);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnExitItem()
|
|
|
|
|
{
|
|
|
|
|
var res = base.OnExitItem();
|
|
|
|
|
if (res) CommandDispatcher.Instance.UnRegistController(this);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnCmdOptionMenu()
|
|
|
|
|
{
|
|
|
|
|
OptionUI.Instance.Pop(m_options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class OptMenu_Search : ExecuteMenu
|
|
|
|
|
{
|
|
|
|
|
private RomListMenuItem m_romListUI;
|
|
|
|
|
|
|
|
|
|
public OptMenu_Search(RomListMenuItem romListUI, Sprite icon = null) : base("<22><><EFBFBD><EFBFBD>", icon)
|
|
|
|
|
{
|
|
|
|
|
m_romListUI = romListUI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnExcute()
|
|
|
|
|
{
|
2024-11-15 10:53:19 +08:00
|
|
|
|
OverlayManager.Input((OnSearchCommit, "<22><><EFBFBD><EFBFBD>Rom<6F><6D><EFBFBD><EFBFBD>", m_romListUI.SearchKey));
|
2024-11-13 13:55:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSearchCommit(string text)
|
|
|
|
|
{
|
|
|
|
|
m_romListUI.SearchKey = text;
|
|
|
|
|
m_romListUI.RefreshUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class OptMenu_ShowAll : ExecuteMenu
|
|
|
|
|
{
|
|
|
|
|
private RomListMenuItem m_ui;
|
|
|
|
|
|
|
|
|
|
public override bool Visible => !string.IsNullOrWhiteSpace(m_ui.SearchKey);
|
|
|
|
|
|
2024-11-15 10:53:19 +08:00
|
|
|
|
public OptMenu_ShowAll(RomListMenuItem romListUI, Sprite icon = null) : base("<22><>ʾȫ<CABE><C8AB>", icon)
|
2024-11-13 13:55:36 +08:00
|
|
|
|
{
|
|
|
|
|
m_ui = romListUI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnExcute()
|
|
|
|
|
{
|
|
|
|
|
m_ui.SearchKey = null;
|
|
|
|
|
m_ui.RefreshUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-22 15:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|