Improve performance of ClueScrollWorldMapPoint
- Create the buffered image only once and not every time ClueScrollWorldMapPoint is created - Pass the world point directly to clue world map point constructor and do it only once Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -596,9 +596,8 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (worldMapPoint == null)
|
if (worldMapPoint == null)
|
||||||
{
|
{
|
||||||
worldMapPoint = new ClueScrollWorldMapPoint();
|
worldMapPoint = new ClueScrollWorldMapPoint(point);
|
||||||
worldMapPointManager.add(worldMapPoint);
|
worldMapPointManager.add(worldMapPoint);
|
||||||
}
|
}
|
||||||
worldMapPoint.setWorldPoint(point);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,44 +27,46 @@ package net.runelite.client.plugins.cluescrolls;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||||
|
|
||||||
class ClueScrollWorldMapPoint extends WorldMapPoint
|
class ClueScrollWorldMapPoint extends WorldMapPoint
|
||||||
{
|
{
|
||||||
private final BufferedImage worldMapImage;
|
private static final BufferedImage CLUE_SCROLL_WORLD_IMAGE;
|
||||||
private final Point imagePoint;
|
private static final Point CLUE_SCROLL_WORLD_IMAGE_POINT;
|
||||||
private final BufferedImage edgeSnapImage;
|
|
||||||
|
|
||||||
ClueScrollWorldMapPoint()
|
static
|
||||||
{
|
{
|
||||||
super(null, null);
|
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)
|
||||||
|
{
|
||||||
|
super(worldPoint, null);
|
||||||
|
|
||||||
this.setSnapToEdge(true);
|
this.setSnapToEdge(true);
|
||||||
this.setJumpOnClick(true);
|
this.setJumpOnClick(true);
|
||||||
|
this.setImage(CLUE_SCROLL_WORLD_IMAGE);
|
||||||
worldMapImage = new BufferedImage(ClueScrollPlugin.MAP_ARROW.getWidth(), ClueScrollPlugin.MAP_ARROW.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT);
|
||||||
Graphics graphics = worldMapImage.getGraphics();
|
|
||||||
graphics.drawImage(ClueScrollPlugin.MAP_ARROW, 0, 0, null);
|
|
||||||
graphics.drawImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE, 0, 2, null);
|
|
||||||
|
|
||||||
imagePoint = new Point(worldMapImage.getWidth() / 2, worldMapImage.getHeight());
|
|
||||||
this.setImage(worldMapImage);
|
|
||||||
this.setImagePoint(imagePoint);
|
|
||||||
|
|
||||||
edgeSnapImage = ClueScrollPlugin.CLUE_SCROLL_IMAGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEdgeSnap()
|
public void onEdgeSnap()
|
||||||
{
|
{
|
||||||
this.setImage(edgeSnapImage);
|
this.setImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE);
|
||||||
this.setImagePoint(null);
|
this.setImagePoint(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEdgeUnsnap()
|
public void onEdgeUnsnap()
|
||||||
{
|
{
|
||||||
this.setImage(worldMapImage);
|
this.setImage(CLUE_SCROLL_WORLD_IMAGE);
|
||||||
this.setImagePoint(imagePoint);
|
this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user