terrarium-earth / Heracles

A tree style questing mod allowing creators to set completable quests for their users
MIT License
35 stars 19 forks source link

fix: Text setting length is limited to 32 chars #251

Closed execsuroot closed 1 month ago

execsuroot commented 1 month ago

We should be setting the max length limit before we set the value, otherwise the text will be shrunk in the EditBox#setValue method.

    public void setValue(String text) {
        if (this.filter.test(text)) {
            if (text.length() > this.maxLength) {
                this.value = text.substring(0, this.maxLength);
            } else {
                this.value = text;
            }

            this.moveCursorToEnd();
            this.setHighlightPos(this.cursorPos);
            this.onValueChange(text);
        }
    }

Originally we call setValue first, and only then follow it with setMaxLength, the text is already shrunk at that point. This PR prioritizes setting the max length first to avoid this issue.

ThatGravyBoat commented 1 month ago

Thank you ❤️