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 | |
| 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')
41 files changed, 1083 insertions, 688 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java index 8a5608e..1b5c5e6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java @@ -24,7 +24,10 @@ import cc.polyfrost.oneconfig.utils.JsonUtils; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; import com.google.gson.*; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java index 791bc4a..7e844f0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java @@ -14,7 +14,6 @@ public class OneKeyBind { keyBinds.add(key); } } - public boolean isActive() { if (keyBinds.size() == 0) return false; for (int keyBind : keyBinds) { 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.se |
