Class TextHudPanel


public abstract class TextHudPanel extends HudPanel
A HUD element made of lines of "label value" text. Implement lines and you get sizing, right-alignment when placed on the right of the screen, and the standard HudStyle colour options. Text is drawn in Noto Sans (FontFamily.SANS) at HudPanel.fontSize(Canvas); labels take the style's label colour and values its value colour, a gradient or rainbow running down the values.
public class PingHud extends TextHudPanel {
    public PingHud() { super("Ping", "", HudStyle.Mode.TEXT); }

    @Override
    protected void lines(Lines out) {
        out.add("Ping", ping() + "ms");
    }
}
  • Field Details

    • style

      protected final HudStyle style
      The element's colour options (its "Colors" settings group).
  • Constructor Details

    • TextHudPanel

      protected TextHudPanel(String title, String icon, HudStyle.Mode defaultMode)
      Parameters:
      title - its name, also its settings group's
      icon - a Nerd Font glyph for it
      defaultMode - how values are coloured until the player changes it
  • Method Details

    • lines

      protected abstract void lines(TextHudPanel.Lines out)
      Called every frame (twice: to size the element and to draw it): add this frame's lines to out, which starts empty. Use HudPanel.preview() to show sample values with no world.
    • preferredSize

      public Rect preferredSize(Canvas c)
      As wide as the widest line (at least 20 units), as tall as the lines (at least one).
      Overrides:
      preferredSize in class Panel
    • render

      public void render(Canvas c, float w, float h, float mx, float my)
      Description copied from class: Panel
      Draws the panel. Called every frame while visible, with the canvas clipped to the content area and translated so (0,0) is its top-left. width/height is the content area's size in UI units (animating while the window opens or moves). The mouse is in the same coordinates while the pointer is over this window and nothing covers it, and far outside (-10000) otherwise, so hover checks fail. A HUD element drawn in game, or while the HUD is being edited, gets no meaningful mouse position.
      Specified by:
      render in class Panel