提交修改

This commit is contained in:
2025-10-11 17:55:09 +08:00
parent 939d3d81fc
commit d99f361f2e
194 changed files with 186 additions and 9533 deletions

View File

@@ -17,6 +17,7 @@ namespace NBF
UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu));
UIObjectFactory.SetPackageItemExtension(MarqueeTag.URL, typeof(MarqueeTag));
UIObjectFactory.SetPackageItemExtension(BtnTextInputControl.URL, typeof(BtnTextInputControl));
UIObjectFactory.SetPackageItemExtension(CommonItemList.URL, typeof(CommonItemList));
UIObjectFactory.SetPackageItemExtension(BtnTitleInputControl.URL, typeof(BtnTitleInputControl));
UIObjectFactory.SetPackageItemExtension(NoticeItem.URL, typeof(NoticeItem));
UIObjectFactory.SetPackageItemExtension(CommonSubMenu.URL, typeof(CommonSubMenu));

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace NBF
{
public static class ItemDataHelper
{
public static List<TabItemData> GetItemTabDataList<T>(List<T> list) where T : class
{
List<TabItemData> ret = new List<TabItemData>();
return ret;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ea59c591744a47729f78e4984cea1675
timeCreated: 1760170968

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fc2f77f68cda4a9c9d7353fc536d2443
timeCreated: 1760148550

View File

@@ -0,0 +1,31 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class CommonItemList
{
public const string URL = "ui://6hgkvlaup1fps";
public Controller style;
public CommonMenu Menu;
public CommonSubMenu SubMenu;
public ClassifyList List;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
style = GetController("style");
Menu = (CommonMenu)GetChild("Menu");
SubMenu = (CommonSubMenu)GetChild("SubMenu");
List = (ClassifyList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 28dc4cb333840804fb479364c41ad525

View File

@@ -0,0 +1,73 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class CommonItemList : GComponent
{
private List<TabItemData> _tabList = new List<TabItemData>();
private TabItemData _currentTab;
private void OnInited()
{
Menu.OnTabChange += ChangeTab;
SubMenu.OnTabChange += ChangeSubTab;
List.OnClickItem += OnClickItem;
}
public override void Dispose()
{
Menu.OnTabChange -= ChangeTab;
SubMenu.OnTabChange -= ChangeSubTab;
List.OnClickItem -= OnClickItem;
base.Dispose();
}
public void SetData<T>(List<T> list) where T : class
{
_tabList.Clear();
_currentTab = null;
var tabList = ItemDataHelper.GetItemTabDataList(list);
style.selectedIndex = 0; //一级菜单
foreach (var tabItemData in tabList)
{
if (tabItemData.Children.Count > 0)
{
style.selectedIndex = 1; //有二级菜单
break;
}
}
_tabList.AddRange(tabList);
}
private void ChangeTab(int index)
{
var tabListData = _tabList[index];
_currentTab = tabListData;
if (style.selectedIndex == 0)
{
//只有一级菜单
List.SetListData(_currentTab.Items);
}
else
{
SubMenu.SetTabs(_currentTab.Children);
}
}
private void ChangeSubTab(int index)
{
var subList = _currentTab.Children[index];
List.SetListData(subList.Items);
}
private void OnClickItem(object item)
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cb564f321c6947e45a44cdd07cd48a8b

View File

@@ -39,7 +39,7 @@ namespace NBF
}
}
public void SetTabs<T>(List<T> tabList, int selectIndex = 0) where T : TabListData
public void SetTabs(List<TabItemData> tabList, int selectIndex = 0)
{
List.RemoveChildrenToPool();
var listWidth = 0f;
@@ -47,14 +47,7 @@ namespace NBF
{
var tabData = tabList[i];
var tabItem = List.AddItemFromPool().asButton;
if (!string.IsNullOrEmpty(tabData.Key))
{
tabItem.SetLanguage(tabData.Key);
}
else
{
tabItem.SetLanguage(tabData.Name);
}
tabItem.SetLanguage(tabData.Key);
listWidth += tabItem.width;
if (i > 0)

View File

@@ -39,7 +39,7 @@ namespace NBF
}
}
public void SetTabs(List<TabSubItemData> subItems, int selectIndex = 0)
public void SetTabs(List<TabItemData> subItems, int selectIndex = 0)
{
List.RemoveChildrenToPool();
var width = 0f;
@@ -47,7 +47,8 @@ namespace NBF
{
var tabData = subItems[i];
var tabItem = List.AddItemFromPool().asButton;
tabItem.SetLanguage(tabData.Name);
tabItem.SetLanguage(tabData.Key);
width += tabItem.width;
if (i > 0)
{

View File

@@ -16,14 +16,14 @@ namespace NBF
private HomePageBase _currentPage;
private List<TabListData> tabList = new List<TabListData>();
private List<TabItemData> tabList = new List<TabItemData>();
protected override void OnInit()
{
base.OnInit();
foreach (var group in PageNames)
{
var tab = new TabListData
var tab = new TabItemData
{
Name = group
};

View File

@@ -13,7 +13,7 @@ namespace NBF
[UIBind(UIDef.ID.SettingPanel)]
public partial class SettingPanel : UIPanel
{
private readonly List<TabListData> tabList = new List<TabListData>();
private readonly List<TabItemData> tabList = new List<TabItemData>();
private string _currentTab = "";
private List<int> _canSelectIndex = new List<int>();
private int _nowSelectIndex = -1;
@@ -27,9 +27,8 @@ namespace NBF
var groupNames = Settings.Instance.GetAllTabs();
foreach (var group in groupNames)
{
var tab = new TabListData
var tab = new TabItemData
{
Name = group,
Key = $"TEXT_SETTINGS_{group}"
};
tabList.Add(tab);
@@ -53,7 +52,7 @@ namespace NBF
if (index < 0) return;
Log.Info($"Change tab index={index}");
var tabListData = tabList[index];
_currentTab = tabListData.Name;
_currentTab = tabListData.Key;
ResetSettingList();
}

View File

@@ -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); }

View File

@@ -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;
}
}
}