按键绑定和重置以及加载功能

This commit is contained in:
bob
2025-06-20 17:56:49 +08:00
parent 8a8821c2e6
commit ac946f41ed
27 changed files with 291 additions and 47 deletions

View File

@@ -10,6 +10,7 @@ using UIPanel = NBC.UIPanel;
namespace NBF
{
[UIBind(UIDef.ID.SettingPanel)]
public partial class SettingPanel : UIPanel
{
public override string UIPackName => "Main";
@@ -64,7 +65,7 @@ namespace NBF
{
// TextTitle.text = Lan.Get(_currentGroup);
_nowSelectIndex = -1;
if (string.IsNullOrEmpty(_currentTab)) return;
var options = Settings.Instance.GetOptionsByTab(_currentTab);
Dictionary<string, List<OptionBase>> groupOptions = new Dictionary<string, List<OptionBase>>();
@@ -82,8 +83,8 @@ namespace NBF
_canSelectIndex.Clear();
List.RemoveChildrenToPool();
var url = UIPackage.GetItemURL(UIPackName, "SettingSubTitleItem");
foreach (var key in groupOptions.Keys)
{
@@ -99,7 +100,7 @@ namespace NBF
{
if (List.AddItemFromPool(SettingInputItem.URL) is SettingInputItem item)
{
item.SetData(option);
item.SetData(option as InputOption);
var index = List.GetChildIndex(item);
_canSelectIndex.Add(index);
}
@@ -125,7 +126,7 @@ namespace NBF
private void OnApplySettings()
{
var options = Settings.Instance.GetOptionsByTab(_currentTab);
Log.Info("OnApplySettings");
foreach (var option in options)
{
option.Apply();
@@ -140,6 +141,8 @@ namespace NBF
{
option.Reset();
}
ResetSettingList();
}
private void OnUICanceled(string action)
@@ -174,6 +177,13 @@ namespace NBF
{
OnApplySettings();
}
else if (action == InputDef.UI.Reset)
{
MessageBox.Show("是否重置为默认?", (ret) =>
{
if (ret) OnResetSettings();
});
}
}