设置分组
This commit is contained in:
@@ -142,20 +142,20 @@ namespace NBF
|
||||
range.SetValue((int)Slider.value);
|
||||
UpdateValueText();
|
||||
}
|
||||
// else if (Option is RangeOptionFloat rangeOptionFloat)
|
||||
// {
|
||||
// rangeOptionFloat.SetValue((float)Math.Round(Slider.value, 1));
|
||||
// // Slider
|
||||
// SliderTitle.text = Math.Round(rangeOptionFloat.GetValue(), 1).ToString(CultureInfo.InvariantCulture);
|
||||
// Debug.LogError(Slider.value);
|
||||
// }
|
||||
}
|
||||
|
||||
private void UpdateValueText()
|
||||
{
|
||||
if (Option is RangeOption range)
|
||||
{
|
||||
TextSliderValue.text = Math.Round(range.GetValue() / 10f, 1).ToString(CultureInfo.InvariantCulture);
|
||||
if (range.ShowRate > 0)
|
||||
{
|
||||
TextSliderValue.text = Math.Round(range.GetValue() / 10f, 1).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextSliderValue.text = range.GetValue().ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace NBF
|
||||
public GImage back;
|
||||
[AutoFind(Name = "Menu")]
|
||||
public CommonMenu Menu;
|
||||
[AutoFind(Name = "TextTitle")]
|
||||
public GTextField TextTitle;
|
||||
[AutoFind(Name = "Introduce")]
|
||||
public IntroduceTag Introduce;
|
||||
[AutoFind(Name = "List")]
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using NBF.Setting;
|
||||
using Unity.VisualScripting;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
@@ -12,10 +15,8 @@ namespace NBF
|
||||
public override string UIPackName => "Main";
|
||||
public override string UIResName => "SettingPanel";
|
||||
|
||||
private List<TabListData> tabList = new List<TabListData>();
|
||||
|
||||
|
||||
private string _currentGroup = "";
|
||||
private readonly List<TabListData> tabList = new List<TabListData>();
|
||||
private string _currentTab = "";
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace NBF
|
||||
IsShowCursor = true;
|
||||
IsDontBack = true;
|
||||
|
||||
var groupNames = Settings.Instance.GetAllGroups();
|
||||
var groupNames = Settings.Instance.GetAllTabs();
|
||||
foreach (var group in groupNames)
|
||||
{
|
||||
var tab = new TabListData
|
||||
@@ -33,6 +34,7 @@ namespace NBF
|
||||
tabList.Add(tab);
|
||||
}
|
||||
|
||||
|
||||
Menu.OnTabChange += ChangeTab;
|
||||
List.onClickItem.Set(OnClickListItem);
|
||||
}
|
||||
@@ -50,24 +52,45 @@ namespace NBF
|
||||
if (index < 0) return;
|
||||
Log.Info($"Change tab index={index}");
|
||||
var tabListData = tabList[index];
|
||||
_currentGroup = tabListData.Name;
|
||||
_currentTab = tabListData.Name;
|
||||
ResetSettingList();
|
||||
}
|
||||
|
||||
|
||||
private void ResetSettingList()
|
||||
{
|
||||
TextTitle.text = Lan.Get(_currentGroup);
|
||||
// TextTitle.text = Lan.Get(_currentGroup);
|
||||
|
||||
List.RemoveChildrenToPool();
|
||||
if (string.IsNullOrEmpty(_currentGroup)) return;
|
||||
var options = Settings.Instance.GetOptionsByGroup(_currentGroup);
|
||||
|
||||
if (string.IsNullOrEmpty(_currentTab)) return;
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
Dictionary<string, List<OptionBase>> groupOptions = new Dictionary<string, List<OptionBase>>();
|
||||
foreach (var option in options)
|
||||
{
|
||||
if (List.AddItemFromPool() is SettingItem item)
|
||||
if (!groupOptions.TryGetValue(option.Group, out List<OptionBase> list))
|
||||
{
|
||||
item.SetData(option);
|
||||
list = new List<OptionBase>();
|
||||
groupOptions.Add(option.Group, list);
|
||||
}
|
||||
|
||||
list.Add(option);
|
||||
}
|
||||
|
||||
var url = UIPackage.GetItemURL(UIPackName, "SettingSubTitleItem");
|
||||
foreach (var key in groupOptions.Keys)
|
||||
{
|
||||
var value = groupOptions[key];
|
||||
if (List.AddItemFromPool(url) is GLabel label)
|
||||
{
|
||||
label.title = Lan.Get(key);
|
||||
}
|
||||
|
||||
foreach (var option in value)
|
||||
{
|
||||
if (List.AddItemFromPool() is SettingItem item)
|
||||
{
|
||||
item.SetData(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +102,7 @@ namespace NBF
|
||||
|
||||
private void OnApplySettings()
|
||||
{
|
||||
var options = Settings.Instance.GetOptionsByGroup(_currentGroup);
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
|
||||
foreach (var option in options)
|
||||
{
|
||||
@@ -89,7 +112,7 @@ namespace NBF
|
||||
|
||||
private void OnResetSettings()
|
||||
{
|
||||
var options = Settings.Instance.GetOptionsByGroup(_currentGroup);
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
|
||||
foreach (var option in options)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user