Class WidgetQuery
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();
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionWidgetQuery(Supplier<List<IWidget>> supplier) Constructs a new widget query with the specified widget supplier. -
Method Summary
Modifier and TypeMethodDescriptionFilters widgets by their available actions.ids(int... ids) Filters widgets by their IDs.protected WidgetQueryResultsWraps the filtered list of widgets in a WidgetQueryResults container.booleanTests whether a widget passes all accumulated filter criteria.Filters widgets by their text content.types(int... types) Filters widgets by their types.Filters widgets by their visibility status.
-
Constructor Details
-
WidgetQuery
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
Wraps the filtered list of widgets in a WidgetQueryResults container.- Specified by:
resultsin classQuery<IWidget,WidgetQuery, WidgetQueryResults> - Parameters:
list- the list of widgets that passed all filters- Returns:
- the results wrapped in a WidgetQueryResults container
-
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
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
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
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
Filters widgets by their visibility status.Only widgets whose visibility matches the specified value will be included.
- Parameters:
visible-trueto include only visible widgets,falsefor hidden widgets- Returns:
- this query instance for method chaining
-
test
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:
testin interfacePredicate<IWidget>- Overrides:
testin classQuery<IWidget,WidgetQuery, WidgetQueryResults> - Parameters:
widget- the widget to test- Returns:
trueif the widget passes all filters,falseotherwise
-