YetAnotherConfigLib

YetAnotherConfigLib

13M Downloads

Save Changes doesn't exit the config menu

falseresync opened this issue ยท 5 comments

commented

I have:

  1. Setup a config with AutoGen
  2. Setup a ModMenu integration

When I click Save changes, no matter if I am in Game or on the Main menu, it does save the config file, but it doesn't exit the config screen.
The only way to exit is to click Cancel, or to click Undo (which doesn't undo the changes because I have already clicked Save changes) and then click Done

commented

Thanks! This should be a fairly easy PR, I'll see if I could do this in the next couple of days

Xander fixed it in commit 5c110c8. So now, you can just add this mixin to your project until an update with the fix is released.

@Mixin(YACLScreen.class)
public class YACLScreenMixin
{
    @Shadow
    private boolean pendingChanges;

    @Shadow
    @Final
    public TabManager tabManager;

    @Inject(method = "finishOrSave", at = @At(value = "INVOKE", target = "Ljava/util/Set;forEach(Ljava/util/function/Consumer;)V", shift = At.Shift.AFTER), remap = false)
    public void tempSaveButtonFix(CallbackInfo ci)
    {
        this.pendingChanges = false;

        if (this.tabManager.getSelectedTab() instanceof YACLScreen.CategoryTab categoryTab)
            categoryTab.updateButtons();
    }
} 
commented

A workaround you can do for now and what I'm also doing in my project is just to close the screen yourself.

This is what I'm doing:

public Screen getHandle()
    {
        return YetAnotherConfigLib.createBuilder()
                .title(Text.translatable("iridium.options.gui_title"))
                .categories(this.optionCategories)
                .save(() ->
                {
                    this.client.options.write();
                    this.iridiumGameOptions.write();

                    // TODO: (Ayydan) Remove this when YACL has fixed the issue with the "Save Changes" button not working properly.
                    //  Refer to this GitHub issue on its repo for more details: https://github.com/isXander/YetAnotherConfigLib/issues/142
                    this.client.setScreen(this.parentScreen);
                })
                .build()
                .generateScreen(this.parentScreen);
    }

Hope this helps.

commented

Thanks! This should be a fairly easy PR, I'll see if I could do this in the next couple of days

commented

Thanks again!

commented

Fixed in v3.3.2