Make mod overrides higher priority than user configuration

Prevents players inadvertently enabling incompatible options
This commit is contained in:
embeddedt 2023-07-11 21:13:02 -04:00
parent 4c484f5125
commit 816346e919
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
3 changed files with 20 additions and 1 deletions

View File

@ -285,7 +285,10 @@ public class ModernFixEarlyConfig {
continue;
}
option.setEnabled(enabled, true);
if(!option.isModDefined())
option.setEnabled(enabled, true);
else
LOGGER.warn("Option '{}' already disabled by a mod. Ignoring user configuration", key);
}
}

View File

@ -128,7 +128,20 @@ public class OptionList extends ContainerObjectSelectionList<OptionList.Entry> {
this.option.setEnabled(!this.option.isEnabled(), !this.option.isUserDefined());
ModernFix.LOGGER.error("Unable to save config", e);
}
}, (btn, gfx, x, y) -> {
if(this.option.isModDefined()) {
String disablingMods = String.join(", ", this.option.getDefiningMods());
OptionList.this.mainScreen.renderTooltip(
gfx,
new TranslatableComponent("modernfix.option." + (this.option.isEnabled() ? "enabled" : "disabled"))
.append(new TranslatableComponent("modernfix.option.mod_override", disablingMods)),
x,
y
);
}
});
if(this.option.isModDefined())
this.toggleButton.active = false;
this.helpButton = new Button(75, 0, 20, 20, new TextComponent("?"), (arg) -> {
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
});

View File

@ -9,6 +9,9 @@
"modernfix.config.done_restart": "Done (restart required)",
"modernfix.option.on": "on",
"modernfix.option.off": "off",
"modernfix.option.disabled": "disabled",
"modernfix.option.enabled": "enabled",
"modernfix.option.mod_override": " by mods [%s]",
"modernfix.config.not_default": " (modified)",
"asynclocator.map.locating": "Map (Locating...)",
"asynclocator.map.none": "Map (No nearby feature found)",