aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-12 20:30:06 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-12 20:30:06 +0200
commitbcdb9ed93960b972d137de17ef0253d3e83deb38 (patch)
tree012bb702dcd0faf967e71c0caf1f7793949f03eb /src/main/java/cc/polyfrost/oneconfig/gui
parent2f9d500c97291cdaa09b0f3afc96551e675280fe (diff)
downloadOneConfig-bcdb9ed93960b972d137de17ef0253d3e83deb38.tar.gz
OneConfig-bcdb9ed93960b972d137de17ef0253d3e83deb38.tar.bz2
OneConfig-bcdb9ed93960b972d137de17ef0253d3e83deb38.zip
some small fixes
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java1
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java27
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java3
5 files changed, 19 insertions, 26 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index c3ecb0c..c15940d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -202,6 +202,7 @@ public class OneConfigGui extends UScreen {
public void openPage(@NotNull Page page, Animation animation, boolean addToPrevious) {
if (page == currentPage) return;
currentPage.finishUpAndClose();
+ textInputField.setInput("");
if (!page.isBase()) {
boolean alreadyInParents = false;
for (int i = 0; i < parents.size(); i++) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
index 0c62443..8734c2c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
@@ -3,8 +3,8 @@ package cc.polyfrost.oneconfig.gui.animations;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
public class ColorAnimation {
- private int speed = 100;
private ColorPalette palette;
+ private final int duration;
/**
* 0 = nothing
* 1 = hovered
@@ -17,14 +17,19 @@ public class ColorAnimation {
private Animation blueAnimation;
private Animation alphaAnimation;
- public ColorAnimation(ColorPalette palette) {
+ public ColorAnimation(ColorPalette palette, int duration) {
this.palette = palette;
+ this.duration = duration;
redAnimation = new DummyAnimation(palette.getNormalColorf()[0]);
greenAnimation = new DummyAnimation(palette.getNormalColorf()[1]);
blueAnimation = new DummyAnimation(palette.getNormalColorf()[2]);
alphaAnimation = new DummyAnimation(palette.getNormalColorf()[3]);
}
+ public ColorAnimation(ColorPalette palette) {
+ this(palette, 100);
+ }
+
/**
* Return the current color at the current time, according to a EaseInOut quadratic animation.
*
@@ -36,25 +41,15 @@ public class ColorAnimation {
int state = pressed ? 2 : hovered ? 1 : 0;
if (state != prevState) {
float[] newColors = pressed ? palette.getPressedColorf() : hovered ? palette.getHoveredColorf() : palette.getNormalColorf();
- redAnimation = new EaseInOutQuad(speed, redAnimation.get(), newColors[0], false);
- greenAnimation = new EaseInOutQuad(speed, greenAnimation.get(), newColors[1], false);
- blueAnimation = new EaseInOutQuad(speed, blueAnimation.get(), newColors[2], false);
- alphaAnimation = new EaseInOutQuad(speed, alphaAnimation.get(), newColors[3], false);
+ redAnimation = new EaseInOutQuad(duration, redAnimation.get(), newColors[0], false);
+ greenAnimation = new EaseInOutQuad(duration, greenAnimation.get(), newColors[1], false);
+ blueAnimation = new EaseInOutQuad(duration, blueAnimation.get(), newColors[2], false);
+ alphaAnimation = new EaseInOutQuad(duration, alphaAnimation.get(), newColors[3], false);
prevState = state;
}
return ((int) (alphaAnimation.get() * 255) << 24) | ((int) (redAnimation.get() * 255) << 16) | ((int) (greenAnimation.get() * 255) << 8) | ((int) (blueAnimation.get() * 255));
}
- /** Set the speed in milliseconds for the animation. */
- public void setSpeed(int speed) {
- this.speed = speed;
- }
-
- /** Get the speed in milliseconds for the animation. */
- public int getSpeed() {
- return speed;
- }
-
/**
* Return the current alpha of the color. This method is used to get the alpha of pressed buttons that have text/icons on them, so they also darken accordingly.
*/
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 788e882..f331fd9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
@@ -69,7 +69,7 @@ public class ColorSelector {
saturationInput.setCurrentValue(color.getSaturation());
brightnessInput.setCurrentValue(color.getBrightness());
alphaInput.setCurrentValue(color.getAlpha() / 255f * 100f);
- if(!hasAlpha) {
+ if (!hasAlpha) {
bottomSlider.disabled = true;
alphaInput.disabled = true;
}
@@ -196,16 +196,16 @@ public class ColorSelector {
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, Colors.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()) {
+ if (closeBtn.isClicked() || Mouse.isButtonDown(0) && !mouseWasDown && !InputUtils.isAreaHovered(x - 3, y - 3, width + 6, height + 6))
OneConfigGui.INSTANCE.closeColorSelector();
- }
ScissorManager.resetScissor(vg, scissor);
+ mouseWasDown = Mouse.isButtonDown(0);
}
private void drawColorSelector(long vg, int mode, int x, int y) {
@@ -254,7 +254,6 @@ public class ColorSelector {
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:
@@ -285,7 +284,6 @@ public class ColorSelector {
hovered = squareDist < 144 * 144 && Mouse.isButtonDown(0);
isMouseDown = Mouse.isButtonDown(0);
if (hovered && isMouseDown && !mouseWasDown) dragging = true;
- mouseWasDown = isMouseDown;
int angle = 0;
int saturation = color.getSaturation();
@@ -431,7 +429,7 @@ public class ColorSelector {
@Override
public void draw(long vg, int x, int y) {
- if(!disabled) update(x, y);
+ if (!disabled) update(x, y);
else RenderManager.setAlpha(vg, 0.5f);
super.dragPointerSize = 15f;
if (image != null) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
index 10852ab..eff9b35 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -55,7 +55,7 @@ public class ModsPage extends Page {
}
}
}
- size = iY + 119;
+ size = iY - y + 135;
if (iX == x + 16 && iY == y + 72) {
RenderManager.drawText(vg, "Looks like there is nothing here. Try another category?", x + 16, y + 72, Colors.WHITE_60, 14f, Fonts.MEDIUM);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
index fff9482..17f9498 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
@@ -17,14 +17,13 @@ import org.lwjgl.input.Mouse;
public abstract class Page {
protected final String title;
protected Animation scrollAnimation;
- private final ColorAnimation colorAnimation = new ColorAnimation(new ColorPalette(Colors.TRANSPARENT, Colors.GRAY_400_60, Colors.GRAY_400_60));
+ private final ColorAnimation colorAnimation = new ColorAnimation(new ColorPalette(Colors.TRANSPARENT, Colors.GRAY_400_60, Colors.GRAY_400_60), 200);
protected float scrollTarget;
private long scrollTime;
private boolean mouseWasDown, dragging;
private float yStart;
public Page(String title) {
- colorAnimation.setSpeed(200);
this.title = title;
}