Class WidgetQuery

All Implemented Interfaces:
Predicate<IWidget>

public class WidgetQuery extends Query<IWidget,WidgetQuery,WidgetQueryResults>
Query class for finding and filtering game interface widgets.

Widgets are components of the game's user interface, including buttons, text labels, inventory slots, and other interactive or display elements. This class provides filtering capabilities for widgets:

  • Filter by widget IDs
  • Filter by widget types
  • Filter by text content
  • Filter by available actions
  • Filter by visibility

Example usage:


 // Find all visible widgets with "Continue" action
 WidgetQuery query = new WidgetQuery(widgetSupplier)
     .actions("Continue")
     .visible(true);
 WidgetQueryResults results = query.results();
 
  • Constructor Details

    • WidgetQuery

      public WidgetQuery(Supplier<List<IWidget>> supplier)
      Constructs a new widget query with the specified widget supplier.
      Parameters:
      supplier - a supplier that provides the list of widgets to query
  • Method Details

    • results

      protected WidgetQueryResults results(List<IWidget> list)
      Wraps the filtered list of widgets in a WidgetQueryResults container.
      Specified by:
      results in class Query<IWidget,WidgetQuery,WidgetQueryResults>
      Parameters:
      list - the list of widgets that passed all filters
      Returns:
      the results wrapped in a WidgetQueryResults container
    • ids

      public WidgetQuery ids(int... ids)
      Filters widgets by their IDs.

      Only widgets with an ID matching one of the specified values will be included.

      Parameters:
      ids - the widget IDs to filter by
      Returns:
      this query instance for method chaining
    • types

      public WidgetQuery types(int... types)
      Filters widgets by their types.

      Only widgets with a type matching one of the specified values will be included. Widget types indicate the kind of interface element (e.g., button, text, etc.).

      Parameters:
      types - the widget types to filter by
      Returns:
      this query instance for method chaining
    • texts

      public WidgetQuery texts(String... texts)
      Filters widgets by their text content.

      Only widgets whose text exactly matches one of the specified values will be included.

      Parameters:
      texts - the text values to filter by
      Returns:
      this query instance for method chaining
    • actions

      public WidgetQuery actions(String... actions)
      Filters widgets by their available actions.

      Only widgets that have at least one action matching one of the specified values will be included.

      Parameters:
      actions - the actions to filter by
      Returns:
      this query instance for method chaining
    • visible

      public WidgetQuery visible(Boolean visible)
      Filters widgets by their visibility status.

      Only widgets whose visibility matches the specified value will be included.

      Parameters:
      visible - true to include only visible widgets, false for hidden widgets
      Returns:
      this query instance for method chaining
    • test

      public boolean test(IWidget widget)
      Tests whether a widget passes all accumulated filter criteria.

      This method checks the widget against all configured filters including ID, type, text, actions, and visibility.

      Specified by:
      test in interface Predicate<IWidget>
      Overrides:
      test in class Query<IWidget,WidgetQuery,WidgetQueryResults>
      Parameters:
      widget - the widget to test
      Returns:
      true if the widget passes all filters, false otherwise