diff options
Diffstat (limited to 'src')
8 files changed, 38 insertions, 16 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java index 98cc5ec..cea220e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java @@ -14,6 +14,8 @@ import java.lang.annotation.Target; public @interface Color { String name(); + boolean allowAlpha() default true; + int size() default 1; String category() default "General"; diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java index 2c49f08..a8fdb5e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java @@ -169,7 +169,7 @@ public class VigilanceConfig extends Config { private OneColor cachedColor = null; public CompatConfigColorElement(Field color, Vigilant parent, String name, String category, String subcategory, int size) { - super(null, parent, name, category, subcategory, size); + super(null, parent, name, category, subcategory, size, true); this.color = color; } 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..5efebdd 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,24 +20,26 @@ 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 allowAlpha; - public ConfigColorElement(Field field, Object parent, String name, String category, String subcategory, int size) { + public ConfigColorElement(Field field, Object parent, String name, String category, String subcategory, int size, boolean allowAlpha) { super(field, parent, name, category, subcategory, size); hexField.setCentered(true); alphaField.setCentered(true); alphaField.onlyAcceptNumbers(true); + this.allowAlpha = allowAlpha; } public static ConfigColorElement create(Field field, Object parent) { Color color = field.getAnnotation(Color.class); - return new ConfigColorElement(field, parent, color.name(), color.category(), color.subcategory(), color.size()); + return new ConfigColorElement(field, parent, color.name(), color.category(), color.subcategory(), color.size(), color.allowAlpha()); } @Override 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() || allowAlpha); element.disable(!isEnabled()); int x1 = size == 1 ? x : x + 512; @@ -85,7 +87,7 @@ public class ConfigColorElement extends BasicOption { 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())); + OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY(), allowAlpha)); } if (OneConfigGui.INSTANCE.currentColorSelector == null) open = false; if (OneConfigGui.INSTANCE.currentColorSelector != null && open) { 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(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java index 3397264..6b28835 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java @@ -27,9 +27,9 @@ public class HUDUtils { options.get(options.size() - 1).addDependency(() -> hud.enabled); options.add(new ConfigCheckbox(hud.getClass().getField("border"), hud, "Outline/border", category, subcategory, 1)); options.get(options.size() - 1).addDependency(() -> hud.enabled); - options.add(new ConfigColorElement(hud.getClass().getField("bgColor"), hud, "Background color:", category, subcategory, 1)); + options.add(new ConfigColorElement(hud.getClass().getField("bgColor"), hud, "Background color:", category, subcategory, 1, true)); options.get(options.size() - 1).addDependency(() -> hud.enabled); - options.add(new ConfigColorElement(hud.getClass().getField("borderColor"), hud, "Border color:", category, subcategory, 1)); + options.add(new ConfigColorElement(hud.getClass().getField("borderColor"), hud, "Border color:", category, subcategory, 1, true)); options.get(options.size() - 1).addDependency(() -> hud.enabled && hud.border); options.add(new ConfigSlider(hud.getClass().getField("cornerRadius"), hud, "Corner radius:", category, subcategory, 0, 10, 0)); options.get(options.size() - 1).addDependency(() -> hud.enabled && hud.rounded); |