death indicator plugin: Use Item IDs for overlays
This commit is contained in:
@@ -39,6 +39,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import static net.runelite.api.AnimationID.DEATH;
|
import static net.runelite.api.AnimationID.DEATH;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.api.events.AnimationChanged;
|
import net.runelite.api.events.AnimationChanged;
|
||||||
@@ -46,6 +47,7 @@ import net.runelite.api.events.ConfigChanged;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
@@ -66,7 +68,6 @@ public class DeathIndicatorPlugin extends Plugin
|
|||||||
12342, // Edgeville
|
12342, // Edgeville
|
||||||
11062 // Camelot
|
11062 // Camelot
|
||||||
);
|
);
|
||||||
static BufferedImage BONES;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
@@ -80,27 +81,17 @@ public class DeathIndicatorPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private InfoBoxManager infoBoxManager;
|
private InfoBoxManager infoBoxManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ItemManager itemManager;
|
||||||
|
|
||||||
|
private BufferedImage mapArrow;
|
||||||
|
|
||||||
private Timer deathTimer;
|
private Timer deathTimer;
|
||||||
|
|
||||||
private WorldPoint lastDeath;
|
private WorldPoint lastDeath;
|
||||||
private Instant lastDeathTime;
|
private Instant lastDeathTime;
|
||||||
private int lastDeathWorld;
|
private int lastDeathWorld;
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
synchronized (ImageIO.class)
|
|
||||||
{
|
|
||||||
BONES = ImageIO.read(DeathIndicatorPlugin.class.getResourceAsStream("bones.png"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
DeathIndicatorConfig deathIndicatorConfig(ConfigManager configManager)
|
DeathIndicatorConfig deathIndicatorConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -133,7 +124,7 @@ public class DeathIndicatorPlugin extends Plugin
|
|||||||
if (config.showDeathOnWorldMap())
|
if (config.showDeathOnWorldMap())
|
||||||
{
|
{
|
||||||
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
|
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
|
||||||
worldMapPointManager.add(new DeathWorldMapPoint(new WorldPoint(config.deathLocationX(), config.deathLocationY(), config.deathLocationPlane())));
|
worldMapPointManager.add(new DeathWorldMapPoint(new WorldPoint(config.deathLocationX(), config.deathLocationY(), config.deathLocationPlane()), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +195,7 @@ public class DeathIndicatorPlugin extends Plugin
|
|||||||
if (config.showDeathOnWorldMap())
|
if (config.showDeathOnWorldMap())
|
||||||
{
|
{
|
||||||
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
|
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
|
||||||
worldMapPointManager.add(new DeathWorldMapPoint(lastDeath));
|
worldMapPointManager.add(new DeathWorldMapPoint(lastDeath, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
resetInfobox();
|
resetInfobox();
|
||||||
@@ -290,7 +281,7 @@ public class DeathIndicatorPlugin extends Plugin
|
|||||||
if (config.showDeathOnWorldMap())
|
if (config.showDeathOnWorldMap())
|
||||||
{
|
{
|
||||||
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
|
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
|
||||||
worldMapPointManager.add(new DeathWorldMapPoint(deathPoint));
|
worldMapPointManager.add(new DeathWorldMapPoint(deathPoint, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -328,10 +319,37 @@ public class DeathIndicatorPlugin extends Plugin
|
|||||||
Duration timeLeft = Duration.ofHours(1).minus(Duration.between(config.timeOfDeath(), now));
|
Duration timeLeft = Duration.ofHours(1).minus(Duration.between(config.timeOfDeath(), now));
|
||||||
if (!timeLeft.isNegative() && !timeLeft.isZero())
|
if (!timeLeft.isNegative() && !timeLeft.isZero())
|
||||||
{
|
{
|
||||||
deathTimer = new Timer(timeLeft.getSeconds(), ChronoUnit.SECONDS, BONES, this);
|
deathTimer = new Timer(timeLeft.getSeconds(), ChronoUnit.SECONDS, getBonesImage(), this);
|
||||||
deathTimer.setTooltip("Died on world: " + config.deathWorld());
|
deathTimer.setTooltip("Died on world: " + config.deathWorld());
|
||||||
infoBoxManager.addInfoBox(deathTimer);
|
infoBoxManager.addInfoBox(deathTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedImage getBonesImage()
|
||||||
|
{
|
||||||
|
return itemManager.getImage(ItemID.BONES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,56 +26,40 @@ package net.runelite.client.plugins.deathindicator;
|
|||||||
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import static net.runelite.client.plugins.deathindicator.DeathIndicatorPlugin.BONES;
|
|
||||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||||
|
|
||||||
class DeathWorldMapPoint extends WorldMapPoint
|
class DeathWorldMapPoint extends WorldMapPoint
|
||||||
{
|
{
|
||||||
private static final BufferedImage WORLDMAP_HINT_ARROW;
|
private final DeathIndicatorPlugin plugin;
|
||||||
private static final Point WORLDMAP_HINT_ARROW_POINT;
|
private final BufferedImage worldmapHintArrow;
|
||||||
|
private final Point worldmapHintArrowPoint;
|
||||||
|
|
||||||
static
|
DeathWorldMapPoint(final WorldPoint worldPoint, final DeathIndicatorPlugin plugin)
|
||||||
{
|
|
||||||
BufferedImage MAP_ARROW;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
synchronized (ImageIO.class)
|
|
||||||
{
|
|
||||||
MAP_ARROW = ImageIO.read(DeathWorldMapPoint.class.getResourceAsStream("/util/clue_arrow.png"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
WORLDMAP_HINT_ARROW = new BufferedImage(MAP_ARROW.getWidth(),
|
|
||||||
MAP_ARROW.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
|
||||||
|
|
||||||
Graphics graphics = WORLDMAP_HINT_ARROW.getGraphics();
|
|
||||||
graphics.drawImage(MAP_ARROW, 0, 0, null);
|
|
||||||
graphics.drawImage(BONES, 0, 1, null);
|
|
||||||
WORLDMAP_HINT_ARROW_POINT = new Point(WORLDMAP_HINT_ARROW.getWidth() / 2, WORLDMAP_HINT_ARROW.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
DeathWorldMapPoint(final WorldPoint worldPoint)
|
|
||||||
{
|
{
|
||||||
super(worldPoint, null);
|
super(worldPoint, null);
|
||||||
|
|
||||||
|
worldmapHintArrow = new BufferedImage(plugin.getMapArrow().getWidth(), plugin.getMapArrow().getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics graphics = worldmapHintArrow.getGraphics();
|
||||||
|
graphics.drawImage(plugin.getMapArrow(), 0, 0, null);
|
||||||
|
graphics.drawImage(plugin.getBonesImage(), 0, 0, null);
|
||||||
|
worldmapHintArrowPoint = new Point(
|
||||||
|
worldmapHintArrow.getWidth() / 2,
|
||||||
|
worldmapHintArrow.getHeight());
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
this.setSnapToEdge(true);
|
this.setSnapToEdge(true);
|
||||||
this.setJumpOnClick(true);
|
this.setJumpOnClick(true);
|
||||||
this.setImage(WORLDMAP_HINT_ARROW);
|
this.setImage(worldmapHintArrow);
|
||||||
this.setImagePoint(WORLDMAP_HINT_ARROW_POINT);
|
this.setImagePoint(worldmapHintArrowPoint);
|
||||||
this.setTooltip("Death Location");
|
this.setTooltip("Death Location");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEdgeSnap()
|
public void onEdgeSnap()
|
||||||
{
|
{
|
||||||
this.setImage(BONES);
|
this.setImage(plugin.getBonesImage());
|
||||||
this.setImagePoint(null);
|
this.setImagePoint(null);
|
||||||
this.setTooltip(null);
|
this.setTooltip(null);
|
||||||
}
|
}
|
||||||
@@ -83,8 +67,8 @@ class DeathWorldMapPoint extends WorldMapPoint
|
|||||||
@Override
|
@Override
|
||||||
public void onEdgeUnsnap()
|
public void onEdgeUnsnap()
|
||||||
{
|
{
|
||||||
this.setImage(WORLDMAP_HINT_ARROW);
|
this.setImage(worldmapHintArrow);
|
||||||
this.setImagePoint(WORLDMAP_HINT_ARROW_POINT);
|
this.setImagePoint(worldmapHintArrowPoint);
|
||||||
this.setTooltip("Death Location");
|
this.setTooltip("Death Location");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 574 B |
Reference in New Issue
Block a user