From 3e472ea407d128de61820fc167e08b8fe24186c9 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sat, 4 Jun 2022 22:34:51 +0700 Subject: move deltaTicks to GuiUtils (#33) * move from mod events to mixin * packet events * move deltaTicks to GuiUtils * delete easeOut --- .../java/cc/polyfrost/oneconfig/gui/OneConfigGui.java | 19 ++----------------- .../polyfrost/oneconfig/gui/animations/Animation.java | 4 ++-- 2 files changed, 4 insertions(+), 19 deletions(-) (limited to 'src/main/java/cc/polyfrost/oneconfig/gui') diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 27ff322..5985d12 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -14,6 +14,7 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; +import cc.polyfrost.oneconfig.utils.GuiUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.InputUtils; import org.jetbrains.annotations.NotNull; @@ -37,8 +38,6 @@ public class OneConfigGui extends UScreen { public boolean mouseDown; private float scale = 1f; public static OneConfigGui instanceToRestore = null; - private long time = -1L; - private long deltaTime = 17L; public boolean allowClose = true; private Animation animation; @@ -72,12 +71,6 @@ public class OneConfigGui extends UScreen { currentPage = new ModsPage(); parents.add(currentPage); } - if (time == -1) time = UMinecraft.getTime(); - else { - long currentTime = UMinecraft.getTime(); - deltaTime = currentTime - time; - time = currentTime; - } scale = Math.min(UResolution.getWindowWidth() / 1920f, UResolution.getWindowHeight() / 1080f); if (scale < 1) scale = Math.min(Math.min(1f, UResolution.getWindowWidth() / 1280f), Math.min(1f, UResolution.getWindowHeight() / 800f)); @@ -139,7 +132,7 @@ public class OneConfigGui extends UScreen { ScissorManager.scissor(vg, x + 224, y + 88, 1056, 698); if (prevPage != null && animation != null) { - float pageProgress = animation.get(deltaTime); + float pageProgress = animation.get(GuiUtils.getDeltaTime()); if (!animation.isReversed()) { prevPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72); currentPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72); @@ -264,14 +257,6 @@ public class OneConfigGui extends UScreen { return textInputField.getInput(); } - public long getDeltaTime() { - return deltaTime; - } - - public static long getDeltaTimeNullSafe() { - return OneConfigGui.INSTANCE == null ? 17 : OneConfigGui.INSTANCE.getDeltaTime(); - } - @Override public boolean doesGuiPauseGame() { return false; 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 9e2c238..069a807 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java @@ -1,6 +1,6 @@ package cc.polyfrost.oneconfig.gui.animations; -import cc.polyfrost.oneconfig.gui.OneConfigGui; +import cc.polyfrost.oneconfig.utils.GuiUtils; public abstract class Animation { private final float duration; @@ -41,7 +41,7 @@ public abstract class Animation { * @return The new value */ public float get() { - return get(OneConfigGui.getDeltaTimeNullSafe()); + return get(GuiUtils.getDeltaTime()); } /** -- cgit