From a18c6282d0adca270a2a9538206e01777b0684c5 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Sun, 2 Jun 2019 23:55:07 -0700 Subject: [PATCH 01/21] PluginListItem: Reset label color on popup menu item click Fixes runelite/runelite#9007 --- .../net/runelite/client/plugins/config/PluginListItem.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java index 092b4c9c92..ee4a6fb166 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java @@ -317,10 +317,14 @@ class PluginListItem extends JPanel static void addLabelPopupMenu(final JLabel label, final Collection menuItems) { final JPopupMenu menu = new JPopupMenu(); + final Color labelForeground = label.getForeground(); menu.setBorder(new EmptyBorder(5, 5, 5, 5)); for (final JMenuItem menuItem : menuItems) { + // Some machines register mouseEntered through a popup menu, and do not register mouseExited when a popup + // menu item is clicked, so reset the label's color when we click one of these options. + menuItem.addActionListener(e -> label.setForeground(labelForeground)); menu.add(menuItem); } From 1c6a5469bc935598bbc43cb389751d7cff48cbbd Mon Sep 17 00:00:00 2001 From: Max Weber Date: Wed, 3 Jul 2019 12:04:07 -0600 Subject: [PATCH 02/21] ClientThread: repeat call immediate invokes correctly --- .../main/java/net/runelite/client/callback/ClientThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java b/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java index a1e3880a39..ff4e0fa07c 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/ClientThread.java @@ -58,7 +58,7 @@ public class ClientThread { if (client.isClientThread()) { - if (r.getAsBoolean()) + if (!r.getAsBoolean()) { invokes.add(r); } From acfe45b3c6c6ddf4defb6d57656c9397efdfe6da Mon Sep 17 00:00:00 2001 From: Max Weber Date: Wed, 3 Jul 2019 12:05:23 -0600 Subject: [PATCH 03/21] runelite-client: Handle missing sprites correctly --- .../main/java/net/runelite/api/Client.java | 2 ++ .../runelite/client/game/SpriteManager.java | 19 ++++++++++++++ .../client/plugins/barrows/BarrowsPlugin.java | 4 ++- .../instancemap/InstanceMapOverlay.java | 23 ++++++++++++++--- .../puzzlesolver/PuzzleSolverOverlay.java | 5 ++++ .../client/plugins/raids/RaidsPlugin.java | 3 ++- .../client/plugins/raids/RaidsTimer.java | 5 ++-- .../plugins/screenshot/ScreenshotPlugin.java | 13 ++-------- .../client/plugins/timers/GameIndicator.java | 20 +-------------- .../client/plugins/timers/GameTimer.java | 23 ++--------------- .../plugins/timers/IndicatorIndicator.java | 5 ++-- .../client/plugins/timers/TimerTimer.java | 5 ++-- .../client/plugins/timers/TimersPlugin.java | 25 +++++++++++++++---- .../ui/overlay/infobox/InfoBoxManager.java | 2 +- 14 files changed, 82 insertions(+), 72 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index de8123b359..95d51c74f9 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -360,6 +360,7 @@ public interface Client extends GameEngine * @param scale the scale of the sprite * @return the created sprite */ + @Nullable SpritePixels createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale); /** @@ -370,6 +371,7 @@ public interface Client extends GameEngine * @param fileId the sprites file ID * @return the sprite image of the file */ + @Nullable SpritePixels[] getSprites(IndexDataBase source, int archiveId, int fileId); /** diff --git a/runelite-client/src/main/java/net/runelite/client/game/SpriteManager.java b/runelite-client/src/main/java/net/runelite/client/game/SpriteManager.java index f177377818..39b565e995 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/SpriteManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/SpriteManager.java @@ -42,6 +42,8 @@ import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.SpritePixels; import net.runelite.client.callback.ClientThread; +import net.runelite.client.ui.overlay.infobox.InfoBox; +import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.util.ImageUtil; @Slf4j @@ -54,6 +56,9 @@ public class SpriteManager @Inject private ClientThread clientThread; + @Inject + private InfoBoxManager infoBoxManager; + public Cache cache = CacheBuilder.newBuilder() .maximumSize(128L) .expireAfterAccess(1, TimeUnit.HOURS) @@ -76,6 +81,11 @@ public class SpriteManager } SpritePixels[] sp = client.getSprites(client.getIndexSprites(), archive, 0); + if (sp == null) + { + return null; + } + BufferedImage img = sp[file].toBufferedImage(); cache.put(key, img); @@ -104,6 +114,15 @@ public class SpriteManager }); } + public void getSpriteAsync(int archive, int file, InfoBox infoBox) + { + getSpriteAsync(archive, file, img -> + { + infoBox.setImage(img); + infoBoxManager.updateInfoBoxImage(infoBox); + }); + } + /** * Calls setIcon on c, ensuring it is repainted when this changes */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java index 30ecefb885..68b726908b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java @@ -322,10 +322,12 @@ public class BarrowsPlugin extends Plugin final LoopTimer loopTimer = new LoopTimer( PRAYER_DRAIN_INTERVAL_MS, ChronoUnit.MILLIS, - spriteManager.getSprite(SpriteID.TAB_PRAYER, 0), + null, this, true); + spriteManager.getSpriteAsync(SpriteID.TAB_PRAYER, 0, loopTimer); + loopTimer.setPriority(InfoBoxPriority.MED); loopTimer.setTooltip("Prayer Drain"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java index 3e44e6d4b8..6a3492a425 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; +import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import lombok.Getter; @@ -87,8 +88,10 @@ class InstanceMapOverlay extends Overlay @Setter private boolean isCloseButtonHovered; + @Getter private Rectangle closeButtonBounds; + private BufferedImage closeButtonImage; private BufferedImage closeButtonHoveredImage; @@ -166,8 +169,6 @@ class InstanceMapOverlay extends Overlay if (image == null) { - BufferedImage closeButton = getCloseButtonImage(); - SpritePixels map = client.drawInstanceMap(viewedPlane); image = minimapToBufferedImage(map); synchronized (this) @@ -177,7 +178,12 @@ class InstanceMapOverlay extends Overlay mapImage = image; } } + } + BufferedImage closeButton = getCloseButtonImage(); + BufferedImage closeButtonHover = getCloseButtonHoveredImage(); + if (closeButton != null && closeButtonBounds == null) + { closeButtonBounds = new Rectangle(image.getWidth() - closeButton.getWidth() - 5, 6, closeButton.getWidth(), closeButton.getHeight()); } @@ -191,8 +197,15 @@ class InstanceMapOverlay extends Overlay drawPlayerDot(graphics, client.getLocalPlayer(), Color.white, Color.black); } - graphics.drawImage(isCloseButtonHovered ? getCloseButtonHoveredImage() : getCloseButtonImage(), - (int) closeButtonBounds.getX(), (int) closeButtonBounds.getY(), null); + if (isCloseButtonHovered) + { + closeButton = closeButtonHover; + } + + if (closeButton != null) + { + graphics.drawImage(closeButton, (int) closeButtonBounds.getX(), (int) closeButtonBounds.getY(), null); + } return new Dimension(image.getWidth(), image.getHeight()); } @@ -252,6 +265,7 @@ class InstanceMapOverlay extends Overlay return img; } + @Nullable private BufferedImage getCloseButtonImage() { if (closeButtonImage == null) @@ -261,6 +275,7 @@ class InstanceMapOverlay extends Overlay return closeButtonImage; } + @Nullable private BufferedImage getCloseButtonHoveredImage() { if (closeButtonHoveredImage == null) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java index 67c821d841..cd6e983a6f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java @@ -299,6 +299,11 @@ public class PuzzleSolverOverlay extends Overlay arrow = getUpArrow(); } + if (arrow == null) + { + continue; + } + int x = puzzleBoxLocation.getX() + blankX * PUZZLE_TILE_SIZE + PUZZLE_TILE_SIZE / 2 - arrow.getWidth() / 2; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 34db989c71..ff668a1472 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -193,7 +193,8 @@ public class RaidsPlugin extends Plugin if (config.raidsTimer() && message.startsWith(RAID_START_MESSAGE)) { - timer = new RaidsTimer(spriteManager.getSprite(TAB_QUESTS_BROWN_RAIDING_PARTY, 0), this, Instant.now()); + timer = new RaidsTimer(this, Instant.now()); + spriteManager.getSpriteAsync(TAB_QUESTS_BROWN_RAIDING_PARTY, 0, timer); infoBoxManager.addInfoBox(timer); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java index 8df3087054..09c3beb722 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java @@ -25,7 +25,6 @@ package net.runelite.client.plugins.raids; import java.awt.Color; -import java.awt.image.BufferedImage; import java.time.Duration; import java.time.Instant; import java.time.LocalTime; @@ -47,9 +46,9 @@ public class RaidsTimer extends InfoBox @Setter private boolean stopped; - public RaidsTimer(BufferedImage image, Plugin plugin, Instant startTime) + public RaidsTimer(Plugin plugin, Instant startTime) { - super(image, plugin); + super(null, plugin); this.startTime = startTime; floorTime = startTime; stopped = false; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java index c586b9cd91..d397a57d5f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java @@ -64,7 +64,6 @@ import net.runelite.api.Point; import net.runelite.api.SpriteID; import net.runelite.api.WorldType; import net.runelite.api.events.ChatMessage; -import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.LocalPlayerDeath; import net.runelite.api.events.WidgetLoaded; @@ -235,6 +234,8 @@ public class ScreenshotPlugin extends Plugin .build(); clientToolbar.addNavigation(titleBarButton); + + spriteManager.getSpriteAsync(SpriteID.CHATBOX_REPORT_BUTTON, 0, s -> reportButton = s); } @Override @@ -245,16 +246,6 @@ public class ScreenshotPlugin extends Plugin 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 public void onGameTick(GameTick event) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java index b91f8c7080..55151e340f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java @@ -25,22 +25,17 @@ package net.runelite.client.plugins.timers; import java.awt.Color; -import java.awt.image.BufferedImage; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.SpriteID; -import net.runelite.client.game.ItemManager; -import net.runelite.client.game.SpriteManager; +@Getter(AccessLevel.PACKAGE) enum GameIndicator { VENGEANCE_ACTIVE(SpriteID.SPELL_VENGEANCE_OTHER, GameTimerImageType.SPRITE, "Vengeance active"); - @Getter(AccessLevel.PACKAGE) private final String description; - @Getter(AccessLevel.PACKAGE) private String text; - @Getter(AccessLevel.PACKAGE) private Color textColor; private final int imageId; private final GameTimerImageType imageType; @@ -58,17 +53,4 @@ enum GameIndicator { this(imageId, idType, description, "", null); } - - BufferedImage getImage(ItemManager itemManager, SpriteManager spriteManager) - { - switch (imageType) - { - case ITEM: - return itemManager.getImage(imageId); - case SPRITE: - return spriteManager.getSprite(imageId, 0); - default: - return null; - } - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java index 40a6c97ecb..f29915740f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java @@ -26,16 +26,15 @@ */ package net.runelite.client.plugins.timers; -import java.awt.image.BufferedImage; import java.time.Duration; import java.time.temporal.ChronoUnit; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.GraphicID; import net.runelite.api.ItemID; import net.runelite.api.SpriteID; -import net.runelite.client.game.ItemManager; -import net.runelite.client.game.SpriteManager; +@Getter(AccessLevel.PACKAGE) enum GameTimer { STAMINA(ItemID.STAMINA_POTION4, GameTimerImageType.ITEM, "Stamina", 2, ChronoUnit.MINUTES, true), @@ -81,15 +80,10 @@ enum GameTimer MINIGAME_TELEPORT(SpriteID.TAB_QUESTS_RED_MINIGAMES, GameTimerImageType.SPRITE, "Minigame Teleport", 20, ChronoUnit.MINUTES), DRAGON_FIRE_SHIELD(ItemID.DRAGONFIRE_SHIELD_11284, GameTimerImageType.ITEM, "Dragonfire Shield Special", 2, ChronoUnit.MINUTES); - @Getter private final Duration duration; - @Getter private final Integer graphicId; - @Getter private final String description; - @Getter private final boolean removedOnDeath; - @Getter private final Duration initialDelay; private final int imageId; private final GameTimerImageType imageType; @@ -129,17 +123,4 @@ enum GameTimer { this(imageId, idType, description, null, time, unit, delay, false); } - - BufferedImage getImage(ItemManager itemManager, SpriteManager spriteManager) - { - switch (imageType) - { - case ITEM: - return itemManager.getImage(imageId); - case SPRITE: - return spriteManager.getSprite(imageId, 0); - default: - return null; - } - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java index 9af1716f4d..03990ce5ed 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java @@ -25,7 +25,6 @@ package net.runelite.client.plugins.timers; import java.awt.Color; -import java.awt.Image; import lombok.Getter; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.InfoBox; @@ -36,9 +35,9 @@ public class IndicatorIndicator extends InfoBox @Getter private final GameIndicator indicator; - IndicatorIndicator(GameIndicator indicator, Image image, Plugin plugin) + IndicatorIndicator(GameIndicator indicator, Plugin plugin) { - super(image, plugin); + super(null, plugin); this.indicator = indicator; setPriority(InfoBoxPriority.MED); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java index 8e1fd3c9d4..2a30f1ca9c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java @@ -24,7 +24,6 @@ */ package net.runelite.client.plugins.timers; -import java.awt.image.BufferedImage; import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; @@ -36,9 +35,9 @@ class TimerTimer extends Timer { private final GameTimer timer; - TimerTimer(GameTimer timer, Plugin plugin, BufferedImage image) + TimerTimer(GameTimer timer, Plugin plugin) { - super(timer.getDuration().toMillis(), ChronoUnit.MILLIS, image, plugin); + super(timer.getDuration().toMillis(), ChronoUnit.MILLIS, null, plugin); this.timer = timer; setPriority(InfoBoxPriority.MED); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index a1b2a04f1c..9b6b879dd9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -26,7 +26,6 @@ package net.runelite.client.plugins.timers; import com.google.inject.Provides; -import java.awt.image.BufferedImage; import java.util.regex.Pattern; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; @@ -866,8 +865,16 @@ public class TimersPlugin extends Plugin { removeGameTimer(timer); - BufferedImage image = timer.getImage(itemManager, spriteManager); - TimerTimer t = new TimerTimer(timer, this, image); + TimerTimer t = new TimerTimer(timer, this); + switch (timer.getImageType()) + { + case SPRITE: + spriteManager.getSpriteAsync(timer.getImageId(), 0, t); + break; + case ITEM: + t.setImage(itemManager.getImage(timer.getImageId())); + break; + } t.setTooltip(timer.getDescription()); infoBoxManager.addInfoBox(t); return t; @@ -882,8 +889,16 @@ public class TimersPlugin extends Plugin { removeGameIndicator(gameIndicator); - BufferedImage image = gameIndicator.getImage(itemManager, spriteManager); - IndicatorIndicator indicator = new IndicatorIndicator(gameIndicator, image, this); + IndicatorIndicator indicator = new IndicatorIndicator(gameIndicator, this); + switch (gameIndicator.getImageType()) + { + case SPRITE: + spriteManager.getSpriteAsync(gameIndicator.getImageId(), 0, indicator); + break; + case ITEM: + indicator.setImage(itemManager.getImage(gameIndicator.getImageId())); + break; + } indicator.setTooltip(gameIndicator.getDescription()); infoBoxManager.addInfoBox(indicator); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java index 4fd1c1ca11..088a1a104a 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java @@ -118,7 +118,7 @@ public class InfoBoxManager } } - private void updateInfoBoxImage(final InfoBox infoBox) + public void updateInfoBoxImage(final InfoBox infoBox) { if (infoBox.getImage() == null) { From a1a860e0f4ed903e7bba589491081aeda5f5b048 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Wed, 3 Jul 2019 12:16:11 -0600 Subject: [PATCH 04/21] runelite-client: Use BufferedImage where applicable All of these places would crash at runtime should they be given a non-buffered image due to calling methods without a null ImageObserver --- .../net/runelite/client/plugins/cooking/FermentTimer.java | 4 ++-- .../client/plugins/statusbars/StatusBarsOverlay.java | 8 ++++---- .../client/ui/overlay/components/InfoBoxComponent.java | 4 ++-- .../net/runelite/client/ui/overlay/infobox/InfoBox.java | 8 ++++---- .../client/ui/overlay/infobox/InfoBoxManager.java | 5 ++--- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java index 5312414ad1..84d7033f57 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java @@ -25,7 +25,7 @@ package net.runelite.client.plugins.cooking; import java.awt.Color; -import java.awt.Image; +import java.awt.image.BufferedImage; import java.time.Duration; import java.time.Instant; import net.runelite.client.plugins.Plugin; @@ -37,7 +37,7 @@ final class FermentTimer extends InfoBox private Instant fermentTime; - FermentTimer(Image image, Plugin plugin) + FermentTimer(BufferedImage image, Plugin plugin) { super(image, plugin); reset(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java index e92251bec0..529fa250a4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java @@ -27,7 +27,7 @@ package net.runelite.client.plugins.statusbars; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; -import java.awt.Image; +import java.awt.image.BufferedImage; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.MenuEntry; @@ -83,7 +83,7 @@ class StatusBarsOverlay extends Overlay private final TextComponent textComponent = new TextComponent(); private final ItemStatChangesService itemStatService; - private final Image prayerImage; + private final BufferedImage prayerImage; @Inject private StatusBarsOverlay(Client client, StatusBarsConfig config, SkillIconManager skillIconManager, ItemStatChangesService itemstatservice) @@ -225,7 +225,7 @@ class StatusBarsOverlay extends Overlay if (config.enableSkillIcon() || config.enableCounter()) { - final Image healthImage = skillIconManager.getSkillImage(Skill.HITPOINTS, true); + final BufferedImage healthImage = skillIconManager.getSkillImage(Skill.HITPOINTS, true); final int counterHealth = client.getBoostedSkillLevel(Skill.HITPOINTS); final int counterPrayer = client.getBoostedSkillLevel(Skill.PRAYER); final String counterHealthText = Integer.toString(counterHealth); @@ -294,7 +294,7 @@ class StatusBarsOverlay extends Overlay return (int) Math.round(ratio * size); } - private void renderIconsAndCounters(Graphics2D graphics, int x, int y, Image image, String counterText, int counterPadding) + private void renderIconsAndCounters(Graphics2D graphics, int x, int y, BufferedImage image, String counterText, int counterPadding) { final int widthOfCounter = graphics.getFontMetrics().stringWidth(counterText); final int centerText = (WIDTH - PADDING) / 2 - (widthOfCounter / 2); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java index d8f7841099..a72d13f73d 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/components/InfoBoxComponent.java @@ -29,9 +29,9 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; -import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; +import java.awt.image.BufferedImage; import lombok.Getter; import lombok.Setter; import net.runelite.client.ui.FontManager; @@ -53,7 +53,7 @@ public class InfoBoxComponent implements LayoutableRenderableEntity private String text; private Color color = Color.WHITE; private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR; - private Image image; + private BufferedImage image; @Override public Dimension render(Graphics2D graphics) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBox.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBox.java index 8c2889e8e6..fab945c11b 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBox.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBox.java @@ -25,7 +25,7 @@ package net.runelite.client.ui.overlay.infobox; import java.awt.Color; -import java.awt.Image; +import java.awt.image.BufferedImage; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -38,11 +38,11 @@ public abstract class InfoBox @Getter @Setter - private Image image; + private BufferedImage image; @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) - private Image scaledImage; + private BufferedImage scaledImage; @Getter(AccessLevel.PACKAGE) @Setter @@ -52,7 +52,7 @@ public abstract class InfoBox @Setter private String tooltip; - public InfoBox(Image image, Plugin plugin) + public InfoBox(BufferedImage image, Plugin plugin) { this.plugin = plugin; setImage(image); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java index 088a1a104a..af47777511 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java @@ -27,7 +27,6 @@ package net.runelite.client.ui.overlay.infobox; import com.google.common.base.Preconditions; import com.google.common.collect.ComparisonChain; import java.awt.Graphics; -import java.awt.Image; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Collections; @@ -126,8 +125,8 @@ public class InfoBoxManager } // Set scaled InfoBox image - final Image image = infoBox.getImage(); - Image resultImage = image; + final BufferedImage image = infoBox.getImage(); + BufferedImage resultImage = image; final double width = image.getWidth(null); final double height = image.getHeight(null); final double size = Math.max(2, runeLiteConfig.infoBoxSize()); // Limit size to 2 as that is minimum size not causing breakage From dbab819761886d1ea28f0f6d3c3ab7e821578769 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Wed, 3 Jul 2019 12:46:23 -0600 Subject: [PATCH 05/21] InfoBoxManager: handle AsyncBufferedImage more correctly --- .../client/ui/overlay/infobox/InfoBoxManager.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java index af47777511..228441a901 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java @@ -39,6 +39,7 @@ import lombok.extern.slf4j.Slf4j; import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.game.AsyncBufferedImage; import net.runelite.client.plugins.PluginDescriptor; @Singleton @@ -71,6 +72,14 @@ public class InfoBoxManager updateInfoBoxImage(infoBox); infoBoxes.add(infoBox); refreshInfoBoxes(); + + BufferedImage image = infoBox.getImage(); + + if (image instanceof AsyncBufferedImage) + { + AsyncBufferedImage abi = (AsyncBufferedImage) image; + abi.onChanged(() -> updateInfoBoxImage(infoBox)); + } } public void removeInfoBox(InfoBox infoBox) From bb1379886c13f7856a4c7d8d1f25993f3a56cb72 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Thu, 11 Jul 2019 00:08:40 -0700 Subject: [PATCH 06/21] grounditemsplugin: Color telegrab menu entries This patch will cause menu entries to have their options and/or targets recolored in the same way as "Take" menu entries are already recolored when telegrab menu entries are added. Closes runelite/runelite#4930 --- .../grounditems/GroundItemsPlugin.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index cce5ab2fbd..8844fedc0d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -105,6 +105,9 @@ public class GroundItemsPlugin extends Plugin private static final int FOURTH_OPTION = MenuAction.GROUND_ITEM_FOURTH_OPTION.getId(); private static final int FIFTH_OPTION = MenuAction.GROUND_ITEM_FIFTH_OPTION.getId(); private static final int EXAMINE_ITEM = MenuAction.EXAMINE_ITEM_GROUND.getId(); + private static final int CAST_ON_ITEM = MenuAction.SPELL_CAST_ON_GROUND_ITEM.getId(); + + private static final String TELEGRAB_TEXT = ColorUtil.wrapWithColorTag("Telekinetic Grab", Color.GREEN) + ColorUtil.prependColorTag(" -> ", Color.WHITE); @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) @@ -446,10 +449,14 @@ public class GroundItemsPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (config.itemHighlightMode() != OVERLAY - && event.getOption().equals("Take") - && event.getType() == THIRD_OPTION) + if (config.itemHighlightMode() != OVERLAY) { + final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == CAST_ON_ITEM; + if (!(event.getOption().equals("Take") && event.getType() == THIRD_OPTION) && !telegrabEntry) + { + return; + } + int itemId = event.getIdentifier(); Scene scene = client.getScene(); Tile tile = scene.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()]; @@ -493,13 +500,27 @@ public class GroundItemsPlugin extends Plugin if (mode == BOTH || mode == OPTION) { - lastEntry.setOption(ColorUtil.prependColorTag("Take", color)); + final String optionText = telegrabEntry ? "Cast" : "Take"; + lastEntry.setOption(ColorUtil.prependColorTag(optionText, color)); } if (mode == BOTH || mode == NAME) { - String target = lastEntry.getTarget().substring(lastEntry.getTarget().indexOf(">") + 1); - lastEntry.setTarget(ColorUtil.prependColorTag(target, color)); + String target = lastEntry.getTarget(); + + if (telegrabEntry) + { + target = target.substring(TELEGRAB_TEXT.length()); + } + + target = ColorUtil.prependColorTag(target.substring(target.indexOf('>') + 1), color); + + if (telegrabEntry) + { + target = TELEGRAB_TEXT + target; + } + + lastEntry.setTarget(target); } } From caaf98a8597a4be0a202c49256d083e8111a8b34 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 11 Jul 2019 18:15:38 -0400 Subject: [PATCH 07/21] api: add npc changed event Co-authored-by: WooxSolo --- .../net/runelite/api/events/NpcChanged.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 runelite-api/src/main/java/net/runelite/api/events/NpcChanged.java diff --git a/runelite-api/src/main/java/net/runelite/api/events/NpcChanged.java b/runelite-api/src/main/java/net/runelite/api/events/NpcChanged.java new file mode 100644 index 0000000000..7abdb731dd --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/NpcChanged.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018, Woox + * 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.api.events; + +import lombok.Value; +import net.runelite.api.NPC; +import net.runelite.api.NPCComposition; + +/** + * Fires after the composition of an {@link NPC} changes. + */ +@Value +public class NpcChanged +{ + /** + * The NPC of which the composition changed. + */ + private final NPC npc; + + /** + * The old composition of the NPC + */ + private final NPCComposition old; +} From f9de6f53fb5355449ea4d109be8b7cdefbada29a Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 11 Jul 2019 18:18:24 -0400 Subject: [PATCH 08/21] imp plugin: cleanup Add imp tag, remove unnecessary declared exceptions, and clear npcs on shutdown --- .../client/plugins/implings/ImplingsPlugin.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java index d73a3200fa..8a9e311b71 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java @@ -42,13 +42,10 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; -/** - * @author robin - */ @PluginDescriptor( name = "Implings", description = "Highlight nearby implings on the minimap and on-screen", - tags = {"hunter", "minimap", "overlay"} + tags = {"hunter", "minimap", "overlay", "imp"} ) public class ImplingsPlugin extends Plugin { @@ -73,17 +70,17 @@ public class ImplingsPlugin extends Plugin return configManager.getConfig(ImplingsConfig.class); } - @Override - protected void startUp() throws Exception + protected void startUp() { overlayManager.add(overlay); overlayManager.add(minimapOverlay); } @Override - protected void shutDown() throws Exception + protected void shutDown() { + implings.clear(); overlayManager.remove(overlay); overlayManager.remove(minimapOverlay); } From 5844c7c5de03f44f4382f285374bf16d2fe41f81 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 11 Jul 2019 18:19:25 -0400 Subject: [PATCH 09/21] imp plugin: handle npc changes to imps The imps in puro-puro will change into imps after spawning as a null npc. Previously this would not track imps unless you happened to walk into visibility of one while it was an imp. --- .../client/plugins/implings/ImplingsPlugin.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java index 8a9e311b71..be1c89154c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java @@ -34,6 +34,7 @@ import lombok.Getter; import net.runelite.api.GameState; import net.runelite.api.NPC; import net.runelite.api.events.GameStateChanged; +import net.runelite.api.events.NpcChanged; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.client.config.ConfigManager; @@ -97,6 +98,18 @@ public class ImplingsPlugin extends Plugin } } + @Subscribe + public void onNpcChanged(NpcChanged npcCompositionChanged) + { + NPC npc = npcCompositionChanged.getNpc(); + Impling impling = Impling.findImpling(npc.getId()); + + if (impling != null && !implings.contains(npc)) + { + implings.add(npc); + } + } + @Subscribe public void onGameStateChanged(GameStateChanged event) { From 50dba923389402d0192dedd5588f95d11130c781 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Fri, 12 Jul 2019 23:27:18 -0700 Subject: [PATCH 10/21] slayerplugin: Correct Jad and Zuk task tracking This adds a field to Task which dictates the expected exp gain of the task. When set to a non-zero value, it will prevent slayer exp gains from registering as a kill unless they are of exactly that amount. Closes runelite/runelite#1865 --- .../client/plugins/slayer/SlayerPlugin.java | 10 +++- .../runelite/client/plugins/slayer/Task.java | 18 +++++- .../plugins/slayer/SlayerPluginTest.java | 60 +++++++++++++++++++ 3 files changed, 85 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index 808f830d24..09e9f95657 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -535,7 +535,15 @@ public class SlayerPlugin extends Plugin return; } - killedOne(); + final int taskKillExp = Task.getTask(taskName).getExpectedKillExp(); + + // Only count exp gain as a kill if the task either has no expected exp for a kill, or if the exp gain is equal + // to the expected exp gain for the task. + if (taskKillExp == 0 || taskKillExp == slayerExp - cachedXp) + { + killedOne(); + } + cachedXp = slayerExp; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java index 5ba47383e1..f844056473 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java @@ -107,7 +107,7 @@ enum Task ICEFIENDS("Icefiends", ItemID.ICE_DIAMOND), INFERNAL_MAGES("Infernal mages", ItemID.INFERNAL_MAGE, "Malevolent mage"), IRON_DRAGONS("Iron dragons", ItemID.IRON_DRAGON_MASK), - JAD("TzTok-Jad", ItemID.TZREKJAD), + JAD("TzTok-Jad", ItemID.TZREKJAD, 25250), JELLIES("Jellies", ItemID.JELLY, "Jelly"), JUNGLE_HORROR("Jungle horrors", ItemID.ENSOULED_HORROR_HEAD), KALPHITE("Kalphite", ItemID.KALPHITE_SOLDIER), @@ -171,7 +171,7 @@ enum Task ZILYANA("Commander Zilyana", ItemID.PET_ZILYANA), ZOMBIES("Zombies", ItemID.ZOMBIE_HEAD, "Undead"), ZULRAH("Zulrah", ItemID.PET_SNAKELING), - ZUK("TzKal-Zuk", ItemID.TZREKZUK); + ZUK("TzKal-Zuk", ItemID.TZREKZUK, 101890); // private static final Map tasks; @@ -181,6 +181,7 @@ enum Task private final String[] targetNames; private final int weaknessThreshold; private final int weaknessItem; + private final int expectedKillExp; static { @@ -202,6 +203,7 @@ enum Task this.weaknessThreshold = -1; this.weaknessItem = -1; this.targetNames = targetNames; + this.expectedKillExp = 0; } Task(String name, int itemSpriteId, int weaknessThreshold, int weaknessItem, String... targetNames) @@ -212,6 +214,18 @@ enum Task this.weaknessThreshold = weaknessThreshold; this.weaknessItem = weaknessItem; this.targetNames = targetNames; + this.expectedKillExp = 0; + } + + Task(String name, int itemSpriteId, int expectedKillExp) + { + Preconditions.checkArgument(itemSpriteId >= 0); + this.name = name; + this.itemSpriteId = itemSpriteId; + this.weaknessThreshold = -1; + this.weaknessItem = -1; + this.targetNames = new String[0]; + this.expectedKillExp = expectedKillExp; } static Task getTask(String taskName) diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java index 4e9850e09f..a10ecaced0 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java @@ -35,8 +35,10 @@ import static net.runelite.api.ChatMessageType.GAMEMESSAGE; import net.runelite.api.Client; import net.runelite.api.MessageNode; import net.runelite.api.Player; +import net.runelite.api.Skill; import net.runelite.api.coords.LocalPoint; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.GameTick; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -418,6 +420,64 @@ public class SlayerPluginTest verifyNoMoreInteractions(notifier); } + @Test + public void testJadTaskKill() + { + final Player player = mock(Player.class); + when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0)); + when(client.getLocalPlayer()).thenReturn(player); + + final ExperienceChanged experienceChanged = new ExperienceChanged(); + experienceChanged.setSkill(Skill.SLAYER); + + when(client.getSkillExperience(Skill.SLAYER)).thenReturn(100); + slayerPlugin.onExperienceChanged(experienceChanged); + + slayerPlugin.setTaskName("TzTok-Jad"); + slayerPlugin.setAmount(1); + + // One bat kill + when(client.getSkillExperience(Skill.SLAYER)).thenReturn(110); + slayerPlugin.onExperienceChanged(experienceChanged); + + assertEquals(1, slayerPlugin.getAmount()); + + // One Jad kill + when(client.getSkillExperience(Skill.SLAYER)).thenReturn(25_360); + slayerPlugin.onExperienceChanged(experienceChanged); + + assertEquals(0, slayerPlugin.getAmount()); + } + + @Test + public void testZukTaskKill() + { + final Player player = mock(Player.class); + when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0)); + when(client.getLocalPlayer()).thenReturn(player); + + final ExperienceChanged experienceChanged = new ExperienceChanged(); + experienceChanged.setSkill(Skill.SLAYER); + + when(client.getSkillExperience(Skill.SLAYER)).thenReturn(100); + slayerPlugin.onExperienceChanged(experienceChanged); + + slayerPlugin.setTaskName("TzKal-Zuk"); + slayerPlugin.setAmount(1); + + // One bat kill + when(client.getSkillExperience(Skill.SLAYER)).thenReturn(125); + slayerPlugin.onExperienceChanged(experienceChanged); + + assertEquals(1, slayerPlugin.getAmount()); + + // One Zuk kill + when(client.getSkillExperience(Skill.SLAYER)).thenReturn(102_015); + slayerPlugin.onExperienceChanged(experienceChanged); + + assertEquals(0, slayerPlugin.getAmount()); + } + @Test public void testBraceletSlaughter() { From 0c171c674f54c958ea65f43b5e50d385eec41ba1 Mon Sep 17 00:00:00 2001 From: Quasindro Date: Sat, 13 Jul 2019 16:11:39 +0200 Subject: [PATCH 11/21] mlm: fix ore vein max respawn time threshold --- .../java/net/runelite/client/plugins/mining/MiningOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java index 9442470c16..c0d06474cf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java @@ -44,7 +44,7 @@ import net.runelite.client.ui.overlay.components.ProgressPieComponent; class MiningOverlay extends Overlay { // Range of Motherlode vein respawn time - not 100% confirmed but based on observation - static final int ORE_VEIN_MAX_RESPAWN_TIME = 123; + static final int ORE_VEIN_MAX_RESPAWN_TIME = 166; private static final int ORE_VEIN_MIN_RESPAWN_TIME = 90; private static final float ORE_VEIN_RANDOM_PERCENT_THRESHOLD = (float) ORE_VEIN_MIN_RESPAWN_TIME / ORE_VEIN_MAX_RESPAWN_TIME; private static final Color DARK_GREEN = new Color(0, 100, 0); From bc9341784cc196983b9e735862c89eb6b78fa3de Mon Sep 17 00:00:00 2001 From: TheStonedTurtle Date: Sat, 13 Jul 2019 23:34:14 -0700 Subject: [PATCH 12/21] ClueScroll - Fix demonic ruins text --- .../runelite/client/plugins/cluescrolls/clues/CrypticClue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java index 4265b0d801..b2d2981d26 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java @@ -204,7 +204,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Search the drawers upstairs in Falador's shield shop.", DRAWERS, new WorldPoint(2971, 3386, 1), "Cassie's Shield Shop at the northern Falador entrance."), new CrypticClue("Go to this building to be illuminated, and check the drawers while you are there.", "Market Guard", DRAWERS_350 , new WorldPoint(2512, 3641, 1), "Search the drawers in the first floor of the Lighthouse. Kill a Rellekka marketplace guard to obtain the key."), new CrypticClue("Dig near some giant mushrooms, behind the Grand Tree.", new WorldPoint(2458, 3504, 0), "Dig near the red mushrooms northwest of the Grand Tree."), - new CrypticClue("Pentagrams and demons, burnt bones and remains, I wonder what the blood contains.", new WorldPoint(3297, 3890, 0), "Dig under the blood rune spawn next the the Demonic Ruins."), + new CrypticClue("Pentagrams and demons, burnt bones and remains, I wonder what the blood contains.", new WorldPoint(3297, 3890, 0), "Dig under the blood rune spawn next to the Demonic Ruins."), new CrypticClue("Search the drawers above Varrock's shops.", DRAWERS_7194, new WorldPoint(3206, 3419, 1), "Located upstairs in Thessalia's Fine Clothes shop in Varrock."), new CrypticClue("Search the drawers in one of Gertrude's bedrooms.", DRAWERS_7194, new WorldPoint(3156, 3406, 0), "Kanel's bedroom (southeastern room), outside of west Varrock."), new CrypticClue("Under a giant robotic bird that cannot fly.", new WorldPoint(1756, 4940, 0), "Dig next to the terrorbird display in the south exhibit of Varrock Museum's basement."), From dc1e409f09ad90fbefac010181f7ed610fd2a78b Mon Sep 17 00:00:00 2001 From: Ron Young Date: Sat, 23 Feb 2019 16:43:14 -0600 Subject: [PATCH 13/21] RuneliteColorPicker: add onClose consumer --- .../client/plugins/config/ConfigPanel.java | 10 +--------- .../screenmarkers/ui/ScreenMarkerPanel.java | 20 ++----------------- .../colorpicker/RuneliteColorPicker.java | 17 ++++++++++++++++ 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index ebaa54e7cb..df8d83556f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -429,15 +429,7 @@ public class ConfigPanel extends PluginPanel colorPickerBtn.setBackground(c); colorPickerBtn.setText(ColorUtil.toHexColor(c).toUpperCase()); }); - - colorPicker.addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent e) - { - changeConfiguration(listItem, config, colorPicker, cd, cid); - } - }); + colorPicker.setOnClose(c -> changeConfiguration(listItem, config, colorPicker, cd, cid)); colorPicker.setVisible(true); } }); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java index 23b6cad174..6937543df2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java @@ -553,15 +553,7 @@ class ScreenMarkerPanel extends JPanel marker.getMarker().setFill(c); updateFill(); }); - - colorPicker.addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent e) - { - plugin.updateConfig(); - } - }); + colorPicker.setOnClose(c -> plugin.updateConfig()); colorPicker.setVisible(true); } @@ -575,15 +567,7 @@ class ScreenMarkerPanel extends JPanel marker.getMarker().setColor(c); updateBorder(); }); - - colorPicker.addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent e) - { - plugin.updateConfig(); - } - }); + colorPicker.setOnClose(c -> plugin.updateConfig()); colorPicker.setVisible(true); } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java index 81d6780d70..1774725c43 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java @@ -39,6 +39,8 @@ import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.function.Consumer; import javax.swing.JDialog; import javax.swing.JFrame; @@ -84,6 +86,9 @@ public class RuneliteColorPicker extends JDialog @Setter private Consumer onColorChange; + @Setter + private Consumer onClose; + public RuneliteColorPicker(Window parent, Color previousColor, String title, boolean alphaHidden) { super(parent, "RuneLite Color Picker - " + title, ModalityType.MODELESS); @@ -265,6 +270,18 @@ public class RuneliteColorPicker extends JDialog updatePanels(); updateText(); + + addWindowListener(new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent e) + { + if (onClose != null) + { + onClose.accept(selectedColor); + } + } + }); } private void updatePanels() From b6dada85c7774643f6b91db758844c13d2a61d5a Mon Sep 17 00:00:00 2001 From: Ron Young Date: Sat, 23 Feb 2019 16:48:44 -0600 Subject: [PATCH 14/21] Add ColorPickerManager --- .../client/plugins/config/ConfigPanel.java | 14 +++-- .../client/plugins/config/ConfigPlugin.java | 6 +- .../screenmarkers/ScreenMarkerPlugin.java | 5 ++ .../screenmarkers/ui/ScreenMarkerPanel.java | 16 +++-- .../colorpicker/ColorPickerManager.java | 63 +++++++++++++++++++ .../colorpicker/RuneliteColorPicker.java | 12 +++- 6 files changed, 103 insertions(+), 13 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/ColorPickerManager.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index df8d83556f..bf66f6c2d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -35,8 +35,6 @@ import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Collections; @@ -88,6 +86,7 @@ import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.components.ComboBoxListRenderer; import net.runelite.client.ui.components.IconButton; import net.runelite.client.ui.components.IconTextField; +import net.runelite.client.ui.components.colorpicker.ColorPickerManager; import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker; import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ImageUtil; @@ -112,6 +111,7 @@ public class ConfigPanel extends PluginPanel private final ScheduledExecutorService executorService; private final RuneLiteConfig runeLiteConfig; private final ChatColorConfig chatColorConfig; + private final ColorPickerManager colorPickerManager; private final List pluginList = new ArrayList<>(); private final IconTextField searchBar = new IconTextField(); @@ -130,7 +130,7 @@ public class ConfigPanel extends PluginPanel } ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService, - RuneLiteConfig runeLiteConfig, ChatColorConfig chatColorConfig) + RuneLiteConfig runeLiteConfig, ChatColorConfig chatColorConfig, ColorPickerManager colorPickerManager) { super(false); this.pluginManager = pluginManager; @@ -138,6 +138,7 @@ public class ConfigPanel extends PluginPanel this.executorService = executorService; this.runeLiteConfig = runeLiteConfig; this.chatColorConfig = chatColorConfig; + this.colorPickerManager = colorPickerManager; searchBar.setIcon(IconTextField.Icon.SEARCH); searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30)); @@ -421,8 +422,11 @@ public class ConfigPanel extends PluginPanel @Override public void mouseClicked(MouseEvent e) { - RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(ConfigPanel.this), - colorPickerBtn.getBackground(), cid.getItem().name(), cid.getAlpha() == null); + RuneliteColorPicker colorPicker = colorPickerManager.create( + SwingUtilities.windowForComponent(ConfigPanel.this), + colorPickerBtn.getBackground(), + cid.getItem().name(), + cid.getAlpha() == null); colorPicker.setLocation(getLocationOnScreen()); colorPicker.setOnColorChange(c -> { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java index 2004675a05..4ff43a6ae3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java @@ -41,6 +41,7 @@ import net.runelite.client.plugins.PluginManager; import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.NavigationButton; +import net.runelite.client.ui.components.colorpicker.ColorPickerManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.util.ImageUtil; @@ -73,13 +74,16 @@ public class ConfigPlugin extends Plugin @Inject private ChatColorConfig chatColorConfig; + @Inject + private ColorPickerManager colorPickerManager; + private ConfigPanel configPanel; private NavigationButton navButton; @Override protected void startUp() throws Exception { - configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, chatColorConfig); + configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, chatColorConfig, colorPickerManager); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java index ff8dcf0057..1f2786f198 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java @@ -50,6 +50,7 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.screenmarkers.ui.ScreenMarkerPluginPanel; import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.NavigationButton; +import net.runelite.client.ui.components.colorpicker.ColorPickerManager; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ImageUtil; @@ -85,6 +86,10 @@ public class ScreenMarkerPlugin extends Plugin @Inject private ScreenMarkerCreationOverlay overlay; + @Getter + @Inject + private ColorPickerManager colorPickerManager; + private ScreenMarkerMouseListener mouseListener; private ScreenMarkerPluginPanel pluginPanel; private NavigationButton navigationButton; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java index 6937543df2..e9d827202b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java @@ -33,8 +33,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import javax.swing.BorderFactory; import javax.swing.ImageIcon; @@ -545,8 +543,11 @@ class ScreenMarkerPanel extends JPanel private void openFillColorPicker() { - RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(this), - marker.getMarker().getFill(), marker.getMarker().getName() + " Fill", false); + RuneliteColorPicker colorPicker = plugin.getColorPickerManager().create( + SwingUtilities.windowForComponent(this), + marker.getMarker().getFill(), + marker.getMarker().getName() + " Fill", + false); colorPicker.setLocation(getLocationOnScreen()); colorPicker.setOnColorChange(c -> { @@ -559,8 +560,11 @@ class ScreenMarkerPanel extends JPanel private void openBorderColorPicker() { - RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(this), - marker.getMarker().getColor(), marker.getMarker().getName() + " Border", false); + RuneliteColorPicker colorPicker = plugin.getColorPickerManager().create( + SwingUtilities.windowForComponent(this), + marker.getMarker().getColor(), + marker.getMarker().getName() + " Border", + false); colorPicker.setLocation(getLocationOnScreen()); colorPicker.setOnColorChange(c -> { diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/ColorPickerManager.java b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/ColorPickerManager.java new file mode 100644 index 0000000000..f85c226784 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/ColorPickerManager.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ron Young + * 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.ui.components.colorpicker; + +import java.awt.Color; +import java.awt.Window; +import java.awt.event.WindowEvent; +import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import net.runelite.client.config.ConfigManager; + +@Singleton +public class ColorPickerManager +{ + private final ConfigManager configManager; + + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) + private RuneliteColorPicker currentPicker; + + @Inject + private ColorPickerManager(final ConfigManager configManager) + { + this.configManager = configManager; + } + + public RuneliteColorPicker create(Window owner, Color previousColor, String title, boolean alphaHidden) + { + if (currentPicker != null) + { + currentPicker.dispatchEvent(new WindowEvent(currentPicker, WindowEvent.WINDOW_CLOSING)); + } + + currentPicker = new RuneliteColorPicker(owner, previousColor, title, alphaHidden, configManager, this); + return currentPicker; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java index 1774725c43..b7b5b0de21 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java @@ -41,6 +41,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.util.Objects; import java.util.function.Consumer; import javax.swing.JDialog; import javax.swing.JFrame; @@ -55,6 +56,7 @@ import javax.swing.text.Document; import javax.swing.text.DocumentFilter; import lombok.Getter; import lombok.Setter; +import net.runelite.client.config.ConfigManager; import net.runelite.client.ui.ColorScheme; import net.runelite.client.util.ColorUtil; import org.pushingpixels.substance.internal.SubstanceSynapse; @@ -89,7 +91,8 @@ public class RuneliteColorPicker extends JDialog @Setter private Consumer onClose; - public RuneliteColorPicker(Window parent, Color previousColor, String title, boolean alphaHidden) + RuneliteColorPicker(Window parent, Color previousColor, String title, boolean alphaHidden, + final ConfigManager configManager, final ColorPickerManager colorPickerManager) { super(parent, "RuneLite Color Picker - " + title, ModalityType.MODELESS); @@ -99,6 +102,7 @@ public class RuneliteColorPicker extends JDialog setResizable(false); setSize(FRAME_WIDTH, FRAME_HEIGHT); setBackground(ColorScheme.PROGRESS_COMPLETE_COLOR); + setDefaultCloseOperation(DISPOSE_ON_CLOSE); JPanel content = new JPanel(new BorderLayout()); content.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0); @@ -280,6 +284,12 @@ public class RuneliteColorPicker extends JDialog { onClose.accept(selectedColor); } + + RuneliteColorPicker cp = colorPickerManager.getCurrentPicker(); + if (Objects.equals(cp, RuneliteColorPicker.this)) + { + colorPickerManager.setCurrentPicker(null); + } } }); } From 46531f7665bcd02d22594c144eb6e4f59f4c7fdb Mon Sep 17 00:00:00 2001 From: Ron Young Date: Sat, 23 Feb 2019 16:51:33 -0600 Subject: [PATCH 15/21] RuneliteColorPicker: add support for recent colors --- .../components/colorpicker/RecentColors.java | 133 ++++++++++++++++++ .../colorpicker/RuneliteColorPicker.java | 29 +++- 2 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RecentColors.java diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RecentColors.java b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RecentColors.java new file mode 100644 index 0000000000..fcb69a3198 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RecentColors.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2019, Ron Young + * 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.ui.components.colorpicker; + +import com.google.common.collect.EvictingQueue; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.function.Consumer; +import javax.swing.JPanel; +import net.runelite.client.config.ConfigManager; +import static net.runelite.client.ui.components.colorpicker.RuneliteColorPicker.CONFIG_GROUP; +import net.runelite.client.util.ColorUtil; +import net.runelite.client.util.Text; + +final class RecentColors +{ + private static final String CONFIG_KEY = "recentColors"; + private static final int MAX = 16; + private static final int BOX_SIZE = 16; + + private final EvictingQueue recentColors = EvictingQueue.create(MAX); + private final ConfigManager configManager; + + RecentColors(final ConfigManager configManager) + { + this.configManager = configManager; + } + + private void load() + { + String str = configManager.getConfiguration(CONFIG_GROUP, CONFIG_KEY); + if (str != null) + { + recentColors.addAll(Text.fromCSV(str)); + } + } + + void add(final String color) + { + if (ColorUtil.fromString(color) == null) + { + return; + } + + recentColors.remove(color); + recentColors.add(color); + + configManager.setConfiguration(CONFIG_GROUP, CONFIG_KEY, Text.toCSV(recentColors)); + } + + JPanel build(final Consumer consumer, final boolean alphaHidden) + { + load(); + + JPanel container = new JPanel(new GridBagLayout()); + + GridBagConstraints cx = new GridBagConstraints(); + cx.insets = new Insets(0, 1, 4, 2); + cx.gridy = 0; + cx.gridx = 0; + cx.anchor = GridBagConstraints.WEST; + + for (String s : recentColors) + { + if (cx.gridx == MAX / 2) + { + cx.gridy++; + cx.gridx = 0; + } + + // Make sure the last element stays in line with all of the others + if (container.getComponentCount() == recentColors.size() - 1) + { + cx.weightx = 1; + cx.gridwidth = MAX / 2 - cx.gridx; + } + + container.add(createBox(ColorUtil.fromString(s), consumer, alphaHidden), cx); + cx.gridx++; + } + + return container; + } + + private static JPanel createBox(final Color color, final Consumer consumer, final boolean alphaHidden) + { + final JPanel box = new JPanel(); + String hex = alphaHidden ? ColorUtil.colorToHexCode(color) : ColorUtil.colorToAlphaHexCode(color); + + box.setBackground(color); + box.setOpaque(true); + box.setPreferredSize(new Dimension(BOX_SIZE, BOX_SIZE)); + box.setToolTipText("#" + hex.toUpperCase()); + box.addMouseListener(new MouseAdapter() + { + @Override + public void mouseClicked(MouseEvent e) + { + consumer.accept(color); + } + }); + + return box; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java index b7b5b0de21..653d31ecf8 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/colorpicker/RuneliteColorPicker.java @@ -63,6 +63,8 @@ import org.pushingpixels.substance.internal.SubstanceSynapse; public class RuneliteColorPicker extends JDialog { + static final String CONFIG_GROUP = "colorpicker"; + private final static int FRAME_WIDTH = 400; private final static int FRAME_HEIGHT = 380; private final static int TONE_PANEL_SIZE = 160; @@ -97,6 +99,9 @@ public class RuneliteColorPicker extends JDialog super(parent, "RuneLite Color Picker - " + title, ModalityType.MODELESS); this.selectedColor = previousColor; + this.alphaHidden = alphaHidden; + + RecentColors recentColors = new RecentColors(configManager); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setResizable(false); @@ -118,7 +123,6 @@ public class RuneliteColorPicker extends JDialog rightPanel.setLayout(new GridBagLayout()); GridBagConstraints cx = new GridBagConstraints(); - cx.insets = new Insets(0, 0, 0, 0); JLabel old = new JLabel("Previous"); old.setHorizontalAlignment(JLabel.CENTER); @@ -149,11 +153,26 @@ public class RuneliteColorPicker extends JDialog hexContainer.add(hexInput, cx); cx.fill = GridBagConstraints.BOTH; - cx.gridwidth = GridBagConstraints.RELATIVE; cx.weightx = 1; cx.weighty = 1; cx.gridy = 0; cx.gridx = 0; + + JPanel recentColorsContainer = recentColors.build(c -> + { + if (!alphaHidden) + { + alphaSlider.update(c.getAlpha()); + } + + colorChange(c); + updatePanels(); + }, alphaHidden); + + rightPanel.add(recentColorsContainer, cx); + + cx.gridwidth = GridBagConstraints.RELATIVE; + cx.gridy++; rightPanel.add(old, cx); cx.gridx++; @@ -185,7 +204,6 @@ public class RuneliteColorPicker extends JDialog slidersContainer.add(blueSlider); slidersContainer.add(alphaSlider); - this.alphaHidden = alphaHidden; if (alphaHidden) { alphaSlider.setVisible(false); @@ -285,6 +303,11 @@ public class RuneliteColorPicker extends JDialog onClose.accept(selectedColor); } + if (!Objects.equals(previousColor, selectedColor)) + { + recentColors.add(selectedColor.getRGB() + ""); + } + RuneliteColorPicker cp = colorPickerManager.getCurrentPicker(); if (Objects.equals(cp, RuneliteColorPicker.this)) { From 37aa862aaf1d26c23c198879fd4fb749561bc0e5 Mon Sep 17 00:00:00 2001 From: Jordan Parker Date: Mon, 15 Jul 2019 16:38:07 +1000 Subject: [PATCH 16/21] fishing: Add Entrana river fishing spots --- .../net/runelite/client/plugins/fishing/FishingSpot.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java index 04dc3bacf8..dca9efe014 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpot.java @@ -90,6 +90,7 @@ import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1508; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1509; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1513; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1515; +import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1516; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1526; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1527; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_6825; @@ -127,9 +128,9 @@ enum FishingSpot ), SALMON("Salmon, Trout", ItemID.RAW_SALMON, ROD_FISHING_SPOT, ROD_FISHING_SPOT_1508, ROD_FISHING_SPOT_1509, - ROD_FISHING_SPOT_1513, ROD_FISHING_SPOT_1515, ROD_FISHING_SPOT_1526, - ROD_FISHING_SPOT_1527, ROD_FISHING_SPOT_7463, ROD_FISHING_SPOT_7464, - ROD_FISHING_SPOT_7468, ROD_FISHING_SPOT_8524 + ROD_FISHING_SPOT_1513, ROD_FISHING_SPOT_1515, ROD_FISHING_SPOT_1516, + ROD_FISHING_SPOT_1526, ROD_FISHING_SPOT_1527, ROD_FISHING_SPOT_7463, + ROD_FISHING_SPOT_7464, ROD_FISHING_SPOT_7468, ROD_FISHING_SPOT_8524 ), BARB_FISH("Sturgeon, Salmon, Trout", ItemID.LEAPING_STURGEON, FISHING_SPOT_1542, FISHING_SPOT_7323 From bd89209a994bd5281386a968e9bf5656b9964283 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Thu, 11 Jul 2019 20:04:05 -0600 Subject: [PATCH 17/21] runelite-client: Allow partial screen containment again --- .../client/config/RuneLiteConfig.java | 9 ++-- .../java/net/runelite/client/ui/ClientUI.java | 10 ++++- .../runelite/client/ui/ContainableFrame.java | 41 +++++++++++-------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java index 13b1f5dee6..2c4cf3597a 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java @@ -26,6 +26,7 @@ package net.runelite.client.config; import java.awt.Dimension; import net.runelite.api.Constants; +import net.runelite.client.ui.ContainableFrame; @ConfigGroup("runelite") public interface RuneLiteConfig extends Config @@ -64,14 +65,14 @@ public interface RuneLiteConfig extends Config } @ConfigItem( - keyName = "containInScreen", + keyName = "containInScreen2", name = "Contain in screen", - description = "Makes the client stay contained in the screen when attempted to move out of it.
Note: Only works if custom chrome is enabled.", + description = "Makes the client stay contained in the screen when attempted to move out of it.
Note: 'Always' only works if custom chrome is enabled.", position = 13 ) - default boolean containInScreen() + default ContainableFrame.Mode containInScreen() { - return false; + return ContainableFrame.Mode.RESIZING; } @ConfigItem( diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 247e6a9dff..5a175716d4 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -858,7 +858,15 @@ public class ClientUI } frame.setExpandResizeType(config.automaticResizeType()); - frame.setContainedInScreen(config.containInScreen() && withTitleBar); + + ContainableFrame.Mode containMode = config.containInScreen(); + if (containMode == ContainableFrame.Mode.ALWAYS && !withTitleBar) + { + // When native window decorations are enabled we don't have a way to receive window move events + // so we can't contain to screen always. + containMode = ContainableFrame.Mode.RESIZING; + } + frame.setContainedInScreen(containMode); if (!config.rememberScreenBounds()) { diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java index fdfca6e89c..e65d6c9fa7 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java @@ -32,18 +32,25 @@ import net.runelite.client.config.ExpandResizeType; public class ContainableFrame extends JFrame { + public enum Mode + { + ALWAYS, + RESIZING, + NEVER; + } + private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40; @Setter private ExpandResizeType expandResizeType; - private boolean containedInScreen; + private Mode containedInScreen; private boolean expandedClientOppositeDirection; - public void setContainedInScreen(boolean value) + public void setContainedInScreen(Mode value) { this.containedInScreen = value; - if (value) + if (this.containedInScreen == Mode.ALWAYS) { // Reposition the frame if it is intersecting with the bounds this.setLocation(this.getX(), this.getY()); @@ -54,13 +61,13 @@ public class ContainableFrame extends JFrame @Override public void setLocation(int x, int y) { - if (containedInScreen) + if (this.containedInScreen == Mode.ALWAYS) { Rectangle bounds = this.getGraphicsConfiguration().getBounds(); - x = Math.max(x, (int)bounds.getX()); - x = Math.min(x, (int)(bounds.getX() + bounds.getWidth() - this.getWidth())); - y = Math.max(y, (int)bounds.getY()); - y = Math.min(y, (int)(bounds.getY() + bounds.getHeight() - this.getHeight())); + x = Math.max(x, (int) bounds.getX()); + x = Math.min(x, (int) (bounds.getX() + bounds.getWidth() - this.getWidth())); + y = Math.max(y, (int) bounds.getY()); + y = Math.min(y, (int) (bounds.getY() + bounds.getHeight() - this.getHeight())); } super.setLocation(x, y); @@ -69,15 +76,17 @@ public class ContainableFrame extends JFrame @Override public void setBounds(int x, int y, int width, int height) { - if (containedInScreen) + if (this.containedInScreen == Mode.ALWAYS) { + // XXX: this is wrong if setSize/resize is called because Component::resize sets private state that is read + // in Window::setBounds Rectangle bounds = this.getGraphicsConfiguration().getBounds(); - width = Math.min(width, width - (int)bounds.getX() + x); - x = Math.max(x, (int)bounds.getX()); - height = Math.min(height, height - (int)bounds.getY() + y); - y = Math.max(y, (int)bounds.getY()); - width = Math.min(width, (int)(bounds.getX() + bounds.getWidth()) - x); - height = Math.min(height, (int)(bounds.getY() + bounds.getHeight()) - y); + width = Math.min(width, width - (int) bounds.getX() + x); + x = Math.max(x, (int) bounds.getX()); + height = Math.min(height, height - (int) bounds.getY() + y); + y = Math.max(y, (int) bounds.getY()); + width = Math.min(width, (int) (bounds.getX() + bounds.getWidth()) - x); + height = Math.min(height, (int) (bounds.getY() + bounds.getHeight()) - y); } super.setBounds(x, y, width, height); @@ -115,7 +124,7 @@ public class ContainableFrame extends JFrame final int newWindowWidth = getWidth() + increment; int newWindowX = getX(); - if (containedInScreen) + if (this.containedInScreen != Mode.NEVER) { final Rectangle screenBounds = getGraphicsConfiguration().getBounds(); final boolean wouldExpandThroughEdge = getX() + newWindowWidth > screenBounds.getX() + screenBounds.getWidth(); From afaf2f61f4de8d490f0bc3f2a68a4d3e92851855 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 15 Jul 2019 16:19:06 +0100 Subject: [PATCH 18/21] mining plugin: add gem rocks --- .../runelite/client/plugins/mining/Rock.java | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java index 19207b7fd6..b87b46d3ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java @@ -29,27 +29,7 @@ import java.time.Duration; import java.util.Map; import lombok.AccessLevel; import lombok.Getter; -import static net.runelite.api.ObjectID.ROCKS_10943; -import static net.runelite.api.ObjectID.ROCKS_11161; -import static net.runelite.api.ObjectID.ROCKS_11360; -import static net.runelite.api.ObjectID.ROCKS_11361; -import static net.runelite.api.ObjectID.ROCKS_11364; -import static net.runelite.api.ObjectID.ROCKS_11365; -import static net.runelite.api.ObjectID.ROCKS_11366; -import static net.runelite.api.ObjectID.ROCKS_11367; -import static net.runelite.api.ObjectID.ROCKS_11368; -import static net.runelite.api.ObjectID.ROCKS_11369; -import static net.runelite.api.ObjectID.ROCKS_11370; -import static net.runelite.api.ObjectID.ROCKS_11371; -import static net.runelite.api.ObjectID.ROCKS_11372; -import static net.runelite.api.ObjectID.ROCKS_11373; -import static net.runelite.api.ObjectID.ROCKS_11374; -import static net.runelite.api.ObjectID.ROCKS_11375; -import static net.runelite.api.ObjectID.ROCKS_11376; -import static net.runelite.api.ObjectID.ROCKS_11377; -import static net.runelite.api.ObjectID.ROCKS_11386; -import static net.runelite.api.ObjectID.ROCKS_11387; -import static net.runelite.api.ObjectID.ASH_PILE; +import static net.runelite.api.ObjectID.*; enum Rock { @@ -101,7 +81,8 @@ enum Rock }, ORE_VEIN(Duration.ofSeconds(MiningOverlay.ORE_VEIN_MAX_RESPAWN_TIME), 150), AMETHYST(Duration.ofSeconds(75), 120), - ASH_VEIN(Duration.ofSeconds(30), 0, ASH_PILE); + ASH_VEIN(Duration.ofSeconds(30), 0, ASH_PILE), + GEM_ROCK(Duration.ofMinutes(1), 0, ROCKS_11380, ROCKS_11381); private static final Map ROCKS; From ebed283f1daf9054065ec6254a2b6b05aecce084 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 12 Jul 2019 23:33:12 -0400 Subject: [PATCH 19/21] zoom plugin: add control to reset zoom --- .../main/java/net/runelite/api/ScriptID.java | 11 +++++ .../client/plugins/zoom/ControlFunction.java | 46 +++++++++++++++++++ .../client/plugins/zoom/ZoomConfig.java | 25 ++++++++-- .../client/plugins/zoom/ZoomPlugin.java | 15 +++++- 4 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptID.java b/runelite-api/src/main/java/net/runelite/api/ScriptID.java index 56f29fb073..355aa5cffa 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java @@ -139,6 +139,17 @@ public final class ScriptID */ public static final int DIARY_QUEST_UPDATE_LINECOUNT = 2523; + /** + * Handles zoom input + * + * Updates the VarClientInts (73, 74) to this same value + *
    + *
  • int Reset zoom position
  • + *
  • int Reset zoom position
  • + *
+ */ + public static final int CAMERA_DO_ZOOM = 42; + /** * Does nothing * diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java new file mode 100644 index 0000000000..1f3b431808 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ControlFunction.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019, Jacob M + * 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 HOLDER 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.zoom; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ControlFunction +{ + NONE("None"), + CONTROL_TO_ZOOM("Hold to zoom"), + CONTROL_TO_RESET("Reset zoom"); + + private final String name; + + @Override + public String toString() + { + return getName(); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java index 577ddf03ab..0bc1f33140 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java @@ -73,13 +73,28 @@ public interface ZoomConfig extends Config } @ConfigItem( - keyName = "requireControlDown", - name = "Require control down", - description = "Configures if holding control is required for zooming", + keyName = "controlFunction", + name = "Control Function", + description = "Configures the zoom function when control is pressed", position = 4 ) - default boolean requireControlDown() + default ControlFunction controlFunction() { - return false; + return ControlFunction.NONE; + } + + @ConfigItem( + keyName = "ctrlZoomValue", + name = "Reset zoom position", + description = "Position of zoom when it is reset", + position = 5 + ) + @Range( + min = OUTER_LIMIT_MIN, + max = OUTER_LIMIT_MAX + ) + default int ctrlZoomValue() + { + return 512; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java index 6a46934de3..db5ffaa5ca 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java @@ -30,9 +30,11 @@ import com.google.inject.Inject; import com.google.inject.Provides; import java.awt.event.KeyEvent; import net.runelite.api.Client; +import net.runelite.api.ScriptID; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; import net.runelite.api.events.ScriptCallbackEvent; +import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.input.KeyListener; @@ -60,6 +62,9 @@ public class ZoomPlugin extends Plugin implements KeyListener @Inject private Client client; + @Inject + private ClientThread clientThread; + @Inject private ZoomConfig zoomConfig; @@ -85,7 +90,7 @@ public class ZoomPlugin extends Plugin implements KeyListener int[] intStack = client.getIntStack(); int intStackSize = client.getIntStackSize(); - if ("scrollWheelZoom".equals(event.getEventName()) && zoomConfig.requireControlDown() && !controlDown) + if (!controlDown && "scrollWheelZoom".equals(event.getEventName()) && zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_ZOOM) { intStack[intStackSize - 1] = 1; } @@ -138,7 +143,7 @@ public class ZoomPlugin extends Plugin implements KeyListener controlDown = false; } } - + @Override protected void startUp() { @@ -180,6 +185,12 @@ public class ZoomPlugin extends Plugin implements KeyListener if (e.getKeyCode() == KeyEvent.VK_CONTROL) { controlDown = false; + + if (zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_RESET) + { + final int zoomValue = Ints.constrainToRange(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT); + clientThread.invokeLater(() -> client.runScript(ScriptID.CAMERA_DO_ZOOM, zoomValue, zoomValue)); + } } } } From aeab3e8a7b77d92507dfd3d580d12c6f5b06ede1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 12 Jul 2019 23:34:01 -0400 Subject: [PATCH 20/21] zoom plugin: add zoom scroll speed configuration --- .../net/runelite/client/plugins/zoom/ZoomConfig.java | 12 ++++++++++++ .../net/runelite/client/plugins/zoom/ZoomPlugin.java | 7 +++++++ .../src/main/scripts/ScrollWheelZoomHandler.rs2asm | 2 ++ 3 files changed, 21 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java index 0bc1f33140..1ed1c5700d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java @@ -97,4 +97,16 @@ public interface ZoomConfig extends Config { return 512; } + + @ConfigItem( + keyName = "zoomIncrement", + name = "Zoom Speed", + description = "Speed of zoom", + position = 6 + ) + default int zoomIncrement() + { + return 25; + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java index db5ffaa5ca..4b2e127bf9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java @@ -56,6 +56,7 @@ public class ZoomPlugin extends Plugin implements KeyListener * Larger values trigger an overflow in the engine's fov to scale code. */ private static final int INNER_ZOOM_LIMIT = 1004; + private static final int DEFAULT_ZOOM_INCREMENT = 25; private boolean controlDown; @@ -109,6 +110,12 @@ public class ZoomPlugin extends Plugin implements KeyListener return; } + if ("scrollWheelZoomIncrement".equals(event.getEventName()) && zoomConfig.zoomIncrement() != DEFAULT_ZOOM_INCREMENT) + { + intStack[intStackSize - 1] = zoomConfig.zoomIncrement(); + return; + } + if (zoomConfig.innerLimit()) { // This lets the options panel's slider have an exponential rate diff --git a/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm b/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm index 665eb44242..618f50abf9 100644 --- a/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm +++ b/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm @@ -11,6 +11,8 @@ iconst 0 iload 0 iconst 25 + sconst "scrollWheelZoomIncrement" + runelite_callback multiply sub istore 1 From ded702b11f56ee3ffa88b695b4fee101adde7458 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 16 Jul 2019 09:37:11 +0100 Subject: [PATCH 21/21] Add GE limit for Golovanova fruit top (#9385) --- .../net/runelite/client/plugins/grandexchange/ge_limits.json | 1 + 1 file changed, 1 insertion(+) diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/grandexchange/ge_limits.json b/runelite-client/src/main/resources/net/runelite/client/plugins/grandexchange/ge_limits.json index 37072ae9b1..bba7233ee1 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/grandexchange/ge_limits.json +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/grandexchange/ge_limits.json @@ -3088,6 +3088,7 @@ "19627": 10000, "19629": 10000, "19631": 10000, + "19653": 100, "19656": 13000, "19662": 10000, "19665": 13000,