Skip to content

Commit

Permalink
Fix issue feldim2425#70: resetting values when resizing
Browse files Browse the repository at this point in the history
- Don't re-init the ConfigOptionList
- Add method to re-size the (existing) ConfigOptionList
  • Loading branch information
kmcnaught committed Mar 2, 2020
1 parent 3fecd90 commit b4e3c25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main/java/at/feldim2425/moreoverlays/gui/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ public ConfigScreen(Screen modListScreen, ForgeConfigSpec spec, String modId) {

@Override
protected void init() {
this.optionList = new ConfigOptionList(this.minecraft, this.modId, this);

if (this.optionList == null) {
this.optionList = new ConfigOptionList(this.minecraft, this.modId, this);

if(pathCache.isEmpty()){
this.optionList.setConfiguration(configSpec);
}
else {
this.optionList.setConfiguration(configSpec, this.pathCache);
}
}
final int buttonY = this.height - 32 + (32-20)/2;

this.btnReset = new Button(this.width-40, buttonY, 20, 20, ConfigOptionList.RESET_CHAR,
Expand All @@ -61,13 +69,7 @@ protected void init() {
this.btnUndo.active = false;
this.btnSave.active = false;


if(pathCache.isEmpty()){
this.optionList.setConfiguration(configSpec);
}
else {
this.optionList.setConfiguration(configSpec, this.pathCache);
}
this.optionList.updateGui();
}

private void back() {
Expand Down Expand Up @@ -137,4 +139,4 @@ public boolean keyPressed(int key, int p_keyPressed_2_, int p_keyPressed_3_) {
return super.keyPressed(key, p_keyPressed_2_, p_keyPressed_3_);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ protected int getScrollbarPosition() {
public int getRowWidth() {
return super.getRowWidth() + 64;
}

public void updateGui() {
this.updateSize(this.parent.width, this.parent.height, 43, this.parent.height - 32);
}


@Override
protected void renderDecorations(int p_renderDecorations_1_, int p_renderDecorations_2_) {
Expand Down

0 comments on commit b4e3c25

Please sign in to comment.