Skip to content

Commit

Permalink
xp globes: remove double call to getSkillImage
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Jun 18, 2017
1 parent a3d3f95 commit 437e99f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.Overlay;

import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

Expand Down Expand Up @@ -71,7 +69,7 @@ public Overlay getOverlay()
}

@Subscribe
private void onExperienceChanged(ExperienceChanged event)
public void onExperienceChanged(ExperienceChanged event)
{
if (!config.enabled())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@

public class XpGlobesOverlay extends Overlay
{
private static final Logger logger = LoggerFactory.getLogger(XpGlobesOverlay.class);

private final XpGlobes plugin;
private final Client client = RuneLite.getClient();
private final XpGlobesConfig config;
private static final Logger logger = LoggerFactory.getLogger(XpGlobesOverlay.class);

private static final int DEFAULT_CIRCLE_WIDTH = 40;
private static final int DEFAULT_CIRCLE_HEIGHT = 40;
Expand Down Expand Up @@ -117,20 +117,20 @@ private void renderProgressCircle(Graphics2D graphics, XpGlobe skillToDraw, int

drawEllipse(graphics, x, y);
drawProgressArc(
graphics,
x, y,
DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT,
PROGRESS_RADIUS_REMAINDER, radiusToGoalXp,
5,
DEFAULT_PROGRESS_REMAINDER_ARC_COLOR
graphics,
x, y,
DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT,
PROGRESS_RADIUS_REMAINDER, radiusToGoalXp,
5,
DEFAULT_PROGRESS_REMAINDER_ARC_COLOR
);
drawProgressArc(
graphics,
x, y,
DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT,
PROGRESS_RADIUS_START, radiusCurrentXp,
2,
DEFAULT_PROGRESS_ARC_COLOR);
graphics,
x, y,
DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT,
PROGRESS_RADIUS_START, radiusCurrentXp,
2,
DEFAULT_PROGRESS_ARC_COLOR);

drawSkillImage(graphics, skillToDraw, x, y);
}
Expand All @@ -140,10 +140,10 @@ private void drawProgressArc(Graphics2D graphics, int x, int y, int w, int h, do
graphics.setStroke(new BasicStroke(strokeWidth));
graphics.setColor(color);
graphics.draw(new Arc2D.Double(
x, y,
w, h,
radiusStart, radiusEnd,
Arc2D.OPEN));
x, y,
w, h,
radiusStart, radiusEnd,
Arc2D.OPEN));
}

private void drawEllipse(Graphics2D graphics, int x, int y)
Expand All @@ -157,11 +157,17 @@ private void drawEllipse(Graphics2D graphics, int x, int y)
private void drawSkillImage(Graphics2D graphics, XpGlobe xpGlobe, int x, int y)
{
BufferedImage skillImage = getSkillImage(xpGlobe);

if (skillImage == null)
{
return;
}

graphics.drawImage(
getSkillImage(xpGlobe),
x + (DEFAULT_CIRCLE_WIDTH / 2) - (skillImage.getWidth() / 2),
y + (DEFAULT_CIRCLE_HEIGHT / 2) - (skillImage.getHeight() / 2),
null
skillImage,
x + (DEFAULT_CIRCLE_WIDTH / 2) - (skillImage.getWidth() / 2),
y + (DEFAULT_CIRCLE_HEIGHT / 2) - (skillImage.getHeight() / 2),
null
);
}

Expand All @@ -174,7 +180,7 @@ private BufferedImage getSkillImage(XpGlobe xpGlobe)
{
return imgCache[skillIdx];
}

try
{
String skillIconPath = "/skill_icons/" + xpGlobe.getSkillName().toLowerCase() + ".png";
Expand Down

0 comments on commit 437e99f

Please sign in to comment.