aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index ba04aff..c0c4c96 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -38,16 +38,13 @@ import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.internal.config.OneConfigConfig;
import cc.polyfrost.oneconfig.internal.config.Preferences;
-import cc.polyfrost.oneconfig.libs.universal.UKeyboard;
-import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
-import cc.polyfrost.oneconfig.libs.universal.UResolution;
-import cc.polyfrost.oneconfig.libs.universal.UScreen;
+import cc.polyfrost.oneconfig.libs.universal.*;
import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
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 cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import org.jetbrains.annotations.NotNull;
@@ -58,6 +55,7 @@ import java.util.ArrayList;
public class OneConfigGui extends UScreen implements GuiPause {
public static OneConfigGui INSTANCE;
+ private InputHandler inputHandler = new InputHandler();
private final SideBar sideBar = new SideBar();
private final TextInputField textInputField = new TextInputField(248, 40, "Search...", false, false, SVGs.MAGNIFYING_GLASS_BOLD);
private final ArrayList<Page> previousPages = new ArrayList<>();
@@ -105,6 +103,7 @@ public class OneConfigGui extends UScreen implements GuiPause {
int x = (int) ((UResolution.getWindowWidth() - 1280 * scale) / 2f / scale);
int y = (int) ((UResolution.getWindowHeight() - 800 * scale) / 2f / scale);
RenderManager.scale(vg, scale, scale);
+ inputHandler.scale(scale, scale);
RenderManager.drawDropShadow(vg, x, y, 1280, 800, 32, 0, 20);
RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, Colors.GRAY_800, 20f);
@@ -119,10 +118,10 @@ public class OneConfigGui extends UScreen implements GuiPause {
RenderManager.drawText(vg, "OneConfig", x + 69, y + 32, -1, 18f, Fonts.BOLD); // added half line height to center text
RenderManager.drawText(vg, "By Polyfrost", x + 69, y + 51, -1, 12f, Fonts.REGULAR);
- textInputField.draw(vg, x + 1020, y + 16);
- sideBar.draw(vg, x, y);
- backArrow.draw(vg, x + 240, y + 16);
- forwardArrow.draw(vg, x + 288, y + 16);
+ textInputField.draw(vg, x + 1020, y + 16, inputHandler);
+ sideBar.draw(vg, x, y, inputHandler);
+ backArrow.draw(vg, x + 240, y + 16, inputHandler);
+ forwardArrow.draw(vg, x + 288, y + 16, inputHandler);
if (previousPages.size() == 0) {
backArrow.disable(true);
@@ -162,37 +161,37 @@ public class OneConfigGui extends UScreen implements GuiPause {
}
ScissorManager.scissor(vg, x + 224, y + 72, 1056, 728);
- Scissor blockedClicks = InputUtils.blockInputArea(x + 224, y, 1056, 72);
+ Scissor blockedClicks = inputHandler.blockInputArea(x + 224, y, 1056, 72);
if (prevPage != null && animation != null) {
float pageProgress = animation.get(GuiUtils.getDeltaTime());
if (!animation.isReversed()) {
- prevPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72);
- currentPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72);
+ prevPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72, inputHandler);
+ currentPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72, inputHandler);
} else {
- prevPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72);
- currentPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72);
+ prevPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72, inputHandler);
+ currentPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72, inputHandler);
}
if (animation.isFinished()) {
prevPage = null;
}
} else {
- currentPage.scrollWithDraw(vg, x + 224, y + 72);
+ currentPage.scrollWithDraw(vg, x + 224, y + 72, inputHandler);
}
ScissorManager.clearScissors(vg);
- InputUtils.stopBlock(blockedClicks);
+ inputHandler.stopBlock(blockedClicks);
float breadcrumbX = x + 352;
for (int i = 0; i < currentPage.parents.size(); i++) {
String title = currentPage.parents.get(i).getTitle();
float width = RenderManager.getTextWidth(vg, title, 24f, Fonts.SEMIBOLD);
- boolean hovered = InputUtils.isAreaHovered((int) breadcrumbX, y + 24, (int) width, 36);
+ boolean hovered = inputHandler.isAreaHovered((int) breadcrumbX, y + 24, (int) width, 36);
int color = Colors.WHITE_60;
if (i == currentPage.parents.size() - 1) color = Colors.WHITE;
else if (hovered && !Platform.getMousePlatform().isButtonDown(0)) color = Colors.WHITE_80;
RenderManager.drawText(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.SEMIBOLD);
if (i != 0)
RenderManager.drawSvg(vg, SVGs.CARET_RIGHT, breadcrumbX - 28, y + 25, 24, 24, color);
- if (hovered && InputUtils.isClicked()) openPage(currentPage.parents.get(i));
+ if (hovered && inputHandler.isClicked()) openPage(currentPage.parents.get(i));
breadcrumbX += width + 32;
}
@@ -264,7 +263,7 @@ public class OneConfigGui extends UScreen implements GuiPause {
/**
* initialize a new ColorSelector and add it to the draw script. This method is used to make sure it is always rendered on top.
* <p>
- * Correct usage: <code>OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY()));</code>
+ * Correct usage: <code>OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, inputUtils.mouseX(), inputUtils.mouseY()));</code>
*/
public void initColorSelector(ColorSelector colorSelector) {
if (currentColorSelector != null) closeColorSelector();