多语言设置界面逻辑
This commit is contained in:
@@ -8,6 +8,7 @@ namespace NBF
|
||||
{
|
||||
public static void BindAll()
|
||||
{
|
||||
UIObjectFactory.SetPackageItemExtension(SelectPages.URL, typeof(SelectPages));
|
||||
UIObjectFactory.SetPackageItemExtension(BottomMenu.URL, typeof(BottomMenu));
|
||||
UIObjectFactory.SetPackageItemExtension(ClassifyList.URL, typeof(ClassifyList));
|
||||
UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu));
|
||||
|
||||
25
Assets/Scripts/UI/Common/SelectPages.Designer.cs
generated
Normal file
25
Assets/Scripts/UI/Common/SelectPages.Designer.cs
generated
Normal 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 SelectPages
|
||||
{
|
||||
public const string URL = "ui://6hgkvlau5dtx1a";
|
||||
|
||||
public GList List;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
List = (GList)GetChild("List");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Common/SelectPages.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Common/SelectPages.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e05d47a4fe9d174db57d8e523b1d53b
|
||||
36
Assets/Scripts/UI/Common/SelectPages.cs
Normal file
36
Assets/Scripts/UI/Common/SelectPages.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class SelectPages : GComponent
|
||||
{
|
||||
public int TotalPages { get; private set; }
|
||||
|
||||
public int CurrentPage { get; private set; }
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetTotal(int totalPage)
|
||||
{
|
||||
TotalPages = totalPage;
|
||||
List.RemoveChildrenToPool();
|
||||
for (var i = 0; i < totalPage; i++)
|
||||
{
|
||||
List.AddItemFromPool();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrent(int currentPage)
|
||||
{
|
||||
if (currentPage < 0 || currentPage >= TotalPages) return;
|
||||
CurrentPage = currentPage;
|
||||
List.selectedIndex = CurrentPage;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Common/SelectPages.cs.meta
Normal file
2
Assets/Scripts/UI/Common/SelectPages.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 405973384bfed8e409a629849e3cef2e
|
||||
@@ -19,6 +19,7 @@ namespace NBF
|
||||
public BtnInputControl BtnPrev;
|
||||
public BtnInputControl BtnNext;
|
||||
public GTextField TextSliderValue;
|
||||
public SelectPages Pages;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
@@ -32,6 +33,7 @@ namespace NBF
|
||||
BtnPrev = (BtnInputControl)GetChild("BtnPrev");
|
||||
BtnNext = (BtnInputControl)GetChild("BtnNext");
|
||||
TextSliderValue = (GTextField)GetChild("TextSliderValue");
|
||||
Pages = (SelectPages)GetChild("Pages");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ namespace NBF
|
||||
|
||||
private void UpdateValueText()
|
||||
{
|
||||
Pages.visible = false;
|
||||
if (Option is RangeOption range)
|
||||
{
|
||||
Slider.value = range.GetValue();
|
||||
@@ -143,6 +144,14 @@ namespace NBF
|
||||
else if (Option is IMultiOption multiOption)
|
||||
{
|
||||
TextInfo.text = multiOption.GetDisplayString();
|
||||
Pages.visible = true;
|
||||
var count = multiOption.GetOptionNames().Count;
|
||||
if (Pages.TotalPages != count)
|
||||
{
|
||||
Pages.SetTotal(count);
|
||||
}
|
||||
|
||||
Pages.SetCurrent(multiOption.GetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace NBF
|
||||
|
||||
private readonly List<TabListData> tabList = new List<TabListData>();
|
||||
private string _currentTab = "";
|
||||
private List<int> _canSelectIndex = new List<int>();
|
||||
private int _nowSelectIndex = -1;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
@@ -60,7 +62,7 @@ namespace NBF
|
||||
private void ResetSettingList()
|
||||
{
|
||||
// TextTitle.text = Lan.Get(_currentGroup);
|
||||
|
||||
_nowSelectIndex = -1;
|
||||
List.RemoveChildrenToPool();
|
||||
if (string.IsNullOrEmpty(_currentTab)) return;
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
@@ -76,6 +78,7 @@ namespace NBF
|
||||
list.Add(option);
|
||||
}
|
||||
|
||||
_canSelectIndex.Clear();
|
||||
var url = UIPackage.GetItemURL(UIPackName, "SettingSubTitleItem");
|
||||
foreach (var key in groupOptions.Keys)
|
||||
{
|
||||
@@ -90,6 +93,8 @@ namespace NBF
|
||||
if (List.AddItemFromPool() is SettingItem item)
|
||||
{
|
||||
item.SetData(option);
|
||||
var index = List.GetChildIndex(item);
|
||||
_canSelectIndex.Add(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,18 +143,11 @@ namespace NBF
|
||||
}
|
||||
else if (action == InputDef.UI.Up)
|
||||
{
|
||||
SetListSelected(List.selectedIndex - 1);
|
||||
ChangeListSelected();
|
||||
}
|
||||
else if (action == InputDef.UI.Down)
|
||||
{
|
||||
if (List.selectedIndex < 0)
|
||||
{
|
||||
SetListSelected(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetListSelected(List.selectedIndex + 1);
|
||||
}
|
||||
ChangeListSelected(false);
|
||||
}
|
||||
else if (action == InputDef.UI.Back)
|
||||
{
|
||||
@@ -161,6 +159,24 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ChangeListSelected(bool up = true)
|
||||
{
|
||||
if (!up)
|
||||
{
|
||||
_nowSelectIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nowSelectIndex--;
|
||||
}
|
||||
|
||||
if (_nowSelectIndex < 0) _nowSelectIndex = 0;
|
||||
else if (_nowSelectIndex >= _canSelectIndex.Count) _nowSelectIndex = _canSelectIndex.Count - 1;
|
||||
var targetIndex = _canSelectIndex[_nowSelectIndex];
|
||||
SetListSelected(targetIndex);
|
||||
}
|
||||
|
||||
private void SetListSelected(int selectedIndex)
|
||||
{
|
||||
if (selectedIndex >= 0 && selectedIndex < List.numItems)
|
||||
|
||||
Reference in New Issue
Block a user