diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-06-11 12:52:33 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-06-11 12:52:33 +0100 |
commit | c0b24f80a50d1c5968bbda16a555e9aa94707112 (patch) | |
tree | 2c761abd0142fa1520e60b571cdd5e6f0b2c1b0c /src | |
parent | 6239cf215a789a21e702cb793706ca0fa5a4bcca (diff) | |
download | OneConfig-c0b24f80a50d1c5968bbda16a555e9aa94707112.tar.gz OneConfig-c0b24f80a50d1c5968bbda16a555e9aa94707112.tar.bz2 OneConfig-c0b24f80a50d1c5968bbda16a555e9aa94707112.zip |
color selector avec no alpha
Diffstat (limited to 'src')
5 files changed, 30 insertions, 10 deletions
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 4729684..788e882 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -51,12 +51,17 @@ public class ColorSelector { private Animation barMoveAnimation = new DummyAnimation(18); private Animation moveAnimation = new DummyAnimation(1); private int mouseX, mouseY; - private int mode = 0, prevMode = 0; + private int mode = 0; private boolean dragging, mouseWasDown; - + private final boolean hasAlpha; public ColorSelector(OneColor color, int mouseX, int mouseY) { + this(color, mouseX, mouseY, true); + } + + public ColorSelector(OneColor color, int mouseX, int mouseY, boolean hasAlpha) { this.color = color; + this.hasAlpha = hasAlpha; buttons.add(new BasicButton(124, 28, "HSB Box", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY)); buttons.add(new BasicButton(124, 28, "Color Wheel", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY)); buttons.add(new BasicButton(124, 28, "Chroma", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY)); @@ -64,6 +69,10 @@ public class ColorSelector { saturationInput.setCurrentValue(color.getSaturation()); brightnessInput.setCurrentValue(color.getBrightness()); alphaInput.setCurrentValue(color.getAlpha() / 255f * 100f); + if(!hasAlpha) { + bottomSlider.disabled = true; + alphaInput.disabled = true; + } speedSlider.setValue(color.getDataBit()); topSlider.setValue(color.getHue()); topSlider.setColor(color.getRGBMax(true)); @@ -134,7 +143,7 @@ public class ColorSelector { for (BasicElement button : buttons) { button.draw(vg, x + i, y + 66); if (button.isClicked()) { - prevMode = mode; + int prevMode = mode; mode = buttons.indexOf(button); setXYFromColor(); barMoveAnimation = new EaseInOutCubic(175, 18 + prevMode * 128, 18 + mode * 128, false); @@ -405,6 +414,9 @@ public class ColorSelector { this.favoriteColors.get(index).setToggled(true); } + public boolean isAlphaAllowed() { + return hasAlpha; + } private static class ColorSlider extends Slider { protected int gradColorStart, gradColorEnd; @@ -419,7 +431,8 @@ public class ColorSelector { @Override public void draw(long vg, int x, int y) { - update(x, y); + if(!disabled) update(x, y); + else RenderManager.setAlpha(vg, 0.5f); super.dragPointerSize = 15f; if (image != null) { RenderManager.drawRoundImage(vg, image, x + 1, y + 1, width - 2, height - 2, 8f); @@ -431,6 +444,7 @@ public class ColorSelector { RenderManager.drawHollowRoundRect(vg, currentDragPoint - 1, y - 1, 18, 18, Colors.WHITE, 9f, 1f); RenderManager.drawHollowRoundRect(vg, currentDragPoint, y, 16, 16, Colors.BLACK, 8f, 1f); RenderManager.drawRoundedRect(vg, currentDragPoint + 1.5f, y + 1.5f, 14, 14, color, 7f); + RenderManager.setAlpha(vg, 1f); } public void setGradient(int start, int end) { 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 73853a1..8c9dfb6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java @@ -22,10 +22,12 @@ public class Slider extends BasicElement { @Override public void draw(long vg, int x, int y) { - update(x, 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); RenderManager.drawRoundedRect(vg, x, y + 2, width * value, height - 4, Colors.PRIMARY_500, 3f); RenderManager.drawRoundedRect(vg, currentDragPoint - dragPointerSize / 2, y - 8, 24, 24, Colors.WHITE, 12f); + 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 5cd9c83..581babd 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 @@ -20,12 +20,14 @@ public class ConfigColorElement extends BasicOption { private final TextInputField alphaField = new TextInputField(72, 32, "", false, false); private final BasicElement element = new BasicElement(64, 32, false); private boolean open = false; + private final boolean isAlphaAllowed; public ConfigColorElement(Field field, Object parent, String name, String category, String subcategory, int size) { super(field, parent, name, category, subcategory, size); hexField.setCentered(true); alphaField.setCentered(true); alphaField.onlyAcceptNumbers(true); + isAlphaAllowed = true; } public static ConfigColorElement create(Field field, Object parent) { @@ -37,7 +39,7 @@ public class ConfigColorElement extends BasicOption { public void draw(long vg, int x, int y) { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); hexField.disable(!isEnabled()); - alphaField.disable(!isEnabled()); + alphaField.disable(!isEnabled() || isAlphaAllowed); element.disable(!isEnabled()); int x1 = size == 1 ? x : x + 512; 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 e6cf5d9..d7e29f5 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 @@ -29,6 +29,7 @@ public class NumberInputField extends TextInputField { @Override public void draw(long vg, int x, int y) { super.errored = false; + if(disabled) RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x + width + 4, y, 12, 28, Colors.GRAY_500, 6f); upArrow.disable(disabled); downArrow.disable(disabled); @@ -71,7 +72,7 @@ public class NumberInputField extends TextInputField { } RenderManager.drawRoundedRectVaried(vg, x + width + 4, y + 14, 12, 14, colorBottom.getColor(downArrow.isHovered(), downArrow.isPressed()), 0f, 0f, 6f, 6f); RenderManager.drawSvg(vg, SVGs.CHEVRON_DOWN, x + width + 5, y + 15, 10, 10); - RenderManager.setAlpha(vg, 1f); + if(!disabled) RenderManager.setAlpha(vg, 1f); try { super.draw(vg, x, y - 2); @@ -80,6 +81,7 @@ public class NumberInputField extends TextInputField { super.caretPos = 0; super.prevCaret = 0; } + if(disabled) RenderManager.setAlpha(vg, 1f); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java index c33896a..f0f1447 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 @@ -211,7 +211,7 @@ public class TextInputField extends BasicElement { } } - + if(disabled) RenderManager.setAlpha(vg, 0.5f); if (toggled) { if (multiLine) { int lineY = y + 20 + getCaretLine(caretPos) * 24; @@ -249,9 +249,9 @@ public class TextInputField extends BasicElement { } else { RenderManager.drawText(vg, s.toString(), x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR); } + RenderManager.setAlpha(vg, 1f); ScissorManager.resetScissor(vg, scissor); - } catch ( - Exception e) { + } catch (Exception e) { e.printStackTrace(); } |