diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-04 18:36:37 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-04 18:36:37 +0100 |
commit | 77f8b7924ad61ebb8334d37a0a2ae2c8a297b400 (patch) | |
tree | 0f36b3509e4a2e20853996ce6e4a86b4fbc39c90 /src/main/java/cc/polyfrost/oneconfig/gui | |
parent | 74b42fa8a490b4226ca1a331fcddb22af149d217 (diff) | |
download | OneConfig-77f8b7924ad61ebb8334d37a0a2ae2c8a297b400.tar.gz OneConfig-77f8b7924ad61ebb8334d37a0a2ae2c8a297b400.tar.bz2 OneConfig-77f8b7924ad61ebb8334d37a0a2ae2c8a297b400.zip |
change some files and start on scrolling
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
6 files changed, 65 insertions, 13 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 72cd8c0..2c0816c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -7,8 +7,8 @@ import cc.polyfrost.oneconfig.gui.elements.TextInputField; import cc.polyfrost.oneconfig.gui.pages.HomePage; import cc.polyfrost.oneconfig.gui.pages.Page; import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import cc.polyfrost.oneconfig.lwjgl.Scissor; -import cc.polyfrost.oneconfig.lwjgl.ScissorManager; +import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; +import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.utils.InputUtils; @@ -125,7 +125,10 @@ public class OneConfigGui extends GuiScreen { pageProgress = -224f; } } else { - currentPage.draw(vg, (int) (x - pageProgress), y + 72); + if(currentPage.getMaxScrollHeight() == 728) { + currentPage.draw(vg, (int) (x - pageProgress), y + 72); + } else currentPage.scrollWithDraw(vg, (int) (x - pageProgress), y + 72); + } ScissorManager.resetScissor(vg, scissor); if (currentColorSelector != null) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java index 83d0f7c..fcd96b2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -9,6 +9,22 @@ import java.awt.*; import java.util.ArrayList; public class ColorSelector { + + public ColorSelector(Color color, int mouseX, int mouseY) { + + } + + public void draw(long vg) { + + } + + public Color getColor() { + + return null; + } +} + +/*public class ColorSelector { private Color color; private final int x, y; private final int width = 416; @@ -147,7 +163,7 @@ public class ColorSelector { public abstract void drawBox(long vg, int x, int y); /** draw the color selector contents, including the box, and the input fields. If it is clicked, getColorAtPos is called. updateElements is also called to update all the input fields. */ - public void draw(long vg, int x, int y) { + /*public void draw(long vg, int x, int y) { drawBox(vg, x + 16, y + 120); if(InputUtils.isAreaHovered(x + 16, y + 120, 384, 288) && Mouse.isButtonDown(0)) { selectedX = InputUtils.mouseX() - x - 16; @@ -170,18 +186,18 @@ public class ColorSelector { RenderManager.drawRoundedRect(vg, x + 16, y + 488, 384, 40, color1.getRGB(), 12f); } - /** called to set the color of the color selector box based on the values of the input fields. */ + /** called to set the color of the color selector box based on the values of the input fields. */ /* public abstract void setColor(Color color); - /** return an array of two ints of the start color of the gradient and the end color of the gradient. */ + /** return an array of two ints of the start color of the gradient and the end color of the gradient. */ /* public abstract int[] drawTopSlider(); - /** return an array of two ints of the start color of the gradient and the end color of the gradient. */ + /** return an array of two ints of the start color of the gradient and the end color of the gradient. */ /* public abstract int[] drawBottomSlider(); /** * This method is called when the color selector is clicked. It needs to return color at the clicked position. * @return color at the clicked position as a <code>float[] rgba.</code> - */ + */ /* public abstract float[] getColorAtPos(int clickX, int clickY); public float getRed() { @@ -246,5 +262,5 @@ public class ColorSelector { } } } - +*/ diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java index 3058643..196c447 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/TextInputField.java @@ -2,8 +2,8 @@ package cc.polyfrost.oneconfig.gui.elements; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import cc.polyfrost.oneconfig.lwjgl.Scissor; -import cc.polyfrost.oneconfig.lwjgl.ScissorManager; +import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; +import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.utils.InputUtils; import net.minecraft.client.gui.GuiScreen; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java index 0623f1e..5fad0a4 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java @@ -3,8 +3,8 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import cc.polyfrost.oneconfig.lwjgl.Scissor; -import cc.polyfrost.oneconfig.lwjgl.ScissorManager; +import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; +import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.utils.InputUtils; 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 f335e4d..d0e809e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -149,4 +149,9 @@ public class ModConfigPage extends Page { button.setToggled(false); } } + + @Override + public int getMaxScrollHeight() { + return 1600; + } } 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 ba31fa8..2f2fa36 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -1,9 +1,17 @@ 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; + /** * 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; + protected final String title; Page(String title) { @@ -15,6 +23,21 @@ public abstract class Page { public void finishUpAndClose() { } + public void scrollWithDraw(long vg, int x, int y) { + int dWheel = Mouse.getDWheel(); + scrollAmount += dWheel / 120f; + scrollPercent = MathUtils.easeOut(scrollPercent, scrollAmount, 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() { return title; } @@ -28,4 +51,9 @@ public abstract class Page { public boolean isBase() { return false; } + + /** Use this method to set the maximum scroll height of the page. */ + public int getMaxScrollHeight() { + return 728; + } } |