client: upstream

This commit is contained in:
TheRealNull
2021-01-10 12:08:49 -05:00
parent 9cc854c051
commit e440cad52f
84 changed files with 596 additions and 338 deletions

View File

@@ -49,7 +49,7 @@ public class SkillIconManager
String skillIconPath = (small ? "/skill_icons_small/" : "/skill_icons/")
+ skill.getName().toLowerCase() + ".png";
log.debug("Loading skill icon from {}", skillIconPath);
BufferedImage skillImage = ImageUtil.getResourceStreamFromClass(getClass(), skillIconPath);
BufferedImage skillImage = ImageUtil.loadImageResource(getClass(), skillIconPath);
imgCache[skillIdx] = skillImage;
return skillImage;

View File

@@ -162,7 +162,7 @@ public class SpriteManager
Class<?> owner = add[0].getClass();
for (SpriteOverride o : add)
{
BufferedImage image = ImageUtil.getResourceStreamFromClass(owner, o.getFileName());
BufferedImage image = ImageUtil.loadImageResource(owner, o.getFileName());
SpritePixels sp = ImageUtil.getImageSpritePixels(image, client);
overrides.put(o.getSpriteId(), sp);
}

View File

@@ -65,8 +65,8 @@ public class AccountPlugin extends Plugin
static
{
LOGIN_IMAGE = ImageUtil.getResourceStreamFromClass(AccountPlugin.class, "login_icon.png");
LOGOUT_IMAGE = ImageUtil.getResourceStreamFromClass(AccountPlugin.class, "logout_icon.png");
LOGIN_IMAGE = ImageUtil.loadImageResource(AccountPlugin.class, "login_icon.png");
LOGOUT_IMAGE = ImageUtil.loadImageResource(AccountPlugin.class, "logout_icon.png");
}
@Override

View File

@@ -100,7 +100,7 @@ public class BarbarianAssaultPlugin extends Plugin
overlayManager.add(timerOverlay);
overlayManager.add(healerOverlay);
clockImage = ImageUtil.getResourceStreamFromClass(getClass(), "clock.png");
clockImage = ImageUtil.loadImageResource(getClass(), "clock.png");
}
@Override

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.barrows;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.text.DecimalFormat;
import javax.inject.Inject;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
@@ -42,6 +43,8 @@ import net.runelite.client.ui.overlay.components.LineComponent;
public class BarrowsBrotherSlainOverlay extends OverlayPanel
{
private static final DecimalFormat REWARD_POTENTIAL_FORMATTER = new DecimalFormat("##0.00%");
private final Client client;
@Inject
@@ -84,10 +87,9 @@ public class BarrowsBrotherSlainOverlay extends OverlayPanel
}
final int rewardPotential = rewardPotential();
float rewardPercent = rewardPotential / 10.12f;
panelComponent.getChildren().add(LineComponent.builder()
.left("Potential")
.right(rewardPercent != 0 ? rewardPercent + "%" : "0%")
.right(REWARD_POTENTIAL_FORMATTER.format(rewardPotential / 1012f))
.rightColor(rewardPotential >= 756 && rewardPotential < 881 ? Color.GREEN : rewardPotential < 631 ? Color.WHITE : Color.YELLOW)
.build());

View File

@@ -119,8 +119,8 @@ public class BoostsPlugin extends Plugin
Arrays.fill(lastSkillLevels, -1);
// Add infoboxes for everything at startup and then determine inside if it will be rendered
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, ImageUtil.loadImageResource(getClass(), "debuffed.png"), this, config));
infoBoxManager.addInfoBox(new StatChangeIndicator(false, ImageUtil.loadImageResource(getClass(), "buffed.png"), this, config));
for (final Skill skill : Skill.values())
{

View File

@@ -625,7 +625,7 @@ public class ClueScrollPlugin extends Plugin
return emoteImage;
}
emoteImage = ImageUtil.getResourceStreamFromClass(getClass(), "emote.png");
emoteImage = ImageUtil.loadImageResource(getClass(), "emote.png");
return emoteImage;
}
@@ -642,7 +642,7 @@ public class ClueScrollPlugin extends Plugin
return mapArrow;
}
mapArrow = ImageUtil.getResourceStreamFromClass(getClass(), "/util/clue_arrow.png");
mapArrow = ImageUtil.loadImageResource(getClass(), "/util/clue_arrow.png");
return mapArrow;
}

View File

@@ -52,7 +52,7 @@ public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScr
new CipherClue("OVEXON", "Eluned", new WorldPoint(2289, 3144, 0), "Outside Lletya or in Prifddinas after Song of the Elves", "A question on elven crystal math. I have 5 and 3 crystals, large and small respectively. A large crystal is worth 10,000 coins and a small is worth but 1,000. How much are all my crystals worth?", "53,000"),
new CipherClue("VTYR APCNTGLW", "King Percival", new WorldPoint(2634, 4682, 1), "Fisher Realm, first floor. Fairy ring BJR", "How many cannons are on this here castle?", "5"),
new CipherClue("UZZU MUJHRKYYKJ", "Otto Godblessed", new WorldPoint(2501, 3487, 0), "Otto's Grotto", "How many pyre sites are found around this lake?", "3"),
new CipherClue("USBJCPSO", "Traiborn", new WorldPoint(3112, 3162, 0), "First floor of Wizards Tower", "How many air runes would I need to cast 630 wind waves?", "3150"),
new CipherClue("USBJCPSO", "Traiborn", new WorldPoint(3112, 3162, 0), "First floor of Wizards Tower. Fairy ring DIS", "How many air runes would I need to cast 630 wind waves?", "3150"),
new CipherClue("HCKTA IQFHCVJGT", "Fairy Godfather", new WorldPoint(2446, 4428, 0), "Zanaris throne room", "There are 3 inputs and 4 letters on each ring How many total individual fairy ring codes are possible?", "64"),
new CipherClue("ZSBKDO ZODO", "Pirate Pete", new WorldPoint(3680, 3537, 0), "Dock northeast of the Ectofunctus"),
new CipherClue("GBJSZ RVFFO", "Fairy Queen", new WorldPoint(2347, 4435, 0), "Fairy Resistance Hideout"),

View File

@@ -134,11 +134,11 @@ class ConfigPanel extends PluginPanel
static
{
final BufferedImage backIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_back_icon.png");
final BufferedImage backIcon = ImageUtil.loadImageResource(ConfigPanel.class, "config_back_icon.png");
BACK_ICON = new ImageIcon(backIcon);
BACK_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(backIcon, -100));
BufferedImage sectionRetractIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "/util/arrow_right.png");
BufferedImage sectionRetractIcon = ImageUtil.loadImageResource(ConfigPanel.class, "/util/arrow_right.png");
sectionRetractIcon = ImageUtil.luminanceOffset(sectionRetractIcon, -121);
SECTION_EXPAND_ICON = new ImageIcon(sectionRetractIcon);
SECTION_EXPAND_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(sectionRetractIcon, -100));
@@ -285,7 +285,7 @@ class ConfigPanel extends PluginPanel
String name = cs.name();
final JLabel sectionName = new JLabel(name);
sectionName.setForeground(ColorScheme.BRAND_BLUE);
sectionName.setForeground(ColorScheme.BRAND_ORANGE);
sectionName.setFont(FontManager.getRunescapeBoldFont());
sectionName.setToolTipText("<html>" + name + ":<br>" + cs.description() + "</html>");
sectionHeader.add(sectionName, BorderLayout.CENTER);

View File

@@ -83,7 +83,7 @@ public class ConfigPlugin extends Plugin
));
pluginListPanel.rebuildPluginList();
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "config_icon.png");
navButton = NavigationButton.builder()
.tooltip("Configuration")

View File

@@ -102,14 +102,14 @@ class PluginHubPanel extends PluginPanel
static
{
BufferedImage missingIcon = ImageUtil.getResourceStreamFromClass(PluginHubPanel.class, "pluginhub_missingicon.png");
BufferedImage missingIcon = ImageUtil.loadImageResource(PluginHubPanel.class, "pluginhub_missingicon.png");
MISSING_ICON = new ImageIcon(missingIcon);
BufferedImage helpIcon = ImageUtil.getResourceStreamFromClass(PluginHubPanel.class, "pluginhub_help.png");
BufferedImage helpIcon = ImageUtil.loadImageResource(PluginHubPanel.class, "pluginhub_help.png");
HELP_ICON = new ImageIcon(helpIcon);
HELP_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(helpIcon, -100));
BufferedImage configureIcon = ImageUtil.getResourceStreamFromClass(PluginHubPanel.class, "pluginhub_configure.png");
BufferedImage configureIcon = ImageUtil.loadImageResource(PluginHubPanel.class, "pluginhub_configure.png");
CONFIGURE_ICON = new ImageIcon(configureIcon);
CONFIGURE_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(configureIcon, -100));
}

View File

@@ -73,10 +73,10 @@ class PluginListItem extends JPanel implements SearchablePlugin
static
{
BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
BufferedImage onStar = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "star_on.png");
BufferedImage configIcon = ImageUtil.loadImageResource(ConfigPanel.class, "config_edit_icon.png");
BufferedImage onStar = ImageUtil.loadImageResource(ConfigPanel.class, "star_on.png");
CONFIG_ICON = new ImageIcon(configIcon);
ON_STAR = new ImageIcon(ImageUtil.recolorImage(onStar, ColorScheme.BRAND_BLUE));
ON_STAR = new ImageIcon(onStar);
CONFIG_ICON_HOVER = new ImageIcon(ImageUtil.luminanceOffset(configIcon, -100));
BufferedImage offStar = ImageUtil.luminanceScale(
@@ -216,7 +216,7 @@ class PluginListItem extends JPanel implements SearchablePlugin
}
/**
* Adds a mouseover effect to change the text of the passed label to {@link ColorScheme#BRAND_BLUE} color, and
* Adds a mouseover effect to change the text of the passed label to {@link ColorScheme#BRAND_ORANGE} color, and
* adds the passed menu items to a popup menu shown when the label is clicked.
*
* @param label The label to attach the mouseover and click effects to
@@ -258,7 +258,7 @@ class PluginListItem extends JPanel implements SearchablePlugin
public void mouseEntered(MouseEvent mouseEvent)
{
lastForeground = label.getForeground();
label.setForeground(ColorScheme.BRAND_BLUE);
label.setForeground(ColorScheme.BRAND_ORANGE);
}
@Override

View File

@@ -76,7 +76,6 @@ class PluginListPanel extends PluginPanel
private static final String RUNELITE_GROUP_NAME = RuneLiteConfig.class.getAnnotation(ConfigGroup.class).value();
private static final String PINNED_PLUGINS_CONFIG_KEY = "pinnedPlugins";
private static final ImmutableList<String> CATEGORY_TAGS = ImmutableList.of(
"OpenOSRS",
"Combat",
"Chat",
"Item",

View File

@@ -29,8 +29,8 @@ import java.awt.Dimension;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JToggleButton;
import com.openosrs.client.util.ImageUtil;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.SwingUtil;
class PluginToggleButton extends JToggleButton
@@ -40,7 +40,7 @@ class PluginToggleButton extends JToggleButton
static
{
BufferedImage onSwitcher = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "switcher_on.png");
BufferedImage onSwitcher = ImageUtil.loadImageResource(ConfigPanel.class, "switcher_on.png");
ON_SWITCHER = new ImageIcon(ImageUtil.recolorImage(onSwitcher, ColorScheme.BRAND_BLUE));
OFF_SWITCHER = new ImageIcon(ImageUtil.flipImage(
ImageUtil.luminanceScale(

View File

@@ -88,7 +88,7 @@ public class CrowdsourcingWoodcutting
put(AnimationID.WOODCUTTING_INFERNAL, ItemID.INFERNAL_AXE).
put(AnimationID.WOODCUTTING_3A_AXE, ItemID._3RD_AGE_AXE).
put(AnimationID.WOODCUTTING_CRYSTAL, ItemID.CRYSTAL_AXE).
put(AnimationID.WOODCUTTING_TRAILBLAZER, ItemID.TRAILBLAZER_AXE).build();
put(AnimationID.WOODCUTTING_TRAILBLAZER, ItemID.INFERNAL_AXE_OR).build();
private static final Set<String> SUCCESS_MESSAGES = new ImmutableSet.Builder<String>().
add("You get some logs.").

View File

@@ -54,6 +54,6 @@ public enum CustomCursor
CustomCursor(String name, String icon)
{
this.name = name;
this.cursorImage = ImageUtil.getResourceStreamFromClass(CustomCursorPlugin.class, icon);
this.cursorImage = ImageUtil.loadImageResource(CustomCursorPlugin.class, icon);
}
}

View File

@@ -174,7 +174,7 @@ class DevToolsPanel extends PluginPanel
final JButton newInfoboxBtn = new JButton("Infobox");
newInfoboxBtn.addActionListener(e ->
{
Counter counter = new Counter(ImageUtil.getResourceStreamFromClass(getClass(), "devtools_icon.png"), plugin, 42)
Counter counter = new Counter(ImageUtil.loadImageResource(getClass(), "devtools_icon.png"), plugin, 42)
{
@Override
public String getName()

View File

@@ -198,7 +198,7 @@ public class DevToolsPlugin extends Plugin
final DevToolsPanel panel = injector.getInstance(DevToolsPanel.class);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "devtools_icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "devtools_icon.png");
navButton = NavigationButton.builder()
.tooltip("Developer Tools")

View File

@@ -297,6 +297,7 @@ enum DiscordGameEventType
MG_PYRAMID_PLUNDER("Pyramid Plunder", DiscordAreaType.MINIGAMES, 7749),
MG_ROGUES_DEN("Rogues' Den", DiscordAreaType.MINIGAMES, 11855, 11854, 12111, 12110),
MG_SORCERESS_GARDEN("Sorceress's Garden", DiscordAreaType.MINIGAMES, 11605),
MG_SOUL_WARS("Soul Wars", DiscordAreaType.MINIGAMES, 8493, 8748, 8749, 9005),
MG_TEMPLE_TREKKING("Temple Trekking", DiscordAreaType.MINIGAMES, 8014, 8270, 8256, 8782, 9038, 9294, 9550, 9806),
MG_TITHE_FARM("Tithe Farm", DiscordAreaType.MINIGAMES, 7222),
MG_TROUBLE_BREWING("Trouble Brewing", DiscordAreaType.MINIGAMES, 15150),

View File

@@ -123,7 +123,7 @@ public class DiscordPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "discord.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "discord.png");
discordButton = NavigationButton.builder()
.tab(false)

View File

@@ -116,7 +116,7 @@ enum Emoji
BufferedImage loadImage()
{
return ImageUtil.getResourceStreamFromClass(getClass(), this.name().toLowerCase() + ".png");
return ImageUtil.loadImageResource(getClass(), this.name().toLowerCase() + ".png");
}
static Emoji getEmoji(String trigger)

View File

@@ -314,7 +314,7 @@ public class ExaminePlugin extends Plugin
return new int[]{widgetItem.getItemQuantity(), widgetItem.getItemId()};
}
}
else if (WidgetInfo.SHOP_ITEMS_CONTAINER.getGroupId() == widgetGroup)
else if (WidgetID.SHOP_GROUP_ID == widgetGroup)
{
Widget widgetItem = widget.getChild(actionParam);
if (widgetItem != null)

View File

@@ -101,8 +101,8 @@ class FeedPanel extends PluginPanel
static
{
RUNELITE_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(FeedPanel.class, "runelite.png"));
OSRS_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(FeedPanel.class, "osrs.png"));
RUNELITE_ICON = new ImageIcon(ImageUtil.loadImageResource(FeedPanel.class, "runelite.png"));
OSRS_ICON = new ImageIcon(ImageUtil.loadImageResource(FeedPanel.class, "osrs.png"));
}
private final FeedConfig config;

View File

@@ -97,7 +97,7 @@ public class FeedPlugin extends Plugin
{
feedPanel = injector.getInstance(FeedPanel.class);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "icon.png");
navButton = NavigationButton.builder()
.tooltip("News Feed")

View File

@@ -274,8 +274,8 @@ public class FishingPlugin extends Plugin
case ItemID.KARAMBWAN_VESSEL_3159:
case ItemID.CORMORANTS_GLOVE:
case ItemID.CORMORANTS_GLOVE_22817:
case ItemID.INFERNAL_HARPOON_OR:
case ItemID.TRAILBLAZER_HARPOON:
case ItemID.TRAILBLAZER_HARPOON_25114:
case ItemID.CRYSTAL_HARPOON:
case ItemID.CRYSTAL_HARPOON_23864:
case ItemID.CRYSTAL_HARPOON_INACTIVE:

View File

@@ -416,7 +416,7 @@ public class FriendNotesPlugin extends Plugin
return;
}
final BufferedImage iconImg = ImageUtil.getResourceStreamFromClass(getClass(), "note_icon.png");
final BufferedImage iconImg = ImageUtil.loadImageResource(getClass(), "note_icon.png");
if (iconImg == null)
{
return;

View File

@@ -269,6 +269,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
private int uniBlockLarge;
private int uniBlockMain;
private int uniSmoothBanding;
private int uniTextureLightMode;
@Override
protected void startUp()
@@ -538,6 +539,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
uniFogDepth = gl.glGetUniformLocation(glProgram, "fogDepth");
uniDrawDistance = gl.glGetUniformLocation(glProgram, "drawDistance");
uniColorBlindMode = gl.glGetUniformLocation(glProgram, "colorBlindMode");
uniTextureLightMode = gl.glGetUniformLocation(glProgram, "textureLightMode");
uniTex = gl.glGetUniformLocation(glUiProgram, "tex");
uniTexSamplingMode = gl.glGetUniformLocation(glUiProgram, "samplingMode");
@@ -791,9 +793,9 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
.put(client.getCenterX())
.put(client.getCenterY())
.put(client.getScale())
.put(client.getCameraX2())
.put(client.getCameraY2())
.put(client.getCameraZ2());
.put(cameraX)
.put(cameraY)
.put(cameraZ);
uniformBuffer.flip();
gl.glBufferSubData(gl.GL_UNIFORM_BUFFER, 0, uniformBuffer.limit() * Integer.BYTES, uniformBuffer);
@@ -1151,6 +1153,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
gl.glUniform1f(uniBrightness, (float) textureProvider.getBrightness());
gl.glUniform1f(uniSmoothBanding, config.smoothBanding() ? 0f : 1f);
gl.glUniform1i(uniColorBlindMode, config.colorBlindMode().ordinal());
gl.glUniform1f(uniTextureLightMode, config.brightTextures() ? 1f : 0f);
// Calculate projection matrix
Matrix4 projectionMatrix = new Matrix4();

View File

@@ -28,9 +28,9 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range;
import static net.runelite.client.plugins.gpu.GpuPlugin.MAX_DISTANCE;
import static net.runelite.client.plugins.gpu.GpuPlugin.MAX_FOG_DEPTH;
import net.runelite.client.plugins.gpu.config.AntiAliasingMode;
import static net.runelite.client.plugins.gpu.GpuPlugin.MAX_DISTANCE;
import net.runelite.client.plugins.gpu.config.ColorBlindMode;
import net.runelite.client.plugins.gpu.config.UIScalingMode;
@@ -135,4 +135,15 @@ public interface GpuPluginConfig extends Config
{
return ColorBlindMode.NONE;
}
@ConfigItem(
keyName = "brightTextures",
name = "Bright Textures",
description = "Use old texture lighting method which results in brighter game textures",
position = 9
)
default boolean brightTextures()
{
return false;
}
}

View File

@@ -82,7 +82,7 @@ public class GrandExchangeOfferSlot extends JPanel
static
{
final BufferedImage rightArrow = ImageUtil.alphaOffset(ImageUtil.getResourceStreamFromClass(GrandExchangeOfferSlot.class, "/util/arrow_right.png"), 0.25f);
final BufferedImage rightArrow = ImageUtil.alphaOffset(ImageUtil.loadImageResource(GrandExchangeOfferSlot.class, "/util/arrow_right.png"), 0.25f);
RIGHT_ARROW_ICON = new ImageIcon(rightArrow);
LEFT_ARROW_ICON = new ImageIcon(ImageUtil.flipImage(rightArrow, true, false));
}

View File

@@ -289,7 +289,7 @@ public class GrandExchangePlugin extends Plugin
{
panel = injector.getInstance(GrandExchangePanel.class);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "ge_icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "ge_icon.png");
button = NavigationButton.builder()
.tooltip("Grand Exchange")

View File

@@ -206,7 +206,7 @@ public class HiscorePanel extends PluginPanel
for (HiscoreEndpoint endpoint : ENDPOINTS)
{
final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), endpoint.name().toLowerCase() + ".png");
final BufferedImage iconImage = ImageUtil.loadImageResource(getClass(), endpoint.name().toLowerCase() + ".png");
MaterialTab tab = new MaterialTab(new ImageIcon(iconImage), tabGroup, null);
tab.setToolTipText(endpoint.getName() + " Hiscores");
@@ -282,6 +282,7 @@ public class HiscorePanel extends PluginPanel
minigamePanel.add(makeHiscorePanel(CLUE_SCROLL_ALL));
minigamePanel.add(makeHiscorePanel(LEAGUE_POINTS));
minigamePanel.add(makeHiscorePanel(LAST_MAN_STANDING));
minigamePanel.add(makeHiscorePanel(SOUL_WARS_ZEAL));
minigamePanel.add(makeHiscorePanel(BOUNTY_HUNTER_ROGUE));
minigamePanel.add(makeHiscorePanel(BOUNTY_HUNTER_HUNTER));
@@ -345,7 +346,7 @@ public class HiscorePanel extends PluginPanel
String skillIcon = directory + skillName + ".png";
log.debug("Loading skill icon from {}", skillIcon);
label.setIcon(new ImageIcon(ImageUtil.getResourceStreamFromClass(getClass(), skillIcon)));
label.setIcon(new ImageIcon(ImageUtil.loadImageResource(getClass(), skillIcon)));
boolean totalLabel = skill == OVERALL || skill == null; //overall or combat
label.setIconTextGap(totalLabel ? 10 : 4);
@@ -595,6 +596,18 @@ public class HiscorePanel extends PluginPanel
}
break;
}
case SOUL_WARS_ZEAL:
{
Skill soulWarsZeal = result.getSoulWarsZeal();
String rank = (soulWarsZeal.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(soulWarsZeal.getRank());
content += "<p><span style = 'color:white'>Soul Wars Zeal</span></p>";
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
if (soulWarsZeal.getLevel() > -1)
{
content += "<p><span style = 'color:white'>Score:</span> " + QuantityFormatter.formatNumber(soulWarsZeal.getLevel()) + "</p>";
}
break;
}
case LEAGUE_POINTS:
{
Skill leaguePoints = result.getLeaguePoints();

View File

@@ -94,7 +94,7 @@ public class HiscorePlugin extends Plugin
{
hiscorePanel = injector.getInstance(HiscorePanel.class);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "normal.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "normal.png");
navButton = NavigationButton.builder()
.tooltip("Hiscore")

View File

@@ -114,12 +114,12 @@ public class InfoPanel extends PluginPanel
static
{
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "/util/arrow_right.png"));
GITHUB_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "github_icon.png"));
DISCORD_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "discord_icon.png"));
PATREON_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "patreon_icon.png"));
WIKI_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "wiki_icon.png"));
IMPORT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "import_icon.png"));
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.loadImageResource(InfoPanel.class, "/util/arrow_right.png"));
GITHUB_ICON = new ImageIcon(ImageUtil.loadImageResource(InfoPanel.class, "github_icon.png"));
DISCORD_ICON = new ImageIcon(ImageUtil.loadImageResource(InfoPanel.class, "discord_icon.png"));
PATREON_ICON = new ImageIcon(ImageUtil.loadImageResource(InfoPanel.class, "patreon_icon.png"));
WIKI_ICON = new ImageIcon(ImageUtil.loadImageResource(InfoPanel.class, "wiki_icon.png"));
IMPORT_ICON = new ImageIcon(ImageUtil.loadImageResource(InfoPanel.class, "import_icon.png"));
}
void init()

View File

@@ -50,7 +50,7 @@ public class InfoPlugin extends Plugin
final InfoPanel panel = injector.getInstance(InfoPanel.class);
panel.init();
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "info_icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "info_icon.png");
navButton = NavigationButton.builder()
.tooltip("Info")

View File

@@ -264,7 +264,7 @@ public class InterfaceStylesPlugin extends Plugin
try
{
log.debug("Loading: {}", file);
BufferedImage image = ImageUtil.getResourceStreamFromClass(this.getClass(), file);
BufferedImage image = ImageUtil.loadImageResource(this.getClass(), file);
return ImageUtil.getImageSpritePixels(image, client);
}
catch (RuntimeException ex)

View File

@@ -59,7 +59,7 @@ class KourendLibraryPanel extends PluginPanel
static
{
final BufferedImage resetIcon = ImageUtil.getResourceStreamFromClass(KourendLibraryPanel.class, "/util/reset.png");
final BufferedImage resetIcon = ImageUtil.loadImageResource(KourendLibraryPanel.class, "/util/reset.png");
RESET_ICON = new ImageIcon(resetIcon);
RESET_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(resetIcon, -100));
}

View File

@@ -134,7 +134,7 @@ public class KourendLibraryPlugin extends Plugin
panel = injector.getInstance(KourendLibraryPanel.class);
panel.init();
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "panel_icon.png");
navButton = NavigationButton.builder()
.tooltip("Kourend Library")

View File

@@ -308,7 +308,7 @@ public class LoginScreenPlugin extends Plugin implements KeyListener
try
{
log.debug("Loading: {}", file);
BufferedImage image = ImageUtil.getResourceStreamFromClass(this.getClass(), file);
BufferedImage image = ImageUtil.loadImageResource(this.getClass(), file);
return ImageUtil.getImageSpritePixels(image, client);
}
catch (RuntimeException ex)

View File

@@ -131,13 +131,13 @@ class LootTrackerPanel extends PluginPanel
static
{
final BufferedImage singleLootImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "single_loot_icon.png");
final BufferedImage groupedLootImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "grouped_loot_icon.png");
final BufferedImage backArrowImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "back_icon.png");
final BufferedImage visibleImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "visible_icon.png");
final BufferedImage invisibleImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "invisible_icon.png");
final BufferedImage collapseImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "collapsed.png");
final BufferedImage expandedImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "expanded.png");
final BufferedImage singleLootImg = ImageUtil.loadImageResource(LootTrackerPlugin.class, "single_loot_icon.png");
final BufferedImage groupedLootImg = ImageUtil.loadImageResource(LootTrackerPlugin.class, "grouped_loot_icon.png");
final BufferedImage backArrowImg = ImageUtil.loadImageResource(LootTrackerPlugin.class, "back_icon.png");
final BufferedImage visibleImg = ImageUtil.loadImageResource(LootTrackerPlugin.class, "visible_icon.png");
final BufferedImage invisibleImg = ImageUtil.loadImageResource(LootTrackerPlugin.class, "invisible_icon.png");
final BufferedImage collapseImg = ImageUtil.loadImageResource(LootTrackerPlugin.class, "collapsed.png");
final BufferedImage expandedImg = ImageUtil.loadImageResource(LootTrackerPlugin.class, "expanded.png");
SINGLE_LOOT_VIEW = new ImageIcon(singleLootImg);
SINGLE_LOOT_VIEW_FADED = new ImageIcon(ImageUtil.alphaOffset(singleLootImg, -180));

View File

@@ -363,7 +363,7 @@ public class LootTrackerPlugin extends Plugin
panel = new LootTrackerPanel(this, itemManager, config);
spriteManager.getSpriteAsync(SpriteID.TAB_INVENTORY, 0, panel::loadHeaderIcon);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "panel_icon.png");
navButton = NavigationButton.builder()
.tooltip("Loot Tracker")

View File

@@ -73,7 +73,7 @@ import static net.runelite.api.ItemID.MITHRIL_PICKAXE;
import static net.runelite.api.ItemID.RUNE_PICKAXE;
import static net.runelite.api.ItemID.STEEL_PICKAXE;
import static net.runelite.api.ItemID._3RD_AGE_PICKAXE;
import static net.runelite.api.ItemID.TRAILBLAZER_PICKAXE;
import static net.runelite.api.ItemID.INFERNAL_PICKAXE_OR;
import net.runelite.api.Player;
@Getter
@@ -93,7 +93,7 @@ enum Pickaxe
INFERNAL(INFERNAL_PICKAXE, MINING_INFERNAL_PICKAXE, MINING_MOTHERLODE_INFERNAL),
THIRDAGE(_3RD_AGE_PICKAXE, MINING_3A_PICKAXE, MINING_MOTHERLODE_3A),
CRYSTAL(CRYSTAL_PICKAXE, MINING_CRYSTAL_PICKAXE, MINING_MOTHERLODE_CRYSTAL),
TRAILBLAZER(TRAILBLAZER_PICKAXE, MINING_TRAILBLAZER_PICKAXE, MINING_TRAILBLAZER_PICKAXE_2,
TRAILBLAZER(INFERNAL_PICKAXE_OR, MINING_TRAILBLAZER_PICKAXE, MINING_TRAILBLAZER_PICKAXE_2,
MINING_TRAILBLAZER_PICKAXE_3, MINING_MOTHERLODE_TRAILBLAZER);
private final int itemId;

View File

@@ -48,7 +48,7 @@ public class AlchemyRoomTimer extends Timer
return image;
}
image = ImageUtil.getResourceStreamFromClass(AlchemyRoomTimer.class, "/util/reset.png");
image = ImageUtil.loadImageResource(AlchemyRoomTimer.class, "/util/reset.png");
return image;
}

View File

@@ -155,4 +155,4 @@ public interface MusicConfig extends Config
hidden = true
)
void setAreaSoundEffectVolume(int vol);
}
}

View File

@@ -924,4 +924,4 @@ public class MusicPlugin extends Plugin
soundEffectPlayed.consume();
}
}
}
}

View File

@@ -65,7 +65,7 @@ public class NotesPlugin extends Plugin
panel = injector.getInstance(NotesPanel.class);
panel.init(config);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "notes_icon.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "notes_icon.png");
navButton = NavigationButton.builder()
.tooltip("Notes")

View File

@@ -48,7 +48,6 @@ import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.Text;
public class NpcSceneOverlay extends Overlay
@@ -200,7 +199,7 @@ public class NpcSceneOverlay extends Overlay
graphics.setColor(color);
graphics.setStroke(new BasicStroke(2));
graphics.draw(polygon);
graphics.setColor(ColorUtil.colorWithAlpha(color, color.getAlpha() / 12));
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
graphics.fill(polygon);
}
}

View File

@@ -34,7 +34,7 @@ import net.runelite.client.ws.PartyMember;
class PartyWorldMapPoint extends WorldMapPoint
{
private static final BufferedImage ARROW = ImageUtil.getResourceStreamFromClass(PartyWorldMapPoint.class, "/util/clue_arrow.png");
private static final BufferedImage ARROW = ImageUtil.loadImageResource(PartyWorldMapPoint.class, "/util/clue_arrow.png");
private BufferedImage partyImage;
private final PartyMember member;

View File

@@ -143,7 +143,7 @@ public enum PohIcons
return image;
}
image = ImageUtil.getResourceStreamFromClass(getClass(), getImageResource() + ".png");
image = ImageUtil.loadImageResource(getClass(), getImageResource() + ".png");
return image;
}

View File

@@ -71,9 +71,9 @@ public class PoisonPlugin extends Plugin
static
{
HEART_DISEASE = ImageUtil.resizeCanvas(ImageUtil.getResourceStreamFromClass(AlternateSprites.class, AlternateSprites.DISEASE_HEART), 26, 26);
HEART_POISON = ImageUtil.resizeCanvas(ImageUtil.getResourceStreamFromClass(AlternateSprites.class, AlternateSprites.POISON_HEART), 26, 26);
HEART_VENOM = ImageUtil.resizeCanvas(ImageUtil.getResourceStreamFromClass(AlternateSprites.class, AlternateSprites.VENOM_HEART), 26, 26);
HEART_DISEASE = ImageUtil.resizeCanvas(ImageUtil.loadImageResource(AlternateSprites.class, AlternateSprites.DISEASE_HEART), 26, 26);
HEART_POISON = ImageUtil.resizeCanvas(ImageUtil.loadImageResource(AlternateSprites.class, AlternateSprites.POISON_HEART), 26, 26);
HEART_VENOM = ImageUtil.resizeCanvas(ImageUtil.loadImageResource(AlternateSprites.class, AlternateSprites.VENOM_HEART), 26, 26);
}
@Inject

View File

@@ -52,8 +52,8 @@ class PrayerBarOverlay extends Overlay
private static final Color FLICK_HELP_COLOR = Color.white;
private static final Dimension PRAYER_BAR_SIZE = new Dimension(30, 5);
private static final int HD_PRAYER_BAR_PADDING = 1;
private static final BufferedImage HD_FRONT_BAR = ImageUtil.getResourceStreamFromClass(PrayerPlugin.class, "front.png");
private static final BufferedImage HD_BACK_BAR = ImageUtil.getResourceStreamFromClass(PrayerPlugin.class, "back.png");
private static final BufferedImage HD_FRONT_BAR = ImageUtil.loadImageResource(PrayerPlugin.class, "front.png");
private static final BufferedImage HD_BACK_BAR = ImageUtil.loadImageResource(PrayerPlugin.class, "back.png");
private final Client client;
private final PrayerConfig config;

View File

@@ -125,7 +125,7 @@ public class ScreenMarkerPlugin extends Plugin
pluginPanel = new ScreenMarkerPluginPanel(this);
pluginPanel.rebuild();
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), ICON_FILE);
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), ICON_FILE);
navigationButton = NavigationButton.builder()
.tooltip(PLUGIN_NAME)

View File

@@ -54,8 +54,8 @@ public class ScreenMarkerCreationPanel extends JPanel
static
{
CONFIRM_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "confirm_icon.png"));
CANCEL_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "cancel_icon.png"));
CONFIRM_ICON = new ImageIcon(ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "confirm_icon.png"));
CANCEL_ICON = new ImageIcon(ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "cancel_icon.png"));
final BufferedImage confirmIcon = ImageUtil.bufferedImageFromImage(CONFIRM_ICON.getImage());
CONFIRM_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(confirmIcon, 0.54f));

View File

@@ -107,7 +107,7 @@ class ScreenMarkerPanel extends JPanel
static
{
final BufferedImage borderImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "border_color_icon.png");
final BufferedImage borderImg = ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "border_color_icon.png");
final BufferedImage borderImgHover = ImageUtil.luminanceOffset(borderImg, -150);
BORDER_COLOR_ICON = new ImageIcon(borderImg);
BORDER_COLOR_HOVER_ICON = new ImageIcon(borderImgHover);
@@ -115,7 +115,7 @@ class ScreenMarkerPanel extends JPanel
NO_BORDER_COLOR_ICON = new ImageIcon(borderImgHover);
NO_BORDER_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(borderImgHover, -100));
final BufferedImage fillImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "fill_color_icon.png");
final BufferedImage fillImg = ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "fill_color_icon.png");
final BufferedImage fillImgHover = ImageUtil.luminanceOffset(fillImg, -150);
FILL_COLOR_ICON = new ImageIcon(fillImg);
FILL_COLOR_HOVER_ICON = new ImageIcon(fillImgHover);
@@ -123,7 +123,7 @@ class ScreenMarkerPanel extends JPanel
NO_FILL_COLOR_ICON = new ImageIcon(fillImgHover);
NO_FILL_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(fillImgHover, -100));
final BufferedImage opacityImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "opacity_icon.png");
final BufferedImage opacityImg = ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "opacity_icon.png");
final BufferedImage opacityImgHover = ImageUtil.luminanceOffset(opacityImg, -150);
FULL_OPACITY_ICON = new ImageIcon(opacityImg);
FULL_OPACITY_HOVER_ICON = new ImageIcon(opacityImgHover);
@@ -131,15 +131,15 @@ class ScreenMarkerPanel extends JPanel
NO_OPACITY_ICON = new ImageIcon(opacityImgHover);
NO_OPACITY_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(opacityImgHover, -100));
final BufferedImage visibleImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "visible_icon.png");
final BufferedImage visibleImg = ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "visible_icon.png");
VISIBLE_ICON = new ImageIcon(visibleImg);
VISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(visibleImg, -100));
final BufferedImage invisibleImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "invisible_icon.png");
final BufferedImage invisibleImg = ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "invisible_icon.png");
INVISIBLE_ICON = new ImageIcon(invisibleImg);
INVISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -100));
final BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "delete_icon.png");
final BufferedImage deleteImg = ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "delete_icon.png");
DELETE_ICON = new ImageIcon(deleteImg);
DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100));
}

View File

@@ -77,7 +77,7 @@ public class ScreenMarkerPluginPanel extends PluginPanel
static
{
final BufferedImage addIcon = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "add_icon.png");
final BufferedImage addIcon = ImageUtil.loadImageResource(ScreenMarkerPlugin.class, "add_icon.png");
ADD_ICON = new ImageIcon(addIcon);
ADD_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(addIcon, 0.53f));
}

View File

@@ -186,7 +186,7 @@ public class ScreenshotPlugin extends Plugin
SCREENSHOT_DIR.mkdirs();
keyManager.registerKeyListener(hotkeyListener);
final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), "screenshot.png");
final BufferedImage iconImage = ImageUtil.loadImageResource(getClass(), "screenshot.png");
titleBarButton = NavigationButton.builder()
.tab(false)

View File

@@ -64,7 +64,7 @@ public class SkillCalculatorPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "calc.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "calc.png");
final SkillCalculatorPanel uiPanel = new SkillCalculatorPanel(skillIconManager, client, spriteManager, itemManager);
uiNavigationButton = NavigationButton.builder()

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.specialcounter;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
@@ -34,13 +35,15 @@ import net.runelite.client.ui.overlay.infobox.Counter;
class SpecialCounter extends Counter
{
private final SpecialWeapon weapon;
private final SpecialCounterConfig config;
@Getter(AccessLevel.PACKAGE)
private final Map<String, Integer> partySpecs = new HashMap<>();
SpecialCounter(BufferedImage image, SpecialCounterPlugin plugin, int hitValue, SpecialWeapon weapon)
SpecialCounter(BufferedImage image, SpecialCounterPlugin plugin, SpecialCounterConfig config, int hitValue, SpecialWeapon weapon)
{
super(image, plugin, hitValue);
this.weapon = weapon;
this.config = config;
}
void addHits(double hit)
@@ -90,4 +93,16 @@ class SpecialCounter extends Counter
return weapon.getName() + " special has hit " + hitValue + " total.";
}
}
@Override
public Color getTextColor()
{
int threshold = weapon.getThreshold().apply(config);
if (threshold > 0)
{
int count = getCount();
return count >= threshold ? Color.GREEN : Color.RED;
}
return super.getTextColor();
}
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 2020, Dylan <dylanhe@umich.edu>
* Copyright (c) 2020, Jacob <jgozon@umich.edu>
* 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.plugins.specialcounter;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("specialcounter")
public interface SpecialCounterConfig extends Config
{
@ConfigItem(
position = 0,
keyName = "thresholdNotification",
name = "Threshold Notifications",
description = "Sends a notification when your special attack counter exceeds the threshold"
)
default boolean thresholdNotification()
{
return false;
}
@ConfigItem(
position = 1,
keyName = "dragonWarhammerThreshold",
name = "Dragon Warhammer",
description = "Threshold for Dragon Warhammer (0 to disable)"
)
default int dragonWarhammerThreshold()
{
return 0;
}
@ConfigItem(
position = 2,
keyName = "arclightThreshold",
name = "Arclight",
description = "Threshold for Arclight (0 to disable)"
)
default int arclightThreshold()
{
return 0;
}
@ConfigItem(
position = 3,
keyName = "darklightThreshold",
name = "Darklight",
description = "Threshold for Darklight (0 to disable)"
)
default int darklightThreshold()
{
return 0;
}
@ConfigItem(
position = 4,
keyName = "bandosGodswordThreshold",
name = "Bandos Godsword",
description = "Threshold for Bandos Godsword (0 to disable)"
)
default int bandosGodswordThreshold()
{
return 0;
}
}

View File

@@ -24,6 +24,8 @@
*/
package net.runelite.client.plugins.specialcounter;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -38,13 +40,16 @@ import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemContainer;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
import net.runelite.api.VarPlayer;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.VarbitChanged;
import net.runelite.client.Notifier;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin;
@@ -62,6 +67,11 @@ import net.runelite.client.ws.WSClient;
@Slf4j
public class SpecialCounterPlugin extends Plugin
{
private static final Set<Integer> IGNORED_NPCS = ImmutableSet.of(
NpcID.DARK_ENERGY_CORE, NpcID.ZOMBIFIED_SPAWN, NpcID.ZOMBIFIED_SPAWN_8063,
NpcID.COMBAT_DUMMY, NpcID.UNDEAD_COMBAT_DUMMY
);
private int currentWorld;
private int specialPercentage;
private Actor lastSpecTarget;
@@ -89,6 +99,18 @@ public class SpecialCounterPlugin extends Plugin
@Inject
private ItemManager itemManager;
@Inject
private Notifier notifier;
@Inject
private SpecialCounterConfig config;
@Provides
SpecialCounterConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(SpecialCounterConfig.class);
}
@Override
protected void startUp()
{
@@ -191,6 +213,11 @@ public class SpecialCounterPlugin extends Plugin
NPC npc = (NPC) target;
int interactingId = npc.getId();
if (IGNORED_NPCS.contains(interactingId))
{
return;
}
// If this is a new NPC reset the counters
if (!interactedNpcIds.contains(interactingId))
{
@@ -301,7 +328,7 @@ public class SpecialCounterPlugin extends Plugin
if (counter == null)
{
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()), this,
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()), this, config,
hit, specialWeapon);
infoBoxManager.addInfoBox(counter);
specialCounter[specialWeapon.ordinal()] = counter;
@@ -311,6 +338,9 @@ public class SpecialCounterPlugin extends Plugin
counter.addHits(hit);
}
// Display a notification if special attack thresholds are met
sendNotification(specialWeapon, counter);
// If in a party, add hit to partySpecs for the infobox tooltip
Map<String, Integer> partySpecs = counter.getPartySpecs();
if (!party.getMembers().isEmpty())
@@ -326,6 +356,15 @@ public class SpecialCounterPlugin extends Plugin
}
}
private void sendNotification(SpecialWeapon weapon, SpecialCounter counter)
{
int threshold = weapon.getThreshold().apply(config);
if (threshold > 0 && counter.getCount() >= threshold && config.thresholdNotification())
{
notifier.notify(weapon.getName() + " special attack threshold reached!");
}
}
private void removeCounters()
{
interactedNpcIds.clear();

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.specialcounter;
import java.util.function.Function;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.ItemID;
@@ -32,13 +33,14 @@ import net.runelite.api.ItemID;
@Getter
enum SpecialWeapon
{
DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false),
ARCLIGHT("Arclight", ItemID.ARCLIGHT, false),
DARKLIGHT("Darklight", ItemID.DARKLIGHT, false),
BANDOS_GODSWORD("Bandos Godsword", ItemID.BANDOS_GODSWORD, true),
BANDOS_GODSWORD_OR("Bandos Godsword", ItemID.BANDOS_GODSWORD_OR, true);
DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false, SpecialCounterConfig::dragonWarhammerThreshold),
ARCLIGHT("Arclight", ItemID.ARCLIGHT, false, SpecialCounterConfig::arclightThreshold),
DARKLIGHT("Darklight", ItemID.DARKLIGHT, false, SpecialCounterConfig::darklightThreshold),
BANDOS_GODSWORD("Bandos Godsword", ItemID.BANDOS_GODSWORD, true, SpecialCounterConfig::bandosGodswordThreshold),
BANDOS_GODSWORD_OR("Bandos Godsword", ItemID.BANDOS_GODSWORD_OR, true, SpecialCounterConfig::bandosGodswordThreshold);
private final String name;
private final int itemID;
private final boolean damage;
private final Function<SpecialCounterConfig, Integer> threshold;
}

View File

@@ -311,9 +311,9 @@ class StatusBarsOverlay extends Overlay
}
heartIcon = ImageUtil.resizeCanvas(Objects.requireNonNull(spriteManager.getSprite(SpriteID.MINIMAP_ORB_HITPOINTS_ICON, 0)), ICON_DIMENSIONS, ICON_DIMENSIONS);
heartDisease = ImageUtil.resizeCanvas(ImageUtil.getResourceStreamFromClass(AlternateSprites.class, AlternateSprites.DISEASE_HEART), ICON_DIMENSIONS, ICON_DIMENSIONS);
heartPoison = ImageUtil.resizeCanvas(ImageUtil.getResourceStreamFromClass(AlternateSprites.class, AlternateSprites.POISON_HEART), ICON_DIMENSIONS, ICON_DIMENSIONS);
heartVenom = ImageUtil.resizeCanvas(ImageUtil.getResourceStreamFromClass(AlternateSprites.class, AlternateSprites.VENOM_HEART), ICON_DIMENSIONS, ICON_DIMENSIONS);
heartDisease = ImageUtil.resizeCanvas(ImageUtil.loadImageResource(AlternateSprites.class, AlternateSprites.DISEASE_HEART), ICON_DIMENSIONS, ICON_DIMENSIONS);
heartPoison = ImageUtil.resizeCanvas(ImageUtil.loadImageResource(AlternateSprites.class, AlternateSprites.POISON_HEART), ICON_DIMENSIONS, ICON_DIMENSIONS);
heartVenom = ImageUtil.resizeCanvas(ImageUtil.loadImageResource(AlternateSprites.class, AlternateSprites.VENOM_HEART), ICON_DIMENSIONS, ICON_DIMENSIONS);
energyIcon = ImageUtil.resizeCanvas(Objects.requireNonNull(spriteManager.getSprite(SpriteID.MINIMAP_ORB_WALK_ICON, 0)), ICON_DIMENSIONS, ICON_DIMENSIONS);
specialIcon = ImageUtil.resizeCanvas(Objects.requireNonNull(spriteManager.getSprite(SpriteID.MINIMAP_ORB_SPECIAL_ICON, 0)), ICON_DIMENSIONS, ICON_DIMENSIONS);
}

View File

@@ -57,7 +57,7 @@ class OverviewItemPanel extends JPanel
static
{
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "/util/arrow_right.png"));
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.loadImageResource(TimeTrackingPlugin.class, "/util/arrow_right.png"));
}
OverviewItemPanel(ItemManager itemManager, TimeTrackingPanel pluginPanel, Tab tab, String title)

View File

@@ -124,7 +124,7 @@ public class TimeTrackingPlugin extends Plugin
birdHouseTracker.loadFromConfig();
farmingTracker.loadCompletionTimes();
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "watch.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "watch.png");
panel = injector.getInstance(TimeTrackingPanel.class);

View File

@@ -71,14 +71,14 @@ public class ClockTabPanel extends TabContentPanel
static
{
BufferedImage deleteIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "delete_icon.png");
BufferedImage lapIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "lap_icon.png");
BufferedImage pauseIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "pause_icon.png");
BufferedImage resetIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "reset_icon.png");
BufferedImage startIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "start_icon.png");
BufferedImage addIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "add_icon.png");
BufferedImage loopIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "loop_icon.png");
BufferedImage loopSelectedIcon = ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "loop_selected_icon.png");
BufferedImage deleteIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "delete_icon.png");
BufferedImage lapIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "lap_icon.png");
BufferedImage pauseIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "pause_icon.png");
BufferedImage resetIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "reset_icon.png");
BufferedImage startIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "start_icon.png");
BufferedImage addIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "add_icon.png");
BufferedImage loopIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "loop_icon.png");
BufferedImage loopSelectedIcon = ImageUtil.loadImageResource(TimeTrackingPlugin.class, "loop_selected_icon.png");
DELETE_ICON = new ImageIcon(deleteIcon);
DELETE_ICON_HOVER = new ImageIcon(ImageUtil.luminanceOffset(deleteIcon, -80));

View File

@@ -52,7 +52,7 @@ import static net.runelite.api.ItemID.IRON_AXE;
import static net.runelite.api.ItemID.MITHRIL_AXE;
import static net.runelite.api.ItemID.RUNE_AXE;
import static net.runelite.api.ItemID.STEEL_AXE;
import static net.runelite.api.ItemID.TRAILBLAZER_AXE;
import static net.runelite.api.ItemID.INFERNAL_AXE_OR;
import static net.runelite.api.ItemID._3RD_AGE_AXE;
import net.runelite.api.Player;
@@ -72,7 +72,7 @@ enum Axe
INFERNAL(WOODCUTTING_INFERNAL, INFERNAL_AXE),
THIRDAGE(WOODCUTTING_3A_AXE, _3RD_AGE_AXE),
CRYSTAL(WOODCUTTING_CRYSTAL, CRYSTAL_AXE),
TRAILBLAZER(WOODCUTTING_TRAILBLAZER, TRAILBLAZER_AXE);
TRAILBLAZER(WOODCUTTING_TRAILBLAZER, INFERNAL_AXE_OR);
private final Integer animId;
private final Integer itemId;

View File

@@ -40,7 +40,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import javax.swing.SwingUtilities;
import lombok.AccessLevel;
@@ -83,6 +82,7 @@ import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ExecutorServiceExceptionLogger;
import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text;
import net.runelite.client.util.WorldUtil;
import net.runelite.http.api.worlds.World;
@@ -190,12 +190,7 @@ public class WorldHopperPlugin extends Plugin
panel = new WorldSwitcherPanel(this);
final BufferedImage icon;
synchronized (ImageIO.class)
{
icon = ImageIO.read(getClass().getResourceAsStream("icon.png"));
}
BufferedImage icon = ImageUtil.loadImageResource(WorldHopperPlugin.class, "icon.png");
navButton = NavigationButton.builder()
.tooltip("World Switcher")
.icon(icon)

View File

@@ -54,7 +54,7 @@ class WorldTableHeader extends JPanel
static
{
final BufferedImage arrowDown = ImageUtil.getResourceStreamFromClass(WorldHopperPlugin.class, "arrow_down.png");
final BufferedImage arrowDown = ImageUtil.loadImageResource(WorldHopperPlugin.class, "arrow_down.png");
final BufferedImage arrowUp = ImageUtil.rotateImage(arrowDown, Math.PI);
final BufferedImage arrowUpFaded = ImageUtil.luminanceOffset(arrowUp, -80);
ARROW_UP = new ImageIcon(arrowUpFaded);

View File

@@ -66,10 +66,10 @@ class WorldTableRow extends JPanel
static
{
FLAG_AUS = new ImageIcon(ImageUtil.getResourceStreamFromClass(WorldHopperPlugin.class, "flag_aus.png"));
FLAG_UK = new ImageIcon(ImageUtil.getResourceStreamFromClass(WorldHopperPlugin.class, "flag_uk.png"));
FLAG_US = new ImageIcon(ImageUtil.getResourceStreamFromClass(WorldHopperPlugin.class, "flag_us.png"));
FLAG_GER = new ImageIcon(ImageUtil.getResourceStreamFromClass(WorldHopperPlugin.class, "flag_ger.png"));
FLAG_AUS = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_aus.png"));
FLAG_UK = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_uk.png"));
FLAG_US = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_us.png"));
FLAG_GER = new ImageIcon(ImageUtil.loadImageResource(WorldHopperPlugin.class, "flag_ger.png"));
}
private final JMenuItem favoriteMenuOption = new JMenuItem();

View File

@@ -40,6 +40,9 @@ enum MiningSiteLocation
new Rock(3, Ore.COPPER), new Rock(1, Ore.TIN), new Rock(7, Ore.IRON), new Rock(5, Ore.SILVER),
new Rock(3, Ore.COAL), new Rock(3, Ore.MITHRIL), new Rock(2, Ore.ADAMANTITE)),
AL_KHARID_MINE_SOUTH(new WorldPoint(3298, 3282, 0), new Rock(2, Ore.IRON), new Rock(2, Ore.GOLD)),
ANCIENT_CAVERN_NORTH(new WorldPoint(1847, 5414, 0), new Rock(4, Ore.MITHRIL)),
ANCIENT_CAVERN_SOUTH(new WorldPoint(1826, 5392, 0), new Rock(2, Ore.MITHRIL)),
ANCIENT_CAVERN_MIDDLE(new WorldPoint(1840, 5397, 0), new Rock(8, Ore.MITHRIL)),
ARANDAR(new WorldPoint(2322, 3269, 0), new Rock(8, Ore.LIMESTONE)),
ARANDAR_PRIFDDINAS_MAP(new WorldPoint(3346, 6021, 0), new Rock(8, Ore.LIMESTONE)),
ARCEUUS_NORTH(new WorldPoint(1763, 3860, 0), new Rock(1, Ore.DENSE_ESSENCE)),

View File

@@ -33,7 +33,7 @@ class RunecraftingAltarPoint extends WorldMapPoint
RunecraftingAltarPoint(RunecraftingAltarLocation point)
{
super(point.getLocation(), WorldMapPlugin.BLANK_ICON);
setImage(ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, point.getIconPath()));
setImage(ImageUtil.loadImageResource(WorldMapPlugin.class, point.getIconPath()));
setTooltip(point.getTooltip());
}
}

View File

@@ -34,6 +34,6 @@ class TeleportPoint extends WorldMapPoint
{
super(data.getLocation(), WorldMapPlugin.BLANK_ICON);
setTooltip(data.getTooltip());
setImage(ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, data.getIconPath()));
setImage(ImageUtil.loadImageResource(WorldMapPlugin.class, data.getIconPath()));
}
}

View File

@@ -101,31 +101,31 @@ public class WorldMapPlugin extends Plugin
BLANK_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
FAIRY_TRAVEL_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage fairyTravelIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "fairy_ring_travel.png");
final BufferedImage fairyTravelIcon = ImageUtil.loadImageResource(WorldMapPlugin.class, "fairy_ring_travel.png");
FAIRY_TRAVEL_ICON.getGraphics().drawImage(fairyTravelIcon, 1, 1, null);
NOPE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage nopeImage = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "nope_icon.png");
final BufferedImage nopeImage = ImageUtil.loadImageResource(WorldMapPlugin.class, "nope_icon.png");
NOPE_ICON.getGraphics().drawImage(nopeImage, 1, 1, null);
NOT_STARTED_ICON = new BufferedImage(questIconBufferSize, questIconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage notStartedIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "quest_not_started_icon.png");
final BufferedImage notStartedIcon = ImageUtil.loadImageResource(WorldMapPlugin.class, "quest_not_started_icon.png");
NOT_STARTED_ICON.getGraphics().drawImage(notStartedIcon, 4, 4, null);
STARTED_ICON = new BufferedImage(questIconBufferSize, questIconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage startedIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "quest_started_icon.png");
final BufferedImage startedIcon = ImageUtil.loadImageResource(WorldMapPlugin.class, "quest_started_icon.png");
STARTED_ICON.getGraphics().drawImage(startedIcon, 4, 4, null);
FINISHED_ICON = new BufferedImage(questIconBufferSize, questIconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage finishedIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "quest_completed_icon.png");
final BufferedImage finishedIcon = ImageUtil.loadImageResource(WorldMapPlugin.class, "quest_completed_icon.png");
FINISHED_ICON.getGraphics().drawImage(finishedIcon, 4, 4, null);
MINING_SITE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage miningSiteIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "mining_site_icon.png");
final BufferedImage miningSiteIcon = ImageUtil.loadImageResource(WorldMapPlugin.class, "mining_site_icon.png");
MINING_SITE_ICON.getGraphics().drawImage(miningSiteIcon, 1, 1, null);
ROOFTOP_COURSE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
final BufferedImage rooftopCourseIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "rooftop_course_icon.png");
final BufferedImage rooftopCourseIcon = ImageUtil.loadImageResource(WorldMapPlugin.class, "rooftop_course_icon.png");
ROOFTOP_COURSE_ICON.getGraphics().drawImage(rooftopCourseIcon, 1, 1, null);
}

View File

@@ -157,7 +157,7 @@ public class XpTrackerPlugin extends Plugin
{
xpPanel = new XpPanel(this, xpTrackerConfig, client, skillIconManager);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "/skill_icons/overall.png");
final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "/skill_icons/overall.png");
navButton = NavigationButton.builder()
.tooltip("XP Tracker")

View File

@@ -265,6 +265,7 @@ public class ZalcanoPlugin extends Plugin
private boolean isHealthbarActive()
{
return client.getVar(VarPlayer.ZALCANO_FORM) != -1;
int npcId = client.getVar(VarPlayer.HP_HUD_NPC_ID);
return npcId == ZALCANO_WEAKENED || npcId == ZALCANO;
}
}

View File

@@ -108,7 +108,7 @@ public class ClientUI
private static final String CONFIG_CLIENT_BOUNDS = "clientBounds";
private static final String CONFIG_CLIENT_MAXIMIZED = "clientMaximized";
private static final String CONFIG_CLIENT_SIDEBAR_CLOSED = "clientSidebarClosed";
public static final BufferedImage ICON = ImageUtil.getResourceStreamFromClass(ClientUI.class, "/openosrs.png");
public static final BufferedImage ICON = ImageUtil.loadImageResource(ClientUI.class, "/openosrs.png");
@Getter
private TrayIcon trayIcon;
@@ -128,8 +128,9 @@ public class ClientUI
private boolean withTitleBar;
private BufferedImage sidebarOpenIcon;
private BufferedImage sidebarClosedIcon;
@Getter
private static ContainableFrame frame;
public static ContainableFrame frame;
private JPanel navContainer;
private PluginPanel pluginPanel;
private ClientPluginToolbar pluginToolbar;
@@ -475,7 +476,7 @@ public class ClientUI
// Create hide sidebar button
sidebarOpenIcon = ImageUtil.getResourceStreamFromClass(ClientUI.class, withTitleBar ? "open.png" : "open_rs.png");
sidebarOpenIcon = ImageUtil.loadImageResource(ClientUI.class, withTitleBar ? "open.png" : "open_rs.png");
sidebarClosedIcon = ImageUtil.flipImage(sidebarOpenIcon, true, false);
sidebarNavigationButton = NavigationButton

View File

@@ -81,7 +81,7 @@ public class FatalErrorDialog extends JDialog
try
{
BufferedImage logo = ImageUtil.getResourceStreamFromClass(FatalErrorDialog.class, "runelite_transparent.png");
BufferedImage logo = ImageUtil.loadImageResource(FatalErrorDialog.class, "runelite_transparent.png");
setIconImage(logo);
JLabel runelite = new JLabel();

View File

@@ -266,29 +266,35 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
else
{
final Rectangle bounds = overlay.getBounds();
final Point location = bounds.getLocation();
final Dimension dimension = bounds.getSize();
final Point preferredLocation = overlay.getPreferredLocation();
Point location;
// If the final position is not modified, layout it
if (overlayPosition != OverlayPosition.DETACHED && (preferredLocation == null || overlay.getPreferredPosition() != null))
{
final Rectangle snapCorner = snapCorners.forPosition(overlayPosition);
final Point translation = OverlayUtil.transformPosition(overlayPosition, dimension);
location.setLocation(snapCorner.getX() + translation.x, snapCorner.getY() + translation.y);
final Point padding = OverlayUtil.padPosition(overlayPosition, dimension, PADDING);
snapCorner.translate(padding.x, padding.y);
final Point translation = OverlayUtil.transformPosition(overlayPosition, dimension); // offset from corner
// Target x/y to draw the overlay
int destX = (int) snapCorner.getX() + translation.x;
int destY = (int) snapCorner.getY() + translation.y;
// Clamp the target position to ensure it is on screen or within parent bounds
location = clampOverlayLocation(destX, destY, dimension.width, dimension.height, overlay);
// Diff final position to target position in order to add it to the snap corner padding. The
// overlay effectively takes up the difference of (clamped location - target location) in
// addition to its normal dimensions.
int dX = location.x - destX;
int dY = location.y - destY;
final Point padding = OverlayUtil.padPosition(overlayPosition, dimension, PADDING); // overlay size + fixed padding
// translate corner for padding and any difference due to the position clamping
snapCorner.translate(padding.x + dX, padding.y + dY);
}
else
{
if (preferredLocation != null)
{
location.setLocation(preferredLocation);
}
location = preferredLocation != null ? preferredLocation : bounds.getLocation();
// Clamp the overlay position to ensure it is on screen or within parent bounds
clampOverlayLocation(location, dimension.width, dimension.height, overlay);
location = clampOverlayLocation(location.x, location.y, dimension.width, dimension.height, overlay);
}
if (overlay.getPreferredSize() != null)
@@ -605,7 +611,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
// Clamp drag to parent component
final Rectangle overlayBounds = currentManagedOverlay.getBounds();
clampOverlayLocation(overlayPosition, overlayBounds.width, overlayBounds.height, currentManagedOverlay);
overlayPosition = clampOverlayLocation(overlayPosition.x, overlayPosition.y, overlayBounds.width, overlayBounds.height, currentManagedOverlay);
currentManagedOverlay.setPreferredPosition(null);
currentManagedOverlay.setPreferredLocation(overlayPosition);
}
@@ -920,12 +926,14 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
/**
* Adjust the given overlay position to be within its parent's bounds.
*
* @param overlayPosition the overlay position, which is modified in place
* @param overlayX
* @param overlayY
* @param overlayWidth
* @param overlayHeight
* @param overlay the overlay
* @param overlay the overlay
* @return the clamped position
*/
private void clampOverlayLocation(Point overlayPosition, int overlayWidth, int overlayHeight, Overlay overlay)
private Point clampOverlayLocation(int overlayX, int overlayY, int overlayWidth, int overlayHeight, Overlay overlay)
{
Rectangle parentBounds = overlay.getParentBounds();
if (parentBounds == null || parentBounds.isEmpty())
@@ -936,9 +944,11 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
}
// Constrain overlay position to be within the parent bounds
overlayPosition.x = Ints.constrainToRange(overlayPosition.x, parentBounds.x,
Math.max(parentBounds.x, parentBounds.width - overlayWidth));
overlayPosition.y = Ints.constrainToRange(overlayPosition.y, parentBounds.y,
Math.max(parentBounds.y, parentBounds.height - overlayHeight));
return new Point(
Ints.constrainToRange(overlayX, parentBounds.x,
Math.max(parentBounds.x, parentBounds.width - overlayWidth)),
Ints.constrainToRange(overlayY, parentBounds.y,
Math.max(parentBounds.y, parentBounds.height - overlayHeight))
);
}
}

View File

@@ -217,8 +217,6 @@ public class OverlayUtil
break;
case TOP_LEFT:
case TOP_CENTER:
result.y += dimension.height + (dimension.height == 0 ? 0 : padding);
break;
case CANVAS_TOP_RIGHT:
case TOP_RIGHT:
result.y += dimension.height + (dimension.height == 0 ? 0 : padding);
@@ -242,18 +240,18 @@ public class OverlayUtil
case TOP_LEFT:
break;
case TOP_CENTER:
result.x = result.x - dimension.width / 2;
result.x = -dimension.width / 2;
break;
case BOTTOM_LEFT:
result.y = result.y - dimension.height;
result.y = -dimension.height;
break;
case BOTTOM_RIGHT:
case ABOVE_CHATBOX_RIGHT:
result.y = result.y - dimension.height;
result.y = -dimension.height;
// FALLTHROUGH
case CANVAS_TOP_RIGHT:
case TOP_RIGHT:
result.x = result.x - dimension.width;
result.x = -dimension.width;
break;
}

View File

@@ -34,12 +34,10 @@ import java.awt.image.BufferedImage;
import java.awt.image.DirectColorModel;
import java.awt.image.PixelGrabber;
import java.awt.image.RescaleOp;
import java.awt.image.WritableRaster;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import javax.imageio.ImageIO;
import javax.swing.GrayFilter;
import lombok.extern.slf4j.Slf4j;
@@ -333,16 +331,25 @@ public class ImageUtil
return outlinedImage;
}
/**
* @see #loadImageResource(Class, String)
*/
@Deprecated
public static BufferedImage getResourceStreamFromClass(Class<?> c, String path)
{
return loadImageResource(c, path);
}
/**
* 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.
* loading image resources from the classpath.
*
* @param c The class to be referenced for resource path.
* @param c The class to be referenced for the package 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)
public static BufferedImage loadImageResource(final Class<?> c, final String path)
{
try
{
@@ -361,7 +368,7 @@ public class ImageUtil
}
else
{
filePath = c.getPackage().getName().replace(".", "/") + "/" + path;
filePath = c.getPackage().getName().replace('.', '/') + "/" + path;
}
log.warn("Failed to load image from class: {}, path: {}", c.getName(), filePath);
@@ -400,56 +407,6 @@ public class ImageUtil
return filledImage;
}
/**
* Recolors pixels of the given image with the given color based on a given recolor condition
* predicate.
*
* @param image The image which should have its non-transparent pixels recolored.
* @param color The color with which to recolor pixels.
* @param recolorCondition The condition on which to recolor pixels with the given color.
* @return The given image with all pixels fulfilling the recolor condition predicate
* set to the given color.
*/
public static BufferedImage recolorImage(final BufferedImage image, final Color color, final Predicate<Color> recolorCondition)
{
final BufferedImage recoloredImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
for (int x = 0; x < recoloredImage.getWidth(); x++)
{
for (int y = 0; y < recoloredImage.getHeight(); y++)
{
final Color pixelColor = new Color(image.getRGB(x, y), true);
if (!recolorCondition.test(pixelColor))
{
recoloredImage.setRGB(x, y, image.getRGB(x, y));
continue;
}
recoloredImage.setRGB(x, y, color.getRGB());
}
}
return recoloredImage;
}
public static BufferedImage recolorImage(BufferedImage image, final Color color)
{
int width = image.getWidth();
int height = image.getHeight();
WritableRaster raster = image.getRaster();
for (int xx = 0; xx < width; xx++)
{
for (int yy = 0; yy < height; yy++)
{
int[] pixels = raster.getPixel(xx, yy, (int[]) null);
pixels[0] = color.getRed();
pixels[1] = color.getGreen();
pixels[2] = color.getBlue();
raster.setPixel(xx, yy, pixels);
}
}
return image;
}
/**
* Performs a rescale operation on the image's color components.
*

View File

@@ -0,0 +1,56 @@
<!--
Default stack using IP multicasting. It is similar to the "udp"
stack in stacks.xml, but doesn't use streaming state transfer and flushing
author: Bela Ban
-->
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd"
version="5.0.0">
<UDP
bind_addr="127.0.0.1"
mcast_port="${jgroups.udp.mcast_port:45588}"
ip_ttl="4"
tos="8"
ucast_recv_buf_size="5M"
ucast_send_buf_size="5M"
mcast_recv_buf_size="5M"
mcast_send_buf_size="5M"
max_bundle_size="64K"
enable_diagnostics="true"
thread_naming_pattern="cl"
thread_pool.min_threads="0"
thread_pool.max_threads="20"
thread_pool.keep_alive_time="30000"/>
<PING/>
<MERGE3 max_interval="30000"
min_interval="10000"/>
<FD_SOCK/>
<FD_ALL/>
<VERIFY_SUSPECT timeout="1500"/>
<BARRIER/>
<pbcast.NAKACK2 xmit_interval="500"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="2000"
xmit_table_max_compaction_time="30000"
use_mcast_xmit="false"
discard_delivered_msgs="true"/>
<UNICAST3 xmit_interval="500"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="2000"
xmit_table_max_compaction_time="60000"
conn_expiry_timeout="0"/>
<pbcast.STABLE desired_avg_gossip="50000"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="false" join_timeout="2000"/>
<UFC max_credits="2M"
min_threshold="0.4"/>
<MFC max_credits="2M"
min_threshold="0.4"/>
<FRAG2 frag_size="60K"/>
<RSVP resend_interval="2000" timeout="10000"/>
<pbcast.STATE_TRANSFER/>
</config>