diff options
4 files changed, 51 insertions, 27 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 2c0816c..febbfd0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -30,6 +30,7 @@ public class OneConfigGui extends GuiScreen { protected Page currentPage; protected Page prevPage; private float pageProgress = -224f; + private float scissorExclusionHeight = 0f; 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<>(); @@ -70,7 +71,12 @@ public class OneConfigGui extends GuiScreen { 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); + RenderManager.drawString(vg, "ALPHA - By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR); + + //RenderManager.drawRect(vg, x + 300, y + 500, 400, 12, OneConfigConfig.ERROR_700); + //RenderManager.drawString(vg, "MoonTidez is Annoyinhg here is an f |||", x + 300, y + 500, OneConfigConfig.WHITE, 14f, 14,Fonts.INTER_REGULAR); + + textInputField.draw(vg, x + 1020, y + 16); sideBar.draw(vg, x, y); backArrow.draw(vg, x + 240, y + 16); @@ -114,7 +120,7 @@ public class OneConfigGui extends GuiScreen { } } - Scissor scissor = ScissorManager.scissor(vg, x + 224, y + 72, 1056, 728); + Scissor scissor = ScissorManager.scissor(vg, x + 224, y + 88, 1056, 698); if (prevPage != null) { pageProgress = MathUtils.easeInOutCirc(50, pageProgress, 832 - pageProgress, 220); prevPage.draw(vg, (int) (x - pageProgress), y + 72); @@ -127,7 +133,13 @@ public class OneConfigGui extends GuiScreen { } else { if(currentPage.getMaxScrollHeight() == 728) { currentPage.draw(vg, (int) (x - pageProgress), y + 72); - } else currentPage.scrollWithDraw(vg, (int) (x - pageProgress), y + 72); + } else { + ScissorManager.resetScissor(vg, scissor); + scissorExclusionHeight = currentPage.drawStatic(vg, (int) (x - pageProgress), y + 72); + Scissor scissor1 = ScissorManager.scissor(vg, x + 224, y + 72 + scissorExclusionHeight, 1056, 698 - scissorExclusionHeight); + currentPage.scrollWithDraw(vg, (int) (x - pageProgress), y + 72); + ScissorManager.resetScissor(vg, scissor1); + } } ScissorManager.resetScissor(vg, scissor); 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 d0e809e..dde6a2b 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -1,5 +1,6 @@ package cc.polyfrost.oneconfig.gui.pages; +import cc.polyfrost.oneconfig.OneConfig; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.data.OptionPage; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; @@ -37,15 +38,6 @@ public class ModConfigPage extends Page { int optionX = x + 30; int optionY = y + (page.categories.size() == 1 ? 16 : 64); - // Category buttons - int buttonX = x + 16; - for (BasicButton button : categories) { - if (button.getWidth() == 0) - button.setWidth((int) (Math.ceil(RenderManager.getTextWidth(vg, button.getText(), 14f, Fonts.INTER_MEDIUM) / 8f) * 8 + 16)); - button.draw(vg, buttonX, y + 16); - buttonX += button.getWidth() + 16; - } - // Top page buttons for (ConfigPageButton page : page.categories.get(selectedCategory).topPages) { page.draw(vg, optionX, optionY); @@ -124,6 +116,20 @@ public class ModConfigPage extends Page { } } } + RenderManager.drawRoundedRect(vg, x, y + 1500, 500, 100, OneConfigConfig.WHITE_90, 16); + } + + @Override + public int drawStatic(long vg, int x, int y) { + // Category buttons + int buttonX = x + 16; + for (BasicButton button : categories) { + if (button.getWidth() == 0) + button.setWidth((int) (Math.ceil(RenderManager.getTextWidth(vg, button.getText(), 14f, Fonts.INTER_MEDIUM) / 8f) * 8 + 16)); + button.draw(vg, buttonX, y + 16); + buttonX += button.getWidth() + 16; + } + return 60; } @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 2f2fa36..1eaf8dd 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -1,7 +1,5 @@ package cc.polyfrost.oneconfig.gui.pages; -import cc.polyfrost.oneconfig.config.OneConfigConfig; -import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.utils.MathUtils; import org.lwjgl.input.Mouse; @@ -9,8 +7,8 @@ import org.lwjgl.input.Mouse; * A page is a 1056x728 rectangle of the GUI. It is the main content of the gui, and can be switched back and forwards easily. All the content of OneConfig is in a page. */ public abstract class Page { - private float scrollPercent = 0f; - private float yDiff, scrollAmount; + private float currentScrollf = 0f; + private float scrollTarget; protected final String title; @@ -20,22 +18,30 @@ public abstract class Page { public abstract void draw(long vg, int x, int y); + /** Use this method to draw elements that are static on the page (ignore the scrolling). + * @return the total height of the elements, so they are excluded from the scissor rectangle. */ + public int drawStatic(long vg, int x, int y) { + return 0; + } + public void finishUpAndClose() { } public void scrollWithDraw(long vg, int x, int y) { + int currentScroll = (int) (currentScrollf * 100); + draw(vg, x, y + currentScroll); int dWheel = Mouse.getDWheel(); - scrollAmount += dWheel / 120f; - scrollPercent = MathUtils.easeOut(scrollPercent, scrollAmount, 20f); + if(dWheel > 120) dWheel = 120; + if(!(Math.abs((scrollTarget * 100) - 728) >= getMaxScrollHeight() && dWheel < 0)) { + scrollTarget += dWheel / 120f; + } + if(scrollTarget > 0f) { // fyi this is anti overscroll protection + scrollTarget = 0; + } + + currentScrollf = MathUtils.easeOut(currentScrollf, scrollTarget, 20f); - int currentScroll = (int) yDiff + (int) (scrollPercent * 100); - if(currentScroll > 0) { - currentScroll = 0; - scrollPercent = 0; - scrollAmount = 0; - } - draw(vg, x, y + currentScroll); } public String getTitle() { diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java index 0ad1748..9af7122 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java @@ -92,7 +92,7 @@ public final class RenderManager { nvgRect(vg, x, y, width, height); NVGColor nvgColor = color(vg, color); NVGColor nvgColor2 = color(vg, color2); - nvgFillPaint(vg, nvgLinearGradient(vg, x, y + height, x + width, y, nvgColor, nvgColor2, bg)); + nvgFillPaint(vg, nvgLinearGradient(vg, x + height, y + height, x + height, y, nvgColor, nvgColor2, bg)); nvgFillPaint(vg, bg); nvgFill(vg); nvgColor.free(); @@ -162,7 +162,7 @@ public final class RenderManager { nvgFontSize(vg, size); nvgFontFace(vg, font.font.getName()); nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP); - nvgTextLineHeight(vg, lineHeight); + nvgTextMetrics(vg, new float[]{10f}, new float[]{10f}, new float[]{lineHeight}); NVGColor nvgColor = color(vg, color); nvgText(vg, x, y, text); nvgFill(vg); |