This commit is contained in:
2025-06-11 20:29:48 +08:00
15 changed files with 85 additions and 29 deletions

View File

@@ -0,0 +1,6 @@
namespace NBF.Setting
{
public abstract class ControllerOption : OptionBase
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 75e11d5298cd48718d39a3e2af82472f
timeCreated: 1749634909

View File

@@ -0,0 +1,6 @@
namespace NBF.Setting
{
public abstract class InputOption : OptionBase
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0df4bee5d9b54ada8be3757d7fe02e30
timeCreated: 1749634814

View File

@@ -0,0 +1,6 @@
namespace NBF.Setting
{
public abstract class KeyBoardOption : InputOption
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 509d2fb0106b42b79854cca29707207d
timeCreated: 1749634771

View File

@@ -7,14 +7,13 @@ namespace NBF.Setting
public interface IMultiOption : IOptionBase
{
List<string> GetOptionNames();
string GetName();
}
public abstract class MultiOption<T> : OptionBase, IMultiOption
{
protected OptionTable<T> OptionTable = new OptionTable<T>();
protected void AddOption(string name, T value)
{
OptionTable.Add(name, value);
@@ -22,11 +21,7 @@ namespace NBF.Setting
public List<string> 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);
}
}
}

View File

@@ -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;

View File

@@ -1,4 +1,7 @@
namespace NBF.Setting
using System;
using System.Globalization;
namespace NBF.Setting
{
/// <summary>
/// 范围设置
@@ -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();
}
}
}

View File

@@ -0,0 +1,7 @@
namespace NBF.Options.Input
{
public class InputAddBobSetting
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 673bfd453717403998342a57e58b9b3a
timeCreated: 1749634714