提交修改
This commit is contained in:
@@ -14,16 +14,12 @@ namespace NBF
|
||||
public override string UIPackName => "Shop";
|
||||
public override string UIResName => "FishingShopPanel";
|
||||
|
||||
[AutoFind(Name = "Menu")]
|
||||
public CommonMenu Menu;
|
||||
[AutoFind(Name = "SubMenu")]
|
||||
public CommonSubMenu SubMenu;
|
||||
[AutoFind(Name = "List")]
|
||||
public ClassifyList List;
|
||||
[AutoFind(Name = "Currencys")]
|
||||
public GComponent Currencys;
|
||||
[AutoFind(Name = "BottomMenu")]
|
||||
public BottomMenu BottomMenu;
|
||||
[AutoFind(Name = "ItemList")]
|
||||
public CommonItemList ItemList;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common"}; }
|
||||
|
||||
public static void Show(object param = null){ App.UI.OpenUI<FishingShopPanel>(param); }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
using NUnit.Framework;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
@@ -10,35 +11,38 @@ namespace NBF
|
||||
public class ShopGearData
|
||||
{
|
||||
public string title;
|
||||
public int type;
|
||||
public int subType;
|
||||
}
|
||||
|
||||
public partial class FishingShopPanel : UIPanel
|
||||
{
|
||||
private List<TabListAndSubListData> _tabList = new List<TabListAndSubListData>();
|
||||
private TabListAndSubListData _currentTab;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
this.AutoAddClick(OnClick);
|
||||
IsShowCursor = true;
|
||||
|
||||
var testData = new List<ShopGearData>();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var itemData = new TabListAndSubListData();
|
||||
itemData.AddTestData(i);
|
||||
_tabList.Add(itemData);
|
||||
for (int j = 20; j < 25; j++)
|
||||
{
|
||||
var item = new ShopGearData
|
||||
{
|
||||
type = i,
|
||||
subType = j
|
||||
};
|
||||
testData.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
Menu.OnTabChange += ChangeTab;
|
||||
SubMenu.OnTabChange += ChangeSubTab;
|
||||
List.OnClickItem += OnClickItem;
|
||||
ItemList.SetData(testData);
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
Menu.SetTabs(_tabList);
|
||||
UseBottomMenu();
|
||||
}
|
||||
|
||||
@@ -48,20 +52,6 @@ namespace NBF
|
||||
}
|
||||
|
||||
|
||||
private void ChangeTab(int index)
|
||||
{
|
||||
Log.Info($"Change tab index={index}");
|
||||
var tabListData = _tabList[index];
|
||||
_currentTab = tabListData;
|
||||
SubMenu.SetTabs(_currentTab.SubTab);
|
||||
}
|
||||
|
||||
private void ChangeSubTab(int index)
|
||||
{
|
||||
var subList = _currentTab.SubTab[index];
|
||||
List.SetListData(subList.Items);
|
||||
}
|
||||
|
||||
private void OnClickItem(object item)
|
||||
{
|
||||
if (item is not ShopGearItem shopGearItem) return;
|
||||
@@ -79,8 +69,6 @@ namespace NBF
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
Menu.OnTabChange -= ChangeTab;
|
||||
SubMenu.OnTabChange -= ChangeSubTab;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user