diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-18 10:13:39 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-18 10:13:39 +0200 |
commit | a929901f2dfb135cbb72036b5e49b4fdb38fe24a (patch) | |
tree | 6edf7913fd2375dd98e07fe053c9a21d6a4b8322 /src/main/java/cc/polyfrost/oneconfig/gui | |
parent | d01767620ee480308dfc03185e6a12d7d1e494f3 (diff) | |
download | OneConfig-a929901f2dfb135cbb72036b5e49b4fdb38fe24a.tar.gz OneConfig-a929901f2dfb135cbb72036b5e49b4fdb38fe24a.tar.bz2 OneConfig-a929901f2dfb135cbb72036b5e49b4fdb38fe24a.zip |
some stuff
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
8 files changed, 25 insertions, 29 deletions
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 <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a> - */ @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 <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a> - */ @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 <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a> - */ @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 <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a> */ @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); } |