use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class JewelleryCountOverlay method getJewelleryWidgetItems.
private Collection<WidgetItem> getJewelleryWidgetItems() {
Query inventoryQuery = new InventoryWidgetItemQuery();
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_AMULET, WidgetInfo.EQUIPMENT_RING, WidgetInfo.EQUIPMENT_GLOVES, WidgetInfo.EQUIPMENT_WEAPON);
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
Collection<WidgetItem> jewellery = new ArrayList<>();
jewellery.addAll(Arrays.asList(inventoryWidgetItems));
jewellery.addAll(Arrays.asList(equipmentWidgetItems));
return jewellery;
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class ItemStatOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
if (client.isMenuOpen() || (!config.relative() && !config.absolute() && !config.theoretical())) {
return null;
}
WidgetItem[] inventory = queryRunner.runQuery(new InventoryWidgetItemQuery());
Point mousePos = new Point(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY());
for (WidgetItem item : inventory) {
if (item.getCanvasBounds().contains(mousePos)) {
Effect change = statChanges.get(item.getId());
if (change != null) {
StringBuilder b = new StringBuilder();
StatsChanges statsChanges = change.calculate(client);
for (StatChange c : statsChanges.getStatChanges()) {
b.append(buildStatChangeString(c));
}
tooltipManager.add(new Tooltip(b.toString()));
}
}
}
return null;
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class DevToolsOverlay method renderInventory.
private void renderInventory(Graphics2D graphics) {
Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
if (inventoryWidget == null || inventoryWidget.isHidden()) {
return;
}
for (WidgetItem item : inventoryWidget.getWidgetItems()) {
Rectangle slotBounds = item.getCanvasBounds();
String idText = "" + item.getId();
FontMetrics fm = graphics.getFontMetrics();
Rectangle2D textBounds = fm.getStringBounds(idText, graphics);
int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2));
int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2));
graphics.setColor(new Color(255, 255, 255, 65));
graphics.fill(slotBounds);
graphics.setColor(Color.BLACK);
graphics.drawString(idText, textX + 1, textY + 1);
graphics.setColor(YELLOW);
graphics.drawString(idText, textX, textY);
}
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class GrandExchangePlugin method startUp.
@Override
protected void startUp() throws IOException {
panel = injector.getInstance(GrandExchangePanel.class);
BufferedImage icon;
synchronized (ImageIO.class) {
icon = ImageIO.read(getClass().getResourceAsStream("ge_icon.png"));
}
button = NavigationButton.builder().name("GE Offers").icon(icon).panel(panel).build();
pluginToolbar.addNavigation(button);
itemClick = new MouseListener() {
@Override
public MouseEvent mouseClicked(MouseEvent e) {
// Check if left click + alt
if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown()) {
Point mousePosition = client.getMouseCanvasPosition();
Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
if (inventoryWidget != null && !inventoryWidget.isHidden()) {
for (WidgetItem item : inventoryWidget.getWidgetItems()) {
if (item.getCanvasBounds().contains(mousePosition.getX(), mousePosition.getY())) {
ItemComposition itemComp = client.getItemDefinition(item.getId());
if (itemComp != null) {
e.consume();
SwingUtilities.invokeLater(() -> {
panel.showSearch();
if (!button.isSelected()) {
button.getOnSelect().run();
}
panel.getSearchPanel().priceLookup(itemComp.getName());
});
}
break;
}
}
}
}
return super.mouseClicked(e);
}
};
if (config.quickLookup()) {
mouseManager.registerMouseListener(itemClick);
}
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class ExaminePlugin method findExamineItem.
private void findExamineItem(PendingExamine pendingExamine) {
int quantity = 1;
int itemId = -1;
// Get widget
int widgetId = pendingExamine.getWidgetId();
int widgetGroup = TO_GROUP(widgetId);
int widgetChild = TO_CHILD(widgetId);
Widget widget = client.getWidget(widgetGroup, widgetChild);
if (widget == null) {
return;
}
if (pendingExamine.getType() == ExamineType.ITEM) {
WidgetItem widgetItem = widget.getWidgetItem(pendingExamine.getActionParam());
quantity = widgetItem != null ? widgetItem.getQuantity() : 1;
itemId = pendingExamine.getId();
} else if (pendingExamine.getType() == ExamineType.ITEM_BANK_EQ) {
if (WidgetInfo.EQUIPMENT.getGroupId() == widgetGroup) {
Widget widgetItem = widget.getChild(1);
if (widgetItem != null) {
quantity = widgetItem.getItemQuantity();
itemId = widgetItem.getItemId();
}
} else if (WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getGroupId() == widgetGroup || WidgetInfo.RUNE_POUCH_ITEM_CONTAINER.getGroupId() == widgetGroup) {
Widget widgetItem = widget.getChild(pendingExamine.getActionParam());
if (widgetItem != null) {
quantity = widgetItem.getItemQuantity();
itemId = widgetItem.getItemId();
}
} else if (WidgetInfo.BANK_ITEM_CONTAINER.getGroupId() == widgetGroup) {
Widget[] children = widget.getDynamicChildren();
if (pendingExamine.getActionParam() < children.length) {
Widget widgetItem = children[pendingExamine.getActionParam()];
quantity = widgetItem.getItemQuantity();
itemId = widgetItem.getItemId();
}
}
}
if (itemId == -1) {
return;
}
final int itemQuantity = quantity;
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
if (itemComposition != null) {
executor.submit(() -> getItemPrice(itemComposition, itemQuantity));
}
}
Aggregations