isXander / YetAnotherConfigLib

YetAnotherConfigLib (yacl) is just that. A builder-based configuration library for Minecraft.
GNU Lesser General Public License v3.0
96 stars 37 forks source link

Suggestion: Make OptionListWidget.Entry a static inner class #76

Open Qendolin opened 1 year ago

Qendolin commented 1 year ago

Non static inner classes are annoying to extend because you cannot do it in a separate file. If I want to customize the entries, I have to extend OptionListWidget as well and I cannot split the code into multiple files.

isXander commented 1 year ago

What is your goal here? It's not recommended to mixin into YACL internals.

Qendolin commented 1 year ago

I'm actually trying to avoid mixins. For my mod want the settings screen to be transparent when the player is in a world. I'm also fixing a few issues.

For example your mouseScrolled scrolls the screen and then then the first element that consumes it. I have a (select) widget that consumes scroll input but the screen then also scrolls so I changed it to:

    @Override
    public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
        for (Entry child : children()) {
            if (child.mouseScrolled(mouseX, mouseY, amount)) {
                return true;
            }
        }

        this.setScrollAmount(this.getScrollAmount() - amount * 20);
        return true;
    }

Also I'm replacing some entries after resetOptions with a proxy entry that delegates all method calls to the original and provides an onBeforeRender and onAfterRender callback.

I'm also adding an blank entry at the bottom to add some padding to the list.