diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-07 15:11:13 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-07 15:11:13 +0900 |
commit | d566771b9fdba45c56b272b28e5fc0dbf2508958 (patch) | |
tree | ba27d674039b80124eea32b597f9935115f12849 /mod/src/main/java/kr | |
parent | 9edc3503704ec77209d14fff2a1437a0d0369190 (diff) | |
download | Skyblock-Dungeons-Guide-d566771b9fdba45c56b272b28e5fc0dbf2508958.tar.gz Skyblock-Dungeons-Guide-d566771b9fdba45c56b272b28e5fc0dbf2508958.tar.bz2 Skyblock-Dungeons-Guide-d566771b9fdba45c56b272b28e5fc0dbf2508958.zip |
- config gui and going back
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java/kr')
6 files changed, 51 insertions, 5 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java index b0d67ab0..f3622b22 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java @@ -27,6 +27,7 @@ import kr.syeyoung.dungeonsguide.mod.commands.CommandDgDebug; import kr.syeyoung.dungeonsguide.mod.commands.CommandDungeonsGuide; import kr.syeyoung.dungeonsguide.mod.commands.CommandReparty; import kr.syeyoung.dungeonsguide.mod.config.Config; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3.ConfigGuiScreenAdapter; import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; import kr.syeyoung.dungeonsguide.mod.cosmetics.CustomNetworkPlayerInfo; import kr.syeyoung.dungeonsguide.mod.discord.DiscordIntegrationManager; @@ -488,6 +489,8 @@ public class DungeonsGuide implements DGInterface { } - - + @Override + public Class<? extends GuiScreen> getModConfigGUI() { + return ConfigGuiScreenAdapter.class; + } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/ConfigGuiScreenAdapter.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/ConfigGuiScreenAdapter.java new file mode 100644 index 00000000..77717c74 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/ConfigGuiScreenAdapter.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3; + +import kr.syeyoung.dungeonsguide.mod.guiv2.GuiScreenAdapter; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.GlobalHUDScale; +import net.minecraft.client.gui.GuiScreen; + +public class ConfigGuiScreenAdapter extends GuiScreenAdapter { + public ConfigGuiScreenAdapter(GuiScreen parent) { + super(new GlobalHUDScale(new MainConfigWidget()), parent); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java index 525d5e97..c082eb2a 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/FeatureItem.java @@ -93,7 +93,7 @@ public class FeatureItem extends AnnotatedImportOnlyWidget { @On(functionName = "relocate") public void onRelocate() { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - Minecraft.getMinecraft().displayGuiScreen(new GuiScreenAdapter(new GlobalHUDScale(new HUDLocationConfig((AbstractHUDFeature) feature)))); + Minecraft.getMinecraft().displayGuiScreen(new GuiScreenAdapter(new GlobalHUDScale(new HUDLocationConfig((AbstractHUDFeature) feature)), Minecraft.getMinecraft().currentScreen)); // do stuff } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java index 0f3d9cda..da65f8c6 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java @@ -52,6 +52,6 @@ public class GUIOpenItem extends AnnotatedImportOnlyWidget { @On(functionName = "click") public void openPage() { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - Minecraft.getMinecraft().displayGuiScreen(new GuiScreenAdapter(new GlobalHUDScale(pageCreator.get()))); + Minecraft.getMinecraft().displayGuiScreen(new GuiScreenAdapter(new GlobalHUDScale(pageCreator.get()), Minecraft.getMinecraft().currentScreen)); } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java index b5b1fafb..94bec8fd 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java @@ -181,7 +181,7 @@ public abstract class AbstractHUDFeature extends AbstractGuiFeature { public void configure() { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); MainConfigWidget mainConfigWidget = new MainConfigWidget(); - GuiScreenAdapter adapter = new GuiScreenAdapter(new GlobalHUDScale(mainConfigWidget)); + GuiScreenAdapter adapter = new GuiScreenAdapter(new GlobalHUDScale(mainConfigWidget), Minecraft.getMinecraft().currentScreen); Minecraft.getMinecraft().displayGuiScreen(adapter); Navigator.getNavigator(mainConfigWidget.getDomElement()).openPage( diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java index 6bcad794..34d755cb 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java @@ -26,6 +26,7 @@ import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; import kr.syeyoung.dungeonsguide.mod.utils.cursor.GLCursors; import lombok.Getter; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; @@ -47,7 +48,12 @@ public class GuiScreenAdapter extends GuiScreen { private Stack<RootDom> domStack = new Stack<>(); + private GuiScreen parent; public GuiScreenAdapter(Widget widget) { + this(widget, null); + } + public GuiScreenAdapter(Widget widget, GuiScreen parent) { + this.parent = parent; view = new RootDom(widget); view.getContext().CONTEXT.put("screenAdapter", this); @@ -134,6 +140,14 @@ public class GuiScreenAdapter extends GuiScreen { @Override public void keyTyped(char typedChar, int keyCode) throws IOException { + if (keyCode == 1) { + this.mc.displayGuiScreen((GuiScreen)parent); + if (this.mc.currentScreen == null) { + this.mc.setIngameFocus(); + } + return; + } + try { view.keyPressed0(typedChar, keyCode); super.keyTyped(typedChar, keyCode); |