diff options
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui')
22 files changed, 0 insertions, 2839 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java deleted file mode 100644 index 32e401b..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java +++ /dev/null @@ -1,326 +0,0 @@ -package io.polyfrost.oneconfig.gui; - -import io.polyfrost.oneconfig.hud.HudCore; -import io.polyfrost.oneconfig.hud.interfaces.BasicHud; -import io.polyfrost.oneconfig.lwjgl.RenderManager; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import org.lwjgl.input.Keyboard; - -import java.awt.*; -import java.io.IOException; -import java.util.ArrayList; - -public class HudGui extends GuiScreen { - private BasicHud editingHud; - private boolean isDragging; - private boolean isScaling; - private int xOffset; - private int yOffset; - - @Override - public void initGui() { - HudCore.editing = true; - Keyboard.enableRepeatEvents(true); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - Gui.drawRect(0, 0, this.width, this.height, new Color(80, 80, 80, 50).getRGB()); - - if (isDragging) { - setPosition(mouseX - xOffset, mouseY - yOffset, true); - } - - for (BasicHud hud : HudCore.huds) { - processHud(hud, mouseX); - } - } - - private void processHud(BasicHud hud, int mouseX) { - if (hud == editingHud && isScaling) { - float xFloat = hud.getXScaled(this.width); - float yFloat = hud.getYScaled(this.height); - float pos = getXSnapping(mouseX, true); - float newWidth = pos - xFloat; - float newScale = newWidth / ((hud.getWidth(hud.scale) + hud.paddingX * hud.scale) / hud.scale); - if (newScale > 20) - newScale = 20; - else if (newScale < 0.3) - newScale = 0.3f; - hud.scale = newScale; - - if (xFloat / this.width > 0.5) - editingHud.xUnscaled = (xFloat + (hud.getWidth(hud.scale) + hud.paddingX * hud.scale)) / (double) this.width; - if (yFloat / this.height > 0.5) - editingHud.yUnscaled = (yFloat + (hud.getHeight(hud.scale) + hud.paddingY * hud.scale)) / (double) this.height; - } - - int width = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int height = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int x = (int) hud.getXScaled(this.width); - int y = (int) hud.getYScaled(this.height); - - if (hud.parent == null) - hud.drawExampleAll(x, y, hud.scale, true); - int color = new Color(215, 224, 235).getRGB(); - if (editingHud == hud) { - color = new Color(43, 159, 235).getRGB(); - if (isDragging) - Gui.drawRect(x, y, x + width, y + height, new Color(108, 176, 255, 60).getRGB()); - } - int finalColor = color; - RenderManager.setupAndDraw(true, (vg) -> { - RenderManager.drawLine(vg, x - 2 / 4f, y, x + width + 2 / 4f, y, 1, finalColor); - RenderManager.drawLine(vg, x, y, x, y + height, 1, finalColor); - RenderManager.drawLine(vg, x + width, y, x + width, y + height, 1, finalColor); - RenderManager.drawLine(vg, x - 2 / 4f, y + height, x + width + 2 / 4f, y + height, 1, finalColor); - }); - - if (hud == editingHud && !isDragging) { - RenderManager.setupAndDraw(true, (vg) -> { - RenderManager.drawCircle(vg, x + width, y + height, 3, new Color(43, 159, 235).getRGB()); - }); - } - - if (hud.childBottom != null) processHud(hud.childBottom, mouseX); - if (hud.childRight != null) processHud(hud.childRight, mouseX); - } - - private void setPosition(float newX, float newY, boolean snap) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - - if (editingHud.childRight != null) { - HudCore.huds.add(editingHud.childRight); - editingHud.childRight.parent = null; - editingHud.childRight = null; - } - if (editingHud.childBottom != null) { - HudCore.huds.add(editingHud.childBottom); - editingHud.childBottom.parent = null; - editingHud.childBottom = null; - } - if (editingHud.parent != null) { - HudCore.huds.add(editingHud); - if (editingHud.parent.childBottom == editingHud) - editingHud.parent.childBottom = null; - else if (editingHud.parent.childRight == editingHud) - editingHud.parent.childRight = null; - editingHud.parent = null; - } - - if (newX < 0) - newX = 0; - else if (newX + width > this.width) - newX = this.width - width; - if (newY < 0) - newY = 0; - else if (newY + height > this.height) - newY = this.height - height; - - if (snap) { - float snapX = getXSnapping(newX, false); - float snapY = getYSnapping(newY); - if (snapX != newX || snapY != newY) { - newX = snapX; - newY = snapY; - for (BasicHud hud : HudCore.huds) { - if (findParent(hud, snapX, snapY)) - break; - } - } - } - - if (newX / this.width <= 0.5) - editingHud.xUnscaled = newX / (double) this.width; - else - editingHud.xUnscaled = (newX + width) / (double) this.width; - if (newY / this.height <= 0.5) - editingHud.yUnscaled = newY / (double) this.height; - else - editingHud.yUnscaled = (newY + height) / (double) this.height; - } - - private boolean findParent(BasicHud hud, float snapX, float snapY) { - int hudWidth = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int hudX = (int) hud.getXScaled(this.width); - int hudHeight = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int hudY = (int) hud.getYScaled(this.height); - if (hudX + hudWidth == snapX && hudY == snapY && hud.childRight == null) { - editingHud.parent = hud; - hud.childRight = editingHud; - HudCore.huds.remove(editingHud); - return true; - } else if (hudX == snapX && hudY + hudHeight == snapY && hud.childBottom == null) { - editingHud.parent = hud; - hud.childBottom = editingHud; - HudCore.huds.remove(editingHud); - return true; - } - return hud.childRight != null && findParent(hud.childRight, snapX, snapY) || hud.childBottom != null && findParent(hud.childBottom, snapX, snapY); - } - - private float getXSnapping(float pos, boolean rightOnly) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - ArrayList<Float> verticalLines = new ArrayList<>(); - for (BasicHud hud : HudCore.huds) { - verticalLines.addAll(getXSnappingHud(hud)); - } - getSpaceSnapping(verticalLines); - verticalLines.add(this.width / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineX : verticalLines) { - for (float offset = 0; offset <= (rightOnly ? 0 : width); offset += width / 2f) { - if (Math.abs(lineX - pos - offset) < 5 && (Math.abs(lineX - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineX - pos); - smallestLine = lineX; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - RenderManager.drawDottedLine(smallestLine, 0, smallestLine, this.height, 2, 12, new Color(255, 255, 255).getRGB()); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList<Float> getXSnappingHud(BasicHud hud) { - ArrayList<Float> verticalLines = new ArrayList<>(); - if (hud == editingHud) return verticalLines; - if (hud.childRight != null) verticalLines.addAll(getXSnappingHud(hud.childRight)); - int hudWidth = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int hudX = (int) hud.getXScaled(this.width); - verticalLines.add((float) hudX); - verticalLines.add((float) (hudX + hudWidth)); - return verticalLines; - } - - private float getYSnapping(float pos) { - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - ArrayList<Float> horizontalLines = new ArrayList<>(); - for (BasicHud hud : HudCore.huds) { - horizontalLines.addAll(getYSnappingHud(hud)); - } - getSpaceSnapping(horizontalLines); - horizontalLines.add(this.height / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineY : horizontalLines) { - for (float offset = 0; offset <= height; offset += height / 2f) { - if (Math.abs(lineY - pos - offset) < 5 && (Math.abs(lineY - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineY - pos); - smallestLine = lineY; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - RenderManager.drawDottedLine(0, smallestLine, this.width, smallestLine, 2, 12, new Color(255, 255, 255).getRGB()); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList<Float> getYSnappingHud(BasicHud hud) { - ArrayList<Float> horizontalLines = new ArrayList<>(); - if (hud == editingHud) return horizontalLines; - if (hud.childBottom != null) horizontalLines.addAll(getYSnappingHud(hud.childBottom)); - int hudHeight = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int hudY = (int) hud.getYScaled(this.height); - horizontalLines.add((float) hudY); - horizontalLines.add((float) (hudY + hudHeight)); - return horizontalLines; - } - - private void getSpaceSnapping(ArrayList<Float> lines) { - ArrayList<Float> newLines = new ArrayList<>(); - for (int i = 0; i < lines.size(); i++) { - for (int l = i + 1; l < lines.size(); l++) { - newLines.add(Math.max(lines.get(i), lines.get(l)) + Math.abs(lines.get(i) - lines.get(l))); - newLines.add(Math.min(lines.get(i), lines.get(l)) - Math.abs(lines.get(i) - lines.get(l))); - } - } - lines.addAll(newLines); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if (mouseButton == 0) { - if (editingHud != null) { - int width = (int) (editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale); - int height = (int) (editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale); - float x = editingHud.getXScaled(this.width); - float y = editingHud.getYScaled(this.height); - if (mouseX >= x + width - 3 && mouseX <= x + width + 3 && mouseY >= y + height - 3 && mouseY <= y + height + 3) { - isScaling = true; - return; - } - } - editingHud = null; - for (BasicHud hud : HudCore.huds) { - if (mouseClickedHud(hud, mouseX, mouseY)) - break; - } - } - } - - private boolean mouseClickedHud(BasicHud hud, int mouseX, int mouseY) { - int width = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int height = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - float x = hud.getXScaled(this.width); - float y = hud.getYScaled(this.height); - if (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height) { - editingHud = hud; - xOffset = (int) (mouseX - x); - yOffset = (int) (mouseY - y); - isDragging = true; - return true; - } - return hud.childBottom != null && mouseClickedHud(hud.childBottom, mouseX, mouseY) || hud.childRight != null && mouseClickedHud(hud.childRight, mouseX, mouseY); - } - - @Override - protected void mouseReleased(int mouseX, int mouseY, int state) { - isDragging = false; - isScaling = false; - } - - @Override - protected void keyTyped(char typedChar, int keyCode) throws IOException { - if (editingHud != null) { - float x = editingHud.getXScaled(this.width); - float y = editingHud.getYScaled(this.height); - switch (keyCode) { - case Keyboard.KEY_UP: - setPosition(x, y - 1, false); - break; - case Keyboard.KEY_DOWN: - setPosition(x, y + 1, false); - break; - case Keyboard.KEY_LEFT: - setPosition(x - 1, y, false); - break; - case Keyboard.KEY_RIGHT: - setPosition(x + 1, y, false); - break; - } - } - super.keyTyped(typedChar, keyCode); - } - - @Override - public void onGuiClosed() { - HudCore.editing = false; - Keyboard.enableRepeatEvents(false); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } -}
\ No newline at end of file diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java deleted file mode 100644 index 3377f19..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java +++ /dev/null @@ -1,234 +0,0 @@ -package io.polyfrost.oneconfig.gui; - -import io.polyfrost.oneconfig.config.OneConfigConfig; -import io.polyfrost.oneconfig.gui.elements.BasicElement; -import io.polyfrost.oneconfig.gui.elements.ColorSelector; -import io.polyfrost.oneconfig.gui.elements.TextInputField; -import io.polyfrost.oneconfig.gui.pages.HomePage; -import io.polyfrost.oneconfig.gui.pages.Page; -import io.polyfrost.oneconfig.lwjgl.RenderManager; -import io.polyfrost.oneconfig.lwjgl.Scissor; -import io.polyfrost.oneconfig.lwjgl.ScissorManager; -import io.polyfrost.oneconfig.lwjgl.font.Fonts; -import io.polyfrost.oneconfig.lwjgl.image.Images; -import io.polyfrost.oneconfig.utils.InputUtils; -import io.polyfrost.oneconfig.utils.MathUtils; -import net.minecraft.client.gui.GuiScreen; -import org.jetbrains.annotations.NotNull; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; - -import java.awt.*; -import java.util.ArrayList; - -import static org.lwjgl.nanovg.NanoVG.nvgResetScissor; -import static org.lwjgl.nanovg.NanoVG.nvgScissor; - -public class OneConfigGui extends GuiScreen { - public static OneConfigGui INSTANCE; - public final int x = 320; - public final int y = 140; - private final SideBar sideBar = new SideBar(); - protected Page currentPage; - protected Page prevPage; - private float pageProgress = -224f; - private final TextInputField textInputField = new TextInputField(248, 40, "Search all of OneConfig...", false, false); - private final ArrayList<Page> previousPages = new ArrayList<>(); - private final ArrayList<Page> nextPages = new ArrayList<>(); - private final BasicElement backArrow = new BasicElement(40, 40, -1, false); - private final BasicElement forwardArrow = new BasicElement(40, 40, -1, false); - private final ArrayList<Page> parents = new ArrayList<>(); - private ColorSelector currentColorSelector; - public boolean mouseDown; - - public OneConfigGui() { - INSTANCE = this; - } - - public OneConfigGui(Page page) { - INSTANCE = this; - currentPage = page; - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawScreen(mouseX, mouseY, partialTicks); - long start = System.nanoTime(); - RenderManager.setupAndDraw((vg) -> { - if (currentPage == null) { - currentPage = new HomePage(); - parents.add(currentPage); - } - //nvgScale(vg, 0.5f, 0.5f); - if (OneConfigConfig.ROUNDED_CORNERS) { - RenderManager.drawRoundedRect(vg, 544, 140, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN); - RenderManager.drawRoundedRect(vg, 320, 140, 244, 800, OneConfigConfig.GRAY_900_80, OneConfigConfig.CORNER_RADIUS_WIN); - RenderManager.drawRect(vg, 544, 140, 20, 800, OneConfigConfig.GRAY_800); - //RenderManager.drawDropShadow(vg, 544, 140, 1056, 800, 20f, 32f, OneConfigConfig.GRAY_800); - } - - RenderManager.drawLine(vg, 544, 212, 1600, 212, 1, OneConfigConfig.GRAY_700); - RenderManager.drawLine(vg, 544, 140, 544, 940, 1, OneConfigConfig.GRAY_700); - - RenderManager.drawImage(vg, Images.LOGO, x + 19, y + 19, 42, 42); - RenderManager.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.INTER_BOLD); // added half line height to center text - RenderManager.drawString(vg, "By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR); - textInputField.draw(vg, x + 1020, y + 16); - sideBar.draw(vg, x, y); - backArrow.draw(vg, x + 240, y + 16); - forwardArrow.draw(vg, x + 280, y + 16); - - if (previousPages.size() == 0) { - backArrow.disable(true); - NanoVG.nvgGlobalAlpha(vg, 0.5f); - } else { - backArrow.disable(false); - if (!backArrow.isHovered() || Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); - } - NanoVG.nvgTranslate(vg, x + 271, y + 47); - NanoVG.nvgRotate(vg, (float) Math.toRadians(180)); - RenderManager.drawImage(vg, Images.CIRCLE_ARROW, 0, 0, 22, 22); - NanoVG.nvgResetTransform(vg); - NanoVG.nvgGlobalAlpha(vg, 1f); - if (nextPages.size() == 0) { - forwardArrow.disable(true); - NanoVG.nvgGlobalAlpha(vg, 0.5f); - } else { - forwardArrow.disable(false); - if (!forwardArrow.isHovered() || Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); - } - RenderManager.drawImage(vg, Images.CIRCLE_ARROW, x + 289, y + 25, 22, 22); - NanoVG.nvgGlobalAlpha(vg, 1f); - - if (backArrow.isClicked() && previousPages.size() > 0) { - try { - nextPages.add(0, currentPage); - openPage(previousPages.get(0), false); - previousPages.remove(0); - } catch (Exception ignored) { - } - } else if (forwardArrow.isClicked() && nextPages.size() > 0) { - try { - previousPages.add(0, currentPage); - openPage(nextPages.get(0), false); - nextPages.remove(0); - } catch (Exception ignored) { - } - } - - Scissor scissor = ScissorManager.scissor(vg, x + 224, y + 72, 1056, 728); - if (prevPage != null) { - pageProgress = MathUtils.easeInOutCirc(50, pageProgress, 832 - pageProgress, 220); - prevPage.draw(vg, (int) (x - pageProgress), y + 72); - RenderManager.drawLine(vg, (int) (x - pageProgress + 1055), y + 72, (int) (x - pageProgress + 1057), y + 800, 2, OneConfigConfig.GRAY_700); // TODO might remove this - currentPage.draw(vg, (int) (x - pageProgress + 1056), y + 72); - if (pageProgress > 830f) { // this number is the 'snap' point of the page - prevPage = null; - pageProgress = -224f; - } - } else { - currentPage.draw(vg, (int) (x - pageProgress), y + 72); - } - ScissorManager.resetScissor(vg, scissor); - if (currentColorSelector != null) { - currentColorSelector.draw(vg); - } - - float breadcrumbX = x + 336; - for (int i = 0; i < parents.size(); i++) { - String title = parents.get(i).getTitle(); - float width = RenderManager.getTextWidth(vg, title, 24f, Fonts.INTER_SEMIBOLD); - boolean hovered = InputUtils.isAreaHovered((int) breadcrumbX, y + 24, (int) width, 36); - int color = OneConfigConfig.WHITE_60; - if (i == parents.size() - 1) color = OneConfigConfig.WHITE_95; - else if (hovered && !Mouse.isButtonDown(0)) color = OneConfigConfig.WHITE_80; - RenderManager.drawString(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.INTER_SEMIBOLD); - if (i != 0) - RenderManager.drawImage(vg, Images.CHEVRON_ARROW, breadcrumbX - 22, y + 26, 13, 22, color); - if (hovered && i != parents.size() - 1) - RenderManager.drawLine(vg, breadcrumbX, y + 48, breadcrumbX + width, y + 48, 2, color); - if (hovered && InputUtils.isClicked()) openPage(parents.get(i)); - breadcrumbX += width + 32; - } - - long end = System.nanoTime() - start; - String s = (" draw: " + end / 1000000f + "ms"); - RenderManager.drawString(vg, s, x + 1170, y + 790, OneConfigConfig.GRAY_300, 10f, Fonts.INTER_MEDIUM); - }); - mouseDown = Mouse.isButtonDown(0); - } - - protected void keyTyped(char key, int keyCode) { - Keyboard.enableRepeatEvents(true); - try { - super.keyTyped(key, keyCode); - textInputField.keyTyped(key, keyCode); - currentPage.keyTyped(key, keyCode); - } catch (Exception e) { - System.out.println("this should literally never happen"); - } - } - - public void openPage(@NotNull Page page) { - openPage(page, true); - } - - public void openPage(@NotNull Page page, boolean addToPrevious) { - if (page == currentPage) return; - currentPage.finishUpAndClose(); - if (!page.isBase()) { - boolean alreadyInParents = false; - for (int i = 0; i < parents.size(); i++) { - Page parent = parents.get(i); - if (parent == page) { - alreadyInParents = true; - parents.subList(i + 1, parents.size()).clear(); - break; - } - } - if (!alreadyInParents) parents.add(page); - } else { - parents.clear(); - parents.add(page); - } - if (addToPrevious) { - previousPages.add(0, currentPage); - nextPages.clear(); - } - if (prevPage == null) { - prevPage = currentPage; - } - currentPage = page; - } - - /** - * initialize a new ColorSelector and add it to the draw script. This method is used to make sure it is always rendered on top. - * - * @implNote Correct usage: <code>OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY()));</code> - */ - public void initColorSelector(ColorSelector colorSelector) { - currentColorSelector = colorSelector; - } - - /** - * Close the current color selector and return the color it had when it closed. - */ - public Color closeColorSelector() { - Color color = currentColorSelector.getColor(); - currentColorSelector = null; - return color; - } - - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - @Override - public void onGuiClosed() { - currentPage.finishUpAndClose(); - INSTANCE = null; - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java deleted file mode 100644 index 195e398..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.polyfrost.oneconfig.gui; - -import io.polyfrost.oneconfig.config.OneConfigConfig; -import io.polyfrost.oneconfig.gui.elements.BasicButton; -import io.polyfrost.oneconfig.gui.pages.HomePage; -import io.polyfrost.oneconfig.gui.pages.ModsPage; -import io.polyfrost.oneconfig.lwjgl.RenderManager; -import io.polyfrost.oneconfig.lwjgl.font.Fonts; -import io.polyfrost.oneconfig.lwjgl.image.Images; -import io.polyfrost.oneconfig.utils.MathUtils; -import net.minecraft.client.Minecraft; - -import java.util.ArrayList; -import java.util.List; - -public class SideBar { - private final List<BasicButton> btnList = new ArrayList<>(); - - private float targetY = 0, currentY = 0; - - public SideBar() { - btnList.add(new BasicButton(192, 36, "Dashboard", Images.DASHBOARD, null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage())); - btnList.add(new BasicButton(192, 36, "Global Search", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Mods", Images.MODS, null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage())); - btnList.add(new BasicButton(192, 36, "Performance", Images.PERFORMANCE, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Profiles", Images.PROFILES, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Updates", Images.UPDATES, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Theme", Images.THEMES, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Screenshots", Images.SCREENSHOT, null, -3, BasicButton.ALIGNMENT_LEFT)); - 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, "Edit HUD", Images.HUD, null, 0, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(new HudGui()))); - } - - public void draw(long vg, int x, int y) { - //percentMove = 36f; - - currentY = MathUtils.easeInOutCirc(50, currentY, targetY - currentY, 120); - RenderManager.drawRoundedRect(vg, x + 16, currentY, 192, 36, OneConfigConfig.BLUE_600, OneConfigConfig.CORNER_RADIUS); - int i = 0; - if (targetY == 0) { - targetY = y + 96; - currentY = targetY; - } - for (BasicButton btn : btnList) { - btn.draw(vg, x + 16, y + 96 + i); - i += 44; - if (i == 88) { // +88 - RenderManager.drawString(vg, "MOD CONFIG", x + 16, y + 200, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_SEMIBOLD); - i = 122; - } - if (i == 298) { - RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 420, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_SEMIBOLD); - i = 342; - } - if (i == 518) { - i = 562; - } - - if (btn.isClicked() && btn.getPage() != null) { - if (i < 520) targetY = btn.y; - } - } - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java deleted file mode 100644 index 716ef1e..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java +++ /dev/null @@ -1,157 +0,0 @@ -package io.polyfrost.oneconfig.gui.elements; - -import io.polyfrost.oneconfig.config.OneConfigConfig; -import io.polyfrost.oneconfig.gui.OneConfigGui; -import io.polyfrost.oneconfig.gui.pages.Page; -import io.polyfrost.oneconfig.lwjgl.RenderManager; -import io.polyfrost.oneconfig.lwjgl.font.Fonts; -import io.polyfrost.oneconfig.lwjgl.image.Images; -import io.polyfrost.oneconfig.utils.ColorUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class BasicButton extends BasicElement { - - protected String text; - protected Images fileNameLeftIco, fileNameRightIco; - private final int thisAlignment; - private final float fontSize; - private final int colorPalette; - public int x, y; - public static final int ALIGNMENT_LEFT = 0; - public static final int ALIGNMENT_CENTER = 1; - private boolean toggleable; - private Page page; - private Runnable runnable; - - /** - * Create a new basic button. Used mostly on the homepage and the sidebar. Note: The button will not be drawn until you call {@link #draw(long, int, int)}. - * The button's content is centered on its total length, so the text is not always in the middle. - * - * @param text Text to display on the button. Has to be there. - * @param fileNameLeftIco file path of the icon to display on the left. Can be null if you don't want to display an icon on the left. - * @param fileNameRightIco file path of the icon to display on the right. Can be null if you don't want to display an icon on the right. - * @param colorPalette color palette to use. see {@link io.polyfrost.oneconfig.utils.ColorUtils} for more info. Can support color palette of -2, which is larger font and icons. Also supports -3, which is just the text changing color. - * @param alignment alignment of the button. ALIGNMENT_LEFT or ALIGNMENT_CENTER. - */ - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment) { - super(width, height, colorPalette, true); - this.text = text; - if (fileNameLeftIco != null) this.fileNameLeftIco = fileNameLeftIco; - if (fileNameRightIco != null) this.fileNameRightIco = fileNameRightIco; - this.thisAlignment = alignment; - if (colorPalette == -2) { - fontSize = 24f; - this.colorPalette = -1; - } else { - fontSize = 14f; - this.colorPalette = colorPalette; - } - } - - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, Page page) { - this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment); - this.page = page; - } - - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, boolean toggleable) { - this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment); - this.toggleable = toggleable; - } - - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, Runnable runnable) { - this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment); - this.runnable = runnable; - } -< |
