aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui
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
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')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java37
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java25
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java16
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java80
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java18
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java36
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java26
-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
26 files changed, 211 insertions, 200 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();
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index cad5a07..bd0503c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -39,6 +39,7 @@ import cc.polyfrost.oneconfig.internal.config.Preferences;
import cc.polyfrost.oneconfig.internal.gui.HudGui;
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 cc.polyfrost.oneconfig.utils.gui.GuiUtils;
@@ -78,7 +79,7 @@ public class SideBar {
}
}
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
this.y = y;
for (BasicButton button : buttons) {
if (!button.isClicked()) continue;
@@ -94,19 +95,19 @@ public class SideBar {
}
}
- buttons.get(0).draw(vg, x + 16, y + 80);
- buttons.get(1).draw(vg, x + 16, y + 116);
+ buttons.get(0).draw(vg, x + 16, y + 80, inputHandler);
+ buttons.get(1).draw(vg, x + 16, y + 116, inputHandler);
RenderManager.drawText(vg, "MOD CONFIG", x + 16, y + 178, Colors.WHITE, 12, Fonts.SEMIBOLD);
- buttons.get(2).draw(vg, x + 16, y + 192);
- buttons.get(3).draw(vg, x + 16, y + 228);
- buttons.get(4).draw(vg, x + 16, y + 264);
- buttons.get(5).draw(vg, x + 16, y + 300);
+ buttons.get(2).draw(vg, x + 16, y + 192, inputHandler);
+ buttons.get(3).draw(vg, x + 16, y + 228, inputHandler);
+ buttons.get(4).draw(vg, x + 16, y + 264, inputHandler);
+ buttons.get(5).draw(vg, x + 16, y + 300, inputHandler);
RenderManager.drawText(vg, "PERSONALIZATION", x + 16, y + 362, Colors.WHITE, 12, Fonts.SEMIBOLD);
- buttons.get(6).draw(vg, x + 16, y + 376);
- buttons.get(7).draw(vg, x + 16, y + 412);
- buttons.get(8).draw(vg, x + 16, y + 448);
- HUDButton.draw(vg, x + 16, y + 704);
- CloseButton.draw(vg, x + 16, y + 748);
+ buttons.get(6).draw(vg, x + 16, y + 376, inputHandler);
+ buttons.get(7).draw(vg, x + 16, y + 412, inputHandler);
+ buttons.get(8).draw(vg, x + 16, y + 448, inputHandler);
+ HUDButton.draw(vg, x + 16, y + 704, inputHandler);
+ CloseButton.draw(vg, x + 16, y + 748, inputHandler);
}
public void pageOpened(String page) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
index e1f7789..948ec11 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -32,6 +32,7 @@ import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.SVG;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import cc.polyfrost.oneconfig.utils.color.ColorUtils;
import org.jetbrains.annotations.NotNull;
@@ -83,10 +84,10 @@ public class BasicButton extends BasicElement {
}
@Override
- public void draw(long vg, float x, float y) {
+ public void draw(long vg, float x, float y, InputHandler inputHandler) {
this.x = x;
this.y = y;
- this.update(x, y);
+ this.update(x, y, inputHandler);
if (disabled) RenderManager.setAlpha(vg, 0.5f);
float contentWidth = 0f;
int color;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java
index 807b8aa..e390880 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java
@@ -29,7 +29,7 @@ package cc.polyfrost.oneconfig.gui.elements;
import cc.polyfrost.oneconfig.gui.animations.ColorAnimation;
import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import org.jetbrains.annotations.NotNull;
@@ -70,7 +70,7 @@ public class BasicElement {
public int currentColor;
protected final float radius;
/**
- * Boolean to determine if this element is allowed to be clicked when {@link InputUtils#isBlockingInput()} is true.
+ * Boolean to determine if this element is allowed to be clicked when {@link InputHandler#isBlockingInput()} is true.
*/
private boolean block = false;
/**
@@ -98,29 +98,29 @@ public class BasicElement {
/**
* Draw script for the element.
- * <br> <b>Make sure to call {@link #update(float, float)} to update the elements states!</b>
+ * <br> <b>Make sure to call {@link #update(float, float, InputHandler)} to update the elements states!</b>
*
* @param vg NanoVG context (see {@link RenderManager})
* @param x x position of the element
* @param y y position of the element
*/
- public void draw(long vg, float x, float y) {
- this.update(x, y);
+ public void draw(long vg, float x, float y, InputHandler inputHandler) {
+ this.update(x, y, inputHandler);
RenderManager.drawRoundedRect(vg, x, y, width, height, currentColor, radius);
}
/**
* Update this element's clicked, hovered, toggled, and pressed states, invoke any necessary methods, and update the color animation.
*/
- public void update(float x, float y) {
+ public void update(float x, float y, InputHandler inputHandler) {
if (disabled) {
hovered = false;
pressed = false;
clicked = false;
} else {
- hovered = InputUtils.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY);
+ hovered = inputHandler.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY);
pressed = hovered && Platform.getMousePlatform().isButtonDown(0);
- clicked = InputUtils.isClicked(block) && hovered;
+ clicked = inputHandler.isClicked(block) && hovered;
if (clicked) {
toggled = !toggled;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
index b03f868..0fa5514 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
@@ -44,7 +44,7 @@ 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.IOUtils;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.NetworkUtils;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
@@ -80,12 +80,14 @@ public class ColorSelector {
private boolean dragging, mouseWasDown;
private final boolean hasAlpha;
private Scissor inputScissor = null;
+ private final InputHandler inputHandler;
- public ColorSelector(OneColor color, float mouseX, float mouseY) {
- this(color, mouseX, mouseY, true);
+ public ColorSelector(OneColor color, float mouseX, float mouseY, InputHandler inputHandler) {
+ this(color, mouseX, mouseY, true, inputHandler);
}
- public ColorSelector(OneColor color, float mouseX, float mouseY, boolean hasAlpha) {
+ public ColorSelector(OneColor color, float mouseX, float mouseY, boolean hasAlpha, InputHandler inputHandler) {
+ this.inputHandler = inputHandler;
this.color = color;
this.hasAlpha = hasAlpha;
buttons.add(new BasicButton(124, 28, "HSB Box", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY));
@@ -132,7 +134,7 @@ public class ColorSelector {
}
public void draw(long vg) {
- if (inputScissor != null) InputUtils.stopBlock(inputScissor);
+ if (inputScissor != null) inputHandler.stopBlock(inputScissor);
doDrag();
int width = 416;
int height = 768;
@@ -141,7 +143,7 @@ public class ColorSelector {
RenderManager.drawRoundedRect(vg, x, y, width, height, Colors.GRAY_800, 20f);
RenderManager.drawText(vg, "Color Selector", x + 16, y + 32, Colors.WHITE_90, 18f, Fonts.SEMIBOLD);
if (!closeBtn.isHovered()) RenderManager.setAlpha(vg, 0.8f);
- closeBtn.draw(vg, x + 368, y + 16);
+ closeBtn.draw(vg, x + 368, y + 16, inputHandler);
RenderManager.drawSvg(vg, SVGs.X_CIRCLE_BOLD, x + 368, y + 16, 32, 32, closeBtn.isHovered() ? Colors.ERROR_600 : -1);
RenderManager.setAlpha(vg, 1f);
@@ -151,13 +153,13 @@ public class ColorSelector {
}
// TODO favorite stuff
- faveBtn.draw(vg, x + 16, y + 672);
- recentBtn.draw(vg, x + 16, y + 720);
+ faveBtn.draw(vg, x + 16, y + 672, inputHandler);
+ recentBtn.draw(vg, x + 16, y + 720, inputHandler);
for (int i = 0; i < 7; i++) {
- favoriteColors.get(i).draw(vg, x + 104 + i * 44, y + 672);
+ favoriteColors.get(i).draw(vg, x + 104 + i * 44, y + 672, inputHandler);
}
for (int i = 0; i < 7; i++) {
- recentColors.get(i).draw(vg, x + 104 + i * 44, y + 720);
+ recentColors.get(i).draw(vg, x + 104 + i * 44, y + 720, inputHandler);
}
RenderManager.drawRoundedRect(vg, x + 16, y + 64, 384, 32, Colors.GRAY_500, 12f);
@@ -167,7 +169,7 @@ public class ColorSelector {
int i = 18;
for (BasicElement button : buttons) {
- button.draw(vg, x + i, y + 66);
+ button.draw(vg, x + i, y + 66, inputHandler);
if (button.isClicked()) {
int prevMode = mode;
mode = buttons.indexOf(button);
@@ -181,36 +183,36 @@ public class ColorSelector {
float percentMoveMain = moveAnimation.get();
RenderManager.drawText(vg, "Saturation", x + 224, y + 560, Colors.WHITE_80, 12f, Fonts.MEDIUM);
- saturationInput.draw(vg, x + 312, y + 544);
+ saturationInput.draw(vg, x + 312, y + 544, inputHandler);
RenderManager.drawText(vg, "Brightness", x + 16, y + 599, Colors.WHITE_80, 12f, Fonts.MEDIUM);
- brightnessInput.draw(vg, x + 104, y + 584);
+ brightnessInput.draw(vg, x + 104, y + 584, inputHandler);
RenderManager.drawText(vg, "Alpha (%)", x + 224, y + 599, Colors.WHITE_80, 12f, Fonts.MEDIUM);
- alphaInput.draw(vg, x + 312, y + 584);
+ alphaInput.draw(vg, x + 312, y + 584, inputHandler);
RenderManager.drawText(vg, color.getDataBit() == -1 ? "Hex (RGB):" : "Color Code:", x + 16, y + 641, Colors.WHITE_80, 12f, Fonts.MEDIUM);
- hexInput.draw(vg, x + 104, y + 624);
+ hexInput.draw(vg, x + 104, y + 624, inputHandler);
- copyBtn.draw(vg, x + 204, y + 624);
- pasteBtn.draw(vg, x + 244, y + 624);
+ copyBtn.draw(vg, x + 204, y + 624, inputHandler);
+ pasteBtn.draw(vg, x + 244, y + 624, inputHandler);
if (mode != 2) {
RenderManager.drawText(vg, "Hue", x + 16, y + 560, Colors.WHITE_80, 12f, Fonts.MEDIUM);
- hueInput.draw(vg, x + 104, y + 544);
+ hueInput.draw(vg, x + 104, y + 544, inputHandler);
} else {
RenderManager.drawText(vg, "Speed (s)", x + 16, y + 560, Colors.WHITE_80, 12f, Fonts.MEDIUM);
- speedInput.draw(vg, x + 104, y + 544);
+ speedInput.draw(vg, x + 104, y + 544, inputHandler);
}
- guideBtn.draw(vg, x + 288, y + 624);
+ guideBtn.draw(vg, x + 288, y + 624, inputHandler);
setColorFromXY();
if (mode != 2) color.setChromaSpeed(-1);
drawColorSelector(vg, mode, (x * percentMoveMain), y);
- if (dragging && InputUtils.isClicked(true)) {
+ if (dragging && inputHandler.isClicked(true)) {
dragging = false;
}
bottomSlider.setGradient(Colors.TRANSPARENT, color.getRGBNoAlpha());
RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x + 16, y + 456, 384, 16, 8f);
- bottomSlider.draw(vg, x + 16, y + 456);
+ bottomSlider.draw(vg, x + 16, y + 456, inputHandler);
if (percentMoveMain > 0.96f) {
RenderManager.drawRoundedRect(vg, mouseX - 7, mouseY - 7, 14, 14, Colors.WHITE, 14f);
@@ -227,7 +229,7 @@ public class ColorSelector {
RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x + 20, y + 492, 376, 32, 8f);
RenderManager.drawRoundedRect(vg, x + 20, y + 492, 376, 32, color.getRGB(), 8f);
- inputScissor = InputUtils.blockInputArea(x - 3, y - 3, width + 6, height + 6);
+ inputScissor = inputHandler.blockInputArea(x - 3, y - 3, width + 6, height + 6);
ScissorManager.resetScissor(vg, scissor);
mouseWasDown = Platform.getMousePlatform().isButtonDown(0);
if (closeBtn.isClicked()) {
@@ -246,10 +248,10 @@ public class ColorSelector {
if (mode == 0) {
topSlider.setColor(color.getRGBMax(true));
- topSlider.draw(vg, x + 16, y + 424);
+ topSlider.draw(vg, x + 16, y + 424, inputHandler);
}
if (mode == 2) {
- speedSlider.draw(vg, x + 60, y + 424);
+ speedSlider.draw(vg, x + 60, y + 424, inputHandler);
RenderManager.drawText(vg, "SLOW", x + 16, y + 429, Colors.WHITE_80, 12f, Fonts.REGULAR);
RenderManager.drawText(vg, "FAST", x + 370, y + 429, Colors.WHITE_80, 12f, Fonts.REGULAR);
}
@@ -261,13 +263,13 @@ public class ColorSelector {
topSlider.setGradient(Colors.BLACK, color.getRGBMax(true));
topSlider.setImage(null);
- topSlider.draw(vg, x + 16, y + 424);
+ topSlider.draw(vg, x + 16, y + 424, inputHandler);
break;
}
}
private void doDrag() {
- if (InputUtils.isAreaHovered(x, y, 368, 64) && Platform.getMousePlatform().isButtonDown(0) && !dragging) {
+ if (inputHandler.isAreaHovered(x, y, 368, 64) && Platform.getMousePlatform().isButtonDown(0) && !dragging) {
float dx = (float) (Platform.getMousePlatform().getMouseDX() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor()));
float dy = (float) (Platform.getMousePlatform().getMouseDY() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor()));
x += dx;
@@ -279,14 +281,14 @@ public class ColorSelector {
private void setColorFromXY() {
boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0);
- boolean hovered = Platform.getMousePlatform().isButtonDown(0) && InputUtils.isAreaHovered(x + 16, y + 120, 384, 288);
+ boolean hovered = Platform.getMousePlatform().isButtonDown(0) && inputHandler.isAreaHovered(x + 16, y + 120, 384, 288);
if (hovered && isMouseDown && !mouseWasDown) dragging = true;
switch (mode) {
case 0:
case 2:
if (dragging) {
- mouseX = InputUtils.mouseX();
- mouseY = InputUtils.mouseY();
+ mouseX = inputHandler.mouseX();
+ mouseY = inputHandler.mouseY();
}
if (mouseX < x + 16) mouseX = x + 16;
if (mouseY < y + 120) mouseY = y + 120;
@@ -307,7 +309,7 @@ public class ColorSelector {
case 1:
float circleCenterX = x + 208;
float circleCenterY = y + 264;
- double squareDist = Math.pow((circleCenterX - InputUtils.mouseX()), 2) + Math.pow((circleCenterY - InputUtils.mouseY()), 2);
+ double squareDist = Math.pow((circleCenterX - inputHandler.mouseX()), 2) + Math.pow((circleCenterY - inputHandler.mouseY()), 2);
hovered = squareDist < 144 * 144 && Platform.getMousePlatform().isButtonDown(0);
isMouseDown = Platform.getMousePlatform().isButtonDown(0);
if (hovered && isMouseDown && !mouseWasDown) dragging = true;
@@ -315,7 +317,7 @@ public class ColorSelector {
int angle = 0;
int saturation = color.getSaturation();
if (dragging) {
- angle = (int) Math.toDegrees(Math.atan2(InputUtils.mouseY() - circleCenterY, InputUtils.mouseX() - circleCenterX));
+ angle = (int) Math.toDegrees(Math.atan2(inputHandler.mouseY() - circleCenterY, inputHandler.mouseX() - circleCenterX));
if (angle < 0) angle += 360;
if ((squareDist / (144 * 144) > 1f)) {
saturation = 100;
@@ -323,8 +325,8 @@ public class ColorSelector {
mouseY = (float) (Math.cos(Math.toRadians(-angle) + 1.5708) * 144 + y + 264);
} else {
saturation = (int) (squareDist / (144 * 144) * 100);
- mouseX = InputUtils.mouseX();
- mouseY = InputUtils.mouseY();
+ mouseX = inputHandler.mouseX();
+ mouseY = inputHandler.mouseY();
}
}
color.setHSBA(dragging ? angle : color.getHue(), saturation, (int) (topSlider.getValue() / 360 * 100), (int) bottomSlider.getValue());
@@ -419,7 +421,7 @@ public class ColorSelector {
}
public void onClose() {
- if (inputScissor != null) InputUtils.stopBlock(inputScissor);
+ if (inputScissor != null) inputHandler.stopBlock(inputScissor);
/*for (int i = 0; i < OneConfigConfig.recentColors.size(); i++) {
OneColor color1 = OneConfigConfig.recentColors.get(i);
if (color1.getRGB() == color.getRGB()) {
@@ -455,8 +457,8 @@ public class ColorSelector {
}
@Override
- public void draw(long vg, float x, float y) {
- if (!disabled) update(x, y);
+ public void draw(long vg, float x, float y, InputHandler inputHandler) {
+ if (!disabled) update(x, y, inputHandler);
else RenderManager.setAlpha(vg, 0.5f);
super.dragPointerSize = 15f;
if (image != null) {
@@ -495,11 +497,11 @@ public class ColorSelector {
}
@Override
- public void draw(long vg, float x, float y) {
+ public void draw(long vg, float x, float y, InputHandler inputHandler) {
RenderManager.drawRoundedRect(vg, x, y, 32, 32, toggled ? Colors.PRIMARY_600 : Colors.GRAY_300, 12f);
RenderManager.drawRoundedRect(vg, x + 2, y + 2, 28, 28, Colors.GRAY_800, 10f);
RenderManager.drawRoundedRect(vg, x + 4, y + 4, 24, 24, color.getRGB(), 8f);
- update(x, y);
+ update(x, y, inputHandler);
}
public OneColor getColor() {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
index 5b30b59..afeaccd 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -42,7 +42,7 @@ 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.color.ColorUtils;
import org.jetbrains.annotations.NotNull;
@@ -70,13 +70,13 @@ public class ModCard extends BasicElement {
}
@Override
- public void draw(long vg, float x, float y) {
- super.update(x, y);
+ public void draw(long vg, float x, float y, InputHandler inputHandler) {
+ super.update(x, y, inputHandler);
String cleanName = modData.name.replaceAll("ยง.", "");
Scissor scissor = ScissorManager.scissor(vg, x, y, width, height);
- isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87);
- boolean isHoveredSecondary = InputUtils.isAreaHovered(x, y + 87, width - 32, 32) && !disabled;
+ isHoveredMain = inputHandler.isAreaHovered(x, y, width, 87);
+ boolean isHoveredSecondary = inputHandler.isAreaHovered(x, y + 87, width - 32, 32) && !disabled;
if (disabled) RenderManager.setAlpha(vg, 0.5f);
RenderManager.drawRoundedRectVaried(vg, x, y, width, 87, colorFrame.getColor(isHoveredMain, isHoveredMain && Platform.getMousePlatform().isButtonDown(0)), 12f, 12f, 0f, 0f);
RenderManager.drawRoundedRectVaried(vg, x, y + 87, width, 32, colorToggle.getColor(isHoveredSecondary, isHoveredSecondary && Platform.getMousePlatform().isButtonDown(0)), 0f, 0f, 12f, 12f);
@@ -88,7 +88,7 @@ public class ModCard extends BasicElement {
} else {
RenderManager.drawText(vg, cleanName, x + Math.max(0, (244 - RenderManager.getTextWidth(vg, cleanName, 16, Fonts.MINECRAFT_BOLD))) / 2f, y + 44, ColorUtils.setAlpha(Colors.WHITE, (int) (colorFrame.getAlpha() * 255)), 16, Fonts.MINECRAFT_BOLD);
}
- favoriteButton.draw(vg, x + 212, y + 87);
+ favoriteButton.draw(vg, x + 212, y + 87, inputHandler);
favorite = favoriteButton.isToggled();
if (favoriteButton.isClicked()) {
if (favorite) OneConfigConfig.favoriteMods.add(modData.name);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java
index a43103b..ffb4470 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java