From 77f8b7924ad61ebb8334d37a0a2ae2c8a297b400 Mon Sep 17 00:00:00 2001 From: nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> Date: Wed, 4 May 2022 18:36:37 +0100 Subject: change some files and start on scrolling --- .../oneconfig/gui/pages/ModConfigPage.java | 5 ++++ .../cc/polyfrost/oneconfig/gui/pages/Page.java | 28 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/pages') 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; + } } -- cgit