aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/pages')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java28
2 files changed, 33 insertions, 0 deletions
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;
+ }
}