diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
16 files changed, 107 insertions, 101 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java new file mode 100644 index 0000000..44b2b5c --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java @@ -0,0 +1,9 @@ +package cc.polyfrost.oneconfig.gui; + +/** + * Hack that allows GUIs to set whether the game should pause when the GUI is displayed without depending on + * Minecraft itself. + */ +public interface GuiPause { + boolean doesGuiPauseGame(); +} diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java index b13170a..2c3e681 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java @@ -3,6 +3,7 @@ package cc.polyfrost.oneconfig.gui; import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; import cc.polyfrost.oneconfig.hud.Hud; import cc.polyfrost.oneconfig.internal.hud.HudCore; +import cc.polyfrost.oneconfig.libs.universal.UResolution; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; @@ -13,7 +14,7 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; import java.util.ArrayList; -public class HudGui extends UScreen { +public class HudGui extends UScreen implements GuiPause { private Hud editingHud; private boolean isDragging; private boolean isScaling; @@ -29,7 +30,7 @@ public class HudGui extends UScreen { @Override public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - RenderManager.drawGlRect(0, 0, this.width, this.height, new Color(80, 80, 80, 50).getRGB()); + RenderManager.drawGlRect(0, 0, UResolution.getScaledWidth(), UResolution.getScaledHeight(), new Color(80, 80, 80, 50).getRGB()); if (isDragging) { setPosition(mouseX - xOffset, mouseY - yOffset, true); @@ -42,8 +43,8 @@ public class HudGui extends UScreen { private void processHud(Hud hud, int mouseX) { if (hud == editingHud && isScaling) { - float xFloat = hud.getXScaled(this.width); - float yFloat = hud.getYScaled(this.height); + float xFloat = hud.getXScaled(UResolution.getScaledWidth()); + float yFloat = hud.getYScaled(UResolution.getScaledHeight()); float pos = getXSnapping(mouseX, true); float newWidth = pos - xFloat; float newScale = newWidth / ((hud.getWidth(hud.scale) + hud.paddingX * hud.scale) / hud.scale); @@ -53,16 +54,16 @@ public class HudGui extends UScreen { newScale = 0.3f; hud.scale = newScale; - if (xFloat / this.width > 0.5) - editingHud.xUnscaled = (xFloat + (hud.getWidth(hud.scale) + hud.paddingX * hud.scale)) / (double) this.width; - if (yFloat / this.height > 0.5) - editingHud.yUnscaled = (yFloat + (hud.getHeight(hud.scale) + hud.paddingY * hud.scale)) / (double) this.height; + if (xFloat / UResolution.getScaledWidth() > 0.5) + editingHud.xUnscaled = (xFloat + (hud.getWidth(hud.scale) + hud.paddingX * hud.scale)) / (double) UResolution.getScaledWidth(); + if (yFloat / UResolution.getScaledHeight() > 0.5) + editingHud.yUnscaled = (yFloat + (hud.getHeight(hud.scale) + hud.paddingY * hud.scale)) / (double) UResolution.getScaledHeight(); } int width = (int) (hud.getExampleWidth(hud.scale) + hud.paddingX * hud.scale); int height = (int) (hud.getExampleHeight(hud.scale) + hud.paddingY * hud.scale); - int x = (int) hud.getXScaled(this.width); - int y = (int) hud.getYScaled(this.height); + int x = (int) hud.getXScaled(UResolution.getScaledWidth()); + int y = (int) hud.getYScaled(UResolution.getScaledHeight()); hud.drawExampleAll(x, y, hud.scale, true); int color = new Color(215, 224, 235).getRGB(); @@ -90,12 +91,12 @@ public class HudGui extends UScreen { if (newX < 0) newX = 0; - else if (newX + width > this.width) - newX = this.width - width; + else if (newX + width > UResolution.getScaledWidth()) + newX = UResolution.getScaledWidth() - width; if (newY < 0) newY = 0; - else if (newY + height > this.height) - newY = this.height - height; + else if (newY + height > UResolution.getScaledHeight()) + newY = UResolution.getScaledHeight() - height; if (snap) { float snapX = getXSnapping(newX, false); @@ -106,14 +107,14 @@ public class HudGui extends UScreen { } } - if (newX / this.width <= 0.5) - editingHud.xUnscaled = newX / (double) this.width; + if (newX / UResolution.getScaledWidth() <= 0.5) + editingHud.xUnscaled = newX / (double) UResolution.getScaledWidth(); else - editingHud.xUnscaled = (newX + width) / (double) this.width; - if (newY / this.height <= 0.5) - editingHud.yUnscaled = newY / (double) this.height; + editingHud.xUnscaled = (newX + width) / (double) UResolution.getScaledWidth(); + if (newY / UResolution.getScaledHeight() <= 0.5) + editingHud.yUnscaled = newY / (double) UResolution.getScaledHeight(); else - editingHud.yUnscaled = (newY + height) / (double) this.height; + editingHud.yUnscaled = (newY + height) / (double) UResolution.getScaledHeight(); } private float getXSnapping(float pos, boolean rightOnly) { @@ -124,7 +125,7 @@ public class HudGui extends UScreen { verticalLines.addAll(getXSnappingHud(hud)); } getSpaceSnapping(verticalLines); - verticalLines.add(this.width / 2f); + verticalLines.add(UResolution.getScaledWidth() / 2f); float smallestDiff = -1; float smallestLine = 0; float smallestOffset = 0; @@ -139,7 +140,7 @@ public class HudGui extends UScreen { } if (smallestDiff != -1) { float finalSmallestLine = smallestLine; - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, finalSmallestLine, 0, finalSmallestLine, this.height, 1, new Color(255, 255, 255).getRGB())); + RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, finalSmallestLine, 0, finalSmallestLine, UResolution.getScaledHeight(), 1, new Color(255, 255, 255).getRGB())); return smallestLine - smallestOffset; } return pos; @@ -149,7 +150,7 @@ public class HudGui extends UScreen { ArrayList<Float> verticalLines = new ArrayList<>(); if (hud == editingHud) return verticalLines; int hudWidth = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int hudX = (int) hud.getXScaled(this.width); + int hudX = (int) hud.getXScaled(UResolution.getScaledWidth()); verticalLines.add((float) hudX); verticalLines.add((float) (hudX + hudWidth)); return verticalLines; @@ -163,7 +164,7 @@ public class HudGui extends UScreen { horizontalLines.addAll(getYSnappingHud(hud)); } getSpaceSnapping(horizontalLines); - horizontalLines.add(this.height / 2f); + horizontalLines.add(UResolution.getScaledHeight() / 2f); float smallestDiff = -1; float smallestLine = 0; float smallestOffset = 0; @@ -178,7 +179,7 @@ public class HudGui extends UScreen { } if (smallestDiff != -1) { float finalSmallestLine = smallestLine; - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, 0, finalSmallestLine, this.width, finalSmallestLine, 1, new Color(255, 255, 255).getRGB())); + RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, 0, finalSmallestLine, UResolution.getScaledWidth(), finalSmallestLine, 1, new Color(255, 255, 255).getRGB())); return smallestLine - smallestOffset; } return pos; @@ -188,7 +189,7 @@ public class HudGui extends UScreen { ArrayList<Float> horizontalLines = new ArrayList<>(); if (hud == editingHud) return horizontalLines; int hudHeight = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int hudY = (int) hud.getYScaled(this.height); + int hudY = (int) hud.getYScaled(UResolution.getScaledHeight()); horizontalLines.add((float) hudY); horizontalLines.add((float) (hudY + hudHeight)); return horizontalLines; @@ -212,8 +213,8 @@ public class HudGui extends UScreen { if (editingHud != null) { int width = (int) (editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale); int height = (int) (editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale); - float x = editingHud.getXScaled(this.width); - float y = editingHud.getYScaled(this.height); + float x = editingHud.getXScaled(UResolution.getScaledWidth()); + float y = editingHud.getYScaled(UResolution.getScaledHeight()); if (mouseX >= x + width - 3 && mouseX <= x + width + 3 && mouseY >= y + height - 3 && mouseY <= y + height + 3) { isScaling = true; return; @@ -231,8 +232,8 @@ public class HudGui extends UScreen { private boolean mouseClickedHud(Hud hud, int mouseX, int mouseY) { int width = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); int height = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - float x = hud.getXScaled(this.width); - float y = hud.getYScaled(this.height); + float x = hud.getXScaled(UResolution.getScaledWidth()); + float y = hud.getYScaled(UResolution.getScaledHeight()); if (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height) { editingHud = hud; xOffset = (int) (mouseX - x); @@ -253,8 +254,8 @@ public class HudGui extends UScreen { @Override public void onKeyPressed(int keyCode, char typedChar, @Nullable UKeyboard.Modifiers modifiers) { if (editingHud != null) { - float x = editingHud.getXScaled(this.width); - float y = editingHud.getYScaled(this.height); + float x = editingHud.getXScaled(UResolution.getScaledWidth()); + float y = editingHud.getYScaled(UResolution.getScaledHeight()); if (keyCode == UKeyboard.KEY_UP) { setPosition(x, y - 1, false); } else if (keyCode == UKeyboard.KEY_DOWN) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index fd3c86b..35946e0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -8,7 +8,6 @@ import cc.polyfrost.oneconfig.gui.elements.ColorSelector; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; import cc.polyfrost.oneconfig.gui.pages.ModsPage; import cc.polyfrost.oneconfig.gui.pages.Page; -import cc.polyfrost.oneconfig.internal.OneConfig; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; @@ -17,6 +16,7 @@ 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.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; @@ -26,12 +26,11 @@ import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.lwjgl.input.Mouse; import org.lwjgl.nanovg.NanoVG; import java.util.ArrayList; -public class OneConfigGui extends UScreen { +public class OneConfigGui extends UScreen implements GuiPause { public static OneConfigGui INSTANCE; public static OneConfigGui instanceToRestore = null; private final SideBar sideBar = new SideBar(); @@ -110,7 +109,7 @@ public class OneConfigGui extends UScreen { RenderManager.setAlpha(vg, 0.5f); } else { backArrow.disable(false); - if (!backArrow.isHovered() || Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); + if (!backArrow.isHovered() || Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); } RenderManager.drawSvg(vg, SVGs.CARET_LEFT, x + 246, y + 22, 28, 28); RenderManager.setAlpha(vg, 1f); @@ -119,7 +118,7 @@ public class OneConfigGui extends UScreen { RenderManager.setAlpha(vg, 0.5f); } else { forwardArrow.disable(false); - if (!forwardArrow.isHovered() || Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); + if (!forwardArrow.isHovered() || Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); } RenderManager.drawSvg(vg, SVGs.CARET_RIGHT, x + 294, y + 22, 28, 28); RenderManager.setAlpha(vg, 1f); @@ -167,7 +166,7 @@ public class OneConfigGui extends UScreen { boolean hovered = InputUtils.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 && !Mouse.isButtonDown(0)) color = Colors.WHITE_80; + 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); @@ -182,7 +181,7 @@ public class OneConfigGui extends UScreen { currentColorSelector.draw(vg); } }); - mouseDown = Mouse.isButtonDown(0); + mouseDown = Platform.getMousePlatform().isButtonDown(0); } @Override @@ -194,7 +193,7 @@ public class OneConfigGui extends UScreen { if (currentColorSelector != null) currentColorSelector.keyTyped(typedChar, keyCode); currentPage.keyTyped(typedChar, keyCode); } catch (Exception e) { - OneConfig.LOGGER.error("Error while processing keyboard input; ignoring!"); + e.printStackTrace(); } } @@ -274,15 +273,15 @@ public class OneConfigGui extends UScreen { } @Override - public boolean doesGuiPauseGame() { - return false; - } - - @Override public void onScreenClose() { currentPage.finishUpAndClose(); instanceToRestore = this; INSTANCE = null; super.onScreenClose(); } + + @Override + public boolean doesGuiPauseGame() { + return false; + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index f6ce543..df3330d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -7,13 +7,13 @@ import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.gui.pages.CreditsPage; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.gui.pages.ModsPage; -import cc.polyfrost.oneconfig.internal.OneConfig; import cc.polyfrost.oneconfig.internal.assets.Colors; +import cc.polyfrost.oneconfig.internal.assets.SVGs; +import cc.polyfrost.oneconfig.internal.config.Preferences; 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.gui.GuiUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.gui.GuiUtils; import java.util.ArrayList; @@ -42,7 +42,7 @@ public class SideBar { public SideBar() { buttons.get(0).setClickAction(new CreditsPage()); buttons.get(2).setClickAction(new ModsPage()); - buttons.get(8).setClickAction(new ModConfigPage(OneConfig.preferences.mod.defaultPage, true)); + buttons.get(8).setClickAction(new ModConfigPage(Preferences.getInstance().mod.defaultPage, true)); HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui())); CloseButton.setClickAction(GuiUtils::closeScreen); for (BasicButton button : buttons) { 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 56eac2d..6f203c4 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -1,11 +1,11 @@ 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.color.ColorPalette; import org.jetbrains.annotations.NotNull; -import org.lwjgl.input.Mouse; public class BasicElement { protected int width, height; @@ -93,7 +93,7 @@ public class BasicElement { clicked = false; } else { hovered = InputUtils.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY); - pressed = hovered && Mouse.isButtonDown(0); + pressed = hovered && Platform.getMousePlatform().isButtonDown(0); clicked = InputUtils.isClicked(block) && hovered; if (clicked) { 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 668fdb3..1fed640 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -12,6 +12,7 @@ import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.internal.assets.Images; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; +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; @@ -20,7 +21,6 @@ import cc.polyfrost.oneconfig.utils.IOUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.NetworkUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import org.lwjgl.input.Mouse; import java.awt.*; import java.util.ArrayList; @@ -203,7 +203,7 @@ public class ColorSelector { inputScissor = InputUtils.blockInputArea(x - 3, y - 3, width + 6, height + 6); ScissorManager.resetScissor(vg, scissor); - mouseWasDown = Mouse.isButtonDown(0); + mouseWasDown = Platform.getMousePlatform().isButtonDown(0); if (closeBtn.isClicked()) { OneConfigGui.INSTANCE.closeColorSelector(); } @@ -241,9 +241,9 @@ public class ColorSelector { } private void doDrag() { - if (InputUtils.isAreaHovered(x, y, 368, 64) && Mouse.isButtonDown(0) && !dragging) { - int dx = (int) (Mouse.getDX() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); - int dy = (int) (Mouse.getDY() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); + if (InputUtils.isAreaHovered(x, y, 368, 64) && Platform.getMousePlatform().isButtonDown(0) && !dragging) { + int dx = (int) (Platform.getMousePlatform().getMouseDX() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); + int dy = (int) (Platform.getMousePlatform().getMouseDY() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); x += dx; mouseX += dx; y -= dy; @@ -252,8 +252,8 @@ public class ColorSelector { } private void setColorFromXY() { - boolean isMouseDown = Mouse.isButtonDown(0); - boolean hovered = Mouse.isButtonDown(0) && InputUtils.isAreaHovered(x + 16, y + 120, 384, 288); + boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0); + boolean hovered = Platform.getMousePlatform().isButtonDown(0) && InputUtils.isAreaHovered(x + 16, y + 120, 384, 288); if (hovered && isMouseDown && !mouseWasDown) dragging = true; switch (mode) { case 0: @@ -282,8 +282,8 @@ public class ColorSelector { int circleCenterX = x + 208; int circleCenterY = y + 264; double squareDist = Math.pow((circleCenterX - InputUtils.mouseX()), 2) + Math.pow((circleCenterY - InputUtils.mouseY()), 2); - hovered = squareDist < 144 * 144 && Mouse.isButtonDown(0); - isMouseDown = Mouse.isButtonDown(0); + hovered = squareDist < 144 * 144 && Platform.getMousePlatform().isButtonDown(0); + isMouseDown = Platform.getMousePlatform().isButtonDown(0); if (hovered && isMouseDown && !mouseWasDown) dragging = true; int angle = 0; 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 2938c41..eebdba1 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -5,11 +5,11 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.gui.pages.ModsPage; -import cc.polyfrost.oneconfig.internal.OneConfig; 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.core.ConfigCore; +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; @@ -18,7 +18,6 @@ import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.color.ColorUtils; import org.jetbrains.annotations.NotNull; -import org.lwjgl.input.Mouse; public class ModCard extends BasicElement { private final Mod modData; @@ -51,8 +50,8 @@ public class ModCard extends BasicElement { isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87); boolean isHoveredSecondary = InputUtils.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 && Mouse.isButtonDown(0)), 12f, 12f, 0f, 0f); - RenderManager.drawRoundedRectVaried(vg, x, y + 87, width, 32, colorToggle.getColor(isHoveredSecondary, isHoveredSecondary && Mouse.isButtonDown(0)), 0f, 0f, 12f, 12f); + 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); RenderManager.drawLine(vg, x, y + 86, x + width, y + 86, 2, Colors.GRAY_300); if (modData.modIcon != null) { if (modData.modIcon.toLowerCase().endsWith(".svg")) @@ -68,7 +67,6 @@ public class ModCard extends BasicElement { else OneConfigConfig.favoriteMods.remove(modData.name); ConfigCore.sortMods(); page.reloadMods(); - OneConfig.config.save(); } Scissor scissor2 = ScissorManager.scissor(vg, x, y + 87, width - 32, 32); RenderManager.drawText(vg, cleanName, x + 12, y + 103, ColorUtils.setAlpha(Colors.WHITE, (int) (colorToggle.getAlpha() * 255)), 14f, Fonts.MEDIUM); 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 8c9dfb6..dda5621 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java @@ -1,9 +1,9 @@ package cc.polyfrost.oneconfig.gui.elements; import cc.polyfrost.oneconfig.internal.assets.Colors; +import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.utils.InputUtils; -import org.lwjgl.input.Mouse; public class Slider extends BasicElement { private final float min, max; @@ -34,7 +34,7 @@ public class Slider extends BasicElement { public void update(int x, int y) { super.update(x, y); - boolean isMouseDown = Mouse.isButtonDown(0); + boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0); boolean hovered = InputUtils.isAreaHovered(x - 6, y - 3, width + 12, height + 6); if (hovered && isMouseDown && !mouseWasDown) dragging = true; mouseWasDown = isMouseDown; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java index 0ff7d8f..51303c6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java @@ -7,13 +7,13 @@ import cc.polyfrost.oneconfig.gui.animations.Animation; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad; +import cc.polyfrost.oneconfig.platform.Platform; 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.InputUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.color.ColorUtils; -import org.lwjgl.input.Mouse; import java.awt.*; import java.lang.reflect.Field; @@ -57,7 +57,7 @@ public class ConfigCheckbox extends BasicOption { RenderManager.drawText(vg, name, x + 32, y + 17, Colors.WHITE_90, 14f, Fonts.MEDIUM); - RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, color.getColor(hover, hover && Mouse.isButtonDown(0)), 6f); + RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, color.getColor(hover, hover && Platform.getMousePlatform().isButtonDown(0)), 6f); RenderManager.drawHollowRoundRect(vg, x, y + 4, 23.5f, 23.5f, Colors.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, ColorUtils.setAlpha(Colors.PRIMARY_500, (int) (percentOn * 255)), 6f); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java index 26d7348..ddcf6eb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java @@ -4,13 +4,13 @@ import cc.polyfrost.oneconfig.config.annotations.Dropdown; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.config.elements.BasicOption; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; +import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import org.lwjgl.input.Mouse; import java.awt.*; import java.lang.reflect.Field; @@ -58,14 +58,14 @@ public class ConfigDropdown extends BasicOption { } catch (IllegalAccessException ignored) { } - if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); + if (hovered && Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); if (size == 1) { - RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor.getColor(hovered, hovered && Mouse.isButtonDown(0)), 12); + RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor.getColor(hovered, hovered && Platform.getMousePlatform().isButtonDown(0)), 12); RenderManager.drawText(vg, options[selected], x + 236, y + 16, Colors.WHITE_80, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, atomColor.getColor(hovered, false), 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 452, y + 4, 24, 24); } else { - RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor.getColor(hovered, hovered && Mouse.isButtonDown(0)), 12); + RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor.getColor(hovered, hovered && Platform.getMousePlatform().isButtonDown(0)), 12); RenderManager.drawText(vg, options[selected], x + 364, y + 16, Colors.WHITE_80, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, atomColor.getColor(hovered, false), 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); @@ -87,11 +87,11 @@ public class ConfigDropdown extends BasicOption { } catch (IllegalAccessException ignored) { } - if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); + if (hovered && Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); if (size == 1) { - RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor.getColor(hovered, hovered && Mouse.isButtonDown(0)), 12); + RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor.getColor(hovered, hovered && Platform.getMousePlatform().isButtonDown(0)), 12); RenderManager.drawText(vg, options[selected], x + 236, y + 16, Colors.WHITE_80, 14f, Fonts.MEDIUM); - if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); + if (hovered && Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, atomColor.getColor(hovered, false), 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 452, y + 4, 24, 24); @@ -102,7 +102,7 @@ public class ConfigDropdown extends BasicOption { for (String option : options) { int color = Colors.WHITE_80; boolean optionHovered = InputUtils.isAreaHovered(x + 224, optionY, 252, 32, true); - if (optionHovered && Mouse.isButtonDown(0)) { + if (optionHovered && Platform.getMousePlatform().isButtonDown(0)) { RenderManager.drawRoundedRect(vg, x + 228, optionY + 2, 248, 28, Colors.PRIMARY_700_80, 8); } else if (optionHovered) { RenderManager.drawRoundedRect(vg, x + 228, optionY + 2, 248, 28, Colors.PRIMARY_700, 8); @@ -122,9 +122,9 @@ public class ConfigDropdown extends BasicOption { optionY += 32; } } else { - RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor.getColor(hovered, hovered && Mouse.isButtonDown(0)), 12); + RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor.getColor(hovered, hovered && Platform.getMousePlatform().isButtonDown(0)), 12); RenderManager.drawText(vg, options[selected], x + 364, y + 16, Colors.WHITE_80, 14f, Fonts.MEDIUM); - if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); + if (hovered && Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, atomColor.getColor(hovered, false), 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); @@ -135,7 +135,7 @@ public class ConfigDropdown extends BasicOption { for (String option : options) { int color = Colors.WHITE_80; boolean optionHovered = InputUtils.isAreaHovered(x + 352, optionY, 640, 36, true); - if (optionHovered && Mouse.isButtonDown(0)) { + if (optionHovered && Platform.getMousePlatform().isButtonDown(0)) { RenderManager.drawRoundedRect(vg, x + 356, optionY + 2, 632, 28, Colors.PRIMARY_700_80, 8); } else if (optionHovered) { RenderManager.drawRoundedRect(vg, x + 356, optionY + 2, 632, 28, Colors.PRIMARY_700, 8); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java index b85d113..ece2888 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java @@ -6,12 +6,12 @@ import cc.polyfrost.oneconfig.config.elements.BasicOption; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; +import cc.polyfrost.oneconfig.platform.Platform; 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.InputUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import org.lwjgl.input.Mouse; import java.lang.reflect.Field; @@ -34,7 +34,7 @@ public class ConfigPageButton extends BasicOption { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); - RenderManager.drawRoundedRect(vg, x - 16, y, 1024, height, backgroundColor.getColor(hovered, hovered && Mouse.isButtonDown(0)), 20); + RenderManager.drawRoundedRect(vg, x - 16, y, 1024, height, backgroundColor.getColor(hovered, hovered && Platform.getMousePlatform().isButtonDown(0)), 20); RenderManager.drawText(vg, name, x + 10, y + 32, Colors.WHITE_90, 24, Fonts.MEDIUM); if (!description.equals("")) RenderManager.drawText(vg, name, x + 10, y + 70, Colors.WHITE_90, 14, Fonts.MEDIUM); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java index bd02d21..da10756 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java @@ -4,11 +4,11 @@ import cc.polyfrost.oneconfig.config.annotations.Slider; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.config.elements.BasicOption; import cc.polyfrost.oneconfig.gui.elements.text.NumberInputField; +import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; -import org.lwjgl.input.Mouse; import java.lang.reflect.Field; @@ -40,7 +40,7 @@ public class ConfigSlider extends BasicOption { boolean hovered = InputUtils.isAreaHovered(x + 352, y, 512, 32) && isEnabled(); inputField.disable(!isEnabled()); if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); - boolean isMouseDown = Mouse.isButtonDown(0); + boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0); if (hovered && isMouseDown && !mouseWasDown) dragging = true; mouseWasDown = isMouseDown; if (dragging) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java index 68e5be3..4b0c117 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java @@ -7,11 +7,11 @@ import cc.polyfrost.oneconfig.gui.animations.Animation; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad; +import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; -import org.lwjgl.input.Mouse; import java.lang.reflect.Field; @@ -43,7 +43,7 @@ public class ConfigSwitch extends BasicOption { int x2 = x + 3 + (int) (percentOn * 18); boolean hovered = InputUtils.isAreaHovered(x, y, 42, 32); if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); - RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, color.getColor(hovered, hovered && Mouse.isButtonDown(0)), 12f); + RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, color.getColor(hovered, hovered && Platform.getMousePlatform().isButtonDown(0)), 12f); RenderManager.drawRoundedRect(vg, x2, y + 7, 18, 18, Colors.WHITE, 9f); RenderManager.drawText(vg, name, x + 50, y + 17, Colors.WHITE, 14f, Fonts.MEDIUM); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java index 81de9ba..3d9602b 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java @@ -4,11 +4,11 @@ import cc.polyfrost.oneconfig.config.annotations.Text; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.config.elements.BasicOption; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; +import cc.polyfrost.oneconfig.platform.Platform; 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.InputUtils; -import org.lwjgl.input.Mouse; import java.lang.reflect.Field; @@ -50,7 +50,7 @@ public class ConfigTextBox extends BasicOption { boolean hovered = InputUtils.isAreaHovered(x + 967, y + 7, 18, 18) && isEnabled(); int color = hovered ? Colors.WHITE : Colors.WHITE_80; if (hovered && InputUtils.isClicked()) textField.setPassword(!textField.getPassword()); - if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.5f); + if (hovered && Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.5f); RenderManager.drawSvg(vg, icon, x + 967, y + 7, 18, 18, color); } RenderManager.setAlpha(vg, 1f); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java index c164eb6..40463df 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java @@ -4,6 +4,7 @@ import cc.polyfrost.oneconfig.gui.elements.BasicElement; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.libs.universal.UKeyboard; +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; @@ -13,8 +14,6 @@ import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; import cc.polyfrost.oneconfig.utils.TextUtils; import org.jetbrains.annotations.NotNull; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import java.util.ArrayList; import java.util.Objects; @@ -112,7 +111,7 @@ public class TextInputField extends BasicElement { } Scissor scissor = ScissorManager.scissor(vg, x, y, width, height); super.update(x, y); - if (Mouse.isButtonDown(0) && !InputUtils.isAreaHovered(x - 40, y - 20, width + 90, height + 20)) { + if (Platform.getMousePlatform().isButtonDown(0) && !InputUtils.isAreaHovered(x - 40, y - 20, width + 90, height + 20)) { onClose(); toggled = false; } @@ -144,9 +143,9 @@ public class TextInputField extends BasicElement { width = RenderManager.getTextWidth(vg, s.substring(0, caretPos), 14f, Fonts.REGULAR.font); } if (hovered) { - while (Mouse.next()) { - if (Mouse.getEventButtonState()) { - if (Mouse.getEventButton() == 0) { + while (Platform.getMousePlatform().next()) { + if (Platform.getMousePlatform().getEventButtonState()) { + if (Platform.getMousePlatform().getEventButton() == 0) { if (multiLine) { int caretLine = Math.max(0, Math.min(wrappedText.size() - 1, (int) Math.floor((InputUtils.mouseY() - y - 10) / 24f))); caretPos = calculatePos(InputUtils.mouseX(), wrappedText.get(caretLine)); @@ -158,7 +157,7 @@ public class TextInputField extends BasicElement { clickTimeD1 = System.currentTimeMillis(); } } else { - if (Mouse.getEventButton() == 0) { + if (Platform.getMousePlatform().getEventButton() == 0) { long clickTimeU = System.currentTimeMillis(); if (clickTimeU - clickTimeD1 < 200) { if (!isDoubleClick) { @@ -188,7 +187,7 @@ public class TextInputField extends BasicElement { } } if (hovered) { - if (Mouse.isButtonDown(0) && !isDoubleClick) { + if (Platform.getMousePlatform().isButtonDown(0) && !isDoubleClick) { if (multiLine) { int caretLine = Math.max(0, Math.min(wrappedText.size() - 1, (int) Math.floor((InputUtils.mouseY() - y - 10) / 24f))); caretPos = calculatePos(InputUtils.mouseX(), wrappedText.get(caretLine)); @@ -265,7 +264,7 @@ public class TextInputField extends BasicElement { } return; } - if (UKeyboard.isKeyComboCtrlV(key) || key == Keyboard.KEY_INSERT) { // TODO: find the UKeyboard equivalent for insert + if (UKeyboard.isKeyComboCtrlV(key) || key == 0xD2) { // TODO: is this the same in LWJGL 3? try { String clip = IOUtils.getStringFromClipboard(); input = input.substring(0, caretPos) + clip + input.substring(caretPos); 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 b55f851..ddf6a3f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -4,12 +4,12 @@ import cc.polyfrost.oneconfig.gui.animations.Animation; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.gui.animations.EaseOutQuad; import cc.polyfrost.oneconfig.internal.assets.Colors; +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.color.ColorPalette; -import org.lwjgl.input.Mouse; import java.util.ArrayList; @@ -52,7 +52,7 @@ public abstract class Page { 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); - int dWheel = Mouse.getDWheel(); + int dWheel = Platform.getMousePlatform().getDWheel(); if (dWheel != 0) { scrollTarget += dWheel; @@ -77,10 +77,10 @@ public abstract class Page { InputUtils.stopBlock(inputScissor); if (!(scrollBarLength > 727f)) { final float scrollBarY = (scroll / maxScroll) * 720f; - final boolean isMouseDown = Mouse.isButtonDown(0); + final boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0); final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength); final boolean scrollTimePeriod = (System.currentTimeMillis() - scrollTime < 1000); - final boolean hovered = (scrollHover || scrollTimePeriod) && Mouse.isButtonDown(0); + final boolean hovered = (scrollHover || scrollTimePeriod) && Platform.getMousePlatform().isButtonDown(0); if (scrollHover && isMouseDown && !mouseWasDown) { yStart = InputUtils.mouseY(); dragging = true; |