aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/elements
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/elements')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java46
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java14
7 files changed, 42 insertions, 42 deletions
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;