use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class Hooks method checkWorldMap.
/**
* When the world map opens it loads about ~100mb of data into memory, which
* represents about half of the total memory allocated by the client.
* This gets cached and never released, which causes GC pressure which can affect
* performance. This method reinitailzies the world map cache, which allows the
* data to be garbage collecged, and causes the map data from disk each time
* is it opened.
*/
private static void checkWorldMap() {
Widget widget = client.getWidget(WORLD_MAP, 0);
if (widget != null) {
return;
}
RenderOverview renderOverview = client.getRenderOverview();
if (renderOverview == null) {
return;
}
WorldMapManager manager = renderOverview.getWorldMapManager();
if (manager != null && manager.isLoaded()) {
log.debug("World map was closed, reinitializing");
renderOverview.initializeWorldMap(renderOverview.getWorldMapData());
}
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class ShopItemQuery method getShopItems.
private Collection<WidgetItem> getShopItems(Client client) {
Collection<WidgetItem> widgetItems = new ArrayList<>();
Widget shop = client.getWidget(WidgetInfo.SHOP_ITEMS_CONTAINER);
if (shop != null && !shop.isHidden()) {
Widget[] children = shop.getDynamicChildren();
for (int i = 1; i < children.length; i++) {
// set bounds to same size as default inventory
Rectangle bounds = children[i].getBounds();
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
widgetItems.add(new WidgetItem(children[i].getItemId(), children[i].getItemQuantity(), i - 1, bounds));
}
}
return widgetItems;
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class KourendLibraryPlugin method onTick.
@Subscribe
void onTick(GameTick tick) {
if (lastBookcaseAnimatedOn != null) {
Widget find = client.getWidget(WidgetInfo.DIALOG_SPRITE_SPRITE);
if (find != null) {
Book book = Book.byId(find.getItemId());
if (book != null) {
library.mark(lastBookcaseAnimatedOn, book);
panel.update();
lastBookcaseAnimatedOn = null;
}
}
}
Widget npcHead = client.getWidget(WidgetInfo.DIALOG_NPC_HEAD_MODEL);
if (npcHead != null) {
LibraryCustomer cust = LibraryCustomer.getById(npcHead.getModelId());
if (cust != null) {
Widget textw = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT);
String text = textw.getText();
Matcher m = BOOK_EXTRACTOR.matcher(text);
if (m.find()) {
String bookName = TAG_MATCHER.matcher(m.group(1).replace("<br>", " ")).replaceAll("");
Book book = Book.byName(bookName);
if (book == null) {
log.warn("Book '{}' is not recognised", bookName);
return;
}
library.setCustomer(cust, book);
panel.update();
} else if (text.contains("You can have this other book") || text.contains("please accept a token of my thanks.") || text.contains("Thanks, I'll get on with reading it.")) {
library.setCustomer(null, null);
panel.update();
}
}
}
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class RSClientMixin method getGroup.
@Inject
@Override
public Widget[] getGroup(int groupId) {
RSWidget[][] widgets = getWidgets();
if (widgets == null || groupId < 0 || groupId >= widgets.length || widgets[groupId] == null) {
return null;
}
List<Widget> w = new ArrayList<Widget>();
for (Widget widget : widgets[groupId]) {
if (widget != null) {
w.add(widget);
}
}
return w.toArray(new Widget[w.size()]);
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class RSClientMixin method getWidgetRoots.
@Inject
@Override
public Widget[] getWidgetRoots() {
int topGroup = getWidgetRoot();
List<Widget> widgets = new ArrayList<Widget>();
for (Widget widget : getWidgets()[topGroup]) {
if (widget != null && widget.getParentId() == -1) {
widgets.add(widget);
}
}
return widgets.toArray(new Widget[widgets.size()]);
}
Aggregations