Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/at/feldim2425/moreoverlays/MoreOverlays.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public void onClientInit(FMLClientSetupEvent event){
}

public Screen openSettings(Minecraft mc, Screen modlist){
return new ConfigScreen(Config.config_client, MOD_ID);
return new ConfigScreen(modlist, Config.config_client, MOD_ID);
}
}
44 changes: 29 additions & 15 deletions src/main/java/at/feldim2425/moreoverlays/gui/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import at.feldim2425.moreoverlays.MoreOverlays;
import at.feldim2425.moreoverlays.gui.config.ConfigOptionList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.resources.I18n;
Expand All @@ -26,20 +27,30 @@ public class ConfigScreen extends Screen {
private String txtUndo = "";
private String txtReset = "";

private Screen modListScreen;

public ConfigScreen(ForgeConfigSpec spec, String modId) {
public ConfigScreen(Screen modListScreen, ForgeConfigSpec spec, String modId) {
super(new TranslationTextComponent("gui.config."+modId+".tile"));
this.modListScreen = modListScreen;
this.configSpec = spec;
this.modId = modId;
this.modId = modId;

this.txtReset = I18n.format("gui.config." + MoreOverlays.MOD_ID + ".reset_config");
this.txtUndo = I18n.format("gui.config." + MoreOverlays.MOD_ID + ".undo");
}

@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 @@ -58,16 +69,19 @@ protected void init() {
this.btnUndo.active = false;
this.btnSave.active = false;


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

private void back() {
if(!this.optionList.getCurrentPath().isEmpty()){
this.optionList.pop();
}
else {
this.optionList.setConfiguration(configSpec, this.pathCache);
Minecraft.getInstance().displayGuiScreen(modListScreen);
}
}
@Override
}

@Override
public void render(int mouseX, int mouseY, float partialTick) {
this.renderBackground();
this.optionList.render(mouseX, mouseY, partialTick);
Expand Down Expand Up @@ -117,12 +131,12 @@ public void updatePath(final List<String> newPath){

@Override
public boolean keyPressed(int key, int p_keyPressed_2_, int p_keyPressed_3_) {
if(key == 256 && !this.optionList.getCurrentPath().isEmpty()){
this.optionList.pop();
return true;
if (key == 256) {
this.back();
return true;
}
else {
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 Expand Up @@ -186,6 +191,7 @@ else if(cEntry.getValue() instanceof ForgeConfigSpec.BooleanValue){
this.addEntry(new OptionGeneric<>(this, (ForgeConfigSpec.ConfigValue<?>)cEntry.getValue(), (ForgeConfigSpec.ValueSpec)rootConfig.getSpec().get(fullPath)));
}
}
this.setFocused(null);
}

public List<String> getCurrentPath() {
Expand Down