aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-08 14:19:42 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-08 14:19:42 +0200
commit42ee590d1e82829872949e678e20ff6a9fd25456 (patch)
tree6d04f3bf7eb15d4bf58696485702b31a53e29c12
parent2e97dce17a401b790799265523d72a3d168e2b7f (diff)
downloadOneConfig-42ee590d1e82829872949e678e20ff6a9fd25456.tar.gz
OneConfig-42ee590d1e82829872949e678e20ff6a9fd25456.tar.bz2
OneConfig-42ee590d1e82829872949e678e20ff6a9fd25456.zip
minimize
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java13
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java5
3 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
index 35d099c..e6a91d9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
+++ b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
@@ -35,7 +35,7 @@ public class OneConfigCommand extends CommandBase {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if (args.length == 0) new TickDelay(() -> mc.displayGuiScreen(new OneConfigGui()), 1);
+ if (args.length == 0) new TickDelay(() -> mc.displayGuiScreen(OneConfigGui.create()), 1);
else {
switch (args[0]) {
case "hud":
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 8897ec5..0b9362a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -41,16 +41,27 @@ public class OneConfigGui extends GuiScreen {
private ColorSelector currentColorSelector;
public boolean mouseDown;
private float scale = 1f;
+ public static OneConfigGui instanceToRestore = null;
public OneConfigGui() {
INSTANCE = this;
+ instanceToRestore = null;
}
public OneConfigGui(Page page) {
INSTANCE = this;
+ instanceToRestore = null;
currentPage = page;
}
+ public static OneConfigGui create() {
+ try {
+ return instanceToRestore == null ? new OneConfigGui() : instanceToRestore;
+ } finally {
+ instanceToRestore = null;
+ }
+ }
+
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
@@ -166,7 +177,7 @@ public class OneConfigGui extends GuiScreen {
try {
super.keyTyped(key, keyCode);
textInputField.keyTyped(key, keyCode);
- if(currentColorSelector != null) currentColorSelector.keyTyped(key, keyCode);
+ if (currentColorSelector != null) currentColorSelector.keyTyped(key, keyCode);
currentPage.keyTyped(key, keyCode);
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index 4d506ba..978f420 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -30,7 +30,10 @@ public class SideBar {
btnList.add(new BasicButton(192, 36, "HUD Settings", Images.HUD_SETTINGS, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Preferences", Images.PREFERENCES, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Close", Images.CLOSE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(null)));
- btnList.add(new BasicButton(192, 36, "Minimize", Images.MINIMIZE, null, -1, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Minimize", Images.MINIMIZE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> {
+ OneConfigGui.instanceToRestore = OneConfigGui.INSTANCE;
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }));
btnList.add(new BasicButton(192, 36, "Edit HUD", Images.HUD, null, 0, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(new HudGui())));
}