clue scroll plugin: Use Item IDs for overlays

This commit is contained in:
Jordan Atwood
2018-07-18 15:46:11 -07:00
parent bcaa92905f
commit ecea2e28ca
12 changed files with 89 additions and 67 deletions

View File

@@ -47,6 +47,7 @@ import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemComposition;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID;
import net.runelite.api.NPC;
import net.runelite.api.Query;
import net.runelite.api.Scene;
@@ -96,11 +97,6 @@ public class ClueScrollPlugin extends Plugin
{
private static final Duration WAIT_DURATION = Duration.ofMinutes(4);
public static final BufferedImage CLUE_SCROLL_IMAGE;
public static final BufferedImage MAP_ARROW;
public static final BufferedImage EMOTE_IMAGE;
public static final BufferedImage SPADE_IMAGE;
@Getter
private ClueScroll clue;
@@ -147,28 +143,12 @@ public class ClueScrollPlugin extends Plugin
@Inject
private WorldMapPointManager worldMapPointManager;
private BufferedImage emoteImage;
private BufferedImage mapArrow;
private Integer clueItemId;
private boolean clueItemChanged = false;
private boolean worldMapPointsSet = false;
static
{
try
{
synchronized (ImageIO.class)
{
CLUE_SCROLL_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("clue_scroll.png"));
MAP_ARROW = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("/util/clue_arrow.png"));
EMOTE_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("emote.png"));
SPADE_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("spade.png"));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
@Provides
ClueScrollConfig getConfig(ConfigManager configManager)
{
@@ -411,6 +391,60 @@ public class ClueScrollPlugin extends Plugin
}
}
public BufferedImage getClueScrollImage()
{
return itemManager.getImage(ItemID.CLUE_SCROLL_MASTER);
}
public BufferedImage getEmoteImage()
{
if (emoteImage != null)
{
return emoteImage;
}
try
{
synchronized (ImageIO.class)
{
emoteImage = ImageIO.read(getClass().getResourceAsStream("emote.png"));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
return emoteImage;
}
public BufferedImage getSpadeImage()
{
return itemManager.getImage(ItemID.SPADE);
}
BufferedImage getMapArrow()
{
if (mapArrow != null)
{
return mapArrow;
}
try
{
synchronized (ImageIO.class)
{
mapArrow = ImageIO.read(getClass().getResourceAsStream("/util/clue_arrow.png"));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
return mapArrow;
}
private void resetClue()
{
if (!clueItemChanged)
@@ -594,7 +628,7 @@ public class ClueScrollPlugin extends Plugin
for (final WorldPoint point : points)
{
worldMapPointManager.add(new ClueScrollWorldMapPoint(point));
worldMapPointManager.add(new ClueScrollWorldMapPoint(point, this));
}
}
}

View File

@@ -32,41 +32,40 @@ import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
class ClueScrollWorldMapPoint extends WorldMapPoint
{
private static final BufferedImage CLUE_SCROLL_WORLD_IMAGE;
private static final Point CLUE_SCROLL_WORLD_IMAGE_POINT;
private final ClueScrollPlugin plugin;
private final BufferedImage clueScrollWorldImage;
private final Point clueScrollWorldImagePoint;
static
{
CLUE_SCROLL_WORLD_IMAGE = new BufferedImage(ClueScrollPlugin.MAP_ARROW.getWidth(), ClueScrollPlugin.MAP_ARROW.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics graphics = CLUE_SCROLL_WORLD_IMAGE.getGraphics();
graphics.drawImage(ClueScrollPlugin.MAP_ARROW, 0, 0, null);
graphics.drawImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE, 0, 2, null);
CLUE_SCROLL_WORLD_IMAGE_POINT = new Point(
CLUE_SCROLL_WORLD_IMAGE.getWidth() / 2,
CLUE_SCROLL_WORLD_IMAGE.getHeight());
}
ClueScrollWorldMapPoint(final WorldPoint worldPoint)
ClueScrollWorldMapPoint(final WorldPoint worldPoint, ClueScrollPlugin plugin)
{
super(worldPoint, null);
clueScrollWorldImage = new BufferedImage(plugin.getMapArrow().getWidth(), plugin.getMapArrow().getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics graphics = clueScrollWorldImage.getGraphics();
graphics.drawImage(plugin.getMapArrow(), 0, 0, null);
graphics.drawImage(plugin.getClueScrollImage(), 0, 0, null);
clueScrollWorldImagePoint = new Point(
clueScrollWorldImage.getWidth() / 2,
clueScrollWorldImage.getHeight());
this.plugin = plugin;
this.setSnapToEdge(true);
this.setJumpOnClick(true);
this.setImage(CLUE_SCROLL_WORLD_IMAGE);
this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT);
this.setImage(clueScrollWorldImage);
this.setImagePoint(clueScrollWorldImagePoint);
}
@Override
public void onEdgeSnap()
{
this.setImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE);
this.setImage(plugin.getClueScrollImage());
this.setImagePoint(null);
}
@Override
public void onEdgeUnsnap()
{
this.setImage(CLUE_SCROLL_WORLD_IMAGE);
this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT);
this.setImage(clueScrollWorldImage);
this.setImagePoint(clueScrollWorldImagePoint);
}
}

View File

@@ -33,7 +33,6 @@ import net.runelite.api.NPC;
import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.LineComponent;
@@ -203,7 +202,7 @@ public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueSc
{
for (NPC npc : plugin.getNpcsToMark())
{
OverlayUtil.renderActorOverlayImage(graphics, npc, CLUE_SCROLL_IMAGE, Color.ORANGE, IMAGE_Z_OFFSET);
OverlayUtil.renderActorOverlayImage(graphics, npc, plugin.getClueScrollImage(), Color.ORANGE, IMAGE_Z_OFFSET);
}
}
}

View File

@@ -33,7 +33,6 @@ import net.runelite.api.NPC;
import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.LineComponent;
@@ -112,7 +111,7 @@ public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScr
{
for (NPC npc : plugin.getNpcsToMark())
{
OverlayUtil.renderActorOverlayImage(graphics, npc, CLUE_SCROLL_IMAGE, Color.ORANGE, IMAGE_Z_OFFSET);
OverlayUtil.renderActorOverlayImage(graphics, npc, plugin.getClueScrollImage(), Color.ORANGE, IMAGE_Z_OFFSET);
}
}
}

View File

@@ -32,7 +32,6 @@ import net.runelite.api.ItemID;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
import net.runelite.client.plugins.cluescrolls.clues.emote.ItemRequirement;
import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement;
import net.runelite.client.ui.overlay.OverlayUtil;
@@ -77,6 +76,6 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati
return;
}
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE);
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
}
}

View File

@@ -38,8 +38,6 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_BORDER_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_HOVER_BORDER_COLOR;
@@ -391,7 +389,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
if (localLocation != null)
{
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE);
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
}
}
@@ -400,7 +398,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
{
for (NPC npc : plugin.getNpcsToMark())
{
OverlayUtil.renderActorOverlayImage(graphics, npc, CLUE_SCROLL_IMAGE, Color.ORANGE, IMAGE_Z_OFFSET);
OverlayUtil.renderActorOverlayImage(graphics, npc, plugin.getClueScrollImage(), Color.ORANGE, IMAGE_Z_OFFSET);
}
}
@@ -416,7 +414,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
OverlayUtil.renderHoverableArea(graphics, gameObject.getClickbox(), mousePosition,
CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR);
OverlayUtil.renderImageLocation(plugin.getClient(), graphics, gameObject.getLocalLocation(), CLUE_SCROLL_IMAGE, IMAGE_Z_OFFSET);
OverlayUtil.renderImageLocation(plugin.getClient(), graphics, gameObject.getLocalLocation(), plugin.getClueScrollImage(), IMAGE_Z_OFFSET);
}
}
}

View File

@@ -38,7 +38,6 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.EMOTE_IMAGE;
import net.runelite.client.plugins.cluescrolls.clues.emote.AllRequirementsCollection;
import net.runelite.client.plugins.cluescrolls.clues.emote.AnyRequirementCollection;
import net.runelite.client.plugins.cluescrolls.clues.emote.Emote;
@@ -285,7 +284,7 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
return;
}
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, EMOTE_IMAGE, Color.ORANGE);
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getEmoteImage(), Color.ORANGE);
}
public static EmoteClue forText(String text)

View File

@@ -34,7 +34,6 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
import net.runelite.client.plugins.cluescrolls.clues.emote.ItemRequirement;
import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement;
import net.runelite.client.ui.overlay.OverlayUtil;
@@ -102,7 +101,7 @@ public class FairyRingClue extends ClueScroll implements TextClueScroll, Locatio
return;
}
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE);
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
}
public static FairyRingClue forText(String text)

View File

@@ -45,8 +45,6 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
import net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea;
import net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdLocation;
@@ -196,7 +194,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
if (localLocation != null)
{
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE);
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
}
return;
@@ -210,7 +208,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
{
for (NPC npc : plugin.getNpcsToMark())
{
OverlayUtil.renderActorOverlayImage(graphics, npc, CLUE_SCROLL_IMAGE, Color.ORANGE, IMAGE_Z_OFFSET);
OverlayUtil.renderActorOverlayImage(graphics, npc, plugin.getClueScrollImage(), Color.ORANGE, IMAGE_Z_OFFSET);
}
}
}
@@ -229,7 +227,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
return;
}
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE);
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
}
}
}

View File

@@ -40,8 +40,6 @@ import static net.runelite.api.ObjectID.CRATE_6616;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_BORDER_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_HOVER_BORDER_COLOR;
@@ -179,14 +177,14 @@ public class MapClue extends ClueScroll implements ObjectClueScroll
OverlayUtil.renderHoverableArea(graphics, gameObject.getClickbox(), mousePosition,
CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR);
OverlayUtil.renderImageLocation(plugin.getClient(), graphics, gameObject.getLocalLocation(), CLUE_SCROLL_IMAGE, IMAGE_Z_OFFSET);
OverlayUtil.renderImageLocation(plugin.getClient(), graphics, gameObject.getLocalLocation(), plugin.getClueScrollImage(), IMAGE_Z_OFFSET);
}
}
}
// Mark tile
else
{
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE);
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB