aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-21 17:50:43 +0700
committerGitHub <noreply@github.com>2022-05-21 12:50:43 +0200
commitba87b8b1fa4e2397a3e0ed5a18f7ea6137d42f77 (patch)
treea052e7ac963be0f64980fc3faa664ebf20a52b34 /src/main/java/cc/polyfrost/oneconfig/utils
parent1abe65dc3875df5a490d8c900399e61a378ae901 (diff)
downloadOneConfig-ba87b8b1fa4e2397a3e0ed5a18f7ea6137d42f77.tar.gz
OneConfig-ba87b8b1fa4e2397a3e0ed5a18f7ea6137d42f77.tar.bz2
OneConfig-ba87b8b1fa4e2397a3e0ed5a18f7ea6137d42f77.zip
vigilance compat (#15)
* vigilance compat reorganize ASM * remove non-RenderManager nanovg usage wherever possible fix build generalize utils * setupGradle task * migrate to kotlin gradle use essential gradle toolkit shade new gson * Small changes * Update .gitignore * fix natives * Fix all problems * null Co-authored-by: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java1
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java10
4 files changed, 10 insertions, 13 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java
index aa37005..2e48bdc 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java
@@ -1,8 +1,7 @@
package cc.polyfrost.oneconfig.utils;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
+import cc.polyfrost.oneconfig.gui.OneConfigGui;
import java.awt.*;
@@ -49,7 +48,6 @@ public class ColorUtils {
* @param currentColor the current color (also the one you want to change)
* @param direction false to move towards initColor, true to move towards finalColor
* @param speed speed of the transition
- * @return currentColor but with the new color
*/
public static int smoothColor(int currentColor, int initColor, int finalColor, boolean direction, float speed) {
float[] init = splitColor(initColor);
@@ -58,8 +56,7 @@ public class ColorUtils {
return getColorComponents(current, init, finalC, direction, speed);
}
- @Contract(value = "_ -> new", pure = true)
- private static float @NotNull [] splitColor(int color) {
+ private static float[] splitColor(int color) {
return new float[]{(color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) / 255f};
}
@@ -74,7 +71,8 @@ public class ColorUtils {
}
private static float smooth(float current, float min, float max, boolean moveToFinal, float speed) {
- current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f, speed);
+ float deltaTime = OneConfigGui.INSTANCE == null ? 16 : OneConfigGui.INSTANCE.getDeltaTime();
+ current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f, speed, deltaTime);
if (current <= min) {
current = min;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
index 6264451..7263a19 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
@@ -19,6 +19,7 @@ public final class IOUtils {
* Taken from legui under MIT License
* <a href="https://github.com/SpinyOwl/legui/blob/develop/LICENSE">https://github.com/SpinyOwl/legui/blob/develop/LICENSE</a>
*/
+ @SuppressWarnings("RedundantCast")
public static ByteBuffer resourceToByteBuffer(String path) throws IOException {
byte[] bytes;
path = path.trim();
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
index 6053a99..922010d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java
@@ -1,7 +1,7 @@
package cc.polyfrost.oneconfig.utils;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
-import gg.essential.universal.UResolution;
+import cc.polyfrost.oneconfig.libs.universal.UResolution;
import org.lwjgl.input.Mouse;
public class InputUtils {
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java
index e10679a..e86061a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java
@@ -1,7 +1,5 @@
package cc.polyfrost.oneconfig.utils;
-import cc.polyfrost.oneconfig.gui.OneConfigGui;
-
public class MathUtils {
public static float clamp(float number) {
return number < 0f ? 0f : Math.min(number, 1f);
@@ -11,9 +9,9 @@ public class MathUtils {
return number < min ? min : Math.min(number, max);
}
- public static float easeOut(float current, float goal, float speed) {
+ public static float easeOut(float current, float goal, float speed, float deltaTime) {
if (Math.round(Math.abs(goal - current) * 100) > 0) {
- return current + (goal - current) / speed * (OneConfigGui.INSTANCE == null ? 17 : OneConfigGui.INSTANCE.getDeltaTime());
+ return current + (goal - current) / speed * deltaTime;
} else {
return goal;
}
@@ -26,8 +24,8 @@ public class MathUtils {
/**
* taken from <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a>
*/
- public static float easeInOutCirc(float t, float b, float c, float d) {
- c *= OneConfigGui.INSTANCE == null ? 17 : OneConfigGui.INSTANCE.getDeltaTime();
+ public static float easeInOutCirc(float t, float b, float c, float d, float deltaTime) {
+ c *= deltaTime;
if ((t /= d / 2) < 1) return -c / 2 * ((float) Math.sqrt(1 - t * t) - 1) + b;
return c / 2 * ((float) Math.sqrt(1 - (t -= 2) * t) + 1) + b;
}