完成按键输入按键显示
This commit is contained in:
@@ -6,7 +6,7 @@ using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BtnInputControl : GButton
|
||||
public partial class BtnInputControl : BtnInputControlBase
|
||||
{
|
||||
private void OnInited()
|
||||
{
|
||||
|
||||
28
Assets/Scripts/UI/Common/Button/BtnInputControlBase.cs
Normal file
28
Assets/Scripts/UI/Common/Button/BtnInputControlBase.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4da865139cbb401a91f63bcf30d233c4
|
||||
timeCreated: 1769960386
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ namespace NBF
|
||||
public void SetPanel(UIPanel panel)
|
||||
{
|
||||
Menu.SetPanel(panel);
|
||||
SubMenu.SetPanel(panel);
|
||||
}
|
||||
|
||||
private void OnInited()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user