From ac946f41ed601c603363e9925b5194b840095a8e Mon Sep 17 00:00:00 2001 From: bob <605277374@qq.com> Date: Fri, 20 Jun 2025 17:56:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=94=AE=E7=BB=91=E5=AE=9A=E5=92=8C?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E4=BB=A5=E5=8F=8A=E5=8A=A0=E8=BD=BD=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/PlayerInputControl.inputactions | 20 +++++ Assets/Resources/Fgui/Common/Common_fui.bytes | Bin 33448 -> 33286 bytes Assets/Resources/Fgui/Main/Main_fui.bytes | Bin 11565 -> 12037 bytes .../Scripts/Common/Attrobites/Attributes.cs | 12 ++- .../Common/Services/Input/InputManager.cs | 5 +- .../Services/Settings/Base/GamepadOption.cs | 18 +++++ .../Settings/Base/GamepadOption.cs.meta | 3 + .../Services/Settings/Base/InputOption.cs | 69 +++++++++++++++++- .../Services/Settings/Base/KeyBoardOption.cs | 11 ++- .../Services/Settings/Base/OptionBase.cs | 8 +- Assets/Scripts/Def/InputDef.cs | 3 + Assets/Scripts/Def/UIDef.cs | 14 ++++ Assets/Scripts/Fishing/PlayerInputControl.cs | 39 ++++++++++ Assets/Scripts/NBC/UI/Runtime/UIManager.cs | 4 +- .../UI/Common/Panel/MessageBox.Designer.cs | 6 +- Assets/Scripts/UI/Common/Panel/MessageBox.cs | 4 +- Assets/Scripts/UI/Settings/KeyboardInput.cs | 6 +- .../Scripts/UI/Settings/SettingInputItem.cs | 58 +++++++++++++-- .../UI/Settings/SettingPanel.Designer.cs | 2 + Assets/Scripts/UI/Settings/SettingPanel.cs | 20 +++-- .../assets/Common/Panel/MessageBox.xml | 17 ++--- .../Main/Com/Items/SettingInputItem.xml | 4 +- FGUIProject/assets/Main/InputWaitingCom.xml | 9 +++ FGUIProject/assets/Main/SettingPanel.xml | 3 + FGUIProject/assets/Main/package.xml | 1 + .../settings/whoot/hxr7rc7p5dtx1d.json | 1 + Fishing2.sln.DotSettings.user | 1 + 27 files changed, 291 insertions(+), 47 deletions(-) create mode 100644 Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs create mode 100644 Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs.meta create mode 100644 FGUIProject/assets/Main/InputWaitingCom.xml create mode 100644 FGUIProject/settings/whoot/hxr7rc7p5dtx1d.json diff --git a/Assets/PlayerInputControl.inputactions b/Assets/PlayerInputControl.inputactions index 91a80884c..6db89102e 100644 --- a/Assets/PlayerInputControl.inputactions +++ b/Assets/PlayerInputControl.inputactions @@ -1018,6 +1018,15 @@ "processors": "", "interactions": "Hold", "initialStateCheck": false + }, + { + "name": "Reset", + "type": "Button", + "id": "b8805b50-7544-4249-b3b8-f6554dfb7a93", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -1350,6 +1359,17 @@ "action": "Up", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "3069f356-c73e-4bac-88f5-88bd6d746bc2", + "path": "/r", + "interactions": "", + "processors": "", + "groups": "", + "action": "Reset", + "isComposite": false, + "isPartOfComposite": false } ] } diff --git a/Assets/Resources/Fgui/Common/Common_fui.bytes b/Assets/Resources/Fgui/Common/Common_fui.bytes index 0842762939e1f4392a0ceb693ef507556a11affd..4d453ce38d245d8d6f7b627086e719a891eb15a0 100644 GIT binary patch delta 3942 zcmZvfdt6mj7RUG6`<{EXtAL^Rf_N|TIDlN_sXUUWC@Rm3B8UWv3XC>En)Y%8ohECV z8GEexSlNV4HTL*4Iz?$8E3`~|3}H{rEP7bl!?3578qDt;4t)G$;B)WycYbTFz1QAn z-^1mRo8;y{$=hdK;{RHhKP|JLnEiq`H9?8T#lOYQ!2uG&u~7(HCcUCQrh!yyYVu91_uWROxZG0U5E)QMdeWSKCvH7O)#oM>_VVRsl-^6 z8O3A73r003M8*caC=M9YAb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!+2#|%AQ-;4ZUwOiG|b``!m!H_#lRRxX(^%xsKy$;Qw zp2KFa7(5B;x%tl-^_8f zdRIGZOh>C_eU4wQajW|fnOAG7$G}GLez2w1bpF(+%QA;?5H&zOYNR(YTfDq zL}tt|or|^2cRij|YfKNr-ZaBhkAfS(d%$*Z7AR+$>KqscHi4yJA-D*<3v30e!M)%M z;8pNNFl3hL{L_s(#(wUc8K#Y^gJyPw8s6g zaUd^Q5F8zPw(aRto7SD-m8Z5ob9((Fr#7uTyKL*3rLCu5SSfrP6O-?4NaQo~!nti; U>_(sYzmxp*f(JK7H=gYG9}>!$aR2}S diff --git a/Assets/Resources/Fgui/Main/Main_fui.bytes b/Assets/Resources/Fgui/Main/Main_fui.bytes index d3062af0c61f9ba21642e8df67ebaffa9d866085..cf48ddf1ded95fd518bcc6459b2aac1f8a09cfbf 100644 GIT binary patch delta 1128 zcma)5TTE1E5dQxCPxr7&1$Nin!*XB|ST$%?mQ+QtRbxZcP+T97=!!%`V!SPyplR%b zpwfD4i_WSQ7135|t0KCsctH@nD_+o2eKuO?i?NTbk#)|oHTagnQty zH4ADdXui!bpW$DaKZ2zJ{p9S&3Cd*tN8=Nh(uSd{$ey%zs2C-&4ppd*^)pMY0+c+E zOG&4WWQ~dxw_J}6ROWTb!mis?t>ig3q6Ux!fMt-8_isifC8g^L7KuTK^&|Pwi&#tu zT9uL_zND#6eZ15pzQU%riVWriFXK2E8H_QE09$$)eT)}|mpVL75l2axPStp)E!aw* z*nOngz3MjBzs5JL7m9Cbt9_2F#ddmPUnX`?(BV>v{SoY>q+$7V#Nn2^u$wv^#o{~C zoY|D+aj5IK(>A1Kk4FY2k#HCjK6iUG9wScFA3G&2839H9u)8t9(O zKlmrM)Z%B}(o3pveIn4U4=33{;Yq(CawAbEQ=0Th_529cItHjD_ zZs6v7(%eGV|40*(xQ#p1l`+>m#k;uo?v z%$y*9t)_fp%6OkoJdEc0 zo-4)HvE`MY2g;E!BfN5TWy!)Nl}o~lr&X+g7y~t&Q)akf3Foj9_)iHSt?xujUmHEG zIo#J+-Ftrf)26!Kx{ZHq+x%yw$?x~muxuAi%--dU3kSx&jWQu~JNFRYn*c4W%S%Hw6Rg=HzzkG3`Emn)PUmOqMAk~>Y6te1R(j7-@&1R`d#G7$Q#C_~A zjhHKV3tGu+sby`{Xt7C0M7|wIsoS!Kcc7D|EamJNwOKQ%U6SattVsGwjxG>=u&y#4 z7a|bA2?TLc6jGmYex%x##Mminusir^oS{~G5ev|`Jxl3EgT#=85|p9>>rsOmBgC)Z z9C|3xQN)5&>d2OQMWh9N)aWSS0R(A83{#D@<2=CggqKX=G$-{s>{{OCT*xorBCT-d zi4J?5*~%sOwGS=DGOR>7{O}ubSrlHuRhkgA0R3Ca||LPhzUyNEW&a=gxfT%l(Av0p~}01yL0f~ z&nsj1{_sX{e-7UFv@-TU<Y$lFa*?mU`Kmo)`LLZafT;*ao{cDnxN z<1=J!<6&*%C9}Adh6Ii=Jo#t4r+D_??fe|iF-|4!b=uu~fr(jnPnKSa@xKz|pK|*& zMX!aTVoxD|BQ~7jPIJMgM>IAQo55Sb)Cn+%17Ls`+YzNv&jJ>uPnu2is{RtqR%^D| o>tU0Te(x7OeO+YLu^cjF1!*vA%otano4+xC)3zOvt&55M1ctf*TL1t6 diff --git a/Assets/Scripts/Common/Attrobites/Attributes.cs b/Assets/Scripts/Common/Attrobites/Attributes.cs index b512318ca..9944be87e 100644 --- a/Assets/Scripts/Common/Attrobites/Attributes.cs +++ b/Assets/Scripts/Common/Attrobites/Attributes.cs @@ -6,6 +6,17 @@ namespace NBF { } + [AttributeUsage(AttributeTargets.Class)] + public class UIBindAttribute : BaseAttribute + { + public int Id; + + public UIBindAttribute(int id) + { + this.Id = id; + } + } + [AttributeUsage(AttributeTargets.Field)] public class InputIconAttribute : BaseAttribute { @@ -57,5 +68,4 @@ namespace NBF Sort = sort; } } - } \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Input/InputManager.cs b/Assets/Scripts/Common/Services/Input/InputManager.cs index 0805fe885..c9d867ac0 100644 --- a/Assets/Scripts/Common/Services/Input/InputManager.cs +++ b/Assets/Scripts/Common/Services/Input/InputManager.cs @@ -64,12 +64,13 @@ namespace NBF { InputCursorExtension.InputInit(); DontDestroyOnLoad(gameObject); + PlayerInputControl = new PlayerInputControl(); + PlayerInputControl.Enable(); } private void Start() { - PlayerInputControl = new PlayerInputControl(); - PlayerInputControl.Enable(); + AddEvent(); } diff --git a/Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs b/Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs new file mode 100644 index 000000000..5e5aaba89 --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs @@ -0,0 +1,18 @@ +using UnityEngine.InputSystem; + +namespace NBF.Setting +{ + public abstract class GamepadOption : InputOption + { + protected override bool IsBindingContains(InputBinding binding) + { + var path = binding.path; + if (path.Contains("")) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs.meta b/Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs.meta new file mode 100644 index 000000000..806cb1347 --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/GamepadOption.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 49041e6a08b744038368d7010acf61ea +timeCreated: 1750408186 \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs b/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs index 285f497a9..bc4829e87 100644 --- a/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs +++ b/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs @@ -1,21 +1,84 @@ -using UnityEngine.InputSystem; +using UnityEngine; +using UnityEngine.InputSystem; namespace NBF.Setting { public abstract class InputOption : OptionBase { + private int _bindingIndex = 0; public abstract InputAction InputAction { get; } + public int BindingIndex => _bindingIndex; + protected override int DefaultValue => 0; - + + /// + /// 保存的值 + /// + protected string InputSaveValue; + + public override bool HaveNotApple() + { + return !InputAction.SaveBindingOverridesAsJson().Equals(InputSaveValue); + } + + public override void Apply() + { + // 保存绑定 + PlayerPrefs.SetString(SaveKey, InputAction.SaveBindingOverridesAsJson()); + SaveValue = Value; + OnApply(); + } + + public override void Load() + { + for (int i = 0; i < InputAction.bindings.Count; i++) + { + var binding = InputAction.bindings[i]; + if (IsBindingContains(binding)) + { + _bindingIndex = i; + break; + } + } + + var value = PlayerPrefs.GetString(SaveKey, string.Empty); + InputSaveValue = value; + if (!string.IsNullOrEmpty(InputSaveValue)) + { + InputAction.LoadBindingOverridesFromJson(InputSaveValue); + } + } + + public override void Reset() + { + if (InputAction.bindings[BindingIndex].isComposite) + { + // It's a composite. Remove overrides from part bindings. + for (var i = BindingIndex + 1; + i < InputAction.bindings.Count && InputAction.bindings[i].isPartOfComposite; + ++i) + InputAction.RemoveBindingOverride(i); + } + else + { + InputAction.RemoveBindingOverride(BindingIndex); + } + } + public override string GetDisplayString() { if (InputAction != null) { - return InputAction.GetBindingDisplayString(); + return InputAction.GetBindingDisplayString(BindingIndex); } return base.GetDisplayString(); } + + protected virtual bool IsBindingContains(InputBinding binding) + { + return true; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs b/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs index 264807d11..e7150ee69 100644 --- a/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs +++ b/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs @@ -4,6 +4,15 @@ namespace NBF.Setting { public abstract class KeyBoardOption : InputOption { - + protected override bool IsBindingContains(InputBinding binding) + { + var path = binding.path; + if (path.Contains("") || path.Contains("")) + { + return true; + } + + return false; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs b/Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs index 909ce01e8..612fc4f74 100644 --- a/Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs +++ b/Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs @@ -45,7 +45,7 @@ namespace NBF.Setting /// protected int SaveValue; - public bool HaveNotApple() + public virtual bool HaveNotApple() { return !Value.Equals(SaveValue); } @@ -64,21 +64,21 @@ namespace NBF.Setting /// /// 加载用户的设置 /// - public void Load() + public virtual void Load() { var value = PlayerPrefs.GetInt(SaveKey, DefaultValue); Value = value; SaveValue = value; } - public void Apply() + public virtual void Apply() { PlayerPrefs.SetInt(SaveKey, Value); SaveValue = Value; OnApply(); } - public void Reset() + public virtual void Reset() { Value = DefaultValue; } diff --git a/Assets/Scripts/Def/InputDef.cs b/Assets/Scripts/Def/InputDef.cs index 9e056b876..db041cf3f 100644 --- a/Assets/Scripts/Def/InputDef.cs +++ b/Assets/Scripts/Def/InputDef.cs @@ -18,6 +18,9 @@ namespace NBF [InputIcon("icon_controller_129", "icon_controller_1")] public const string Enter = "Enter"; + [InputIcon("icon_controller_129", "icon_controller_1")] + public const string Reset = "Reset"; + [InputIcon("icon_controller_127", "icon_controller_19")] public const string Tab = "Tab"; diff --git a/Assets/Scripts/Def/UIDef.cs b/Assets/Scripts/Def/UIDef.cs index 565405ac2..db009bd0d 100644 --- a/Assets/Scripts/Def/UIDef.cs +++ b/Assets/Scripts/Def/UIDef.cs @@ -83,5 +83,19 @@ namespace NBF [InspectorName("订购市场")] ReserveBazaar = 22 } + + public class ID + { + public const int Loading = 1; + public const int Home = 2; + public const int SettingPanel = 3; + public const int HelpPanel = 4; + public const int MapPanel = 5; + + public const int ShopPanel = 10; + public const int MakePanel = 11; + public const int BagPanel = 12; + public const int FishBagPanel = 13; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/PlayerInputControl.cs b/Assets/Scripts/Fishing/PlayerInputControl.cs index 199a8b95a..33440ed45 100644 --- a/Assets/Scripts/Fishing/PlayerInputControl.cs +++ b/Assets/Scripts/Fishing/PlayerInputControl.cs @@ -1106,6 +1106,15 @@ namespace NBF ""processors"": """", ""interactions"": ""Hold"", ""initialStateCheck"": false + }, + { + ""name"": ""Reset"", + ""type"": ""Button"", + ""id"": ""b8805b50-7544-4249-b3b8-f6554dfb7a93"", + ""expectedControlType"": """", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false } ], ""bindings"": [ @@ -1438,6 +1447,17 @@ namespace NBF ""action"": ""Up"", ""isComposite"": false, ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""3069f356-c73e-4bac-88f5-88bd6d746bc2"", + ""path"": ""/r"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Reset"", + ""isComposite"": false, + ""isPartOfComposite"": false } ] } @@ -1556,6 +1576,7 @@ namespace NBF m_UI_Left = m_UI.FindAction("Left", throwIfNotFound: true); m_UI_Down = m_UI.FindAction("Down", throwIfNotFound: true); m_UI_Up = m_UI.FindAction("Up", throwIfNotFound: true); + m_UI_Reset = m_UI.FindAction("Reset", throwIfNotFound: true); } ~@PlayerInputControl() @@ -2129,6 +2150,7 @@ namespace NBF private readonly InputAction m_UI_Left; private readonly InputAction m_UI_Down; private readonly InputAction m_UI_Up; + private readonly InputAction m_UI_Reset; /// /// Provides access to input actions defined in input action map "UI". /// @@ -2185,6 +2207,10 @@ namespace NBF /// public InputAction @Up => m_Wrapper.m_UI_Up; /// + /// Provides access to the underlying input action "UI/Reset". + /// + public InputAction @Reset => m_Wrapper.m_UI_Reset; + /// /// Provides access to the underlying input action map instance. /// public InputActionMap Get() { return m_Wrapper.m_UI; } @@ -2243,6 +2269,9 @@ namespace NBF @Up.started += instance.OnUp; @Up.performed += instance.OnUp; @Up.canceled += instance.OnUp; + @Reset.started += instance.OnReset; + @Reset.performed += instance.OnReset; + @Reset.canceled += instance.OnReset; } /// @@ -2287,6 +2316,9 @@ namespace NBF @Up.started -= instance.OnUp; @Up.performed -= instance.OnUp; @Up.canceled -= instance.OnUp; + @Reset.started -= instance.OnReset; + @Reset.performed -= instance.OnReset; + @Reset.canceled -= instance.OnReset; } /// @@ -2729,6 +2761,13 @@ namespace NBF /// /// void OnUp(InputAction.CallbackContext context); + /// + /// Method invoked when associated input action "Reset" is either , or . + /// + /// + /// + /// + void OnReset(InputAction.CallbackContext context); } } } diff --git a/Assets/Scripts/NBC/UI/Runtime/UIManager.cs b/Assets/Scripts/NBC/UI/Runtime/UIManager.cs index c744d2639..8ca43353e 100644 --- a/Assets/Scripts/NBC/UI/Runtime/UIManager.cs +++ b/Assets/Scripts/NBC/UI/Runtime/UIManager.cs @@ -129,7 +129,7 @@ namespace NBC _uiArray.Add(uiName, panel); } - public IUIPanel GetUI() + public T GetUI() where T : class { IUIPanel wind = null; Type type = typeof(T); @@ -141,7 +141,7 @@ namespace NBC break; } - return wind; + return wind as T; } public IUIPanel GetUI(Type type) diff --git a/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs b/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs index e3579bb71..b7186e927 100644 --- a/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs +++ b/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs @@ -19,12 +19,10 @@ namespace NBF public GImage box; [AutoFind(Name = "TextTitle")] public GTextField TextTitle; - [AutoFind(Name = "TextContent")] - public GTextField TextContent; - [AutoFind(Name = "BtnConfirm")] - public BtnTitleInputControl BtnConfirm; [AutoFind(Name = "BtnCancel")] public BtnTitleInputControl BtnCancel; + [AutoFind(Name = "BtnConfirm")] + public BtnTitleInputControl BtnConfirm; public override string[] GetDependPackages(){ return new string[] {}; } diff --git a/Assets/Scripts/UI/Common/Panel/MessageBox.cs b/Assets/Scripts/UI/Common/Panel/MessageBox.cs index 54610f47a..dcc8e194a 100644 --- a/Assets/Scripts/UI/Common/Panel/MessageBox.cs +++ b/Assets/Scripts/UI/Common/Panel/MessageBox.cs @@ -59,10 +59,10 @@ namespace NBF protected override void OnShow() { - TextTitle.SetLanguage(_title); + // TextTitle.SetLanguage(_title); BtnConfirm.SetLanguage(_confirmText); BtnCancel.SetLanguage(_cancelText); - TextContent.SetLanguage(_content); + TextTitle.SetLanguage(_content); MessageStyle.selectedIndex = _style; } diff --git a/Assets/Scripts/UI/Settings/KeyboardInput.cs b/Assets/Scripts/UI/Settings/KeyboardInput.cs index 847e51cd2..34474300e 100644 --- a/Assets/Scripts/UI/Settings/KeyboardInput.cs +++ b/Assets/Scripts/UI/Settings/KeyboardInput.cs @@ -1,10 +1,8 @@ // 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖 -using UnityEngine; + using FairyGUI; -using NBC; using NBF.Setting; -using UnityEngine.InputSystem; namespace NBF { @@ -20,7 +18,7 @@ namespace NBF if (option is KeyBoardOption) { TextKeyboard.visible = true; - TextKeyboard.text = option.GetDisplayString(); + TextKeyboard.text = option.GetDisplayString(); // + "- " + string.Join(",", list); } } } diff --git a/Assets/Scripts/UI/Settings/SettingInputItem.cs b/Assets/Scripts/UI/Settings/SettingInputItem.cs index 7078f8de4..c583a6d9a 100644 --- a/Assets/Scripts/UI/Settings/SettingInputItem.cs +++ b/Assets/Scripts/UI/Settings/SettingInputItem.cs @@ -1,36 +1,80 @@ // 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖 -using System.Globalization; -using UnityEngine; using FairyGUI; using NBC; using NBF.Setting; +using UnityEngine.InputSystem; namespace NBF { public partial class SettingInputItem : GButton { - public OptionBase Option; + public InputOption Option; + private InputActionRebindingExtensions.RebindingOperation rebindingOperation; + private void OnInited() { + BtnKeyboard.onClick.Set(OnClickRebind); + onChanged.Add(SelfChanged); } - public void SetData(OptionBase option) + public void SetData(InputOption option) { Option = option; TextName.SetLanguage(Option.Name); - SetShow(); + UpdateValueText(); } - private void SetShow() + public void OnClickRebind() { + // InputWaitingPanel.Show(true); + // UI.Inst.OpenUI(); + // 取消当前绑定 + var settingPanel = UI.Inst.GetUI(); + 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(); + + var settingPanel = UI.Inst.GetUI(); + settingPanel.InputWait.visible = false; + // UI.Inst.HideUI(); + // startRebindObject.SetActive(true); + // waitingForInputObject.SetActive(false); + } + + private void RebindCanceled() + { + rebindingOperation.Dispose(); + Option.InputAction.Enable(); + // UI.Inst.HideUI(); + } + + + private void SelfChanged(EventContext context) + { + if (!selected) + { + // RebindOver(); + } } private void UpdateValueText() { - BtnKeyboard.SetData(Option as InputOption); + BtnKeyboard.SetData(Option); } } } \ No newline at end of file diff --git a/Assets/Scripts/UI/Settings/SettingPanel.Designer.cs b/Assets/Scripts/UI/Settings/SettingPanel.Designer.cs index 37e8c9342..33af10bbb 100644 --- a/Assets/Scripts/UI/Settings/SettingPanel.Designer.cs +++ b/Assets/Scripts/UI/Settings/SettingPanel.Designer.cs @@ -23,6 +23,8 @@ namespace NBF public GImage BottomLine; [AutoFind(Name = "Mask")] public GLabel Mask; + [AutoFind(Name = "InputWait")] + public GComponent InputWait; public override string[] GetDependPackages(){ return new string[] {"Common"}; } diff --git a/Assets/Scripts/UI/Settings/SettingPanel.cs b/Assets/Scripts/UI/Settings/SettingPanel.cs index 118ce7e82..f3ffa540b 100644 --- a/Assets/Scripts/UI/Settings/SettingPanel.cs +++ b/Assets/Scripts/UI/Settings/SettingPanel.cs @@ -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> groupOptions = new Dictionary>(); @@ -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(); + }); + } } diff --git a/FGUIProject/assets/Common/Panel/MessageBox.xml b/FGUIProject/assets/Common/Panel/MessageBox.xml index 6510ef78b..b66e74754 100644 --- a/FGUIProject/assets/Common/Panel/MessageBox.xml +++ b/FGUIProject/assets/Common/Panel/MessageBox.xml @@ -11,22 +11,19 @@ - + - - - - - -