Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
* The format used to display the integer.
* This is the syntax used in {@link String#format(String, Object...)}.
*/
String format() default "%.0f";
String format() default "%d";
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@
*/
int max();

/**
* The step size of this slider.
* <p>
* For example, if this is set to 1, the slider will
* increment/decrement by 1 when dragging, no less, no more and
* will always be a multiple of 1.
*/
int step();

/**
* The format used to display the integer.
* This is the syntax used in {@link String#format(String, Object...)}.
*/
int step();
String format() default "%d";
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
* The format used to display the long.
* This is the syntax used in {@link String#format(String, Object...)}.
*/
String format() default "%.0f";
String format() default "%d";
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@
long max();

/**
* The format used to display the integer.
* This is the syntax used in {@link String#format(String, Object...)}.
* The step size of this slider.
* <p>
* For example, if this is set to 1, the slider will
* increment/decrement by 1 when dragging, no less, no more and
* will always be a multiple of 1.
*/
long step();

/**
* The format used to display the long.
* This is the syntax used in {@link String#format(String, Object...)}.
*/
String format() default "%d";
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected ControllerBuilder<Integer> createController(IntField annotation, Confi
key = getTranslationKey(field, "fmt");
if (Language.getInstance().has(key))
return Component.translatable(key, v);
return Component.literal(Integer.toString(v));
return Component.literal(String.format(annotation.format(), v));
})
.range(annotation.min(), annotation.max());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected ControllerBuilder<Integer> createController(IntSlider annotation, Conf
key = getTranslationKey(field, "fmt");
if (Language.getInstance().has(key))
return Component.translatable(key, v);
return Component.literal(Integer.toString(v));
return Component.literal(String.format(annotation.format(), v));
})
.range(annotation.min(), annotation.max())
.step(annotation.step());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected ControllerBuilder<Long> createController(LongField annotation, ConfigF
key = getTranslationKey(field, "fmt");
if (Language.getInstance().has(key))
return Component.translatable(key, v);
return Component.literal(Long.toString(v));
return Component.literal(String.format(annotation.format(), v));
})
.range(annotation.min(), annotation.max());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected ControllerBuilder<Long> createController(LongSlider annotation, Config
key = getTranslationKey(field, "fmt");
if (Language.getInstance().has(key))
return Component.translatable(key, v);
return Component.literal(Long.toString(v));
return Component.literal(String.format(annotation.format(), v));
})
.range(annotation.min(), annotation.max())
.step(annotation.step());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AutogenConfigTest {
.build();

@AutoGen(category = "test", group = "master_test")
@MasterTickBox({ "testTickBox", "testBoolean", "testInt", "testDouble", "testFloat", "testLong", "testIntField", "testDoubleField", "testFloatField", "testLongField", "testEnum", "testColor", "testString", "testDropdown", "testItem" })
@MasterTickBox({ "testTickBox", "testBoolean", "testInt", "testDouble", "testFloat", "testLong", "testLongFormatted", "testIntField", "testDoubleField", "testFloatField", "testLongField", "testEnum", "testColor", "testString", "testDropdown", "testItem" })
@SerialEntry(comment = "This option disables all the other options in this group")
public boolean masterOption = true;

Expand Down Expand Up @@ -64,6 +64,10 @@ public class AutogenConfigTest {
@LongSlider(min = 0, max = 10, step = 2)
@SerialEntry public long testLong = 0;

@AutoGen(category = "test", group = "master_test")
@LongSlider(min = 0, max = 1000, step = 10, format = "%dms")
@SerialEntry public long testLongFormatted = 500;

@AutoGen(category = "test", group = "master_test")
@IntField(min = 0, max = 10)
@SerialEntry public int testIntField = 0;
Expand Down