Remember previous scroll position on config screen

This commit is contained in:
embeddedt 2023-10-25 14:56:37 -04:00
parent 6740857274
commit 77760d7dd2
2 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,8 @@ public class ModernFixConfigScreen extends Screen {
public boolean madeChanges = false;
private Button doneButton, wikiButton;
private double lastScrollAmount = 0;
public ModernFixConfigScreen(Screen lastScreen) {
super(new TranslatableComponent("modernfix.config"));
this.lastScreen = lastScreen;
@ -21,6 +23,7 @@ public class ModernFixConfigScreen extends Screen {
@Override
protected void init() {
this.optionList = new OptionList(this, this.minecraft);
this.optionList.setScrollAmount(lastScrollAmount);
this.children.add(this.optionList);
this.wikiButton = new Button(this.width / 2 - 155, this.height - 29, 150, 20, new TranslatableComponent("modernfix.config.wiki"), (arg) -> {
Util.getPlatform().openUri("https://github.com/embeddedt/ModernFix/wiki/Summary-of-Patches");
@ -50,4 +53,8 @@ public class ModernFixConfigScreen extends Screen {
public void renderComponentHoverEffect(PoseStack matrixStack, @Nullable Style style, int mouseX, int mouseY) {
super.renderComponentHoverEffect(matrixStack, style, mouseX, mouseY);
}
public void setLastScrollAmount(double d) {
this.lastScrollAmount = d;
}
}

View File

@ -158,6 +158,7 @@ public class OptionList extends ContainerObjectSelectionList<OptionList.Entry> {
});
updateStatus();
this.helpButton = new Button(75, 0, 20, 20, new TextComponent("?"), (arg) -> {
mainScreen.setLastScrollAmount(getScrollAmount());
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
});
if(!I18n.exists("modernfix.option." + optionName)) {