Merge branch 'master' of https://git.bobsong.cn/Game/Fishing2
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class ControllerOption : OptionBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75e11d5298cd48718d39a3e2af82472f
|
||||
timeCreated: 1749634909
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class InputOption : OptionBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0df4bee5d9b54ada8be3757d7fe02e30
|
||||
timeCreated: 1749634814
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class KeyBoardOption : InputOption
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 509d2fb0106b42b79854cca29707207d
|
||||
timeCreated: 1749634771
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace NBF.Options.Input
|
||||
{
|
||||
public class InputAddBobSetting
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 673bfd453717403998342a57e58b9b3a
|
||||
timeCreated: 1749634714
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user