diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-21 04:04:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-20 20:04:48 +0100 |
commit | f06946c01b2c8f210b398a16610c260eca093a8b (patch) | |
tree | 22bda7a5e9b0a1e7370ff2b1e74fc7c9e4035379 /src/main/java/cc/polyfrost/oneconfig/gui | |
parent | ff2ead62333e90b61e05c8cb6a91f692fcf30805 (diff) | |
download | OneConfig-f06946c01b2c8f210b398a16610c260eca093a8b.tar.gz OneConfig-f06946c01b2c8f210b398a16610c260eca093a8b.tar.bz2 OneConfig-f06946c01b2c8f210b398a16610c260eca093a8b.zip |
HUD Improvements, 1.16 port, fix NanoVG with ARM (#52)
* egg 1
* separate Hud from background stuff
* 1984
This reverts commit 9ae517d57bbd495d30d35cb1cbfe81a03556e6bd.
* hitboxes woo!!!!!
* Revert "hitboxes woo!!!!!"
This reverts commit 405d32d17df3c83f2e79eddf0de853f7279767a6.
* padding
* allow position to go slightly off the screen
* stop using ints for ABSOLUTELY EVERYTHING, DIAMOND ...
fix vigilance compat not setting color
* start on new pos system
* some stuff
* finish new position system
* api momento
* 1.16.2 fabric port
* start on hud gui
* temp remove 1.16.2 fabric since it doesn't compile
* fix fabric build
* hud gui stuff
* apiDump
* fix fabric build 2
* so true
* selecting stuff
* scaling + other small things
* More protecting
* fix nanovg not working with macOS ARM
move OneConfig.preLaunch to OneConfigInit
* clean up OneUIScreen
make kotlin version of TestNanoVGGui
* make keybinds have runnable by default
* rollback keybind things
* merge master into hud-improvements (#55)
* Release workflow (#53)
* release workflow
* update normal version to hash
* fix
* fix naming
* fix some stuff
* fix version thing
* switch to number from hash
* Release workflow (#54)
* release workflow
* update normal version to hash
* fix
* fix naming
* fix some stuff
* fix version thing
* switch to number from hash
* Maybe epic fixo
* gotta love those Java principles
* Revert "gotta love those Java principles", wrong branch
This reverts commit 333d8b2ad8941790c13c4bfe0777fbd203d463e5.
* start on snapping
* Finish snapping
* stop including mixin by default on legacy versions
this breaks builds if the mod itself does not use mixin
* merge draw and drawExample
* fix gradle publish
* Some fixes
* Api DUmpidy
* Help subcommand impovments (#59)
* Made the overall look of the "help" subcommand better + added the ability to change the colour for the command overall + each individual SubCommand
* Made the alliases show batter + added support for to show subcommand aliasses
* mr deliverer didnt reply but whatever, added a space between command/subcommand and alliasses
Co-authored-by: pinkulu <pinkulumc@gmail.com>
* fix file not overwriting
toJavaColor
* Fix full shadow not scaling correctly
Co-authored-by: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>
Co-authored-by: nxtdaydelivery <12willettsh@gmail.com>
Co-authored-by: pinkulu <56201697+pinkulu@users.noreply.github.com>
Co-authored-by: pinkulu <pinkulumc@gmail.com>
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
12 files changed, 53 insertions, 343 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java index 44b2b5c..344f7bb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java @@ -5,5 +5,6 @@ package cc.polyfrost.oneconfig.gui; * Minecraft itself. */ public interface GuiPause { + @SuppressWarnings("unused") boolean doesGuiPauseGame(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java deleted file mode 100644 index fc90c01..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java +++ /dev/null @@ -1,292 +0,0 @@ -package cc.polyfrost.oneconfig.gui; - -import cc.polyfrost.oneconfig.hud.Hud; -import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; -import cc.polyfrost.oneconfig.internal.hud.HudCore; -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.renderer.RenderManager; -import cc.polyfrost.oneconfig.utils.gui.GuiUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.util.ArrayList; - -public class HudGui extends UScreen implements GuiPause { - private Hud editingHud; - private boolean isDragging; - private boolean isScaling; - private final boolean openOneConfigOnClose; - private int xOffset; - private int yOffset; - - public HudGui(boolean openOneConfigOnClose) { - super(); - this.openOneConfigOnClose = openOneConfigOnClose; - } - - @Override - public void initScreen(int width, int height) { - HudCore.editing = true; - UKeyboard.allowRepeatEvents(true); - super.initScreen(width, height); - } - - @Override - public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - RenderManager.drawGlRect(0, 0, UResolution.getScaledWidth(), UResolution.getScaledHeight(), new Color(80, 80, 80, 50).getRGB()); - - if (isDragging) { - setPosition(mouseX - xOffset, mouseY - yOffset, true); - } - - for (Hud hud : HudCore.huds) { - if (hud.isEnabled()) processHud(matrixStack, hud, mouseX); - } - } - - private void processHud(UMatrixStack matrixStack, Hud hud, int mouseX) { - if (hud == editingHud && isScaling) { - 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); - if (newScale > 20) - newScale = 20; - else if (newScale < 0.3) - newScale = 0.3f; - hud.scale = newScale; - - 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(UResolution.getScaledWidth()); - int y = (int) hud.getYScaled(UResolution.getScaledHeight()); - - hud.drawExampleAll(matrixStack, x, y, hud.scale, true); - int color = new Color(215, 224, 235).getRGB(); - if (editingHud == hud) { - color = new Color(43, 159, 235).getRGB(); - if (isDragging) - RenderManager.drawGlRect(x, y, width, height, new Color(108, 176, 255, 60).getRGB()); - } - int finalColor = color; - RenderManager.setupAndDraw(true, (vg) -> { - RenderManager.drawLine(vg, x - 2 / 4f, y, x + width + 2 / 4f, y, 1, finalColor); - RenderManager.drawLine(vg, x, y, x, y + height, 1, finalColor); - RenderManager.drawLine(vg, x + width, y, x + width, y + height, 1, finalColor); - RenderManager.drawLine(vg, x - 2 / 4f, y + height, x + width + 2 / 4f, y + height, 1, finalColor); - }); - - if (hud == editingHud && !isDragging) { - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawCircle(vg, x + width, y + height, 3, new Color(43, 159, 235).getRGB())); - } - } - - private void setPosition(float newX, float newY, boolean snap) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - - if (newX < 0) - newX = 0; - else if (newX + width > UResolution.getScaledWidth()) - newX = UResolution.getScaledWidth() - width; - if (newY < 0) - newY = 0; - else if (newY + height > UResolution.getScaledHeight()) - newY = UResolution.getScaledHeight() - height; - - if (snap) { - float snapX = getXSnapping(newX, false); - float snapY = getYSnapping(newY); - if (snapX != newX || snapY != newY) { - newX = snapX; - newY = snapY; - } - } - - if (newX / UResolution.getScaledWidth() <= 0.5) - editingHud.xUnscaled = newX / (double) UResolution.getScaledWidth(); - else - 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) UResolution.getScaledHeight(); - } - - private float getXSnapping(float pos, boolean rightOnly) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - ArrayList<Float> verticalLines = new ArrayList<>(); - for (Hud hud : HudCore.huds) { - if (!hud.isEnabled()) continue; - verticalLines.addAll(getXSnappingHud(hud)); - } - getSpaceSnapping(verticalLines); - verticalLines.add(UResolution.getScaledWidth() / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineX : verticalLines) { - for (float offset = 0; offset <= (rightOnly ? 0 : width); offset += width / 2f) { - if (Math.abs(lineX - pos - offset) < 5 && (Math.abs(lineX - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineX - pos); - smallestLine = lineX; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - float finalSmallestLine = smallestLine; - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, finalSmallestLine, 0, finalSmallestLine, UResolution.getScaledHeight(), 1, new Color(255, 255, 255).getRGB())); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList<Float> getXSnappingHud(Hud hud) { - 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(UResolution.getScaledWidth()); - verticalLines.add((float) hudX); - verticalLines.add((float) (hudX + hudWidth)); - return verticalLines; - } - - private float getYSnapping(float pos) { - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - ArrayList<Float> horizontalLines = new ArrayList<>(); - for (Hud hud : HudCore.huds) { - if (!hud.isEnabled()) continue; - horizontalLines.addAll(getYSnappingHud(hud)); - } - getSpaceSnapping(horizontalLines); - horizontalLines.add(UResolution.getScaledHeight() / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineY : horizontalLines) { - for (float offset = 0; offset <= height; offset += height / 2f) { - if (Math.abs(lineY - pos - offset) < 5 && (Math.abs(lineY - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineY - pos); - smallestLine = lineY; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - float finalSmallestLine = smallestLine; - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, 0, finalSmallestLine, UResolution.getScaledWidth(), finalSmallestLine, 1, new Color(255, 255, 255).getRGB())); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList<Float> getYSnappingHud(Hud hud) { - 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(UResolution.getScaledHeight()); - horizontalLines.add((float) hudY); - horizontalLines.add((float) (hudY + hudHeight)); - return horizontalLines; - } - - private void getSpaceSnapping(ArrayList<Float> lines) { - ArrayList<Float> newLines = new ArrayList<>(); - for (int i = 0; i < lines.size(); i++) { - for (int l = i + 1; l < lines.size(); l++) { - newLines.add(Math.max(lines.get(i), lines.get(l)) + Math.abs(lines.get(i) - lines.get(l))); - newLines.add(Math.min(lines.get(i), lines.get(l)) - Math.abs(lines.get(i) - lines.get(l))); - } - } - lines.addAll(newLines); - } - - @Override - public void onMouseClicked(double mouseX, double mouseY, int mouseButton) { - super.onMouseClicked(mouseX, mouseY, mouseButton); - if (mouseButton == 0) { - 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(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; - } - } - editingHud = null; - for (Hud hud : HudCore.huds) { - if (!hud.isEnabled()) continue; - if (mouseClickedHud(hud, (int) mouseX, (int) mouseY)) - break; - } - } - } - - 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(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); - yOffset = (int) (mouseY - y); - isDragging = true; - return true; - } - return false; - } - - @Override - public void onMouseReleased(double mouseX, double mouseY, int state) { - super.onMouseReleased(mouseX, mouseY, state); - isDragging = false; - isScaling = false; - } - - @Override - public void onKeyPressed(int keyCode, char typedChar, @Nullable UKeyboard.Modifiers modifiers) { - if (editingHud != null) { - 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) { - setPosition(x, y + 1, false); - } else if (keyCode == UKeyboard.KEY_LEFT) { - setPosition(x - 1, y, false); - } else if (keyCode == UKeyboard.KEY_RIGHT) { - setPosition(x + 1, y, false); - } - } - super.onKeyPressed(keyCode, typedChar, modifiers); - } - - @Override - public void onScreenClose() { - super.onScreenClose(); - HudCore.editing = false; - UKeyboard.allowRepeatEvents(false); - ConfigCore.saveAll(); - if(openOneConfigOnClose) GuiUtils.displayScreen(OneConfigGui.create()); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } -}
\ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 41d0b4f..1d40d0a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -85,13 +85,13 @@ 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); - if (Colors.ROUNDED_CORNERS) { - RenderManager.drawDropShadow(vg, x, y, 1280, 800, 32, 0, 20); - RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, Colors.GRAY_800, Colors.CORNER_RADIUS_WIN); - RenderManager.drawRoundedRect(vg, x, y, 244, 800, Colors.GRAY_800_95, Colors.CORNER_RADIUS_WIN); - RenderManager.drawRect(vg, x + 224, y, 20, 800, Colors.GRAY_800); - RenderManager.drawHollowRoundRect(vg, x - 1, y - 1, 1282, 802, 0x4DCCCCCC, 20, scale < 1 ? 1 / scale : 1); - } + + RenderManager.drawDropShadow(vg, x, y, 1280, 800, 32, 0, 20); + RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, Colors.GRAY_800, 20f); + RenderManager.drawRoundedRect(vg, x, y, 244, 800, Colors.GRAY_800_95, 20f); + RenderManager.drawRect(vg, x + 224, y, 20, 800, Colors.GRAY_800); + RenderManager.drawHollowRoundRect(vg, x - 1, y - 1, 1282, 802, 0x4DCCCCCC, 20, scale < 1 ? 1 / scale : 1); + RenderManager.drawLine(vg, x + 224, y + 72, x + 1280, y + 72, 1, Colors.GRAY_700); RenderManager.drawLine(vg, x + 224, y, x + 222, y + 800, 1, Colors.GRAY_700); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index d1b5532..ebfc8cb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -10,6 +10,7 @@ import cc.polyfrost.oneconfig.gui.pages.ModsPage; 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.internal.gui.HudGui; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.utils.color.ColorPalette; @@ -43,7 +44,7 @@ public class SideBar { buttons.get(0).setClickAction(new CreditsPage()); buttons.get(2).setClickAction(new ModsPage()); buttons.get(8).setClickAction(new ModConfigPage(Preferences.getInstance().mod.defaultPage, true)); - HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui(true))); + HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui())); CloseButton.setClickAction(GuiUtils::closeScreen); for (BasicButton button : buttons) { if (button.hasClickAction()) continue; 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 7869114..1691eca 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -16,9 +16,9 @@ public class BasicButton extends BasicElement { protected SVGs icon1, icon2; private final int alignment; private final float fontSize, cornerRadius; - private final int xSpacing, xPadding; + private final float xSpacing, xPadding; private final int iconSize; - public int x, y; + public float x, y; public static final int ALIGNMENT_LEFT = 0; public static final int ALIGNMENT_CENTER = 2; public static final int ALIGNMENT_JUSTIFIED = 3; @@ -57,7 +57,7 @@ public class BasicButton extends BasicElement { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { this.x = x; this.y = y; this.update(x, y); 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 6f203c4..ef98120 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -72,13 +72,13 @@ public class BasicElement { /** * Draw script for the element. - * <br> <b>Make sure to call {@link #update(int x, int y)} to update the elements states!</b> + * <br> <b>Make sure to call {@link #update(float, float)} 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, int x, int y) { + public void draw(long vg, float x, float y) { this.update(x, y); RenderManager.drawRoundedRect(vg, x, y, width, height, currentColor, radius); } @@ -86,7 +86,7 @@ public class BasicElement { /** * Update this element's clicked, hovered, toggled, and pressed states, invoke any necessary methods, and update the color animation. */ - public void update(int x, int y) { + public void update(float x, float y) { if (disabled) { hovered = false; pressed = false; 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 1fed640..568567d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -45,21 +45,21 @@ public class ColorSelector { private final ColorSlider topSlider = new ColorSlider(384, 0, 360, 127); private final ColorSlider bottomSlider = new ColorSlider(384, 0, 255, 100); private final Slider speedSlider = new Slider(296, 1, 32, 0); - private int x; - private int y; + private float x; + private float y; private Animation barMoveAnimation = new DummyAnimation(18); private Animation moveAnimation = new DummyAnimation(1); - private int mouseX, mouseY; + private float mouseX, mouseY; private int mode = 0; private boolean dragging, mouseWasDown; private final boolean hasAlpha; private Scissor inputScissor = null; - public ColorSelector(OneColor color, int mouseX, int mouseY) { + public ColorSelector(OneColor color, float mouseX, float mouseY) { this(color, mouseX, mouseY, true); } - public ColorSelector(OneColor color, int mouseX, int mouseY, boolean hasAlpha) { + public ColorSelector(OneColor color, float mouseX, float mouseY, boolean hasAlpha) { this.color = color; this.hasAlpha = hasAlpha; buttons.add(new BasicButton(124, 28, "HSB Box", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY)); @@ -82,12 +82,12 @@ public class ColorSelector { this.y = Math.max(0, mouseY - 776); if (color.getDataBit() != -1) mode = 2; if (mode == 0 || mode == 2) { - this.mouseX = (int) (color.getSaturation() / 100f * 384 + x + 16); - this.mouseY = (int) (Math.abs(color.getBrightness() / 100f - 1f) * 288 + y + 120); + this.mouseX = (color.getSaturation() / 100f * 384 + x + 16); + this.mouseY = (Math.abs(color.getBrightness() / 100f - 1f) * 288 + y + 120); } else { topSlider.setValue(color.getBrightness() / 100f * 360f); - this.mouseX = (int) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); - this.mouseY = (int) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); + this.mouseX = (float) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); + this.mouseY = (float) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); } //for(OneColor color1 : OneConfigConfig.recentColors) { // recentColors.add(new ColorBox(color1)); @@ -178,7 +178,7 @@ public class ColorSelector { setColorFromXY(); if (mode != 2) color.setChromaSpeed(-1); - drawColorSelector(vg, mode, (int) (x * percentMoveMain), y); + drawColorSelector(vg, mode, (x * percentMoveMain), y); if (dragging && InputUtils.isClicked(true)) { dragging = false; } @@ -209,7 +209,7 @@ public class ColorSelector { } } - private void drawColorSelector(long vg, int mode, int x, int y) { + private void drawColorSelector(long vg, int mode, float x, float y) { switch (mode) { default: case 0: @@ -242,8 +242,8 @@ public class ColorSelector { private void doDrag() { 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())); + 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; mouseX += dx; y -= dy; @@ -279,8 +279,8 @@ public class ColorSelector { } break; case 1: - int circleCenterX = x + 208; - int circleCenterY = y + 264; + float circleCenterX = x + 208; + float circleCenterY = y + 264; double squareDist = Math.pow((circleCenterX - InputUtils.mouseX()), 2) + Math.pow((circleCenterY - InputUtils.mouseY()), 2); hovered = squareDist < 144 * 144 && Platform.getMousePlatform().isButtonDown(0); isMouseDown = Platform.getMousePlatform().isButtonDown(0); @@ -293,8 +293,8 @@ public class ColorSelector { if (angle < 0) angle += 360; if ((squareDist / (144 * 144) > 1f)) { saturation = 100; - mouseX = (int) (Math.sin(Math.toRadians(-angle) + 1.5708) * 144 + x + 208); - mouseY = (int) (Math.cos(Math.toRadians(-angle) + 1.5708) * 144 + y + 264); + mouseX = (float) (Math.sin(Math.toRadians(-angle) + 1.5708) * 144 + x + 208); + mouseY = (float) (Math.cos(Math.toRadians(-angle) + 1.5708) * 144 + y + 264); } else { saturation = (int) (squareDist / (144 * 144) * 100); mouseX = InputUtils.mouseX(); @@ -309,14 +309,14 @@ public class ColorSelector { private void setXYFromColor() { bottomSlider.setValue(color.getAlpha()); if (mode == 1) { - mouseX = (int) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); - mouseY = (int) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); + mouseX = (float) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); + mouseY = (float) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); topSlider.setValue(color.getBrightness() / 100f * 360f); } if (mode == 0 || mode == 2) { topSlider.setValue(color.getHue()); - mouseX = (int) (saturationInput.getCurrentValue() / 100f * 384 + x + 16); - mouseY = (int) (Math.abs(brightnessInput.getCurrentValue() / 100f - 1f) * 288 + y + 120); + mouseX = (saturationInput.getCurrentValue() / 100f * 384 + x + 16); + mouseY = (Math.abs(brightnessInput.getCurrentValue() / 100f - 1f) * 288 + y + 120); } } @@ -429,7 +429,7 @@ public class ColorSelector { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { if (!disabled) update(x, y); else RenderManager.setAlpha(vg, 0.5f); super.dragPointerSize = 15f; @@ -469,7 +469,7 @@ public class ColorSelector { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { 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); 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 eebdba1..ffac8e3 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 @@ public class ModCard extends BasicElement { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { super.update(x, y); String cleanName = modData.name.replaceAll("ยง.", ""); Scissor scissor = ScissorManager.scissor(vg, x, y, width, height); 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 dda5621..a22064c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java @@ -21,7 +21,7 @@ public class Slider extends BasicElement { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { if(!disabled) update(x, y); else RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x, y + 2, width, height - 4, Colors.GRAY_300, 3f); @@ -32,18 +32,18 @@ public class Slider extends BasicElement { } - public void update(int x, int y) { + public void update(float x, float y) { super.update(x, y); 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; if (dragging) { - value = ((float) InputUtils.mouseX() - x) / width; + value = (InputUtils.mouseX() - x) / width; } if (dragging && InputUtils.isClicked(true)) { dragging = false; - value = ((float) InputUtils.mouseX() - x) / width; + value = (InputUtils.mouseX() - x) / width; } if (value < 0) value = 0; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java index d7e29f5..5162ecb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java @@ -27,7 +27,7 @@ public class NumberInputField extends TextInputField { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { super.errored = false; if(disabled) RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x + width + 4, y, 12, 28, Colors.GRAY_500, 6f); 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 054915c..3c2cb1c 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 @@ -26,7 +26,7 @@ public class TextInputField extends BasicElement { protected boolean password; protected int caretPos; - protected int x, y; + protected float x, y; protected float start, end; protected int startLine, endLine; protected long vg; @@ -95,7 +95,7 @@ public class TextInputField extends BasicElement { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { this.x = x; this.y = y; this.vg = vg; @@ -206,12 +206,12 @@ public class TextInputField extends BasicElement { if(disabled) RenderManager.setAlpha(vg, 0.5f); if (toggled) { if (multiLine) { - int lineY = y + 20 + getCaretLine(caretPos) * 24; + float lineY = y + 20 + getCaretLine(caretPos) * 24; RenderManager.drawLine(vg, x + width + 12, lineY - 10, x + width + 12, lineY + 10, 1, Colors.WHITE); } else if (!centered) { - RenderManager.drawLine(vg, x + width + 12, (float) y + height / 2f - 10, x + width + 12, (float) y + height / 2f + 10, 1, Colors.WHITE); + RenderManager.drawLine(vg, x + width + 12, y + height / 2f - 10, x + width + 12, y + height / 2f + 10, 1, Colors.WHITE); } else { - RenderManager.drawLine(vg, x + this.width / 2f - halfTextWidth + width, (float) y + height / 2f - 10, x + this.width / 2f - halfTextWidth + width, (float) y + height / 2f + 10, 1, Colors.WHITE); + RenderManager.drawLine(vg, x + this.width / 2f - halfTextWidth + width, y + height / 2f - 10, x + this.width / 2f - halfTextWidth + width, y + height / 2f + 10, 1, Colors.WHITE); } } @@ -228,7 +228,7 @@ public class TextInputField extends BasicElement { if (!password) { if (multiLine) { - int textY = y + 20; + float textY = y + 20; for (String line : wrappedText) { RenderManager.drawText(vg, line, x + 12, textY, color, 14f, Fonts.REGULAR); textY += 24; @@ -453,7 +453,7 @@ public class TextInputField extends BasicElement { } } - private int calculatePos(int pos, String string) { + private int calculatePos(float pos, String string) { if (centered) pos -= 12; String s1 = ""; int i; 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 028f098..5a5970a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -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 = (int) Platform.getMousePlatform().getDWheel(); + float dWheel = (float) Platform.getMousePlatform().getDWheel(); if (dWheel != 0) { scrollTarget += dWheel; |