use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class ShiftClickInputListener method mouseClicked.
@Override
public MouseEvent mouseClicked(MouseEvent event) {
if (!config.shiftClickCustomization() || !isValidInventoryClick(event.getPoint())) {
return event;
}
final WidgetItem item = getClickedItem(event.getPoint());
final int button = event.getButton();
if (item != null) {
clientThread.invokeLater(() -> plugin.cycleItemShiftClickAction(item, button));
event.consume();
}
return event;
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class RunepouchOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
Query query = new InventoryWidgetItemQuery().idEquals(ItemID.RUNE_POUCH);
WidgetItem[] items = queryRunner.runQuery(query);
if (items.length == 0) {
return null;
}
WidgetItem runePouch = items[0];
Point location = runePouch.getCanvasLocation();
if (location == null) {
return null;
}
assert AMOUNT_VARBITS.length == RUNE_VARBITS.length;
graphics.setFont(FontManager.getRunescapeSmallFont());
StringBuilder tooltipBuilder = new StringBuilder();
for (int i = 0; i < AMOUNT_VARBITS.length; i++) {
Varbits amountVarbit = AMOUNT_VARBITS[i];
int amount = client.getSetting(amountVarbit);
if (amount <= 0) {
continue;
}
Varbits runeVarbit = RUNE_VARBITS[i];
int runeId = client.getSetting(runeVarbit);
Runes rune = Runes.getRune(runeId);
if (rune == null) {
continue;
}
tooltipBuilder.append(amount).append(" <col=ffff00>").append(rune.getName()).append("</col></br>");
if (config.showOnlyOnHover()) {
continue;
}
graphics.setColor(Color.black);
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 13 : 6), location.getY() + 14 + (graphics.getFontMetrics().getHeight() - 1) * i);
graphics.setColor(config.fontColor());
graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 12 : 5), location.getY() + 13 + (graphics.getFontMetrics().getHeight() - 1) * i);
if (!config.showIcons()) {
continue;
}
BufferedImage image = getRuneImage(rune);
if (image != null) {
OverlayUtil.renderImageLocation(graphics, new Point(location.getX(), location.getY() + graphics.getFontMetrics().getHeight() * i), image);
}
}
String tooltip = tooltipBuilder.toString();
if (!tooltip.isEmpty() && runePouch.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())) {
tooltipManager.add(new Tooltip(tooltip));
}
return null;
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class SlayerOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
if (!config.showItemOverlay()) {
return null;
}
int amount = plugin.getAmount();
if (amount <= 0) {
return null;
}
graphics.setFont(FontManager.getRunescapeSmallFont());
for (WidgetItem item : getSlayerWidgetItems()) {
int itemId = item.getId();
if (!slayerEquipment.contains(itemId) && !slayerJewelry.contains(itemId)) {
continue;
}
final Rectangle bounds = item.getCanvasBounds();
final TextComponent textComponent = new TextComponent();
textComponent.setText(String.valueOf(amount));
// Draw the counter in the bottom left for equipment, and top left for jewelry
textComponent.setPosition(new Point(bounds.x, bounds.y + (slayerJewelry.contains(itemId) ? bounds.height : graphics.getFontMetrics().getHeight())));
textComponent.render(graphics);
}
return null;
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class BindNeckOverlay method getNecklaceWidgetItems.
private Collection<WidgetItem> getNecklaceWidgetItems() {
Query inventoryQuery = new InventoryWidgetItemQuery().idEquals(BINDING_NECKLACE);
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_AMULET).idEquals(BINDING_NECKLACE);
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
Collection<WidgetItem> necklaces = new ArrayList<>();
necklaces.addAll(Arrays.asList(inventoryWidgetItems));
necklaces.addAll(Arrays.asList(equipmentWidgetItems));
return necklaces;
}
use of net.runelite.api.widgets.WidgetItem in project runelite by runelite.
the class RSWidgetMixin method getWidgetItem.
@Inject
@Override
public WidgetItem getWidgetItem(int index) {
int[] itemIds = getItemIds();
int[] itemQuantities = getItemQuantities();
if (itemIds == null || itemQuantities == null) {
return null;
}
// the number of item slot columns is stored here
int columns = getWidth();
int paddingX = getPaddingX();
int paddingY = getPaddingY();
int itemId = itemIds[index];
int itemQuantity = itemQuantities[index];
Point widgetCanvasLocation = getCanvasLocation();
if (itemId <= 0 || itemQuantity <= 0 || columns <= 0) {
return null;
}
int row = index / columns;
int col = index % columns;
int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + paddingX) * col);
int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + paddingY) * row);
Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
return new WidgetItem(itemId - 1, itemQuantity, index, bounds);
}
Aggregations