完成按键输入按键显示

This commit is contained in:
2026-02-01 23:46:11 +08:00
parent e05561ff43
commit ebef45c4a3
95 changed files with 426 additions and 341 deletions

View File

@@ -13,16 +13,13 @@ namespace NBF
{
base.OnInit();
}
protected override void OnShow()
{
ItemList.List.OnClickItem += OnClickItem;
InputManager.OnUICanceled += OnUICanceled;
UseBottomMenu();
List<TabItemData> tabItemList = new List<TabItemData>();
var dic = RoleModel.Instance.GetItemsByType();
foreach (var (type, list) in dic)
{
@@ -36,25 +33,8 @@ namespace NBF
ItemList.SetPanel(this);
ItemList.SetData(tabItemList, true, true);
}
private void OnUICanceled(string action)
{
if (!IsTop) return;
if (action == InputDef.UI.SubPrev)
{
}
else if (action == InputDef.UI.SubNext)
{
}
else if (action == InputDef.UI.Up)
{
}
else if (action == InputDef.UI.Down)
{
}
}
private void OnClickItem(object item)
{
@@ -63,14 +43,8 @@ namespace NBF
ItemDetailsPanel.Show(bagItem.ItemInfo);
}
private void UseBottomMenu()
{
BottomMenu.Use(this);
}
protected override void OnHide()
{
InputManager.OnUICanceled -= OnUICanceled;
ItemList.List.OnClickItem -= OnClickItem;
}

View File

@@ -6,7 +6,7 @@ using NBC;
namespace NBF
{
public partial class BtnInputControl : GButton
public partial class BtnInputControl : BtnInputControlBase
{
private void OnInited()
{

View File

@@ -0,0 +1,28 @@
using FairyGUI;
using NBC;
namespace NBF
{
public abstract class BtnInputControlBase : GButton
{
public string ActionName;
public string ShowName;
public virtual void SetData(string actionName, string showName)
{
this.ActionName = actionName;
this.ShowName = showName;
if (!string.IsNullOrEmpty(showName))
{
title = Lan.Get(showName);
}
else
{
title = Lan.Get(actionName);
}
var iconName = InputManager.Instance.GetUIKeyCode(ActionName);
icon = UIPackage.GetItemURL(UIDef.Pack.Common, iconName);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4da865139cbb401a91f63bcf30d233c4
timeCreated: 1769960386

View File

@@ -7,19 +7,10 @@ using NBC;
namespace NBF
{
public partial class BtnTitleInputControl : GButton
public partial class BtnTitleInputControl : BtnInputControlBase
{
public string ActionName;
public string ShowName;
private void OnInited()
{
}
public void SetData(string actionName, string showName)
{
this.ActionName = actionName;
this.ShowName = showName;
}
}
}

View File

@@ -18,7 +18,6 @@ namespace NBF
public void SetPanel(UIPanel panel)
{
Menu.SetPanel(panel);
SubMenu.SetPanel(panel);
}
private void OnInited()

View File

@@ -15,6 +15,14 @@ namespace NBF
private void OnInited()
{
List.onClickItem.Add(OnClickItem);
LeftList.onClickItem.Add(OnClickItem);
InputManager.OnUIInvokeChange += OnUIInvokeChange;
}
public override void Dispose()
{
InputManager.OnUIInvokeChange -= OnUIInvokeChange;
base.Dispose();
}
private void OnClickItem(EventContext context)
@@ -25,29 +33,26 @@ namespace NBF
Debug.Log("模拟点击===");
}
public void Use(UIPanel panel)
private void OnUIInvokeChange()
{
_panel = panel;
List.RemoveChildrenToPool();
LeftList.RemoveChildrenToPool();
// AddButtonItem(OnUse, "");
// AddButtonItem(OnTab, InputDef.UI.Tab);
// AddButtonItem(OnEnter, InputDef.UI.Enter);
// AddButtonItem(OnBack, InputDef.UI.Back);
var invokes = InputManager.Instance.GetUsableInvokes();
foreach (var uiInputInvoke in invokes)
{
var invokeData = uiInputInvoke.InputInvoke;
if (uiInputInvoke.InputInvoke.Mode == UIInputButtonShowMode.BottomLeft)
{
AddButton(invokeData.Name, invokeData.Key, false);
}
else if (uiInputInvoke.InputInvoke.Mode == UIInputButtonShowMode.BottomRight)
{
AddButton(invokeData.Name, invokeData.Key);
}
}
}
public void AddRightButton(string inputName, string showName = "")
{
AddButton(inputName, string.Empty, true);
}
public void AddLeftButton(string inputName, string showName = "")
{
AddButton(inputName, string.Empty, false);
}
public void AddButton(string inputName, string showName = "", bool isRight = true)
{
if (isRight)

View File

@@ -79,7 +79,7 @@ namespace NBF
OnTabChange?.Invoke(List.selectedIndex);
}
private void OnClickBtnPrev()
public void OnClickBtnPrev()
{
if (List.selectedIndex > 0)
{
@@ -93,7 +93,7 @@ namespace NBF
OnClickItem();
}
private void OnClickBtnNext()
public void OnClickBtnNext()
{
if (List.selectedIndex < List.numItems - 1)
{

View File

@@ -12,12 +12,9 @@ namespace NBF
public partial class CommonSubMenu : GComponent
{
public event Action<int> OnTabChange;
private UIPanel _panel;
public void SetPanel(UIPanel panel)
{
_panel = panel;
}
private string _leftActionName;
private string _rightActionName;
private void OnInited()
{
@@ -25,31 +22,22 @@ namespace NBF
BtnPrev.onClick.Add(OnClickBtnPrev);
BtnNext.onClick.Add(OnClickBtnNext);
InputManager.OnUICanceled += OnUICanceled;
// CommonSubMenu
}
public void SetBtnActionName(string leftActionName, string rightActionName)
{
_leftActionName = leftActionName;
_rightActionName = rightActionName;
BtnPrev.SetData(leftActionName, string.Empty);
BtnNext.SetData(rightActionName, string.Empty);
}
public override void Dispose()
{
InputManager.OnUICanceled -= OnUICanceled;
base.Dispose();
}
private void OnUICanceled(string action)
{
if (_panel == null) return;
if (!_panel.IsShowing) return;
if (!_panel.IsTop) return;
if (action == InputDef.UI.SubPrev)
{
OnClickBtnPrev();
}
else if (action == InputDef.UI.SubNext)
{
OnClickBtnNext();
}
}
public void SetTabs(List<TabItemData> subItems, int selectIndex = 0)
{
List.RemoveChildrenToPool();
@@ -79,7 +67,7 @@ namespace NBF
OnTabChange?.Invoke(List.selectedIndex);
}
private void OnClickBtnPrev()
public void OnClickBtnPrev()
{
if (List.selectedIndex > 0)
{
@@ -93,7 +81,7 @@ namespace NBF
OnClickItem();
}
private void OnClickBtnNext()
public void OnClickBtnNext()
{
if (List.selectedIndex < List.numItems - 1)
{

View File

@@ -15,7 +15,6 @@ namespace NBF
protected override void OnShow()
{
InputManager.OnUICanceled += OnUICanceled;
}
protected override void OnUpdate()
@@ -39,7 +38,6 @@ namespace NBF
{
UI.Inst.HideUI(ui.GetType());
break;
// ui.Hide();
}
}
}
@@ -47,7 +45,6 @@ namespace NBF
protected override void OnHide()
{
InputManager.OnUICanceled -= OnUICanceled;
}
protected override void OnDestroy()

View File

@@ -24,13 +24,11 @@ namespace NBF
// buttons.Add(BtnTest);
navigate = new ButtonNavigate(buttons);
this.AutoListenInput();
}
protected override void OnShow()
{
InputManager.OnUICanceled += OnUICanceled;
UseBottomMenu();
// Model.LoadAsset(0);
// Model.SetBackground(Panel.Back.GetChild("back"));//, Panel.Back.GetChild("icon")
@@ -72,13 +70,5 @@ namespace NBF
navigate.Click();
}
}
private void UseBottomMenu()
{
BottomMenu.Use(Panel);
BottomMenu.AddRightButton(InputDef.UI.Enter);
BottomMenu.AddRightButton(InputDef.UI.Back);
}
}
}

View File

@@ -22,7 +22,6 @@ namespace NBF
public void SetData(OptionBase option)
{
Option = option;
if (option is IMultiOption multiOption)
{
if (multiOption.IsDropdown)

View File

@@ -42,10 +42,10 @@ namespace NBF
protected override void OnShow()
{
InputManager.Instance.Off(this);
InputManager.Instance.On(this);
SetActionIcon();
Settings.Instance.LoadAllSettings();
MenuList.SetTabs(tabList);
UseBottomMenu();
}
private void ChangeTab(int index)
@@ -109,11 +109,6 @@ namespace NBF
}
}
private void UseBottomMenu()
{
BottomMenu.Use(this);
}
private void OnResetSettings()
{
@@ -173,6 +168,15 @@ namespace NBF
Introduce.TextIntroduce.SetLanguage(item.Option.Name);
// Introduce.
}
for (var i = 0; i < _canSelectIndex.Count; i++)
{
var targetIndex = _canSelectIndex[i];
if (targetIndex == index)
{
_nowSelectIndex = i;
}
}
}
@@ -194,8 +198,26 @@ namespace NBF
#region Input Evnet
[InputInvoke(InputDef.UI.SubPrev)]
private void OnSubPrev()
private void SetActionIcon()
{
MenuList.SetBtnActionName(InputDef.UI.Prev, InputDef.UI.Next);
}
[InputInvoke(InputDef.UI.Prev, UIInputButtonShowMode.MenuLeft)]
private void OnPrev()
{
MenuList.OnClickBtnPrev();
}
[InputInvoke(InputDef.UI.Next, UIInputButtonShowMode.MenuRight)]
private void OnNext()
{
MenuList.OnClickBtnNext();
}
[InputInvoke(InputDef.UI.Left, UIInputButtonShowMode.BottomLeft)]
private void OnLeft()
{
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
{
@@ -203,8 +225,8 @@ namespace NBF
}
}
[InputInvoke(InputDef.UI.SubNext)]
private void OnSubNext()
[InputInvoke(InputDef.UI.Right, UIInputButtonShowMode.BottomLeft)]
private void OnRight()
{
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
{
@@ -212,19 +234,42 @@ namespace NBF
}
}
[InputInvoke(InputDef.UI.Up)]
[InputInvoke(InputDef.UI.Up, UIInputButtonShowMode.BottomLeft)]
private void OnUp()
{
ChangeListSelected();
}
[InputInvoke(InputDef.UI.Down)]
[InputInvoke(InputDef.UI.Down, UIInputButtonShowMode.BottomLeft)]
private void OnDown()
{
ChangeListSelected(false);
}
[InputInvoke(InputDef.UI.Back)]
[InputInvoke(InputDef.UI.Enter, UIInputButtonShowMode.BottomRight, "保存")]
private void OnApplySettings()
{
var options = Settings.Instance.GetOptionsByTab(_currentTab);
Log.Info("OnApplySettings");
foreach (var option in options)
{
option.Apply();
}
Notices.Success("TEXT_OP_SUCCESS");
}
[InputInvoke(InputDef.UI.Reset, UIInputButtonShowMode.BottomRight, "重置")]
private void OnReset()
{
MessageBox.Show("是否重置为默认?", (ret) =>
{
if (ret) OnResetSettings();
});
}
[InputInvoke(InputDef.UI.Back, UIInputButtonShowMode.BottomRight, "返回")]
private void OnBack()
{
if (Settings.Instance.HaveNotAppleSettings())
@@ -244,28 +289,6 @@ namespace NBF
}
}
[InputInvoke(InputDef.UI.Enter)]
private void OnApplySettings()
{
var options = Settings.Instance.GetOptionsByTab(_currentTab);
Log.Info("OnApplySettings");
foreach (var option in options)
{
option.Apply();
}
Notices.Success("TEXT_OP_SUCCESS");
}
[InputInvoke(InputDef.UI.Reset)]
private void OnReset()
{
MessageBox.Show("是否重置为默认?", (ret) =>
{
if (ret) OnResetSettings();
});
}
#endregion
protected override void OnHide()

View File

@@ -21,7 +21,6 @@ namespace NBF
{
ItemList.List.OnClickItem += OnClickItem;
InputManager.OnUICanceled += OnUICanceled;
UseBottomMenu();
List<TabItemData> tabItemList = GoodsConfigHelper.TabItemList;
@@ -53,12 +52,7 @@ namespace NBF
// ItemDetailsPanel.Show(bagItem.ItemInfo);
ShopDetailsPanel.Show(gearItem.Config);
}
private void UseBottomMenu()
{
BottomMenu.Use(this);
}
protected override void OnHide()
{
InputManager.OnUICanceled -= OnUICanceled;