Search in sources :

Example 1 with Tooltip

use of net.runelite.client.ui.overlay.tooltip.Tooltip in project runelite by runelite.

the class ItemPricesOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (client.isMenuOpen()) {
        return null;
    }
    final MenuEntry[] menuEntries = client.getMenuEntries();
    final int last = menuEntries.length - 1;
    if (last < 0) {
        return null;
    }
    final MenuEntry menuEntry = menuEntries[last];
    final MenuAction action = MenuAction.of(menuEntry.getType());
    final int widgetId = menuEntry.getParam1();
    final int groupId = WidgetInfo.TO_GROUP(widgetId);
    // Tooltip action type handling
    switch(action) {
        case WIDGET_DEFAULT:
        case ITEM_USE:
        case ITEM_FIRST_OPTION:
        case ITEM_SECOND_OPTION:
        case ITEM_THIRD_OPTION:
        case ITEM_FOURTH_OPTION:
        case ITEM_FIFTH_OPTION:
            // Item tooltip values
            switch(groupId) {
                case WidgetID.INVENTORY_GROUP_ID:
                    if (config.hideInventory()) {
                        return null;
                    }
                // intentional fallthrough
                case WidgetID.BANK_GROUP_ID:
                case WidgetID.BANK_INVENTORY_GROUP_ID:
                    // Make tooltip
                    final String text = makeValueTooltip(menuEntry);
                    if (text != null) {
                        tooltipManager.add(new Tooltip("<col=eeeeee>" + text));
                    }
                    break;
            }
            break;
    }
    return null;
}
Also used : MenuAction(net.runelite.api.MenuAction) MenuEntry(net.runelite.api.MenuEntry) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip)

Example 2 with Tooltip

use of net.runelite.client.ui.overlay.tooltip.Tooltip in project runelite by runelite.

the class InfoBoxOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    List<InfoBox> infoBoxes = infoboxManager.getInfoBoxes();
    if (infoBoxes.isEmpty()) {
        return null;
    }
    int width = infoBoxes.size() * (BOXSIZE + SEPARATOR);
    int x = 0;
    for (InfoBox box : infoBoxes) {
        if (!box.render()) {
            continue;
        }
        final InfoBoxComponent infoBoxComponent = new InfoBoxComponent();
        infoBoxComponent.setColor(box.getTextColor());
        infoBoxComponent.setImage(box.getImage());
        infoBoxComponent.setText(box.getText());
        infoBoxComponent.setPosition(new Point(x, 0));
        final Dimension infoBoxBounds = infoBoxComponent.render(graphics);
        if (!Strings.isNullOrEmpty(box.getTooltip())) {
            final Rectangle intersectionRectangle = new Rectangle(infoBoxBounds);
            intersectionRectangle.setLocation(getBounds().getLocation());
            intersectionRectangle.translate(x, 0);
            final Point transformed = OverlayUtil.transformPosition(getPosition(), intersectionRectangle.getSize());
            intersectionRectangle.translate(transformed.x, transformed.y);
            final Client client = clientProvider.get();
            if (client != null && intersectionRectangle.contains(new Point(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY()))) {
                tooltipManager.add(new Tooltip(box.getTooltip()));
            }
        }
        x += BOXSIZE + SEPARATOR;
    }
    return new Dimension(width, BOXSIZE);
}
Also used : InfoBoxComponent(net.runelite.client.ui.overlay.components.InfoBoxComponent) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Dimension(java.awt.Dimension) Client(net.runelite.api.Client) Point(java.awt.Point)

Example 3 with Tooltip

use of net.runelite.client.ui.overlay.tooltip.Tooltip in project runelite by runelite.

the class MouseHighlightOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (client.isMenuOpen()) {
        return null;
    }
    MenuEntry[] menuEntries = client.getMenuEntries();
    int last = menuEntries.length - 1;
    if (last < 0) {
        return null;
    }
    MenuEntry menuEntry = menuEntries[last];
    String target = menuEntry.getTarget();
    String option = menuEntry.getOption();
    if (Strings.isNullOrEmpty(option)) {
        return null;
    }
    // Trivial options that don't need to be highlighted, add more as they appear.
    switch(option) {
        case "Walk here":
        case "Cancel":
        case "Continue":
            return null;
        case "Move":
            // Hide overlay on sliding puzzle boxes
            if (target.contains("Sliding piece")) {
                return null;
            }
    }
    final int widgetId = menuEntry.getParam1();
    final int groupId = WidgetInfo.TO_GROUP(widgetId);
    final int childId = WidgetInfo.TO_CHILD(widgetId);
    final Widget widget = client.getWidget(groupId, childId);
    if (!config.uiTooltip() && widget != null) {
        return null;
    }
    if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId()) {
        return null;
    }
    if (widget != null) {
        // If this varc is set, some CS is showing tooltip
        Varcs varcs = client.getVarcs();
        int tooltipTimeout = varcs.getIntVar(VarClient.TOOLTIP_TIMEOUT);
        if (tooltipTimeout > client.getGameCycle()) {
            return null;
        }
    }
    tooltipManager.addFront(new Tooltip(option + (Strings.isNullOrEmpty(target) ? "" : " " + target)));
    return null;
}
Also used : MenuEntry(net.runelite.api.MenuEntry) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) Widget(net.runelite.api.widgets.Widget) Varcs(net.runelite.api.Varcs)

Example 4 with Tooltip

use of net.runelite.client.ui.overlay.tooltip.Tooltip 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;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Query(net.runelite.api.Query) InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(net.runelite.api.Point) Point(net.runelite.api.Point) BufferedImage(java.awt.image.BufferedImage) Varbits(net.runelite.api.Varbits)

Example 5 with Tooltip

use of net.runelite.client.ui.overlay.tooltip.Tooltip 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;
}
Also used : InventoryWidgetItemQuery(net.runelite.api.queries.InventoryWidgetItemQuery) Tooltip(net.runelite.client.ui.overlay.tooltip.Tooltip) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point)

Aggregations

Tooltip (net.runelite.client.ui.overlay.tooltip.Tooltip)5 Point (java.awt.Point)2 MenuEntry (net.runelite.api.MenuEntry)2 InventoryWidgetItemQuery (net.runelite.api.queries.InventoryWidgetItemQuery)2 WidgetItem (net.runelite.api.widgets.WidgetItem)2 Dimension (java.awt.Dimension)1 Rectangle (java.awt.Rectangle)1 BufferedImage (java.awt.image.BufferedImage)1 Client (net.runelite.api.Client)1 MenuAction (net.runelite.api.MenuAction)1 Point (net.runelite.api.Point)1 Query (net.runelite.api.Query)1 Varbits (net.runelite.api.Varbits)1 Varcs (net.runelite.api.Varcs)1 Widget (net.runelite.api.widgets.Widget)1 InfoBoxComponent (net.runelite.client.ui.overlay.components.InfoBoxComponent)1