Record Class DrawCommand.ComponentTarget

java.lang.Object
java.lang.Record
com.botwithus.bot.api.draw.DrawCommand.ComponentTarget
All Implemented Interfaces:
DrawCommand, DrawCommand.Primitive
Enclosing interface:
DrawCommand

public static record DrawCommand.ComponentTarget(String key, DrawSpace space, DrawStyle style, int interfaceId, int componentId, DrawCaption caption) extends Record implements DrawCommand.Primitive
A highlight that tracks an interface component rather than a rectangle.

Carries no geometry: the producer stores (interfaceId, componentId) and re-resolves the on-screen rect on the game thread once per tick, because the client recomputes a component's rect on every layout pass. A stored rectangle would drift the moment the UI relaid out, the window resized, or a scrollpane moved.

The optional caption is the only way to tell highlights apart, and it has to travel with the command precisely because the caller never learns where the rect landed — with six highlights on screen there is nothing else to distinguish them by. The producer draws it against the resolved rect. DrawCaption.NONE for an uncaptioned highlight.

  • Constructor Details

    • ComponentTarget

      public ComponentTarget(String key, DrawSpace space, DrawStyle style, int interfaceId, int componentId, DrawCaption caption)
      Creates an instance of a ComponentTarget record class.
      Parameters:
      key - the value for the key record component
      space - the value for the space record component
      style - the value for the style record component
      interfaceId - the value for the interfaceId record component
      componentId - the value for the componentId record component
      caption - the value for the caption record component
  • Method Details

    • autoKey

      public static String autoKey(int interfaceId, int componentId)
      The key a component highlight gets when the caller names none: comp:<iface>:<comp>, for example comp:1473:5.

      That format is part of the producer's contract, and it exists so a caller who omitted a key still has a way to name the highlight in order to clear it. This host computes it rather than reading it back, so the key is known before the command is sent — but the producer echoes the key it actually used on every reply, and a live test asserts the two agree rather than assuming it.

    • kind

      public DrawKind kind()
      Description copied from interface: DrawCommand
      The primitive this command draws.
      Specified by:
      kind in interface DrawCommand
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public String key()
      Returns the value of the key record component.
      Specified by:
      key in interface DrawCommand
      Returns:
      the value of the key record component
    • space

      public DrawSpace space()
      Returns the value of the space record component.
      Specified by:
      space in interface DrawCommand
      Returns:
      the value of the space record component
    • style

      public DrawStyle style()
      Returns the value of the style record component.
      Specified by:
      style in interface DrawCommand
      Returns:
      the value of the style record component
    • interfaceId

      public int interfaceId()
      Returns the value of the interfaceId record component.
      Returns:
      the value of the interfaceId record component
    • componentId

      public int componentId()
      Returns the value of the componentId record component.
      Returns:
      the value of the componentId record component
    • caption

      public DrawCaption caption()
      Returns the value of the caption record component.
      Returns:
      the value of the caption record component