- Added float, double settingentry types. Adjusted display formatting.
- Added menu refresh on Apply button. - Fixed package name resolution for invalid chars. - Added helper console command to get xml-safe name for use in localization files. - Made error messages for bad settings xml more descriptive. - Modified GUISlider. - Converted HarmonyEventPatchesService to a System. - Fixed package name resolution for incompatible names in Xml and files, in many places. - Fixed base textbox implementation for settings.
This commit is contained in:
@@ -66,7 +66,8 @@ public abstract class SettingBase : ISettingBase
|
||||
{
|
||||
new GUITextBox(new RectTransform(relativeSize, layoutGroup.RectTransform), font: GUIStyle.SmallFont)
|
||||
{
|
||||
OnEnterPressed = (box, txt) =>
|
||||
Text = GetStringValue(),
|
||||
OnTextChangedDelegate = (box, txt) =>
|
||||
{
|
||||
onSerializedValue?.Invoke(txt);
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.LuaCs.Data;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using OneOf;
|
||||
|
||||
namespace Barotrauma.LuaCs.Data;
|
||||
@@ -44,6 +46,19 @@ public class SettingRangeFloat : SettingRangeBase<float>
|
||||
}
|
||||
return base.TrySetValue(value);
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
public override void AddDisplayComponent(GUILayoutGroup layoutGroup, Vector2 relativeSize, Action<string> onSerializedValue)
|
||||
{
|
||||
GUIUtil.Slider(layoutGroup, new Vector2(MinValue, MaxValue), IncrementalSteps, labelFunc: val =>
|
||||
{
|
||||
return val.ToString("G4", CultureInfo.InvariantCulture);
|
||||
}, Value, setter: val =>
|
||||
{
|
||||
onSerializedValue?.Invoke(val.ToString());
|
||||
}, TextManager.Get(this.GetDisplayInfo().Tooltip), relativeSize);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public class SettingRangeInt : SettingRangeBase<int>
|
||||
@@ -73,4 +88,17 @@ public class SettingRangeInt : SettingRangeBase<int>
|
||||
}
|
||||
return base.TrySetValue(value);
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
public override void AddDisplayComponent(GUILayoutGroup layoutGroup, Vector2 relativeSize, Action<string> onSerializedValue)
|
||||
{
|
||||
GUIUtil.Slider(layoutGroup, new Vector2(MinValue, MaxValue), IncrementalSteps, labelFunc: val =>
|
||||
{
|
||||
return ((int)val).ToString();
|
||||
}, Value, setter: val =>
|
||||
{
|
||||
onSerializedValue?.Invoke(((int)val).ToString());
|
||||
}, TextManager.Get(this.GetDisplayInfo().Tooltip), relativeSize);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+3
@@ -34,6 +34,9 @@ public class SettingsEntryRegistrar : ISettingsRegistrationProvider
|
||||
RegisterSettingEntry<long>(configService, "long", valueChangePredicate);
|
||||
RegisterSettingEntry<ulong>(configService, "ulong", valueChangePredicate);
|
||||
RegisterSettingEntry<string>(configService, "string", valueChangePredicate);
|
||||
RegisterSettingEntry<float>(configService, "float", valueChangePredicate);
|
||||
RegisterSettingEntry<float>(configService, "single", valueChangePredicate);
|
||||
RegisterSettingEntry<double>(configService, "double", valueChangePredicate);
|
||||
|
||||
// ISettingRangeBase<T>
|
||||
configService.RegisterSettingTypeInitializer("rangeInt", cfgInfo =>
|
||||
|
||||
Reference in New Issue
Block a user