Skip to content

Commit 77760d7

Browse files
committed
Remember previous scroll position on config screen
1 parent 6740857 commit 77760d7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

common/src/main/java/org/embeddedt/modernfix/screen/ModernFixConfigScreen.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class ModernFixConfigScreen extends Screen {
1313

1414
public boolean madeChanges = false;
1515
private Button doneButton, wikiButton;
16+
private double lastScrollAmount = 0;
17+
1618
public ModernFixConfigScreen(Screen lastScreen) {
1719
super(new TranslatableComponent("modernfix.config"));
1820
this.lastScreen = lastScreen;
@@ -21,6 +23,7 @@ public ModernFixConfigScreen(Screen lastScreen) {
2123
@Override
2224
protected void init() {
2325
this.optionList = new OptionList(this, this.minecraft);
26+
this.optionList.setScrollAmount(lastScrollAmount);
2427
this.children.add(this.optionList);
2528
this.wikiButton = new Button(this.width / 2 - 155, this.height - 29, 150, 20, new TranslatableComponent("modernfix.config.wiki"), (arg) -> {
2629
Util.getPlatform().openUri("https://github.com/embeddedt/ModernFix/wiki/Summary-of-Patches");
@@ -50,4 +53,8 @@ public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTic
5053
public void renderComponentHoverEffect(PoseStack matrixStack, @Nullable Style style, int mouseX, int mouseY) {
5154
super.renderComponentHoverEffect(matrixStack, style, mouseX, mouseY);
5255
}
56+
57+
public void setLastScrollAmount(double d) {
58+
this.lastScrollAmount = d;
59+
}
5360
}

common/src/main/java/org/embeddedt/modernfix/screen/OptionList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public OptionEntry(String optionName, Option option) {
158158
});
159159
updateStatus();
160160
this.helpButton = new Button(75, 0, 20, 20, new TextComponent("?"), (arg) -> {
161+
mainScreen.setLastScrollAmount(getScrollAmount());
161162
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
162163
});
163164
if(!I18n.exists("modernfix.option." + optionName)) {

0 commit comments

Comments
 (0)