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;
}
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;
}
Aggregations