diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
3 files changed, 22 insertions, 9 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 1f7e621..9ae82e1 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -69,7 +69,6 @@ public class OneConfigGui extends UScreen { RenderManager.setupAndDraw((vg) -> { if (currentPage == null) { currentPage = new ModsPage(); - currentPage.parents = new ArrayList<>(); currentPage.parents.add(currentPage); } if (OneConfigConfig.australia) { @@ -203,8 +202,8 @@ public class OneConfigGui extends UScreen { if (page == currentPage) return; currentPage.finishUpAndClose(); textInputField.setInput(""); - if (page.parents == null) { - page.parents = new ArrayList<>(currentPage.parents); + if (page.parents.size() == 0) { + page.parents.addAll(currentPage.parents); if (!page.isBase()) { boolean alreadyInParents = false; for (int i = 0; i < page.parents.size(); i++) { @@ -221,6 +220,7 @@ public class OneConfigGui extends UScreen { page.parents.add(page); } } + sideBar.pageOpened(page.parents.get(0).getTitle()); if (addToPrevious) { previousPages.add(0, currentPage); nextPages.clear(); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index 4652ae0..fd8d3d6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -54,11 +54,8 @@ public class SideBar { public void draw(long vg, int x, int y) { for (BasicButton button : buttons) { if (!button.isClicked()) continue; - if (button.equals(buttons.get(selected))) break; - buttons.get(selected).setColorPalette(ColorPalette.TERTIARY); - moveAnimation = new EaseInOutQuart(300, buttons.get(selected).y, button.y, false); - sizeAnimation = new DummyAnimation(36); - selected = buttons.indexOf(button); + moveSideBar(button); + break; } if (moveAnimation != null) { RenderManager.drawRoundedRect(vg, x + 16, moveAnimation.get() - (sizeAnimation.get() - 36) / 2f, 192, sizeAnimation.get(0), Colors.PRIMARY_600, 12); @@ -83,4 +80,20 @@ public class SideBar { HUDButton.draw(vg, x + 16, y + 704); CloseButton.draw(vg, x + 16, y + 748); } + + public void pageOpened(String page) { + for (BasicButton button : buttons) { + if (!button.getText().equalsIgnoreCase(page)) continue; + moveSideBar(button); + return; + } + } + + private void moveSideBar(BasicButton button) { + if (button.equals(buttons.get(selected))) return; + buttons.get(selected).setColorPalette(ColorPalette.TERTIARY); + moveAnimation = new EaseInOutQuart(300, buttons.get(selected).y, button.y, false); + sizeAnimation = new DummyAnimation(36); + selected = buttons.indexOf(button); + } } 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 5ce6561..9a4b1eb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -24,7 +24,7 @@ public abstract class Page { private long scrollTime; private boolean mouseWasDown, dragging; private float yStart; - public ArrayList<Page> parents = null; + public final ArrayList<Page> parents = new ArrayList<>(); public Page(String title) { this.title = title; |