Search in sources :

Example 6 with TextComponent

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

Example 7 with TextComponent

use of net.runelite.client.ui.overlay.components.TextComponent in project runelite by runelite.

the class ShiftClickConfigurationOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!plugin.isConfiguringShiftClick() || client.isMenuOpen() || client.getWidget(WidgetInfo.INVENTORY).isHidden()) {
        return null;
    }
    Font font = FontManager.getRunescapeSmallFont();
    graphics.setFont(font);
    net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition();
    Point mousePoint = new Point(mouseCanvasPosition.getX(), mouseCanvasPosition.getY());
    for (WidgetItem item : plugin.getInventoryItems()) {
        final Rectangle bounds = item.getCanvasBounds();
        if (!bounds.contains(mousePoint)) {
            continue;
        }
        ItemComposition itemComposition = client.getItemDefinition(item.getId());
        String[] actions = itemComposition.getInventoryActions();
        int index = itemComposition.getShiftClickActionIndex();
        if (index >= 0 && actions[index] == null) {
            continue;
        }
        String action = index == -1 ? "Use" : actions[index];
        int textWidth = graphics.getFontMetrics().stringWidth(action);
        int textLocationX = (int) (bounds.x + bounds.getWidth() / 2 - textWidth / 2);
        int textLocationY = bounds.y + 28;
        final TextComponent textComponent = new TextComponent();
        textComponent.setPosition(new Point(textLocationX, textLocationY));
        textComponent.setText(action);
        textComponent.render(graphics);
    }
    return null;
}
Also used : TextComponent(net.runelite.client.ui.overlay.components.TextComponent) Rectangle(java.awt.Rectangle) ItemComposition(net.runelite.api.ItemComposition) WidgetItem(net.runelite.api.widgets.WidgetItem) Point(java.awt.Point) Font(java.awt.Font) Point(java.awt.Point)

Aggregations

Point (java.awt.Point)7 Rectangle (java.awt.Rectangle)7 TextComponent (net.runelite.client.ui.overlay.components.TextComponent)7 WidgetItem (net.runelite.api.widgets.WidgetItem)5 FontMetrics (java.awt.FontMetrics)2 BackgroundComponent (net.runelite.client.ui.overlay.components.BackgroundComponent)2 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 BufferedImage (java.awt.image.BufferedImage)1 Actor (net.runelite.api.Actor)1 ItemComposition (net.runelite.api.ItemComposition)1 ItemContainer (net.runelite.api.ItemContainer)1 NPC (net.runelite.api.NPC)1 Query (net.runelite.api.Query)1 Varbits (net.runelite.api.Varbits)1 InventoryWidgetItemQuery (net.runelite.api.queries.InventoryWidgetItemQuery)1 Widget (net.runelite.api.widgets.Widget)1 PuzzleState (net.runelite.client.plugins.puzzlesolver.solver.PuzzleState)1