Merge pull request #4604 from Nightfirecat/exterminate-game-image-files

Remove item and sprite images from runelite-client resources directory
This commit is contained in:
Tomas Slusny
2018-08-04 12:59:02 +02:00
committed by GitHub
129 changed files with 1316 additions and 884 deletions

View File

@@ -28,16 +28,17 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.ColorModel; import java.awt.image.ColorModel;
import java.awt.image.DataBufferByte; import java.awt.image.DataBufferByte;
import java.awt.image.IndexColorModel; import java.awt.image.IndexColorModel;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO; import javax.annotation.Nonnull;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -46,26 +47,33 @@ import net.runelite.api.ClanMemberRank;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.IndexedSprite; import net.runelite.api.IndexedSprite;
import net.runelite.api.SpriteID;
import net.runelite.api.events.ClanChanged; import net.runelite.api.events.ClanChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@Singleton @Singleton
@Slf4j @Slf4j
public class ClanManager public class ClanManager
{ {
private static final String[] CLANCHAT_IMAGES = private static final int[] CLANCHAT_IMAGES =
{ {
"Friend_clan_rank.png", "Recruit_clan_rank.png", SpriteID.CLAN_CHAT_RANK_SMILEY_FRIEND,
"Corporal_clan_rank.png", "Sergeant_clan_rank.png", SpriteID.CLAN_CHAT_RANK_SINGLE_CHEVRON_RECRUIT,
"Lieutenant_clan_rank.png", "Captain_clan_rank.png", SpriteID.CLAN_CHAT_RANK_DOUBLE_CHEVRON_CORPORAL,
"General_clan_rank.png", "Owner_clan_rank.png", SpriteID.CLAN_CHAT_RANK_TRIPLE_CHEVRON_SERGEANT,
"JMod_clan_rank.png" SpriteID.CLAN_CHAT_RANK_BRONZE_STAR_LIEUTENANT,
SpriteID.CLAN_CHAT_RANK_SILVER_STAR_CAPTAIN,
SpriteID.CLAN_CHAT_RANK_GOLD_STAR_GENERAL,
SpriteID.CLAN_CHAT_RANK_KEY_CHANNEL_OWNER,
SpriteID.CLAN_CHAT_RANK_CROWN_JAGEX_MODERATOR,
}; };
private static final Dimension CLANCHAT_IMAGE_DIMENSION = new Dimension(11, 11);
private int modIconsLength; private static final Color CLANCHAT_IMAGE_OUTLINE_COLOR = new Color(33, 33, 33);
private final Client client; private final Client client;
private final SpriteManager spriteManager;
private final BufferedImage[] clanChatImages = new BufferedImage[CLANCHAT_IMAGES.length]; private final BufferedImage[] clanChatImages = new BufferedImage[CLANCHAT_IMAGES.length];
private final LoadingCache<String, ClanMemberRank> clanRanksCache = CacheBuilder.newBuilder() private final LoadingCache<String, ClanMemberRank> clanRanksCache = CacheBuilder.newBuilder()
@@ -74,7 +82,7 @@ public class ClanManager
.build(new CacheLoader<String, ClanMemberRank>() .build(new CacheLoader<String, ClanMemberRank>()
{ {
@Override @Override
public ClanMemberRank load(String key) throws Exception public ClanMemberRank load(@Nonnull String key)
{ {
final ClanMember[] clanMembersArr = client.getClanMembers(); final ClanMember[] clanMembersArr = client.getClanMembers();
@@ -92,27 +100,13 @@ public class ClanManager
} }
}); });
private int modIconsLength;
@Inject @Inject
private ClanManager(Client client) private ClanManager(Client client, SpriteManager spriteManager)
{ {
this.client = client; this.client = client;
this.spriteManager = spriteManager;
int i = 0;
for (String resource : CLANCHAT_IMAGES)
{
try
{
final BufferedImage bufferedImage = rgbaToIndexedBufferedImage(ImageIO
.read(ClanManager.class.getResource(resource)));
clanChatImages[i] = bufferedImage;
}
catch (IOException e)
{
log.warn("unable to load clan image", e);
}
++i;
}
} }
public ClanMemberRank getRank(String playerName) public ClanMemberRank getRank(String playerName)
@@ -138,10 +132,9 @@ public class ClanManager
@Subscribe @Subscribe
public void onGameStateChanged(GameStateChanged gameStateChanged) public void onGameStateChanged(GameStateChanged gameStateChanged)
{ {
if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN if (gameStateChanged.getGameState() == GameState.LOGGED_IN
&& modIconsLength == 0) && modIconsLength == 0)
{ {
// this is after "Loading sprites" so we can modify modicons now
loadClanChatIcons(); loadClanChatIcons();
} }
} }
@@ -154,25 +147,19 @@ public class ClanManager
private void loadClanChatIcons() private void loadClanChatIcons()
{ {
try final IndexedSprite[] modIcons = client.getModIcons();
{ final IndexedSprite[] newModIcons = Arrays.copyOf(modIcons, modIcons.length + CLANCHAT_IMAGES.length);
final IndexedSprite[] modIcons = client.getModIcons(); int curPosition = newModIcons.length - CLANCHAT_IMAGES.length;
final IndexedSprite[] newModIcons = Arrays.copyOf(modIcons, modIcons.length + CLANCHAT_IMAGES.length);
int curPosition = newModIcons.length - CLANCHAT_IMAGES.length;
for (BufferedImage image : clanChatImages) for (int i = 0; i < CLANCHAT_IMAGES.length; i++, curPosition++)
{
IndexedSprite sprite = createIndexedSprite(client, image);
newModIcons[curPosition++] = sprite;
}
client.setModIcons(newModIcons);
modIconsLength = newModIcons.length;
}
catch (IOException e)
{ {
log.warn("Failed loading of clan chat icons", e); final int resource = CLANCHAT_IMAGES[i];
clanChatImages[i] = rgbaToIndexedBufferedImage(clanChatImageFromSprite(spriteManager.getSprite(resource, 0)));
newModIcons[curPosition] = createIndexedSprite(client, clanChatImages[i]);
} }
client.setModIcons(newModIcons);
modIconsLength = newModIcons.length;
} }
private static String sanitize(String lookup) private static String sanitize(String lookup)
@@ -181,7 +168,7 @@ public class ClanManager
return cleaned.replace('\u00A0', ' '); return cleaned.replace('\u00A0', ' ');
} }
private static IndexedSprite createIndexedSprite(final Client client, final BufferedImage bufferedImage) throws IOException private static IndexedSprite createIndexedSprite(final Client client, final BufferedImage bufferedImage)
{ {
final IndexColorModel indexedCM = (IndexColorModel) bufferedImage.getColorModel(); final IndexColorModel indexedCM = (IndexColorModel) bufferedImage.getColorModel();
@@ -228,4 +215,10 @@ public class ClanManager
resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null); resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null);
return resultIndexedImage; return resultIndexedImage;
} }
private static BufferedImage clanChatImageFromSprite(final BufferedImage clanSprite)
{
final BufferedImage clanChatCanvas = ImageUtil.resizeCanvas(clanSprite, CLANCHAT_IMAGE_DIMENSION.width, CLANCHAT_IMAGE_DIMENSION.height);
return ImageUtil.outlineImage(clanChatCanvas, CLANCHAT_IMAGE_OUTLINE_COLOR);
}
} }

View File

@@ -25,11 +25,10 @@
package net.runelite.client.game; package net.runelite.client.game;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import net.runelite.client.util.ImageUtil;
@Singleton @Singleton
@Slf4j @Slf4j
@@ -48,21 +47,11 @@ public class SkillIconManager
return imgCache[skillIdx]; return imgCache[skillIdx];
} }
try String skillIconPath = (small ? "/skill_icons_small/" : "/skill_icons/")
{ + skill.getName().toLowerCase() + ".png";
String skillIconPath = (small ? "/skill_icons_small/" : "/skill_icons/") log.debug("Loading skill icon from {}", skillIconPath);
+ skill.getName().toLowerCase() + ".png"; skillImage = ImageUtil.getResourceStreamFromClass(getClass(), skillIconPath);
log.debug("Loading skill icon from {}", skillIconPath); imgCache[skillIdx] = skillImage;
synchronized (ImageIO.class)
{
skillImage = ImageIO.read(SkillIconManager.class.getResourceAsStream(skillIconPath));
}
imgCache[skillIdx] = skillImage;
}
catch (IOException e)
{
log.debug("Error Loading skill icons {}", e);
}
return skillImage; return skillImage;
} }

View File

@@ -26,9 +26,7 @@ package net.runelite.client.plugins.account;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -40,6 +38,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.RunnableExceptionLogger; import net.runelite.client.util.RunnableExceptionLogger;
@PluginDescriptor( @PluginDescriptor(
@@ -67,18 +66,8 @@ public class AccountPlugin extends Plugin
static static
{ {
try LOGIN_IMAGE = ImageUtil.getResourceStreamFromClass(AccountPlugin.class, "login_icon.png");
{ LOGOUT_IMAGE = ImageUtil.getResourceStreamFromClass(AccountPlugin.class, "logout_icon.png");
synchronized (ImageIO.class)
{
LOGIN_IMAGE = ImageIO.read(AccountPlugin.class.getResourceAsStream("login_icon.png"));
LOGOUT_IMAGE = ImageIO.read(AccountPlugin.class.getResourceAsStream("logout_icon.png"));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
@Override @Override

View File

@@ -25,9 +25,7 @@
package net.runelite.client.plugins.agility; package net.runelite.client.plugins.agility;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import javax.imageio.ImageIO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.Timer; import net.runelite.client.ui.overlay.infobox.Timer;
@@ -35,32 +33,9 @@ import net.runelite.client.ui.overlay.infobox.Timer;
@Slf4j @Slf4j
class AgilityArenaTimer extends Timer class AgilityArenaTimer extends Timer
{ {
AgilityArenaTimer(Plugin plugin) AgilityArenaTimer(Plugin plugin, BufferedImage image)
{ {
super(1, ChronoUnit.MINUTES, getTicketImage(), plugin); super(1, ChronoUnit.MINUTES, image, plugin);
setTooltip("Time left until location changes"); setTooltip("Time left until location changes");
} }
private static BufferedImage image;
private static BufferedImage getTicketImage()
{
if (image != null)
{
return image;
}
try
{
synchronized (ImageIO.class)
{
image = ImageIO.read(AgilityArenaTimer.class.getResourceAsStream( "agilityarenaticket.png"));
}
}
catch (IOException ex)
{
log.warn("unable to load image", ex);
}
return image;
}
} }

View File

@@ -35,6 +35,7 @@ import lombok.Getter;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import static net.runelite.api.ItemID.AGILITY_ARENA_TICKET;
import net.runelite.api.Player; import net.runelite.api.Player;
import static net.runelite.api.Skill.AGILITY; import static net.runelite.api.Skill.AGILITY;
import net.runelite.api.Tile; import net.runelite.api.Tile;
@@ -60,6 +61,7 @@ import net.runelite.api.events.WallObjectDespawned;
import net.runelite.api.events.WallObjectSpawned; import net.runelite.api.events.WallObjectSpawned;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
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.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@@ -101,6 +103,9 @@ public class AgilityPlugin extends Plugin
@Inject @Inject
private AgilityConfig config; private AgilityConfig config;
@Inject
private ItemManager itemManager;
@Getter @Getter
private AgilitySession session; private AgilitySession session;
@@ -275,7 +280,7 @@ public class AgilityPlugin extends Plugin
private void showNewAgilityArenaTimer() private void showNewAgilityArenaTimer()
{ {
removeAgilityArenaTimer(); removeAgilityArenaTimer();
infoBoxManager.addInfoBox(new AgilityArenaTimer(this)); infoBoxManager.addInfoBox(new AgilityArenaTimer(this, itemManager.getImage(AGILITY_ARENA_TICKET)));
} }
@Subscribe @Subscribe

View File

@@ -30,7 +30,6 @@ import java.awt.Font;
import java.awt.Image; import java.awt.Image;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
@@ -46,6 +45,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Barbarian Assault", name = "Barbarian Assault",
@@ -87,10 +87,7 @@ public class BarbarianAssaultPlugin extends Plugin
font = FontManager.getRunescapeFont() font = FontManager.getRunescapeFont()
.deriveFont(Font.BOLD, 24); .deriveFont(Font.BOLD, 24);
synchronized (ImageIO.class) clockImage = ImageUtil.getResourceStreamFromClass(getClass(), "clock.png");
{
clockImage = ImageIO.read(getClass().getResourceAsStream("clock.png"));
}
} }
@Override @Override

View File

@@ -30,7 +30,6 @@ import com.google.inject.Provides;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.Getter; import lombok.Getter;
@@ -49,6 +48,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Boosts Information", name = "Boosts Information",
@@ -118,11 +118,8 @@ public class BoostsPlugin extends Plugin
Arrays.fill(lastSkillLevels, -1); Arrays.fill(lastSkillLevels, -1);
// Add infoboxes for everything at startup and then determine inside if it will be rendered // Add infoboxes for everything at startup and then determine inside if it will be rendered
synchronized (ImageIO.class) infoBoxManager.addInfoBox(new StatChangeIndicator(true, ImageUtil.getResourceStreamFromClass(getClass(), "debuffed.png"), this, config));
{ infoBoxManager.addInfoBox(new StatChangeIndicator(false, ImageUtil.getResourceStreamFromClass(getClass(), "buffed.png"), this, config));
infoBoxManager.addInfoBox(new StatChangeIndicator(true, ImageIO.read(getClass().getResourceAsStream("debuffed.png")), this, config));
infoBoxManager.addInfoBox(new StatChangeIndicator(false, ImageIO.read(getClass().getResourceAsStream("buffed.png")), this, config));
}
for (final Skill skill : Skill.values()) for (final Skill skill : Skill.values())
{ {

View File

@@ -29,13 +29,11 @@ package net.runelite.client.plugins.cluescrolls;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -47,6 +45,7 @@ import net.runelite.api.InventoryID;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.Query; import net.runelite.api.Query;
import net.runelite.api.Scene; import net.runelite.api.Scene;
@@ -83,6 +82,7 @@ import net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll;
import net.runelite.client.plugins.cluescrolls.clues.TextClueScroll; import net.runelite.client.plugins.cluescrolls.clues.TextClueScroll;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.QueryRunner; import net.runelite.client.util.QueryRunner;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@@ -96,11 +96,6 @@ public class ClueScrollPlugin extends Plugin
{ {
private static final Duration WAIT_DURATION = Duration.ofMinutes(4); 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 @Getter
private ClueScroll clue; private ClueScroll clue;
@@ -147,28 +142,12 @@ public class ClueScrollPlugin extends Plugin
@Inject @Inject
private WorldMapPointManager worldMapPointManager; private WorldMapPointManager worldMapPointManager;
private BufferedImage emoteImage;
private BufferedImage mapArrow;
private Integer clueItemId; private Integer clueItemId;
private boolean clueItemChanged = false; private boolean clueItemChanged = false;
private boolean worldMapPointsSet = 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("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 @Provides
ClueScrollConfig getConfig(ConfigManager configManager) ClueScrollConfig getConfig(ConfigManager configManager)
{ {
@@ -411,6 +390,40 @@ public class ClueScrollPlugin extends Plugin
} }
} }
public BufferedImage getClueScrollImage()
{
return itemManager.getImage(ItemID.CLUE_SCROLL_MASTER);
}
public BufferedImage getEmoteImage()
{
if (emoteImage != null)
{
return emoteImage;
}
emoteImage = ImageUtil.getResourceStreamFromClass(getClass(), "emote.png");
return emoteImage;
}
public BufferedImage getSpadeImage()
{
return itemManager.getImage(ItemID.SPADE);
}
BufferedImage getMapArrow()
{
if (mapArrow != null)
{
return mapArrow;
}
mapArrow = ImageUtil.getResourceStreamFromClass(getClass(), "/util/clue_arrow.png");
return mapArrow;
}
private void resetClue() private void resetClue()
{ {
if (!clueItemChanged) if (!clueItemChanged)
@@ -594,7 +607,7 @@ public class ClueScrollPlugin extends Plugin
for (final WorldPoint point : points) 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 class ClueScrollWorldMapPoint extends WorldMapPoint
{ {
private static final BufferedImage CLUE_SCROLL_WORLD_IMAGE; private final ClueScrollPlugin plugin;
private static final Point CLUE_SCROLL_WORLD_IMAGE_POINT; private final BufferedImage clueScrollWorldImage;
private final Point clueScrollWorldImagePoint;
static ClueScrollWorldMapPoint(final WorldPoint worldPoint, ClueScrollPlugin plugin)
{
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); 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.setSnapToEdge(true);
this.setJumpOnClick(true); this.setJumpOnClick(true);
this.setImage(CLUE_SCROLL_WORLD_IMAGE); this.setImage(clueScrollWorldImage);
this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT); this.setImagePoint(clueScrollWorldImagePoint);
} }
@Override @Override
public void onEdgeSnap() public void onEdgeSnap()
{ {
this.setImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE); this.setImage(plugin.getClueScrollImage());
this.setImagePoint(null); this.setImagePoint(null);
} }
@Override @Override
public void onEdgeUnsnap() public void onEdgeUnsnap()
{ {
this.setImage(CLUE_SCROLL_WORLD_IMAGE); this.setImage(clueScrollWorldImage);
this.setImagePoint(CLUE_SCROLL_WORLD_IMAGE_POINT); this.setImagePoint(clueScrollWorldImagePoint);
} }
} }

View File

@@ -33,7 +33,6 @@ import net.runelite.api.NPC;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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 static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.LineComponent; 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()) 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 net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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 static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.LineComponent; 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()) 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.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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.ItemRequirement;
import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement; import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
@@ -77,6 +76,6 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati
return; 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 net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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_BORDER_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_HOVER_BORDER_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) 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()) 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, OverlayUtil.renderHoverableArea(graphics, gameObject.getClickbox(), mousePosition,
CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR); 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 net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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.AllRequirementsCollection;
import net.runelite.client.plugins.cluescrolls.clues.emote.AnyRequirementCollection; import net.runelite.client.plugins.cluescrolls.clues.emote.AnyRequirementCollection;
import net.runelite.client.plugins.cluescrolls.clues.emote.Emote; import net.runelite.client.plugins.cluescrolls.clues.emote.Emote;
@@ -285,7 +284,7 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
return; 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) 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 net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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.ItemRequirement;
import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement; import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
@@ -102,7 +101,7 @@ public class FairyRingClue extends ClueScroll implements TextClueScroll, Locatio
return; 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) 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 net.runelite.api.coords.WorldPoint;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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 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.HotColdArea;
import net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdLocation; import net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdLocation;
@@ -196,7 +194,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
if (localLocation != null) if (localLocation != null)
{ {
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE); OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
} }
return; return;
@@ -210,7 +208,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
{ {
for (NPC npc : plugin.getNpcsToMark()) 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; 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.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin; 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_BORDER_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR; import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR;
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_HOVER_BORDER_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, OverlayUtil.renderHoverableArea(graphics, gameObject.getClickbox(), mousePosition,
CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR); 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 // Mark tile
else else
{ {
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE); OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, plugin.getSpadeImage(), Color.ORANGE);
} }
} }

View File

@@ -38,14 +38,12 @@ import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
@@ -89,7 +87,7 @@ import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.ComboBoxListRenderer; import net.runelite.client.ui.components.ComboBoxListRenderer;
import net.runelite.client.ui.components.IconButton; import net.runelite.client.ui.components.IconButton;
import net.runelite.client.ui.components.IconTextField; import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.util.SwingUtil; import net.runelite.client.util.ImageUtil;
@Slf4j @Slf4j
public class ConfigPanel extends PluginPanel public class ConfigPanel extends PluginPanel
@@ -124,20 +122,10 @@ public class ConfigPanel extends PluginPanel
static static
{ {
try final BufferedImage backIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_back_icon.png");
{ BACK_ICON = new ImageIcon(backIcon);
synchronized (ImageIO.class) BACK_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(backIcon, -100));
{ SEARCH = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "search.png"));
BufferedImage backIcon = ImageIO.read(ConfigPanel.class.getResourceAsStream("config_back_icon.png"));
BACK_ICON = new ImageIcon(backIcon);
BACK_ICON_HOVER = new ImageIcon(SwingUtil.grayscaleOffset(backIcon, -100));
SEARCH = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("search.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService, ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService,

View File

@@ -27,7 +27,6 @@ package net.runelite.client.plugins.config;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ChatColorConfig;
@@ -39,6 +38,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginManager; import net.runelite.client.plugins.PluginManager;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Configuration", name = "Configuration",
@@ -73,11 +73,7 @@ public class ConfigPlugin extends Plugin
{ {
configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, chatColorConfig); configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, chatColorConfig);
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("config_icon.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("Configuration") .tooltip("Configuration")

View File

@@ -29,12 +29,10 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -45,7 +43,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.IconButton; import net.runelite.client.ui.components.IconButton;
import net.runelite.client.util.SwingUtil; import net.runelite.client.util.ImageUtil;
import org.apache.commons.text.similarity.JaroWinklerDistance; import org.apache.commons.text.similarity.JaroWinklerDistance;
class PluginListItem extends JPanel class PluginListItem extends JPanel
@@ -84,26 +82,27 @@ class PluginListItem extends JPanel
static static
{ {
try BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
{ BufferedImage onSwitcher = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "switcher_on.png");
BufferedImage configIcon; BufferedImage onStar = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "star_on.png");
CONFIG_ICON = new ImageIcon(configIcon);
synchronized (ImageIO.class) ON_SWITCHER = new ImageIcon(onSwitcher);
{ ON_STAR = new ImageIcon(onStar);
configIcon = ImageIO.read(ConfigPanel.class.getResourceAsStream("config_edit_icon.png")); CONFIG_ICON_HOVER = new ImageIcon(ImageUtil.grayscaleOffset(configIcon, -100));
CONFIG_ICON = new ImageIcon(configIcon); BufferedImage offSwitcherImage = ImageUtil.flipImage(
ON_SWITCHER = new ImageIcon(ImageIO.read(ConfigPanel.class.getResourceAsStream("switchers/on.png"))); ImageUtil.grayscaleOffset(
OFF_SWITCHER = new ImageIcon(ImageIO.read(ConfigPanel.class.getResourceAsStream("switchers/off.png"))); ImageUtil.grayscaleImage(onSwitcher),
ON_STAR = new ImageIcon(ImageIO.read(ConfigPanel.class.getResourceAsStream("stars/on.png"))); 0.61f
OFF_STAR = new ImageIcon(ImageIO.read(ConfigPanel.class.getResourceAsStream("stars/off.png"))); ),
} true,
false
CONFIG_ICON_HOVER = new ImageIcon(SwingUtil.grayscaleOffset(configIcon, -100)); );
} OFF_SWITCHER = new ImageIcon(offSwitcherImage);
catch (IOException e) BufferedImage offStar = ImageUtil.grayscaleOffset(
{ ImageUtil.grayscaleImage(onStar),
throw new RuntimeException(e); 0.77f
} );
OFF_STAR = new ImageIcon(offStar);
} }
/** /**

View File

@@ -28,17 +28,16 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Set; import java.util.Set;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; 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,11 +45,13 @@ 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;
import net.runelite.client.ui.overlay.infobox.Timer; import net.runelite.client.ui.overlay.infobox.Timer;
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Death Indicator", name = "Death Indicator",
@@ -66,7 +67,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 +80,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 +123,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 +194,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 +280,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 +318,27 @@ 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;
}
mapArrow = ImageUtil.getResourceStreamFromClass(getClass(), "/util/clue_arrow.png");
return mapArrow;
}
BufferedImage getBonesImage()
{
return itemManager.getImage(ItemID.BONES);
}
} }

View File

@@ -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("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");
} }
} }

View File

@@ -32,7 +32,6 @@ import com.google.inject.Provides;
import java.awt.Font; import java.awt.Font;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import static java.lang.Math.min; import static java.lang.Math.min;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
@@ -51,6 +50,7 @@ import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ImageUtil;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@PluginDescriptor( @PluginDescriptor(
@@ -130,11 +130,7 @@ public class DevToolsPlugin extends Plugin
final DevToolsPanel panel = injector.getInstance(DevToolsPanel.class); final DevToolsPanel panel = injector.getInstance(DevToolsPanel.class);
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "devtools_icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("devtools_icon.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("Developer Tools") .tooltip("Developer Tools")

View File

@@ -33,7 +33,6 @@ import java.time.temporal.ChronoUnit;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.imageio.ImageIO;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.Constants.CHUNK_SIZE; import static net.runelite.api.Constants.CHUNK_SIZE;
import net.runelite.api.GameState; import net.runelite.api.GameState;
@@ -51,6 +50,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.task.Schedule; import net.runelite.client.task.Schedule;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.LinkBrowser; import net.runelite.client.util.LinkBrowser;
@PluginDescriptor( @PluginDescriptor(
@@ -88,11 +88,7 @@ public class DiscordPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "discord.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("discord.png"));
}
discordButton = NavigationButton.builder() discordButton = NavigationButton.builder()
.tab(false) .tab(false)

View File

@@ -29,7 +29,6 @@ import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -46,6 +45,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.task.Schedule; import net.runelite.client.task.Schedule;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Farming Tracker", name = "Farming Tracker",
@@ -88,11 +88,7 @@ public class FarmingTrackerPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "farming.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("farming.png"));
}
panel = new FarmingTrackerPanel(client, itemManager, configManager, config, farmingWorld); panel = new FarmingTrackerPanel(client, itemManager, configManager, config, farmingWorld);

View File

@@ -53,6 +53,7 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.LinkBrowser; import net.runelite.client.util.LinkBrowser;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import net.runelite.http.api.feed.FeedItem; import net.runelite.http.api.feed.FeedItem;
@@ -102,18 +103,8 @@ class FeedPanel extends PluginPanel
static static
{ {
try RUNELITE_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(FeedPanel.class, "runelite.png"));
{ OSRS_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(FeedPanel.class, "osrs.png"));
synchronized (ImageIO.class)
{
RUNELITE_ICON = new ImageIcon(ImageIO.read(FeedPanel.class.getResourceAsStream("runelite.png")));
OSRS_ICON = new ImageIcon(ImageIO.read(FeedPanel.class.getResourceAsStream("osrs.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
private final FeedConfig config; private final FeedConfig config;

View File

@@ -33,7 +33,6 @@ import java.time.temporal.ChronoUnit;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
@@ -43,6 +42,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.task.Schedule; import net.runelite.client.task.Schedule;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
import net.runelite.http.api.feed.FeedClient; import net.runelite.http.api.feed.FeedClient;
import net.runelite.http.api.feed.FeedResult; import net.runelite.http.api.feed.FeedResult;
@@ -86,11 +86,7 @@ public class FeedPlugin extends Plugin
{ {
feedPanel = new FeedPanel(config, feedSupplier); feedPanel = new FeedPanel(config, feedSupplier);
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("icon.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("News Feed") .tooltip("News Feed")

View File

@@ -28,11 +28,11 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.SpriteID;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayPriority;
@@ -47,17 +47,17 @@ public class FightCaveOverlay extends Overlay
private final Client client; private final Client client;
private final FightCavePlugin plugin; private final FightCavePlugin plugin;
private final SpriteManager spriteManager;
private final PanelComponent imagePanelComponent = new PanelComponent(); private final PanelComponent imagePanelComponent = new PanelComponent();
private BufferedImage protectFromMagicImg;
private BufferedImage protectFromMissilesImg;
@Inject @Inject
private FightCaveOverlay(Client client, FightCavePlugin plugin) private FightCaveOverlay(Client client, FightCavePlugin plugin, SpriteManager spriteManager)
{ {
setPosition(OverlayPosition.BOTTOM_RIGHT); setPosition(OverlayPosition.BOTTOM_RIGHT);
setPriority(OverlayPriority.HIGH); setPriority(OverlayPriority.HIGH);
this.client = client; this.client = client;
this.plugin = plugin; this.plugin = plugin;
this.spriteManager = spriteManager;
} }
@Override @Override
@@ -83,43 +83,7 @@ public class FightCaveOverlay extends Overlay
private BufferedImage getPrayerImage(JadAttack attack) private BufferedImage getPrayerImage(JadAttack attack)
{ {
return attack == JadAttack.MAGIC ? getProtectFromMagicImage() : getProtectFromMissilesImage(); final int prayerSpriteID = attack == JadAttack.MAGIC ? SpriteID.PRAYER_PROTECT_FROM_MAGIC : SpriteID.PRAYER_PROTECT_FROM_MISSILES;
} return spriteManager.getSprite(prayerSpriteID, 0);
private BufferedImage getProtectFromMagicImage()
{
if (protectFromMagicImg == null)
{
String path = "/prayers/protect_from_magic.png";
protectFromMagicImg = getImage(path);
}
return protectFromMagicImg;
}
private BufferedImage getProtectFromMissilesImage()
{
if (protectFromMissilesImg == null)
{
String path = "/prayers/protect_from_missiles.png";
protectFromMissilesImg = getImage(path);
}
return protectFromMissilesImg;
}
private BufferedImage getImage(String path)
{
BufferedImage image = null;
try
{
synchronized (ImageIO.class)
{
image = ImageIO.read(FightCaveOverlay.class.getResourceAsStream(path));
}
}
catch (IOException e)
{
log.warn("Error loading image", e);
}
return image;
} }
} }

View File

@@ -36,9 +36,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -54,6 +52,7 @@ import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.components.ThinProgressBar; import net.runelite.client.ui.components.ThinProgressBar;
import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter; import net.runelite.client.util.StackFormatter;
@Slf4j @Slf4j
@@ -83,18 +82,9 @@ public class GrandExchangeOfferSlot extends JPanel
static static
{ {
try final BufferedImage rightArrow = ImageUtil.alphaOffset(ImageUtil.getResourceStreamFromClass(GrandExchangeOfferSlot.class, "/util/arrow_right.png"), 0.25f);
{ RIGHT_ARROW_ICON = new ImageIcon(rightArrow);
synchronized (ImageIO.class) LEFT_ARROW_ICON = new ImageIcon(ImageUtil.flipImage(rightArrow, true, false));
{
RIGHT_ARROW_ICON = new ImageIcon(ImageIO.read(GrandExchangeOfferSlot.class.getResourceAsStream("arrow_right.png")));
LEFT_ARROW_ICON = new ImageIcon(ImageIO.read(GrandExchangeOfferSlot.class.getResourceAsStream("arrow_left.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
/** /**

View File

@@ -32,7 +32,6 @@ import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import lombok.AccessLevel; import lombok.AccessLevel;
@@ -66,6 +65,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter; import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import net.runelite.http.api.osbuddy.GrandExchangeClient; import net.runelite.http.api.osbuddy.GrandExchangeClient;
@@ -134,15 +134,11 @@ public class GrandExchangePlugin extends Plugin
} }
@Override @Override
protected void startUp() throws IOException protected void startUp()
{ {
panel = injector.getInstance(GrandExchangePanel.class); panel = injector.getInstance(GrandExchangePanel.class);
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "ge_icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("ge_icon.png"));
}
button = NavigationButton.builder() button = NavigationButton.builder()
.tooltip("Grand Exchange") .tooltip("Grand Exchange")

View File

@@ -31,11 +31,9 @@ import java.awt.CardLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
@@ -49,6 +47,7 @@ import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.components.IconTextField; import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.ui.components.PluginErrorPanel; import net.runelite.client.ui.components.PluginErrorPanel;
import net.runelite.client.util.ImageUtil;
import net.runelite.http.api.item.Item; import net.runelite.http.api.item.Item;
import net.runelite.http.api.item.ItemPrice; import net.runelite.http.api.item.ItemPrice;
import net.runelite.http.api.item.SearchResult; import net.runelite.http.api.item.SearchResult;
@@ -95,19 +94,9 @@ class GrandExchangeSearchPanel extends JPanel
static static
{ {
try SEARCH_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.grayscaleOffset(ImageUtil.getResourceStreamFromClass(IconTextField.class, "search.png"), 0f), 1.75f));
{ LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner.gif"));
synchronized (ImageIO.class) ERROR_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "error.png"));
{
SEARCH_ICON = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("search_darker.png")));
LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner.gif"));
ERROR_ICON = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("error.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
GrandExchangeSearchPanel(Client client, ItemManager itemManager, ScheduledExecutorService executor) GrandExchangeSearchPanel(Client client, ItemManager itemManager, ScheduledExecutorService executor)

View File

@@ -41,7 +41,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JLabel; import javax.swing.JLabel;
@@ -57,6 +56,7 @@ import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.IconTextField; import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.ui.components.materialtabs.MaterialTab; import net.runelite.client.ui.components.materialtabs.MaterialTab;
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup; import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.RunnableExceptionLogger; import net.runelite.client.util.RunnableExceptionLogger;
import net.runelite.client.util.StackFormatter; import net.runelite.client.util.StackFormatter;
import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreClient;
@@ -146,19 +146,9 @@ public class HiscorePanel extends PluginPanel
static static
{ {
try SEARCH_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "search.png"));
{ LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner_darker.gif"));
synchronized (ImageIO.class) ERROR_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "error.png"));
{
SEARCH_ICON = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("search.png")));
LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner_darker.gif"));
ERROR_ICON = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("error.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
@Inject @Inject
@@ -220,51 +210,39 @@ public class HiscorePanel extends PluginPanel
for (HiscoreEndpoint endpoint : HiscoreEndpoint.values()) for (HiscoreEndpoint endpoint : HiscoreEndpoint.values())
{ {
try final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), endpoint.name().toLowerCase() + ".png");
MaterialTab tab = new MaterialTab(new ImageIcon(iconImage), tabGroup, null);
tab.setToolTipText(endpoint.getName() + " Hiscores");
tab.setOnSelectEvent(() ->
{ {
BufferedImage iconImage; if (loading)
synchronized (ImageIO.class)
{ {
iconImage = ImageIO.read(HiscorePanel.class.getResourceAsStream( return false;
endpoint.name().toLowerCase() + ".png"));
} }
MaterialTab tab = new MaterialTab(new ImageIcon(iconImage), tabGroup, null); selectedEndPoint = endpoint;
tab.setToolTipText(endpoint.getName() + " Hiscores"); return true;
tab.setOnSelectEvent(() -> });
// Adding the lookup method to a mouseListener instead of the above onSelectedEvent
// Because sometimes you might want to switch the tab, without calling for lookup
// Ex: selecting the normal hiscores as default
tab.addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(MouseEvent mouseEvent)
{ {
if (loading) if (loading)
{ {
return false; return;
} }
selectedEndPoint = endpoint; executor.execute(HiscorePanel.this::lookup);
return true; }
}); });
// Adding the lookup method to a mouseListener instead of the above onSelectedEvent tabGroup.addTab(tab);
// Because sometimes you might want to switch the tab, without calling for lookup
// Ex: selecting the normal hiscores as default
tab.addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(MouseEvent mouseEvent)
{
if (loading)
{
return;
}
executor.execute(HiscorePanel.this::lookup);
}
});
tabGroup.addTab(tab);
}
catch (IOException ex)
{
throw new RuntimeException(ex);
}
} }
// Default selected tab is normal hiscores // Default selected tab is normal hiscores
@@ -328,22 +306,22 @@ public class HiscorePanel extends PluginPanel
label.setFont(FontManager.getRunescapeSmallFont()); label.setFont(FontManager.getRunescapeSmallFont());
label.setText("--"); label.setText("--");
String skillIcon = "skill_icons_small/" + (skill == null ? "combat" : skill.getName().toLowerCase()) + ".png"; String skillName = (skill == null ? "combat" : skill.getName().toLowerCase());
String directory = "/skill_icons";
if (skillName.equals("combat") || skillName.equals("overall"))
{
// Cannot use SpriteManager as HiscorePlugin loads before a Client is available
directory += "/";
}
else
{
directory += "_small/";
}
String skillIcon = directory + skillName + ".png";
log.debug("Loading skill icon from {}", skillIcon); log.debug("Loading skill icon from {}", skillIcon);
try label.setIcon(new ImageIcon(ImageUtil.getResourceStreamFromClass(getClass(), skillIcon)));
{
BufferedImage icon;
synchronized (ImageIO.class)
{
icon = ImageIO.read(HiscorePanel.class.getResourceAsStream(skillIcon));
}
label.setIcon(new ImageIcon(icon));
}
catch (IOException ex)
{
log.warn(null, ex);
}
boolean totalLabel = skill == HiscoreSkill.OVERALL || skill == null; //overall or combat boolean totalLabel = skill == HiscoreSkill.OVERALL || skill == null; //overall or combat
label.setIconTextGap(totalLabel ? 10 : 4); label.setIconTextGap(totalLabel ? 10 : 4);

View File

@@ -32,7 +32,6 @@ import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Provider; import javax.inject.Provider;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@@ -49,6 +48,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@@ -98,11 +98,7 @@ public class HiscorePlugin extends Plugin
{ {
hiscorePanel = injector.getInstance(HiscorePanel.class); hiscorePanel = injector.getInstance(HiscorePanel.class);
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "normal.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("normal.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("Hiscore") .tooltip("Hiscore")

View File

@@ -36,10 +36,8 @@ import java.awt.Font;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@@ -56,6 +54,7 @@ import net.runelite.client.account.SessionManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.LinkBrowser; import net.runelite.client.util.LinkBrowser;
import net.runelite.client.util.RunnableExceptionLogger; import net.runelite.client.util.RunnableExceptionLogger;
@@ -92,21 +91,11 @@ public class InfoPanel extends PluginPanel
static static
{ {
try ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "/util/arrow_right.png"));
{ GITHUB_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "github_icon.png"));
synchronized (ImageIO.class) DISCORD_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "discord_icon.png"));
{ PATREON_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "patreon_icon.png"));
ARROW_RIGHT_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("arrow_right.png"))); WIKI_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "wiki_icon.png"));
GITHUB_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("github_icon.png")));
DISCORD_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("discord_icon.png")));
PATREON_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("patreon_icon.png")));
WIKI_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("wiki_icon.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
void init() void init()

View File

@@ -25,12 +25,12 @@
package net.runelite.client.plugins.info; package net.runelite.client.plugins.info;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
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.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Info Panel", name = "Info Panel",
@@ -50,11 +50,7 @@ public class InfoPlugin extends Plugin
final InfoPanel panel = injector.getInstance(InfoPanel.class); final InfoPanel panel = injector.getInstance(InfoPanel.class);
panel.init(); panel.init();
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "info_icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("info_icon.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("Info") .tooltip("Info")

View File

@@ -26,16 +26,16 @@ package net.runelite.client.plugins.kingdomofmiscellania;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import static net.runelite.api.ItemID.TEAK_CHEST;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
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;
@@ -57,20 +57,13 @@ public class KingdomPlugin extends Plugin
@Inject @Inject
private InfoBoxManager infoBoxManager; private InfoBoxManager infoBoxManager;
@Inject
private ItemManager itemManager;
@Getter @Getter
private int favor = 0, coffer = 0; private int favor = 0, coffer = 0;
private KingdomCounter counter; private KingdomCounter counter;
private BufferedImage counterImage;
@Override
protected void startUp() throws Exception
{
synchronized (ImageIO.class)
{
counterImage = ImageIO.read(getClass().getResourceAsStream("teak_chest.png"));
}
}
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
@@ -112,7 +105,7 @@ public class KingdomPlugin extends Plugin
{ {
if (counter == null) if (counter == null)
{ {
counter = new KingdomCounter(counterImage, this); counter = new KingdomCounter(itemManager.getImage(TEAK_CHEST), this);
infoBoxManager.addInfoBox(counter); infoBoxManager.addInfoBox(counter);
log.debug("Added Kingdom Infobox"); log.debug("Added Kingdom Infobox");
} }

View File

@@ -33,14 +33,12 @@ import java.awt.GridBagLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.imageio.ImageIO;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
@@ -52,7 +50,7 @@ import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import net.runelite.client.util.SwingUtil; import net.runelite.client.util.ImageUtil;
@Singleton @Singleton
class KourendLibraryPanel extends PluginPanel class KourendLibraryPanel extends PluginPanel
@@ -67,19 +65,9 @@ class KourendLibraryPanel extends PluginPanel
static static
{ {
try final BufferedImage resetIcon = ImageUtil.getResourceStreamFromClass(KourendLibraryPanel.class, "/util/reset.png");
{ RESET_ICON = new ImageIcon(resetIcon);
synchronized (ImageIO.class) RESET_CLICK_ICON = new ImageIcon(ImageUtil.alphaOffset(resetIcon, -100));
{
BufferedImage resetIcon = ImageIO.read(KourendLibraryPanel.class.getResourceAsStream("reset.png"));
RESET_ICON = new ImageIcon(resetIcon);
RESET_CLICK_ICON = new ImageIcon(SwingUtil.grayscaleOffset(resetIcon, -100));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
void init() void init()

View File

@@ -29,7 +29,6 @@ import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -53,6 +52,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Kourend Library", name = "Kourend Library",
@@ -109,11 +109,7 @@ public class KourendLibraryPlugin extends Plugin
panel = injector.getInstance(KourendLibraryPanel.class); panel = injector.getInstance(KourendLibraryPanel.class);
panel.init(); panel.init();
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(Book.class.getResourceAsStream("panel_icon.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("Kourend Library") .tooltip("Kourend Library")

View File

@@ -34,7 +34,6 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -59,6 +58,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import net.runelite.http.api.item.ItemPrice; import net.runelite.http.api.item.ItemPrice;
@@ -125,11 +125,7 @@ public class LootTrackerPlugin extends Plugin
panel = new LootTrackerPanel(itemManager); panel = new LootTrackerPanel(itemManager);
spriteManager.getSpriteAsync(SpriteID.UNUSED_TAB_INVENTORY, 0, panel::loadHeaderIcon); spriteManager.getSpriteAsync(SpriteID.UNUSED_TAB_INVENTORY, 0, panel::loadHeaderIcon);
final BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(LootTrackerPanel.class.getResourceAsStream("panel_icon.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("Loot Tracker") .tooltip("Loot Tracker")

View File

@@ -25,12 +25,11 @@
package net.runelite.client.plugins.mta.alchemy; package net.runelite.client.plugins.mta.alchemy;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import javax.imageio.ImageIO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.Timer; import net.runelite.client.ui.overlay.infobox.Timer;
import net.runelite.client.util.ImageUtil;
@Slf4j @Slf4j
public class AlchemyRoomTimer extends Timer public class AlchemyRoomTimer extends Timer
@@ -51,17 +50,7 @@ public class AlchemyRoomTimer extends Timer
return image; return image;
} }
try image = ImageUtil.getResourceStreamFromClass(AlchemyRoomTimer.class, "/util/reset.png");
{
synchronized (ImageIO.class)
{
image = ImageIO.read(AlchemyRoomTimer.class.getResourceAsStream("reset.png"));
}
}
catch (IOException ex)
{
log.warn(null, ex);
}
return image; return image;
} }

View File

@@ -27,7 +27,6 @@ package net.runelite.client.plugins.notes;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.SessionOpen; import net.runelite.api.events.SessionOpen;
@@ -36,6 +35,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Notes", name = "Notes",
@@ -67,11 +67,7 @@ public class NotesPlugin extends Plugin
panel = injector.getInstance(NotesPanel.class); panel = injector.getInstance(NotesPanel.class);
panel.init(config); panel.init(config);
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "notes_icon.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("notes_icon.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("Notes") .tooltip("Notes")

View File

@@ -25,14 +25,13 @@
package net.runelite.client.plugins.poh; package net.runelite.client.plugins.poh;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.imageio.ImageIO;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import static net.runelite.api.ObjectID.*; import static net.runelite.api.ObjectID.*;
import static net.runelite.api.NullObjectID.*; import static net.runelite.api.NullObjectID.*;
import net.runelite.client.util.ImageUtil;
@Slf4j @Slf4j
public enum PohIcons public enum PohIcons
@@ -105,17 +104,7 @@ public enum PohIcons
return image; return image;
} }
try image = ImageUtil.getResourceStreamFromClass(getClass(), getImageResource() + ".png");
{
synchronized (ImageIO.class)
{
image = ImageIO.read(PohIcons.class.getResourceAsStream(getImageResource() + ".png"));
}
}
catch (IOException ex)
{
log.warn("unable to load image", ex);
}
return image; return image;
} }

View File

@@ -32,14 +32,10 @@ import java.awt.FontMetrics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
@@ -47,8 +43,10 @@ import net.runelite.api.GameState;
import net.runelite.api.InventoryID; import net.runelite.api.InventoryID;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import static net.runelite.api.SpriteID.MINIMAP_DESTINATION_FLAG;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver; import net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver;
import net.runelite.client.plugins.puzzlesolver.solver.PuzzleState; import net.runelite.client.plugins.puzzlesolver.solver.PuzzleState;
import net.runelite.client.plugins.puzzlesolver.solver.heuristics.ManhattanDistance; import net.runelite.client.plugins.puzzlesolver.solver.heuristics.ManhattanDistance;
@@ -60,6 +58,7 @@ import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.BackgroundComponent; import net.runelite.client.ui.overlay.components.BackgroundComponent;
import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.ui.overlay.components.TextComponent;
import net.runelite.client.util.ImageUtil;
@Slf4j @Slf4j
public class PuzzleSolverOverlay extends Overlay public class PuzzleSolverOverlay extends Overlay
@@ -78,18 +77,18 @@ public class PuzzleSolverOverlay extends Overlay
private final Client client; private final Client client;
private final PuzzleSolverConfig config; private final PuzzleSolverConfig config;
private final ScheduledExecutorService executorService; private final ScheduledExecutorService executorService;
private final SpriteManager spriteManager;
private PuzzleSolver solver; private PuzzleSolver solver;
private Future<?> solverFuture; private Future<?> solverFuture;
private int[] cachedItems; private int[] cachedItems;
private BufferedImage downArrow;
private BufferedImage upArrow; private BufferedImage upArrow;
private BufferedImage leftArrow; private BufferedImage leftArrow;
private BufferedImage rightArrow; private BufferedImage rightArrow;
@Inject @Inject
public PuzzleSolverOverlay(Client client, PuzzleSolverConfig config, ScheduledExecutorService executorService) public PuzzleSolverOverlay(Client client, PuzzleSolverConfig config, ScheduledExecutorService executorService, SpriteManager spriteManager)
{ {
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
setPriority(OverlayPriority.HIGH); setPriority(OverlayPriority.HIGH);
@@ -97,6 +96,7 @@ public class PuzzleSolverOverlay extends Overlay
this.client = client; this.client = client;
this.config = config; this.config = config;
this.executorService = executorService; this.executorService = executorService;
this.spriteManager = spriteManager;
} }
@Override @Override
@@ -427,28 +427,14 @@ public class PuzzleSolverOverlay extends Overlay
private BufferedImage getDownArrow() private BufferedImage getDownArrow()
{ {
if (downArrow == null) return spriteManager.getSprite(MINIMAP_DESTINATION_FLAG, 1);
{
try
{
synchronized (ImageIO.class)
{
downArrow = ImageIO.read(PuzzleSolverOverlay.class.getResourceAsStream("arrow.png"));
}
}
catch (IOException e)
{
log.warn("Error loading image", e);
}
}
return downArrow;
} }
private BufferedImage getUpArrow() private BufferedImage getUpArrow()
{ {
if (upArrow == null) if (upArrow == null)
{ {
upArrow = getRotatedImage(getDownArrow(), Math.PI); upArrow = ImageUtil.rotateImage(getDownArrow(), Math.PI);
} }
return upArrow; return upArrow;
} }
@@ -457,7 +443,7 @@ public class PuzzleSolverOverlay extends Overlay
{ {
if (leftArrow == null) if (leftArrow == null)
{ {
leftArrow = getRotatedImage(getDownArrow(), Math.PI / 2); leftArrow = ImageUtil.rotateImage(getDownArrow(), Math.PI / 2);
} }
return leftArrow; return leftArrow;
} }
@@ -466,16 +452,8 @@ public class PuzzleSolverOverlay extends Overlay
{ {
if (rightArrow == null) if (rightArrow == null)
{ {
rightArrow = getRotatedImage(getDownArrow(), 3 * Math.PI / 2); rightArrow = ImageUtil.rotateImage(getDownArrow(), 3 * Math.PI / 2);
} }
return rightArrow; return rightArrow;
} }
private BufferedImage getRotatedImage(BufferedImage image, double theta)
{
AffineTransform transform = new AffineTransform();
transform.rotate(theta, image.getWidth() / 2, image.getHeight() / 2);
AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
return transformOp.filter(image, null);
}
} }

View File

@@ -27,15 +27,12 @@ package net.runelite.client.plugins.raids;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.google.inject.Binder; import com.google.inject.Binder;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -46,6 +43,7 @@ import net.runelite.api.InstanceTemplates;
import net.runelite.api.NullObjectID; import net.runelite.api.NullObjectID;
import static net.runelite.api.Perspective.SCENE_SIZE; import static net.runelite.api.Perspective.SCENE_SIZE;
import net.runelite.api.Point; import net.runelite.api.Point;
import static net.runelite.api.SpriteID.TAB_QUESTS_BROWN_RAIDING_PARTY;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.VarPlayer; import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
@@ -60,6 +58,7 @@ import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.game.SpriteManager;
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.plugins.raids.solver.Layout; import net.runelite.client.plugins.raids.solver.Layout;
@@ -86,7 +85,6 @@ public class RaidsPlugin extends Plugin
private static final String SPLIT_REGEX = "\\s*,\\s*"; private static final String SPLIT_REGEX = "\\s*,\\s*";
private static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)]"); private static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)]");
private BufferedImage raidsIcon;
private RaidsTimer timer; private RaidsTimer timer;
@Getter @Getter
@@ -116,6 +114,9 @@ public class RaidsPlugin extends Plugin
@Inject @Inject
private LayoutSolver layoutSolver; private LayoutSolver layoutSolver;
@Inject
private SpriteManager spriteManager;
@Getter @Getter
private Raid raid; private Raid raid;
@@ -270,7 +271,7 @@ public class RaidsPlugin extends Plugin
if (config.raidsTimer() && message.startsWith(RAID_START_MESSAGE)) if (config.raidsTimer() && message.startsWith(RAID_START_MESSAGE))
{ {
timer = new RaidsTimer(getRaidsIcon(), this, Instant.now()); timer = new RaidsTimer(spriteManager.getSprite(TAB_QUESTS_BROWN_RAIDING_PARTY, 0), this, Instant.now());
infoBoxManager.addInfoBox(timer); infoBoxManager.addInfoBox(timer);
} }
@@ -602,25 +603,4 @@ public class RaidsPlugin extends Plugin
return room; return room;
} }
private BufferedImage getRaidsIcon()
{
if (raidsIcon != null)
{
return raidsIcon;
}
try
{
synchronized (ImageIO.class)
{
raidsIcon = ImageIO.read(RaidsPlugin.class.getResourceAsStream("raids_icon.png"));
}
}
catch (IOException ex)
{
log.warn("Unable to load image", ex);
}
return raidsIcon;
}
} }

View File

@@ -39,7 +39,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
@@ -53,6 +52,7 @@ import net.runelite.client.plugins.screenmarkers.ui.ScreenMarkerPluginPanel;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Screen Markers", name = "Screen Markers",
@@ -108,11 +108,7 @@ public class ScreenMarkerPlugin extends Plugin
pluginPanel = injector.getInstance(ScreenMarkerPluginPanel.class); pluginPanel = injector.getInstance(ScreenMarkerPluginPanel.class);
pluginPanel.rebuild(); pluginPanel.rebuild();
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), ICON_FILE);
synchronized (ImageIO.class)
{
icon = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream(ICON_FILE));
}
navigationButton = NavigationButton.builder() navigationButton = NavigationButton.builder()
.tooltip(PLUGIN_NAME) .tooltip(PLUGIN_NAME)

View File

@@ -29,8 +29,7 @@ import java.awt.Color;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.IOException; import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -39,6 +38,7 @@ import net.runelite.client.plugins.screenmarkers.ScreenMarkerPlugin;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.components.shadowlabel.JShadowedLabel; import net.runelite.client.ui.components.shadowlabel.JShadowedLabel;
import net.runelite.client.util.ImageUtil;
public class ScreenMarkerCreationPanel extends JPanel public class ScreenMarkerCreationPanel extends JPanel
{ {
@@ -54,21 +54,13 @@ public class ScreenMarkerCreationPanel extends JPanel
static static
{ {
try CONFIRM_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "confirm_icon.png"));
{ CANCEL_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "cancel_icon.png"));
synchronized (ImageIO.class)
{ final BufferedImage confirmIcon = ImageUtil.bufferedImageFromImage(CONFIRM_ICON.getImage());
CONFIRM_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("confirm_icon.png"))); CONFIRM_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(confirmIcon, 0.54f));
CONFIRM_HOVER_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("confirm_hover_icon.png"))); CONFIRM_LOCKED_ICON = new ImageIcon(ImageUtil.grayscaleImage(confirmIcon));
CONFIRM_LOCKED_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("confirm_locked_icon.png"))); CANCEL_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.bufferedImageFromImage(CANCEL_ICON.getImage()), 0.6f));
CANCEL_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("cancel_icon.png")));
CANCEL_HOVER_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("cancel_hover_icon.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
ScreenMarkerCreationPanel(ScreenMarkerPlugin plugin) ScreenMarkerCreationPanel(ScreenMarkerPlugin plugin)

View File

@@ -34,8 +34,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JColorChooser; import javax.swing.JColorChooser;
@@ -55,7 +53,7 @@ import net.runelite.client.plugins.screenmarkers.ScreenMarkerPlugin;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.components.FlatTextField; import net.runelite.client.ui.components.FlatTextField;
import net.runelite.client.util.SwingUtil; import net.runelite.client.util.ImageUtil;
class ScreenMarkerPanel extends JPanel class ScreenMarkerPanel extends JPanel
{ {
@@ -108,48 +106,38 @@ class ScreenMarkerPanel extends JPanel
static static
{ {
try final BufferedImage borderImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "border_color_icon.png");
{ BORDER_COLOR_ICON = new ImageIcon(borderImg);
synchronized (ImageIO.class) BORDER_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(borderImg, -100));
{
BufferedImage borderImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("border_color_icon.png"));
BORDER_COLOR_ICON = new ImageIcon(borderImg);
BORDER_COLOR_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(borderImg, -100));
BufferedImage noBorderImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("no_border_color_icon.png")); final BufferedImage noBorderImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "no_border_color_icon.png");
NO_BORDER_COLOR_ICON = new ImageIcon(noBorderImg); NO_BORDER_COLOR_ICON = new ImageIcon(noBorderImg);
NO_BORDER_COLOR_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(noBorderImg, -100)); NO_BORDER_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(noBorderImg, -100));
BufferedImage fillImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("fill_color_icon.png")); final BufferedImage fillImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "fill_color_icon.png");
FILL_COLOR_ICON = new ImageIcon(fillImg); FILL_COLOR_ICON = new ImageIcon(fillImg);
FILL_COLOR_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(fillImg, -100)); FILL_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(fillImg, -100));
BufferedImage noFillImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("no_fill_color_icon.png")); final BufferedImage noFillImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "no_fill_color_icon.png");
NO_FILL_COLOR_ICON = new ImageIcon(noFillImg); NO_FILL_COLOR_ICON = new ImageIcon(noFillImg);
NO_FILL_COLOR_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(noFillImg, -100)); NO_FILL_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(noFillImg, -100));
BufferedImage opacityImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("opacity_icon.png")); final BufferedImage opacityImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "opacity_icon.png");
FULL_OPACITY_ICON = new ImageIcon(opacityImg); FULL_OPACITY_ICON = new ImageIcon(opacityImg);
OPACITY_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(opacityImg, -100)); OPACITY_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(opacityImg, -100));
NO_OPACITY_ICON = new ImageIcon(SwingUtil.grayscaleOffset(opacityImg, -150)); NO_OPACITY_ICON = new ImageIcon(ImageUtil.alphaOffset(opacityImg, -150));
BufferedImage visibleImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("visible_icon.png")); final BufferedImage visibleImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "visible_icon.png");
VISIBLE_ICON = new ImageIcon(visibleImg); VISIBLE_ICON = new ImageIcon(visibleImg);
VISIBLE_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(visibleImg, -100)); VISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(visibleImg, -100));
BufferedImage invisibleImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("invisible_icon.png")); final BufferedImage invisibleImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "invisible_icon.png");
INVISIBLE_ICON = new ImageIcon(invisibleImg); INVISIBLE_ICON = new ImageIcon(invisibleImg);
INVISIBLE_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(invisibleImg, -100)); INVISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -100));
BufferedImage deleteImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("delete_icon.png")); final BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "delete_icon.png");
DELETE_ICON = new ImageIcon(deleteImg); DELETE_ICON = new ImageIcon(deleteImg);
DELETE_HOVER_ICON = new ImageIcon(SwingUtil.grayscaleOffset(deleteImg, -100)); DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
ScreenMarkerPanel(ScreenMarkerPlugin plugin, ScreenMarkerOverlay marker) ScreenMarkerPanel(ScreenMarkerPlugin plugin, ScreenMarkerOverlay marker)

View File

@@ -34,8 +34,7 @@ import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.IOException; import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JLabel; import javax.swing.JLabel;
@@ -47,6 +46,7 @@ import net.runelite.client.plugins.screenmarkers.ScreenMarkerPlugin;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.PluginErrorPanel; import net.runelite.client.ui.components.PluginErrorPanel;
import net.runelite.client.util.ImageUtil;
@Singleton @Singleton
public class ScreenMarkerPluginPanel extends PluginPanel public class ScreenMarkerPluginPanel extends PluginPanel
@@ -80,18 +80,9 @@ public class ScreenMarkerPluginPanel extends PluginPanel
static static
{ {
try final BufferedImage addIcon = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "add_icon.png");
{ ADD_ICON = new ImageIcon(addIcon);
synchronized (ImageIO.class) ADD_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(addIcon, 0.53f));
{
ADD_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("add_icon.png")));
ADD_HOVER_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("add_hover_icon.png")));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
public void init() public void init()

View File

@@ -31,16 +31,13 @@ import java.awt.FontMetrics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Consumer; import java.util.function.Consumer;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.MainBufferProvider; import net.runelite.api.MainBufferProvider;
import net.runelite.client.ui.DrawManager; import net.runelite.client.ui.DrawManager;
@@ -50,41 +47,26 @@ import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayPriority;
@Slf4j
public class ScreenshotOverlay extends Overlay public class ScreenshotOverlay extends Overlay
{ {
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MMM. dd, yyyy"); private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MMM. dd, yyyy");
private static final int REPORT_BUTTON_X_OFFSET = 404; private static final int REPORT_BUTTON_X_OFFSET = 404;
private static BufferedImage REPORT_BUTTON;
static
{
try
{
synchronized (ImageIO.class)
{
REPORT_BUTTON = ImageIO.read(ScreenshotPlugin.class.getResourceAsStream("report_button.png"));
}
}
catch (IOException e)
{
log.warn("Report button image failed to load", e);
}
}
private final Client client; private final Client client;
private final DrawManager drawManager; private final DrawManager drawManager;
private final ScreenshotPlugin plugin;
private final Queue<Consumer<Image>> consumers = new ConcurrentLinkedQueue<>(); private final Queue<Consumer<Image>> consumers = new ConcurrentLinkedQueue<>();
@Inject @Inject
public ScreenshotOverlay(Client client, DrawManager drawManager) public ScreenshotOverlay(Client client, DrawManager drawManager, ScreenshotPlugin plugin)
{ {
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
setPriority(OverlayPriority.HIGH); setPriority(OverlayPriority.HIGH);
setLayer(OverlayLayer.ABOVE_WIDGETS); setLayer(OverlayLayer.ABOVE_WIDGETS);
this.client = client; this.client = client;
this.drawManager = drawManager; this.drawManager = drawManager;
this.plugin = plugin;
} }
@Override @Override
@@ -97,9 +79,9 @@ public class ScreenshotOverlay extends Overlay
final MainBufferProvider bufferProvider = (MainBufferProvider) client.getBufferProvider(); final MainBufferProvider bufferProvider = (MainBufferProvider) client.getBufferProvider();
final int imageHeight = ((BufferedImage) bufferProvider.getImage()).getHeight(); final int imageHeight = ((BufferedImage) bufferProvider.getImage()).getHeight();
final int y = imageHeight - REPORT_BUTTON.getHeight() - 1; final int y = imageHeight - plugin.getReportButton().getHeight() - 1;
graphics.drawImage(REPORT_BUTTON, REPORT_BUTTON_X_OFFSET, y, null); graphics.drawImage(plugin.getReportButton(), REPORT_BUTTON_X_OFFSET, y, null);
graphics.setFont(FontManager.getRunescapeSmallFont()); graphics.setFont(FontManager.getRunescapeSmallFont());
FontMetrics fontMetrics = graphics.getFontMetrics(); FontMetrics fontMetrics = graphics.getFontMetrics();
@@ -108,8 +90,8 @@ public class ScreenshotOverlay extends Overlay
final int dateWidth = fontMetrics.stringWidth(date); final int dateWidth = fontMetrics.stringWidth(date);
final int dateHeight = fontMetrics.getHeight(); final int dateHeight = fontMetrics.getHeight();
final int textX = REPORT_BUTTON_X_OFFSET + REPORT_BUTTON.getWidth() / 2 - dateWidth / 2; final int textX = REPORT_BUTTON_X_OFFSET + plugin.getReportButton().getWidth() / 2 - dateWidth / 2;
final int textY = y + REPORT_BUTTON.getHeight() / 2 + dateHeight / 2; final int textY = y + plugin.getReportButton().getHeight() / 2 + dateHeight / 2;
graphics.setColor(Color.BLACK); graphics.setColor(Color.BLACK);
graphics.drawString(date, textX + 1, textY + 1); graphics.drawString(date, textX + 1, textY + 1);
@@ -130,7 +112,7 @@ public class ScreenshotOverlay extends Overlay
public void queueForTimestamp(Consumer<Image> screenshotConsumer) public void queueForTimestamp(Consumer<Image> screenshotConsumer)
{ {
if (REPORT_BUTTON == null) if (plugin.getReportButton() == null)
{ {
return; return;
} }

View File

@@ -52,13 +52,17 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.SpriteID;
import net.runelite.api.WorldType; import net.runelite.api.WorldType;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.WidgetLoaded; import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
@@ -74,6 +78,7 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import static net.runelite.client.RuneLite.SCREENSHOT_DIR; import static net.runelite.client.RuneLite.SCREENSHOT_DIR;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -85,6 +90,7 @@ import net.runelite.client.ui.DrawManager;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call; import okhttp3.Call;
@@ -170,6 +176,12 @@ public class ScreenshotPlugin extends Plugin
@Inject @Inject
private KeyManager keyManager; private KeyManager keyManager;
@Inject
private SpriteManager spriteManager;
@Getter(AccessLevel.PACKAGE)
private BufferedImage reportButton;
private NavigationButton titleBarButton; private NavigationButton titleBarButton;
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey()) private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey())
@@ -194,42 +206,30 @@ public class ScreenshotPlugin extends Plugin
SCREENSHOT_DIR.mkdirs(); SCREENSHOT_DIR.mkdirs();
keyManager.registerKeyListener(hotkeyListener); keyManager.registerKeyListener(hotkeyListener);
try final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), "screenshot.png");
{
BufferedImage iconImage;
synchronized (ImageIO.class)
{
iconImage = ImageIO.read(ScreenshotPlugin.class.getResourceAsStream("screenshot.png"));
}
titleBarButton = NavigationButton.builder() titleBarButton = NavigationButton.builder()
.tab(false) .tab(false)
.tooltip("Take screenshot") .tooltip("Take screenshot")
.icon(iconImage) .icon(iconImage)
.onClick(() -> takeScreenshot(format(new Date()))) .onClick(() -> takeScreenshot(format(new Date())))
.popup(ImmutableMap .popup(ImmutableMap
.<String, Runnable>builder() .<String, Runnable>builder()
.put("Open screenshot folder...", () -> .put("Open screenshot folder...", () ->
{
try
{ {
try Desktop.getDesktop().open(SCREENSHOT_DIR);
{ }
Desktop.getDesktop().open(SCREENSHOT_DIR); catch (IOException ex)
} {
catch (IOException ex) log.warn("Error opening screenshot dir", ex);
{ }
log.warn("Error opening screenshot dir", ex); })
.build())
.build();
} clientToolbar.addNavigation(titleBarButton);
})
.build())
.build();
clientToolbar.addNavigation(titleBarButton);
}
catch (IOException ex)
{
log.warn("Error adding screenshot button to titlebar", ex);
}
} }
@Override @Override
@@ -240,6 +240,16 @@ public class ScreenshotPlugin extends Plugin
keyManager.unregisterKeyListener(hotkeyListener); keyManager.unregisterKeyListener(hotkeyListener);
} }
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState() == GameState.LOGGED_IN
&& reportButton == null)
{
reportButton = spriteManager.getSprite(SpriteID.CHATBOX_REPORT_BUTTON, 0);
}
}
@Subscribe @Subscribe
public void onGameTick(GameTick event) public void onGameTick(GameTick event)
{ {

View File

@@ -26,7 +26,6 @@
package net.runelite.client.plugins.skillcalculator; package net.runelite.client.plugins.skillcalculator;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
@@ -37,6 +36,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "Skill Calculator", name = "Skill Calculator",
@@ -69,11 +69,7 @@ public class SkillCalculatorPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "calc.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("calc.png"));
}
SkillCalculator.spriteManager = spriteManager; SkillCalculator.spriteManager = spriteManager;
SkillCalculator.itemManager = itemManager; SkillCalculator.itemManager = itemManager;

View File

@@ -25,10 +25,9 @@
*/ */
package net.runelite.client.plugins.worldmap; package net.runelite.client.plugins.worldmap;
import java.io.IOException;
import javax.imageio.ImageIO;
import lombok.Getter; import lombok.Getter;
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
import net.runelite.client.util.ImageUtil;
class TeleportPoint extends WorldMapPoint class TeleportPoint extends WorldMapPoint
{ {
@@ -42,13 +41,6 @@ class TeleportPoint extends WorldMapPoint
this.data = data; this.data = data;
setTooltip(data.getTooltip()); setTooltip(data.getTooltip());
try setImage(ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, data.getIconPath()));
{
setImage(ImageIO.read(WorldMapPlugin.class.getResourceAsStream(data.getIconPath())));
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
} }

View File

@@ -29,9 +29,7 @@ import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import javax.imageio.ImageIO;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Experience; import net.runelite.api.Experience;
import net.runelite.api.Skill; import net.runelite.api.Skill;
@@ -41,6 +39,7 @@ import net.runelite.client.config.ConfigManager;
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.worldmap.WorldMapPointManager; import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor( @PluginDescriptor(
name = "World Map", name = "World Map",
@@ -73,23 +72,13 @@ public class WorldMapPlugin extends Plugin
BLANK_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB); BLANK_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
try FAIRY_TRAVEL_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
{ final BufferedImage fairyTravelIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "fairy_ring_travel.png");
synchronized (ImageIO.class) FAIRY_TRAVEL_ICON.getGraphics().drawImage(fairyTravelIcon, 1, 1, null);
{
FAIRY_TRAVEL_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage icon = ImageIO.read(WorldMapPlugin.class.getResourceAsStream("fairy_ring_travel.png"));
FAIRY_TRAVEL_ICON.getGraphics().drawImage(icon, 1, 1, null);
NOPE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB); NOPE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage nopeImage = ImageIO.read(WorldMapPlugin.class.getResourceAsStream("nope_icon.png")); final BufferedImage nopeImage = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "nope_icon.png");
NOPE_ICON.getGraphics().drawImage(nopeImage, 1, 1, null); NOPE_ICON.getGraphics().drawImage(nopeImage, 1, 1, null);
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
} }
@Inject @Inject

View File

@@ -33,7 +33,6 @@ import java.awt.image.BufferedImage;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Objects; import java.util.Objects;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
@@ -53,6 +52,7 @@ import static net.runelite.client.plugins.xptracker.XpWorldType.NORMAL;
import net.runelite.client.task.Schedule; import net.runelite.client.task.Schedule;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.util.ImageUtil;
import net.runelite.http.api.xp.XpClient; import net.runelite.http.api.xp.XpClient;
@PluginDescriptor( @PluginDescriptor(
@@ -102,11 +102,7 @@ public class XpTrackerPlugin extends Plugin
{ {
xpPanel = new XpPanel(this, client, skillIconManager); xpPanel = new XpPanel(this, client, skillIconManager);
BufferedImage icon; final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "/skill_icons/overall.png");
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("xp.png"));
}
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
.tooltip("XP Tracker") .tooltip("XP Tracker")

View File

@@ -38,9 +38,7 @@ import java.awt.LayoutManager;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.TrayIcon; import java.awt.TrayIcon;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@@ -70,6 +68,7 @@ import net.runelite.client.events.NavigationButtonAdded;
import net.runelite.client.events.NavigationButtonRemoved; import net.runelite.client.events.NavigationButtonRemoved;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.ui.skin.SubstanceRuneLiteLookAndFeel; import net.runelite.client.ui.skin.SubstanceRuneLiteLookAndFeel;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.OSType; import net.runelite.client.util.OSType;
import net.runelite.client.util.OSXUtil; import net.runelite.client.util.OSXUtil;
import net.runelite.client.util.SwingUtil; import net.runelite.client.util.SwingUtil;
@@ -95,27 +94,9 @@ public class ClientUI
static static
{ {
BufferedImage icon; ICON = ImageUtil.getResourceStreamFromClass(ClientUI.class, "/runelite.png");
BufferedImage sidebarOpen; SIDEBAR_OPEN = ImageUtil.getResourceStreamFromClass(ClientUI.class, "open.png");
BufferedImage sidebarClose; SIDEBAR_CLOSE = ImageUtil.flipImage(SIDEBAR_OPEN, true, false);
try
{
synchronized (ImageIO.class)
{
icon = ImageIO.read(ClientUI.class.getResourceAsStream("/runelite.png"));
sidebarOpen = ImageIO.read(ClientUI.class.getResourceAsStream("open.png"));
sidebarClose = ImageIO.read(ClientUI.class.getResourceAsStream("close.png"));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
ICON = icon;
SIDEBAR_OPEN = sidebarOpen;
SIDEBAR_CLOSE = sidebarClose;
} }
@Getter @Getter

View File

@@ -112,4 +112,14 @@ public class ColorUtil
{ {
return String.format("%06x", color.getRGB() & 0xFFFFFF); return String.format("%06x", color.getRGB() & 0xFFFFFF);
} }
static boolean isFullyTransparent(final Color color)
{
return color.getAlpha() == 0;
}
static boolean isNotFullyTransparent(final Color color)
{
return !isFullyTransparent(color);
}
} }

View File

@@ -0,0 +1,410 @@
/*
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.util;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
import java.io.IOException;
import java.util.Arrays;
import javax.imageio.ImageIO;
import javax.swing.GrayFilter;
import java.util.function.Predicate;
/**
* Various Image/BufferedImage utilities.
*/
public class ImageUtil
{
/**
* Creates a {@link BufferedImage} from an {@link Image}.
*
* @param image An Image to be converted to a BufferedImage.
* @return A BufferedImage instance of the same given image.
*/
public static BufferedImage bufferedImageFromImage(final Image image)
{
if (image instanceof BufferedImage)
{
return (BufferedImage) image;
}
final BufferedImage out = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = out.createGraphics();
g2d.drawImage(image, 0, 0, null);
g2d.dispose();
return out;
}
/**
* Offsets an image in the grayscale (darkens/brightens) by a given offset.
*
* @param image The image to be darkened or brightened.
* @param offset A signed 8-bit integer value to brighten or darken the image with.
* Values above 0 will brighten, and values below 0 will darken.
* @return The given image with its brightness adjusted by the given offset.
*/
public static BufferedImage grayscaleOffset(final BufferedImage image, final int offset)
{
final float offsetFloat = (float) offset;
final int numComponents = image.getColorModel().getNumComponents();
final float[] scales = new float[numComponents];
final float[] offsets = new float[numComponents];
Arrays.fill(scales, 1f);
for (int i = 0; i < numComponents; i++)
{
offsets[i] = offsetFloat;
}
// Set alpha to not offset
offsets[numComponents - 1] = 0f;
return offset(image, scales, offsets);
}
/**
* Offsets an image in the grayscale (darkens/brightens) by a given percentage.
*
* @param image The image to be darkened or brightened.
* @param percentage The ratio to darken or brighten the given image.
* Values above 1 will brighten, and values below 1 will darken.
* @return The given image with its brightness scaled by the given percentage.
*/
public static BufferedImage grayscaleOffset(final BufferedImage image, final float percentage)
{
final int numComponents = image.getColorModel().getNumComponents();
final float[] scales = new float[numComponents];
final float[] offsets = new float[numComponents];
Arrays.fill(offsets, 0f);
for (int i = 0; i < numComponents; i++)
{
scales[i] = percentage;
}
// Set alpha to not scale
scales[numComponents - 1] = 1f;
return offset(image, scales, offsets);
}
/**
* Offsets an image's alpha component by a given offset.
*
* @param image The image to be made more or less transparent.
* @param offset A signed 8-bit integer value to modify the image's alpha component with.
* Values above 0 will increase transparency, and values below 0 will decrease
* transparency.
* @return The given image with its alpha component adjusted by the given offset.
*/
public static BufferedImage alphaOffset(final BufferedImage image, final int offset)
{
final float offsetFloat = (float) offset;
final int numComponents = image.getColorModel().getNumComponents();
final float[] scales = new float[numComponents];
final float[] offsets = new float[numComponents];
Arrays.fill(scales, 1f);
Arrays.fill(offsets, 0f);
offsets[numComponents - 1] = offsetFloat;
return offset(image, scales, offsets);
}
/**
* Offsets an image's alpha component by a given percentage.
*
* @param image The image to be made more or less transparent.
* @param percentage The ratio to modify the image's alpha component with.
* Values above 1 will increase transparency, and values below 1 will decrease
* transparency.
* @return The given image with its alpha component scaled by the given percentage.
*/
public static BufferedImage alphaOffset(final BufferedImage image, final float percentage)
{
final int numComponents = image.getColorModel().getNumComponents();
final float[] scales = new float[numComponents];
final float[] offsets = new float[numComponents];
Arrays.fill(scales, 1f);
Arrays.fill(offsets, 0f);
scales[numComponents - 1] = percentage;
return offset(image, scales, offsets);
}
/**
* Creates a grayscale image from the given image.
*
* @param image The source image to be converted.
* @return A copy of the given imnage, with colors converted to grayscale.
*/
public static BufferedImage grayscaleImage(final BufferedImage image)
{
final Image grayImage = GrayFilter.createDisabledImage(image);
return ImageUtil.bufferedImageFromImage(grayImage);
}
/**
* Re-size a BufferedImage to the given dimensions.
*
* @param image the BufferedImage.
* @param newWidth The width to set the BufferedImage to.
* @param newHeight The height to set the BufferedImage to.
* @return The BufferedImage with the specified dimensions
*/
public static BufferedImage resizeImage(final BufferedImage image, final int newWidth, final int newHeight)
{
final Image resized = image.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH);
return ImageUtil.bufferedImageFromImage(resized);
}
/**
* Re-size a BufferedImage's canvas to the given dimensions.
*
* @param image The image whose canvas should be re-sized.
* @param newWidth The width to set the BufferedImage to.
* @param newHeight The height to set the BufferedImage to.
* @return The BufferedImage centered within canvas of given dimensions.
*/
public static BufferedImage resizeCanvas(final BufferedImage image, final int newWidth, final int newHeight)
{
final BufferedImage dimg = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
final int centeredX = newWidth / 2 - image.getWidth() / 2;
final int centeredY = newHeight / 2 - image.getHeight() / 2;
final Graphics2D g2d = dimg.createGraphics();
g2d.drawImage(image, centeredX, centeredY, null);
g2d.dispose();
return dimg;
}
/**
* Rotates an image around its center by a given number of radians.
*
* @param image The image to be rotated.
* @param theta The number of radians to rotate the image.
* @return The given image, rotated by the given theta.
*/
public static BufferedImage rotateImage(final BufferedImage image, final double theta)
{
AffineTransform transform = new AffineTransform();
transform.rotate(theta, image.getWidth() / 2.0, image.getHeight() / 2.0);
AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
return transformOp.filter(image, null);
}
/**
* Flips an image horizontally and/or vertically.
*
* @param image The image to be flipped.
* @param horizontal Whether the image should be flipped horizontally.
* @param vertical Whether the image should be flipped vertically.
* @return The given image, flipped horizontally and/or vertically.
*/
public static BufferedImage flipImage(final BufferedImage image, final boolean horizontal, final boolean vertical)
{
int x = 0;
int y = 0;
int w = image.getWidth();
int h = image.getHeight();
final BufferedImage out = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = out.createGraphics();
if (horizontal)
{
x = w;
w *= -1;
}
if (vertical)
{
y = h;
h *= -1;
}
g2d.drawImage(image, x, y, w, h, null);
g2d.dispose();
return out;
}
/**
* Outlines non-transparent pixels of a BufferedImage with the given color.
*
* @param image The image to be outlined.
* @param color The color to use for the outline.
* @return The BufferedImage with its edges outlined with the given color.
*/
public static BufferedImage outlineImage(final BufferedImage image, final Color color)
{
return outlineImage(image, color, ColorUtil::isNotFullyTransparent, false);
}
/**
* Outlines pixels of a BufferedImage with the given color, using a given predicate to colorize
* the given image for outlining.
*
* @param image The image to be outlined.
* @param color The color to use for the outline.
* @param fillCondition The predicate to be consumed by {@link #fillImage(BufferedImage, Color, Predicate) fillImage(BufferedImage, Color, Predicate)}
* @return The BufferedImage with its edges outlined with the given color.
*/
public static BufferedImage outlineImage(final BufferedImage image, final Color color, final Predicate<Color> fillCondition)
{
return outlineImage(image, color, fillCondition, false);
}
/**
* Outlines non-transparent pixels of a BufferedImage with the given color. Optionally outlines
* corners in addition to edges.
*
* @param image The image to be outlined.
* @param color The color to use for the outline.
* @param outlineCorners Whether to draw an outline around corners, or only around edges.
* @return The BufferedImage with its edges--and optionally, corners--outlined
* with the given color.
*/
public static BufferedImage outlineImage(final BufferedImage image, final Color color, final Boolean outlineCorners)
{
return outlineImage(image, color, ColorUtil::isNotFullyTransparent, outlineCorners);
}
/**
* Outlines pixels of a BufferedImage with the given color, using a given predicate to colorize
* the given image for outlining. Optionally outlines corners in addition to edges.
*
* @param image The image to be outlined.
* @param color The color to use for the outline.
* @param fillCondition The predicate to be consumed by {@link #fillImage(BufferedImage, Color, Predicate) fillImage(BufferedImage, Color, Predicate)}
* @param outlineCorners Whether to draw an outline around corners, or only around edges.
* @return The BufferedImage with its edges--and optionally, corners--outlined
* with the given color.
*/
public static BufferedImage outlineImage(final BufferedImage image, final Color color, final Predicate<Color> fillCondition, final Boolean outlineCorners)
{
final BufferedImage filledImage = fillImage(image, color, fillCondition);
final BufferedImage outlinedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = outlinedImage.createGraphics();
for (int x = -1; x <= 1; x++)
{
for (int y = -1; y <= 1; y++)
{
if ((x == 0 && y == 0)
|| (!outlineCorners && Math.abs(x) + Math.abs(y) != 1))
{
continue;
}
g2d.drawImage(filledImage, x, y, null);
}
}
g2d.drawImage(image, 0, 0, null);
g2d.dispose();
return outlinedImage;
}
/**
* Reads an image resource from a given path relative to a given class.
* This method is primarily shorthand for the synchronization and error handling required for
* loading image resources from classes.
*
* @param c The class to be referenced for resource path.
* @param path The path, relative to the given class.
* @return A {@link BufferedImage} of the loaded image resource from the given path.
*/
public static BufferedImage getResourceStreamFromClass(final Class c, final String path)
{
try
{
synchronized (ImageIO.class)
{
return ImageIO.read(c.getResourceAsStream(path));
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
/**
* Fills all non-transparent pixels of the given image with the given color.
*
* @param image The image which should have its non-transparent pixels filled.
* @param color The color with which to fill pixels.
* @return The given image with all non-transparent pixels set to the given color.
*/
static BufferedImage fillImage(final BufferedImage image, final Color color)
{
return fillImage(image, color, ColorUtil::isNotFullyTransparent);
}
/**
* Fills pixels of the given image with the given color based on a given fill condition
* predicate.
*
* @param image The image which should have its non-transparent pixels filled.
* @param color The color with which to fill pixels.
* @param fillCondition The condition on which to fill pixels with the given color.
* @return The given image with all pixels fulfilling the fill condition predicate
* set to the given color.
*/
static BufferedImage fillImage(final BufferedImage image, final Color color, final Predicate<Color> fillCondition)
{
final BufferedImage filledImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
for (int x = 0; x < filledImage.getWidth(); x++)
{
for (int y = 0; y < filledImage.getHeight(); y++)
{
final Color pixelColor = new Color(image.getRGB(x, y), true);
if (!fillCondition.test(pixelColor))
{
continue;
}
filledImage.setRGB(x, y, color.getRGB());
}
}
return filledImage;
}
/**
* Performs a rescale operation on the image's color components.
*
* @param image The image to be adjusted.
* @param scales An array of scale operations to be performed on the image's color components.
* @param offsets An array of offset operations to be performed on the image's color components.
* @return The modified image after applying the given adjustments.
*/
private static BufferedImage offset(final BufferedImage image, final float[] scales, final float[] offsets)
{
return new RescaleOp(scales, offsets, null).filter(image, null);
}
}

View File

@@ -29,10 +29,8 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.SystemTray; import java.awt.SystemTray;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.TrayIcon; import java.awt.TrayIcon;
@@ -42,8 +40,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.LookupOp;
import java.awt.image.LookupTable;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
@@ -106,40 +102,6 @@ public class SwingUtil
System.setProperty("sun.awt.noerasebackground", "true"); System.setProperty("sun.awt.noerasebackground", "true");
} }
/**
* Offsets an image in the grayscale (darkens/brightens) by an offset
*/
public static BufferedImage grayscaleOffset(BufferedImage image, int offset)
{
int numComponents = image.getColorModel().getNumComponents();
int index = numComponents - 1;
LookupTable lookup = new LookupTable(0, numComponents)
{
@Override
public int[] lookupPixel(int[] src, int[] dest)
{
if (dest[index] != 0)
{
dest[index] = dest[index] + offset;
if (dest[index] < 0)
{
dest[index] = 0;
}
else if (dest[index] > 255)
{
dest[index] = 255;
}
}
return dest;
}
};
LookupOp op = new LookupOp(lookup, new RenderingHints(null));
return op.filter(image, null);
}
/** /**
* Safely sets Swing theme * Safely sets Swing theme
* *
@@ -280,25 +242,6 @@ public class SwingUtil
}); });
} }
/**
* Re-size a BufferedImage to the given dimensions.
*
* @param image the BufferedImage.
* @param newWidth The width to set the BufferedImage to.
* @param newHeight The height to set the BufferedImage to.
* @return The BufferedImage with the specified dimensions
*/
private static BufferedImage resizeImage(BufferedImage image, int newWidth, int newHeight)
{
final Image tmp = image.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH);
final BufferedImage dimg = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = dimg.createGraphics();
g2d.drawImage(tmp, 0, 0, null);
g2d.dispose();
return dimg;
}
/** /**
* Create swing button from navigation button. * Create swing button from navigation button.
* *
@@ -314,7 +257,7 @@ public class SwingUtil
{ {
final BufferedImage scaledImage = iconSize > 0 final BufferedImage scaledImage = iconSize > 0
? resizeImage(navigationButton.getIcon(), iconSize, iconSize) ? ImageUtil.resizeImage(navigationButton.getIcon(), iconSize, iconSize)
: navigationButton.getIcon(); : navigationButton.getIcon();
final JButton button = new JButton(); final JButton button = new JButton();
@@ -364,5 +307,4 @@ public class SwingUtil
{ {
return SubstanceCoreUtilities.getTitlePaneComponent(frame) != null; return SubstanceCoreUtilities.getTitlePaneComponent(frame) != null;
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 742 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Some files were not shown because too many files have changed in this diff Show More