修改设置界面
This commit is contained in:
@@ -23,27 +23,28 @@ namespace NBF
|
||||
base.OnInit();
|
||||
IsShowCursor = true;
|
||||
IsDontBack = true;
|
||||
|
||||
//TEXT_SETTINGS_
|
||||
var groupNames = Settings.Instance.GetAllTabs();
|
||||
foreach (var group in groupNames)
|
||||
{
|
||||
var tab = new TabItemData
|
||||
{
|
||||
Key = $"TEXT_SETTINGS_{group}"
|
||||
Key = $"TEXT_SETTINGS_{group}",
|
||||
Name = group
|
||||
};
|
||||
tabList.Add(tab);
|
||||
}
|
||||
|
||||
|
||||
Menu.OnTabChange += ChangeTab;
|
||||
MenuList.OnTabChange += ChangeTab;
|
||||
List.onClickItem.Set(OnClickListItem);
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
InputManager.Instance.Off(this);
|
||||
Settings.Instance.LoadAllSettings();
|
||||
InputManager.OnUICanceled += OnUICanceled;
|
||||
Menu.SetTabs(tabList);
|
||||
MenuList.SetTabs(tabList);
|
||||
UseBottomMenu();
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ namespace NBF
|
||||
if (index < 0) return;
|
||||
Log.Info($"Change tab index={index}");
|
||||
var tabListData = tabList[index];
|
||||
_currentTab = tabListData.Key;
|
||||
_currentTab = tabListData.Name;
|
||||
ResetSettingList();
|
||||
}
|
||||
|
||||
@@ -82,35 +83,29 @@ namespace NBF
|
||||
|
||||
|
||||
var url = UIPackage.GetItemURL(UIPackName, "SettingSubTitleItem");
|
||||
var groupIndex = 0;
|
||||
foreach (var key in groupOptions.Keys)
|
||||
{
|
||||
var value = groupOptions[key];
|
||||
if (List.AddItemFromPool(url) is GLabel label)
|
||||
if (groupIndex > 0)
|
||||
{
|
||||
label.SetLanguage(key);
|
||||
if (List.AddItemFromPool(url) is GLabel label)
|
||||
{
|
||||
label.SetLanguage(key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var option in value)
|
||||
{
|
||||
if (option is InputOption)
|
||||
if (List.AddItemFromPool() is SettingItem item)
|
||||
{
|
||||
if (List.AddItemFromPool(SettingInputItem.URL) is SettingInputItem item)
|
||||
{
|
||||
item.SetData(option as InputOption);
|
||||
var index = List.GetChildIndex(item);
|
||||
_canSelectIndex.Add(index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (List.AddItemFromPool() is SettingItem item)
|
||||
{
|
||||
item.SetData(option);
|
||||
var index = List.GetChildIndex(item);
|
||||
_canSelectIndex.Add(index);
|
||||
}
|
||||
item.SetData(option);
|
||||
var index = List.GetChildIndex(item);
|
||||
_canSelectIndex.Add(index);
|
||||
}
|
||||
}
|
||||
|
||||
groupIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,16 +114,6 @@ namespace NBF
|
||||
BottomMenu.Use(this);
|
||||
}
|
||||
|
||||
private void OnApplySettings()
|
||||
{
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
Log.Info("OnApplySettings");
|
||||
foreach (var option in options)
|
||||
{
|
||||
option.Apply();
|
||||
}
|
||||
Notices.Success("TEXT_OP_SUCCESS");
|
||||
}
|
||||
|
||||
private void OnResetSettings()
|
||||
{
|
||||
@@ -138,51 +123,10 @@ namespace NBF
|
||||
{
|
||||
option.Reset();
|
||||
}
|
||||
|
||||
ResetSettingList();
|
||||
|
||||
Notices.Success("TEXT_OP_SUCCESS");
|
||||
}
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (action == InputDef.UI.SubPrev)
|
||||
{
|
||||
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
|
||||
{
|
||||
item.OnPrev();
|
||||
}
|
||||
}
|
||||
else if (action == InputDef.UI.SubNext)
|
||||
{
|
||||
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
|
||||
{
|
||||
item.OnNext();
|
||||
}
|
||||
}
|
||||
else if (action == InputDef.UI.Up)
|
||||
{
|
||||
ChangeListSelected();
|
||||
}
|
||||
else if (action == InputDef.UI.Down)
|
||||
{
|
||||
ChangeListSelected(false);
|
||||
}
|
||||
else if (action == InputDef.UI.Back)
|
||||
{
|
||||
OnBack();
|
||||
}
|
||||
else if (action == InputDef.UI.Enter)
|
||||
{
|
||||
OnApplySettings();
|
||||
}
|
||||
else if (action == InputDef.UI.Reset)
|
||||
{
|
||||
MessageBox.Show("是否重置为默认?", (ret) =>
|
||||
{
|
||||
if (ret) OnResetSettings();
|
||||
});
|
||||
}
|
||||
ResetSettingList();
|
||||
|
||||
Notices.Success("TEXT_OP_SUCCESS");
|
||||
}
|
||||
|
||||
|
||||
@@ -225,12 +169,62 @@ namespace NBF
|
||||
var settingItem = List.GetChildAt(index);
|
||||
if (settingItem is SettingItem item)
|
||||
{
|
||||
Introduce.TextName.SetLanguage(item.Option.Name);
|
||||
// Introduce.TextName.SetLanguage(item.Option.Name);
|
||||
Introduce.TextIntroduce.SetLanguage(item.Option.Name);
|
||||
// Introduce.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CancelAndBack()
|
||||
{
|
||||
var groupNames = Settings.Instance.GetAllTabs();
|
||||
foreach (var group in groupNames)
|
||||
{
|
||||
var options = Settings.Instance.GetOptionsByTab(group);
|
||||
foreach (var option in options)
|
||||
{
|
||||
if (option.HaveNotApple())
|
||||
{
|
||||
option.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Input Evnet
|
||||
|
||||
[InputInvoke(InputDef.UI.SubPrev)]
|
||||
private void OnSubPrev()
|
||||
{
|
||||
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
|
||||
{
|
||||
item.OnPrev();
|
||||
}
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.SubNext)]
|
||||
private void OnSubNext()
|
||||
{
|
||||
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
|
||||
{
|
||||
item.OnNext();
|
||||
}
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Up)]
|
||||
private void OnUp()
|
||||
{
|
||||
ChangeListSelected();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Down)]
|
||||
private void OnDown()
|
||||
{
|
||||
ChangeListSelected(false);
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Back)]
|
||||
private void OnBack()
|
||||
{
|
||||
if (Settings.Instance.HaveNotAppleSettings())
|
||||
@@ -250,33 +244,40 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelAndBack()
|
||||
[InputInvoke(InputDef.UI.Enter)]
|
||||
private void OnApplySettings()
|
||||
{
|
||||
|
||||
var groupNames = Settings.Instance.GetAllTabs();
|
||||
foreach (var group in groupNames)
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
Log.Info("OnApplySettings");
|
||||
foreach (var option in options)
|
||||
{
|
||||
var options = Settings.Instance.GetOptionsByTab(group);
|
||||
foreach (var option in options)
|
||||
{
|
||||
if (option.HaveNotApple())
|
||||
{
|
||||
option.Cancel();
|
||||
}
|
||||
}
|
||||
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()
|
||||
{
|
||||
base.OnHide();
|
||||
InputManager.OnUICanceled -= OnUICanceled;
|
||||
InputManager.Instance.Off(this);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
Menu.OnTabChange -= ChangeTab;
|
||||
MenuList.OnTabChange -= ChangeTab;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user