diff --git a/cache/src/main/java/net/runelite/cache/io/OutputStream.java b/cache/src/main/java/net/runelite/cache/io/OutputStream.java index 751905f4fb..24275b5c73 100644 --- a/cache/src/main/java/net/runelite/cache/io/OutputStream.java +++ b/cache/src/main/java/net/runelite/cache/io/OutputStream.java @@ -27,6 +27,7 @@ package net.runelite.cache.io; import com.google.common.base.Preconditions; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.nio.Buffer; import java.nio.ByteBuffer; public final class OutputStream extends java.io.OutputStream @@ -56,7 +57,7 @@ public final class OutputStream extends java.io.OutputStream int newCapacity = buffer.capacity() * 2; ByteBuffer old = buffer; - old.flip(); + ((Buffer) old).flip(); buffer = ByteBuffer.allocate(newCapacity); @@ -196,7 +197,7 @@ public final class OutputStream extends java.io.OutputStream public byte[] flip() { - buffer.flip(); + ((Buffer) buffer).flip(); byte[] b = new byte[buffer.limit()]; buffer.get(b); return b; diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java index 7e01dc4b56..151fbfd81f 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java @@ -62,18 +62,6 @@ public class XteaClient .url(url) .build(); - try - { - try (Response response = RuneLiteAPI.RLP_CLIENT.newCall(request).execute()) - { - logger.debug("xtea response " + response.code()); - } - } - catch (IOException e) - { - e.printStackTrace(); - } - RuneLiteAPI.RLP_CLIENT.newCall(request).enqueue(new Callback() { @Override @@ -114,9 +102,7 @@ public class XteaClient { InputStream in = response.body().byteStream(); // CHECKSTYLE:OFF - return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken>() - { - }.getType()); + return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken>() {}.getType()); // CHECKSTYLE:ON } catch (JsonParseException ex) 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 1caa667aa9..2c416451aa 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -363,6 +363,7 @@ public interface Client extends GameShell * @param scale the scale of the sprite * @return the created sprite */ + @Nullable Sprite createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale); /** @@ -373,6 +374,7 @@ public interface Client extends GameShell * @param fileId the sprites file ID * @return the sprite image of the file */ + @Nullable Sprite[] getSprites(IndexDataBase source, int archiveId, int fileId); /** 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 70076e3a6d..8d6796b40a 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java @@ -160,9 +160,11 @@ public final class ScriptID /** * Handles zoom input + * + * Updates the VarClientInts (73, 74) to this same value * */ public static final int CAMERA_DO_ZOOM = 42; 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 bbe3ae3f0d..805b7a5620 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); } 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 069483865a..ea30bfe5dd 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 @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Font; import net.runelite.api.Constants; import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.ContainableFrame; @ConfigGroup("runelite") public interface RuneLiteConfig extends Config @@ -66,14 +67,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/game/SpriteManager.java b/runelite-client/src/main/java/net/runelite/client/game/SpriteManager.java index aca3a9ea14..63469c4e49 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 @@ -41,6 +41,8 @@ import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Sprite; 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; @Singleton @@ -52,7 +54,10 @@ public class SpriteManager @Inject private ClientThread clientThread; - private final Cache cache = CacheBuilder.newBuilder() + @Inject + private InfoBoxManager infoBoxManager; + + public Cache cache = CacheBuilder.newBuilder() .maximumSize(128L) .expireAfterAccess(1, TimeUnit.HOURS) .build(); @@ -74,6 +79,11 @@ public class SpriteManager } Sprite[] sp = client.getSprites(client.getIndexSprites(), archive, 0); + if (sp == null) + { + return null; + } + BufferedImage img = sp[file].toBufferedImage(); cache.put(key, img); @@ -102,6 +112,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/antidrag/AntiDragConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java index bd3de31419..833a07e2a3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java @@ -80,9 +80,7 @@ public interface AntiDragConfig extends Config keyName = "dragDelay", name = "Drag Delay", description = "Configures the inventory drag delay in client ticks (20ms)", - position = 3, - hidden = true, - unhide = "keybind" + position = 3 ) default int dragDelay() { 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 382a511753..e630d08389 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 @@ -370,10 +370,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/cluescrolls/clues/CrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java index dbd1bc413a..d94275dcdc 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."), 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 8a8692b947..0273fb6044 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 @@ -30,17 +30,15 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.Font; import java.awt.FontMetrics; import java.awt.Insets; import java.awt.Rectangle; -import java.awt.Font; import java.awt.event.FocusAdapter; 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.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -108,6 +106,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; @@ -136,6 +135,7 @@ public class ConfigPanel extends PluginPanel private final RuneLiteConfig runeLiteConfig; private final RuneLitePlusConfig runeLitePlusConfig; private final ChatColorConfig chatColorConfig; + private final ColorPickerManager colorPickerManager; public static List pluginList = new ArrayList<>(); private final IconTextField searchBar = new IconTextField(); @@ -154,7 +154,8 @@ public class ConfigPanel extends PluginPanel } ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService, - RuneLiteConfig runeLiteConfig, RuneLitePlusConfig runeLitePlusConfig, ChatColorConfig chatColorConfig) + RuneLiteConfig runeLiteConfig, RuneLitePlusConfig runeLitePlusConfig, ChatColorConfig chatColorConfig, + ColorPickerManager colorPickerManager) { super(false); this.pluginManager = pluginManager; @@ -163,6 +164,7 @@ public class ConfigPanel extends PluginPanel this.runeLiteConfig = runeLiteConfig; this.runeLitePlusConfig = runeLitePlusConfig; this.chatColorConfig = chatColorConfig; + this.colorPickerManager = colorPickerManager; searchBar.setIcon(IconTextField.Icon.SEARCH); searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30)); @@ -250,7 +252,7 @@ public class ConfigPanel extends PluginPanel } lines.add(sb.toString()); - return new Dimension(WIDTH, (lines.size() * fontMetrics.getHeight()) + HEIGHT_PADDING); + return new Dimension(WIDTH, (lines.size() * fontMetrics.getHeight()) + HEIGHT_PADDING); } } @@ -910,8 +912,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 -> { @@ -919,14 +924,7 @@ public class ConfigPanel extends PluginPanel 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/config/ConfigPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java index d649f3832e..16cb909628 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 @@ -46,6 +46,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; @@ -80,6 +81,9 @@ public class ConfigPlugin extends Plugin @Inject private ChatColorConfig chatColorConfig; + @Inject + private ColorPickerManager colorPickerManager; + @Inject private EventBus eventBus; @@ -91,7 +95,7 @@ public class ConfigPlugin extends Plugin { addSubscriptions(); - configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, runeLitePlusConfig, chatColorConfig); + configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, runeLitePlusConfig, chatColorConfig, colorPickerManager); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png"); 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 36ef995fa8..bede4b7236 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 javax.inject.Singleton; @@ -39,7 +39,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/coxhelper/CoxInfoBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxInfoBox.java index e69be13521..7c2e3e83e6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxInfoBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxInfoBox.java @@ -28,7 +28,6 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.Image; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; @@ -87,7 +86,7 @@ public class CoxInfoBox extends Overlay if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null) { InfoBoxComponent prayComponent = new InfoBoxComponent(); - Image prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm)); + BufferedImage prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm)); prayComponent.setImage(prayImg); prayComponent.setColor(Color.WHITE); prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer()) @@ -160,7 +159,7 @@ public class CoxInfoBox extends Overlay return null; } - private Image scaleImg(final Image img) + private BufferedImage scaleImg(final BufferedImage img) { if (img == null) { 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 diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeInfo.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeInfo.java deleted file mode 100644 index 2a5409cd4d..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeInfo.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.runelite.client.plugins.freezetimers; - -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import net.runelite.api.Actor; -import net.runelite.api.coords.LocalPoint; - -@Builder -class FreezeInfo -{ - @Getter(AccessLevel.PACKAGE) - private final Actor actor; - @Getter(AccessLevel.PACKAGE) - private final LocalPoint freezePoint; -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java index 50e4824c94..55085bd094 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java @@ -25,25 +25,24 @@ package net.runelite.client.plugins.freezetimers; import com.google.inject.Provides; -import java.util.HashMap; -import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Actor; import net.runelite.api.Client; -import net.runelite.api.Player; +import net.runelite.api.NPC; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; +import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.SpotAnimationChanged; -import net.runelite.api.events.PlayerDespawned; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.EventBus; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.OverlayManager; +import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( name = "Freeze Timers", @@ -55,7 +54,7 @@ import net.runelite.client.ui.overlay.OverlayManager; @Singleton public class FreezeTimersPlugin extends Plugin { - private final Map freezes = new HashMap<>(); + private static final int VORKATH_REGION = 9023; @Inject private Client client; @@ -122,7 +121,7 @@ public class FreezeTimersPlugin extends Plugin eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged); eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged); eventBus.subscribe(GameTick.class, this, this::onGameTick); - eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned); + eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); } private void onSpotAnimationChanged(SpotAnimationChanged graphicChanged) @@ -166,16 +165,30 @@ public class FreezeTimersPlugin extends Plugin } } - private void onPlayerDespawned(PlayerDespawned playerDespawned) + private void onNpcDespawned(NpcDespawned event) { - final Player player = playerDespawned.getPlayer(); - // All despawns ok: death, teleports, log out, runs away from screen - this.remove(player); + if (!isAtVorkath()) + { + return; + } + + final NPC npc = event.getNpc(); + + if (npc.getName() == null) + { + return; + } + + if (npc.getName().equals("Zombified Spawn")) + { + timers.setTimerEnd(client.getLocalPlayer(), TimerType.FREEZE, + System.currentTimeMillis()); + } } - private void remove(Actor actor) + private boolean isAtVorkath() { - freezes.remove(actor.getName()); + return ArrayUtils.contains(client.getMapRegions(), VORKATH_REGION); } private void onConfigChanged(ConfigChanged event) 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 82f9aa2a83..28b1674e00 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 @@ -128,7 +128,9 @@ public class GroundItemsPlugin extends Plugin 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 WALK = MenuAction.WALK.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) @@ -685,10 +687,14 @@ public class GroundItemsPlugin extends Plugin private void onMenuEntryAdded(MenuEntryAdded event) { - if (this.itemHighlightMode != OVERLAY - && event.getOption().equals("Take") - && event.getType() == THIRD_OPTION) + if (this.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()]; @@ -732,13 +738,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); } } 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 cfca7c4540..d005a30af3 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 @@ -39,6 +39,7 @@ import net.runelite.api.NPC; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; +import net.runelite.api.events.NpcDefinitionChanged; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.client.config.ConfigManager; @@ -47,13 +48,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"} ) @Singleton public class ImplingsPlugin extends Plugin @@ -127,7 +125,7 @@ public class ImplingsPlugin extends Plugin } @Override - protected void startUp() throws Exception + protected void startUp() { updateConfig(); addSubscriptions(); @@ -142,10 +140,11 @@ public class ImplingsPlugin extends Plugin } @Override - protected void shutDown() throws Exception + protected void shutDown() { eventBus.unregister(this); + implings.clear(); overlayManager.remove(overlay); overlayManager.remove(minimapOverlay); overlayManager.remove(implingCounterOverlay); @@ -158,6 +157,7 @@ public class ImplingsPlugin extends Plugin eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned); eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged); eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); + eventBus.subscribe(NpcDefinitionChanged.class, this, this::onNpcDefinitionChanged); } private void onGameTick(GameTick event) @@ -195,6 +195,17 @@ public class ImplingsPlugin extends Plugin } } + private void onNpcDefinitionChanged(NpcDefinitionChanged npcCompositionChanged) + { + NPC npc = npcCompositionChanged.getNpc(); + Impling impling = Impling.findImpling(npc.getId()); + + if (impling != null && !implings.contains(npc)) + { + implings.add(npc); + } + } + private void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) 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 2ef28d51b1..0db24547e1 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.AccessLevel; @@ -88,8 +89,10 @@ class InstanceMapOverlay extends Overlay @Setter(AccessLevel.PACKAGE) private boolean isCloseButtonHovered; - @Getter(AccessLevel.PACKAGE) + + @Getter private Rectangle closeButtonBounds; + private BufferedImage closeButtonImage; private BufferedImage closeButtonHoveredImage; @@ -167,8 +170,6 @@ class InstanceMapOverlay extends Overlay if (image == null) { - BufferedImage closeButton = getCloseButtonImage(); - Sprite map = client.drawInstanceMap(viewedPlane); image = minimapToBufferedImage(map); synchronized (this) @@ -178,7 +179,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()); } @@ -192,8 +198,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()); } @@ -253,6 +266,7 @@ class InstanceMapOverlay extends Overlay return img; } + @Nullable private BufferedImage getCloseButtonImage() { if (closeButtonImage == null) @@ -262,6 +276,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/mining/MiningOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java index f0ca9fea59..763d52b38c 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 @@ -32,8 +32,6 @@ import java.util.Iterator; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; -import lombok.AccessLevel; -import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -47,9 +45,8 @@ import net.runelite.client.ui.overlay.components.ProgressPieComponent; @Singleton class MiningOverlay extends Overlay { - // Range of Motherlode vein respawn time not 100% confirmed but based on observation - @Getter(AccessLevel.PACKAGE) - public static final int ORE_VEIN_MAX_RESPAWN_TIME = 123; + // Range of Motherlode vein respawn time - not 100% confirmed but based on observation + 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); 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; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java index 906cd981fb..85d155dac9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java @@ -25,7 +25,7 @@ package net.runelite.client.plugins.playerinfo; import java.awt.Color; -import java.awt.Image; +import java.awt.image.BufferedImage; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -54,7 +54,7 @@ public class PlayerInfoCustomIndicator extends InfoBox private final Client client; private final IndicatorType type; - PlayerInfoCustomIndicator(final Image image, final PlayerInfoPlugin plugin, final Client client, final IndicatorType type) + PlayerInfoCustomIndicator(final BufferedImage image, final PlayerInfoPlugin plugin, final Client client, final IndicatorType type) { super(image, plugin); this.plugin = plugin; 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 55eaede2bb..7dc1db8748 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 @@ -301,6 +301,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 5b8081236d..16494579e6 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 @@ -389,9 +389,9 @@ public class RaidsPlugin extends Plugin { if (this.raidsTimer) { - 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); - raidStarted = true; } if (this.partyDisplay) { 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 b1cf6600ef..e33fd7c3c0 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; @@ -48,9 +47,9 @@ public class RaidsTimer extends InfoBox @Setter(AccessLevel.PACKAGE) private boolean stopped; - RaidsTimer(final BufferedImage image, final Plugin plugin, final 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/screenmarkers/ScreenMarkerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java index e45bf34e0e..e94418945d 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 @@ -51,6 +51,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; @@ -87,6 +88,10 @@ public class ScreenMarkerPlugin extends Plugin @Inject private ScreenMarkerCreationOverlay overlay; + @Getter + @Inject + private ColorPickerManager colorPickerManager; + @Inject private EventBus eventBus; 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 217922790e..3aced96c5a 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 @@ -31,8 +31,6 @@ import java.awt.Dimension; import java.awt.FlowLayout; 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.inject.Singleton; import javax.swing.BorderFactory; @@ -491,45 +489,35 @@ 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 -> { 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); } 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 -> { 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/plugins/screenshot/ScreenshotPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java index 6e7dce0237..73991b48fa 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 @@ -276,6 +276,8 @@ public class ScreenshotPlugin extends Plugin .build(); clientToolbar.addNavigation(titleBarButton); + + spriteManager.getSpriteAsync(SpriteID.CHATBOX_REPORT_BUTTON, 0, s -> reportButton = s); } @Override 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 485ab55986..c06ed1ce49 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 @@ -1154,7 +1154,7 @@ public class SlayerPlugin extends Plugin else { player = Text.removeTags(chatMessage.getName()) - .replace('\u00A0', ' '); + .replace('\u00A0', ' '); } if (Integer.toString(getPoints()) == null) @@ -1163,11 +1163,11 @@ public class SlayerPlugin extends Plugin } String response = new ChatMessageBuilder() - .append(ChatColorType.NORMAL) - .append("Slayer Points: ") - .append(ChatColorType.HIGHLIGHT) - .append(Integer.toString(getPoints())) - .build(); + .append(ChatColorType.NORMAL) + .append("Slayer Points: ") + .append(ChatColorType.HIGHLIGHT) + .append(Integer.toString(getPoints())) + .build(); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); @@ -1269,4 +1269,4 @@ public class SlayerPlugin extends Plugin this.lastCertainAmount = config.lastCertainAmount(); this.taskLocation = config.taskLocation(); } -} +} \ No newline at end of file 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 538c5326bc..de867b0284 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 @@ -339,4 +339,4 @@ enum Task { return tasks.get(taskName.toLowerCase()); } -} +} \ No newline at end of file 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 6434ad8203..0cdf993aed 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; - } - } -} +} \ No newline at end of file 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 97b51e82fb..1f3406a040 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 @@ -27,7 +27,6 @@ */ package net.runelite.client.plugins.timers; -import java.awt.image.BufferedImage; import java.time.Duration; import java.time.temporal.ChronoUnit; import lombok.AccessLevel; @@ -35,9 +34,8 @@ 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), @@ -77,13 +75,9 @@ enum GameTimer ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom"), DRAGON_FIRE_SHIELD(ItemID.DRAGONFIRE_SHIELD_11284, GameTimerImageType.ITEM, "Dragonfire Shield Special", 2, ChronoUnit.MINUTES); - @Getter(AccessLevel.PACKAGE) private final Duration duration; - @Getter(AccessLevel.PACKAGE) private final Integer graphicId; - @Getter(AccessLevel.PACKAGE) private final String description; - @Getter(AccessLevel.PACKAGE) private final boolean removedOnDeath; private final int imageId; @@ -118,17 +112,4 @@ enum GameTimer { this(imageId, idType, description, null, 1, ChronoUnit.MILLIS, 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; - } - } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimerImageType.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimerImageType.java index 1d51d05e34..008e323fe1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimerImageType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimerImageType.java @@ -28,4 +28,4 @@ enum GameTimerImageType { ITEM, SPRITE -} +} \ No newline at end of file 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 395fd7ba74..85263b0f00 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.AccessLevel; import lombok.Getter; import net.runelite.client.plugins.Plugin; @@ -37,9 +36,9 @@ public class IndicatorIndicator extends InfoBox @Getter(AccessLevel.PACKAGE) private final GameIndicator indicator; - IndicatorIndicator(final GameIndicator indicator, final Image image, final Plugin plugin) + IndicatorIndicator(final GameIndicator indicator, final Plugin plugin) { - super(image, plugin); + super(null, plugin); this.indicator = indicator; setPriority(InfoBoxPriority.MED); } @@ -55,4 +54,4 @@ public class IndicatorIndicator extends InfoBox { return indicator.getTextColor(); } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java index a5e3c44a2e..3cb6a7ef3e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java @@ -57,4 +57,4 @@ enum TeleportWidget } return null; } -} +} \ No newline at end of file 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 5d7ffa5762..88776d3bb6 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 @@ -25,7 +25,6 @@ */ package net.runelite.client.plugins.timers; -import java.awt.image.BufferedImage; import java.time.temporal.ChronoUnit; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.InfoBoxPriority; @@ -35,16 +34,16 @@ class TimerTimer extends Timer { private final GameTimer timer; - TimerTimer(final GameTimer timer, final Plugin plugin, final BufferedImage image) + TimerTimer(final GameTimer timer, final Plugin plugin) { - super(timer.getDuration().toMillis(), ChronoUnit.MILLIS, image, plugin); + super(timer.getDuration().toMillis(), ChronoUnit.MILLIS, null, plugin); this.timer = timer; setPriority(InfoBoxPriority.MED); } - TimerTimer(final GameTimer timer, final int amount, final Plugin plugin, final BufferedImage image) + TimerTimer(final GameTimer timer, final int amount, final Plugin plugin) { - super(timer.getDuration().toMillis() * amount, ChronoUnit.MILLIS, image, plugin); + super(timer.getDuration().toMillis() * amount, ChronoUnit.MILLIS, null, plugin); this.timer = timer; setPriority(InfoBoxPriority.MED); } @@ -53,4 +52,4 @@ class TimerTimer extends Timer { return timer; } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java index 320509b301..4926b9893c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java @@ -220,4 +220,4 @@ public interface TimersConfig extends Config { return true; } -} +} \ No newline at end of file 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 6291672cf7..b66d821b93 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 @@ -27,7 +27,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 javax.inject.Singleton; @@ -153,7 +152,7 @@ public class TimersPlugin extends Plugin @Inject private EventBus eventBus; - + private boolean showHomeMinigameTeleports; private boolean showAntiPoison; private boolean showAntiFire; @@ -186,7 +185,7 @@ public class TimersPlugin extends Plugin updateConfig(); addSubscriptions(); } - + @Override protected void shutDown() throws Exception { @@ -324,9 +323,9 @@ public class TimersPlugin extends Plugin { return; } - + updateConfig(); - + if (!this.showHomeMinigameTeleports) { removeGameTimer(HOME_TELEPORT); @@ -929,8 +928,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; @@ -940,8 +947,16 @@ public class TimersPlugin extends Plugin { removeGameTimer(timer); - BufferedImage image = timer.getImage(itemManager, spriteManager); - TimerTimer t = new TimerTimer(timer, duration, this, image); + TimerTimer t = new TimerTimer(timer, duration, 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; @@ -956,8 +971,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); @@ -976,7 +999,7 @@ public class TimersPlugin extends Plugin removeGameTimer(DMM_FULLTB); removeGameTimer(DMM_HALFTB); } - + private void updateConfig() { this.showHomeMinigameTeleports = config.showHomeMinigameTeleports(); @@ -998,4 +1021,4 @@ public class TimersPlugin extends Plugin this.showStaffOfTheDead = config.showStaffOfTheDead(); this.showAbyssalSireStun = config.showAbyssalSireStun(); } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java index 117583f362..60063c25e5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java @@ -234,13 +234,9 @@ public class VorkathPlugin extends Plugin vorkath.updatePhase(Vorkath.Phase.FIRE_BALL); vorkath.setAttacksLeft(vorkath.getAttacksLeft() - 1); } - else if (vorkathAttack == VorkathAttack.FREEZE_BREATH && vorkath.getLastAttack() != VorkathAttack.ZOMBIFIED_SPAWN) + else if (vorkathAttack == VorkathAttack.FREEZE_BREATH || vorkathAttack == VorkathAttack.ZOMBIFIED_SPAWN) { vorkath.updatePhase(Vorkath.Phase.SPAWN); - vorkath.setAttacksLeft(vorkath.getAttacksLeft() - (vorkath.getAttacksLeft() / 2)); - } - else if (vorkathAttack == VorkathAttack.ZOMBIFIED_SPAWN || (vorkath.getLastAttack() == VorkathAttack.ZOMBIFIED_SPAWN)) - { vorkath.setAttacksLeft(0); } else 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 index 9b526eb543..a5b2522b1c 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Jacob M + * Copyright (c) 2019, Jacob M * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,7 @@ public enum ControlFunction CONTROL_TO_ZOOM("Hold to zoom"), CONTROL_TO_RESET("Reset zoom"); - private String name; + private final String name; @Override public String toString() 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 d3fb50007b..91821ba91b 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 @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package net.runelite.client.plugins.zoom; import net.runelite.client.config.Config; @@ -48,12 +72,11 @@ public interface ZoomConfig extends Config return false; } - @ConfigItem( keyName = "controlFunction", name = "Control Function", description = "Configures the zoom function when control is pressed", - position = 5 + position = 4 ) default ControlFunction controlFunction() { @@ -64,18 +87,22 @@ public interface ZoomConfig extends Config keyName = "ctrlZoomValue", name = "Reset zoom position", description = "Position of zoom when it is reset", - position = 6 + position = 5 + ) + @Range( + min = OUTER_LIMIT_MIN, + max = OUTER_LIMIT_MAX ) default int ctrlZoomValue() { - return 600; + return 512; } @ConfigItem( keyName = "zoomIncrement", name = "Zoom Speed", description = "Speed of zoom", - position = 7 + position = 6 ) default int zoomIncrement() { 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 5e66dc6cd0..21af699278 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 @@ -52,10 +52,11 @@ public class ZoomPlugin extends Plugin implements KeyListener { /** * The largest (most zoomed in) value that can be used without the client crashing. - *

+ * * 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; @@ -92,7 +93,7 @@ public class ZoomPlugin extends Plugin implements KeyListener int[] intStack = client.getIntStack(); int intStackSize = client.getIntStackSize(); - if ("scrollWheelZoom".equals(event.getEventName()) && zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_ZOOM && !controlDown) + if (!controlDown && "scrollWheelZoom".equals(event.getEventName()) && zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_ZOOM) { intStack[intStackSize - 1] = 1; } @@ -111,9 +112,10 @@ public class ZoomPlugin extends Plugin implements KeyListener return; } - if ("scrollWheelZoomIncrement".equals(event.getEventName()) && zoomConfig.zoomIncrement() != 25) + if ("scrollWheelZoomIncrement".equals(event.getEventName()) && zoomConfig.zoomIncrement() != DEFAULT_ZOOM_INCREMENT) { intStack[intStackSize - 1] = zoomConfig.zoomIncrement(); + return; } if (zoomConfig.innerLimit()) @@ -201,6 +203,7 @@ 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 = MiscUtils.clamp(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT); 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 23df405312..7af0ad5675 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 @@ -873,7 +873,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 1a528f75aa..7d03d05ef3 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,11 +32,18 @@ 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; ContainableFrame() @@ -50,11 +57,11 @@ public class ContainableFrame extends JFrame }); } - 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()); @@ -65,7 +72,7 @@ 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()); @@ -80,8 +87,10 @@ 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()); @@ -127,7 +136,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(); 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/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 81d6780d70..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 @@ -39,6 +39,9 @@ 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.Objects; import java.util.function.Consumer; import javax.swing.JDialog; import javax.swing.JFrame; @@ -53,12 +56,15 @@ 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; 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; @@ -84,16 +90,24 @@ public class RuneliteColorPicker extends JDialog @Setter private Consumer onColorChange; - public RuneliteColorPicker(Window parent, Color previousColor, String title, boolean alphaHidden) + @Setter + private Consumer onClose; + + RuneliteColorPicker(Window parent, Color previousColor, String title, boolean alphaHidden, + final ConfigManager configManager, final ColorPickerManager colorPickerManager) { 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); 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); @@ -109,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); @@ -140,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++; @@ -176,7 +204,6 @@ public class RuneliteColorPicker extends JDialog slidersContainer.add(blueSlider); slidersContainer.add(alphaSlider); - this.alphaHidden = alphaHidden; if (alphaHidden) { alphaSlider.setVisible(false); @@ -265,6 +292,29 @@ public class RuneliteColorPicker extends JDialog updatePanels(); updateText(); + + addWindowListener(new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent e) + { + if (onClose != null) + { + onClose.accept(selectedColor); + } + + if (!Objects.equals(previousColor, selectedColor)) + { + recentColors.add(selectedColor.getRGB() + ""); + } + + RuneliteColorPicker cp = colorPickerManager.getCurrentPicker(); + if (Objects.equals(cp, RuneliteColorPicker.this)) + { + colorPickerManager.setCurrentPicker(null); + } + } + }); } private void updatePanels() 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 3a433ffb15..b643bc0062 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 764cde23e4..f2e4b2f1ea 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; @@ -40,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.EventBus; +import net.runelite.client.game.AsyncBufferedImage; import net.runelite.client.plugins.PluginDescriptor; @Singleton @@ -73,6 +73,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) @@ -119,7 +127,7 @@ public class InfoBoxManager } } - private void updateInfoBoxImage(final InfoBox infoBox) + public void updateInfoBoxImage(final InfoBox infoBox) { if (infoBox.getImage() == null) { @@ -127,8 +135,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 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, diff --git a/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm b/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm index c9a0d99f8d..b5f275eab2 100644 --- a/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm +++ b/runelite-client/src/main/scripts/ScrollWheelZoomHandler.rs2asm @@ -11,9 +11,9 @@ iconst 0 iload 0 iconst 25 - sconst "scrollWheelZoomIncrement" + sconst "scrollWheelZoomIncrement" runelite_callback - multiply + multiply sub istore 1 iconst 512 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 169caac2a9..07cb08987b 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 @@ -34,8 +34,10 @@ import net.runelite.api.ChatMessageType; import static net.runelite.api.ChatMessageType.GAMEMESSAGE; import net.runelite.api.Client; import net.runelite.api.MessageNode; +import net.runelite.api.Skill; import net.runelite.api.Varbits; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.VarbitChanged; import net.runelite.api.widgets.Widget; @@ -362,6 +364,9 @@ public class SlayerPluginTest slayerPlugin.getCurrentTask().setTaskName("cows"); slayerPlugin.getCurrentTask().setAmount(42); + final ExperienceChanged experienceChanged = new ExperienceChanged(); + experienceChanged.setSkill(Skill.SLAYER); + ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE, null, 0); slayerPlugin.onChatMessage(chatMessageEvent);