Skip to content

Commit 268c692

Browse files
committed
Rename the 'Enum' metadata label to 'Values', based on UX feedback.
1 parent c34dc29 commit 268c692

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎CLAUDE.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ A comment line that begins and ends in a trailing // should be considered a "cat
2929
// This is a category header //
3030
///////////////////////////////
3131
32-
set g_nFooNumber 42 // This is the Foo value. Range: [0-42]
33-
set g_fBarNumber 42.42 // This is the Bar value. Range: [0.0-100.0]
32+
set g_nFooNumber 42 // This is the Foo value.
33+
set g_fBarNumber 45.67 // This is the Bar value.
3434
3535
// This is also a category header //
3636
set g_bSomethingEnabled 1
@@ -133,12 +133,14 @@ For boolean values, prefer text labels "ON" and "Off", not true/false or 1/0.
133133

134134
### Input validation and conversions:
135135

136-
Some cfg params may need a range enforced. If the description-comment contains `Range:[0-100]` treat that as the allowable range (inclusive). `Range:[0-]` means the value is unsigned (can't be negative) but no upper bound.
136+
Some cfg params may need a range enforced. If the description-comment contains `Range: [0-100]` treat that as the allowable range (inclusive). `Range: [0-]` means the value is unsigned (can't be negative) but no upper bound. `Range: [20-100, by 10]` means the range is [20-100] but values must step by 10 (viz. 20, 30, 40, ... 90, 100).
137+
138+
If existing cfg documents contain values outside the allowed range or stepping, that is fine -- highlight that condition (warning) in the UX.
137139

138140
Integer values: may be signed or unsigned. Always serialized as base-10 decimal, but accept hexadecimal input with leading 0x prefix .. eg "0x10000001" converts to 268435457.
139141

140-
Some integer values may be enumerations.. if the description-comment contains `Enum:[Low,Medium,High]` those labels can be presented, instead of 0,1,2.
142+
Some integer values may be enumerations.. if the description-comment contains `Values: [Low,Medium,High]` those labels can be presented, instead of 0,1,2. (The enums will always be zero-based, unique identifiers, not combinable bitfields.)
141143

142-
Floating-point values: no Infinities or NaNs, and no exponential notation.
144+
Floating-point values: no Infinities or NaNs, and no exponential notation. Always parsed using the "invariant" locale.. no localized radix or commas.
143145

144-
String values: a common user error is to paste in unicode fancy-quotes, instead of ascii 0x22 doublequotes. If the user pastes a string already wrapped in doublequote (0x22 or fancy quotes) or singalquotes, remove them (but when serializing, always use 0x22 doublequotes for string values)
146+
String values: a common user error is to paste in unicode fancy-quotes, instead of ascii 0x22 doublequotes. If the user pastes a string already wrapped in doublequote (0x22 or fancy quotes) or singlequotes, remove them (but when serializing, always use 0x22 doublequotes for string values).

‎src/BmsConfig/Core/ValueConverter.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static string DisplayName(ParamType type)
4646
}
4747

4848
/// <summary>
49-
/// Constraints parsed from a param's description text: "Range:[0-100]", "Range:[0-]", "Enum:[Low,Medium,High]".
49+
/// Constraints parsed from a param's description text: "Range: [0-100]", "Range: [0-]", "Values: [Low,Medium,High]".
5050
/// </summary>
5151
public sealed class ParamConstraints
5252
{
@@ -55,7 +55,7 @@ public sealed class ParamConstraints
5555
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
5656

5757
static readonly Regex s_enum = new Regex(
58-
@"Enum:\s*\[(?<labels>[^\]]*)\]",
58+
@"Values:\s*\[(?<labels>[^\]]*)\]",
5959
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
6060

6161
public static readonly ParamConstraints None = new ParamConstraints();

‎tests/BmsConfig.Tests/CfgDocumentTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void MergesLastWriterWins()
255255
CfgDocument bms = CfgDocument.Parse(
256256
"// GENERAL //\n" +
257257
"set g_bA 1 // A\n" +
258-
"set g_nB 2 // B Enum:[Low,Medium,High]\n" +
258+
"set g_nB 2 // B Values:[Low,Medium,High]\n" +
259259
"// GRAPHICS //\n" +
260260
"set g_fC 1.0 // C Range:[0-]\n");
261261
CfgDocument user = CfgDocument.Parse(

‎tests/BmsConfig.Tests/ValueConverterTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void UnsignedRange()
6363
[Fact]
6464
public void EnumLabels()
6565
{
66-
const string desc = "Quality. Enum:[Low, Medium, High]";
66+
const string desc = "Quality. Values: [Low, Medium, High]";
6767
Assert.Equal("2", Convert("g_nX", "high", desc));
6868
Assert.Equal("1", Convert("g_nX", "1", desc));
6969
Assert.Null(Convert("g_nX", "3", desc));

0 commit comments

Comments
 (0)