diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-12 12:17:43 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-12 12:17:43 +0200 |
commit | 0f853804ef7c626e9c31749d6f948aa6bb23f4db (patch) | |
tree | 31cce815049d969cacf8e2daeb95b16f7c27153e /src/main/java/cc/polyfrost/oneconfig/gui | |
parent | 7f28a19a6e11ab7cddeb51caffa76b1ad71cfeae (diff) | |
download | OneConfig-0f853804ef7c626e9c31749d6f948aa6bb23f4db.tar.gz OneConfig-0f853804ef7c626e9c31749d6f948aa6bb23f4db.tar.bz2 OneConfig-0f853804ef7c626e9c31749d6f948aa6bb23f4db.zip |
prefernces, keybinds, scrolling fixes
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
6 files changed, 29 insertions, 5 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index bda24a2..4652ae0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -5,7 +5,9 @@ import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuart; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.gui.pages.CreditsPage; +import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.gui.pages.ModsPage; +import cc.polyfrost.oneconfig.internal.OneConfig; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; @@ -40,6 +42,7 @@ public class SideBar { public SideBar() { buttons.get(0).setClickAction(new CreditsPage()); buttons.get(2).setClickAction(new ModsPage()); + buttons.get(8).setClickAction(new ModConfigPage(OneConfig.preferences.mod.defaultPage, true)); HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui())); CloseButton.setClickAction(GuiUtils::closeScreen); for (BasicButton button : buttons) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java index b7d1a68..1aa5d66 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java @@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.config.core.OneKeyBind; import cc.polyfrost.oneconfig.config.elements.BasicOption; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.elements.BasicButton; +import cc.polyfrost.oneconfig.internal.config.core.KeyBindHandler; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.internal.assets.SVGs; @@ -22,6 +23,7 @@ public class ConfigKeyBind extends BasicOption { super(field, parent, name, category, subcategory, size); button = new BasicButton(256, 32, "", SVGs.KEYSTROKE, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY); button.setToggleable(true); + KeyBindHandler.addKeyBind(getKeyBind()); } public static ConfigKeyBind create(Field field, Object parent) { @@ -71,6 +73,7 @@ public class ConfigKeyBind extends BasicOption { private OneKeyBind getKeyBind() { OneKeyBind keyBind = new OneKeyBind(); try { + field.setAccessible(true); keyBind = (OneKeyBind) get(); } catch (IllegalAccessException ignored) { } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java index 455a538..a101071 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java @@ -32,4 +32,9 @@ public class CreditsPage extends Page { RenderManager.drawText(vg, " - Quiltflower (Quilt Team) - Gradle decompiler", x + 20, y + 415, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, " - Seraph (Scherso) - Locraw and Multithreading utilities", x + 20, y + 430, -1, 12, Fonts.REGULAR); } + + @Override + public boolean isBase() { + return true; + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java index 3e8fbf8..fb04dc2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -3,6 +3,7 @@ package cc.polyfrost.oneconfig.gui.pages; import cc.polyfrost.oneconfig.config.elements.OptionPage; import cc.polyfrost.oneconfig.config.elements.OptionSubcategory; import cc.polyfrost.oneconfig.config.elements.BasicOption; +import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; @@ -17,10 +18,12 @@ public class ModConfigPage extends Page { private final ArrayList<BasicButton> categories = new ArrayList<>(); private String selectedCategory; private int totalSize = 724; + private final boolean base; - public ModConfigPage(OptionPage page) { + public ModConfigPage(OptionPage page, boolean base) { super(page.name); this.page = page; + this.base = base; if (page.categories.size() == 0) return; for (String category : page.categories.keySet()) { selectedCategory = category; @@ -36,6 +39,10 @@ public class ModConfigPage extends Page { } } + public ModConfigPage(OptionPage page) { + this(page, false); + } + @Override public void draw(long vg, int x, int y) { if (page.categories.size() == 0) return; @@ -84,6 +91,8 @@ public class ModConfigPage extends Page { for (BasicButton button : categories) { if (button.getText().equals(newCategory)) continue; button.setToggled(false); + scrollTarget = 0; + scrollAnimation = null; } } @@ -91,4 +100,9 @@ public class ModConfigPage extends Page { public int getMaxScrollHeight() { return totalSize; } + + @Override + public boolean isBase() { + return base; + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java index 797512f..10852ab 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -100,8 +100,7 @@ public class ModsPage extends Page { @Override public int getMaxScrollHeight() { - //return size; - return 3298046; + return size; } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java index d884814..fff9482 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -16,9 +16,9 @@ import org.lwjgl.input.Mouse; */ public abstract class Page { protected final String title; - private Animation scrollAnimation; + protected Animation scrollAnimation; private final ColorAnimation colorAnimation = new ColorAnimation(new ColorPalette(Colors.TRANSPARENT, Colors.GRAY_400_60, Colors.GRAY_400_60)); - private float scrollTarget; + protected float scrollTarget; private long scrollTime; private boolean mouseWasDown, dragging; private float yStart; |