aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/pages
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-08-17 17:43:23 +0200
committerGitHub <noreply@github.com>2022-08-17 17:43:23 +0200
commit97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f (patch)
tree2bccc96007025fbccf1758ac66d4665a97d6c315 /src/main/java/cc/polyfrost/oneconfig/gui/pages
parente18629af6aee276b0be6cec473e4099cca9100f1 (diff)
downloadOneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.tar.gz
OneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.tar.bz2
OneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.zip
Input revamp (#93)
* hud fix * api * things * stuff
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/pages')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java28
5 files changed, 30 insertions, 27 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
index df97ba6..e8a44e5 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
@@ -29,6 +29,7 @@ package cc.polyfrost.oneconfig.gui.pages;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
+import cc.polyfrost.oneconfig.utils.InputHandler;
public class CreditsPage extends Page {
public CreditsPage() {
@@ -36,7 +37,7 @@ public class CreditsPage extends Page {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
RenderManager.drawSvg(vg, SVGs.ONECONFIG, x + 20f, y + 20f, 96, 96);
RenderManager.drawText(vg, "OneConfig", x + 130, y + 46, -1, 42, Fonts.BOLD);
RenderManager.drawText(vg, "ALPHA - By Polyfrost", x + 132, y + 76, -1, 18, Fonts.MEDIUM);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
index 69c3cd1..be40b3b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -30,6 +30,7 @@ import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
+import cc.polyfrost.oneconfig.utils.InputHandler;
public class HomePage extends Page {
/*private final BasicButton socialsBtn = new BasicButton(184, 36, "Socials", SVGs.SHARE, SVGs.POP_OUT, BasicButton.ALIGNMENT_CENTER, ColorUtils.PRIMARY);
@@ -57,7 +58,7 @@ public class HomePage extends Page {
}
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
RenderManager.drawRoundedRect(vg, x, y, 184, 36, -1, 12f);
RenderManager.drawText(vg, "This is a cool string to test pages", x + 32, y + 72, -1, 36f, Fonts.BOLD);
RenderManager.drawRoundedRect(vg, x + 350, y + 310, 300, 200, Colors.PRIMARY_600, 14f);
@@ -65,7 +66,7 @@ public class HomePage extends Page {
RenderManager.drawText(vg, "Info", x + 52, y + 618, Colors.WHITE_90, 24f, Fonts.MEDIUM);
RenderManager.drawRoundedRect(vg, x + 16, y + 644, 1024, 64, Colors.GRAY_700, 20f);
- RenderManager.drawURL(vg, "https://www.youtube.com/watch?v=dQw4w9WgXcQ", x + 100, y + 205, 24, Fonts.MEDIUM);
+ RenderManager.drawURL(vg, "https://www.youtube.com/watch?v=dQw4w9WgXcQ", x + 100, y + 205, 24, Fonts.MEDIUM, inputHandler);
/*discordBtn.draw(vg, x + 32, y + 658);
webBtn.draw(vg, x + 232, y + 658);
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 db8949c..ec1e4a1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -29,10 +29,10 @@ package cc.polyfrost.oneconfig.gui.pages;
import cc.polyfrost.oneconfig.config.elements.OptionPage;
import cc.polyfrost.oneconfig.config.elements.OptionSubcategory;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
-import cc.polyfrost.oneconfig.gui.animations.DummyAnimation;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.util.ArrayList;
@@ -70,26 +70,26 @@ public class ModConfigPage extends Page {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
if (page.categories.size() == 0) return;
int optionY = y + (page.categories.size() == 1 ? 16 : 64);
for (OptionSubcategory subCategory : page.categories.get(selectedCategory).subcategories) {
- optionY += subCategory.draw(vg, x + 30, optionY);
+ optionY += subCategory.draw(vg, x + 30, optionY, inputHandler);
}
for (OptionSubcategory subCategory : page.categories.get(selectedCategory).subcategories) {
- subCategory.drawLast(vg, x + 30);
+ subCategory.drawLast(vg, x + 30, inputHandler);
}
totalSize = optionY - y;
}
@Override
- public int drawStatic(long vg, int x, int y) {
+ public int drawStatic(long vg, int x, int y, InputHandler inputHandler) {
if (categories.size() <= 1) return 0;
int buttonX = x + 16;
for (BasicButton button : categories) {
if (button.getWidth() == 0)
button.setWidth((int) (Math.ceil(RenderManager.getTextWidth(vg, button.getText(), 12f, Fonts.MEDIUM) / 8f) * 8 + 16));
- button.draw(vg, buttonX, y + 16);
+ button.draw(vg, buttonX, y + 16, inputHandler);
buttonX += button.getWidth() + 16;
}
return 60;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
index d2df082..7dad8f0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -37,6 +37,7 @@ import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.TextRenderer;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.util.ArrayList;
@@ -65,14 +66,14 @@ public class ModsPage extends Page {
modCategories.get(0).setToggled(true);
}
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
String filter = OneConfigGui.INSTANCE == null ? "" : OneConfigGui.INSTANCE.getSearchValue().toLowerCase().trim();
int iX = x + 16;
int iY = y + 72;
ArrayList<ModCard> finalModCards = new ArrayList<>(modCards);
for (ModCard modCard : finalModCards) {
if (inSelection(modCard) && (filter.equals("") || modCard.getModData().name.toLowerCase().contains(filter))) {
- if (iY + 135 >= y - scroll && iY <= y + 728 - scroll) modCard.draw(vg, iX, iY);
+ if (iY + 135 >= y - scroll && iY <= y + 728 - scroll) modCard.draw(vg, iX, iY, inputHandler);
iX += 260;
if (iX > x + 796) {
iX = x + 16;
@@ -87,11 +88,11 @@ public class ModsPage extends Page {
}
@Override
- public int drawStatic(long vg, int x, int y) {
+ public int drawStatic(long vg, int x, int y, InputHandler inputHandler) {
int iXCat = x + 16;
boolean selected = false;
for (BasicButton btn : modCategories) {
- btn.draw(vg, iXCat, y + 16);
+ btn.draw(vg, iXCat, y + 16, inputHandler);
iXCat += btn.getWidth() + 8;
if (btn.isToggled()) selected = true;
}
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 01a1a8c..9b9b4d3 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
@@ -34,7 +34,7 @@ import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.scissor.Scissor;
import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.util.ArrayList;
@@ -57,27 +57,27 @@ public abstract class Page {
this.title = title;
}
- public abstract void draw(long vg, int x, int y);
+ public abstract void draw(long vg, int x, int y, InputHandler inputHandler);
/**
* 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) {
+ public int drawStatic(long vg, int x, int y, InputHandler inputHandler) {
return 0;
}
public void finishUpAndClose() {
}
- public void scrollWithDraw(long vg, int x, int y) {
+ public void scrollWithDraw(long vg, int x, int y, InputHandler inputHandler) {
int maxScroll = getMaxScrollHeight();
- int scissorOffset = drawStatic(vg, x, y);
+ int scissorOffset = drawStatic(vg, x, y, inputHandler);
scroll = scrollAnimation == null ? scrollTarget : scrollAnimation.get();
final float scrollBarLength = (728f / maxScroll) * 728f;
Scissor scissor = ScissorManager.scissor(vg, x, y + scissorOffset, x + 1056, y + 728 - scissorOffset);
- Scissor inputScissor = InputUtils.blockInputArea(x, y,1056, scissorOffset);
+ Scissor inputScissor = inputHandler.blockInputArea(x, y,1056, scissorOffset);
float dWheel = (float) Platform.getMousePlatform().getDWheel();
if (dWheel != 0) {
scrollTarget += dWheel;
@@ -89,31 +89,31 @@ public abstract class Page {
scrollTime = System.currentTimeMillis();
} else if (scrollAnimation != null && scrollAnimation.isFinished()) scrollAnimation = null;
if (maxScroll <= 728) {
- draw(vg, x, y);
+ draw(vg, x, y, inputHandler);
ScissorManager.resetScissor(vg, scissor);
- InputUtils.stopBlock(inputScissor);
+ inputHandler.stopBlock(inputScissor);
return;
}
- draw(vg, x, (int) (y + scroll));
- if (dragging && InputUtils.isClicked(true)) {
+ draw(vg, x, (int) (y + scroll), inputHandler);
+ if (dragging && inputHandler.isClicked(true)) {
dragging = false;
}
ScissorManager.resetScissor(vg, scissor);
- InputUtils.stopBlock(inputScissor);
+ inputHandler.stopBlock(inputScissor);
if (!(scrollBarLength > 727f)) {
final float scrollBarY = (scroll / maxScroll) * 720f;
final boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0);
- final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength);
+ final boolean scrollHover = inputHandler.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength);
final boolean scrollTimePeriod = (System.currentTimeMillis() - scrollTime < 1000);
final boolean hovered = (scrollHover || scrollTimePeriod) && Platform.getMousePlatform().isButtonDown(0);
if (scrollHover && isMouseDown && !mouseWasDown) {
- yStart = InputUtils.mouseY();
+ yStart = inputHandler.mouseY();
dragging = true;
}
mouseWasDown = isMouseDown;
if (dragging) {
- scrollTarget = -(InputUtils.mouseY() - yStart) * maxScroll / 728f;
+ scrollTarget = -(inputHandler.mouseY() - yStart) * maxScroll / 728f;
if (scrollTarget > 0f) scrollTarget = 0f;
else if (scrollTarget < -maxScroll + 728) scrollTarget = -maxScroll + 728;
scrollAnimation = new EaseOutQuad(150, scroll, scrollTarget, false);