Class ImGuiUtils

java.lang.Object
de.luckymcdev.foundryengine.client.imgui.ImGuiUtils

public class ImGuiUtils extends Object
A Class which has static methods for some ImGui utils.
  • Constructor Details

    • ImGuiUtils

      public ImGuiUtils()
  • Method Details

    • helpTooltip

      public static void helpTooltip(String text)
      Displays a (?) with a hover tooltip. Useful for example information. It is rendered at the same line as the thing before it.
      Parameters:
      text - The tooltip text
    • pushErrorButtonStyle

      public static void pushErrorButtonStyle()
      Pushes a red style for buttons to indicate a dangerous or error-related action. Must be paired with popErrorButtonStyle().
    • popErrorButtonStyle

      public static void popErrorButtonStyle()
      Pops the 3 style colors pushed by pushErrorButtonStyle().
    • icon

      public static String icon(ImIcon icon)
      Returns an icon
      Parameters:
      icon - The icon
    • displayIcon

      public static void displayIcon(ImIcon icon)
    • h1

      public static void h1(Runnable txt)
    • h2

      public static void h2(Runnable txt)
    • h3

      public static void h3(Runnable txt)
    • h4

      public static void h4(Runnable txt)
    • textCentered

      public static void textCentered(String text, float width)
      Helper to draw centered text.
      Parameters:
      text - The text to render
      width - The width of the area to center on
    • centered

      public static void centered(Runnable runnable, float itemWidth, float totalWidth)
      Helper to draw something centered
      Parameters:
      runnable - What to draw
      itemWidth - The known width of the item(s) you are drawing
      totalWidth - The width of the area to center within (usually ImGui.getContentRegionAvailX())
    • redTextIf

      public static void redTextIf(String text, boolean condition)
    • identifier

      public static void identifier(net.minecraft.resources.Identifier loc)
      Displays an identifier with a dimmed namespace
      Parameters:
      loc - The identifier
    • timer

      public static String timer(long time)
    • colorOf

      public static Color colorOf(String modid)
      Obtains the color of the modid
      Parameters:
      modid - The modid to get the color of
      Returns:
      color The color based on the hash of the modid
    • getStringSplitter

      public static net.minecraft.client.StringSplitter getStringSplitter()
      Returns:
      A string splitter for ImGui fonts
    • drawImage

      public static void drawImage(ImGuiUtils.Image image)
    • drawImage

      public static void drawImage(int id, float w, float h)
    • drawImageButton

      public static void drawImageButton(int id, float w, float h)
    • getTexture

      public static ImGuiUtils.Image getTexture(net.minecraft.resources.Identifier texture)
    • getTexture

      public static ImGuiUtils.Image getTexture(File imageFile)
    • section

      public static void section(String title)
      Renders a section header with colored text and a separator below it.
    • scrollableRegion

      public static void scrollableRegion(String id, Runnable content)
      Renders a scrollable child region at full available width/height with a border.
    • scrollableRegion

      public static void scrollableRegion(String id, float width, float height, boolean border, Runnable content)
      Renders a scrollable child region with explicit dimensions. Pass 0 for width or height to use the full available space.
    • collapse

      public static boolean collapse(String label, Runnable content)
      Collapsible section header. Only runs content when the header is open.
    • collapse

      public static boolean collapse(String label, int flags, Runnable content)
      Collapsible section header with custom tree-node flags.
    • labeledValue

      public static void labeledValue(String label, String value)
      Renders a colored label followed by a dimmed value on the same line.
    • withFont

      public static void withFont(net.minecraft.resources.Identifier font, Runnable body)
      Runs body while the given font is pushed, then pops it.
    • treeSection

      public static void treeSection(String label, Runnable body)
      Runs body inside a framed, default-open tree node.
    • iconButton

      public static boolean iconButton(ImIcon icon, String id)
      Renders a small icon button.
    • formatColored

      public static String formatColored(String text, Object... args)
      Returns a colored string formatted with the given arguments, using the standard bright-blue tint for labels.