aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/pages
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-04 18:36:37 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-04 18:36:37 +0100
commit77f8b7924ad61ebb8334d37a0a2ae2c8a297b400 (patch)
tree0f36b3509e4a2e20853996ce6e4a86b4fbc39c90 /src/main/java/cc/polyfrost/oneconfig/gui/pages
parent74b42fa8a490b4226ca1a331fcddb22af149d217 (diff)
downloadOneConfig-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/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;
+ }
}