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