aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-22 14:57:45 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-22 14:57:45 +0100
commitffcb16e4c7f0f4414c69541238178ce3a128bb74 (patch)
tree0806698ae4fecfba85146aa8e24f4cc0067ed4ef /src/main/java/cc/polyfrost/oneconfig/gui
parent89af4c9fe007e0c4d8ed8edae541b9377e12d8d0 (diff)
downloadOneConfig-ffcb16e4c7f0f4414c69541238178ce3a128bb74.tar.gz
OneConfig-ffcb16e4c7f0f4414c69541238178ce3a128bb74.tar.bz2
OneConfig-ffcb16e4c7f0f4414c69541238178ce3a128bb74.zip
color selector and loads of stuffs
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java7
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java193
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java16
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java23
8 files changed, 182 insertions, 83 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 7e12a74..3bfcc74 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -6,7 +6,7 @@ import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.gui.pages.HomePage;
import cc.polyfrost.oneconfig.gui.pages.Page;
-import cc.polyfrost.oneconfig.lwjgl.OneColor;
+import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.SVGs;
@@ -32,7 +32,7 @@ public class OneConfigGui extends UScreen {
private final BasicElement backArrow = new BasicElement(40, 40, -1, false);
private final BasicElement forwardArrow = new BasicElement(40, 40, -1, false);
private final ArrayList<Page> parents = new ArrayList<>();
- private ColorSelector currentColorSelector;
+ public ColorSelector currentColorSelector;
public boolean mouseDown;
private float scale = 1f;
private static OneConfigGui instanceToRestore = null;
@@ -229,6 +229,7 @@ public class OneConfigGui extends UScreen {
* Correct usage: <code>OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY()));</code>
*/
public void initColorSelector(ColorSelector colorSelector) {
+ InputUtils.blockClicks(true);
currentColorSelector = colorSelector;
}
@@ -242,6 +243,11 @@ public class OneConfigGui extends UScreen {
return color;
}
+ public OneColor getColor() {
+ if(currentColorSelector == null) return null;
+ return currentColorSelector.getColor();
+ }
+
public float getScaleFactor() {
return scale;
}
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 bcfebd3..887d8d2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java
@@ -16,6 +16,7 @@ public class BasicElement {
protected boolean disabled = false;
protected int currentColor;
protected final float radius;
+ private boolean block = false;
public BasicElement(int width, int height, int colorPalette, boolean hoverFx) {
this(width, height, colorPalette, hoverFx, 12f);
@@ -50,7 +51,7 @@ public class BasicElement {
return;
}
hovered = InputUtils.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY);
- clicked = InputUtils.isClicked() && hovered;
+ clicked = InputUtils.isClicked(block) && hovered;
if (clicked) {
toggled = !toggled;
@@ -58,6 +59,10 @@ public class BasicElement {
}
}
+ public void ignoreBlockedTouches(boolean state) {
+ block = state;
+ }
+
public void onClick() {
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 f32abc3..a0c094a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
@@ -1,14 +1,15 @@
package cc.polyfrost.oneconfig.gui.elements;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.text.NumberInputField;
import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
-import cc.polyfrost.oneconfig.lwjgl.OneColor;
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.utils.IOUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.MathUtils;
import org.lwjgl.input.Mouse;
@@ -19,17 +20,19 @@ import java.awt.datatransfer.StringSelection;
import java.util.ArrayList;
public class ColorSelector {
- private final int x;
- private final int y;
+ private int x;
+ private int y;
private OneColor color;
private float percentMove = 0f;
private int mouseX, mouseY;
private final ArrayList<BasicElement> buttons = new ArrayList<>();
- private final BasicElement closeBtn = new BasicElement(32, 32, true);
+ private final BasicElement closeBtn = new BasicElement(32, 32, false);
private final BasicElement copyBtn = new BasicElement(32, 32, 2, true);
private final BasicElement pasteBtn = new BasicElement(32, 32, 2, true);
private final BasicButton guideBtn = new BasicButton(112, 32, "Guide", null, null, 0, BasicButton.ALIGNMENT_CENTER);
+ private final BasicElement faveBtn = new BasicElement(32, 32, 2, true);
+ private final BasicElement recentBtn = new BasicElement(32, 32, 2, true);
private final NumberInputField hueInput = new NumberInputField(90, 32, 0, 0, 360, 1);
private final NumberInputField saturationInput = new NumberInputField(90, 32, 100, 0, 100, 1);
@@ -55,76 +58,117 @@ public class ColorSelector {
saturationInput.setCurrentValue(color.getSaturation());
brightnessInput.setCurrentValue(color.getBrightness());
alphaInput.setCurrentValue(color.getAlpha() / 255f * 100f);
- speedSlider.setValue(color.getChroma());
+ speedSlider.setValue(color.getDataBit());
topSlider.setValue(color.getHue());
topSlider.setColor(color);
bottomSlider.setValue(color.getAlpha() / 255f * 100f);
+ hexInput.setInput(color.getHex());
this.x = mouseX - 208;
this.y = Math.max(0, mouseY - 776);
- for(OneColor color1 : OneConfigConfig.recentColors) {
- recentColors.add(new ColorBox(color1));
+ 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);
+ } 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);
}
- for(OneColor color1 : OneConfigConfig.favoriteColors) {
- favoriteColors.add(new ColorBox(color1));
+ //for(OneColor color1 : OneConfigConfig.recentColors) {
+ // recentColors.add(new ColorBox(color1));
+ //}
+ //for(OneColor color1 : OneConfigConfig.favoriteColors) {
+ // favoriteColors.add(new ColorBox(color1));
+ //}
+ while (favoriteColors.size() < 7) {
+ favoriteColors.add(new ColorBox(new OneColor(0, 0, 0, 0)));
+ }
+ while (recentColors.size() < 7) {
+ recentColors.add(new ColorBox(new OneColor(0, 0, 0, 0)));
}
topSlider.setImage(Images.HUE_GRADIENT);
}
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;
+ }
int width = 416;
int height = 768;
-
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.drawString(vg, "Color Selector", x + 16, y + 32, OneConfigConfig.WHITE_90, 18f, Fonts.SEMIBOLD);
+ RenderManager.setAlpha(vg, 0.8f);
+ if (closeBtn.isHovered()) RenderManager.setAlpha(vg, 1f);
+ if (closeBtn.isClicked()) RenderManager.setAlpha(vg, 0.5f);
closeBtn.draw(vg, x + 368, y + 16);
- RenderManager.drawSvg(vg, SVGs.X_CIRCLE, x + 369, y + 17, 32, 32);
- if (closeBtn.isClicked()) {
- OneConfigGui.INSTANCE.closeColorSelector();
- }
+ RenderManager.drawSvg(vg, SVGs.X_CIRCLE, x + 368, y + 16, 32, 32);
+ RenderManager.setAlpha(vg, 1f);
// hex parser
- if(copyBtn.isClicked()) {
+ if (copyBtn.isClicked()) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(color.getHex()), null);
}
- if(pasteBtn.isClicked()) {
+ 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()) { // TODO fix this
+ 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);
}
// TODO favorite stuff
+ faveBtn.draw(vg, x + 16, y + 672);
+ RenderManager.drawSvg(vg, SVGs.HEART_OUTLINE, x + 23, y + 679, 18, 18);
+ recentBtn.draw(vg, x + 16, y + 720);
+ RenderManager.drawSvg(vg, SVGs.HISTORY, x + 23, y + 727, 18, 18);
+ for(int i = 0; i < 7; i++) {
+ favoriteColors.get(i).draw(vg, x + 104 + i * 44, y + 672);
+ }
+ for(int i = 0; i < 7; i++) {
+ recentColors.get(i).draw(vg, x + 104 + i * 44, y + 720);
+ }
RenderManager.drawRoundedRect(vg, x + 16, y + 64, 384, 32, OneConfigConfig.GRAY_500, 12f);
RenderManager.drawRoundedRect(vg, x + 18 + (percentMove * 128), y + 66, 124, 28, OneConfigConfig.PRIMARY_600, 10f);
int i = 18;
- for(BasicElement button : buttons) {
+ for (BasicElement button : buttons) {
button.draw(vg, x + i, y + 66);
- if(button.isClicked()) {
+ if (button.isClicked()) {
mode = buttons.indexOf(button);
- if(mode == 1) {
+ 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) {
+ 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);
}
}
- if(percentMove != mode) {
+ if (percentMove != mode) {
button.currentColor = OneConfigConfig.TRANSPARENT;
}
i += 128;
@@ -141,7 +185,7 @@ public class ColorSelector {
brightnessInput.draw(vg, x + 104, y + 584);
RenderManager.drawString(vg, "Alpha (%)", x + 224, y + 599, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
alphaInput.draw(vg, x + 312, y + 584);
- RenderManager.drawString(vg, color.getChroma() == -1 ? "Hex (RGB)" : "Chroma Speed", x + 16, y + 641, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
+ RenderManager.drawString(vg, color.getDataBit() == -1 ? "Hex (RGB):" : "Color Code:", x + 16, y + 641, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
hexInput.draw(vg, x + 104, y + 624);
copyBtn.draw(vg, x + 204, y + 624);
@@ -158,7 +202,7 @@ public class ColorSelector {
boolean hovered = Mouse.isButtonDown(0) && InputUtils.isAreaHovered(x + 16, y + 120, 384, 288);
if (hovered && isMouseDown && !mouseWasDown) dragging = true;
mouseWasDown = isMouseDown;
- if(mode != 2) color.setChromaSpeed(-1);
+ if (mode != 2) color.setChromaSpeed(-1);
switch (mode) {
default:
case 0:
@@ -166,30 +210,32 @@ 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(false));
- if(dragging) {
+ if (dragging) {
mouseX = InputUtils.mouseX();
mouseY = InputUtils.mouseY();
}
- if(mouseX < x + 16) mouseX = x + 16;
- if(mouseY < y + 120) mouseY = y + 120;
- if(mouseX > x + 400) mouseX = x + 400;
- if(mouseY > y + 408) mouseY = y + 408;
+ if (mouseX < x + 16) mouseX = x + 16;
+ if (mouseY < y + 120) mouseY = y + 120;
+ if (mouseX > x + 400) mouseX = x + 400;
+ 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) {
+ if (mode == 0) {
topSlider.setColor(color);
topSlider.draw(vg, x + 16, y + 424);
RenderManager.drawString(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
hueInput.draw(vg, x + 104, y + 544);
}
- if(mode == 2) {
+ if (mode == 2) {
speedSlider.draw(vg, x + 60, y + 424);
RenderManager.drawString(vg, "SLOW", x + 16, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR);
RenderManager.drawString(vg, "FAST", x + 370, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR);
RenderManager.drawString(vg, "Speed (s)", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
hueInput.draw(vg, x + 104, y + 544);
- color.setChromaSpeed((int) speedSlider.getValue());
+ if (!speedSlider.isDragging()) {
+ color.setChromaSpeed((int) Math.abs(speedSlider.getValue() - 29));
+ }
}
break;
case 1:
@@ -205,14 +251,21 @@ public class ColorSelector {
mouseWasDown = isMouseDown;
int angle = 0;
- if(dragging) {
- //if(!(squareDist / (144 * 144) > 1f)
- mouseX = InputUtils.mouseX();
- mouseY = InputUtils.mouseY();
- angle = (int) Math.toDegrees(Math.atan2(mouseY - circleCenterY, mouseX - circleCenterX));
- if(angle < 0) angle += 360;
+ int saturation = color.getSaturation();
+ if (dragging) {
+ angle = (int) Math.toDegrees(Math.atan2(InputUtils.mouseY() - circleCenterY, InputUtils.mouseX() - circleCenterX));
+ 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);
+ } else {
+ saturation = (int) (squareDist / (144 * 144) * 100);
+ mouseX = InputUtils.mouseX();
+ mouseY = InputUtils.mouseY();
+ }
}
- color.setHSBA(dragging ? angle : color.getHue(), dragging ? (int) (squareDist / (144 * 144) * 100) : color.getSaturation(), (int) (topSlider.getValue() / 360 * 100), (int) ((bottomSlider.getValue() / 100f) * 255));
+ 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.drawString(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM);
@@ -220,7 +273,7 @@ public class ColorSelector {
topSlider.draw(vg, x + 16, y + 424);
break;
}
- if(dragging && InputUtils.isClicked()) {
+ if (dragging && InputUtils.isClicked(true)) {
dragging = false;
}
bottomSlider.setGradient(OneConfigConfig.TRANSPARENT_25, color.getRGBNoAlpha());
@@ -231,17 +284,17 @@ public class ColorSelector {
RenderManager.drawRoundedRect(vg, mouseX - 5, mouseY - 5, 10, 10, color.getRGBNoAlpha(), 10f);
// deal with the input fields
- if(hueInput.isToggled() || saturationInput.isToggled() || brightnessInput.isToggled() || alphaInput.isToggled() || hueInput.arrowsClicked() || saturationInput.arrowsClicked() || brightnessInput.arrowsClicked() || alphaInput.arrowsClicked()) {
- if(mode != 2) {
+ if (hueInput.isToggled() || saturationInput.isToggled() || brightnessInput.isToggled() || alphaInput.isToggled() || hueInput.arrowsClicked() || saturationInput.arrowsClicked() || brightnessInput.arrowsClicked() || alphaInput.arrowsClicked() || hexInput.isToggled() || pasteBtn.isClicked()) {
+ if (mode != 2 && !hexInput.isToggled()) {
color.setHSBA((int) hueInput.getCurrentValue(), (int) saturationInput.getCurrentValue(), (int) brightnessInput.getCurrentValue(), (int) ((alphaInput.getCurrentValue() / 100f) * 255f));
}
- if(mode == 2) {
+ 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) {
+ 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 {
@@ -249,32 +302,38 @@ public class ColorSelector {
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) {
+ if (mode == 0) {
topSlider.setValue(color.getHue());
}
- }
- else if(OneConfigGui.INSTANCE.mouseDown) {
- if(mode != 2) {
+ } 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 (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.getChroma()));
- hexInput.setInput("Z" + color.getChroma());
+ hueInput.setInput(String.format("%.01f", (float) color.getDataBit()));
+ hexInput.setInput("Z" + color.getDataBit());
}
- 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 != 2 && !hexInput.isToggled()) {
+ if (mode != 2 && !hexInput.isToggled()) {
hueInput.setInput(String.format("%.01f", (float) color.getHue()));
hexInput.setInput("#" + color.getHex());
}
+ if(guideBtn.isClicked()) IOUtils.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.drawImage(vg, Images.ALPHA_GRID, x + 20, y + 492, 376, 32);
RenderManager.drawRoundedRect(vg, x + 20, y + 492, 376, 32, color.getRGB(), 8f);
+ InputUtils.blockClicks(true);
+ if (closeBtn.isClicked()) {
+ OneConfigGui.INSTANCE.closeColorSelector();
+ }
}
public OneColor getColor() {
@@ -290,18 +349,19 @@ public class ColorSelector {
}
public void onClose() {
- for(int i = 0; i < OneConfigConfig.recentColors.size(); i++) {
+ InputUtils.blockClicks(false);
+ /*for (int i = 0; i < OneConfigConfig.recentColors.size(); i++) {
OneColor color1 = OneConfigConfig.recentColors.get(i);
- if(color1.getRGB() == color.getRGB()) {
+ if (color1.getRGB() == color.getRGB()) {
OneConfigConfig.recentColors.get(i).setFromOneColor(color1);
return;
}
}
- OneConfigConfig.recentColors.add(color);
+ OneConfigConfig.recentColors.add(color);*/
}
public void setFavorite(int index) {
- if(index < 0 || index >= OneConfigConfig.favoriteColors.size()) {
+ if (index < 0 || index >= OneConfigConfig.favoriteColors.size()) {
return;
}
OneConfigConfig.favoriteColors.add(index, color);
@@ -325,16 +385,17 @@ public class ColorSelector {
public void draw(long vg, int x, int y) {
update(x, y);
super.dragPointerSize = 15f;
- if(image != null) {
- RenderManager.drawRoundImage(vg, image, x, y, width, height, 8f);
+ if (image != null) {
+ RenderManager.drawRoundImage(vg, image, x + 1, y + 1, width - 2, height - 2, 8f);
} else {
RenderManager.drawGradientRoundedRect(vg, x, y, width, height, gradColorStart, gradColorEnd, 8f);
}
- RenderManager.drawHollowRoundRect(vg, x - 1.5f, y - 1.5f, width + 2, height + 2, new Color(204, 204, 204, 77).getRGB(), 8f, 1f);
- RenderManager.drawHollowRoundRect(vg, currentDragPoint - 2, y - 2, 18, 18, OneConfigConfig.WHITE, 7f, 1f);
- if(color != null) {
- RenderManager.drawRoundedRect(vg, currentDragPoint, y, 15, 15, color.getRGBNoAlpha(), 7.5f);
+ 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.getRGBNoAlpha(), 7f);
}
}
@@ -354,6 +415,7 @@ public class ColorSelector {
private static class ColorBox extends BasicElement {
protected OneColor color;
+
public ColorBox(OneColor color) {
super(32, 32, false);
this.color = color;
@@ -362,8 +424,9 @@ public class ColorSelector {
@Override
public void draw(long vg, int x, int y) {
RenderManager.drawRoundedRect(vg, x, y, 32, 32, toggled ? OneConfigConfig.PRIMARY_600 : OneConfigConfig.GRAY_300, 12f);
- RenderManager.drawRoundedRect(vg, x + 2, y + 2, 28, 28, OneConfigConfig.GRAY_800, 8f);
+ RenderManager.drawRoundedRect(vg, x + 2, y + 2, 28, 28, OneConfigConfig.GRAY_800, 10f);
RenderManager.drawRoundedRect(vg, x + 4, y + 4, 24, 24, color.getRGB(), 8f);
+ update(x, y);
}
public void setColor(OneColor color) {
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 08a2823..3aab5ad 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java
@@ -39,7 +39,7 @@ public class Slider extends BasicElement {
if (dragging) {
value = ((float) InputUtils.mouseX() - x) / width;
}
- if (dragging && InputUtils.isClicked()) {
+ if (dragging && InputUtils.isClicked(true)) {
dragging = false;
value = ((float) InputUtils.mouseX() - x) / width;
}
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 7986598..2068882 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
@@ -6,7 +6,7 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
-import cc.polyfrost.oneconfig.lwjgl.OneColor;
+import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
@@ -40,10 +40,7 @@ public class ConfigColorElement extends BasicOption {
hexField.setErrored(false);
if (hexField.isToggled()) {
try {
- int alpha = color.getAlpha();
color.setColorFromHex(hexField.getInput());
- color.setAlpha(alpha);
- setColor(color);
} catch (NumberFormatException e) {
hexField.setErrored(true);
}
@@ -64,7 +61,6 @@ public class ConfigColorElement extends BasicOption {
input = 100f;
}
color = new OneColor((float) color.getHue(), color.getSaturation(), color.getBrightness(), Math.round(input * 2.55f));
- setColor(color);
} catch (NumberFormatException e) {
alphaField.setErrored(true);
}
@@ -72,12 +68,16 @@ public class ConfigColorElement extends BasicOption {
alphaField.draw(vg, x1 + 336, y);
element.update(x1 + 416, y);
- RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x1 + 416, y, 64, 32, 12f);
- RenderManager.drawRoundedRect(vg, x1 + 416, y, 64, 32, color.getRGB(), 12f);
RenderManager.drawHollowRoundRect(vg, x1 + 415, y - 1, 64, 32, OneConfigConfig.GRAY_300, 12f, 2f);
+ 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()) {
- OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(new OneColor(40, 30, 20), InputUtils.mouseX(), InputUtils.mouseY()));
+ OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY()));
}
+ if(OneConfigGui.INSTANCE.currentColorSelector != null) {
+ color = (OneConfigGui.INSTANCE.getColor());
+ }
+ setColor(color);
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
index b367934..e5b3d90 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
@@ -35,7 +35,7 @@ public class ConfigSlider extends BasicOption {
inputField.disable(!isEnabled());
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
boolean isMouseDown = Mouse.isButtonDown(0);
- if (hovered && isMouseDown && !mouseWasDown) dragging = true;
+ if (hovered && isMouseDown && !mouseWasDown && !InputUtils.isBlockingClicks()) dragging = true;
mouseWasDown = isMouseDown;
if (dragging) {
xCoordinate = (int) MathUtils.clamp(InputUtils.mouseX(), x + 352, x + 864);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
new file mode 100644
index 0000000..ec02dce
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
@@ -0,0 +1,12 @@
+package cc.polyfrost.oneconfig.gui.pages;
+
+public class CreditsPage extends Page {
+ CreditsPage() {
+ super("Credits");
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
index 91f4181..ca0fe0e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -4,16 +4,22 @@ import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
-import cc.polyfrost.oneconfig.lwjgl.OneColor;
+import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.SVGs;
+import cc.polyfrost.oneconfig.utils.IOUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
import java.awt.*;
public class HomePage extends Page {
- private final BasicButton btn = new BasicButton(184, 36, "Socials", SVGs.SHARE, SVGs.POP_OUT, 1, BasicButton.ALIGNMENT_CENTER);
+ private final BasicButton socialsBtn = new BasicButton(184, 36, "Socials", SVGs.SHARE, SVGs.POP_OUT, 1, BasicButton.ALIGNMENT_CENTER, () -> IOUtils.browseLink("https://twitter.com/polyfrost"));
+ private final BasicButton discordBtn = new BasicButton(184, 36, "Discord", SVGs.WEBSITE, SVGs.LINK_DIAGONAL, 1, BasicButton.ALIGNMENT_CENTER, () -> IOUtils.browseLink("https://discord.gg/4BdUuGpMdf"));
+ private final BasicButton webBtn = new BasicButton(184, 36, "Website", SVGs.WEBSITE, null, 1, BasicButton.ALIGNMENT_CENTER, () -> IOUtils.browseLink("https://polyfrost.cc"));
+ private final BasicButton creditsBtn = new BasicButton(184, 36, "Credits", SVGs.AUDIO_PLAY, SVGs.LINK_DIAGONAL, 0, BasicButton.ALIGNMENT_CENTER, () -> OneConfigGui.INSTANCE.openPage(new CreditsPage()));
+ private final BasicButton guideBtn = new BasicButton(184, 36, "Online Guide", SVGs.HELP_CIRCLE, null, 0, BasicButton.ALIGNMENT_CENTER, () -> IOUtils.browseLink("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
+
public HomePage() {
super("Home Dashboard");
@@ -23,9 +29,16 @@ public class HomePage extends Page {
RenderManager.drawRoundedRect(vg, x, y, 184, 36, -1, 12f);
RenderManager.drawString(vg, "This is a cool string to test pages", x + 32, y + 72, -1, 36f, Fonts.BOLD);
RenderManager.drawRoundedRect(vg, x + 350, y + 310, 300, 200, OneConfigConfig.PRIMARY_600, 14f);
- //RenderManager.drawRoundedRect(vg);
- btn.draw(vg, x + 432, y + 658);
- if(btn.isClicked()) {
+ RenderManager.drawSvg(vg, SVGs.INFO_CIRCLE, x + 20, y + 604, 24, 24);
+ RenderManager.drawString(vg, "Info", x + 52, y + 618, OneConfigConfig.WHITE_90, 24f, Fonts.MEDIUM);
+ RenderManager.drawRoundedRect(vg, x + 16, y + 644, 1024, 64, OneConfigConfig.GRAY_700, 20f);
+
+ discordBtn.draw(vg, x + 32, y + 658);
+ webBtn.draw(vg, x + 232, y + 658);
+ socialsBtn.draw(vg, x + 432, y + 658);
+ creditsBtn.draw(vg, x + 632, y + 658);
+ guideBtn.draw(vg, x + 832, y + 658);
+ if(socialsBtn.isClicked()) {
OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(new OneColor(new Color(255, 0, 255, 127)), InputUtils.mouseX(), InputUtils.mouseY()));
}
}