新增菜单all和列表标题功能
This commit is contained in:
@@ -8,6 +8,11 @@ using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class ClassifyListTitleData
|
||||
{
|
||||
public string Title;
|
||||
}
|
||||
|
||||
public partial class ClassifyList : GComponent
|
||||
{
|
||||
private readonly List<object> _listData = new List<object>();
|
||||
@@ -19,6 +24,10 @@ namespace NBF
|
||||
private void OnInited()
|
||||
{
|
||||
Game.Input.OnUICanceled += OnUICanceled;
|
||||
List.defaultItem = ListTitleItem.URL;
|
||||
List.itemProvider = GetListItemResource;
|
||||
List.itemRenderer = OnRenderItem;
|
||||
List.onClickItem.Add(OnClickListItem);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
@@ -67,18 +76,13 @@ namespace NBF
|
||||
ListSelectionMode selectionMode = ListSelectionMode.Single)
|
||||
{
|
||||
List.selectedIndex = -1;
|
||||
List.defaultItem = ListTitleItem.URL;
|
||||
List.itemProvider = GetListItemResource;
|
||||
List.itemRenderer = OnRenderItem;
|
||||
List.onClickItem.Add(OnClickListItem);
|
||||
// List.SetVirtual();
|
||||
_listData.Clear();
|
||||
|
||||
foreach (var obj in listData)
|
||||
{
|
||||
_listData.Add(obj);
|
||||
}
|
||||
|
||||
List.RemoveChildrenToPool();
|
||||
List.selectionMode = selectionMode;
|
||||
List.numItems = _listData.Count;
|
||||
List.ScrollToView(0);
|
||||
@@ -92,17 +96,19 @@ namespace NBF
|
||||
|
||||
void OnRenderItem(int index, GObject obj)
|
||||
{
|
||||
var itemData = _listData[index];
|
||||
if (obj is ListItemBase item)
|
||||
{
|
||||
item.SetData(_listData[index]);
|
||||
item.SetData(itemData);
|
||||
obj.SetSize(350, 300);
|
||||
}
|
||||
else if (obj is ListTitleItem titleItem)
|
||||
{
|
||||
titleItem.SetData(itemData);
|
||||
titleItem.SetSize(List.width, 32);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//根据索引的不同,返回不同的资源URL
|
||||
string GetListItemResource(int index)
|
||||
@@ -114,7 +120,7 @@ namespace NBF
|
||||
return ShopGearItem.URL;
|
||||
}
|
||||
|
||||
if (itemData is string title)
|
||||
if (itemData is ClassifyListTitleData titleData)
|
||||
{
|
||||
return ListTitleItem.URL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user