aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-07-03 10:57:19 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-07-03 10:57:19 +0100
commit52d921c208d87b71665ff78cea88b37a44a29cae (patch)
treee3626f139fd8ce71523a3e4f475d661e9af4ff1d /src/main/java
parent1e285b84ec8dace3331b11dfa5b10a8af6cd8354 (diff)
downloadOneConfig-52d921c208d87b71665ff78cea88b37a44a29cae.tar.gz
OneConfig-52d921c208d87b71665ff78cea88b37a44a29cae.tar.bz2
OneConfig-52d921c208d87b71665ff78cea88b37a44a29cae.zip
changes to ESC behavior
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/Config.java17
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java2
5 files changed, 30 insertions, 3 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
index 9c70aa6..9557728 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
@@ -32,6 +32,7 @@ import java.nio.file.Files;
import java.util.*;
import java.util.function.Supplier;
+@SuppressWarnings({"unused", "ResultOfMethodCallIgnored"})
public class Config {
public final transient HashMap<String, BasicOption> optionNames = new HashMap<>();
transient protected final String configFile;
@@ -303,4 +304,20 @@ public class Config {
keyBind.setRunnable(runnable);
KeyBindHandler.INSTANCE.addKeyBind(keyBind);
}
+
+ /**
+ * Reset this config file to its defaults.
+ * @return true if successful, false if not.
+ * @deprecated <b>not implemented yet.</b>
+ */
+ @Deprecated
+ public boolean reset() {
+ try {
+ // TODO
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
index b45a1d8..f5b1d3f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
@@ -8,6 +8,7 @@ import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.libs.universal.UKeyboard;
import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
import cc.polyfrost.oneconfig.libs.universal.UScreen;
+import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -18,9 +19,15 @@ public class HudGui extends UScreen implements GuiPause {
private Hud editingHud;
private boolean isDragging;
private boolean isScaling;
+ private final boolean openOneConfigOnClose;
private int xOffset;
private int yOffset;
+ public HudGui(boolean openOneConfigOnClose) {
+ super();
+ this.openOneConfigOnClose = openOneConfigOnClose;
+ }
+
@Override
public void initScreen(int width, int height) {
HudCore.editing = true;
@@ -275,6 +282,7 @@ public class HudGui extends UScreen implements GuiPause {
HudCore.editing = false;
UKeyboard.allowRepeatEvents(false);
ConfigCore.saveAll();
+ if(openOneConfigOnClose) GuiUtils.displayScreen(OneConfigGui.create());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 35946e0..1095ae0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -188,7 +188,9 @@ public class OneConfigGui extends UScreen implements GuiPause {
public void onKeyPressed(int keyCode, char typedChar, @Nullable UKeyboard.Modifiers modifiers) {
UKeyboard.allowRepeatEvents(true);
try {
- if (allowClose) super.onKeyPressed(keyCode, typedChar, modifiers);
+ if (keyCode == 1 && currentPage.parents.size() > 1) {
+ openPage(currentPage.parents.get(currentPage.parents.size() - 2));
+ } else if (allowClose) super.onKeyPressed(keyCode, typedChar, modifiers);
textInputField.keyTyped(typedChar, keyCode);
if (currentColorSelector != null) currentColorSelector.keyTyped(typedChar, keyCode);
currentPage.keyTyped(typedChar, keyCode);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index df3330d..d1b5532 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -43,7 +43,7 @@ public class SideBar {
buttons.get(0).setClickAction(new CreditsPage());
buttons.get(2).setClickAction(new ModsPage());
buttons.get(8).setClickAction(new ModConfigPage(Preferences.getInstance().mod.defaultPage, true));
- HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui()));
+ HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui(true)));
CloseButton.setClickAction(GuiUtils::closeScreen);
for (BasicButton button : buttons) {
if (button.hasClickAction()) continue;
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java b/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java
index 7f38721..93d3c42 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java
@@ -23,7 +23,7 @@ public class OneConfigCommand {
private static class HUDSubCommand {
@Main
private static void main() {
- GuiUtils.displayScreen(new HudGui());
+ GuiUtils.displayScreen(new HudGui(false));
}
}