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

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

View File

@@ -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.<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
)
default boolean containInScreen()
default ContainableFrame.Mode containInScreen()
{
return false;
return ContainableFrame.Mode.RESIZING;
}
@ConfigItem(

View File

@@ -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<Long, BufferedImage> cache = CacheBuilder.newBuilder()
@Inject
private InfoBoxManager infoBoxManager;
public Cache<Long, BufferedImage> 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
*/

View File

@@ -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()
{

View File

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

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

View File

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

View File

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

View File

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

View File

@@ -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)
{

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_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

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;
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<String, FreezeInfo> 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)

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

View File

@@ -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)

View File

@@ -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)

View File

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

View File

@@ -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<Integer, Rock> ROCKS;

View File

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

View File

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

View File

@@ -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)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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.
*
* 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()

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;
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()
{

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.
* <p>
*
* 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);

View File

@@ -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())
{

View File

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

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.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<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);
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()

View File

@@ -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)

View File

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

View File

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

View File

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

View File

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

View File

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