aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java274
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java10
5 files changed, 178 insertions, 122 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java b/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java
index 8135ac0..dbec72a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java
@@ -211,7 +211,14 @@ public final class OneColor {
* Return the color as if it had maximum saturation and brightness. Internal method.
*/
public int getRGBMax(boolean maxBrightness) {
- return HSBAtoRGBA(hsba[0], 100, maxBrightness ? 100 : hsba[2], 255);
+ if (dataBit == 0) dataBit = -1;
+ if (dataBit == -1) {
+ return HSBAtoRGBA(this.hsba[0], 100, maxBrightness ? 100 : 0, this.hsba[3]);
+ } else {
+ int temp = Color.HSBtoRGB(System.currentTimeMillis() % dataBit / (float) dataBit, 1, maxBrightness ? 1 : 0);
+ hsba[0] = (short) ((System.currentTimeMillis() % dataBit / (float) dataBit) * 360);
+ return ((temp & 0x00ffffff) | (hsba[3] << 24));
+ }
}
/**
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 6c8845c..db97d5f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
@@ -9,6 +9,8 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.lwjgl.image.SVGs;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import cc.polyfrost.oneconfig.utils.ColorUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.MathUtils;
@@ -39,14 +41,16 @@ public class ColorSelector {
private final NumberInputField saturationInput = new NumberInputField(90, 32, 100, 0, 100, 1);
private final NumberInputField brightnessInput = new NumberInputField(90, 32, 100, 0, 100, 1);
private final NumberInputField alphaInput = new NumberInputField(90, 32, 0, 0, 100, 1);
+ private final NumberInputField speedInput = new NumberInputField(90, 32, 2, 1, 30, 1);
private final TextInputField hexInput = new TextInputField(88, 32, true, "");
private final ArrayList<ColorBox> favoriteColors = new ArrayList<>();
private final ArrayList<ColorBox> recentColors = new ArrayList<>();
private final ColorSlider topSlider = new ColorSlider(384, 0, 360, 127);
- private final ColorSlider bottomSlider = new ColorSlider(384, 0, 100, 100);
- private final Slider speedSlider = new Slider(296, 1, 30, 20);
- private int mode = 0;
+ private final ColorSlider bottomSlider = new ColorSlider(384, 0, 255, 100);
+ private final Slider speedSlider = new Slider(296, 1, 32, 0);
+ private int mode = 0, prevMode = 0;
+ private float percentMoveMain = 1f;
private boolean dragging, mouseWasDown;
@@ -61,8 +65,8 @@ public class ColorSelector {
alphaInput.setCurrentValue(color.getAlpha() / 255f * 100f);
speedSlider.setValue(color.getDataBit());
topSlider.setValue(color.getHue());
- topSlider.setColor(color);
- bottomSlider.setValue(color.getAlpha() / 255f * 100f);
+ topSlider.setColor(color.getRGBMax(true));
+ bottomSlider.setValue(color.getAlpha());
hexInput.setInput(color.getHex());
this.x = mouseX - 208;
this.y = Math.max(0, mouseY - 776);
@@ -93,16 +97,10 @@ public class ColorSelector {
public void draw(long vg) {
InputUtils.blockClicks(false);
- if (InputUtils.isAreaHovered(x, y, 368, 64) && Mouse.isButtonDown(0) && !dragging) {
- int dx = Mouse.getDX();
- int dy = Mouse.getDY();
- x += dx;
- mouseX += dx;
- y -= dy;
- mouseY -= dy;
- }
+ doDrag();
int width = 416;
int height = 768;
+ Scissor scissor = ScissorManager.scissor(vg, x - 3, y - 3, width + 6, height + 6);
RenderManager.drawHollowRoundRect(vg, x - 3, y - 3, width + 4, height + 4, new Color(204, 204, 204, 77).getRGB(), 20f, 2f);
RenderManager.drawRoundedRect(vg, x, y, width, height, OneConfigConfig.GRAY_800, 20f);
RenderManager.drawText(vg, "Color Selector", x + 16, y + 32, OneConfigConfig.WHITE_90, 18f, Fonts.SEMIBOLD);
@@ -112,29 +110,8 @@ public class ColorSelector {
RenderManager.setAlpha(vg, 1f);
// hex parser
- if (copyBtn.isClicked()) {
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(color.getHex()), null);
- }
- if (pasteBtn.isClicked() && mode != 2) {
- try {
- color.setColorFromHex(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor).toString());
- hexInput.setInput("#" + color.getHex());
- } catch (Exception ignored) {
- }
- }
- hexInput.setErrored(false);
- if ((hexInput.isToggled() || pasteBtn.isClicked()) && mode != 2) {
- try {
- color.setColorFromHex(hexInput.getInput());
- } catch (Exception e) {
- hexInput.setErrored(true);
- e.printStackTrace();
- }
- saturationInput.setInput(String.format("%.01f", (float) color.getSaturation()));
- brightnessInput.setInput(String.format("%.01f", (float) color.getBrightness()));
- alphaInput.setInput(String.format("%.01f", color.getAlpha() / 255f * 100f));
- if (mode == 0) topSlider.setValue(color.getHue());
- if (mode == 1) bottomSlider.setValue(color.getBrightness() / 100f * 360f);
+ if(hexInput.isToggled()) {
+ parseHex();
}
// TODO favorite stuff
@@ -153,24 +130,19 @@ public class ColorSelector {
for (BasicElement button : buttons) {
button.draw(vg, x + i, y + 66);
if (button.isClicked()) {
+ prevMode = mode;
mode = buttons.indexOf(button);
- 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);
- 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);
- }
+ setXYFromColor();
+ percentMoveMain = 0f;
}
if (percentMove != mode) {
button.currentColor = OneConfigConfig.TRANSPARENT;
+ drawColorSelector(vg, prevMode, (int) (x + (width * percentMoveMain)), y);
}
i += 128;
}
percentMove = MathUtils.easeOut(percentMove, mode, 100f);
+ percentMoveMain = MathUtils.clamp(MathUtils.easeOut(percentMoveMain, 1f, 100f));
RenderManager.drawText(vg, "HSB Box", x + 55, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM);
RenderManager.drawText(vg, "Color Wheel", x + 172.5f, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM);
@@ -187,16 +159,50 @@ public class ColorSelector {
copyBtn.draw(vg, x + 204, y + 624);
pasteBtn.draw(vg, x + 244, y + 624);
-
+ if(mode != 2) {
+ RenderManager.drawText(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
+ hueInput.draw(vg, x + 104, y + 544);
+ } else {
+ RenderManager.drawText(vg, "Speed (s)", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
+ speedInput.draw(vg, x + 104, y + 544);
+ }
guideBtn.draw(vg, x + 288, y + 624);
- boolean isMouseDown = Mouse.isButtonDown(0);
- boolean hovered = Mouse.isButtonDown(0) && InputUtils.isAreaHovered(x + 16, y + 120, 384, 288);
- if (hovered && isMouseDown && !mouseWasDown) dragging = true;
- mouseWasDown = isMouseDown;
+ setColorFromXY();
if (mode != 2) color.setChromaSpeed(-1);
+ drawColorSelector(vg, mode, (int) (x * percentMoveMain), y);
+ if (dragging && InputUtils.isClicked(true)) {
+ dragging = false;
+ }
+ bottomSlider.setGradient(OneConfigConfig.TRANSPARENT, color.getRGBNoAlpha());
+ RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x + 16, y + 456, 384, 16, 8f);
+ bottomSlider.draw(vg, x + 16, y + 456);
+
+ if(percentMoveMain > 0.96f) {
+ RenderManager.drawRoundedRect(vg, mouseX - 7, mouseY - 7, 14, 14, OneConfigConfig.WHITE, 14f);
+ RenderManager.drawRoundedRect(vg, mouseX - 6, mouseY - 6, 12, 12, OneConfigConfig.BLACK, 12f);
+ RenderManager.drawRoundedRect(vg, mouseX - 5, mouseY - 5, 10, 10, color.getRGBMax(true), 10f);
+ }
+
+ // deal with the input fields
+ parseInputFields();
+ if (guideBtn.isClicked()) NetworkUtils.browseLink("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
+
+
+ // draw the color preview
+ RenderManager.drawHollowRoundRect(vg, x + 15, y + 487, 384, 40, OneConfigConfig.GRAY_300, 12f, 2f);
+ RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x + 20, y + 492, 376, 32, 8f);
+ RenderManager.drawRoundedRect(vg, x + 20, y + 492, 376, 32, color.getRGB(), 8f);
+ InputUtils.blockClicks(true);
+ if (closeBtn.isClicked()) {
+ OneConfigGui.INSTANCE.closeColorSelector();
+ }
+ ScissorManager.resetScissor(vg, scissor);
+ }
+
+ private void drawColorSelector(long vg, int mode, int x, int y) {
switch (mode) {
default:
case 0:
@@ -204,6 +210,48 @@ public class ColorSelector {
buttons.get(mode).currentColor = OneConfigConfig.TRANSPARENT;
topSlider.setImage(Images.HUE_GRADIENT);
RenderManager.drawHSBBox(vg, x + 16, y + 120, 384, 288, color.getRGBMax(true));
+
+ if (mode == 0) {
+ topSlider.setColor(color.getRGBMax(true));
+ topSlider.draw(vg, x + 16, y + 424);
+ }
+ if (mode == 2) {
+ speedSlider.draw(vg, x + 60, y + 424);
+ RenderManager.drawText(vg, "SLOW", x + 16, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR);
+ RenderManager.drawText(vg, "FAST", x + 370, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR);
+ }
+ break;
+ case 1:
+ buttons.get(1).currentColor = OneConfigConfig.TRANSPARENT;
+ topSlider.setImage(null);
+ RenderManager.drawRoundImage(vg, Images.COLOR_WHEEL, x + 64, y + 120, 288, 288, 144f);
+
+ topSlider.setGradient(OneConfigConfig.BLACK, color.getRGBMax(true));
+ topSlider.setImage(null);
+ topSlider.draw(vg, x + 16, y + 424);
+ break;
+ }
+ }
+
+ private void doDrag() {
+ if (InputUtils.isAreaHovered(x, y, 368, 64) && Mouse.isButtonDown(0) && !dragging) {
+ int dx = Mouse.getDX();
+ int dy = Mouse.getDY();
+ x += dx;
+ mouseX += dx;
+ y -= dy;
+ mouseY -= dy;
+ }
+ }
+
+ private void setColorFromXY() {
+ boolean isMouseDown = Mouse.isButtonDown(0);
+ boolean hovered = Mouse.isButtonDown(0) && InputUtils.isAreaHovered(x + 16, y + 120, 384, 288);
+ if (hovered && isMouseDown && !mouseWasDown) dragging = true;
+ mouseWasDown = isMouseDown;
+ switch (mode) {
+ case 0:
+ case 2:
if (dragging) {
mouseX = InputUtils.mouseX();
mouseY = InputUtils.mouseY();
@@ -214,28 +262,17 @@ public class ColorSelector {
if (mouseY > y + 408) mouseY = y + 408;
float progressX = (mouseX - x - 16f) / 384f;
float progressY = Math.abs((mouseY - y - 120f) / 288f - 1f);
- color.setHSBA((int) topSlider.getValue(), Math.round(progressX * 100), Math.round(progressY * 100), (int) ((bottomSlider.getValue() / 100f) * 255));
- if (mode == 0) {
- topSlider.setColor(color);
- topSlider.draw(vg, x + 16, y + 424);
- RenderManager.drawText(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
- hueInput.draw(vg, x + 104, y + 544);
- }
- if (mode == 2) {
- speedSlider.draw(vg, x + 60, y + 424);
- RenderManager.drawText(vg, "SLOW", x + 16, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR);
- RenderManager.drawText(vg, "FAST", x + 370, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR);
- RenderManager.drawText(vg, "Speed (s)", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
- hueInput.draw(vg, x + 104, y + 544);
+ color.setHSBA((int) topSlider.getValue(), Math.round(progressX * 100), Math.round(progressY * 100), (int) bottomSlider.getValue());
+ if(mode == 2) {
if (!speedSlider.isDragging()) {
- color.setChromaSpeed((int) Math.abs(speedSlider.getValue() - 29));
+ if(!speedInput.isToggled()) {
+ color.setChromaSpeed((int) Math.abs(speedSlider.getValue() - 31));
+ speedInput.setCurrentValue(color.getDataBit());
+ }
}
}
break;
case 1:
- buttons.get(1).currentColor = OneConfigConfig.TRANSPARENT;
- topSlider.setImage(null);
- RenderManager.drawRoundImage(vg, Images.COLOR_WHEEL, x + 64, y + 120, 288, 288, 144f);
int circleCenterX = x + 208;
int circleCenterY = y + 264;
double squareDist = Math.pow((circleCenterX - InputUtils.mouseX()), 2) + Math.pow((circleCenterY - InputUtils.mouseY()), 2);
@@ -259,75 +296,81 @@ public class ColorSelector {
mouseY = InputUtils.mouseY();
}
}
- color.setHSBA(dragging ? angle : color.getHue(), saturation, (int) (topSlider.getValue() / 360 * 100), (int) ((bottomSlider.getValue() / 100f) * 255));
- topSlider.setGradient(OneConfigConfig.BLACK, color.getRGBMax(true));
- topSlider.setImage(null);
- RenderManager.drawText(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
- hueInput.draw(vg, x + 104, y + 544);
- topSlider.draw(vg, x + 16, y + 424);
+ color.setHSBA(dragging ? angle : color.getHue(), saturation, (int) (topSlider.getValue() / 360 * 100), (int) bottomSlider.getValue());
break;
}
- if (dragging && InputUtils.isClicked(true)) {
- dragging = false;
- }
- bottomSlider.setGradient(OneConfigConfig.TRANSPARENT, color.getRGBNoAlpha());
- RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x + 16, y + 456, 384, 16, 8f);
- bottomSlider.draw(vg, x + 16, y + 456);
+ }
- RenderManager.drawRoundedRect(vg, mouseX - 7, mouseY - 7, 14, 14, OneConfigConfig.WHITE, 14f);
- RenderManager.drawRoundedRect(vg, mouseX - 6, mouseY - 6, 12, 12, OneConfigConfig.BLACK, 12f);
- RenderManager.drawRoundedRect(vg, mouseX - 5, mouseY - 5, 10, 10, color.getRGBNoAlpha(), 10f);
+ 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);
+ 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);
+ }
+ }
- // deal with the input fields
- if (hueInput.isToggled() || saturationInput.isToggled() || brightnessInput.isToggled() || alphaInput.isToggled() || hueInput.arrowsClicked() || saturationInput.arrowsClicked() || brightnessInput.arrowsClicked() || alphaInput.arrowsClicked() || hexInput.isToggled() || pasteBtn.isClicked()) {
+ private void parseInputFields() {
+ if (hueInput.isToggled() || saturationInput.isToggled() || brightnessInput.isToggled() || alphaInput.isToggled() || hueInput.arrowsClicked() || saturationInput.arrowsClicked() || brightnessInput.arrowsClicked() || alphaInput.arrowsClicked() || hexInput.isToggled() || pasteBtn.isClicked() || speedInput.isToggled()) {
if (mode != 2 && !hexInput.isToggled()) {
color.setHSBA((int) hueInput.getCurrentValue(), (int) saturationInput.getCurrentValue(), (int) brightnessInput.getCurrentValue(), (int) ((alphaInput.getCurrentValue() / 100f) * 255f));
}
if (mode == 2) {
color.setHSBA(color.getHue(), (int) saturationInput.getCurrentValue(), (int) brightnessInput.getCurrentValue(), (int) ((alphaInput.getCurrentValue() / 100f) * 255f));
- color.setChromaSpeed((int) (hueInput.getCurrentValue() / 360f * 30f));
- speedSlider.setValue(hueInput.getCurrentValue() / 360f * 30f);
- }
- bottomSlider.setValue(color.getAlpha() / 255f * 100f);
- if (mode == 0 || mode == 2) {
- mouseX = (int) (saturationInput.getCurrentValue() / 100f * 384 + x + 16);
- mouseY = (int) (Math.abs(brightnessInput.getCurrentValue() / 100f - 1f) * 288 + y + 120);
- } else {
- topSlider.setValue(color.getBrightness() / 100f * 360f);
- 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);
- }
- if (mode == 0) {
- topSlider.setValue(color.getHue());
+ color.setChromaSpeed((int) speedInput.getCurrentValue());
}
+ setXYFromColor();
} else if (OneConfigGui.INSTANCE.mouseDown) {
saturationInput.setInput(String.format("%.01f", (float) color.getSaturation()));
brightnessInput.setInput(String.format("%.01f", (float) color.getBrightness()));
- alphaInput.setInput(String.format("%.01f", color.getAlpha() / 255f * 100f));
+ if(!alphaInput.arrowsClicked()) {
+ alphaInput.setInput(String.format("%.01f", color.getAlpha() / 255f * 100f));
+ }
if (hexInput.isToggled()) return;
if (mode != 2) {
hueInput.setInput(String.format("%.01f", (float) color.getHue()));
hexInput.setInput("#" + color.getHex());
} else {
- hueInput.setInput(String.format("%.01f", (float) color.getDataBit()));
+ speedInput.setInput(String.format("%.01f", (float) color.getDataBit()));
hexInput.setInput("Z" + color.getDataBit());
}
}
if (mode != 2 && !hexInput.isToggled()) {
- hueInput.setInput(String.format("%.01f", (float) color.getHue()));
hexInput.setInput("#" + color.getHex());
}
- if (guideBtn.isClicked()) NetworkUtils.browseLink("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
-
+ }
- // draw the color preview
- RenderManager.drawHollowRoundRect(vg, x + 15, y + 487, 384, 40, OneConfigConfig.GRAY_300, 12f, 2f);
- RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x + 20, y + 492, 376, 32, 8f);
- RenderManager.drawRoundedRect(vg, x + 20, y + 492, 376, 32, color.getRGB(), 8f);
- InputUtils.blockClicks(true);
- if (closeBtn.isClicked()) {
- OneConfigGui.INSTANCE.closeColorSelector();
+ private void parseHex() {
+ if (copyBtn.isClicked()) {
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(color.getHex()), null);
+ }
+ if (pasteBtn.isClicked() && mode != 2) {
+ try {
+ color.setColorFromHex(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor).toString());
+ hexInput.setInput("#" + color.getHex());
+ } catch (Exception ignored) {
+ }
+ }
+ hexInput.setErrored(false);
+ if ((hexInput.isToggled() || pasteBtn.isClicked()) && mode != 2) {
+ try {
+ color.setColorFromHex(hexInput.getInput());
+ } catch (Exception e) {
+ hexInput.setErrored(true);
+ e.printStackTrace();
+ }
+ saturationInput.setInput(String.format("%.01f", (float) color.getSaturation()));
+ brightnessInput.setInput(String.format("%.01f", (float) color.getBrightness()));
+ alphaInput.setInput(String.format("%.01f", color.getAlpha() / 255f * 100f));
+ hueInput.setInput(String.format("%.01f", (float) color.getHue()));
+ if (mode == 0) topSlider.setValue(color.getHue());
+ if (mode == 1) topSlider.setValue(color.getBrightness() / 100f * 360f);
}
}
@@ -341,6 +384,7 @@ public class ColorSelector {
brightnessInput.keyTyped(typedChar, keyCode);
alphaInput.keyTyped(typedChar, keyCode);
hueInput.keyTyped(typedChar, keyCode);
+ speedInput.keyTyped(typedChar, keyCode);
}
public void onClose() {
@@ -368,7 +412,7 @@ public class ColorSelector {
private static class ColorSlider extends Slider {
protected int gradColorStart, gradColorEnd;
protected Images image;
- protected OneColor color;
+ protected int color;
public ColorSlider(int length, float min, float max, float startValue) {
super(length, min, max, startValue);
@@ -389,9 +433,7 @@ public class ColorSelector {
RenderManager.drawHollowRoundRect(vg, x - 0.5f, y - 0.5f, width, height, new Color(204, 204, 204, 80).getRGB(), 8f, 1f);
RenderManager.drawHollowRoundRect(vg, currentDragPoint - 1, y - 1, 18, 18, OneConfigConfig.WHITE, 9f, 1f);
RenderManager.drawHollowRoundRect(vg, currentDragPoint, y, 16, 16, OneConfigConfig.BLACK, 8f, 1f);
- if (color != null) {
- RenderManager.drawRoundedRect(vg, currentDragPoint + 1.5f, y + 1.5f, 14, 14, color.getRGBMax(true), 7f);
- }
+ RenderManager.drawRoundedRect(vg, currentDragPoint + 1.5f, y + 1.5f, 14, 14, color, 7f);
}
public void setGradient(int start, int end) {
@@ -399,7 +441,7 @@ public class ColorSelector {
gradColorEnd = end;
}
- public void setColor(OneColor color) {
+ public void setColor(int color) {
this.color = color;
}
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 f7e0f90..0f1a2bb 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
@@ -54,7 +54,7 @@ public class ConfigCheckbox extends BasicOption {
RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, OneConfigConfig.PRIMARY_500, 6f);
RenderManager.drawSvg(vg, SVGs.CHECKBOX_TICK, x, y + 4, 24, 24);
}
- if (percentOn != 0 && hover)
+ if (toggled && hover)
RenderManager.drawHollowRoundRect(vg, x - 1, y + 3, 24, 24, OneConfigConfig.PRIMARY_600, 6f, 2f);
RenderManager.setAlpha(vg, 1f);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
index 0d420e8..d031e6a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
@@ -18,6 +18,7 @@ public class ConfigColorElement extends BasicOption {
private final TextInputField hexField = new TextInputField(104, 32, "", false, false);
private final TextInputField alphaField = new TextInputField(72, 32, "", false, false);
private final BasicElement element = new BasicElement(64, 32, false);
+ private boolean open = false;
public ConfigColorElement(Field field, Object parent, String name, int size) {
super(field, parent, name, size);
@@ -72,9 +73,11 @@ public class ConfigColorElement extends BasicOption {
RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x1 + 420, y + 4, 56, 24, 8f);
RenderManager.drawRoundedRect(vg, x1 + 420, y + 4, 56, 24, color.getRGB(), 8f);
if (element.isClicked() && !element.isToggled()) {
+ open = !open;
OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY()));
}
- if (OneConfigGui.INSTANCE != null && OneConfigGui.INSTANCE.currentColorSelector != null) {
+ if(OneConfigGui.INSTANCE.currentColorSelector == null) open = false;
+ if (OneConfigGui.INSTANCE.currentColorSelector != null && open) {
color = (OneConfigGui.INSTANCE.getColor());
}
setColor(color);
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java
index f168b8f..913ee73 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java
@@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.utils.commands.annotations.*;
import cc.polyfrost.oneconfig.utils.commands.arguments.*;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
+import net.minecraft.util.BlockPos;
import net.minecraftforge.client.ClientCommandHandler;
import java.lang.reflect.InvocationTargetException;
@@ -42,7 +43,7 @@ public class CommandManager {
* Adds a parser to the parsers map.
*
* @param parser The parser to add.
- * @param clazz The class of the parser.
+ * @param clazz The class of the parser.
*/
public void addParser(ArgumentParser<?> parser, Class<?> clazz) {
parsers.put(clazz, parser);
@@ -50,6 +51,7 @@ public class CommandManager {
/**
* Adds a parser to the parsers map.
+ *
* @param parser The parser to add.
*/
public void addParser(ArgumentParser<?> parser) {
@@ -93,7 +95,8 @@ public class CommandManager {
if (!root.invokers.isEmpty()) {
try {
root.invokers.stream().findFirst().get().method.invoke(null);
- } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException | ExceptionInInitializerError e) {
+ } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException |
+ ExceptionInInitializerError e) {
UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
}
}
@@ -224,7 +227,8 @@ public class CommandManager {
}
invoker.method.invoke(null, params.toArray());
return null;
- } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException | ExceptionInInitializerError e) {
+ } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException |
+ ExceptionInInitializerError e) {
return ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR;
}
}