From ab3cd3f30750af06ce9ef87e68931dd04af504bc Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 16 Jul 2019 17:52:39 +0200 Subject: [PATCH] Fixed pony settings not going back to the ModMenu screen when opened from there --- .../java/com/minelittlepony/client/MineLittlePony.java | 4 ++-- .../com/minelittlepony/client/gui/GuiPonySettings.java | 8 +++++--- .../client/hdskins/gui/GuiSkinsMineLP.java | 9 ++++----- .../client/modmenu/MineLPModMenuFactory.java | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/MineLittlePony.java b/src/main/java/com/minelittlepony/client/MineLittlePony.java index 77e834e0..8b1406ba 100644 --- a/src/main/java/com/minelittlepony/client/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/client/MineLittlePony.java @@ -113,7 +113,7 @@ public class MineLittlePony implements ClientModInitializer { } if ((mainMenu || inGame) && keyBinding.isPressed()) { - client.openScreen(new GuiPonySettings()); + client.openScreen(new GuiPonySettings(client.currentScreen)); } else if (inGame) { long handle = client.window.getHandle(); @@ -149,7 +149,7 @@ public class MineLittlePony implements ClientModInitializer { if (show) { int y = hasHdSkins ? 75 : 50; Button button = buttons.add(new Button(screen.width - 50, screen.height - y, 20, 20)) - .onClick(sender -> MinecraftClient.getInstance().openScreen(new GuiPonySettings())); + .onClick(sender -> MinecraftClient.getInstance().openScreen(new GuiPonySettings(screen))); button.getStyle() .setIcon(new TextureSprite() .setPosition(2, 2) diff --git a/src/main/java/com/minelittlepony/client/gui/GuiPonySettings.java b/src/main/java/com/minelittlepony/client/gui/GuiPonySettings.java index 152bb21b..2cceedd0 100644 --- a/src/main/java/com/minelittlepony/client/gui/GuiPonySettings.java +++ b/src/main/java/com/minelittlepony/client/gui/GuiPonySettings.java @@ -17,6 +17,8 @@ import com.minelittlepony.common.client.gui.element.Toggle; import com.minelittlepony.common.util.settings.Setting; import com.minelittlepony.settings.PonyLevel; +import javax.annotation.Nullable; + /** * In-Game options menu. * @@ -35,8 +37,8 @@ public class GuiPonySettings extends GameGui { private final boolean hiddenOptions; - public GuiPonySettings() { - super(new LiteralText(OPTIONS_PREFIX + "title")); + public GuiPonySettings(@Nullable Screen parent) { + super(new LiteralText(OPTIONS_PREFIX + "title"), parent); config = (ClientPonyConfig)MineLittlePony.getInstance().getConfig(); @@ -72,7 +74,7 @@ public class GuiPonySettings extends GameGui { addButton(new Label(width / 2, 5).setCentered()).getStyle().setText(getTitle().getString()); addButton(new Button(width / 2 - 100, height - 25)) - .onClick(sender -> onClose()) + .onClick(sender -> finish()) .getStyle() .setText("gui.done"); diff --git a/src/main/java/com/minelittlepony/client/hdskins/gui/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/client/hdskins/gui/GuiSkinsMineLP.java index c2c460f3..4ade74eb 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/client/hdskins/gui/GuiSkinsMineLP.java @@ -5,18 +5,17 @@ import com.minelittlepony.common.client.gui.element.IconicToggle; import com.minelittlepony.common.client.gui.style.Style; import com.minelittlepony.hdskins.dummy.PlayerPreview; import com.minelittlepony.hdskins.gui.GuiSkins; -import com.minelittlepony.hdskins.net.SkinServer; +import com.minelittlepony.hdskins.net.SkinServerList; import com.minelittlepony.pony.IPonyManager; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import net.minecraft.item.Items; import net.minecraft.sound.SoundEvents; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; -import java.util.List; - /** * Skin uploading GUI. Usually displayed over the main menu. */ @@ -32,8 +31,8 @@ public class GuiSkinsMineLP extends GuiSkins { "minelittlepony:textures/cubemap/sweetappleacres" }; - public GuiSkinsMineLP(List servers) { - super(servers); + public GuiSkinsMineLP(Screen parent, SkinServerList servers) { + super(parent, servers); } @Override diff --git a/src/main/java/com/minelittlepony/client/modmenu/MineLPModMenuFactory.java b/src/main/java/com/minelittlepony/client/modmenu/MineLPModMenuFactory.java index 8ed70ab9..5f8b422b 100644 --- a/src/main/java/com/minelittlepony/client/modmenu/MineLPModMenuFactory.java +++ b/src/main/java/com/minelittlepony/client/modmenu/MineLPModMenuFactory.java @@ -15,6 +15,6 @@ public class MineLPModMenuFactory implements ModMenuApi { @Override public Function getConfigScreenFactory() { - return screen -> new GuiPonySettings(); + return GuiPonySettings::new; } }