Class BoardToastOverlay

java.lang.Object
megamek.client.ui.clientGUI.boardview.overlay.BoardToastOverlay
All Implemented Interfaces:
IDisplayable

public class BoardToastOverlay extends Object implements IDisplayable
A board view overlay that displays transient toast notifications. Messages appear at the top-center of the viewport, optionally showing the acting unit's sprite icon, then fade out after a configurable duration. Multiple messages stack vertically, each on its own independent timer.

Thread-safe: show(megamek.client.ui.clientGUI.boardview.overlay.ToastLevel, java.lang.String) may be called from any thread. Rendering and animation run on the EDT.

  • Constructor Details

  • Method Details

    • show

      public void show(ToastLevel level, String text)
      Shows a toast notification with no associated entity icon, using the level's default duration.
      Parameters:
      level - the severity level determining color and default duration
      text - the message text to display
    • show

      public void show(ToastLevel level, String text, @Nullable Entity entity)
      Shows a toast notification, optionally displaying the given entity's sprite icon, using the level's default duration.
      Parameters:
      level - the severity level determining color and default duration
      text - the message text to display
      entity - the entity whose icon to show, or null for text-only
    • show

      public void show(ToastLevel level, String text, @Nullable Entity entity, int durationMs)
      Shows a toast notification with explicit duration control.
      Parameters:
      level - the severity level determining color
      text - the message text to display
      entity - the entity whose icon to show, or null for text-only
      durationMs - how long the toast remains visible in milliseconds
    • isSliding

      public boolean isSliding()
      Description copied from interface: IDisplayable
      Return true while sliding. "Sliding" means that this IDisplayable is in the process of opening, closing moving or fading. The BoardView will repaint at some fps while an IDisplayable is sliding. The default for this method will always return false.
      Specified by:
      isSliding in interface IDisplayable
    • slide

      public boolean slide()
      Description copied from interface: IDisplayable
      Conducts a frame update when sliding. "Sliding" means that this IDisplayable is in the process of opening, closing moving or fading. The BoardView will repaint at some fps while an IDisplayable is sliding. Return true as long as the slide process is not finished. See ChatterBox2 and KeyBindingsOverlay for examples. The default for this method will always return false.
      Specified by:
      slide in interface IDisplayable
    • draw

      public void draw(Graphics graph, Rectangle clipBounds)
      Description copied from interface: IDisplayable
      Draw this IDisplayable to the Graphics graph, which is the BoardView graphics. The currently visible part of the BoardView is given by the Rectangle rect, so the upper left corner of the visible BoardView is rect.x, rect.y.
      Specified by:
      draw in interface IDisplayable