diff --git a/Assets/Scripts/Common/Services/Settings/Base/ControllerOption.cs b/Assets/Scripts/Common/Services/Settings/Base/ControllerOption.cs new file mode 100644 index 000000000..78811b546 --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/ControllerOption.cs @@ -0,0 +1,6 @@ +namespace NBF.Setting +{ + public abstract class ControllerOption : OptionBase + { + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/ControllerOption.cs.meta b/Assets/Scripts/Common/Services/Settings/Base/ControllerOption.cs.meta new file mode 100644 index 000000000..8edebfc3f --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/ControllerOption.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 75e11d5298cd48718d39a3e2af82472f +timeCreated: 1749634909 \ 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 new file mode 100644 index 000000000..beb03bd39 --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs @@ -0,0 +1,6 @@ +namespace NBF.Setting +{ + public abstract class InputOption : OptionBase + { + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs.meta b/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs.meta new file mode 100644 index 000000000..715bb9eaa --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/InputOption.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0df4bee5d9b54ada8be3757d7fe02e30 +timeCreated: 1749634814 \ 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 new file mode 100644 index 000000000..6b9b36eb1 --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs @@ -0,0 +1,6 @@ +namespace NBF.Setting +{ + public abstract class KeyBoardOption : InputOption + { + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs.meta b/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs.meta new file mode 100644 index 000000000..6f1f6cb44 --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Base/KeyBoardOption.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 509d2fb0106b42b79854cca29707207d +timeCreated: 1749634771 \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Base/MultiOption.cs b/Assets/Scripts/Common/Services/Settings/Base/MultiOption.cs index aac475db0..0a7b88692 100644 --- a/Assets/Scripts/Common/Services/Settings/Base/MultiOption.cs +++ b/Assets/Scripts/Common/Services/Settings/Base/MultiOption.cs @@ -7,14 +7,13 @@ namespace NBF.Setting public interface IMultiOption : IOptionBase { List GetOptionNames(); - string GetName(); } public abstract class MultiOption : OptionBase, IMultiOption { protected OptionTable OptionTable = new OptionTable(); - + protected void AddOption(string name, T value) { OptionTable.Add(name, value); @@ -22,11 +21,7 @@ namespace NBF.Setting public List GetOptionNames() => OptionTable.GetNames(); - public string GetName() - { - return OptionTable.GetName(Value); - } - + protected void SelectOption(T value, int defaultIndex = 0) { SetValue(TryGetIndex(value, out var index) ? index : defaultIndex); @@ -59,5 +54,10 @@ namespace NBF.Setting } public T GetSelectedOption() => OptionTable.GetValue(Value); + + public override string GetDisplayString() + { + return OptionTable.GetName(Value); + } } } \ 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 65ed27484..629ff44fc 100644 --- a/Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs +++ b/Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs @@ -11,6 +11,7 @@ namespace NBF.Setting void SetValue(int index); bool HaveNotApple(); ISettings Root { get; } + string GetDisplayString(); } public abstract class OptionBase : IOptionBase @@ -50,6 +51,8 @@ namespace NBF.Setting } public ISettings Root { get; private set; } + + public void Initialize(ISettings root) { @@ -81,6 +84,11 @@ namespace NBF.Setting Value = DefaultValue; } + public virtual string GetDisplayString() + { + return GetValue().ToString(); + } + public virtual int GetValue() { return Value; diff --git a/Assets/Scripts/Common/Services/Settings/Base/RangeOption.cs b/Assets/Scripts/Common/Services/Settings/Base/RangeOption.cs index 304b1ef44..a2f08e3fc 100644 --- a/Assets/Scripts/Common/Services/Settings/Base/RangeOption.cs +++ b/Assets/Scripts/Common/Services/Settings/Base/RangeOption.cs @@ -1,4 +1,7 @@ -namespace NBF.Setting +using System; +using System.Globalization; + +namespace NBF.Setting { /// /// 范围设置 @@ -9,12 +12,22 @@ public abstract int MaxValue { get; } public virtual int ShowRate => 0; - + public override void SetValue(int value) { if (value > MaxValue) value = MaxValue; else if (value < MinValue) value = MinValue; Value = value; } + + public override string GetDisplayString() + { + if (ShowRate > 0) + { + return Math.Round(GetValue() / (ShowRate * 1f), 1).ToString(CultureInfo.InvariantCulture); + } + + return base.GetDisplayString(); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Options/Input/InputAddBobSetting.cs b/Assets/Scripts/Common/Services/Settings/Options/Input/InputAddBobSetting.cs new file mode 100644 index 000000000..4d1b8b5d6 --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Options/Input/InputAddBobSetting.cs @@ -0,0 +1,7 @@ +namespace NBF.Options.Input +{ + public class InputAddBobSetting + { + + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Options/Input/InputAddBobSetting.cs.meta b/Assets/Scripts/Common/Services/Settings/Options/Input/InputAddBobSetting.cs.meta new file mode 100644 index 000000000..6a797213a --- /dev/null +++ b/Assets/Scripts/Common/Services/Settings/Options/Input/InputAddBobSetting.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 673bfd453717403998342a57e58b9b3a +timeCreated: 1749634714 \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Options/Input/Play.meta b/Assets/Scripts/Common/Services/Settings/Options/Input/Play.meta deleted file mode 100644 index 417034393..000000000 --- a/Assets/Scripts/Common/Services/Settings/Options/Input/Play.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a62c4b82ff5b41fcb8dce043124b2451 -timeCreated: 1749539107 \ No newline at end of file diff --git a/Assets/Scripts/Common/Services/Settings/Options/Input/UI.meta b/Assets/Scripts/Common/Services/Settings/Options/Input/UI.meta deleted file mode 100644 index 44f259279..000000000 --- a/Assets/Scripts/Common/Services/Settings/Options/Input/UI.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: acbdfd25f6584a93a4b750bb757ff2c3 -timeCreated: 1749539097 \ No newline at end of file diff --git a/Assets/Scripts/UI/Settings/SettingItem.cs b/Assets/Scripts/UI/Settings/SettingItem.cs index 402c4f26c..404ad7f8e 100644 --- a/Assets/Scripts/UI/Settings/SettingItem.cs +++ b/Assets/Scripts/UI/Settings/SettingItem.cs @@ -1,7 +1,5 @@ // 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖 -using System; -using System.Globalization; using FairyGUI; using NBC; using NBF.Setting; @@ -42,15 +40,6 @@ namespace NBF private void SetShow() { - if (Option is IMultiOption multiOption) - { - TextInfo.text = multiOption.GetName(); - } - else if (Option is RangeOption range) - { - Slider.value = range.GetValue(); - } - UpdateValueText(); } @@ -148,14 +137,12 @@ namespace NBF { if (Option is RangeOption range) { - if (range.ShowRate > 0) - { - TextSliderValue.text = Math.Round(range.GetValue() / 10f, 1).ToString(CultureInfo.InvariantCulture); - } - else - { - TextSliderValue.text = range.GetValue().ToString(); - } + Slider.value = range.GetValue(); + TextSliderValue.text = range.GetDisplayString(); + } + else if (Option is IMultiOption multiOption) + { + TextInfo.text = multiOption.GetDisplayString(); } } } diff --git a/FGUIProject/assets/Main/Com/SettingMask.xml b/FGUIProject/assets/Main/Com/SettingMask.xml new file mode 100644 index 000000000..1e9bb0edb --- /dev/null +++ b/FGUIProject/assets/Main/Com/SettingMask.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/FGUIProject/assets/Main/SettingPanel.xml b/FGUIProject/assets/Main/SettingPanel.xml index 4713a2537..ab990ce65 100644 --- a/FGUIProject/assets/Main/SettingPanel.xml +++ b/FGUIProject/assets/Main/SettingPanel.xml @@ -1,5 +1,5 @@ - + @@ -34,5 +34,6 @@ + \ No newline at end of file diff --git a/FGUIProject/assets/Main/package.xml b/FGUIProject/assets/Main/package.xml index 14730315d..bab810884 100644 --- a/FGUIProject/assets/Main/package.xml +++ b/FGUIProject/assets/Main/package.xml @@ -42,6 +42,7 @@ + \ No newline at end of file