Update FishingSpot to use sprites

This commit is contained in:
Tyler Hardy
2017-10-19 12:19:45 -05:00
committed by Adam
parent 97f7bd0c48
commit 3afa41bd36
10 changed files with 21 additions and 43 deletions

View File

@@ -24,6 +24,8 @@
*/
package net.runelite.client.plugins.fishing;
import net.runelite.api.ItemID;
import java.util.HashMap;
import java.util.Map;
import static net.runelite.api.NpcID.FISHING_SPOT_1506;
@@ -58,32 +60,32 @@ import static net.runelite.api.NpcID.FISHING_SPOT_7734;
public enum FishingSpot
{
SHRIMP("Shrimp, Anchovies", "shrimp",
SHRIMP("Shrimp, Anchovies", ItemID.RAW_SHRIMPS,
FISHING_SPOT_1518, FISHING_SPOT_1525, FISHING_SPOT_1528,
FISHING_SPOT_1530, FISHING_SPOT_1544, FISHING_SPOT_7155,
FISHING_SPOT_7469
),
LOBSTER("Lobster, Swordfish, Tuna", "lobster",
LOBSTER("Lobster, Swordfish, Tuna", ItemID.RAW_LOBSTER,
FISHING_SPOT_1510, FISHING_SPOT_1519, FISHING_SPOT_1521,
FISHING_SPOT_1522, FISHING_SPOT_7199, FISHING_SPOT_7470
),
SHARK("Shark, Bass", "shark",
SHARK("Shark, Bass", ItemID.RAW_SHARK,
FISHING_SPOT_1511, FISHING_SPOT_1520, FISHING_SPOT_7200
),
MONKFISH("Monkfish", "monkfish",
MONKFISH("Monkfish", ItemID.RAW_MONKFISH,
FISHING_SPOT_4316
),
SALMON("Salmon, Trout", "salmon",
SALMON("Salmon, Trout", ItemID.RAW_SALMON,
FISHING_SPOT_1506, FISHING_SPOT_1508, FISHING_SPOT_1515,
FISHING_SPOT_1526, FISHING_SPOT_1527
),
BARB_FISH("Sturgeon, Salmon, Trout", "barb",
BARB_FISH("Sturgeon, Salmon, Trout", ItemID.LEAPING_STURGEON,
FISHING_SPOT_1542
),
ANGLERFISH("Anglerfish", "anglerfish",
ANGLERFISH("Anglerfish", ItemID.RAW_ANGLERFISH,
FISHING_SPOT_6825
),
MINNOW("Minnow", "minnow",
MINNOW("Minnow", ItemID.MINNOW,
FISHING_SPOT_7730, FISHING_SPOT_7731, FISHING_SPOT_7732, FISHING_SPOT_7733, FISHING_SPOT_7734
);
@@ -91,7 +93,7 @@ public enum FishingSpot
private static final Map<Integer, FishingSpot> fishingSpots = new HashMap<>();
private final String name;
private final String image;
private final int itemSpriteId;
private final int[] spots;
static
@@ -107,10 +109,10 @@ public enum FishingSpot
}
}
FishingSpot(String spot, String image, int... spots)
FishingSpot(String spot, int itemSpriteId, int... spots)
{
this.name = spot;
this.image = image;
this.itemSpriteId = itemSpriteId;
this.spots = spots;
}
@@ -119,9 +121,9 @@ public enum FishingSpot
return name;
}
public String getImage()
public int getItemSpriteId()
{
return image;
return itemSpriteId;
}
public int[] getIds()

View File

@@ -28,15 +28,12 @@ import com.google.common.primitives.Ints;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.NPC;
import net.runelite.api.SpritePixels;
import net.runelite.api.queries.NPCQuery;
import net.runelite.client.RuneLite;
import net.runelite.client.ui.overlay.Overlay;
@@ -49,8 +46,6 @@ class FishingSpotOverlay extends Overlay
{
private static final Logger logger = LoggerFactory.getLogger(FishingSpotOverlay.class);
private final BufferedImage[] imgCache = new BufferedImage[FishingSpot.values().length];
private final List<Integer> ids = new ArrayList<>();
private final RuneLite runelite = RuneLite.getRunelite();
@@ -86,10 +81,10 @@ class FishingSpotOverlay extends Overlay
Color color = npc.getId() == FishingSpot.FLYING_FISH ? Color.RED : Color.CYAN;
if (config.showIcons())
{
BufferedImage fishImage = getFishImage(spot);
if (fishImage != null)
SpritePixels fishSprite = getFishSprite(spot);
if (fishSprite != null)
{
OverlayUtil.renderActorOverlayImage(graphics, npc, fishImage, color.darker());
OverlayUtil.renderActorOverlaySprite(graphics, npc, fishSprite, color.darker());
}
}
else
@@ -102,28 +97,9 @@ class FishingSpotOverlay extends Overlay
return null;
}
private BufferedImage getFishImage(FishingSpot spot)
private SpritePixels getFishSprite(FishingSpot spot)
{
int fishIdx = spot.ordinal();
BufferedImage fishImage = null;
if (imgCache[fishIdx] != null)
{
return imgCache[fishIdx];
}
try
{
InputStream in = FishingSpotOverlay.class.getResourceAsStream(spot.getImage() + ".png");
fishImage = ImageIO.read(in);
imgCache[fishIdx] = fishImage;
}
catch (IOException e)
{
logger.warn("Error Loading fish icon", e);
}
return fishImage;
return client.createItemSprite(spot.getItemSpriteId(), 5, 1, SpritePixels.DEFAULT_SHADOW_COLOR, 0, false);
}
public void updateConfig()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB