首次提交
This commit is contained in:
25
Assets/Scripts/UI/Settings/IntroduceTag.Designer.cs
generated
Normal file
25
Assets/Scripts/UI/Settings/IntroduceTag.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 IntroduceTag
|
||||
{
|
||||
public const string URL = "ui://hxr7rc7pe9z89";
|
||||
|
||||
public GTextField TextIntroduce;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
TextIntroduce = (GTextField)GetChild("TextIntroduce");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/IntroduceTag.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/IntroduceTag.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8efd42e53f5fd964797208b7caa3f1b3
|
||||
15
Assets/Scripts/UI/Settings/IntroduceTag.cs
Normal file
15
Assets/Scripts/UI/Settings/IntroduceTag.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class IntroduceTag : GComponent
|
||||
{
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/IntroduceTag.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/IntroduceTag.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c36c049022265e428de9586bc9ed952
|
||||
29
Assets/Scripts/UI/Settings/KeyboardInput.Designer.cs
generated
Normal file
29
Assets/Scripts/UI/Settings/KeyboardInput.Designer.cs
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class KeyboardInput
|
||||
{
|
||||
public const string URL = "ui://hxr7rc7p5dtx1b";
|
||||
|
||||
public Controller state;
|
||||
public GImage bottomLine;
|
||||
public GTextField TextKeyboard;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
state = GetController("state");
|
||||
bottomLine = (GImage)GetChild("bottomLine");
|
||||
TextKeyboard = (GTextField)GetChild("TextKeyboard");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ddb059fe879d5c4abe82933558551a2
|
||||
25
Assets/Scripts/UI/Settings/KeyboardInput.cs
Normal file
25
Assets/Scripts/UI/Settings/KeyboardInput.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using NBF.Setting;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class KeyboardInput : GButton
|
||||
{
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetData(InputOption option)
|
||||
{
|
||||
TextKeyboard.visible = false;
|
||||
if (option is KeyBoardOption)
|
||||
{
|
||||
TextKeyboard.visible = true;
|
||||
TextKeyboard.text = option.GetDisplayString(); // + "- " + string.Join(",", list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/KeyboardInput.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/KeyboardInput.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ed06aa0989ac484689d7c696bcf8246
|
||||
29
Assets/Scripts/UI/Settings/SettingInputItem.Designer.cs
generated
Normal file
29
Assets/Scripts/UI/Settings/SettingInputItem.Designer.cs
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class SettingInputItem
|
||||
{
|
||||
public const string URL = "ui://hxr7rc7p5dtx1c";
|
||||
|
||||
public GImage back;
|
||||
public GTextField TextName;
|
||||
public KeyboardInput BtnKeyboard;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
back = (GImage)GetChild("back");
|
||||
TextName = (GTextField)GetChild("TextName");
|
||||
BtnKeyboard = (KeyboardInput)GetChild("BtnKeyboard");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3336f2973a5dd242a9fed2120d8b75b
|
||||
75
Assets/Scripts/UI/Settings/SettingInputItem.cs
Normal file
75
Assets/Scripts/UI/Settings/SettingInputItem.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
using NBF.Setting;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class SettingInputItem : GButton
|
||||
{
|
||||
public InputOption Option;
|
||||
private InputActionRebindingExtensions.RebindingOperation rebindingOperation;
|
||||
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
BtnKeyboard.onClick.Set(OnClickRebind);
|
||||
onChanged.Add(SelfChanged);
|
||||
}
|
||||
|
||||
public void SetData(InputOption option)
|
||||
{
|
||||
Option = option;
|
||||
TextName.SetLanguage(Option.Name);
|
||||
UpdateValueText();
|
||||
}
|
||||
|
||||
public void OnClickRebind()
|
||||
{
|
||||
// InputWaitingPanel.Show(true);
|
||||
// UI.Inst.OpenUI<InputWaitingPanel>();
|
||||
SettingWaitInputPanel.Show();
|
||||
// // 取消当前绑定
|
||||
// var settingPanel = UI.Inst.GetUI<SettingPanel>();
|
||||
// settingPanel.InputWait.visible = true;
|
||||
// Option.InputAction.Disable();
|
||||
//
|
||||
// // 开始重绑定操作
|
||||
// rebindingOperation = Option.InputAction.PerformInteractiveRebinding(Option.BindingIndex)
|
||||
// .OnMatchWaitForAnother(0.1f)
|
||||
// .OnComplete(operation => RebindComplete())
|
||||
// .OnCancel(operation => RebindCanceled())
|
||||
// .Start();
|
||||
}
|
||||
|
||||
private void RebindComplete()
|
||||
{
|
||||
rebindingOperation.Dispose();
|
||||
UpdateValueText();
|
||||
Option.InputAction.Enable();
|
||||
}
|
||||
|
||||
private void RebindCanceled()
|
||||
{
|
||||
rebindingOperation.Dispose();
|
||||
Option.InputAction.Enable();
|
||||
// UI.Inst.HideUI<InputWaitingPanel>();
|
||||
}
|
||||
|
||||
|
||||
private void SelfChanged(EventContext context)
|
||||
{
|
||||
if (!selected)
|
||||
{
|
||||
// RebindOver();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateValueText()
|
||||
{
|
||||
BtnKeyboard.SetData(Option);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/SettingInputItem.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/SettingInputItem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd7a19031ef9b1143997dca07c932a46
|
||||
45
Assets/Scripts/UI/Settings/SettingItem.Designer.cs
generated
Normal file
45
Assets/Scripts/UI/Settings/SettingItem.Designer.cs
generated
Normal file
@@ -0,0 +1,45 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class SettingItem
|
||||
{
|
||||
public const string URL = "ui://hxr7rc7pmnqh2w";
|
||||
|
||||
public Controller style;
|
||||
public GImage back;
|
||||
public GTextField TextName;
|
||||
public GTextField TextInfo;
|
||||
public GSlider Slider;
|
||||
public GTextField TextSliderValue;
|
||||
public SelectPages Pages;
|
||||
public GButton BtnPrev;
|
||||
public GButton BtnNext;
|
||||
public BtnInputName BtnControl1;
|
||||
public GComboBox ComboBox;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
style = GetController("style");
|
||||
back = (GImage)GetChild("back");
|
||||
TextName = (GTextField)GetChild("TextName");
|
||||
TextInfo = (GTextField)GetChild("TextInfo");
|
||||
Slider = (GSlider)GetChild("Slider");
|
||||
TextSliderValue = (GTextField)GetChild("TextSliderValue");
|
||||
Pages = (SelectPages)GetChild("Pages");
|
||||
BtnPrev = (GButton)GetChild("BtnPrev");
|
||||
BtnNext = (GButton)GetChild("BtnNext");
|
||||
BtnControl1 = (BtnInputName)GetChild("BtnControl1");
|
||||
ComboBox = (GComboBox)GetChild("ComboBox");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/SettingItem.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/SettingItem.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a99a3eda0b402314e998ff820ebb5b4d
|
||||
212
Assets/Scripts/UI/Settings/SettingItem.cs
Normal file
212
Assets/Scripts/UI/Settings/SettingItem.cs
Normal file
@@ -0,0 +1,212 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
using NBF.Setting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class SettingItem : GButton
|
||||
{
|
||||
public OptionBase Option;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
BtnPrev.onClick.Set(OnPrev);
|
||||
BtnNext.onClick.Set(OnNext);
|
||||
BtnControl1.onClick.Set(OnControl);
|
||||
Slider.onChanged.Set(OnSliderChanged);
|
||||
ComboBox.onChanged.Set(OnComboBoxChanged);
|
||||
}
|
||||
|
||||
public void SetData(OptionBase option)
|
||||
{
|
||||
Option = option;
|
||||
if (option is IMultiOption multiOption)
|
||||
{
|
||||
if (multiOption.IsDropdown)
|
||||
{
|
||||
style.selectedIndex = 2;
|
||||
if (multiOption.IsDropdown)
|
||||
{
|
||||
ComboBox.items = multiOption.GetOptionNames().ToArray();
|
||||
ComboBox.selectedIndex = multiOption.GetValue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
style.selectedIndex = 1;
|
||||
}
|
||||
}
|
||||
else if (option is RangeOption range)
|
||||
{
|
||||
style.selectedIndex = 3; //进度类型
|
||||
Slider.min = range.MinValue;
|
||||
Slider.max = range.MaxValue;
|
||||
Slider.wholeNumbers = true;
|
||||
}
|
||||
else if (option is KeyBoardOption keyBoardOption)
|
||||
{
|
||||
style.selectedIndex = 4; //按键类型
|
||||
}
|
||||
else
|
||||
{
|
||||
style.selectedIndex = 0;
|
||||
}
|
||||
|
||||
TextName.SetLanguage(Option.Name);
|
||||
SetShow();
|
||||
}
|
||||
|
||||
private void SetShow()
|
||||
{
|
||||
UpdateValueText();
|
||||
}
|
||||
|
||||
public void OnPrev()
|
||||
{
|
||||
if (Option is IMultiOption multiOption)
|
||||
{
|
||||
var index = multiOption.GetValue();
|
||||
if (index > 0)
|
||||
{
|
||||
index--;
|
||||
}
|
||||
else if (index == 0)
|
||||
{
|
||||
var names = multiOption.GetOptionNames();
|
||||
index = names.Count - 1;
|
||||
}
|
||||
|
||||
if (Option is ResolutionSetting resolutionSetting)
|
||||
{
|
||||
var res = Screen.resolutions;
|
||||
Debug.LogError(
|
||||
$"next index={index} count = {multiOption.GetOptionNames().Count} res={res.Length}");
|
||||
}
|
||||
|
||||
multiOption.SetValue(index);
|
||||
}
|
||||
else if (Option is RangeOption range)
|
||||
{
|
||||
var value = range.GetValue();
|
||||
value--;
|
||||
if (value < range.MinValue)
|
||||
{
|
||||
value = range.MinValue;
|
||||
}
|
||||
|
||||
range.SetValue(value);
|
||||
Slider.value = value;
|
||||
UpdateValueText();
|
||||
}
|
||||
|
||||
SetShow();
|
||||
}
|
||||
|
||||
public void OnNext()
|
||||
{
|
||||
if (Option is IMultiOption multiOption)
|
||||
{
|
||||
var names = multiOption.GetOptionNames();
|
||||
var index = multiOption.GetValue();
|
||||
if (index < names.Count - 1)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
else if (index == names.Count - 1)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (Option is ResolutionSetting resolutionSetting)
|
||||
{
|
||||
var res = Screen.resolutions;
|
||||
Debug.LogError($"next index={index} count = {names.Count} res={res.Length}");
|
||||
}
|
||||
|
||||
multiOption.SetValue(index);
|
||||
}
|
||||
else if (Option is RangeOption range)
|
||||
{
|
||||
var value = range.GetValue();
|
||||
value++;
|
||||
if (value > range.MaxValue)
|
||||
{
|
||||
value = range.MaxValue;
|
||||
}
|
||||
|
||||
range.SetValue(value);
|
||||
Slider.value = value;
|
||||
UpdateValueText();
|
||||
}
|
||||
|
||||
|
||||
SetShow();
|
||||
}
|
||||
|
||||
public void OnSliderChanged()
|
||||
{
|
||||
if (Option is RangeOption range)
|
||||
{
|
||||
range.SetValue((int)Slider.value);
|
||||
UpdateValueText();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnComboBoxChanged()
|
||||
{
|
||||
Debug.Log(ComboBox.selectedIndex);
|
||||
if (Option is IMultiOption multiOption)
|
||||
{
|
||||
multiOption.SetValue(ComboBox.selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnControl()
|
||||
{
|
||||
SettingWaitInputPanel.Show(this);
|
||||
}
|
||||
|
||||
public void UpdateValueText()
|
||||
{
|
||||
Pages.visible = false;
|
||||
if (Option is RangeOption range)
|
||||
{
|
||||
Slider.value = range.GetValue();
|
||||
TextSliderValue.text = range.GetDisplayString();
|
||||
}
|
||||
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());
|
||||
}
|
||||
else if (Option is KeyBoardOption keyBoardOption)
|
||||
{
|
||||
UpdateControlInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateControlInfo()
|
||||
{
|
||||
// BtnControl
|
||||
if (Option is KeyBoardOption keyBoardOption)
|
||||
{
|
||||
if (keyBoardOption.InputAction.name.Contains("Bob"))
|
||||
{
|
||||
int i = 0;
|
||||
}
|
||||
BtnControl1.SetData(0, keyBoardOption);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/SettingItem.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/SettingItem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80e8fd431260afb49a8f82e2b17ad93d
|
||||
34
Assets/Scripts/UI/Settings/SettingPanel.Designer.cs
generated
Normal file
34
Assets/Scripts/UI/Settings/SettingPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,34 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary> </summary>
|
||||
public partial class SettingPanel
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
public override string UIPackName => "Main";
|
||||
public override string UIResName => "SettingPanel";
|
||||
|
||||
[AutoFind(Name = "MenuList")]
|
||||
public CommonMenu MenuList;
|
||||
[AutoFind(Name = "Introduce")]
|
||||
public IntroduceTag Introduce;
|
||||
[AutoFind(Name = "List")]
|
||||
public GList List;
|
||||
[AutoFind(Name = "Mask")]
|
||||
public GLabel Mask;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common","CommonNew"}; }
|
||||
|
||||
public static void Show(object param = null){ UI.Inst.OpenUI<SettingPanel>(param); }
|
||||
|
||||
public static void Hide(){ UI.Inst.HideUI<SettingPanel>(); }
|
||||
|
||||
public static void Del(){ UI.Inst.DestroyUI<SettingPanel>(); }
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/SettingPanel.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/SettingPanel.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bd9a89782b28a342b84154c6ca06d32
|
||||
302
Assets/Scripts/UI/Settings/SettingPanel.cs
Normal file
302
Assets/Scripts/UI/Settings/SettingPanel.cs
Normal file
@@ -0,0 +1,302 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using NBF.Setting;
|
||||
using Unity.VisualScripting;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[UIBind(UIDef.ID.SettingPanel)]
|
||||
public partial class SettingPanel : UIPanel
|
||||
{
|
||||
private readonly List<TabItemData> tabList = new List<TabItemData>();
|
||||
private string _currentTab = "";
|
||||
private List<int> _canSelectIndex = new List<int>();
|
||||
private int _nowSelectIndex = -1;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
IsShowCursor = true;
|
||||
//TEXT_SETTINGS_
|
||||
var groupNames = Settings.Instance.GetAllTabs();
|
||||
foreach (var group in groupNames)
|
||||
{
|
||||
var tab = new TabItemData
|
||||
{
|
||||
Key = $"TEXT_SETTINGS_{group}",
|
||||
Name = group
|
||||
};
|
||||
tabList.Add(tab);
|
||||
}
|
||||
|
||||
|
||||
MenuList.OnTabChange += ChangeTab;
|
||||
List.onClickItem.Set(OnClickListItem);
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
InputManager.Instance.On(this);
|
||||
SetActionIcon();
|
||||
Settings.Instance.LoadAllSettings();
|
||||
MenuList.SetTabs(tabList);
|
||||
}
|
||||
|
||||
private void ChangeTab(int index)
|
||||
{
|
||||
if (index < 0) return;
|
||||
Log.Info($"Change tab index={index}");
|
||||
var tabListData = tabList[index];
|
||||
_currentTab = tabListData.Name;
|
||||
ResetSettingList();
|
||||
}
|
||||
|
||||
|
||||
private void ResetSettingList()
|
||||
{
|
||||
// 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>>();
|
||||
foreach (var option in options)
|
||||
{
|
||||
if (!groupOptions.TryGetValue(option.Group, out List<OptionBase> list))
|
||||
{
|
||||
list = new List<OptionBase>();
|
||||
groupOptions.Add(option.Group, list);
|
||||
}
|
||||
|
||||
list.Add(option);
|
||||
}
|
||||
|
||||
_canSelectIndex.Clear();
|
||||
|
||||
List.RemoveChildrenToPool();
|
||||
|
||||
|
||||
var url = UIPackage.GetItemURL(UIPackName, "SettingSubTitleItem");
|
||||
|
||||
foreach (var key in groupOptions.Keys)
|
||||
{
|
||||
var value = groupOptions[key];
|
||||
|
||||
|
||||
if (List.AddItemFromPool(url) is GLabel label)
|
||||
{
|
||||
label.SetLanguage(key);
|
||||
}
|
||||
|
||||
foreach (var option in value)
|
||||
{
|
||||
if (List.AddItemFromPool() is SettingItem item)
|
||||
{
|
||||
item.SetData(option);
|
||||
var index = List.GetChildIndex(item);
|
||||
_canSelectIndex.Add(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnResetSettings()
|
||||
{
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
|
||||
foreach (var option in options)
|
||||
{
|
||||
option.Reset();
|
||||
}
|
||||
|
||||
ResetSettingList();
|
||||
|
||||
Notices.Success("TEXT_OP_SUCCESS");
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
List.selectedIndex = selectedIndex;
|
||||
List.ScrollToView(List.selectedIndex);
|
||||
}
|
||||
|
||||
OnClickListItem();
|
||||
}
|
||||
|
||||
private void OnClickListItem()
|
||||
{
|
||||
var index = List.selectedIndex;
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var settingItem = List.GetChildAt(index);
|
||||
if (settingItem is SettingItem item)
|
||||
{
|
||||
// Introduce.TextName.SetLanguage(item.Option.Name);
|
||||
Introduce.TextIntroduce.SetLanguage(item.Option.Name);
|
||||
// Introduce.
|
||||
}
|
||||
|
||||
for (var i = 0; i < _canSelectIndex.Count; i++)
|
||||
{
|
||||
var targetIndex = _canSelectIndex[i];
|
||||
if (targetIndex == index)
|
||||
{
|
||||
_nowSelectIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
private void SetActionIcon()
|
||||
{
|
||||
MenuList.SetBtnActionName(InputDef.UI.Prev, InputDef.UI.Next);
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Prev, UIInputButtonShowMode.MenuLeft)]
|
||||
private void OnPrev()
|
||||
{
|
||||
MenuList.OnClickBtnPrev();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Next, UIInputButtonShowMode.MenuRight)]
|
||||
private void OnNext()
|
||||
{
|
||||
MenuList.OnClickBtnNext();
|
||||
}
|
||||
|
||||
|
||||
[InputInvoke(InputDef.UI.Left, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnLeft()
|
||||
{
|
||||
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
|
||||
{
|
||||
item.OnPrev();
|
||||
}
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Right, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnRight()
|
||||
{
|
||||
if (List.GetChildAt(List.selectedIndex) is SettingItem item)
|
||||
{
|
||||
item.OnNext();
|
||||
}
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Up, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnUp()
|
||||
{
|
||||
ChangeListSelected();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Down, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnDown()
|
||||
{
|
||||
ChangeListSelected(false);
|
||||
}
|
||||
|
||||
|
||||
[InputInvoke(InputDef.UI.Enter, UIInputButtonShowMode.BottomRight, "保存")]
|
||||
private void OnApplySettings()
|
||||
{
|
||||
var options = Settings.Instance.GetOptionsByTab(_currentTab);
|
||||
Log.Info("OnApplySettings");
|
||||
foreach (var option in options)
|
||||
{
|
||||
option.Apply();
|
||||
}
|
||||
|
||||
Notices.Success("TEXT_OP_SUCCESS");
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Reset, UIInputButtonShowMode.BottomRight, "重置")]
|
||||
private void OnReset()
|
||||
{
|
||||
MessageBox.Show("是否重置为默认?", (ret) =>
|
||||
{
|
||||
if (ret) OnResetSettings();
|
||||
});
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Back, UIInputButtonShowMode.BottomRight)]
|
||||
private void OnBack()
|
||||
{
|
||||
if (Settings.Instance.HaveNotAppleSettings())
|
||||
{
|
||||
MessageBox.Show("还有未保存的信息", (b) =>
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
CancelAndBack();
|
||||
Hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
base.OnHide();
|
||||
InputManager.Instance.Off(this);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
MenuList.OnTabChange -= ChangeTab;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/SettingPanel.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/SettingPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9daadae7a1573774cb1b07ea9dc5b077
|
||||
32
Assets/Scripts/UI/Settings/SettingWaitInputPanel.Designer.cs
generated
Normal file
32
Assets/Scripts/UI/Settings/SettingWaitInputPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,32 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary> </summary>
|
||||
public partial class SettingWaitInputPanel
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
public override string UIPackName => "Main";
|
||||
public override string UIResName => "SettingWaitInputPanel";
|
||||
|
||||
[AutoFind(Name = "back")]
|
||||
public GImage back;
|
||||
[AutoFind(Name = "TextTime")]
|
||||
public GTextField TextTime;
|
||||
[AutoFind(Name = "BtnCancel")]
|
||||
public BtnTitleInputControl BtnCancel;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common","CommonNew"}; }
|
||||
|
||||
public static void Show(object param = null){ UI.Inst.OpenUI<SettingWaitInputPanel>(param); }
|
||||
|
||||
public static void Hide(){ UI.Inst.HideUI<SettingWaitInputPanel>(); }
|
||||
|
||||
public static void Del(){ UI.Inst.DestroyUI<SettingWaitInputPanel>(); }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 516cf8ed4abe3a14a8e101f8ec0d6924
|
||||
108
Assets/Scripts/UI/Settings/SettingWaitInputPanel.cs
Normal file
108
Assets/Scripts/UI/Settings/SettingWaitInputPanel.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using NBF.Setting;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class SettingWaitInputPanel : UIPanel
|
||||
{
|
||||
private SettingItem _settingItem;
|
||||
private InputOption _inputOption;
|
||||
private InputActionRebindingExtensions.RebindingOperation rebindingOperation;
|
||||
private int _time;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
IsModal = true;
|
||||
BtnCancel.onClick.Set(Hide);
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
_time = 5;
|
||||
Timer.Loop(1, this, OnTimer);
|
||||
TextTime.text = _time.ToString();
|
||||
_settingItem = GetData() as SettingItem;
|
||||
if (_settingItem == null)
|
||||
{
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_settingItem.Option is InputOption inputOption)
|
||||
{
|
||||
_inputOption = inputOption;
|
||||
OnRebinding();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTimer()
|
||||
{
|
||||
_time--;
|
||||
TextTime.text = _time.ToString();
|
||||
if (_time <= 0)
|
||||
{
|
||||
OnBack();
|
||||
}
|
||||
}
|
||||
|
||||
#region 按键绑定
|
||||
|
||||
private void OnRebinding()
|
||||
{
|
||||
_inputOption.InputAction.Disable();
|
||||
// 开始重绑定操作
|
||||
rebindingOperation = _inputOption.InputAction.PerformInteractiveRebinding(_inputOption.BindingIndex)
|
||||
.OnMatchWaitForAnother(0.1f)
|
||||
.WithCancelingThrough("<Keyboard>/escape")
|
||||
.WithControlsExcluding("<Pointer>/press")
|
||||
.WithControlsExcluding("<Mouse>/press")
|
||||
.WithControlsExcluding("<Mouse>/leftButton")
|
||||
.WithControlsExcluding("<Mouse>/rightButton")
|
||||
.OnComplete(operation => RebindComplete())
|
||||
.OnCancel(operation => OnRebindCanceled())
|
||||
.Start();
|
||||
}
|
||||
|
||||
private void RebindComplete()
|
||||
{
|
||||
var bindings = _inputOption.InputAction.bindings;
|
||||
for (int i = 0; i < bindings.Count; i++)
|
||||
{
|
||||
var bin = bindings[i];
|
||||
Log.Info($"RebindComplete==={bin.path}");
|
||||
}
|
||||
|
||||
rebindingOperation.Dispose();
|
||||
_inputOption.InputAction.Enable();
|
||||
UpdateValueText();
|
||||
}
|
||||
|
||||
private void OnRebindCanceled()
|
||||
{
|
||||
rebindingOperation.Dispose();
|
||||
_inputOption.InputAction.Enable();
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void UpdateValueText()
|
||||
{
|
||||
_settingItem.UpdateValueText();
|
||||
Hide();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
[InputInvoke(InputDef.UI.Back)]
|
||||
private void OnBack()
|
||||
{
|
||||
rebindingOperation.Cancel();
|
||||
Hide();
|
||||
Timer.ClearAll(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/SettingWaitInputPanel.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/SettingWaitInputPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebd4baa307d417f48ade9e2c8255ace9
|
||||
Reference in New Issue
Block a user