diff options
| author | Xander <xander@isxander.dev> | 2023-04-25 16:28:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-25 16:28:41 +0100 |
| commit | 13c7ba45ff201423eb8dba8a40cfb66ebb531439 (patch) | |
| tree | 1e799aa9da11fbc0833bc6b7c6e6799633c2ec50 /src/client/java/dev/isxander/yacl/gui/utils | |
| parent | 8ba7196ae990fe9aa98680aba1b387e385fff99c (diff) | |
| download | YetAnotherConfigLib-13c7ba45ff201423eb8dba8a40cfb66ebb531439.tar.gz YetAnotherConfigLib-13c7ba45ff201423eb8dba8a40cfb66ebb531439.tar.bz2 YetAnotherConfigLib-13c7ba45ff201423eb8dba8a40cfb66ebb531439.zip | |
Architectury! (#61)
Diffstat (limited to 'src/client/java/dev/isxander/yacl/gui/utils')
| -rw-r--r-- | src/client/java/dev/isxander/yacl/gui/utils/GuiUtils.java | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/client/java/dev/isxander/yacl/gui/utils/GuiUtils.java b/src/client/java/dev/isxander/yacl/gui/utils/GuiUtils.java deleted file mode 100644 index aa8bbaa..0000000 --- a/src/client/java/dev/isxander/yacl/gui/utils/GuiUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -package dev.isxander.yacl.gui.utils; - -import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.locale.Language; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; - -public class GuiUtils { - public static MutableComponent translatableFallback(String key, Component fallback) { - if (Language.getInstance().has(key)) - return Component.translatable(key); - return fallback.copy(); - } - - public static void enableScissor(int x, int y, int width, int height) { - Window window = Minecraft.getInstance().getWindow(); - double d = window.getGuiScale(); - RenderSystem.enableScissor((int)(x * d), (int)((window.getGuiScaledHeight() - y - height) * d), (int)(width * d), (int)(height * d)); - } - - public static String shortenString(String string, Font font, int maxWidth, String suffix) { - if (string.isEmpty()) - return string; - - boolean firstIter = true; - while (font.width(string) > maxWidth) { - string = string.substring(0, Math.max(string.length() - 1 - (firstIter ? 1 : suffix.length() + 1), 0)).trim(); - string += suffix; - - if (string.equals(suffix)) - break; - - firstIter = false; - } - - return string; - } -} |
