Class Widgets


  • public class Widgets
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Widgets()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      KSWidget get​(int widgetId, int child)  
      KSWidget get​(rs.kreme.ksbot.api.game.utils.widgets.WidgetInfo widgetInfo)  
      KSWidget getChildContains​(KSWidget parent, java.lang.String text)
      Finds a child widget in a parent that contains the specified text.
      java.util.List<KSWidget> getChildWithOffset​(KSWidget parent, int startIndex, int offset)
      Retrieves child widgets at a given offset.
      java.util.List<KSItem> getItems​(KSWidget widget)
      Retrieves the list of items from a widget.
      KSWidget getWidget​(int componentId)
      Retrieves a widget by its component ID.
      KSWidget getWidget​(int[] widgetId)
      Retrieves a widget by its ID.
      KSWidget getWidget​(int groupId, int childId)
      Retrieves a widget using a group and child ID.
      KSWidget getWidget​(int groupId, int childId, int index)
      Retrieves a child widget from a parent using group, child, and index.
      KSWidget getWidget​(rs.kreme.ksbot.api.game.utils.widgets.WidgetInfo widgetInfo)
      Retrieves a widget by its WidgetInfo.
      void interact​(int widgetId)
      Interacts with a widget.
      void interact​(int widgetId, int index, int option)
      Interacts with a widget based on its ID, index, and option.
      void interact​(KSWidget widget, int option)
      Interacts with a widget using the specified option.
      void interact​(KSWidget widget, int option, int index)
      Interacts with a widget using the specified option and index.
      void interact​(KSWidget widget, net.runelite.api.MenuAction menuAction, int index, int option)
      Interacts with a widget using a specified menu action, index, and option.
      boolean isUsable​(int widget)  
      boolean isUsable​(rs.kreme.ksbot.api.game.utils.widgets.WidgetInfo widget)  
      boolean isUsable​(KSWidget widget)
      Checks if a widget is usable (i.e., not hidden).
      boolean isUsable​(KSWidget widget, java.util.function.Predicate<? super KSWidget> predicate)
      Checks if a widget is usable and satisfies a given predicate.
      int PACK​(int groupId, int childId)
      Packs group and child IDs into a single ID.
      WidgetQuery query()
      Searches for all widgets in the game.
      int TO_CHILD​(int id)
      Converts an ID to its child part.
      int TO_GROUP​(int id)
      Converts an ID to its group part.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Widgets

        public Widgets()
    • Method Detail

      • query

        public WidgetQuery query()
        Searches for all widgets in the game.
        Returns:
        A WidgetQuery containing all widgets in the client.
      • getWidget

        public KSWidget getWidget​(int[] widgetId)
        Retrieves a widget by its ID.
        Parameters:
        widgetId - An array representing group and child ID.
        Returns:
        The corresponding widget or null if not found.
      • getWidget

        public KSWidget getWidget​(int groupId,
                                  int childId)
        Retrieves a widget using a group and child ID.
        Parameters:
        groupId - The group ID of the widget.
        childId - The child ID of the widget.
        Returns:
        The corresponding widget or null if not found.
      • getWidget

        public KSWidget getWidget​(int groupId,
                                  int childId,
                                  int index)
        Retrieves a child widget from a parent using group, child, and index.
        Parameters:
        groupId - The group ID of the widget.
        childId - The child ID of the widget.
        index - The index of the child.
        Returns:
        The child widget or null if not found.
      • isUsable

        public boolean isUsable​(KSWidget widget)
        Checks if a widget is usable (i.e., not hidden).
        Parameters:
        widget - The widget to check.
        Returns:
        True if the widget is usable, false otherwise.
      • isUsable

        public boolean isUsable​(rs.kreme.ksbot.api.game.utils.widgets.WidgetInfo widget)
      • isUsable

        public boolean isUsable​(int widget)
      • isUsable

        public boolean isUsable​(KSWidget widget,
                                java.util.function.Predicate<? super KSWidget> predicate)
        Checks if a widget is usable and satisfies a given predicate.
        Parameters:
        widget - The widget to check.
        predicate - A condition to test on the widget.
        Returns:
        True if the widget is usable and matches the predicate, false otherwise.
      • TO_GROUP

        public int TO_GROUP​(int id)
        Converts an ID to its group part.
        Parameters:
        id - The widget ID.
        Returns:
        The group part of the ID.
      • TO_CHILD

        public int TO_CHILD​(int id)
        Converts an ID to its child part.
        Parameters:
        id - The widget ID.
        Returns:
        The child part of the ID.
      • PACK

        public int PACK​(int groupId,
                        int childId)
        Packs group and child IDs into a single ID.
        Parameters:
        groupId - The group ID.
        childId - The child ID.
        Returns:
        A packed widget ID.
      • getWidget

        public KSWidget getWidget​(rs.kreme.ksbot.api.game.utils.widgets.WidgetInfo widgetInfo)
        Retrieves a widget by its WidgetInfo.
        Parameters:
        widgetInfo - The WidgetInfo of the widget.
        Returns:
        The corresponding widget or null if not found.
      • getWidget

        public KSWidget getWidget​(int componentId)
        Retrieves a widget by its component ID.
        Parameters:
        componentId - The component ID.
        Returns:
        The corresponding widget or null if not found.
      • getChildContains

        public KSWidget getChildContains​(KSWidget parent,
                                         java.lang.String text)
        Finds a child widget in a parent that contains the specified text.
        Parameters:
        parent - The parent widget.
        text - The text to search for.
        Returns:
        The child widget containing the text or null if not found.
      • getChildWithOffset

        public java.util.List<KSWidget> getChildWithOffset​(KSWidget parent,
                                                           int startIndex,
                                                           int offset)
        Retrieves child widgets at a given offset.
        Parameters:
        parent - The parent widget.
        startIndex - The start index.
        offset - The offset between each child.
        Returns:
        A list of child widgets.
      • getItems

        public java.util.List<KSItem> getItems​(KSWidget widget)
        Retrieves the list of items from a widget.
        Parameters:
        widget - The widget to get items from.
        Returns:
        A list of KSItem objects representing the items in the widget.
      • interact

        public void interact​(KSWidget widget,
                             int option,
                             int index)
        Interacts with a widget using the specified option and index.
        Parameters:
        widget - The widget to interact with.
        option - The option to select.
        index - The index of the widget.
      • interact

        public void interact​(int widgetId)
        Interacts with a widget.
        Parameters:
        widgetId - The widget id to interact with.
      • interact

        public void interact​(int widgetId,
                             int index,
                             int option)
        Interacts with a widget based on its ID, index, and option.
        Parameters:
        widgetId - The ID of the widget to interact with.
        index - The index of the interaction option.
        option - The specific option to select for the interaction.
      • interact

        public void interact​(KSWidget widget,
                             net.runelite.api.MenuAction menuAction,
                             int index,
                             int option)
        Interacts with a widget using a specified menu action, index, and option.
        Parameters:
        widget - The widget to interact with.
        menuAction - The type of menu action.
        index - The index of the widget.
        option - The option to select.
      • interact

        public void interact​(KSWidget widget,
                             int option)
        Interacts with a widget using the specified option.
        Parameters:
        widget - The widget to interact with.
        option - The option to select.
      • get

        public KSWidget get​(int widgetId,
                            int child)
      • get

        public KSWidget get​(rs.kreme.ksbot.api.game.utils.widgets.WidgetInfo widgetInfo)