client: modify plugins to use WidgetItemOverlay
This commit is contained in:
@@ -25,65 +25,39 @@
|
||||
package net.runelite.client.plugins.inventorytags;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
|
||||
public class InventoryTagsOverlay extends Overlay
|
||||
public class InventoryTagsOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private final QueryRunner queryRunner;
|
||||
private final ItemManager itemManager;
|
||||
private final InventoryTagsPlugin plugin;
|
||||
|
||||
@Inject
|
||||
private InventoryTagsOverlay(QueryRunner queryRunner, ItemManager itemManager, InventoryTagsPlugin plugin)
|
||||
private InventoryTagsOverlay(ItemManager itemManager, InventoryTagsPlugin plugin)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.LOW);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.queryRunner = queryRunner;
|
||||
this.itemManager = itemManager;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
if (!plugin.isHasTaggedItems())
|
||||
final String group = plugin.getTag(itemId);
|
||||
if (group != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Now query the inventory for the tagged item ids
|
||||
final Query query = new InventoryWidgetItemQuery();
|
||||
final WidgetItem[] widgetItems = queryRunner.runQuery(query);
|
||||
|
||||
// Iterate through all found items and draw the outlines
|
||||
for (final WidgetItem item : widgetItems)
|
||||
{
|
||||
final String group = plugin.getTag(item.getId());
|
||||
|
||||
if (group != null)
|
||||
final Color color = plugin.getGroupNameColor(group);
|
||||
if (color != null)
|
||||
{
|
||||
final Color color = plugin.getGroupNameColor(group);
|
||||
if (color != null)
|
||||
{
|
||||
final BufferedImage outline = itemManager.getItemOutline(item.getId(), item.getQuantity(), color);
|
||||
graphics.drawImage(outline, item.getCanvasLocation().getX() + 1, item.getCanvasLocation().getY() + 1, null);
|
||||
}
|
||||
Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), color);
|
||||
graphics.drawImage(outline, (int) bounds.getX() + 1, (int) bounds.getY() + 1, null);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,9 @@ import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.MenuOpened;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
@@ -107,9 +101,6 @@ public class InventoryTagsPlugin extends Plugin
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean hasTaggedItems;
|
||||
|
||||
private boolean editorMode;
|
||||
|
||||
@Provides
|
||||
@@ -151,7 +142,7 @@ public class InventoryTagsPlugin extends Plugin
|
||||
{
|
||||
removeInventoryMenuOptions();
|
||||
overlayManager.remove(overlay);
|
||||
hasTaggedItems = editorMode = false;
|
||||
editorMode = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -179,14 +170,10 @@ public class InventoryTagsPlugin extends Plugin
|
||||
if (event.getMenuOption().equals(MENU_SET))
|
||||
{
|
||||
setTag(event.getId(), selectedMenu);
|
||||
|
||||
hasTaggedItems = true;
|
||||
}
|
||||
else if (event.getMenuOption().equals(MENU_REMOVE))
|
||||
{
|
||||
unsetTag(event.getId());
|
||||
|
||||
checkForTags(client.getItemContainer(InventoryID.INVENTORY));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,47 +222,6 @@ public class InventoryTagsPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onItemContainerChanged(ItemContainerChanged itemContainerChanged)
|
||||
{
|
||||
ItemContainer itemContainer = itemContainerChanged.getItemContainer();
|
||||
if (itemContainer == client.getItemContainer(InventoryID.INVENTORY))
|
||||
{
|
||||
checkForTags(itemContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForTags(ItemContainer itemContainer)
|
||||
{
|
||||
hasTaggedItems = false;
|
||||
|
||||
if (itemContainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] items = itemContainer.getItems();
|
||||
if (items != null)
|
||||
{
|
||||
for (Item item : items)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String tag = getTag(item.getId());
|
||||
if (tag == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
hasTaggedItems = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color getGroupNameColor(final String name)
|
||||
{
|
||||
switch (name)
|
||||
|
||||
@@ -24,125 +24,93 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.itemcharges;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.EquipmentItemQuery;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.*;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN;
|
||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
class ItemChargeOverlay extends Overlay
|
||||
class ItemChargeOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private final QueryRunner queryRunner;
|
||||
private final ItemChargePlugin itemChargePlugin;
|
||||
private final ItemChargeConfig config;
|
||||
|
||||
@Inject
|
||||
ItemChargeOverlay(QueryRunner queryRunner, ItemChargePlugin itemChargePlugin, ItemChargeConfig config)
|
||||
ItemChargeOverlay(ItemChargePlugin itemChargePlugin, ItemChargeConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.queryRunner = queryRunner;
|
||||
this.itemChargePlugin = itemChargePlugin;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
if (!displayOverlay())
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
for (WidgetItem item : getChargeWidgetItems())
|
||||
int charges;
|
||||
if (itemId == ItemID.DODGY_NECKLACE)
|
||||
{
|
||||
int charges;
|
||||
if (item.getId() == ItemID.DODGY_NECKLACE)
|
||||
if (!config.showDodgyCount())
|
||||
{
|
||||
if (!config.showDodgyCount())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
charges = config.dodgyNecklace();
|
||||
}
|
||||
else if (item.getId() == ItemID.BINDING_NECKLACE)
|
||||
{
|
||||
if (!config.showBindingNecklaceCharges())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
charges = config.bindingNecklace();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWithCharge chargeItem = ItemWithCharge.findItem(item.getId());
|
||||
if (chargeItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemChargeType type = chargeItem.getType();
|
||||
if ((type == TELEPORT && !config.showTeleportCharges())
|
||||
|| (type == FUNGICIDE_SPRAY && !config.showFungicideCharges())
|
||||
|| (type == IMPBOX && !config.showImpCharges())
|
||||
|| (type == WATERCAN && !config.showWateringCanCharges())
|
||||
|| (type == WATERSKIN && !config.showWaterskinCharges())
|
||||
|| (type == BELLOWS && !config.showBellowCharges())
|
||||
|| (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
charges = chargeItem.getCharges();
|
||||
return;
|
||||
}
|
||||
|
||||
final Rectangle bounds = item.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
|
||||
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
|
||||
textComponent.setColor(itemChargePlugin.getColor(charges));
|
||||
textComponent.render(graphics);
|
||||
charges = config.dodgyNecklace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else if (itemId == ItemID.BINDING_NECKLACE)
|
||||
{
|
||||
if (!config.showBindingNecklaceCharges())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private Collection<WidgetItem> getChargeWidgetItems()
|
||||
{
|
||||
Query inventoryQuery = new InventoryWidgetItemQuery();
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
charges = config.bindingNecklace();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId);
|
||||
if (chargeItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(
|
||||
WidgetInfo.EQUIPMENT_AMULET,
|
||||
WidgetInfo.EQUIPMENT_RING,
|
||||
WidgetInfo.EQUIPMENT_GLOVES,
|
||||
WidgetInfo.EQUIPMENT_WEAPON
|
||||
);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
ItemChargeType type = chargeItem.getType();
|
||||
if ((type == TELEPORT && !config.showTeleportCharges())
|
||||
|| (type == FUNGICIDE_SPRAY && !config.showFungicideCharges())
|
||||
|| (type == IMPBOX && !config.showImpCharges())
|
||||
|| (type == WATERCAN && !config.showWateringCanCharges())
|
||||
|| (type == WATERSKIN && !config.showWaterskinCharges())
|
||||
|| (type == BELLOWS && !config.showBellowCharges())
|
||||
|| (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<WidgetItem> jewellery = new ArrayList<>();
|
||||
jewellery.addAll(Arrays.asList(inventoryWidgetItems));
|
||||
jewellery.addAll(Arrays.asList(equipmentWidgetItems));
|
||||
return jewellery;
|
||||
charges = chargeItem.getCharges();
|
||||
}
|
||||
|
||||
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
|
||||
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
|
||||
textComponent.setColor(itemChargePlugin.getColor(charges));
|
||||
textComponent.render(graphics);
|
||||
}
|
||||
|
||||
private boolean displayOverlay()
|
||||
|
||||
@@ -32,24 +32,19 @@ import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.BOTH;
|
||||
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.MOUSE_HOVER;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
||||
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
public class RunepouchOverlay extends Overlay
|
||||
public class RunepouchOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private static final Varbits[] AMOUNT_VARBITS =
|
||||
{
|
||||
@@ -61,8 +56,6 @@ public class RunepouchOverlay extends Overlay
|
||||
};
|
||||
private static final Dimension IMAGE_SIZE = new Dimension(11, 11);
|
||||
|
||||
|
||||
private final QueryRunner queryRunner;
|
||||
private final Client client;
|
||||
private final RunepouchConfig config;
|
||||
private final TooltipManager tooltipManager;
|
||||
@@ -71,37 +64,26 @@ public class RunepouchOverlay extends Overlay
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Inject
|
||||
RunepouchOverlay(QueryRunner queryRunner, Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
||||
RunepouchOverlay(Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.tooltipManager = tooltipManager;
|
||||
this.queryRunner = queryRunner;
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
Query query = new InventoryWidgetItemQuery().idEquals(ItemID.RUNE_POUCH);
|
||||
WidgetItem[] items = queryRunner.runQuery(query);
|
||||
if (items.length == 0)
|
||||
if (itemId != ItemID.RUNE_POUCH)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
WidgetItem runePouch = items[0];
|
||||
Point location = runePouch.getCanvasLocation();
|
||||
if (location == null)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
assert AMOUNT_VARBITS.length == RUNE_VARBITS.length;
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
Point location = itemWidget.getCanvasLocation();
|
||||
StringBuilder tooltipBuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < AMOUNT_VARBITS.length; i++)
|
||||
@@ -158,12 +140,11 @@ public class RunepouchOverlay extends Overlay
|
||||
String tooltip = tooltipBuilder.toString();
|
||||
|
||||
if (!tooltip.isEmpty()
|
||||
&& runePouch.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())
|
||||
&& itemWidget.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())
|
||||
&& (config.runePouchOverlayMode() == MOUSE_HOVER || config.runePouchOverlayMode() == BOTH))
|
||||
{
|
||||
tooltipManager.add(new Tooltip(tooltip));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedImage getRuneImage(Runes rune)
|
||||
|
||||
@@ -24,111 +24,88 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import static com.google.common.collect.ObjectArrays.concat;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import com.google.common.primitives.ImmutableIntArray;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.EquipmentItemQuery;
|
||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
class SlayerOverlay extends Overlay
|
||||
class SlayerOverlay extends WidgetItemOverlay
|
||||
{
|
||||
private final static Set<Integer> SLAYER_JEWELRY = ImmutableSet.of(
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
);
|
||||
|
||||
private final static ImmutableIntArray ALL_SLAYER_ITEMS = ImmutableIntArray.of(
|
||||
ItemID.SLAYER_HELMET,
|
||||
ItemID.SLAYER_HELMET_I,
|
||||
ItemID.BLACK_SLAYER_HELMET,
|
||||
ItemID.BLACK_SLAYER_HELMET_I,
|
||||
ItemID.GREEN_SLAYER_HELMET,
|
||||
ItemID.GREEN_SLAYER_HELMET_I,
|
||||
ItemID.PURPLE_SLAYER_HELMET,
|
||||
ItemID.PURPLE_SLAYER_HELMET_I,
|
||||
ItemID.RED_SLAYER_HELMET,
|
||||
ItemID.RED_SLAYER_HELMET_I,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET_I,
|
||||
ItemID.HYDRA_SLAYER_HELMET,
|
||||
ItemID.HYDRA_SLAYER_HELMET_I,
|
||||
ItemID.SLAYER_RING_ETERNAL,
|
||||
ItemID.ENCHANTED_GEM,
|
||||
ItemID.ETERNAL_GEM,
|
||||
ItemID.BRACELET_OF_SLAUGHTER,
|
||||
ItemID.EXPEDITIOUS_BRACELET,
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
private final static Set<Integer> ALL_SLAYER_ITEMS = ImmutableSet.of(
|
||||
ItemID.SLAYER_HELMET,
|
||||
ItemID.SLAYER_HELMET_I,
|
||||
ItemID.BLACK_SLAYER_HELMET,
|
||||
ItemID.BLACK_SLAYER_HELMET_I,
|
||||
ItemID.GREEN_SLAYER_HELMET,
|
||||
ItemID.GREEN_SLAYER_HELMET_I,
|
||||
ItemID.PURPLE_SLAYER_HELMET,
|
||||
ItemID.PURPLE_SLAYER_HELMET_I,
|
||||
ItemID.RED_SLAYER_HELMET,
|
||||
ItemID.RED_SLAYER_HELMET_I,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET,
|
||||
ItemID.TURQUOISE_SLAYER_HELMET_I,
|
||||
ItemID.HYDRA_SLAYER_HELMET,
|
||||
ItemID.HYDRA_SLAYER_HELMET_I,
|
||||
ItemID.SLAYER_RING_ETERNAL,
|
||||
ItemID.ENCHANTED_GEM,
|
||||
ItemID.ETERNAL_GEM,
|
||||
ItemID.BRACELET_OF_SLAUGHTER,
|
||||
ItemID.EXPEDITIOUS_BRACELET,
|
||||
ItemID.SLAYER_RING_1,
|
||||
ItemID.SLAYER_RING_2,
|
||||
ItemID.SLAYER_RING_3,
|
||||
ItemID.SLAYER_RING_4,
|
||||
ItemID.SLAYER_RING_5,
|
||||
ItemID.SLAYER_RING_6,
|
||||
ItemID.SLAYER_RING_7,
|
||||
ItemID.SLAYER_RING_8
|
||||
);
|
||||
|
||||
private final SlayerConfig config;
|
||||
private final SlayerPlugin plugin;
|
||||
private final QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
private SlayerOverlay(SlayerPlugin plugin, SlayerConfig config, QueryRunner queryRunner)
|
||||
private SlayerOverlay(SlayerPlugin plugin, SlayerConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.queryRunner = queryRunner;
|
||||
}
|
||||
|
||||
private ImmutableList<WidgetItem> getSlayerItems()
|
||||
{
|
||||
int[] slayerItems = ALL_SLAYER_ITEMS.toArray();
|
||||
Query inventoryQuery = new InventoryWidgetItemQuery().idEquals(slayerItems);
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_HELMET, WidgetInfo.EQUIPMENT_RING, WidgetInfo.EQUIPMENT_GLOVES).idEquals(slayerItems);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
|
||||
WidgetItem[] items = concat(inventoryWidgetItems, equipmentWidgetItems, WidgetItem.class);
|
||||
return ImmutableList.copyOf(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||
{
|
||||
if (!ALL_SLAYER_ITEMS.contains(itemId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.showItemOverlay())
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = plugin.getAmount();
|
||||
if (amount <= 0)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
int slaughterCount = plugin.getSlaughterChargeCount();
|
||||
@@ -136,33 +113,26 @@ class SlayerOverlay extends Overlay
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
for (WidgetItem item : getSlayerItems())
|
||||
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
|
||||
switch (itemId)
|
||||
{
|
||||
int itemId = item.getId();
|
||||
|
||||
final Rectangle bounds = item.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
|
||||
switch (item.getId())
|
||||
{
|
||||
case ItemID.EXPEDITIOUS_BRACELET:
|
||||
textComponent.setText(String.valueOf(expeditiousCount));
|
||||
break;
|
||||
case ItemID.BRACELET_OF_SLAUGHTER:
|
||||
textComponent.setText(String.valueOf(slaughterCount));
|
||||
break;
|
||||
default:
|
||||
textComponent.setText(String.valueOf(amount));
|
||||
break;
|
||||
}
|
||||
|
||||
// Draw the counter in the bottom left for equipment, and top left for jewelry
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + (SLAYER_JEWELRY.contains(itemId)
|
||||
? bounds.height
|
||||
: graphics.getFontMetrics().getHeight())));
|
||||
textComponent.render(graphics);
|
||||
case ItemID.EXPEDITIOUS_BRACELET:
|
||||
textComponent.setText(String.valueOf(expeditiousCount));
|
||||
break;
|
||||
case ItemID.BRACELET_OF_SLAUGHTER:
|
||||
textComponent.setText(String.valueOf(slaughterCount));
|
||||
break;
|
||||
default:
|
||||
textComponent.setText(String.valueOf(amount));
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
// Draw the counter in the bottom left for equipment, and top left for jewelry
|
||||
textComponent.setPosition(new Point(bounds.x, bounds.y + (SLAYER_JEWELRY.contains(itemId)
|
||||
? bounds.height
|
||||
: graphics.getFontMetrics().getHeight())));
|
||||
textComponent.render(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user