From a929901f2dfb135cbb72036b5e49b4fdb38fe24a Mon Sep 17 00:00:00 2001
From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>
Date: Sat, 18 Jun 2022 10:13:39 +0200
Subject: some stuff
---
.../java/cc/polyfrost/oneconfig/gui/OneConfigGui.java | 5 +++--
.../cc/polyfrost/oneconfig/gui/animations/Animation.java | 6 +++---
.../oneconfig/gui/animations/DummyAnimation.java | 12 ++++++++++--
.../oneconfig/gui/animations/EaseInOutCubic.java | 8 ++------
.../polyfrost/oneconfig/gui/animations/EaseInOutQuad.java | 8 ++------
.../oneconfig/gui/animations/EaseInOutQuart.java | 9 ++-------
.../polyfrost/oneconfig/gui/animations/EaseOutQuad.java | 4 ++--
.../cc/polyfrost/oneconfig/gui/pages/CreditsPage.java | 2 +-
.../polyfrost/oneconfig/internal/config/Preferences.java | 15 +++++++++++++++
9 files changed, 40 insertions(+), 29 deletions(-)
(limited to 'src/main/java/cc')
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 79d6b55..c138e4a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -12,6 +12,7 @@ import cc.polyfrost.oneconfig.internal.OneConfig;
import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.internal.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.internal.config.Preferences;
import cc.polyfrost.oneconfig.libs.universal.UKeyboard;
import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
import cc.polyfrost.oneconfig.libs.universal.UResolution;
@@ -78,8 +79,8 @@ public class OneConfigGui extends UScreen {
NanoVG.nvgTranslate(vg, UResolution.getWindowWidth(), UResolution.getWindowHeight());
NanoVG.nvgRotate(vg, (float) Math.toRadians(180));
}
- scale = Math.min(UResolution.getWindowWidth() / 1920f, UResolution.getWindowHeight() / 1080f);
- if (scale < 1)
+ scale = Preferences.enableCustomScale ? Preferences.customScale : Math.min(UResolution.getWindowWidth() / 1920f, UResolution.getWindowHeight() / 1080f);
+ if (scale < 1 && !Preferences.enableCustomScale)
scale = Math.min(Math.min(1f, UResolution.getWindowWidth() / 1280f), Math.min(1f, UResolution.getWindowHeight() / 800f));
int x = (int) ((UResolution.getWindowWidth() - 1280 * scale) / 2f / scale);
int y = (int) ((UResolution.getWindowHeight() - 800 * scale) / 2f / scale);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
index a5cfae0..30fcc4e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
@@ -3,7 +3,7 @@ package cc.polyfrost.oneconfig.gui.animations;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
public abstract class Animation {
- protected final boolean reverse;
+ private final boolean reverse;
private final float duration;
private final float start;
private final float change;
@@ -34,7 +34,7 @@ public abstract class Animation {
public float get(float deltaTime) {
timePassed += deltaTime;
if (timePassed >= duration) timePassed = duration;
- return animate(timePassed, duration, start, change);
+ return animate(timePassed / duration) * change + start;
}
/**
@@ -58,5 +58,5 @@ public abstract class Animation {
return reverse;
}
- protected abstract float animate(float timePassed, float duration, float start, float change);
+ protected abstract float animate(float x);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
index dc5bc26..7363ed6 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
@@ -1,15 +1,23 @@
package cc.polyfrost.oneconfig.gui.animations;
public class DummyAnimation extends Animation {
+ protected final float value;
+
/**
* @param value The value that is returned
*/
public DummyAnimation(float value) {
super(value, value, value, false);
+ this.value = value;
+ }
+
+ @Override
+ public float get(float deltaTime) {
+ return value;
}
@Override
- protected float animate(float timePassed, float duration, float start, float change) {
- return start;
+ protected float animate(float x) {
+ return x;
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java
index 760f369..1de3346 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java
@@ -12,12 +12,8 @@ public class EaseInOutCubic extends Animation {
super(duration, start, end, reverse);
}
- /**
- * Adapted from https://github.com/jesusgollonet/processing-penner-easing
- */
@Override
- protected float animate(float timePassed, float duration, float start, float change) {
- if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed * timePassed + start;
- return change / 2 * ((timePassed -= 2) * timePassed * timePassed + 2) + start;
+ protected float animate(float x) {
+ return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
index f43c75d..3855eac 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
@@ -12,12 +12,8 @@ public class EaseInOutQuad extends Animation {
super(duration, start, end, reverse);
}
- /**
- * Adapted from https://github.com/jesusgollonet/processing-penner-easing
- */
@Override
- protected float animate(float timePassed, float duration, float start, float change) {
- if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed + start;
- return -change / 2 * ((--timePassed) * (timePassed - 2) - 1) + start;
+ protected float animate(float x) {
+ return x < 0.5 ? 2 * x * x : (float) (1 - Math.pow(-2 * x + 2, 2) / 2);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
index 9c3abe9..c397d4b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
@@ -12,13 +12,8 @@ public class EaseInOutQuart extends Animation {
super(duration, start, end, reverse);
}
- /**
- * Adapted from https://github.com/jesusgollonet/processing-penner-easing
- */
@Override
- protected float animate(float timePassed, float duration, float start, float change) {
- if ((timePassed /= duration / 2) < 1)
- return change / 2 * timePassed * timePassed * timePassed * timePassed + start;
- return -change / 2 * ((timePassed -= 2) * timePassed * timePassed * timePassed - 2) + start;
+ protected float animate(float x) {
+ return x < 0.5 ? 8 * x * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 4) / 2);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java
index 6cc97bf..8c7bff2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java
@@ -16,7 +16,7 @@ public class EaseOutQuad extends Animation {
* Adapted from https://github.com/jesusgollonet/processing-penner-easing
*/
@Override
- protected float animate(float timePassed, float duration, float start, float change) {
- return -change * (timePassed /= duration) * (timePassed - 2) + start;
+ protected float animate(float x) {
+ return 1 - (1 - x) * (1 - x);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
index a101071..cf160d3 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
@@ -28,7 +28,7 @@ public class CreditsPage extends Page {
RenderManager.drawText(vg, " - #getResourceAsStream (SpinyOwl) - IO Utility and shadow", x + 20, y + 355, -1, 12, Fonts.REGULAR);
RenderManager.drawText(vg, " - NanoVG (memononen) - NanoVG Library", x + 20, y + 370, -1, 12, Fonts.REGULAR);
RenderManager.drawText(vg, " - UniversalCraft (Sk1er LLC) - Multiversioning bindings", x + 20, y + 385, -1, 12, Fonts.REGULAR);
- RenderManager.drawText(vg, " - Easing Functions (jesusgollonet)", x + 20, y + 400, -1, 12, Fonts.REGULAR);
+ RenderManager.drawText(vg, " - https://easings.net/ - Easing functions", x + 20, y + 400, -1, 12, Fonts.REGULAR);
RenderManager.drawText(vg, " - Quiltflower (Quilt Team) - Gradle decompiler", x + 20, y + 415, -1, 12, Fonts.REGULAR);
RenderManager.drawText(vg, " - Seraph (Scherso) - Locraw and Multithreading utilities", x + 20, y + 430, -1, 12, Fonts.REGULAR);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java
index ffb4b62..0d5c933 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.internal.config;
import cc.polyfrost.oneconfig.config.annotations.KeyBind;
+import cc.polyfrost.oneconfig.config.annotations.Slider;
import cc.polyfrost.oneconfig.config.annotations.Switch;
import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
@@ -19,6 +20,20 @@ public class Preferences extends InternalConfig {
)
public static OneKeyBind oneConfigKeyBind = new OneKeyBind(UKeyboard.KEY_RSHIFT);
+ @Switch(
+ name = "Use custom GUI scale",
+ subcategory = "GUI Scale",
+ size = 2
+ )
+ public static boolean enableCustomScale = false;
+
+ @Slider(
+ name = "Custom GUI scale",
+ min = 0.5f,
+ max = 5f
+ )
+ public static float customScale = 1f;
+
public Preferences() {
super("Preferences", "Preferences.json");
registerKeyBind(oneConfigKeyBind, () -> GuiUtils.displayScreen(OneConfigGui.create()));
--
cgit