diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index bd0503c..cdcc571 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -29,6 +29,7 @@ package cc.polyfrost.oneconfig.gui; import cc.polyfrost.oneconfig.gui.animations.Animation; import cc.polyfrost.oneconfig.gui.animations.CubicBezier; import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; +import cc.polyfrost.oneconfig.gui.animations.EaseOutExpo; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.gui.pages.CreditsPage; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; @@ -37,6 +38,9 @@ import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.internal.config.Preferences; import cc.polyfrost.oneconfig.internal.gui.HudGui; +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.libs.universal.wrappers.UPlayer; +import cc.polyfrost.oneconfig.libs.universal.wrappers.message.UTextComponent; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.utils.InputHandler; @@ -50,29 +54,31 @@ import static cc.polyfrost.oneconfig.gui.elements.BasicButton.SIZE_36; public class SideBar { private final ArrayList<BasicButton> buttons = new ArrayList<BasicButton>() {{ - add(new BasicButton(192, SIZE_36, "Credits", SVGs.COPYRIGHT_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(192, SIZE_36, "Global Search", SVGs.MAGNIFYING_GLASS_BOLD, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(192, SIZE_36, "Mods", SVGs.FADERS_HORIZONTAL_BOLD, null, ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(192, SIZE_36, "Profiles", SVGs.USER_SWITCH_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(192, SIZE_36, "Performance", SVGs.GAUGE_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(192, SIZE_36, "Updates", SVGs.ARROWS_CLOCKWISE_BOLD, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(192, SIZE_36, "Themes", SVGs.PAINT_BRUSH_BROAD_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(192, SIZE_36, "Screenshots", SVGs.APERTURE_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(192, SIZE_36, "Preferences", SVGs.GEAR_SIX_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + int width = 192; + add(new BasicButton(width, SIZE_36, "Credits", SVGs.COPYRIGHT_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + + add(new BasicButton(width, SIZE_36, "Mods", SVGs.FADERS_HORIZONTAL_BOLD, null, ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(width, SIZE_36, "Profiles", SVGs.USER_SWITCH_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(width, SIZE_36, "Performance", SVGs.GAUGE_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + + add(new BasicButton(width, SIZE_36, "Themes", SVGs.PAINT_BRUSH_BROAD_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(width, SIZE_36, "Screenshots", SVGs.APERTURE_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(width, SIZE_36, "Preferences", SVGs.GEAR_SIX_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); }}; - private final BasicButton HUDButton = new BasicButton(192, SIZE_36, "Edit HUD", SVGs.NOTE_PENCIL_BOLD, null, ALIGNMENT_LEFT, ColorPalette.SECONDARY); - private final BasicButton CloseButton = new BasicButton(192, SIZE_36, "Close", SVGs.X_CIRCLE_BOLD, null, ALIGNMENT_LEFT, ColorPalette.SECONDARY_DESTRUCTIVE); + private final BasicButton hudButton = new BasicButton(192, SIZE_36, "Edit HUD", SVGs.NOTE_PENCIL_BOLD, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY); + private final BasicButton closeButton = new BasicButton(192, SIZE_36, "Close", SVGs.X_CIRCLE_BOLD, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY_DESTRUCTIVE); private int selected = 2; private Animation moveAnimation = null; private Animation sizeAnimation = null; private int y; + private int sidebarY; public 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())); - CloseButton.setClickAction(GuiUtils::closeScreen); + buttons.get(1).setClickAction(new ModsPage()); + buttons.get(6).setClickAction(new ModConfigPage(Preferences.getInstance().mod.defaultPage, true)); + hudButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui())); + closeButton.setClickAction(GuiUtils::closeScreen); for (BasicButton button : buttons) { if (button.hasClickAction()) continue; button.disable(true); @@ -95,19 +101,24 @@ public class SideBar { } } - buttons.get(0).draw(vg, x + 16, y + 80, inputHandler); - buttons.get(1).draw(vg, x + 16, y + 116, inputHandler); - RenderManager.drawText(vg, "MOD CONFIG", x + 16, y + 178, Colors.WHITE, 12, Fonts.SEMIBOLD); - buttons.get(2).draw(vg, x + 16, y + 192, inputHandler); - buttons.get(3).draw(vg, x + 16, y + 228, inputHandler); - buttons.get(4).draw(vg, x + 16, y + 264, inputHandler); - buttons.get(5).draw(vg, x + 16, y + 300, inputHandler); - RenderManager.drawText(vg, "PERSONALIZATION", x + 16, y + 362, Colors.WHITE, 12, Fonts.SEMIBOLD); - buttons.get(6).draw(vg, x + 16, y + 376, inputHandler); - buttons.get(7).draw(vg, x + 16, y + 412, inputHandler); - buttons.get(8).draw(vg, x + 16, y + 448, inputHandler); - HUDButton.draw(vg, x + 16, y + 704, inputHandler); - CloseButton.draw(vg, x + 16, y + 748, inputHandler); + sidebarY = y + 44; + buttons.get(0).draw(vg, x + 16, calcAndIncrementLn(sidebarY), inputHandler); +// buttons.get(1).draw(vg, x + 16, y + 116, inputHandler); + RenderManager.drawText(vg, "MOD CONFIG", x + 16, calcAndIncrementLn(sidebarY + 26), Colors.WHITE_50, 12, Fonts.SEMIBOLD); + sidebarY = sidebarY - 26; + buttons.get(1).draw(vg, x + 16, calcAndIncrementLn(sidebarY), inputHandler); + buttons.get(2).draw(vg, x + 16, calcAndIncrementLn(sidebarY), inputHandler); + buttons.get(3).draw(vg, x + 16, calcAndIncrementLn(sidebarY), inputHandler); +// buttons.get(5).draw(vg, x + 16, listNewLn(sidebarY), inputHandler); + RenderManager.drawText(vg, "PERSONALIZATION", x + 16, calcAndIncrementLn(sidebarY + 26), Colors.WHITE_50, 12, Fonts.SEMIBOLD); + sidebarY = sidebarY - 26; + buttons.get(4).draw(vg, x + 16, calcAndIncrementLn(sidebarY), inputHandler); + buttons.get(5).draw(vg, x + 16, calcAndIncrementLn(sidebarY), inputHandler); + buttons.get(6).draw(vg, x + 16, calcAndIncrementLn(sidebarY), inputHandler); + sidebarY = 0; + + hudButton.draw(vg, x + 16, y + 704, inputHandler); + closeButton.draw(vg, x + 16, y + 748, inputHandler); } public void pageOpened(String page) { @@ -121,8 +132,14 @@ public class SideBar { private void moveSideBar(BasicButton button) { if (button.equals(buttons.get(selected))) return; buttons.get(selected).setColorPalette(ColorPalette.TERTIARY); - moveAnimation = new CubicBezier(0.76f, 0, 0.24f, 1, 300, buttons.get(selected).y - y, button.y - y, false); + moveAnimation = new EaseOutExpo(300, buttons.get(selected).y - y, button.y - y, false); sizeAnimation = new DummyAnimation(36); selected = buttons.indexOf(button); } + + // Utils + private int calcAndIncrementLn(int n) { + sidebarY = n + 36; + return sidebarY; + } } |