快捷键重构

This commit is contained in:
2025-05-25 00:54:06 +08:00
parent d6327c7946
commit 68b88d57db
186 changed files with 2248 additions and 1066 deletions

View File

@@ -8,9 +8,12 @@ namespace NBF
{
public static void BindAll()
{
UIObjectFactory.SetPackageItemExtension(BottomMenu.URL, typeof(BottomMenu));
UIObjectFactory.SetPackageItemExtension(ClassifyList.URL, typeof(ClassifyList));
UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu));
UIObjectFactory.SetPackageItemExtension(ListTitleItem.URL, typeof(ListTitleItem));
UIObjectFactory.SetPackageItemExtension(BtnTitleInputControl.URL, typeof(BtnTitleInputControl));
UIObjectFactory.SetPackageItemExtension(CommonSubMenu.URL, typeof(CommonSubMenu));
UIObjectFactory.SetPackageItemExtension(BtnInputControl.URL, typeof(BtnInputControl));
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e421fb97db2b48ccb37e75b8766265de
timeCreated: 1748071593

View File

@@ -7,17 +7,17 @@ using NBC;
namespace NBF
{
public partial class ListTitleItem
public partial class BtnInputControl
{
public const string URL = "ui://6hgkvlauoomea";
public const string URL = "ui://6hgkvlaur03ut";
public GImage back;
public Controller show;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
back = (GImage)GetChild("back");
show = GetController("show");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}

View File

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

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BtnInputControl : GButton
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9bc3045114c90ef4888ae8cd51aa1e2e

View File

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

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3a4cdcb09978fcd47b043fa05e53e433

View File

@@ -0,0 +1,19 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BtnTitleInputControl : GButton
{
public Action OnAction;
public string ActionName;
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 15ebd24da667f9146bc2cfbfec56a512

View File

@@ -11,18 +11,65 @@ namespace NBF
public partial class ClassifyList : GComponent
{
private readonly List<object> _listData = new List<object>();
public event Action<object> OnClickItem;
private int _columnsCount;
private void OnInited()
{
List.itemProvider = GetListItemResource;
List.itemRenderer = OnRenderItem;
List.onClickItem.Add(OnClickListItem);
InputManager.OnUICanceled += OnUICanceled;
}
public void SetListData(List<object> listData,ListSelectionMode selectionMode = ListSelectionMode.Single)
public override void Dispose()
{
InputManager.OnUICanceled -= OnUICanceled;
base.Dispose();
}
private void OnUICanceled(string action)
{
if (action == InputDef.UI.Right)
{
SetListSelected(List.selectedIndex + 1);
}
else if (action == InputDef.UI.Left)
{
SetListSelected(List.selectedIndex - 1);
}
else if (action == InputDef.UI.Up)
{
SetListSelected(List.selectedIndex - _columnsCount);
}
else if (action == InputDef.UI.Down)
{
if (List.selectedIndex < 0)
{
SetListSelected(0);
}
else
{
SetListSelected(List.selectedIndex + _columnsCount);
}
}
}
private void SetListSelected(int selectedIndex)
{
if (selectedIndex >= 0 && selectedIndex < _listData.Count)
{
List.selectedIndex = selectedIndex;
List.ScrollToView(List.selectedIndex);
}
}
public void SetListData(List<object> listData, ListSelectionMode selectionMode = ListSelectionMode.Single)
{
List.selectedIndex = -1;
List.defaultItem = GetListDefaultItemResource(listData);
List.itemRenderer = OnRenderItem;
List.onClickItem.Add(OnClickListItem);
List.SetVirtual();
_listData.Clear();
foreach (var obj in listData)
{
@@ -32,13 +79,14 @@ namespace NBF
List.selectionMode = selectionMode;
List.numItems = _listData.Count;
List.ScrollToView(0);
_columnsCount = 5;
}
void OnClickListItem(EventContext context)
{
OnClickItem?.Invoke(context.data);
}
void OnRenderItem(int index, GObject obj)
{
if (obj is ListItemBase item)
@@ -48,20 +96,15 @@ namespace NBF
}
//根据索引的不同返回不同的资源URL
string GetListItemResource(int index)
string GetListDefaultItemResource(List<object> listData)
{
var itemData = _listData[index];
if (itemData is ShopGearData shopItem)
var itemData = listData.Find(t => t != null);
if (itemData is ShopGearData)
{
return ShopGearItem.URL;
}
if (itemData is ListClassifyData item)
{
return ListTitleItem.URL;
}
return List.defaultItem;
}
}

View File

@@ -1,46 +0,0 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class CommonMenu : GLabel
{
public event Action OnClose;
public event Action<int> OnTabChange;
private void OnInited()
{
BtnClose.onClick.Add(OnClickClose);
List.onClickItem.Add(OnClickItem);
}
public void SetTabs(List<TabListData> tabList,int selectIndex = 0)
{
List.RemoveChildrenToPool();
for (int i = 0; i < tabList.Count; i++)
{
var tabData = tabList[i];
var tabItem = List.AddItemFromPool().asButton;
tabItem.title = tabData.TabName;
}
Log.Info($"Set tab index={List.selectedIndex}");
List.selectedIndex = selectIndex;
OnClickItem();
}
private void OnClickItem()
{
OnTabChange?.Invoke(List.selectedIndex);
}
private void OnClickClose()
{
OnClose?.Invoke();
}
}
}

View File

@@ -17,7 +17,7 @@ namespace NBF
public GButton BtnOk;
[AutoFind(Name = "Dir")]
public GComboBox Dir;
public override string[] GetDependPackages(){ return new string[] {"Main"}; }
public override string[] GetDependPackages(){ return new string[] {}; }
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 8042079334b43394ca275c4a2189dbfb

View File

@@ -1,27 +0,0 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class ListTitleItem : ListItemBase
{
public ListClassifyData ClassifyData;
private void OnInited()
{
}
protected override void OnSetData(object showData)
{
width = parent.width - 40;
ClassifyData = showData as ListClassifyData;
if (ClassifyData == null)
{
ClassifyData = new ListClassifyData(string.Empty);
}
title = ClassifyData.Title;
}
}
}

View File

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

View File

@@ -1,30 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
namespace NBF
{
public class TabListData
{
public string TabName;
public bool Selected;
public List<object> ListData;
public void AddTestData(int index)
{
ListData = new List<object>();
TabName = $"标题-{index + 1}";
var count1 = Random.Range(5, 10);
var count2 = Random.Range(10, 30);
for (int i = 0; i < count1; i++)
{
ListData.Add(new ListClassifyData($"Title-{i}"));
for (int j = 0; j < count2; j++)
{
var item = new ShopGearData();
item.title = $"Item {i}-" + j;
ListData.Add(item);
}
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 47a09808fe3440d59857224bdc01a91f
timeCreated: 1747970638

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5d49e5e796ac4b4487b72a164e22ba73
timeCreated: 1748093228

View File

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

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 172ed53c6c409e04c8a993c9fae4c820

View File

@@ -0,0 +1,79 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BottomMenu : GComponent
{
public event Action OnBack;
public event Action OnEnter;
public event Action OnTab;
public event Action OnUse;
private void OnInited()
{
List.onClickItem.Add(OnClickItem);
}
private void OnClickItem(EventContext context)
{
var item = context.data as BtnTitleInputControl;
if (item == null) return;
item.OnAction?.Invoke();
}
public void UnUse()
{
OnBack = null;
OnEnter = null;
OnTab = null;
OnUse = null;
InputManager.OnUICanceled -= OnAction;
}
public void Use()
{
List.RemoveChildrenToPool();
LeftList.RemoveChildrenToPool();
InputManager.OnUICanceled += OnAction;
AddButtonItem(OnUse, "");
AddButtonItem(OnTab, InputDef.UI.Tab);
AddButtonItem(OnEnter, InputDef.UI.Enter);
AddButtonItem(OnBack, InputDef.UI.Back);
}
private void AddButtonItem(Action action, string actionName)
{
if (action != null)
{
if (List.AddItemFromPool() is BtnTitleInputControl item)
{
item.OnAction = action;
item.ActionName = actionName;
}
}
}
private void OnAction(string action)
{
var children = List.GetChildren();
foreach (var child in children)
{
if (child is BtnTitleInputControl item)
{
if (action == item.ActionName)
{
item.OnAction?.Invoke();
}
}
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 94c5df4d4f05c2b40ad72c5c90008295

View File

@@ -11,23 +11,19 @@ namespace NBF
{
public const string URL = "ui://6hgkvlaufcfggr";
public GImage LongLine;
public GList List;
public GButton Head;
public GTextField TextName;
public GComponent Currency;
public GButton BtnClose;
public GButton BtnUserHead;
public BtnInputControl BtnPrev;
public BtnInputControl BtnNext;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
LongLine = (GImage)GetChild("LongLine");
List = (GList)GetChild("List");
Head = (GButton)GetChild("Head");
TextName = (GTextField)GetChild("TextName");
Currency = (GComponent)GetChild("Currency");
BtnClose = (GButton)GetChild("BtnClose");
BtnUserHead = (GButton)GetChild("BtnUserHead");
BtnPrev = (BtnInputControl)GetChild("BtnPrev");
BtnNext = (BtnInputControl)GetChild("BtnNext");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}

View File

@@ -0,0 +1,98 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class CommonMenu : GLabel
{
public event Action<int> OnTabChange;
private void OnInited()
{
List.onClickItem.Add(OnClickItem);
BtnPrev.onClick.Add(OnClickBtnPrev);
BtnNext.onClick.Add(OnClickBtnNext);
InputManager.OnUICanceled += OnUICanceled;
}
public override void Dispose()
{
InputManager.OnUICanceled -= OnUICanceled;
base.Dispose();
}
private void OnUICanceled(string action)
{
if (action == InputDef.UI.Prev)
{
OnClickBtnPrev();
}
else if (action == InputDef.UI.Next)
{
OnClickBtnNext();
}
}
public void SetTabs(List<TabListData> tabList, int selectIndex = 0)
{
List.RemoveChildrenToPool();
var width = 0f;
for (int i = 0; i < tabList.Count; i++)
{
var tabData = tabList[i];
var tabItem = List.AddItemFromPool().asButton;
tabItem.title = tabData.Tab.Name;
width += tabItem.width;
if (i > 0)
{
width += List.columnGap;
}
}
Log.Info($"Set tab index={List.selectedIndex}");
List.selectedIndex = selectIndex;
List.width = width;
OnClickItem();
}
private void OnClickItem()
{
OnTabChange?.Invoke(List.selectedIndex);
}
private void OnClickBtnPrev()
{
if (List.selectedIndex > 0)
{
List.selectedIndex -= 1;
}
else
{
List.selectedIndex = List.numItems - 1;
}
OnClickItem();
}
private void OnClickBtnNext()
{
if (List.selectedIndex < List.numItems - 1)
{
List.selectedIndex += 1;
}
else
{
List.selectedIndex = 0;
}
OnClickItem();
}
}
}

View File

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

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4b9116bdcaaf42e4ea12741ceab85742

View File

@@ -0,0 +1,98 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class CommonSubMenu : GComponent
{
public event Action<int> OnTabChange;
private void OnInited()
{
List.onClickItem.Add(OnClickItem);
BtnPrev.onClick.Add(OnClickBtnPrev);
BtnNext.onClick.Add(OnClickBtnNext);
InputManager.OnUICanceled += OnUICanceled;
}
public override void Dispose()
{
InputManager.OnUICanceled -= OnUICanceled;
base.Dispose();
}
private void OnUICanceled(string action)
{
if (action == InputDef.UI.SubPrev)
{
OnClickBtnPrev();
}
else if (action == InputDef.UI.SubNext)
{
OnClickBtnNext();
}
}
public void SetTabs(List<TabSubItemData> subItems, int selectIndex = 0)
{
List.RemoveChildrenToPool();
var width = 0f;
for (int i = 0; i < subItems.Count; i++)
{
var tabData = subItems[i];
var tabItem = List.AddItemFromPool().asButton;
tabItem.title = tabData.Name;
width += tabItem.width;
if (i > 0)
{
width += List.columnGap;
}
}
Log.Info($"Set tab index={List.selectedIndex}");
List.selectedIndex = selectIndex;
List.width = width;
OnClickItem();
}
private void OnClickItem()
{
OnTabChange?.Invoke(List.selectedIndex);
}
private void OnClickBtnPrev()
{
if (List.selectedIndex > 0)
{
List.selectedIndex -= 1;
}
else
{
List.selectedIndex = List.numItems - 1;
}
OnClickItem();
}
private void OnClickBtnNext()
{
if (List.selectedIndex < List.numItems - 1)
{
List.selectedIndex += 1;
}
else
{
List.selectedIndex = 0;
}
OnClickItem();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 93621bc99ea075a4089f13224578d4ef

View File

@@ -0,0 +1,30 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
using System.Collections.Generic;
namespace NBF
{
/// <summary> </summary>
public partial class MessageBox
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
[AutoFind(Name = "back")]
public GImage back;
[AutoFind(Name = "box")]
public GImage box;
[AutoFind(Name = "TextTitle")]
public GTextField TextTitle;
[AutoFind(Name = "TextContent")]
public GTextField TextContent;
[AutoFind(Name = "BtnConfirm")]
public BtnTitleInputControl BtnConfirm;
[AutoFind(Name = "BtnCancel")]
public BtnTitleInputControl BtnCancel;
public override string[] GetDependPackages(){ return new string[] {}; }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7ce689c460bfe8245948899939807a59

View File

@@ -1,9 +1,33 @@
namespace NBF
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using UnityEngine;
using NBC;
namespace NBF
{
public class MessageBox
public partial class MessageBox : UIPanel
{
public static void Show(string text)
public override string UIPackName => "Common";
public override string UIResName => "MessageBox";
protected override void OnInit()
{
base.OnInit();
}
protected override void OnShow()
{
base.OnShow();
}
protected override void OnHide()
{
base.OnHide();
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}

View File

@@ -1,3 +1,2 @@
fileFormatVersion: 2
guid: 8e4609ff88d94fa8ad77c3cb17641809
timeCreated: 1742483434
guid: 8e4609ff88d94fa8ad77c3cb17641809

View File

@@ -15,8 +15,9 @@ namespace NBF
{
base.OnShow();
InputManager.OnInteractiveObjectAction += OnInteractiveObjectAction;
InputManager.OnUseAction += OnUseAction;
InputManager.OnUse2Action += OnUse2Action;
InputManager.OnPlayerCanceled += OnPlayerCanceled;
// InputManager.OnUseAction += OnUseAction;
// InputManager.OnUse2Action += OnUse2Action;
}
protected override void OnUpdate()
@@ -38,28 +39,27 @@ namespace NBF
}
}
private void OnUseAction()
private void OnPlayerCanceled(string action)
{
if (Interactive.visible)
{
Interactive.Use1();
if (action == "Use1")
{
Interactive.Use1();
}
else if (action == "Use2")
{
Interactive.Use2();
}
}
}
private void OnUse2Action()
{
if (Interactive.visible)
{
Interactive.Use2();
}
}
protected override void OnHide()
{
base.OnHide();
InputManager.OnInteractiveObjectAction -= OnInteractiveObjectAction;
InputManager.OnUseAction -= OnUseAction;
InputManager.OnUse2Action -= OnUse2Action;
InputManager.OnUICanceled -= OnPlayerCanceled;
}
}
}

View File

@@ -15,10 +15,14 @@ namespace NBF
public GImage back;
[AutoFind(Name = "Menu")]
public CommonMenu Menu;
[AutoFind(Name = "divisionLine")]
public GImage divisionLine;
[AutoFind(Name = "SubMenu")]
public CommonSubMenu SubMenu;
[AutoFind(Name = "List")]
public ClassifyList List;
[AutoFind(Name = "Currencys")]
public GComponent Currencys;
[AutoFind(Name = "BottomMenu")]
public BottomMenu BottomMenu;
public override string[] GetDependPackages(){ return new string[] {"Common"}; }

View File

@@ -7,7 +7,6 @@ using UIPanel = NBC.UIPanel;
namespace NBF
{
public class ShopGearData
{
public string title;
@@ -18,14 +17,13 @@ namespace NBF
public override string UIPackName => "Shop";
public override string UIResName => "FishingShopPanel";
private List<TabListData> _tabList = new List<TabListData>();
private TabListData _currentTab;
protected override void OnInit()
{
base.OnInit();
this.AutoAddClick(OnClick);
Menu.OnClose += Hide;
for (int i = 0; i < 10; i++)
{
@@ -35,7 +33,7 @@ namespace NBF
}
Menu.OnTabChange += ChangeTab;
SubMenu.OnTabChange += ChangeSubTab;
List.OnClickItem += OnClickItem;
}
@@ -43,23 +41,35 @@ namespace NBF
{
base.OnShow();
Menu.SetTabs(_tabList);
UseBottomMenu();
}
private void UseBottomMenu()
{
BottomMenu.OnBack += Hide;
BottomMenu.Use();
}
private void ChangeTab(int index)
{
Log.Info($"Change tab index={index}");
var listData = _tabList[index];
List.SetListData(listData.ListData);
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;
if (item is not ShopGearItem shopGearItem) return;
Log.Info($"click item ={shopGearItem.GearData.title}");
}
private void OnClick(GComponent btn)
{
// if (btn == BtnClose)
@@ -71,11 +81,14 @@ namespace NBF
protected override void OnHide()
{
base.OnHide();
BottomMenu.UnUse();
}
protected override void OnDestroy()
{
base.OnDestroy();
Menu.OnTabChange -= ChangeTab;
SubMenu.OnTabChange -= ChangeSubTab;
}
}
}

View File

@@ -11,15 +11,15 @@ namespace NBF
{
public const string URL = "ui://146ra2lqoome9";
public GGraph select;
public GGraph over;
public GImage back;
public GImage ba;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
select = (GGraph)GetChild("select");
over = (GGraph)GetChild("over");
back = (GImage)GetChild("back");
ba = (GImage)GetChild("ba");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}