use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class ClueScrollPlugin method findClueScroll.
private ClueScroll findClueScroll() {
Widget clueScrollText = client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT);
if (clueScrollText != null) {
// Remove line breaks and also the rare occasion where there are double line breaks
String text = clueScrollText.getText().replaceAll("-<br>", "-").replaceAll("<br>", " ").replaceAll("[ ]+", " ").toLowerCase();
if (clue != null && clue instanceof TextClueScroll) {
if (((TextClueScroll) clue).getText().equalsIgnoreCase(text)) {
return clue;
}
}
if (text.startsWith("this anagram reveals who to speak to next:")) {
return AnagramClue.forText(text);
} else if (text.startsWith("the cipher reveals who to speak to next:")) {
return CipherClue.forText(text);
} else if (text.contains("degrees") && text.contains("minutes")) {
return coordinatesToWorldPoint(text);
} else {
CrypticClue crypticClue = CrypticClue.forText(text);
if (crypticClue != null) {
return crypticClue;
}
EmoteClue emoteClue = EmoteClue.forText(text);
if (emoteClue != null) {
return emoteClue;
}
return FairyRingClue.forText(text);
}
}
Item[] result = queryRunner.runQuery(new InventoryItemQuery(InventoryID.INVENTORY));
if (result == null) {
return null;
}
for (Item item : result) {
MapClue clue = MapClue.forItemId(item.getId());
if (clue != null) {
return clue;
}
}
return null;
}
use of net.runelite.api.widgets.Widget 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.Widget 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.Widget in project runelite by runelite.
the class WidgetTreeNode method toString.
@Override
public String toString() {
Widget widget = getWidget();
int id = widget.getId();
WidgetInfo info = WidgetInspector.getWidgetInfo(id);
return type + " " + TO_GROUP(id) + "." + TO_CHILD(id) + ((info != null) ? " " + info.name() : "");
}
use of net.runelite.api.widgets.Widget 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