diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-29 15:26:36 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-29 15:26:36 +0700 |
commit | 98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315 (patch) | |
tree | a26d876b223229a35d05ef93c81a429ea1d877cd /src/main/java/cc/polyfrost/oneconfig/utils | |
parent | ce370c8e2768383b57212fccd4018f92f88b8847 (diff) | |
download | OneConfig-98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315.tar.gz OneConfig-98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315.tar.bz2 OneConfig-98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315.zip |
kotlin dsl
RenderManager reorganization
fix build error in CommandHelper
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
3 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java index 19d399f..79634da 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java @@ -4,7 +4,7 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; public final class MathUtils { public static float clamp(float number) { - return number < 0f ? 0f : Math.min(number, 1f); + return clamp(number, 0, 1); } public static float clamp(float number, float min, float max) { diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java index f9f0fbd..4fa5125 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java @@ -1,6 +1,7 @@ package cc.polyfrost.oneconfig.utils; import cc.polyfrost.oneconfig.lwjgl.RenderManager; +import cc.polyfrost.oneconfig.lwjgl.font.Font; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import java.util.ArrayList; @@ -20,6 +21,19 @@ public final class TextUtils { * @return The array of lines. */ public static ArrayList<String> wrapText(long vg, String text, float maxWidth, float fontSize, Fonts font) { + return wrapText(vg, text, maxWidth, fontSize, font.font); + } + + /** + * Wraps a string into an array of lines. + * @param vg The NanoVG context. + * @param text The text to wrap. + * @param maxWidth The maximum width of each line. + * @param fontSize The font size. + * @param font The font to use. + * @return The array of lines. + */ + public static ArrayList<String> wrapText(long vg, String text, float maxWidth, float fontSize, Font font) { ArrayList<String> wrappedText = new ArrayList<>(); text += " "; int prevIndex = 0; diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java index bc57fc2..3e7b7ea 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java @@ -10,7 +10,7 @@ package cc.polyfrost.oneconfig.utils.commands; public abstract class CommandHelper { public CommandHelper() { - CommandManager.registerCommand(this); + CommandManager.INSTANCE.registerCommand(this); } public void preload() { |