YetAnotherConfigLib

YetAnotherConfigLib

13M Downloads

NumberFieldControllers increase their values by ^10 when clicking on screen

Rasmion opened this issue ยท 0 comments

commented

When using a FloatFieldController or DoubleFieldController there seems to be an error on how the number is read back from the input field.
Everytime you click on an area that is not the option, the value increases by ^10 with some exceptions.
Another issue is, that you cannot close the config screen, because every time you click on done/save changes, the values are changed.

This bug occours on version '3.1.0+1.20 (Fabric)' and was tested by me and a friend in seperate projects.
edit: version '3.1.1+1.20 (Fabric)' is also affected.

Showcase video:

2023-08-29-16-14-47.mp4

Code from the video (written in Kotlin):

    private const val TEST_FLOAT_DEFAULT = 0.00002f
    private var testFloat = 0f

    private fun buildTestFloat() =
        Option.createBuilder<Float>()
            .name(Text.of("Float Test"))
            .description { it ->
                OptionDescription.of(Text.of("""
                    This is a test option for floats.
                    It has a default value of $TEST_FLOAT_DEFAULT.
                    Current value: $it
                    """.trimIndent()))
            }
            .binding(TEST_FLOAT_DEFAULT, { testFloat }, { it -> testFloat = it })
            .controller { it ->
                FloatFieldControllerBuilder.create(it).valueFormatter { Text.literal(it.toString()) }
            }.build()

Here I'm using Text.literal(it.toString()) but the results are the same if you use the default formatter or any other.