Merge remote-tracking branch 'upstream/master' into rx

This commit is contained in:
Owain van Brakel
2019-07-16 18:52:02 +02:00
54 changed files with 590 additions and 270 deletions

View File

@@ -27,6 +27,7 @@ package net.runelite.cache.io;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public final class OutputStream extends java.io.OutputStream 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; int newCapacity = buffer.capacity() * 2;
ByteBuffer old = buffer; ByteBuffer old = buffer;
old.flip(); ((Buffer) old).flip();
buffer = ByteBuffer.allocate(newCapacity); buffer = ByteBuffer.allocate(newCapacity);
@@ -196,7 +197,7 @@ public final class OutputStream extends java.io.OutputStream
public byte[] flip() public byte[] flip()
{ {
buffer.flip(); ((Buffer) buffer).flip();
byte[] b = new byte[buffer.limit()]; byte[] b = new byte[buffer.limit()];
buffer.get(b); buffer.get(b);
return b; return b;

View File

@@ -62,18 +62,6 @@ public class XteaClient
.url(url) .url(url)
.build(); .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() RuneLiteAPI.RLP_CLIENT.newCall(request).enqueue(new Callback()
{ {
@Override @Override
@@ -114,9 +102,7 @@ public class XteaClient
{ {
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
// CHECKSTYLE:OFF // CHECKSTYLE:OFF
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<List<XteaKey>>() return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<List<XteaKey>>() {}.getType());
{
}.getType());
// CHECKSTYLE:ON // CHECKSTYLE:ON
} }
catch (JsonParseException ex) catch (JsonParseException ex)

View File

@@ -363,6 +363,7 @@ public interface Client extends GameShell
* @param scale the scale of the sprite * @param scale the scale of the sprite
* @return the created sprite * @return the created sprite
*/ */
@Nullable
Sprite createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale); 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 * @param fileId the sprites file ID
* @return the sprite image of the file * @return the sprite image of the file
*/ */
@Nullable
Sprite[] getSprites(IndexDataBase source, int archiveId, int fileId); Sprite[] getSprites(IndexDataBase source, int archiveId, int fileId);
/** /**

View File

@@ -160,9 +160,11 @@ public final class ScriptID
/** /**
* Handles zoom input * Handles zoom input
*
* Updates the VarClientInts (73, 74) to this same value
* <ul> * <ul>
* <li> int zoom value </li> * <li> int Reset zoom position </li>
* <li> int zoom value </li> * <li> int Reset zoom position </li>
* </ul> * </ul>
*/ */
public static final int CAMERA_DO_ZOOM = 42; public static final int CAMERA_DO_ZOOM = 42;

View File

@@ -58,7 +58,7 @@ public class ClientThread
{ {
if (client.isClientThread()) if (client.isClientThread())
{ {
if (r.getAsBoolean()) if (!r.getAsBoolean())
{ {
invokes.add(r); invokes.add(r);
} }

View File

@@ -28,6 +28,7 @@ import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import net.runelite.api.Constants; import net.runelite.api.Constants;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.ContainableFrame;
@ConfigGroup("runelite") @ConfigGroup("runelite")
public interface RuneLiteConfig extends Config public interface RuneLiteConfig extends Config
@@ -66,14 +67,14 @@ public interface RuneLiteConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "containInScreen", keyName = "containInScreen2",
name = "Contain in screen", name = "Contain in screen",
description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: Only works if custom chrome is enabled.", description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: 'Always' only works if custom chrome is enabled.",
position = 13 position = 13
) )
default boolean containInScreen() default ContainableFrame.Mode containInScreen()
{ {
return false; return ContainableFrame.Mode.RESIZING;
} }
@ConfigItem( @ConfigItem(

View File

@@ -41,6 +41,8 @@ import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Sprite; import net.runelite.api.Sprite;
import net.runelite.client.callback.ClientThread; 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; import net.runelite.client.util.ImageUtil;
@Singleton @Singleton
@@ -52,7 +54,10 @@ public class SpriteManager
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
private final Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder() @Inject
private InfoBoxManager infoBoxManager;
public Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder()
.maximumSize(128L) .maximumSize(128L)
.expireAfterAccess(1, TimeUnit.HOURS) .expireAfterAccess(1, TimeUnit.HOURS)
.build(); .build();
@@ -74,6 +79,11 @@ public class SpriteManager
} }
Sprite[] sp = client.getSprites(client.getIndexSprites(), archive, 0); Sprite[] sp = client.getSprites(client.getIndexSprites(), archive, 0);
if (sp == null)
{
return null;
}
BufferedImage img = sp[file].toBufferedImage(); BufferedImage img = sp[file].toBufferedImage();
cache.put(key, img); 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 * Calls setIcon on c, ensuring it is repainted when this changes
*/ */

View File

@@ -80,9 +80,7 @@ public interface AntiDragConfig extends Config
keyName = "dragDelay", keyName = "dragDelay",
name = "Drag Delay", name = "Drag Delay",
description = "Configures the inventory drag delay in client ticks (20ms)", description = "Configures the inventory drag delay in client ticks (20ms)",
position = 3, position = 3
hidden = true,
unhide = "keybind"
) )
default int dragDelay() default int dragDelay()
{ {

View File

@@ -370,10 +370,12 @@ public class BarrowsPlugin extends Plugin
final LoopTimer loopTimer = new LoopTimer( final LoopTimer loopTimer = new LoopTimer(
PRAYER_DRAIN_INTERVAL_MS, PRAYER_DRAIN_INTERVAL_MS,
ChronoUnit.MILLIS, ChronoUnit.MILLIS,
spriteManager.getSprite(SpriteID.TAB_PRAYER, 0), null,
this, this,
true); true);
spriteManager.getSpriteAsync(SpriteID.TAB_PRAYER, 0, loopTimer);
loopTimer.setPriority(InfoBoxPriority.MED); loopTimer.setPriority(InfoBoxPriority.MED);
loopTimer.setTooltip("Prayer Drain"); loopTimer.setTooltip("Prayer Drain");

View File

@@ -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("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("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("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 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("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."), 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."),

View File

@@ -30,17 +30,15 @@ import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; 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.ComboBoxListRenderer;
import net.runelite.client.ui.components.IconButton; import net.runelite.client.ui.components.IconButton;
import net.runelite.client.ui.components.IconTextField; import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker; import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker;
import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
@@ -136,6 +135,7 @@ public class ConfigPanel extends PluginPanel
private final RuneLiteConfig runeLiteConfig; private final RuneLiteConfig runeLiteConfig;
private final RuneLitePlusConfig runeLitePlusConfig; private final RuneLitePlusConfig runeLitePlusConfig;
private final ChatColorConfig chatColorConfig; private final ChatColorConfig chatColorConfig;
private final ColorPickerManager colorPickerManager;
public static List<PluginListItem> pluginList = new ArrayList<>(); public static List<PluginListItem> pluginList = new ArrayList<>();
private final IconTextField searchBar = new IconTextField(); private final IconTextField searchBar = new IconTextField();
@@ -154,7 +154,8 @@ public class ConfigPanel extends PluginPanel
} }
ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService, ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService,
RuneLiteConfig runeLiteConfig, RuneLitePlusConfig runeLitePlusConfig, ChatColorConfig chatColorConfig) RuneLiteConfig runeLiteConfig, RuneLitePlusConfig runeLitePlusConfig, ChatColorConfig chatColorConfig,
ColorPickerManager colorPickerManager)
{ {
super(false); super(false);
this.pluginManager = pluginManager; this.pluginManager = pluginManager;
@@ -163,6 +164,7 @@ public class ConfigPanel extends PluginPanel
this.runeLiteConfig = runeLiteConfig; this.runeLiteConfig = runeLiteConfig;
this.runeLitePlusConfig = runeLitePlusConfig; this.runeLitePlusConfig = runeLitePlusConfig;
this.chatColorConfig = chatColorConfig; this.chatColorConfig = chatColorConfig;
this.colorPickerManager = colorPickerManager;
searchBar.setIcon(IconTextField.Icon.SEARCH); searchBar.setIcon(IconTextField.Icon.SEARCH);
searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30)); searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30));
@@ -250,7 +252,7 @@ public class ConfigPanel extends PluginPanel
} }
lines.add(sb.toString()); 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 @Override
public void mouseClicked(MouseEvent e) public void mouseClicked(MouseEvent e)
{ {
RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(ConfigPanel.this), RuneliteColorPicker colorPicker = colorPickerManager.create(
colorPickerBtn.getBackground(), cid.getItem().name(), cid.getAlpha() == null); SwingUtilities.windowForComponent(ConfigPanel.this),
colorPickerBtn.getBackground(),
cid.getItem().name(),
cid.getAlpha() == null);
colorPicker.setLocation(getLocationOnScreen()); colorPicker.setLocation(getLocationOnScreen());
colorPicker.setOnColorChange(c -> colorPicker.setOnColorChange(c ->
{ {
@@ -919,14 +924,7 @@ public class ConfigPanel extends PluginPanel
colorPickerBtn.setText(ColorUtil.toHexColor(c).toUpperCase()); colorPickerBtn.setText(ColorUtil.toHexColor(c).toUpperCase());
}); });
colorPicker.addWindowListener(new WindowAdapter() colorPicker.setOnClose(c -> changeConfiguration(listItem, config, colorPicker, cd, cid));
{
@Override
public void windowClosing(WindowEvent e)
{
changeConfiguration(listItem, config, colorPicker, cd, cid);
}
});
colorPicker.setVisible(true); colorPicker.setVisible(true);
} }
}); });

View File

@@ -46,6 +46,7 @@ import net.runelite.client.plugins.PluginManager;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
@@ -80,6 +81,9 @@ public class ConfigPlugin extends Plugin
@Inject @Inject
private ChatColorConfig chatColorConfig; private ChatColorConfig chatColorConfig;
@Inject
private ColorPickerManager colorPickerManager;
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;
@@ -91,7 +95,7 @@ public class ConfigPlugin extends Plugin
{ {
addSubscriptions(); 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"); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png");

View File

@@ -25,7 +25,7 @@
package net.runelite.client.plugins.cooking; package net.runelite.client.plugins.cooking;
import java.awt.Color; import java.awt.Color;
import java.awt.Image; import java.awt.image.BufferedImage;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -39,7 +39,7 @@ final class FermentTimer extends InfoBox
private Instant fermentTime; private Instant fermentTime;
FermentTimer(Image image, Plugin plugin) FermentTimer(BufferedImage image, Plugin plugin)
{ {
super(image, plugin); super(image, plugin);
reset(); reset();

View File

@@ -28,7 +28,6 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.inject.Inject; import javax.inject.Inject;
@@ -87,7 +86,7 @@ public class CoxInfoBox extends Overlay
if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null) if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null)
{ {
InfoBoxComponent prayComponent = new InfoBoxComponent(); InfoBoxComponent prayComponent = new InfoBoxComponent();
Image prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm)); BufferedImage prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm));
prayComponent.setImage(prayImg); prayComponent.setImage(prayImg);
prayComponent.setColor(Color.WHITE); prayComponent.setColor(Color.WHITE);
prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer()) prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer())
@@ -160,7 +159,7 @@ public class CoxInfoBox extends Overlay
return null; return null;
} }
private Image scaleImg(final Image img) private BufferedImage scaleImg(final BufferedImage img)
{ {
if (img == null) if (img == null)
{ {

View File

@@ -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_1509;
import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1513; 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_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_1526;
import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1527; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_1527;
import static net.runelite.api.NpcID.ROD_FISHING_SPOT_6825; import static net.runelite.api.NpcID.ROD_FISHING_SPOT_6825;
@@ -127,9 +128,9 @@ enum FishingSpot
), ),
SALMON("Salmon, Trout", ItemID.RAW_SALMON, SALMON("Salmon, Trout", ItemID.RAW_SALMON,
ROD_FISHING_SPOT, ROD_FISHING_SPOT_1508, ROD_FISHING_SPOT_1509, 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_1513, ROD_FISHING_SPOT_1515, ROD_FISHING_SPOT_1516,
ROD_FISHING_SPOT_1527, ROD_FISHING_SPOT_7463, ROD_FISHING_SPOT_7464, ROD_FISHING_SPOT_1526, ROD_FISHING_SPOT_1527, ROD_FISHING_SPOT_7463,
ROD_FISHING_SPOT_7468, ROD_FISHING_SPOT_8524 ROD_FISHING_SPOT_7464, ROD_FISHING_SPOT_7468, ROD_FISHING_SPOT_8524
), ),
BARB_FISH("Sturgeon, Salmon, Trout", ItemID.LEAPING_STURGEON, BARB_FISH("Sturgeon, Salmon, Trout", ItemID.LEAPING_STURGEON,
FISHING_SPOT_1542, FISHING_SPOT_7323 FISHING_SPOT_1542, FISHING_SPOT_7323

View File

@@ -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;
}

View File

@@ -25,25 +25,24 @@
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Client; 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.ConfigChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.SpotAnimationChanged; import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.api.events.PlayerDespawned;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor( @PluginDescriptor(
name = "Freeze Timers", name = "Freeze Timers",
@@ -55,7 +54,7 @@ import net.runelite.client.ui.overlay.OverlayManager;
@Singleton @Singleton
public class FreezeTimersPlugin extends Plugin public class FreezeTimersPlugin extends Plugin
{ {
private final Map<String, FreezeInfo> freezes = new HashMap<>(); private static final int VORKATH_REGION = 9023;
@Inject @Inject
private Client client; private Client client;
@@ -122,7 +121,7 @@ public class FreezeTimersPlugin extends Plugin
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged); eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged); eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick); 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) 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(); if (!isAtVorkath())
// All despawns ok: death, teleports, log out, runs away from screen {
this.remove(player); 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) private void onConfigChanged(ConfigChanged event)

View File

@@ -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 FIFTH_OPTION = MenuAction.GROUND_ITEM_FIFTH_OPTION.getId();
private static final int EXAMINE_ITEM = MenuAction.EXAMINE_ITEM_GROUND.getId(); private static final int EXAMINE_ITEM = MenuAction.EXAMINE_ITEM_GROUND.getId();
private static final int WALK = MenuAction.WALK.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) @Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@@ -685,10 +687,14 @@ public class GroundItemsPlugin extends Plugin
private void onMenuEntryAdded(MenuEntryAdded event) private void onMenuEntryAdded(MenuEntryAdded event)
{ {
if (this.itemHighlightMode != OVERLAY if (this.itemHighlightMode != OVERLAY)
&& event.getOption().equals("Take")
&& event.getType() == THIRD_OPTION)
{ {
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(); int itemId = event.getIdentifier();
Scene scene = client.getScene(); Scene scene = client.getScene();
Tile tile = scene.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()]; Tile tile = scene.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()];
@@ -732,13 +738,27 @@ public class GroundItemsPlugin extends Plugin
if (mode == BOTH || mode == OPTION) 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) if (mode == BOTH || mode == NAME)
{ {
String target = lastEntry.getTarget().substring(lastEntry.getTarget().indexOf(">") + 1); String target = lastEntry.getTarget();
lastEntry.setTarget(ColorUtil.prependColorTag(target, color));
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);
} }
} }

View File

@@ -39,6 +39,7 @@ import net.runelite.api.NPC;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.NpcDefinitionChanged;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.client.config.ConfigManager; 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.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
/**
* @author robin
*/
@PluginDescriptor( @PluginDescriptor(
name = "Implings", name = "Implings",
description = "Highlight nearby implings on the minimap and on-screen", description = "Highlight nearby implings on the minimap and on-screen",
tags = {"hunter", "minimap", "overlay"} tags = {"hunter", "minimap", "overlay", "imp"}
) )
@Singleton @Singleton
public class ImplingsPlugin extends Plugin public class ImplingsPlugin extends Plugin
@@ -127,7 +125,7 @@ public class ImplingsPlugin extends Plugin
} }
@Override @Override
protected void startUp() throws Exception protected void startUp()
{ {
updateConfig(); updateConfig();
addSubscriptions(); addSubscriptions();
@@ -142,10 +140,11 @@ public class ImplingsPlugin extends Plugin
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown()
{ {
eventBus.unregister(this); eventBus.unregister(this);
implings.clear();
overlayManager.remove(overlay); overlayManager.remove(overlay);
overlayManager.remove(minimapOverlay); overlayManager.remove(minimapOverlay);
overlayManager.remove(implingCounterOverlay); overlayManager.remove(implingCounterOverlay);
@@ -158,6 +157,7 @@ public class ImplingsPlugin extends Plugin
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned); eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged); eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(NpcDefinitionChanged.class, this, this::onNpcDefinitionChanged);
} }
private void onGameTick(GameTick event) 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) private void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING)

View File

@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
@@ -88,8 +89,10 @@ class InstanceMapOverlay extends Overlay
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
private boolean isCloseButtonHovered; private boolean isCloseButtonHovered;
@Getter(AccessLevel.PACKAGE)
@Getter
private Rectangle closeButtonBounds; private Rectangle closeButtonBounds;
private BufferedImage closeButtonImage; private BufferedImage closeButtonImage;
private BufferedImage closeButtonHoveredImage; private BufferedImage closeButtonHoveredImage;
@@ -167,8 +170,6 @@ class InstanceMapOverlay extends Overlay
if (image == null) if (image == null)
{ {
BufferedImage closeButton = getCloseButtonImage();
Sprite map = client.drawInstanceMap(viewedPlane); Sprite map = client.drawInstanceMap(viewedPlane);
image = minimapToBufferedImage(map); image = minimapToBufferedImage(map);
synchronized (this) synchronized (this)
@@ -178,7 +179,12 @@ class InstanceMapOverlay extends Overlay
mapImage = image; mapImage = image;
} }
} }
}
BufferedImage closeButton = getCloseButtonImage();
BufferedImage closeButtonHover = getCloseButtonHoveredImage();
if (closeButton != null && closeButtonBounds == null)
{
closeButtonBounds = new Rectangle(image.getWidth() - closeButton.getWidth() - 5, 6, closeButtonBounds = new Rectangle(image.getWidth() - closeButton.getWidth() - 5, 6,
closeButton.getWidth(), closeButton.getHeight()); closeButton.getWidth(), closeButton.getHeight());
} }
@@ -192,8 +198,15 @@ class InstanceMapOverlay extends Overlay
drawPlayerDot(graphics, client.getLocalPlayer(), Color.white, Color.black); drawPlayerDot(graphics, client.getLocalPlayer(), Color.white, Color.black);
} }
graphics.drawImage(isCloseButtonHovered ? getCloseButtonHoveredImage() : getCloseButtonImage(), if (isCloseButtonHovered)
(int) closeButtonBounds.getX(), (int) closeButtonBounds.getY(), null); {
closeButton = closeButtonHover;
}
if (closeButton != null)
{
graphics.drawImage(closeButton, (int) closeButtonBounds.getX(), (int) closeButtonBounds.getY(), null);
}
return new Dimension(image.getWidth(), image.getHeight()); return new Dimension(image.getWidth(), image.getHeight());
} }
@@ -253,6 +266,7 @@ class InstanceMapOverlay extends Overlay
return img; return img;
} }
@Nullable
private BufferedImage getCloseButtonImage() private BufferedImage getCloseButtonImage()
{ {
if (closeButtonImage == null) if (closeButtonImage == null)
@@ -262,6 +276,7 @@ class InstanceMapOverlay extends Overlay
return closeButtonImage; return closeButtonImage;
} }
@Nullable
private BufferedImage getCloseButtonHoveredImage() private BufferedImage getCloseButtonHoveredImage()
{ {
if (closeButtonHoveredImage == null) if (closeButtonHoveredImage == null)

View File

@@ -32,8 +32,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Point; import net.runelite.api.Point;
@@ -47,9 +45,8 @@ import net.runelite.client.ui.overlay.components.ProgressPieComponent;
@Singleton @Singleton
class MiningOverlay extends Overlay class MiningOverlay extends Overlay
{ {
// Range of Motherlode vein respawn time not 100% confirmed but based on observation // Range of Motherlode vein respawn time - not 100% confirmed but based on observation
@Getter(AccessLevel.PACKAGE) static final int ORE_VEIN_MAX_RESPAWN_TIME = 166;
public static final int ORE_VEIN_MAX_RESPAWN_TIME = 123;
private static final int ORE_VEIN_MIN_RESPAWN_TIME = 90; 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 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); private static final Color DARK_GREEN = new Color(0, 100, 0);

View File

@@ -29,27 +29,7 @@ import java.time.Duration;
import java.util.Map; import java.util.Map;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import static net.runelite.api.ObjectID.ROCKS_10943; import static net.runelite.api.ObjectID.*;
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;
enum Rock enum Rock
{ {
@@ -101,7 +81,8 @@ enum Rock
}, },
ORE_VEIN(Duration.ofSeconds(MiningOverlay.ORE_VEIN_MAX_RESPAWN_TIME), 150), ORE_VEIN(Duration.ofSeconds(MiningOverlay.ORE_VEIN_MAX_RESPAWN_TIME), 150),
AMETHYST(Duration.ofSeconds(75), 120), 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<Integer, Rock> ROCKS; private static final Map<Integer, Rock> ROCKS;

View File

@@ -25,7 +25,7 @@
package net.runelite.client.plugins.playerinfo; package net.runelite.client.plugins.playerinfo;
import java.awt.Color; import java.awt.Color;
import java.awt.Image; import java.awt.image.BufferedImage;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@@ -54,7 +54,7 @@ public class PlayerInfoCustomIndicator extends InfoBox
private final Client client; private final Client client;
private final IndicatorType type; 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); super(image, plugin);
this.plugin = plugin; this.plugin = plugin;

View File

@@ -301,6 +301,11 @@ public class PuzzleSolverOverlay extends Overlay
arrow = getUpArrow(); arrow = getUpArrow();
} }
if (arrow == null)
{
continue;
}
int x = puzzleBoxLocation.getX() + blankX * PUZZLE_TILE_SIZE int x = puzzleBoxLocation.getX() + blankX * PUZZLE_TILE_SIZE
+ PUZZLE_TILE_SIZE / 2 - arrow.getWidth() / 2; + PUZZLE_TILE_SIZE / 2 - arrow.getWidth() / 2;

View File

@@ -389,9 +389,9 @@ public class RaidsPlugin extends Plugin
{ {
if (this.raidsTimer) 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); infoBoxManager.addInfoBox(timer);
raidStarted = true;
} }
if (this.partyDisplay) if (this.partyDisplay)
{ {

View File

@@ -25,7 +25,6 @@
package net.runelite.client.plugins.raids; package net.runelite.client.plugins.raids;
import java.awt.Color; import java.awt.Color;
import java.awt.image.BufferedImage;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalTime; import java.time.LocalTime;
@@ -48,9 +47,9 @@ public class RaidsTimer extends InfoBox
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
private boolean stopped; 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; this.startTime = startTime;
floorTime = startTime; floorTime = startTime;
stopped = false; stopped = false;

View File

@@ -51,6 +51,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.screenmarkers.ui.ScreenMarkerPluginPanel; import net.runelite.client.plugins.screenmarkers.ui.ScreenMarkerPluginPanel;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
@@ -87,6 +88,10 @@ public class ScreenMarkerPlugin extends Plugin
@Inject @Inject
private ScreenMarkerCreationOverlay overlay; private ScreenMarkerCreationOverlay overlay;
@Getter
@Inject
private ColorPickerManager colorPickerManager;
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;

View File

@@ -31,8 +31,6 @@ import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@@ -491,45 +489,35 @@ class ScreenMarkerPanel extends JPanel
private void openFillColorPicker() private void openFillColorPicker()
{ {
RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(this), RuneliteColorPicker colorPicker = plugin.getColorPickerManager().create(
marker.getMarker().getFill(), marker.getMarker().getName() + " Fill", false); SwingUtilities.windowForComponent(this),
marker.getMarker().getFill(),
marker.getMarker().getName() + " Fill",
false);
colorPicker.setLocation(getLocationOnScreen()); colorPicker.setLocation(getLocationOnScreen());
colorPicker.setOnColorChange(c -> colorPicker.setOnColorChange(c ->
{ {
marker.getMarker().setFill(c); marker.getMarker().setFill(c);
updateFill(); updateFill();
}); });
colorPicker.setOnClose(c -> plugin.updateConfig());
colorPicker.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent e)
{
plugin.updateConfig();
}
});
colorPicker.setVisible(true); colorPicker.setVisible(true);
} }
private void openBorderColorPicker() private void openBorderColorPicker()
{ {
RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(this), RuneliteColorPicker colorPicker = plugin.getColorPickerManager().create(
marker.getMarker().getColor(), marker.getMarker().getName() + " Border", false); SwingUtilities.windowForComponent(this),
marker.getMarker().getColor(),
marker.getMarker().getName() + " Border",
false);
colorPicker.setLocation(getLocationOnScreen()); colorPicker.setLocation(getLocationOnScreen());
colorPicker.setOnColorChange(c -> colorPicker.setOnColorChange(c ->
{ {
marker.getMarker().setColor(c); marker.getMarker().setColor(c);
updateBorder(); updateBorder();
}); });
colorPicker.setOnClose(c -> plugin.updateConfig());
colorPicker.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent e)
{
plugin.updateConfig();
}
});
colorPicker.setVisible(true); colorPicker.setVisible(true);
} }
} }

View File

@@ -276,6 +276,8 @@ public class ScreenshotPlugin extends Plugin
.build(); .build();
clientToolbar.addNavigation(titleBarButton); clientToolbar.addNavigation(titleBarButton);
spriteManager.getSpriteAsync(SpriteID.CHATBOX_REPORT_BUTTON, 0, s -> reportButton = s);
} }
@Override @Override

View File

@@ -1154,7 +1154,7 @@ public class SlayerPlugin extends Plugin
else else
{ {
player = Text.removeTags(chatMessage.getName()) player = Text.removeTags(chatMessage.getName())
.replace('\u00A0', ' '); .replace('\u00A0', ' ');
} }
if (Integer.toString(getPoints()) == null) if (Integer.toString(getPoints()) == null)
@@ -1163,11 +1163,11 @@ public class SlayerPlugin extends Plugin
} }
String response = new ChatMessageBuilder() String response = new ChatMessageBuilder()
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append("Slayer Points: ") .append("Slayer Points: ")
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(getPoints())) .append(Integer.toString(getPoints()))
.build(); .build();
final MessageNode messageNode = chatMessage.getMessageNode(); final MessageNode messageNode = chatMessage.getMessageNode();
messageNode.setRuneLiteFormatMessage(response); messageNode.setRuneLiteFormatMessage(response);
@@ -1269,4 +1269,4 @@ public class SlayerPlugin extends Plugin
this.lastCertainAmount = config.lastCertainAmount(); this.lastCertainAmount = config.lastCertainAmount();
this.taskLocation = config.taskLocation(); this.taskLocation = config.taskLocation();
} }
} }

View File

@@ -339,4 +339,4 @@ enum Task
{ {
return tasks.get(taskName.toLowerCase()); return tasks.get(taskName.toLowerCase());
} }
} }

View File

@@ -25,22 +25,17 @@
package net.runelite.client.plugins.timers; package net.runelite.client.plugins.timers;
import java.awt.Color; import java.awt.Color;
import java.awt.image.BufferedImage;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.SpriteID; import net.runelite.api.SpriteID;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;
@Getter(AccessLevel.PACKAGE)
enum GameIndicator enum GameIndicator
{ {
VENGEANCE_ACTIVE(SpriteID.SPELL_VENGEANCE_OTHER, GameTimerImageType.SPRITE, "Vengeance active"); VENGEANCE_ACTIVE(SpriteID.SPELL_VENGEANCE_OTHER, GameTimerImageType.SPRITE, "Vengeance active");
@Getter(AccessLevel.PACKAGE)
private final String description; private final String description;
@Getter(AccessLevel.PACKAGE)
private String text; private String text;
@Getter(AccessLevel.PACKAGE)
private Color textColor; private Color textColor;
private final int imageId; private final int imageId;
private final GameTimerImageType imageType; private final GameTimerImageType imageType;
@@ -58,17 +53,4 @@ enum GameIndicator
{ {
this(imageId, idType, description, "", null); 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;
}
}
}

View File

@@ -27,7 +27,6 @@
*/ */
package net.runelite.client.plugins.timers; package net.runelite.client.plugins.timers;
import java.awt.image.BufferedImage;
import java.time.Duration; import java.time.Duration;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import lombok.AccessLevel; import lombok.AccessLevel;
@@ -35,9 +34,8 @@ import lombok.Getter;
import net.runelite.api.GraphicID; import net.runelite.api.GraphicID;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.SpriteID; import net.runelite.api.SpriteID;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;
@Getter(AccessLevel.PACKAGE)
enum GameTimer enum GameTimer
{ {
STAMINA(ItemID.STAMINA_POTION4, GameTimerImageType.ITEM, "Stamina", 2, ChronoUnit.MINUTES, true), STAMINA(ItemID.STAMINA_POTION4, GameTimerImageType.ITEM, "Stamina", 2, ChronoUnit.MINUTES, true),
@@ -77,13 +75,9 @@ enum GameTimer
ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom"), ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom"),
DRAGON_FIRE_SHIELD(ItemID.DRAGONFIRE_SHIELD_11284, GameTimerImageType.ITEM, "Dragonfire Shield Special", 2, ChronoUnit.MINUTES); DRAGON_FIRE_SHIELD(ItemID.DRAGONFIRE_SHIELD_11284, GameTimerImageType.ITEM, "Dragonfire Shield Special", 2, ChronoUnit.MINUTES);
@Getter(AccessLevel.PACKAGE)
private final Duration duration; private final Duration duration;
@Getter(AccessLevel.PACKAGE)
private final Integer graphicId; private final Integer graphicId;
@Getter(AccessLevel.PACKAGE)
private final String description; private final String description;
@Getter(AccessLevel.PACKAGE)
private final boolean removedOnDeath; private final boolean removedOnDeath;
private final int imageId; private final int imageId;
@@ -118,17 +112,4 @@ enum GameTimer
{ {
this(imageId, idType, description, null, 1, ChronoUnit.MILLIS, false); 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;
}
}
}

View File

@@ -28,4 +28,4 @@ enum GameTimerImageType
{ {
ITEM, ITEM,
SPRITE SPRITE
} }

View File

@@ -25,7 +25,6 @@
package net.runelite.client.plugins.timers; package net.runelite.client.plugins.timers;
import java.awt.Color; import java.awt.Color;
import java.awt.Image;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -37,9 +36,9 @@ public class IndicatorIndicator extends InfoBox
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final GameIndicator indicator; 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; this.indicator = indicator;
setPriority(InfoBoxPriority.MED); setPriority(InfoBoxPriority.MED);
} }
@@ -55,4 +54,4 @@ public class IndicatorIndicator extends InfoBox
{ {
return indicator.getTextColor(); return indicator.getTextColor();
} }
} }

View File

@@ -57,4 +57,4 @@ enum TeleportWidget
} }
return null; return null;
} }
} }

View File

@@ -25,7 +25,6 @@
*/ */
package net.runelite.client.plugins.timers; package net.runelite.client.plugins.timers;
import java.awt.image.BufferedImage;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.InfoBoxPriority; import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
@@ -35,16 +34,16 @@ class TimerTimer extends Timer
{ {
private final GameTimer 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; this.timer = timer;
setPriority(InfoBoxPriority.MED); 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; this.timer = timer;
setPriority(InfoBoxPriority.MED); setPriority(InfoBoxPriority.MED);
} }
@@ -53,4 +52,4 @@ class TimerTimer extends Timer
{ {
return timer; return timer;
} }
} }

View File

@@ -220,4 +220,4 @@ public interface TimersConfig extends Config
{ {
return true; return true;
} }
} }

View File

@@ -27,7 +27,6 @@
package net.runelite.client.plugins.timers; package net.runelite.client.plugins.timers;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -153,7 +152,7 @@ public class TimersPlugin extends Plugin
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;
private boolean showHomeMinigameTeleports; private boolean showHomeMinigameTeleports;
private boolean showAntiPoison; private boolean showAntiPoison;
private boolean showAntiFire; private boolean showAntiFire;
@@ -186,7 +185,7 @@ public class TimersPlugin extends Plugin
updateConfig(); updateConfig();
addSubscriptions(); addSubscriptions();
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
@@ -324,9 +323,9 @@ public class TimersPlugin extends Plugin
{ {
return; return;
} }
updateConfig(); updateConfig();
if (!this.showHomeMinigameTeleports) if (!this.showHomeMinigameTeleports)
{ {
removeGameTimer(HOME_TELEPORT); removeGameTimer(HOME_TELEPORT);
@@ -929,8 +928,16 @@ public class TimersPlugin extends Plugin
{ {
removeGameTimer(timer); removeGameTimer(timer);
BufferedImage image = timer.getImage(itemManager, spriteManager); TimerTimer t = new TimerTimer(timer, this);
TimerTimer t = new TimerTimer(timer, this, image); 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()); t.setTooltip(timer.getDescription());
infoBoxManager.addInfoBox(t); infoBoxManager.addInfoBox(t);
return t; return t;
@@ -940,8 +947,16 @@ public class TimersPlugin extends Plugin
{ {
removeGameTimer(timer); removeGameTimer(timer);
BufferedImage image = timer.getImage(itemManager, spriteManager); TimerTimer t = new TimerTimer(timer, duration, this);
TimerTimer t = new TimerTimer(timer, duration, this, image); 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()); t.setTooltip(timer.getDescription());
infoBoxManager.addInfoBox(t); infoBoxManager.addInfoBox(t);
return t; return t;
@@ -956,8 +971,16 @@ public class TimersPlugin extends Plugin
{ {
removeGameIndicator(gameIndicator); removeGameIndicator(gameIndicator);
BufferedImage image = gameIndicator.getImage(itemManager, spriteManager); IndicatorIndicator indicator = new IndicatorIndicator(gameIndicator, this);
IndicatorIndicator indicator = new IndicatorIndicator(gameIndicator, image, 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()); indicator.setTooltip(gameIndicator.getDescription());
infoBoxManager.addInfoBox(indicator); infoBoxManager.addInfoBox(indicator);
@@ -976,7 +999,7 @@ public class TimersPlugin extends Plugin
removeGameTimer(DMM_FULLTB); removeGameTimer(DMM_FULLTB);
removeGameTimer(DMM_HALFTB); removeGameTimer(DMM_HALFTB);
} }
private void updateConfig() private void updateConfig()
{ {
this.showHomeMinigameTeleports = config.showHomeMinigameTeleports(); this.showHomeMinigameTeleports = config.showHomeMinigameTeleports();
@@ -998,4 +1021,4 @@ public class TimersPlugin extends Plugin
this.showStaffOfTheDead = config.showStaffOfTheDead(); this.showStaffOfTheDead = config.showStaffOfTheDead();
this.showAbyssalSireStun = config.showAbyssalSireStun(); this.showAbyssalSireStun = config.showAbyssalSireStun();
} }
} }

View File

@@ -234,13 +234,9 @@ public class VorkathPlugin extends Plugin
vorkath.updatePhase(Vorkath.Phase.FIRE_BALL); vorkath.updatePhase(Vorkath.Phase.FIRE_BALL);
vorkath.setAttacksLeft(vorkath.getAttacksLeft() - 1); 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.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); vorkath.setAttacksLeft(0);
} }
else else

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Jacob M <https://github.com/jacoblairm> * Copyright (c) 2019, Jacob M <https://github.com/jacoblairm>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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_ZOOM("Hold to zoom"),
CONTROL_TO_RESET("Reset zoom"); CONTROL_TO_RESET("Reset zoom");
private String name; private final String name;
@Override @Override
public String toString() public String toString()

View File

@@ -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; package net.runelite.client.plugins.zoom;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
@@ -48,12 +72,11 @@ public interface ZoomConfig extends Config
return false; return false;
} }
@ConfigItem( @ConfigItem(
keyName = "controlFunction", keyName = "controlFunction",
name = "Control Function", name = "Control Function",
description = "Configures the zoom function when control is pressed", description = "Configures the zoom function when control is pressed",
position = 5 position = 4
) )
default ControlFunction controlFunction() default ControlFunction controlFunction()
{ {
@@ -64,18 +87,22 @@ public interface ZoomConfig extends Config
keyName = "ctrlZoomValue", keyName = "ctrlZoomValue",
name = "Reset zoom position", name = "Reset zoom position",
description = "Position of zoom when it is reset", description = "Position of zoom when it is reset",
position = 6 position = 5
)
@Range(
min = OUTER_LIMIT_MIN,
max = OUTER_LIMIT_MAX
) )
default int ctrlZoomValue() default int ctrlZoomValue()
{ {
return 600; return 512;
} }
@ConfigItem( @ConfigItem(
keyName = "zoomIncrement", keyName = "zoomIncrement",
name = "Zoom Speed", name = "Zoom Speed",
description = "Speed of zoom", description = "Speed of zoom",
position = 7 position = 6
) )
default int zoomIncrement() default int zoomIncrement()
{ {

View File

@@ -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. * The largest (most zoomed in) value that can be used without the client crashing.
* <p> *
* Larger values trigger an overflow in the engine's fov to scale code. * 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 INNER_ZOOM_LIMIT = 1004;
private static final int DEFAULT_ZOOM_INCREMENT = 25;
private boolean controlDown; private boolean controlDown;
@@ -92,7 +93,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
int[] intStack = client.getIntStack(); int[] intStack = client.getIntStack();
int intStackSize = client.getIntStackSize(); 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; intStack[intStackSize - 1] = 1;
} }
@@ -111,9 +112,10 @@ public class ZoomPlugin extends Plugin implements KeyListener
return; return;
} }
if ("scrollWheelZoomIncrement".equals(event.getEventName()) && zoomConfig.zoomIncrement() != 25) if ("scrollWheelZoomIncrement".equals(event.getEventName()) && zoomConfig.zoomIncrement() != DEFAULT_ZOOM_INCREMENT)
{ {
intStack[intStackSize - 1] = zoomConfig.zoomIncrement(); intStack[intStackSize - 1] = zoomConfig.zoomIncrement();
return;
} }
if (zoomConfig.innerLimit()) if (zoomConfig.innerLimit())
@@ -201,6 +203,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
if (e.getKeyCode() == KeyEvent.VK_CONTROL) if (e.getKeyCode() == KeyEvent.VK_CONTROL)
{ {
controlDown = false; controlDown = false;
if (zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_RESET) if (zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_RESET)
{ {
final int zoomValue = MiscUtils.clamp(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT); final int zoomValue = MiscUtils.clamp(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT);

View File

@@ -873,7 +873,15 @@ public class ClientUI
} }
frame.setExpandResizeType(config.automaticResizeType()); 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()) if (!config.rememberScreenBounds())
{ {

View File

@@ -32,11 +32,18 @@ import net.runelite.client.config.ExpandResizeType;
public class ContainableFrame extends JFrame public class ContainableFrame extends JFrame
{ {
public enum Mode
{
ALWAYS,
RESIZING,
NEVER;
}
private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40; private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40;
@Setter @Setter
private ExpandResizeType expandResizeType; private ExpandResizeType expandResizeType;
private boolean containedInScreen; private Mode containedInScreen;
private boolean expandedClientOppositeDirection; private boolean expandedClientOppositeDirection;
ContainableFrame() ContainableFrame()
@@ -50,11 +57,11 @@ public class ContainableFrame extends JFrame
}); });
} }
public void setContainedInScreen(boolean value) public void setContainedInScreen(Mode value)
{ {
this.containedInScreen = value; this.containedInScreen = value;
if (value) if (this.containedInScreen == Mode.ALWAYS)
{ {
// Reposition the frame if it is intersecting with the bounds // Reposition the frame if it is intersecting with the bounds
this.setLocation(this.getX(), this.getY()); this.setLocation(this.getX(), this.getY());
@@ -65,7 +72,7 @@ public class ContainableFrame extends JFrame
@Override @Override
public void setLocation(int x, int y) public void setLocation(int x, int y)
{ {
if (containedInScreen) if (this.containedInScreen == Mode.ALWAYS)
{ {
Rectangle bounds = this.getGraphicsConfiguration().getBounds(); Rectangle bounds = this.getGraphicsConfiguration().getBounds();
x = Math.max(x, (int) bounds.getX()); x = Math.max(x, (int) bounds.getX());
@@ -80,8 +87,10 @@ public class ContainableFrame extends JFrame
@Override @Override
public void setBounds(int x, int y, int width, int height) 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(); Rectangle bounds = this.getGraphicsConfiguration().getBounds();
width = Math.min(width, width - (int) bounds.getX() + x); width = Math.min(width, width - (int) bounds.getX() + x);
x = Math.max(x, (int) bounds.getX()); x = Math.max(x, (int) bounds.getX());
@@ -127,7 +136,7 @@ public class ContainableFrame extends JFrame
final int newWindowWidth = getWidth() + increment; final int newWindowWidth = getWidth() + increment;
int newWindowX = getX(); int newWindowX = getX();
if (containedInScreen) if (this.containedInScreen != Mode.NEVER)
{ {
final Rectangle screenBounds = getGraphicsConfiguration().getBounds(); final Rectangle screenBounds = getGraphicsConfiguration().getBounds();
final boolean wouldExpandThroughEdge = getX() + newWindowWidth > screenBounds.getX() + screenBounds.getWidth(); final boolean wouldExpandThroughEdge = getX() + newWindowWidth > screenBounds.getX() + screenBounds.getWidth();

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2019, Ron Young <https://github.com/raiyni>
* 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;
}
}

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2019, Ron Young <https://github.com/raiyni>
* 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<String> 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<Color> 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<Color> 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;
}
}

View File

@@ -39,6 +39,9 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; 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 java.util.function.Consumer;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
@@ -53,12 +56,15 @@ import javax.swing.text.Document;
import javax.swing.text.DocumentFilter; import javax.swing.text.DocumentFilter;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ColorUtil;
import org.pushingpixels.substance.internal.SubstanceSynapse; import org.pushingpixels.substance.internal.SubstanceSynapse;
public class RuneliteColorPicker extends JDialog public class RuneliteColorPicker extends JDialog
{ {
static final String CONFIG_GROUP = "colorpicker";
private final static int FRAME_WIDTH = 400; private final static int FRAME_WIDTH = 400;
private final static int FRAME_HEIGHT = 380; private final static int FRAME_HEIGHT = 380;
private final static int TONE_PANEL_SIZE = 160; private final static int TONE_PANEL_SIZE = 160;
@@ -84,16 +90,24 @@ public class RuneliteColorPicker extends JDialog
@Setter @Setter
private Consumer<Color> onColorChange; private Consumer<Color> onColorChange;
public RuneliteColorPicker(Window parent, Color previousColor, String title, boolean alphaHidden) @Setter
private Consumer<Color> onClose;
RuneliteColorPicker(Window parent, Color previousColor, String title, boolean alphaHidden,
final ConfigManager configManager, final ColorPickerManager colorPickerManager)
{ {
super(parent, "RuneLite Color Picker - " + title, ModalityType.MODELESS); super(parent, "RuneLite Color Picker - " + title, ModalityType.MODELESS);
this.selectedColor = previousColor; this.selectedColor = previousColor;
this.alphaHidden = alphaHidden;
RecentColors recentColors = new RecentColors(configManager);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setResizable(false); setResizable(false);
setSize(FRAME_WIDTH, FRAME_HEIGHT); setSize(FRAME_WIDTH, FRAME_HEIGHT);
setBackground(ColorScheme.PROGRESS_COMPLETE_COLOR); setBackground(ColorScheme.PROGRESS_COMPLETE_COLOR);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
JPanel content = new JPanel(new BorderLayout()); JPanel content = new JPanel(new BorderLayout());
content.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0); content.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0);
@@ -109,7 +123,6 @@ public class RuneliteColorPicker extends JDialog
rightPanel.setLayout(new GridBagLayout()); rightPanel.setLayout(new GridBagLayout());
GridBagConstraints cx = new GridBagConstraints(); GridBagConstraints cx = new GridBagConstraints();
cx.insets = new Insets(0, 0, 0, 0); cx.insets = new Insets(0, 0, 0, 0);
JLabel old = new JLabel("Previous"); JLabel old = new JLabel("Previous");
old.setHorizontalAlignment(JLabel.CENTER); old.setHorizontalAlignment(JLabel.CENTER);
@@ -140,11 +153,26 @@ public class RuneliteColorPicker extends JDialog
hexContainer.add(hexInput, cx); hexContainer.add(hexInput, cx);
cx.fill = GridBagConstraints.BOTH; cx.fill = GridBagConstraints.BOTH;
cx.gridwidth = GridBagConstraints.RELATIVE;
cx.weightx = 1; cx.weightx = 1;
cx.weighty = 1; cx.weighty = 1;
cx.gridy = 0; cx.gridy = 0;
cx.gridx = 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); rightPanel.add(old, cx);
cx.gridx++; cx.gridx++;
@@ -176,7 +204,6 @@ public class RuneliteColorPicker extends JDialog
slidersContainer.add(blueSlider); slidersContainer.add(blueSlider);
slidersContainer.add(alphaSlider); slidersContainer.add(alphaSlider);
this.alphaHidden = alphaHidden;
if (alphaHidden) if (alphaHidden)
{ {
alphaSlider.setVisible(false); alphaSlider.setVisible(false);
@@ -265,6 +292,29 @@ public class RuneliteColorPicker extends JDialog
updatePanels(); updatePanels();
updateText(); 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() private void updatePanels()

View File

@@ -29,9 +29,9 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
@@ -53,7 +53,7 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
private String text; private String text;
private Color color = Color.WHITE; private Color color = Color.WHITE;
private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR; private Color backgroundColor = ComponentConstants.STANDARD_BACKGROUND_COLOR;
private Image image; private BufferedImage image;
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)

View File

@@ -25,7 +25,7 @@
package net.runelite.client.ui.overlay.infobox; package net.runelite.client.ui.overlay.infobox;
import java.awt.Color; import java.awt.Color;
import java.awt.Image; import java.awt.image.BufferedImage;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -38,11 +38,11 @@ public abstract class InfoBox
@Getter @Getter
@Setter @Setter
private Image image; private BufferedImage image;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
private Image scaledImage; private BufferedImage scaledImage;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@Setter @Setter
@@ -52,7 +52,7 @@ public abstract class InfoBox
@Setter @Setter
private String tooltip; private String tooltip;
public InfoBox(Image image, Plugin plugin) public InfoBox(BufferedImage image, Plugin plugin)
{ {
this.plugin = plugin; this.plugin = plugin;
setImage(image); setImage(image);

View File

@@ -27,7 +27,6 @@ package net.runelite.client.ui.overlay.infobox;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -40,6 +39,7 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.AsyncBufferedImage;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@Singleton @Singleton
@@ -73,6 +73,14 @@ public class InfoBoxManager
updateInfoBoxImage(infoBox); updateInfoBoxImage(infoBox);
infoBoxes.add(infoBox); infoBoxes.add(infoBox);
refreshInfoBoxes(); refreshInfoBoxes();
BufferedImage image = infoBox.getImage();
if (image instanceof AsyncBufferedImage)
{
AsyncBufferedImage abi = (AsyncBufferedImage) image;
abi.onChanged(() -> updateInfoBoxImage(infoBox));
}
} }
public void removeInfoBox(InfoBox 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) if (infoBox.getImage() == null)
{ {
@@ -127,8 +135,8 @@ public class InfoBoxManager
} }
// Set scaled InfoBox image // Set scaled InfoBox image
final Image image = infoBox.getImage(); final BufferedImage image = infoBox.getImage();
Image resultImage = image; BufferedImage resultImage = image;
final double width = image.getWidth(null); final double width = image.getWidth(null);
final double height = image.getHeight(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 final double size = Math.max(2, runeLiteConfig.infoBoxSize()); // Limit size to 2 as that is minimum size not causing breakage

View File

@@ -3088,6 +3088,7 @@
"19627": 10000, "19627": 10000,
"19629": 10000, "19629": 10000,
"19631": 10000, "19631": 10000,
"19653": 100,
"19656": 13000, "19656": 13000,
"19662": 10000, "19662": 10000,
"19665": 13000, "19665": 13000,

View File

@@ -11,9 +11,9 @@
iconst 0 iconst 0
iload 0 iload 0
iconst 25 iconst 25
sconst "scrollWheelZoomIncrement" sconst "scrollWheelZoomIncrement"
runelite_callback runelite_callback
multiply multiply
sub sub
istore 1 istore 1
iconst 512 iconst 512

View File

@@ -34,8 +34,10 @@ import net.runelite.api.ChatMessageType;
import static net.runelite.api.ChatMessageType.GAMEMESSAGE; import static net.runelite.api.ChatMessageType.GAMEMESSAGE;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.MessageNode; import net.runelite.api.MessageNode;
import net.runelite.api.Skill;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ExperienceChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
@@ -362,6 +364,9 @@ public class SlayerPluginTest
slayerPlugin.getCurrentTask().setTaskName("cows"); slayerPlugin.getCurrentTask().setTaskName("cows");
slayerPlugin.getCurrentTask().setAmount(42); slayerPlugin.getCurrentTask().setAmount(42);
final ExperienceChanged experienceChanged = new ExperienceChanged();
experienceChanged.setSkill(Skill.SLAYER);
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE, null, 0); ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent); slayerPlugin.onChatMessage(chatMessageEvent);