MaLiLib (Forge)

MaLiLib (Forge)

291k Downloads

ConfigStringList.setValueChangeCallback not work

plusls opened this issue ยท 3 comments

commented

In WidgetStringListEditEntry.java

    @Override
    public void applyNewValueToConfig()
    {
        if (this.isDummy() == false)
        {
            IConfigStringList config = this.parent.getParent().getConfig();
            List<String> list = config.getStrings();
            String value = this.textField.getTextField().getText();

            if (list.size() > this.listIndex)
            {
                // i think it should call ConfigStringList.onValueChanged
                list.set(this.listIndex, value);
                this.lastAppliedValue = value;
            }
        }
    }
commented

Yes that was broken. But all of that stuff has been entirely refactored already in the main development branch.

See:

this.resetButton.setActionListener((btn, mbtn) -> {
this.textField.setText(this.toStringConverter.apply(this.defaultValue));
if (this.originalListIndex < this.dataList.size())
{
this.dataList.set(this.originalListIndex, this.defaultValue);
}
this.resetButton.setEnabled(this.textField.getText().equals(this.toStringConverter.apply(this.defaultValue)) == false);
});
this.textField.setUpdateListenerAlways(true);
this.textField.setListener((newText) -> {
if (this.originalListIndex < this.dataList.size())
{
TYPE value = this.fromStringConverter.apply(newText);
if (value != null)
{
this.dataList.set(this.originalListIndex, value);
}
}
this.resetButton.setEnabled(newText.equals(this.toStringConverter.apply(this.defaultValue)) == false);
});

and:
this.config.setValues(ImmutableList.copyOf(this.getListWidget().getCurrentEntries()));
if (this.saveListener != null)
{
this.saveListener.onEvent();
}

commented

So when can merge it to 1,16 branch?

I'm just curious, because you said it was going to merge one year ago.

commented

I've been meaning to work on these rewrites for like 2 years now, and I started working on them properly around June 2020. A bunch of stuff has been done already and some more progress recently, but there are still a number of new systems to add. And after malilib itself is starting to be finished, I still need to also work on a a number of changes and additions and improvements for the other mods before I can start the next port to the later MC versions. So progress is being made, even if it's a lot slower than I'd like...