Merge pull request #2313 from Owain94/merge-0602

project: Merge upstream
This commit is contained in:
Owain van Brakel
2020-02-06 16:25:31 +01:00
committed by GitHub
72 changed files with 844 additions and 362 deletions

View File

@@ -31,17 +31,17 @@ public class SequenceDefinition
{ {
private final int id; private final int id;
public int[] frameIDs; // top 16 bits are FrameDefinition ids public int[] frameIDs; // top 16 bits are FrameDefinition ids
public int[] field3048; public int[] chatFrameIds;
public int[] frameLenghts; public int[] frameLenghts;
public int rightHandItem = -1; public int[] frameSounds;
public int frameStep = -1;
public int[] interleaveLeave; public int[] interleaveLeave;
public boolean stretches = false; public boolean stretches = false;
public int forcedPriority = 5; public int forcedPriority = 5;
public int maxLoops = 99;
public int[] field3056;
public int precedenceAnimating = -1;
public int leftHandItem = -1; public int leftHandItem = -1;
public int replyMode = 2; public int rightHandItem = -1;
public int frameStep = -1; public int maxLoops = 99;
public int precedenceAnimating = -1;
public int priority = -1; public int priority = -1;
public int replyMode = 2;
} }

View File

@@ -26,13 +26,9 @@ package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.SequenceDefinition; import net.runelite.cache.definitions.SequenceDefinition;
import net.runelite.cache.io.InputStream; import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SequenceLoader public class SequenceLoader
{ {
private static final Logger logger = LoggerFactory.getLogger(SequenceLoader.class);
public SequenceDefinition load(int id, byte[] b) public SequenceDefinition load(int id, byte[] b)
{ {
SequenceDefinition def = new SequenceDefinition(id); SequenceDefinition def = new SequenceDefinition(id);
@@ -129,26 +125,26 @@ public class SequenceLoader
else if (opcode == 12) else if (opcode == 12)
{ {
var3 = stream.readUnsignedByte(); var3 = stream.readUnsignedByte();
def.field3048 = new int[var3]; def.chatFrameIds = new int[var3];
for (var4 = 0; var4 < var3; ++var4) for (var4 = 0; var4 < var3; ++var4)
{ {
def.field3048[var4] = stream.readUnsignedShort(); def.chatFrameIds[var4] = stream.readUnsignedShort();
} }
for (var4 = 0; var4 < var3; ++var4) for (var4 = 0; var4 < var3; ++var4)
{ {
def.field3048[var4] += stream.readUnsignedShort() << 16; def.chatFrameIds[var4] += stream.readUnsignedShort() << 16;
} }
} }
else if (opcode == 13) else if (opcode == 13)
{ {
var3 = stream.readUnsignedByte(); var3 = stream.readUnsignedByte();
def.field3056 = new int[var3]; def.frameSounds = new int[var3];
for (var4 = 0; var4 < var3; ++var4) for (var4 = 0; var4 < var3; ++var4)
{ {
def.field3056[var4] = stream.read24BitInt(); def.frameSounds[var4] = stream.read24BitInt();
} }
} }

View File

@@ -1180,8 +1180,9 @@ public class WidgetID
static class Lms static class Lms
{ {
static final int INFO = 2; static final int INFO = 3;
} }
static class LmsKDA static class LmsKDA
{ {
static final int INFO = 4; static final int INFO = 4;
@@ -1213,4 +1214,4 @@ public class WidgetID
{ {
static final int CONTAINER = 0; static final int CONTAINER = 0;
} }
} }

View File

@@ -45,6 +45,7 @@ public class RuneLiteProperties
private static final String TROUBLESHOOTING_LINK = "runelite.wiki.troubleshooting.link"; private static final String TROUBLESHOOTING_LINK = "runelite.wiki.troubleshooting.link";
private static final String BUILDING_LINK = "runelite.wiki.building.link"; private static final String BUILDING_LINK = "runelite.wiki.building.link";
private static final String DNS_CHANGE_LINK = "runelite.dnschange.link"; private static final String DNS_CHANGE_LINK = "runelite.dnschange.link";
private static final String IMGUR_CLIENT_ID = "runelite.imgur.client.id";
private static final Properties properties = new Properties(); private static final Properties properties = new Properties();
@@ -137,4 +138,9 @@ public class RuneLiteProperties
String launcherVersion = properties.getProperty(LAUNCHER_VERSION_PROPERTY); String launcherVersion = properties.getProperty(LAUNCHER_VERSION_PROPERTY);
return launcherVersion.equals("-1") ? null : launcherVersion; return launcherVersion.equals("-1") ? null : launcherVersion;
} }
public static String getImgurClientId()
{
return properties.getProperty(IMGUR_CLIENT_ID);
}
} }

View File

@@ -33,4 +33,5 @@ public class ConfigItemDescriptor
private final Class<?> type; private final Class<?> type;
private final Range range; private final Range range;
private final Alpha alpha; private final Alpha alpha;
private final Units units;
} }

View File

@@ -350,7 +350,8 @@ public class ConfigManager
m.getDeclaredAnnotation(ConfigItem.class), m.getDeclaredAnnotation(ConfigItem.class),
m.getReturnType(), m.getReturnType(),
m.getDeclaredAnnotation(Range.class), m.getDeclaredAnnotation(Range.class),
m.getDeclaredAnnotation(Alpha.class) m.getDeclaredAnnotation(Alpha.class),
m.getDeclaredAnnotation(Units.class)
)) ))
.sorted((a, b) -> ComparisonChain.start() .sorted((a, b) -> ComparisonChain.start()
.compare(a.getItem().position(), b.getItem().position()) .compare(a.getItem().position(), b.getItem().position())

View File

@@ -325,6 +325,7 @@ public interface OpenOSRSConfig extends Config
position = 19, position = 19,
titleSection = "opacityTitle" titleSection = "opacityTitle"
) )
@Units(Units.PERCENT)
default int opacityPercentage() default int opacityPercentage()
{ {
return 100; return 100;

View File

@@ -52,6 +52,7 @@ public interface RuneLiteConfig extends Config
position = 2, position = 2,
titleSection = "uiTitle" titleSection = "uiTitle"
) )
@Units(Units.PIXELS)
default Dimension gameSize() default Dimension gameSize()
{ {
return Constants.GAME_FIXED_SIZE; return Constants.GAME_FIXED_SIZE;
@@ -174,6 +175,7 @@ public interface RuneLiteConfig extends Config
position = 12, position = 12,
titleSection = "miscTitle" titleSection = "miscTitle"
) )
@Units(Units.PERCENT)
default int volume() default int volume()
{ {
return 100; return 100;
@@ -332,6 +334,17 @@ public interface RuneLiteConfig extends Config
return true; return true;
} }
@ConfigItem(
keyName = "tooltipPosition",
name = "Tooltip Position",
description = "Configures whether to show the tooltip above or under the cursor",
position = 35
)
default TooltipPositionType tooltipPosition()
{
return TooltipPositionType.UNDER_CURSOR;
}
@ConfigItem( @ConfigItem(
keyName = "infoBoxVertical", keyName = "infoBoxVertical",
name = "Display infoboxes vertically", name = "Display infoboxes vertically",
@@ -358,11 +371,12 @@ public interface RuneLiteConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "infoBoxSize", keyName = "infoBoxSize",
name = "Infobox size (px)", name = "Infobox size",
description = "Configures the size of each infobox in pixels", description = "Configures the size of each infobox in pixels",
position = 28, position = 28,
titleSection = "infoboxTitle" titleSection = "infoboxTitle"
) )
@Units(Units.PIXELS)
default int infoBoxSize() default int infoBoxSize()
{ {
return 35; return 35;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, Alexsuperfly <https://github.com/Alexsuperfly> * Copyright (c) 2020, Crypthead <https://github.com/Crypthead>
* 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
@@ -22,23 +22,23 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.client.config;
package net.runelite.client.plugins.screenshot;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Getter;
@Getter
@RequiredArgsConstructor @RequiredArgsConstructor
public enum UploadStyle public enum TooltipPositionType
{ {
NEITHER("Neither"), ABOVE_CURSOR("Above cursor"),
IMGUR("Imgur"), UNDER_CURSOR("Under cursor");
CLIPBOARD("Clipboard");
private final String name; private final String type;
@Override @Override
public String toString() public String toString()
{ {
return name; return type;
} }
} }

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2020, Hydrox6 <ikada@protonmail.ch>
* 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.config;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used with ConfigItem, defines what units are shown to the side of the box.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface Units
{
String MILLISECONDS = "ms";
String MINUTES = " mins";
String PERCENT = "%";
String PIXELS = "px";
String POINTS = "pt";
String SECONDS = "s";
String TICKS = " ticks";
String LEVELS = " lvls";
String FPS = " fps";
String GP = " GP";
String value();
}

View File

@@ -87,4 +87,8 @@ public abstract class Plugin implements Module
{ {
subs.forEach(s -> s.subscribe(eventBus, this)); subs.forEach(s -> s.subscribe(eventBus, this));
} }
public void resetConfiguration()
{
}
} }

View File

@@ -30,6 +30,7 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("agility") @ConfigGroup("agility")
public interface AgilityConfig extends Config public interface AgilityConfig extends Config
@@ -91,6 +92,7 @@ public interface AgilityConfig extends Config
hidden = true, hidden = true,
unhide = "showLapCount" unhide = "showLapCount"
) )
@Units(Units.MINUTES)
default int lapTimeout() default int lapTimeout()
{ {
return 5; return 5;

View File

@@ -37,6 +37,7 @@ import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("aoe") @ConfigGroup("aoe")
public interface AoeWarningConfig extends Config public interface AoeWarningConfig extends Config
@@ -124,6 +125,7 @@ public interface AoeWarningConfig extends Config
titleSection = "overlayTitle", titleSection = "overlayTitle",
position = 4 position = 4
) )
@Units(Units.MILLISECONDS)
default int delay() default int delay()
{ {
return 300; return 300;

View File

@@ -30,6 +30,7 @@ package net.runelite.client.plugins.banktags;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.HashMultiset; import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset; import com.google.common.collect.Multiset;
import com.google.common.collect.Lists;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
@@ -100,6 +101,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
public static final String CONFIG_GROUP = "banktags"; public static final String CONFIG_GROUP = "banktags";
public static final String TAG_SEARCH = "tag:"; public static final String TAG_SEARCH = "tag:";
public static final String ICON_SEARCH = "icon_"; public static final String ICON_SEARCH = "icon_";
public static final String TAG_TABS_CONFIG = "tagtabs";
public static final String VAR_TAG_SUFFIX = "*"; public static final String VAR_TAG_SUFFIX = "*";
private static final String EDIT_TAGS_MENU_OPTION = "Edit-tags"; private static final String EDIT_TAGS_MENU_OPTION = "Edit-tags";
private static final String NUMBER_REGEX = "[0-9]+(\\.[0-9]+)?[kmb]?"; private static final String NUMBER_REGEX = "[0-9]+(\\.[0-9]+)?[kmb]?";
@@ -162,6 +164,36 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
return configManager.getConfig(BankTagsConfig.class); return configManager.getConfig(BankTagsConfig.class);
} }
@Override
public void resetConfiguration()
{
List<String> extraKeys = Lists.newArrayList(
CONFIG_GROUP + "." + TagManager.ITEM_KEY_PREFIX,
CONFIG_GROUP + "." + ICON_SEARCH,
CONFIG_GROUP + "." + TAG_TABS_CONFIG
);
for (String prefix : extraKeys)
{
List<String> keys = configManager.getConfigurationKeys(prefix);
for (String key : keys)
{
String[] str = key.split("\\.", 2);
if (str.length == 2)
{
configManager.unsetConfiguration(str[0], str[1]);
}
}
}
clientThread.invokeLater(() ->
{
tabInterface.destroy();
tabInterface.init();
});
}
@Override @Override
public void startUp() public void startUp()
{ {
@@ -481,7 +513,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
@Subscribe @Subscribe
private void onConfigChanged(ConfigChanged configChanged) private void onConfigChanged(ConfigChanged configChanged)
{ {
if (configChanged.getGroup().equals("banktags") && configChanged.getKey().equals("useTabs")) if (configChanged.getGroup().equals(CONFIG_GROUP) && configChanged.getKey().equals("useTabs"))
{ {
if (config.tabs()) if (config.tabs())
{ {

View File

@@ -50,7 +50,7 @@ import net.runelite.client.plugins.cluescrolls.clues.item.ItemRequirement;
@Singleton @Singleton
public class TagManager public class TagManager
{ {
private static final String ITEM_KEY_PREFIX = "item_"; static final String ITEM_KEY_PREFIX = "item_";
private final ConfigManager configManager; private final ConfigManager configManager;
private final ItemManager itemManager; private final ItemManager itemManager;
private final ClueScrollService clueScrollService; private final ClueScrollService clueScrollService;

View File

@@ -40,13 +40,12 @@ import net.runelite.api.util.Text;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import static net.runelite.client.plugins.banktags.BankTagsPlugin.CONFIG_GROUP; import static net.runelite.client.plugins.banktags.BankTagsPlugin.CONFIG_GROUP;
import static net.runelite.client.plugins.banktags.BankTagsPlugin.ICON_SEARCH; import static net.runelite.client.plugins.banktags.BankTagsPlugin.ICON_SEARCH;
import static net.runelite.client.plugins.banktags.BankTagsPlugin.TAG_TABS_CONFIG;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
@Singleton @Singleton
class TabManager class TabManager
{ {
private static final String TAG_TABS_CONFIG = "tagtabs";
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final List<TagTab> tabs = new ArrayList<>(); private final List<TagTab> tabs = new ArrayList<>();
private final ConfigManager configManager; private final ConfigManager configManager;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.boosts;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("boosts") @ConfigGroup("boosts")
public interface BoostsConfig extends Config public interface BoostsConfig extends Config
@@ -129,6 +130,7 @@ public interface BoostsConfig extends Config
description = "The amount of levels boosted to send a notification at. A value of 0 will disable notification.", description = "The amount of levels boosted to send a notification at. A value of 0 will disable notification.",
position = 8 position = 8
) )
@Units(Units.LEVELS)
default int boostThreshold() default int boostThreshold()
{ {
return 0; return 0;

View File

@@ -4,6 +4,7 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("clanmanmode") @ConfigGroup("clanmanmode")
public interface ClanManModeConfig extends Config public interface ClanManModeConfig extends Config
@@ -135,6 +136,7 @@ public interface ClanManModeConfig extends Config
name = "Ticks to hide", name = "Ticks to hide",
description = "How many ticks after you are logged in that attackbles are hidden (1 tick = 0.6 seconds)" description = "How many ticks after you are logged in that attackbles are hidden (1 tick = 0.6 seconds)"
) )
@Units(Units.TICKS)
default int hideTime() default int hideTime()
{ {
return 5; return 5;

View File

@@ -41,6 +41,7 @@ import java.awt.event.MouseEvent;
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;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
@@ -88,6 +89,7 @@ import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Keybind; import net.runelite.client.config.Keybind;
import net.runelite.client.config.ModifierlessKeybind; import net.runelite.client.config.ModifierlessKeybind;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.PluginChanged; import net.runelite.client.events.PluginChanged;
import net.runelite.client.plugins.PluginManager; import net.runelite.client.plugins.PluginManager;
@@ -543,6 +545,7 @@ class ConfigPanel extends PluginPanel
{ {
int value = Integer.parseInt(configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName())); int value = Integer.parseInt(configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName()));
Units units = cid.getUnits();
Range range = cid.getRange(); Range range = cid.getRange();
int min = 0, max = Integer.MAX_VALUE; int min = 0, max = Integer.MAX_VALUE;
if (range != null) if (range != null)
@@ -558,12 +561,27 @@ class ConfigPanel extends PluginPanel
{ {
JLabel sliderValueLabel = new JLabel(); JLabel sliderValueLabel = new JLabel();
JSlider slider = new JSlider(min, max, value); JSlider slider = new JSlider(min, max, value);
sliderValueLabel.setText(String.valueOf(slider.getValue())); if (units != null)
{
sliderValueLabel.setText(slider.getValue() + " " + units.value());
}
else
{
sliderValueLabel.setText(String.valueOf(slider.getValue()));
}
slider.setPreferredSize(new Dimension(80, 25)); slider.setPreferredSize(new Dimension(80, 25));
slider.setBackground(Color.WHITE); slider.setBackground(Color.WHITE);
slider.addChangeListener((l) -> slider.addChangeListener((l) ->
{ {
sliderValueLabel.setText(String.valueOf(slider.getValue())); if (units != null)
{
sliderValueLabel.setText(slider.getValue() + " " + units.value());
}
else
{
sliderValueLabel.setText(String.valueOf(slider.getValue()));
}
if (!slider.getValueIsAdjusting()) if (!slider.getValueIsAdjusting())
{ {
changeConfiguration(slider, cd, cid); changeConfiguration(slider, cd, cid);
@@ -597,7 +615,14 @@ class ConfigPanel extends PluginPanel
{ {
changeConfiguration(spinner, cd, cid); changeConfiguration(spinner, cd, cid);
sliderValueLabel.setText(String.valueOf(spinner.getValue())); if (units != null)
{
sliderValueLabel.setText(spinner.getValue() + " " + units.value());
}
else
{
sliderValueLabel.setText(String.valueOf(spinner.getValue()));
}
slider.setValue((Integer) spinner.getValue()); slider.setValue((Integer) spinner.getValue());
subPanel.add(sliderValueLabel, BorderLayout.WEST); subPanel.add(sliderValueLabel, BorderLayout.WEST);
@@ -641,6 +666,15 @@ class ConfigPanel extends PluginPanel
spinnerTextField.setColumns(SPINNER_FIELD_WIDTH); spinnerTextField.setColumns(SPINNER_FIELD_WIDTH);
spinner.addChangeListener(ce -> changeConfiguration(spinner, cd, cid)); spinner.addChangeListener(ce -> changeConfiguration(spinner, cd, cid));
if (units != null)
{
DecimalFormat df = ((JSpinner.NumberEditor) spinner.getEditor()).getFormat();
df.setPositiveSuffix(units.value());
df.setNegativeSuffix(units.value());
// Force update the spinner to have it add the units initially
spinnerTextField.setValue(value);
}
item.add(spinner, BorderLayout.EAST); item.add(spinner, BorderLayout.EAST);
} }
} }
@@ -760,6 +794,7 @@ class ConfigPanel extends PluginPanel
JPanel dimensionPanel = new JPanel(); JPanel dimensionPanel = new JPanel();
dimensionPanel.setLayout(new BorderLayout()); dimensionPanel.setLayout(new BorderLayout());
Units units = cid.getUnits();
String str = configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName()); String str = configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName());
String[] splitStr = str.split("x"); String[] splitStr = str.split("x");
int width = Integer.parseInt(splitStr[0]); int width = Integer.parseInt(splitStr[0]);
@@ -771,12 +806,30 @@ class ConfigPanel extends PluginPanel
JFormattedTextField widthSpinnerTextField = ((JSpinner.DefaultEditor) widthEditor).getTextField(); JFormattedTextField widthSpinnerTextField = ((JSpinner.DefaultEditor) widthEditor).getTextField();
widthSpinnerTextField.setColumns(4); widthSpinnerTextField.setColumns(4);
if (units != null)
{
DecimalFormat df = ((JSpinner.NumberEditor) widthSpinner.getEditor()).getFormat();
df.setPositiveSuffix(units.value());
df.setNegativeSuffix(units.value());
// Force update the spinner to have it add the units initially
widthSpinnerTextField.setValue(width);
}
SpinnerModel heightModel = new SpinnerNumberModel(height, 0, Integer.MAX_VALUE, 1); SpinnerModel heightModel = new SpinnerNumberModel(height, 0, Integer.MAX_VALUE, 1);
JSpinner heightSpinner = new JSpinner(heightModel); JSpinner heightSpinner = new JSpinner(heightModel);
Component heightEditor = heightSpinner.getEditor(); Component heightEditor = heightSpinner.getEditor();
JFormattedTextField heightSpinnerTextField = ((JSpinner.DefaultEditor) heightEditor).getTextField(); JFormattedTextField heightSpinnerTextField = ((JSpinner.DefaultEditor) heightEditor).getTextField();
heightSpinnerTextField.setColumns(4); heightSpinnerTextField.setColumns(4);
if (units != null)
{
DecimalFormat df = ((JSpinner.NumberEditor) heightSpinner.getEditor()).getFormat();
df.setPositiveSuffix(units.value());
df.setNegativeSuffix(units.value());
// Force update the spinner to have it add the units initially
heightSpinnerTextField.setValue(height);
}
ChangeListener listener = e -> ChangeListener listener = e ->
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), widthSpinner.getValue() + "x" + heightSpinner.getValue()); configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), widthSpinner.getValue() + "x" + heightSpinner.getValue());

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.cooking;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("cooking") @ConfigGroup("cooking")
public interface CookingConfig extends Config public interface CookingConfig extends Config
@@ -35,9 +36,10 @@ public interface CookingConfig extends Config
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "statTimeout", keyName = "statTimeout",
name = "Reset stats (minutes)", name = "Reset stats",
description = "Configures the time until the session resets and the overlay is hidden (0 = Disable feature)" description = "Configures the time until the session resets and the overlay is hidden (0 = Disable feature)"
) )
@Units(Units.MINUTES)
default int statTimeout() default int statTimeout()
{ {
return 5; return 5;

View File

@@ -35,6 +35,7 @@ import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("Cox") @ConfigGroup("Cox")
@@ -220,6 +221,7 @@ public interface CoxConfig extends Config
description = "Change the Size of the Olm Infobox.", description = "Change the Size of the Olm Infobox.",
titleSection = "olmTitle" titleSection = "olmTitle"
) )
@Units(Units.PIXELS)
default int prayAgainstOlmSize() default int prayAgainstOlmSize()
{ {
return 40; return 40;
@@ -390,6 +392,7 @@ public interface CoxConfig extends Config
description = "Text Size for Timers.", description = "Text Size for Timers.",
titleSection = "text" titleSection = "text"
) )
@Units(Units.POINTS)
default int textSize() default int textSize()
{ {
return 14; return 14;

View File

@@ -27,16 +27,18 @@ package net.runelite.client.plugins.discord;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("discord") @ConfigGroup("discord")
public interface DiscordConfig extends Config public interface DiscordConfig extends Config
{ {
@ConfigItem( @ConfigItem(
keyName = "actionTimeout", keyName = "actionTimeout",
name = "Action timeout (minutes)", name = "Action timeout",
description = "Configures after how long of not updating status will be reset (in minutes)", description = "Configures after how long of not updating status will be reset (in minutes)",
position = 0 position = 0
) )
@Units(Units.MINUTES)
default int actionTimeout() default int actionTimeout()
{ {
return 5; return 5;

View File

@@ -8,6 +8,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("drop") @ConfigGroup("drop")
public interface DropPartyConfig extends Config public interface DropPartyConfig extends Config
@@ -70,6 +71,7 @@ public interface DropPartyConfig extends Config
name = "Text Size", name = "Text Size",
description = "Text Size for Timers." description = "Text Size for Timers."
) )
@Units(Units.POINTS)
default int textSize() default int textSize()
{ {
return 18; return 18;

View File

@@ -28,6 +28,7 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("xpdrop") @ConfigGroup("xpdrop")
public interface XpDropConfig extends Config public interface XpDropConfig extends Config
@@ -89,6 +90,7 @@ public interface XpDropConfig extends Config
description = "Configures how many ticks should pass between fake XP drops, 0 to disable", description = "Configures how many ticks should pass between fake XP drops, 0 to disable",
position = 4 position = 4
) )
@Units(Units.TICKS)
default int fakeXpDropDelay() default int fakeXpDropDelay()
{ {
return 0; return 0;

View File

@@ -33,6 +33,7 @@ import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("fightcave") @ConfigGroup("fightcave")
public interface FightCaveConfig extends Config public interface FightCaveConfig extends Config
@@ -106,6 +107,7 @@ public interface FightCaveConfig extends Config
description = "Text Size for Timers.", description = "Text Size for Timers.",
titleSection = "text" titleSection = "text"
) )
@Units(Units.POINTS)
default int textSize() default int textSize()
{ {
return 32; return 32;

View File

@@ -28,6 +28,7 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("fishing") @ConfigGroup("fishing")
public interface FishingConfig extends Config public interface FishingConfig extends Config
@@ -112,9 +113,10 @@ public interface FishingConfig extends Config
@ConfigItem( @ConfigItem(
position = 7, position = 7,
keyName = "statTimeout", keyName = "statTimeout",
name = "Reset stats (minutes)", name = "Reset stats",
description = "The time until fishing session data is reset in minutes." description = "The time until fishing session data is reset in minutes."
) )
@Units(Units.MINUTES)
default int statTimeout() default int statTimeout()
{ {
return 5; return 5;

View File

@@ -28,6 +28,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup(FpsPlugin.CONFIG_GROUP_KEY) @ConfigGroup(FpsPlugin.CONFIG_GROUP_KEY)
public interface FpsConfig extends Config public interface FpsConfig extends Config
@@ -54,6 +55,7 @@ public interface FpsConfig extends Config
description = "Desired max global frames per second", description = "Desired max global frames per second",
position = 2 position = 2
) )
@Units(Units.FPS)
default int maxFps() default int maxFps()
{ {
return 50; return 50;
@@ -80,6 +82,7 @@ public interface FpsConfig extends Config
description = "Desired max frames per second for unfocused", description = "Desired max frames per second for unfocused",
position = 4 position = 4
) )
@Units(Units.FPS)
default int maxFpsUnfocused() default int maxFpsUnfocused()
{ {
return 50; return 50;

View File

@@ -30,6 +30,7 @@ import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("freezetimers") @ConfigGroup("freezetimers")
public interface FreezeTimersConfig extends Config public interface FreezeTimersConfig extends Config
@@ -123,6 +124,7 @@ public interface FreezeTimersConfig extends Config
position = 8, position = 8,
titleSection = "overlayTitle" titleSection = "overlayTitle"
) )
@Units(Units.PIXELS)
default int offset() default int offset()
{ {
return 20; return 20;
@@ -163,6 +165,7 @@ public interface FreezeTimersConfig extends Config
position = 11, position = 11,
titleSection = "overlayTitle" titleSection = "overlayTitle"
) )
@Units(Units.POINTS)
default int textSize() default int textSize()
{ {
return 11; return 11;

View File

@@ -35,6 +35,7 @@ import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("Gauntlet") @ConfigGroup("Gauntlet")
@@ -282,6 +283,7 @@ public interface GauntletConfig extends Config
description = " change the size of Projectile icons.", description = " change the size of Projectile icons.",
titleSection = "boss" titleSection = "boss"
) )
@Units(Units.PIXELS)
default int projectileIconSize() default int projectileIconSize()
{ {
return 20; return 20;

View File

@@ -32,6 +32,7 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
import net.runelite.client.plugins.grounditems.config.ItemHighlightMode; import net.runelite.client.plugins.grounditems.config.ItemHighlightMode;
import net.runelite.client.plugins.grounditems.config.MenuHighlightMode; import net.runelite.client.plugins.grounditems.config.MenuHighlightMode;
import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; import net.runelite.client.plugins.grounditems.config.PriceDisplayMode;
@@ -152,6 +153,7 @@ public interface GroundItemsConfig extends Config
position = 9, position = 9,
titleSection = "highlightedTitle" titleSection = "highlightedTitle"
) )
@Units(Units.GP)
default int getHighlightOverValue() default int getHighlightOverValue()
{ {
return 0; return 0;
@@ -231,6 +233,7 @@ public interface GroundItemsConfig extends Config
position = 15, position = 15,
titleSection = "hiddenTitle" titleSection = "hiddenTitle"
) )
@Units(Units.GP)
default int getHideUnderValue() default int getHideUnderValue()
{ {
return 0; return 0;
@@ -338,6 +341,7 @@ public interface GroundItemsConfig extends Config
position = 24, position = 24,
titleSection = "lowValueTitle" titleSection = "lowValueTitle"
) )
@Units(Units.GP)
default int lowValuePrice() default int lowValuePrice()
{ {
return 20000; return 20000;
@@ -386,6 +390,7 @@ public interface GroundItemsConfig extends Config
position = 28, position = 28,
titleSection = "mediumValueTitle" titleSection = "mediumValueTitle"
) )
@Units(Units.GP)
default int mediumValuePrice() default int mediumValuePrice()
{ {
return 100000; return 100000;
@@ -434,6 +439,7 @@ public interface GroundItemsConfig extends Config
position = 32, position = 32,
titleSection = "highValueTitle" titleSection = "highValueTitle"
) )
@Units(Units.GP)
default int highValuePrice() default int highValuePrice()
{ {
return 1000000; return 1000000;
@@ -482,6 +488,7 @@ public interface GroundItemsConfig extends Config
position = 36, position = 36,
titleSection = "insaneValueTitle" titleSection = "insaneValueTitle"
) )
@Units(Units.GP)
default int insaneValuePrice() default int insaneValuePrice()
{ {
return 10000000; return 10000000;
@@ -600,6 +607,7 @@ public interface GroundItemsConfig extends Config
position = 46, position = 46,
titleSection = "miscTitle" titleSection = "miscTitle"
) )
@Units(Units.MILLISECONDS)
default int doubleTapDelay() default int doubleTapDelay()
{ {
return 250; return 250;

View File

@@ -33,6 +33,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("groundMarker") @ConfigGroup("groundMarker")
public interface GroundMarkerConfig extends Config public interface GroundMarkerConfig extends Config
@@ -279,6 +280,7 @@ public interface GroundMarkerConfig extends Config
name = "Minimap opacity", name = "Minimap opacity",
description = "The opacity of the minimap markers" description = "The opacity of the minimap markers"
) )
@Units(Units.PERCENT)
default int minimapOverlayOpacity() default int minimapOverlayOpacity()
{ {
return 100; return 100;

View File

@@ -28,6 +28,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigSection; import net.runelite.client.config.ConfigSection;
import net.runelite.client.config.Units;
@ConfigGroup("idlenotifier") @ConfigGroup("idlenotifier")
public interface IdleNotifierConfig extends Config public interface IdleNotifierConfig extends Config
@@ -144,10 +145,11 @@ public interface IdleNotifierConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "timeout", keyName = "timeout",
name = "Idle Notification Delay (ms)", name = "Idle Notification Delay",
description = "The notification delay after the player is idle", description = "The notification delay after the player is idle",
position = 11 position = 11
) )
@Units(Units.MILLISECONDS)
default int getIdleNotificationDelay() default int getIdleNotificationDelay()
{ {
return 5000; return 5000;
@@ -203,6 +205,7 @@ public interface IdleNotifierConfig extends Config
description = "The amount of remaining oxygen to send a notification at. A value of 0 will disable notification.", description = "The amount of remaining oxygen to send a notification at. A value of 0 will disable notification.",
position = 16 position = 16
) )
@Units(Units.PERCENT)
default int getOxygenThreshold() default int getOxygenThreshold()
{ {
return 0; return 0;
@@ -214,6 +217,7 @@ public interface IdleNotifierConfig extends Config
description = "The amount of spec energy reached to send a notification at. A value of 0 will disable notification.", description = "The amount of spec energy reached to send a notification at. A value of 0 will disable notification.",
position = 17 position = 17
) )
@Units(Units.PERCENT)
default int getSpecEnergyThreshold() default int getSpecEnergyThreshold()
{ {
return 0; return 0;

View File

@@ -782,6 +782,11 @@ public class IdleNotifierPlugin extends Plugin
{ {
lastInteract = null; lastInteract = null;
lastInteracting = null; lastInteracting = null;
// prevent animation notifications from firing too
lastAnimation = IDLE;
lastAnimating = null;
return true; return true;
} }
} }
@@ -869,6 +874,11 @@ public class IdleNotifierPlugin extends Plugin
{ {
lastAnimation = IDLE; lastAnimation = IDLE;
lastAnimating = null; lastAnimating = null;
// prevent interaction notifications from firing too
lastInteract = null;
lastInteracting = null;
return true; return true;
} }
} }

View File

@@ -30,6 +30,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("inventorygrid") @ConfigGroup("inventorygrid")
public interface InventoryGridConfig extends Config public interface InventoryGridConfig extends Config
@@ -74,6 +75,7 @@ public interface InventoryGridConfig extends Config
position = 4 position = 4
) )
@Range(min = 100) @Range(min = 100)
@Units(Units.MILLISECONDS)
default int dragDelay() default int dragDelay()
{ {
return 100; return 100;

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.kingdomofmiscellania;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("kingdomofmiscellania") @ConfigGroup("kingdomofmiscellania")
public interface KingdomConfig extends Config public interface KingdomConfig extends Config
@@ -59,6 +60,7 @@ public interface KingdomConfig extends Config
description = "Sends a message to your chatbox when your kingdom's coffer is below the threshold. Leave at 0 to disable.", description = "Sends a message to your chatbox when your kingdom's coffer is below the threshold. Leave at 0 to disable.",
position = 2 position = 2
) )
@Units(Units.GP)
default int notifyCofferThreshold() default int notifyCofferThreshold()
{ {
return 0; return 0;

View File

@@ -29,6 +29,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("metronome") @ConfigGroup("metronome")
public interface MetronomePluginConfiguration extends Config public interface MetronomePluginConfiguration extends Config
@@ -38,6 +39,7 @@ public interface MetronomePluginConfiguration extends Config
name = "Tick count", name = "Tick count",
description = "Configures the number of game ticks between metronome sounds" description = "Configures the number of game ticks between metronome sounds"
) )
@Units(Units.TICKS)
default int tickCount() default int tickCount()
{ {
return 1; return 1;
@@ -58,6 +60,7 @@ public interface MetronomePluginConfiguration extends Config
name = "Tock every nth \"tick\"", name = "Tock every nth \"tick\"",
description = "Configures how many \"ticks\" between each \"tock\"" description = "Configures how many \"ticks\" between each \"tock\""
) )
@Units(Units.TICKS)
default int tockNumber() default int tockNumber()
{ {
return 2; return 2;
@@ -102,6 +105,7 @@ public interface MetronomePluginConfiguration extends Config
name = "Volume modification", name = "Volume modification",
description = "Configures tick/tock volume; only effects custom sounds." description = "Configures tick/tock volume; only effects custom sounds."
) )
@Units(Units.PERCENT)
default int volume() default int volume()
{ {
return 35; return 35;

View File

@@ -30,6 +30,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("mining") @ConfigGroup("mining")
public interface MiningConfig extends Config public interface MiningConfig extends Config
@@ -104,6 +105,7 @@ public interface MiningConfig extends Config
name = "Progress pie diameter", name = "Progress pie diameter",
description = "Configures how big the progress pie is" description = "Configures how big the progress pie is"
) )
@Units(Units.PIXELS)
default int progressPieDiameter() default int progressPieDiameter()
{ {
return 30; return 30;

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.motherlode;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("motherlode") @ConfigGroup("motherlode")
public interface MotherlodeConfig extends Config public interface MotherlodeConfig extends Config
@@ -54,9 +55,10 @@ public interface MotherlodeConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "statTimeout", keyName = "statTimeout",
name = "Reset stats (minutes)", name = "Reset stats",
description = "Configures the time until statistics are reset" description = "Configures the time until statistics are reset"
) )
@Units(Units.MINUTES)
default int statTimeout() default int statTimeout()
{ {
return 5; return 5;

View File

@@ -28,6 +28,7 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("npcindicators") @ConfigGroup("npcindicators")
public interface NpcIndicatorsConfig extends Config public interface NpcIndicatorsConfig extends Config
@@ -124,7 +125,8 @@ public interface NpcIndicatorsConfig extends Config
position = 7, position = 7,
keyName = "showRespawnTimer", keyName = "showRespawnTimer",
name = "Show respawn timer", name = "Show respawn timer",
description = "Show respawn timer of tagged NPCs") description = "Show respawn timer of tagged NPCs"
)
default boolean showRespawnTimer() default boolean showRespawnTimer()
{ {
return false; return false;
@@ -134,7 +136,8 @@ public interface NpcIndicatorsConfig extends Config
position = 7, position = 7,
keyName = "notifyOnRespawn", keyName = "notifyOnRespawn",
name = "Notify on Respawn", name = "Notify on Respawn",
description = "Enable notification on respawn") description = "Enable notification on respawn"
)
default boolean getNotifyOnRespawn() default boolean getNotifyOnRespawn()
{ {
return false; return false;
@@ -144,7 +147,9 @@ public interface NpcIndicatorsConfig extends Config
position = 8, position = 8,
keyName = "notifyOnRespawnDelay", keyName = "notifyOnRespawnDelay",
name = "Notification Delay", name = "Notification Delay",
description = "Notify when NPC is x ms from respawning") description = "Notify when NPC is x ms from respawning"
)
@Units(Units.MILLISECONDS)
default int getNotifyOnRespawnDelay() default int getNotifyOnRespawnDelay()
{ {
return -1; return -1;

View File

@@ -33,6 +33,7 @@ import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("objectindicators") @ConfigGroup("objectindicators")
public interface ObjectIndicatorsConfig extends Config public interface ObjectIndicatorsConfig extends Config
@@ -109,6 +110,7 @@ public interface ObjectIndicatorsConfig extends Config
description = "Configures the opacity/alpha of object marker", description = "Configures the opacity/alpha of object marker",
titleSection = "colorTitle" titleSection = "colorTitle"
) )
@Units(Units.PERCENT)
default int objectMarkerAlpha() default int objectMarkerAlpha()
{ {
return 100; return 100;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.performancestats;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("performancestats") @ConfigGroup("performancestats")
public interface PerformanceStatsConfig extends Config public interface PerformanceStatsConfig extends Config
@@ -34,9 +35,10 @@ public interface PerformanceStatsConfig extends Config
@ConfigItem( @ConfigItem(
position = 0, position = 0,
keyName = "submitTimeout", keyName = "submitTimeout",
name = "Submit Timeout (seconds)", name = "Submit Timeout",
description = "Submits after this many seconds of inactivity" description = "Submits after this many seconds of inactivity"
) )
@Units(Units.SECONDS)
default int submitTimeout() default int submitTimeout()
{ {
return 30; return 30;

View File

@@ -27,6 +27,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("playerscouter") @ConfigGroup("playerscouter")
public interface PlayerScouterConfig extends Config public interface PlayerScouterConfig extends Config
@@ -116,6 +117,7 @@ public interface PlayerScouterConfig extends Config
description = "Minimum value for the item to be posted on discord.", description = "Minimum value for the item to be posted on discord.",
position = 6 position = 6
) )
@Units(Units.GP)
default int minimumValue() default int minimumValue()
{ {
return 1000; return 1000;
@@ -157,6 +159,7 @@ public interface PlayerScouterConfig extends Config
description = "Minimum amount of ticks before the player can be scouted again. (1 tick = 600ms)", description = "Minimum amount of ticks before the player can be scouted again. (1 tick = 600ms)",
position = 9 position = 9
) )
@Units(Units.TICKS)
default int timeout() default int timeout()
{ {
return 500; return 500;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.poison;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup(PoisonConfig.GROUP) @ConfigGroup(PoisonConfig.GROUP)
public interface PoisonConfig extends Config public interface PoisonConfig extends Config
@@ -81,6 +82,7 @@ public interface PoisonConfig extends Config
description = "The size the time left text for other players/npc's will be", description = "The size the time left text for other players/npc's will be",
position = 3 position = 3
) )
@Units(Units.POINTS)
default int fontSize() default int fontSize()
{ {
return 8; return 8;

View File

@@ -29,6 +29,7 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("pyramidplunder") @ConfigGroup("pyramidplunder")
public interface PyramidPlunderConfig extends Config public interface PyramidPlunderConfig extends Config
@@ -133,6 +134,7 @@ public interface PyramidPlunderConfig extends Config
description = "Recolor time left(s)", description = "Recolor time left(s)",
titleSection = "warningsTitle" titleSection = "warningsTitle"
) )
@Units(Units.SECONDS)
default int firstWarningTime() default int firstWarningTime()
{ {
return 90; return 90;
@@ -145,6 +147,7 @@ public interface PyramidPlunderConfig extends Config
description = "Recolor time left(s)", description = "Recolor time left(s)",
titleSection = "warningsTitle" titleSection = "warningsTitle"
) )
@Units(Units.SECONDS)
default int secondWarningTime() default int secondWarningTime()
{ {
return 30; return 30;

View File

@@ -31,6 +31,7 @@ import java.awt.Graphics2D;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
@@ -43,7 +44,7 @@ public class ScreenMarkerOverlay extends Overlay
private final ScreenMarker marker; private final ScreenMarker marker;
private final ScreenMarkerRenderable screenMarkerRenderable; private final ScreenMarkerRenderable screenMarkerRenderable;
ScreenMarkerOverlay(final ScreenMarker marker) ScreenMarkerOverlay(@NonNull ScreenMarker marker)
{ {
this.marker = marker; this.marker = marker;
this.screenMarkerRenderable = new ScreenMarkerRenderable(); this.screenMarkerRenderable = new ScreenMarkerRenderable();

View File

@@ -36,6 +36,7 @@ import java.awt.image.BufferedImage;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.inject.Inject; import javax.inject.Inject;
@@ -188,9 +189,10 @@ public class ScreenMarkerPlugin extends Plugin
public void finishCreation(boolean aborted) public void finishCreation(boolean aborted)
{ {
if (!aborted && currentMarker != null) ScreenMarker marker = currentMarker;
if (!aborted && marker != null)
{ {
final ScreenMarkerOverlay screenMarkerOverlay = new ScreenMarkerOverlay(currentMarker); final ScreenMarkerOverlay screenMarkerOverlay = new ScreenMarkerOverlay(marker);
screenMarkerOverlay.setPreferredLocation(overlay.getBounds().getLocation()); screenMarkerOverlay.setPreferredLocation(overlay.getBounds().getLocation());
screenMarkerOverlay.setPreferredSize(overlay.getBounds().getSize()); screenMarkerOverlay.setPreferredSize(overlay.getBounds().getSize());
@@ -258,6 +260,6 @@ public class ScreenMarkerPlugin extends Plugin
{ {
}.getType()); }.getType());
return screenMarkerData.stream().map(ScreenMarkerOverlay::new); return screenMarkerData.stream().filter(Objects::nonNull).map(ScreenMarkerOverlay::new);
} }
} }

View File

@@ -28,6 +28,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind; import net.runelite.client.config.Keybind;
import net.runelite.client.util.ImageUploadStyle;
@ConfigGroup("screenshot") @ConfigGroup("screenshot")
public interface ScreenshotConfig extends Config public interface ScreenshotConfig extends Config
@@ -115,9 +116,9 @@ public interface ScreenshotConfig extends Config
description = "Configures whether or not screenshots are uploaded to Imgur, or placed on your clipboard", description = "Configures whether or not screenshots are uploaded to Imgur, or placed on your clipboard",
position = 7 position = 7
) )
default UploadStyle uploadScreenshot() default ImageUploadStyle uploadScreenshot()
{ {
return UploadStyle.NEITHER; return ImageUploadStyle.NEITHER;
} }
@ConfigItem( @ConfigItem(

View File

@@ -32,26 +32,17 @@ import com.google.inject.Provides;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date; import java.util.Date;
import java.util.EnumSet;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@@ -66,7 +57,6 @@ import net.runelite.api.Player;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.SpriteID; import net.runelite.api.SpriteID;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.WorldType;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
@@ -96,24 +86,14 @@ import net.runelite.client.input.KeyManager;
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.plugins.screenshot.imgur.ImageUploadRequest;
import net.runelite.client.plugins.screenshot.imgur.ImageUploadResponse;
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.DrawManager; import net.runelite.client.ui.DrawManager;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageCapture;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@PluginDescriptor( @PluginDescriptor(
@@ -126,10 +106,6 @@ import org.jetbrains.annotations.Nullable;
@Singleton @Singleton
public class ScreenshotPlugin extends Plugin public class ScreenshotPlugin extends Plugin
{ {
private static final String IMGUR_CLIENT_ID = "30d71e5f6860809";
private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.parse("https://api.imgur.com/3/image");
private static final MediaType JSON = MediaType.parse("application/json");
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
private static final Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)"); private static final Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)");
@@ -196,6 +172,9 @@ public class ScreenshotPlugin extends Plugin
@Inject @Inject
private SpriteManager spriteManager; private SpriteManager spriteManager;
@Inject
private ImageCapture imageCapture;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private BufferedImage reportButton; private BufferedImage reportButton;
@@ -206,7 +185,7 @@ public class ScreenshotPlugin extends Plugin
@Override @Override
public void hotkeyPressed() public void hotkeyPressed()
{ {
takeScreenshot(format(new Date())); takeScreenshot("");
} }
}; };
@@ -220,7 +199,6 @@ public class ScreenshotPlugin extends Plugin
private boolean screenshotLevels; private boolean screenshotLevels;
private boolean screenshotKingdom; private boolean screenshotKingdom;
private boolean screenshotPet; private boolean screenshotPet;
private UploadStyle uploadScreenshot;
private boolean screenshotKills; private boolean screenshotKills;
private boolean screenshotBossKills; private boolean screenshotBossKills;
private boolean screenshotFriendDeath; private boolean screenshotFriendDeath;
@@ -253,7 +231,7 @@ public class ScreenshotPlugin extends Plugin
.tab(false) .tab(false)
.tooltip("Take screenshot") .tooltip("Take screenshot")
.icon(iconImage) .icon(iconImage)
.onClick(() -> takeScreenshot(format(new Date()))) .onClick(() -> takeScreenshot(""))
.popup(ImmutableMap .popup(ImmutableMap
.<String, Runnable>builder() .<String, Runnable>builder()
.put("Open screenshot folder...", () -> .put("Open screenshot folder...", () ->
@@ -353,7 +331,7 @@ public class ScreenshotPlugin extends Plugin
{ {
final Player player = playerLootReceived.getPlayer(); final Player player = playerLootReceived.getPlayer();
final String name = player.getName(); final String name = player.getName();
String fileName = "Kill " + name + " " + format(new Date()); String fileName = "Kill " + name;
takeScreenshot(fileName); takeScreenshot(fileName);
} }
} }
@@ -421,7 +399,7 @@ public class ScreenshotPlugin extends Plugin
if (this.screenshotPet && PET_MESSAGES.stream().anyMatch(chatMessage::contains)) if (this.screenshotPet && PET_MESSAGES.stream().anyMatch(chatMessage::contains))
{ {
String fileName = "Pet " + format(new Date()); String fileName = "Pet";
takeScreenshot(fileName); takeScreenshot(fileName);
} }
@@ -443,7 +421,7 @@ public class ScreenshotPlugin extends Plugin
if (m.matches()) if (m.matches())
{ {
String valuableDropName = m.group(1); String valuableDropName = m.group(1);
String fileName = "Valuable drop " + valuableDropName + " " + format(new Date()); String fileName = "Valuable drop " + valuableDropName;
takeScreenshot(fileName); takeScreenshot(fileName);
} }
} }
@@ -454,7 +432,7 @@ public class ScreenshotPlugin extends Plugin
if (m.matches()) if (m.matches())
{ {
String untradeableDropName = m.group(1); String untradeableDropName = m.group(1);
String fileName = "Untradeable drop " + untradeableDropName + " " + format(new Date()); String fileName = "Untradeable drop " + untradeableDropName;
takeScreenshot(fileName); takeScreenshot(fileName);
} }
} }
@@ -703,135 +681,7 @@ public class ScreenshotPlugin extends Plugin
// Draw the game onto the screenshot // Draw the game onto the screenshot
graphics.drawImage(image, gameOffsetX, gameOffsetY, null); graphics.drawImage(image, gameOffsetX, gameOffsetY, null);
imageCapture.takeScreenshot(screenshot, fileName, config.notifyWhenTaken(), config.uploadScreenshot());
File playerFolder;
if (client.getLocalPlayer() != null && client.getLocalPlayer().getName() != null)
{
final EnumSet<WorldType> worldTypes = client.getWorldType();
String playerDir = client.getLocalPlayer().getName();
if (worldTypes.contains(WorldType.DEADMAN))
{
playerDir += "-Deadman";
}
else if (worldTypes.contains(WorldType.LEAGUE))
{
playerDir += "-League";
}
playerFolder = new File(SCREENSHOT_DIR, playerDir);
}
else
{
playerFolder = SCREENSHOT_DIR;
}
playerFolder.mkdirs();
if (subdirectory != null)
{
//uhh just tried to do this as workaround, not sure if it's the best idea tho
File actualplayerFolder = new File(playerFolder, subdirectory);
actualplayerFolder.mkdir();
playerFolder = actualplayerFolder;
}
try
{
File screenshotFile = new File(playerFolder, fileName + ".png");
// To make sure that screenshots don't get overwritten, check if file exists,
// and if it does create file with same name and suffix.
int i = 1;
while (screenshotFile.exists())
{
screenshotFile = new File(playerFolder, fileName + String.format("(%d)", i++) + ".png");
}
ImageIO.write(screenshot, "PNG", screenshotFile);
UploadStyle uploadStyle = this.uploadScreenshot;
if (uploadStyle == UploadStyle.IMGUR)
{
uploadScreenshot(screenshotFile);
}
else if (uploadStyle == UploadStyle.CLIPBOARD)
{
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
TransferableBufferedImage transferableBufferedImage = new TransferableBufferedImage(screenshot);
clipboard.setContents(transferableBufferedImage, null);
if (this.notifyWhenTaken)
{
notifier.notify("A screenshot was saved and inserted into your clipboard!", TrayIcon.MessageType.INFO);
}
}
else if (this.notifyWhenTaken)
{
notifier.notify("A screenshot was saved to " + screenshotFile, TrayIcon.MessageType.INFO);
}
}
catch (IOException ex)
{
log.warn("error writing screenshot", ex);
}
}
/**
* Uploads a screenshot to the Imgur image-hosting service,
* and copies the image link to the clipboard.
*
* @param screenshotFile Image file to upload.
* @throws IOException Thrown if the file cannot be read.
*/
/**
* Uploads a screenshot to the Imgur image-hosting service,
* and copies the image link to the clipboard.
*
* @param screenshotFile Image file to upload.
* @throws IOException Thrown if the file cannot be read.
*/
private void uploadScreenshot(File screenshotFile) throws IOException
{
String json = RuneLiteAPI.GSON.toJson(new ImageUploadRequest(screenshotFile));
Request request = new Request.Builder()
.url(IMGUR_IMAGE_UPLOAD_URL)
.addHeader("Authorization", "Client-ID " + IMGUR_CLIENT_ID)
.post(RequestBody.create(JSON, json))
.build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
{
@Override
public void onFailure(@NotNull Call call, @NotNull IOException ex)
{
log.warn("error uploading screenshot", ex);
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException
{
try (InputStream in = response.body().byteStream())
{
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
if (imageUploadResponse.isSuccess())
{
String link = imageUploadResponse.getData().getLink();
StringSelection selection = new StringSelection(link);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
if (notifyWhenTaken)
{
notifier.notify("A screenshot was uploaded and inserted into your clipboard!", TrayIcon.MessageType.INFO);
}
}
}
}
});
} }
@VisibleForTesting @VisibleForTesting
@@ -890,7 +740,6 @@ public class ScreenshotPlugin extends Plugin
this.screenshotLevels = config.screenshotLevels(); this.screenshotLevels = config.screenshotLevels();
this.screenshotKingdom = config.screenshotKingdom(); this.screenshotKingdom = config.screenshotKingdom();
this.screenshotPet = config.screenshotPet(); this.screenshotPet = config.screenshotPet();
this.uploadScreenshot = config.uploadScreenshot();
this.screenshotKills = config.screenshotKills(); this.screenshotKills = config.screenshotKills();
this.screenshotBossKills = config.screenshotBossKills(); this.screenshotBossKills = config.screenshotBossKills();
this.screenshotFriendDeath = config.screenshotFriendDeath(); this.screenshotFriendDeath = config.screenshotFriendDeath();

View File

@@ -29,6 +29,7 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("slayer") @ConfigGroup("slayer")
public interface SlayerConfig extends Config public interface SlayerConfig extends Config
@@ -70,9 +71,10 @@ public interface SlayerConfig extends Config
@ConfigItem( @ConfigItem(
position = 4, position = 4,
keyName = "statTimeout", keyName = "statTimeout",
name = "InfoBox Expiry (minutes)", name = "InfoBox Expiry",
description = "Set the time until the InfoBox expires" description = "Set the time until the InfoBox expires"
) )
@Units(Units.MINUTES)
default int statTimeout() default int statTimeout()
{ {
return 5; return 5;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.smelting;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("smelting") @ConfigGroup("smelting")
public interface SmeltingConfig extends Config public interface SmeltingConfig extends Config
@@ -34,9 +35,10 @@ public interface SmeltingConfig extends Config
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "statTimeout", keyName = "statTimeout",
name = "Reset stats (minutes)", name = "Reset stats",
description = "The time it takes for the current smelting session to be reset" description = "The time it takes for the current smelting session to be reset"
) )
@Units(Units.MINUTES)
default int statTimeout() default int statTimeout()
{ {
return 5; return 5;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.spellbook;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("spellbook") @ConfigGroup("spellbook")
public interface SpellbookConfig extends Config public interface SpellbookConfig extends Config
@@ -70,6 +71,7 @@ public interface SpellbookConfig extends Config
description = "Size (in px) of spells. Normal mobile size is 40px, use common sense for this setting", description = "Size (in px) of spells. Normal mobile size is 40px, use common sense for this setting",
position = 4 position = 4
) )
@Units(Units.PIXELS)
default int size() default int size()
{ {
return 40; return 40;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.statusbars;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
import net.runelite.client.plugins.statusbars.config.BarMode; import net.runelite.client.plugins.statusbars.config.BarMode;
@ConfigGroup("statusbars") @ConfigGroup("statusbars")
@@ -101,9 +102,10 @@ public interface StatusBarsConfig extends Config
@ConfigItem( @ConfigItem(
position = 7, position = 7,
keyName = "hideStatusBarDelay", keyName = "hideStatusBarDelay",
name = "Delay (seconds)", name = "Delay",
description = "Number of seconds after combat to hide the status bars." description = "Number of seconds after combat to hide the status bars."
) )
@Units(Units.SECONDS)
default int hideStatusBarDelay() default int hideStatusBarDelay()
{ {
return 3; return 3;

View File

@@ -30,6 +30,7 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection; import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Title; import net.runelite.client.config.Title;
import net.runelite.client.config.Units;
@ConfigGroup("statusorbs") @ConfigGroup("statusorbs")
public interface StatusOrbsConfig extends Config public interface StatusOrbsConfig extends Config
@@ -83,11 +84,12 @@ public interface StatusOrbsConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "notifyBeforeHpRegenDuration", keyName = "notifyBeforeHpRegenDuration",
name = "Hitpoint Regen Notification (seconds)", name = "Hitpoint Regen Notification",
description = "Notify approximately when your next hitpoint is about to regen. A value of 0 will disable notification.", description = "Notify approximately when your next hitpoint is about to regen. A value of 0 will disable notification.",
titleSection = "hp", titleSection = "hp",
position = 4 position = 4
) )
@Units(Units.SECONDS)
default int getNotifyBeforeHpRegenSeconds() default int getNotifyBeforeHpRegenSeconds()
{ {
return 0; return 0;

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.stretchedmode;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("stretchedmode") @ConfigGroup("stretchedmode")
public interface StretchedModeConfig extends Config public interface StretchedModeConfig extends Config
@@ -64,9 +65,10 @@ public interface StretchedModeConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "scalingFactor", keyName = "scalingFactor",
name = "Resizable Scaling (%)", name = "Resizable Scaling",
description = "In resizable mode, the game is reduced in size this much before it's stretched." description = "In resizable mode, the game is reduced in size this much before it's stretched."
) )
@Units(Units.PERCENT)
default int scalingFactor() default int scalingFactor()
{ {
return 50; return 50;

View File

@@ -33,6 +33,7 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigSection; import net.runelite.client.config.ConfigSection;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
@ConfigGroup("thieving") @ConfigGroup("thieving")
public interface ThievingConfig extends Config public interface ThievingConfig extends Config
@@ -40,9 +41,10 @@ public interface ThievingConfig extends Config
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "statTimeout", keyName = "statTimeout",
name = "Reset stats (minutes)", name = "Reset stats",
description = "Change the time until the thieving session is reset and the overlay is hidden" description = "Change the time until the thieving session is reset and the overlay is hidden"
) )
@Units(Units.MINUTES)
default int statTimeout() default int statTimeout()
{ {
return 5; return 5;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.timetracking;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("timetracking") @ConfigGroup("timetracking")
public interface TimeTrackingConfig extends Config public interface TimeTrackingConfig extends Config
@@ -72,10 +73,11 @@ public interface TimeTrackingConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "defaultTimerMinutes", keyName = "defaultTimerMinutes",
name = "Default Time (Minutes)", name = "Default Time",
description = "The default time for the timer in minutes", description = "The default time for the timer in minutes",
position = 4 position = 4
) )
@Units(Units.MINUTES)
default int defaultTimerMinutes() default int defaultTimerMinutes()
{ {
return 5; return 5;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Lotto <https://github.com/devLotto> * Copyright (c) 2020, Henry Darnell <hjdarnel@gmail.com>
* 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
@@ -22,23 +22,23 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.client.plugins.screenshot.imgur; package net.runelite.client.plugins.wiki;
import java.io.File; import net.runelite.client.config.Config;
import java.io.IOException; import net.runelite.client.config.ConfigGroup;
import java.nio.file.Files; import net.runelite.client.config.ConfigItem;
import java.util.Base64;
import lombok.Data;
@Data @ConfigGroup(WikiPlugin.CONFIG_GROUP_KEY)
public class ImageUploadRequest public interface WikiConfig extends Config
{ {
private final String image; @ConfigItem(
private final String type; keyName = "leftClickSearch",
name = "Left Click Search",
public ImageUploadRequest(File imageFile) throws IOException description = "Swap left-click on the Wiki button to Search",
position = 1
)
default boolean leftClickSearch()
{ {
this.image = Base64.getEncoder().encodeToString(Files.readAllBytes(imageFile.toPath())); return false;
this.type = "base64";
} }
} }

View File

@@ -24,6 +24,7 @@
*/ */
package net.runelite.client.plugins.wiki; package net.runelite.client.plugins.wiki;
import com.google.inject.Provides;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Provider; import javax.inject.Provider;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -48,7 +49,9 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetPositionMode; import net.runelite.api.widgets.WidgetPositionMode;
import net.runelite.api.widgets.WidgetType; import net.runelite.api.widgets.WidgetType;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager; import net.runelite.client.game.SpriteManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -86,6 +89,9 @@ public class WikiPlugin extends Plugin
@Inject @Inject
private SpriteManager spriteManager; private SpriteManager spriteManager;
@Inject
private WikiConfig config;
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
@@ -102,6 +108,14 @@ public class WikiPlugin extends Plugin
private boolean wikiSelected = false; private boolean wikiSelected = false;
static final String CONFIG_GROUP_KEY = "wiki";
@Provides
WikiConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(WikiConfig.class);
}
@Override @Override
public void startUp() public void startUp()
{ {
@@ -111,29 +125,32 @@ public class WikiPlugin extends Plugin
@Override @Override
public void shutDown() public void shutDown()
{ {
clientThread.invokeLater(() -> clientThread.invokeLater(this::removeWidgets);
}
private void removeWidgets()
{
Widget minimapOrbs = client.getWidget(WidgetInfo.MINIMAP_ORBS);
if (minimapOrbs == null)
{ {
Widget minimapOrbs = client.getWidget(WidgetInfo.MINIMAP_ORBS); return;
if (minimapOrbs == null) }
{ Widget[] children = minimapOrbs.getChildren();
return; if (children == null || children.length < 1)
} {
Widget[] children = minimapOrbs.getChildren(); return;
if (children == null || children.length < 1) }
{ children[0] = null;
return;
}
children[0] = null;
Widget vanilla = client.getWidget(WidgetInfo.MINIMAP_WIKI_BANNER); Widget vanilla = client.getWidget(WidgetInfo.MINIMAP_WIKI_BANNER);
if (vanilla != null) if (vanilla != null)
{ {
vanilla.setHidden(false); vanilla.setHidden(false);
} }
onDeselect(); onDeselect();
client.setSpellSelected(false); client.setSpellSelected(false);
});
} }
@Subscribe @Subscribe
@@ -178,14 +195,17 @@ public class WikiPlugin extends Plugin
icon.setSpriteId(SpriteID.WIKI_SELECTED); icon.setSpriteId(SpriteID.WIKI_SELECTED);
client.setAllWidgetsAreOpTargetable(true); client.setAllWidgetsAreOpTargetable(true);
}); });
icon.setAction(5, "Search"); // Start at option 5 so the target op is ontop
final int searchIndex = config.leftClickSearch() ? 4 : 5;
icon.setAction(searchIndex, "Search");
icon.setOnOpListener((JavaScriptCallback) ev -> icon.setOnOpListener((JavaScriptCallback) ev ->
{ {
if (ev.getOp() == 6) if (ev.getOp() == searchIndex + 1)
{ {
openSearchInput(); openSearchInput();
} }
}); });
// This doesn't always run because we cancel the menuop // This doesn't always run because we cancel the menuop
icon.setOnTargetLeaveListener((JavaScriptCallback) ev -> onDeselect()); icon.setOnTargetLeaveListener((JavaScriptCallback) ev -> onDeselect());
icon.revalidate(); icon.revalidate();
@@ -200,6 +220,19 @@ public class WikiPlugin extends Plugin
} }
} }
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals(CONFIG_GROUP_KEY))
{
clientThread.invokeLater(() ->
{
removeWidgets();
addWidgets();
});
}
}
private void onDeselect() private void onDeselect()
{ {
client.setAllWidgetsAreOpTargetable(false); client.setAllWidgetsAreOpTargetable(false);

View File

@@ -30,6 +30,7 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range; import net.runelite.client.config.Range;
import net.runelite.client.config.Units;
import net.runelite.client.plugins.wintertodt.config.WintertodtNotifyMode; import net.runelite.client.plugins.wintertodt.config.WintertodtNotifyMode;
@ConfigGroup("wintertodt") @ConfigGroup("wintertodt")
@@ -66,6 +67,7 @@ public interface WintertodtConfig extends Config
@Range( @Range(
max = 60 max = 60
) )
@Units(Units.SECONDS)
default int roundNotification() default int roundNotification()
{ {
return 5; return 5;

View File

@@ -311,8 +311,8 @@ public class WintertodtPlugin extends Plugin
chatMessageManager.update(messageNode); chatMessageManager.update(messageNode);
client.refreshChat(); client.refreshChat();
// all actions except woodcutting are interrupted from damage // all actions except woodcutting and idle are interrupted from damage
if (currentActivity != WintertodtActivity.WOODCUTTING) if (currentActivity != WintertodtActivity.WOODCUTTING && currentActivity != WintertodtActivity.IDLE)
{ {
wasInterrupted = true; wasInterrupted = true;
} }

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.woodcutting;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("woodcutting") @ConfigGroup("woodcutting")
public interface WoodcuttingConfig extends Config public interface WoodcuttingConfig extends Config
@@ -34,9 +35,10 @@ public interface WoodcuttingConfig extends Config
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "statTimeout", keyName = "statTimeout",
name = "Reset stats (minutes)", name = "Reset stats",
description = "Configures the time until statistic is reset. Also configures when tree indicator is hidden" description = "Configures the time until statistic is reset. Also configures when tree indicator is hidden"
) )
@Units(Units.MINUTES)
default int statTimeout() default int statTimeout()
{ {
return 5; return 5;

View File

@@ -29,6 +29,7 @@ import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("xpglobes") @ConfigGroup("xpglobes")
public interface XpGlobesConfig extends Config public interface XpGlobesConfig extends Config
@@ -152,6 +153,7 @@ public interface XpGlobesConfig extends Config
description = "Change the stroke width of the progress arc", description = "Change the stroke width of the progress arc",
position = 10 position = 10
) )
@Units(Units.PIXELS)
default int progressArcStrokeWidth() default int progressArcStrokeWidth()
{ {
return 2; return 2;
@@ -163,6 +165,7 @@ public interface XpGlobesConfig extends Config
description = "Change the size of the xp orbs", description = "Change the size of the xp orbs",
position = 11 position = 11
) )
@Units(Units.PIXELS)
default int xpOrbSize() default int xpOrbSize()
{ {
return 40; return 40;
@@ -174,6 +177,7 @@ public interface XpGlobesConfig extends Config
description = "Change the duration the xp orbs are visible", description = "Change the duration the xp orbs are visible",
position = 12 position = 12
) )
@Units(Units.SECONDS)
default int xpOrbDuration() default int xpOrbDuration()
{ {
return 10; return 10;

View File

@@ -28,6 +28,7 @@ import lombok.AllArgsConstructor;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("xpTracker") @ConfigGroup("xpTracker")
public interface XpTrackerConfig extends Config public interface XpTrackerConfig extends Config
@@ -87,6 +88,7 @@ public interface XpTrackerConfig extends Config
name = "Auto pause after", name = "Auto pause after",
description = "Configures how many minutes passes before pausing a skill while in game and there's no XP, 0 means disabled" description = "Configures how many minutes passes before pausing a skill while in game and there's no XP, 0 means disabled"
) )
@Units(Units.MINUTES)
default int pauseSkillAfter() default int pauseSkillAfter()
{ {
return 0; return 0;

View File

@@ -26,6 +26,7 @@ package net.runelite.client.ui.overlay;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -61,6 +62,8 @@ public abstract class WidgetItemOverlay extends Overlay
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
final List<WidgetItem> itemWidgets = overlayManager.getItemWidgets(); final List<WidgetItem> itemWidgets = overlayManager.getItemWidgets();
final Rectangle originalClipBounds = graphics.getClipBounds();
Widget curClipParent = null;
for (WidgetItem widgetItem : itemWidgets) for (WidgetItem widgetItem : itemWidgets)
{ {
Widget widget = widgetItem.getWidget(); Widget widget = widgetItem.getWidget();
@@ -74,6 +77,29 @@ public abstract class WidgetItemOverlay extends Overlay
continue; continue;
} }
Widget parent = widget.getParent();
Rectangle parentBounds = parent.getBounds();
Rectangle itemCanvasBounds = widgetItem.getCanvasBounds();
boolean shouldClip;
shouldClip = itemCanvasBounds.y < parentBounds.y && itemCanvasBounds.y + itemCanvasBounds.height >= parentBounds.y;
shouldClip |= itemCanvasBounds.y < parentBounds.y + parentBounds.height && itemCanvasBounds.y + itemCanvasBounds.height >= parentBounds.y + parentBounds.height;
shouldClip |= itemCanvasBounds.x < parentBounds.x && (itemCanvasBounds.x + itemCanvasBounds.width) >= parentBounds.x;
shouldClip |= itemCanvasBounds.x < parentBounds.x + parentBounds.width && itemCanvasBounds.x + itemCanvasBounds.width >= parentBounds.x + parentBounds.width;
if (shouldClip)
{
if (curClipParent != parent)
{
graphics.setClip(parentBounds);
curClipParent = parent;
}
}
else if (curClipParent != null && curClipParent != parent)
{
graphics.setClip(originalClipBounds);
curClipParent = null;
}
renderItemOverlay(graphics, widgetItem.getId(), widgetItem); renderItemOverlay(graphics, widgetItem.getId(), widgetItem);
} }
return null; return null;

View File

@@ -32,6 +32,8 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.config.TooltipPositionType;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
@@ -41,16 +43,19 @@ import net.runelite.client.ui.overlay.components.TooltipComponent;
@Singleton @Singleton
public class TooltipOverlay extends Overlay public class TooltipOverlay extends Overlay
{ {
private static final int OFFSET = 24; private static final int UNDER_OFFSET = 24;
private static final int ABOVE_OFFSET = -20;
private static final int PADDING = 2; private static final int PADDING = 2;
private final TooltipManager tooltipManager; private final TooltipManager tooltipManager;
private final Client client; private final Client client;
private final RuneLiteConfig runeLiteConfig;
@Inject @Inject
private TooltipOverlay(Client client, TooltipManager tooltipManager) private TooltipOverlay(Client client, TooltipManager tooltipManager, final RuneLiteConfig runeLiteConfig)
{ {
this.client = client; this.client = client;
this.tooltipManager = tooltipManager; this.tooltipManager = tooltipManager;
this.runeLiteConfig = runeLiteConfig;
setPosition(OverlayPosition.TOOLTIP); setPosition(OverlayPosition.TOOLTIP);
setPriority(OverlayPriority.HIGHEST); setPriority(OverlayPriority.HIGHEST);
setLayer(OverlayLayer.ALWAYS_ON_TOP); setLayer(OverlayLayer.ALWAYS_ON_TOP);
@@ -81,7 +86,8 @@ public class TooltipOverlay extends Overlay
{ {
final Rectangle clientCanvasBounds = new Rectangle(client.getRealDimensions()); final Rectangle clientCanvasBounds = new Rectangle(client.getRealDimensions());
final net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition(); final net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition();
final Point mousePosition = new Point(mouseCanvasPosition.getX(), mouseCanvasPosition.getY() + OFFSET); final int offset = runeLiteConfig.tooltipPosition() == TooltipPositionType.UNDER_CURSOR ? UNDER_OFFSET : ABOVE_OFFSET;
final Point mousePosition = new Point(mouseCanvasPosition.getX(), mouseCanvasPosition.getY() + offset);
final Rectangle bounds = new Rectangle(getBounds()); final Rectangle bounds = new Rectangle(getBounds());
bounds.setLocation(mousePosition); bounds.setLocation(mousePosition);
@@ -94,7 +100,7 @@ public class TooltipOverlay extends Overlay
if (boundsY > clientY) if (boundsY > clientY)
{ {
graphics.translate(0, -bounds.height - OFFSET); graphics.translate(0, -bounds.height - offset);
} }
if (boundsX > clientX) if (boundsX > clientX)
@@ -113,7 +119,7 @@ public class TooltipOverlay extends Overlay
if (newBounds.contains(mousePosition)) if (newBounds.contains(mousePosition))
{ {
mousePosition.move(mouseCanvasPosition.getX(), mouseCanvasPosition.getY() + OFFSET + newBounds.height); mousePosition.move(mouseCanvasPosition.getX(), mouseCanvasPosition.getY() + offset + newBounds.height);
} }
tooltipComponent.setPosition(mousePosition); tooltipComponent.setPosition(mousePosition);

View File

@@ -0,0 +1,244 @@
/*
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
* Copyright (c) 2019, Alexsuperfly <https://github.com/Alexsuperfly>
* 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.util;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.EnumSet;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.WorldType;
import net.runelite.client.Notifier;
import static net.runelite.client.RuneLite.SCREENSHOT_DIR;
import net.runelite.client.RuneLiteProperties;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
@Slf4j
@Singleton
public class ImageCapture
{
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.parse("https://api.imgur.com/3/image");
private static final MediaType JSON = MediaType.parse("application/json");
@Inject
private Client client;
@Inject
private Notifier notifier;
/**
* Saves a screenshot of the client window to the screenshot folder as a PNG,
* and optionally uploads it to an image-hosting service.
*
* @param screenshot BufferedImage to capture.
* @param fileName Filename to use, without file extension.
* @param notify Send a notification to the system tray when the image is captured.
* @param imageUploadStyle which method to use to upload the screenshot (Imgur or directly to clipboard).
*/
public void takeScreenshot(BufferedImage screenshot, String fileName, boolean notify, ImageUploadStyle imageUploadStyle)
{
if (client.getGameState() == GameState.LOGIN_SCREEN)
{
// Prevent the screenshot from being captured
log.info("Login screenshot prevented");
return;
}
File playerFolder;
if (client.getLocalPlayer() != null && client.getLocalPlayer().getName() != null)
{
final EnumSet<WorldType> worldTypes = client.getWorldType();
String playerDir = client.getLocalPlayer().getName();
if (worldTypes.contains(WorldType.DEADMAN))
{
playerDir += "-Deadman";
}
else if (worldTypes.contains(WorldType.LEAGUE))
{
playerDir += "-League";
}
playerFolder = new File(SCREENSHOT_DIR, playerDir);
}
else
{
playerFolder = SCREENSHOT_DIR;
}
playerFolder.mkdirs();
fileName += " " + format(new Date());
try
{
File screenshotFile = new File(playerFolder, fileName + ".png");
// To make sure that screenshots don't get overwritten, check if file exists,
// and if it does create file with same name and suffix.
int i = 1;
while (screenshotFile.exists())
{
screenshotFile = new File(playerFolder, fileName + String.format("(%d)", i++) + ".png");
}
ImageIO.write(screenshot, "PNG", screenshotFile);
if (imageUploadStyle == ImageUploadStyle.IMGUR)
{
uploadScreenshot(screenshotFile, notify);
}
else if (imageUploadStyle == ImageUploadStyle.CLIPBOARD)
{
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
TransferableBufferedImage transferableBufferedImage = new TransferableBufferedImage(screenshot);
clipboard.setContents(transferableBufferedImage, null);
if (notify)
{
notifier.notify("A screenshot was saved and inserted into your clipboard!", TrayIcon.MessageType.INFO);
}
}
else if (notify)
{
notifier.notify("A screenshot was saved to " + screenshotFile, TrayIcon.MessageType.INFO);
}
}
catch (IOException ex)
{
log.warn("error writing screenshot", ex);
}
}
/**
* Uploads a screenshot to the Imgur image-hosting service,
* and copies the image link to the clipboard.
*
* @param screenshotFile Image file to upload.
* @throws IOException Thrown if the file cannot be read.
*/
private void uploadScreenshot(File screenshotFile, boolean notify) throws IOException
{
String json = RuneLiteAPI.GSON.toJson(new ImageUploadRequest(screenshotFile));
Request request = new Request.Builder()
.url(IMGUR_IMAGE_UPLOAD_URL)
.addHeader("Authorization", "Client-ID " + RuneLiteProperties.getImgurClientId())
.post(RequestBody.create(JSON, json))
.build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
{
@Override
public void onFailure(Call call, IOException ex)
{
log.warn("error uploading screenshot", ex);
}
@Override
public void onResponse(Call call, Response response) throws IOException
{
try (InputStream in = response.body().byteStream())
{
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
if (imageUploadResponse.isSuccess())
{
String link = imageUploadResponse.getData().getLink();
StringSelection selection = new StringSelection(link);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
if (notify)
{
notifier.notify("A screenshot was uploaded and inserted into your clipboard!", TrayIcon.MessageType.INFO);
}
}
}
}
});
}
private static String format(Date date)
{
synchronized (TIME_FORMAT)
{
return TIME_FORMAT.format(date);
}
}
@Data
private static class ImageUploadResponse
{
private Data data;
private boolean success;
@lombok.Data
private static class Data
{
private String link;
}
}
@Data
private static class ImageUploadRequest
{
private final String image;
private final String type;
ImageUploadRequest(File imageFile) throws IOException
{
this.image = Base64.getEncoder().encodeToString(Files.readAllBytes(imageFile.toPath()));
this.type = "base64";
}
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Lotto <https://github.com/devLotto> * Copyright (c) 2019, Alexsuperfly <https://github.com/Alexsuperfly>
* 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
@@ -22,19 +22,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.client.plugins.screenshot.imgur;
import lombok.Data; package net.runelite.client.util;
@Data public enum ImageUploadStyle
public class ImageUploadResponse
{ {
private Data data; NEITHER,
private boolean success; IMGUR,
CLIPBOARD
@lombok.Data }
public static class Data
{
private String link;
}
}

View File

@@ -24,7 +24,7 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 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. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.client.plugins.screenshot; package net.runelite.client.util;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;

View File

@@ -12,3 +12,4 @@ runelite.wiki.troubleshooting.link=https://github.com/open-osrs/runelite/wiki/Tr
runelite.wiki.building.link=https://github.com/open-osrs/runelite/wiki/Building-with-IntelliJ-IDEA runelite.wiki.building.link=https://github.com/open-osrs/runelite/wiki/Building-with-IntelliJ-IDEA
runelite.dnschange.link=https://1.1.1.1/dns/ runelite.dnschange.link=https://1.1.1.1/dns/
launcher.version=@launcher.version@ launcher.version=@launcher.version@
runelite.imgur.client.id=30d71e5f6860809

View File

@@ -1 +1 @@
14DBDBF6FB86760F32965613C7393403F142073AA388332F9A5C97B69FE65D19 3444503072AEE70EEB53938C1FDC826A7530B62BB5FAB65402A22BAB08D7B76D

View File

@@ -25,65 +25,83 @@ LABEL17:
iload 1 iload 1
iconst 0 iconst 0
if_icmple LABEL21 if_icmple LABEL21
jump LABEL25 jump LABEL31
LABEL21: LABEL21:
iconst 1 ; What we compare the boolean with iconst 1 ; What we compare the boolean with
iconst 0 ; Boolean iconst 0 ; Boolean
sconst "drawSpecbarAnyway" sconst "drawSpecbarAnyway"
runelite_callback runelite_callback
if_icmpeq LABEL25 if_icmpeq LABEL41
iconst 1 iconst 1
iconst 38862883 iconst 38862883
if_sethide if_sethide
iconst 190
iconst 28
iconst 0
iconst 0
iconst 38862850
if_setsize
return return
LABEL25: LABEL31:
invoke 1972
iconst 1
if_icmpeq LABEL35
jump LABEL41
LABEL35:
iconst 190
iconst 16
iconst 0
iconst 0
iconst 38862850
if_setsize
LABEL41:
iconst 0 iconst 0
istore 2 istore 2
iconst 38862883 iconst 38862883
if_gethide if_gethide
iconst 1 iconst 1
if_icmpeq LABEL32 if_icmpeq LABEL48
jump LABEL34 jump LABEL50
LABEL32: LABEL48:
iconst 1 iconst 1
istore 2 istore 2
LABEL34: LABEL50:
iconst 0 iconst 0
iconst 38862883 iconst 38862883
if_sethide if_sethide
get_varp 301 get_varp 301
iconst 0 iconst 0
if_icmpgt LABEL41 if_icmpgt LABEL57
jump LABEL45 jump LABEL61
LABEL41: LABEL57:
iconst 16776960 iconst 16776960
iconst 38862888 iconst 38862888
if_setcolour if_setcolour
jump LABEL48 jump LABEL64
LABEL45: LABEL61:
iconst 16 iconst 16
iconst 38862888 iconst 38862888
if_setcolour if_setcolour
LABEL48: LABEL64:
get_varp 300 get_varp 300
istore 3 istore 3
iload 3 iload 3
iconst 0 iconst 0
if_icmplt LABEL54 if_icmplt LABEL70
jump LABEL56 jump LABEL72
LABEL54: LABEL70:
iconst 0 iconst 0
istore 3 istore 3
LABEL56: LABEL72:
sconst "Special Attack: " sconst "Special Attack: "
iload 3 iload 3
iconst 10 iconst 10
div div
tostring tostring
sconst "%" sconst "%"
join_string 3 join_string 3
iconst 38862888 iconst 38862888
if_settext if_settext
iload 0 iload 0
iload 3 iload 3
iload 2 iload 2
@@ -96,119 +114,119 @@ LABEL56:
iconst 0 iconst 0
if_icmple RETURN ; Return if the weapon isn't supposed to have a spec if_icmple RETURN ; Return if the weapon isn't supposed to have a spec
jump CONTINUE ; Idk why I'm doing it like this but it's the jagex way jump CONTINUE ; Idk why I'm doing it like this but it's the jagex way
RETURN: RETURN:
return return
CONTINUE: CONTINUE:
iload 3 iload 3
iload 1 iload 1
if_icmpge LABEL73 if_icmpge LABEL89
jump LABEL77 jump LABEL93
LABEL73: LABEL89:
iconst 3767611 iconst 3767611
iconst 38862887 iconst 38862887
if_setcolour if_setcolour
jump LABEL80 jump LABEL96
LABEL77: LABEL93:
iconst 12907 iconst 12907
iconst 38862887 iconst 38862887
if_setcolour if_setcolour
LABEL80: LABEL96:
iconst 94 iconst 94
iconst 3 iconst 3
inv_getobj inv_getobj
istore 4 istore 4
iconst 111 iconst 111
iconst 115 iconst 115
iconst 1739 iconst 1739
iload 4 iload 4
enum enum
sconst " (" sconst " ("
iconst 111 iconst 111
iconst 105 iconst 105
iconst 906 iconst 906
iload 4 iload 4
enum enum
iconst 10 iconst 10
div div
tostring tostring
sconst "%)" sconst "%)"
join_string 4 join_string 4
sstore 0 sstore 0
iload 4 iload 4
switch switch
22737: LABEL108 22737: LABEL124
22740: LABEL108 22740: LABEL124
22743: LABEL108 22743: LABEL124
22731: LABEL108 22731: LABEL124
22734: LABEL108 22734: LABEL124
jump LABEL116 jump LABEL132
LABEL108: LABEL124:
iconst 111 iconst 111
iconst 115 iconst 115
iconst 1739 iconst 1739
iload 4 iload 4
enum enum
sconst " 5-100% " sconst " 5-100% "
join_string 2 join_string 2
sstore 0 sstore 0
LABEL116: LABEL132:
get_varbit 5712 get_varbit 5712
iconst 0 iconst 0
if_icmpeq LABEL120 if_icmpeq LABEL136
jump LABEL185 jump LABEL201
LABEL120: LABEL136:
iload 4 iload 4
iconst 11235 iconst 11235
if_icmpeq LABEL136 if_icmpeq LABEL152
iload 4 iload 4
iconst 20408 iconst 20408
if_icmpeq LABEL136 if_icmpeq LABEL152
iload 4 iload 4
iconst 12765 iconst 12765
if_icmpeq LABEL136 if_icmpeq LABEL152
iload 4 iload 4
iconst 12768 iconst 12768
if_icmpeq LABEL136 if_icmpeq LABEL152
iload 4 iload 4
iconst 12767 iconst 12767
if_icmpeq LABEL136 if_icmpeq LABEL152
jump LABEL169 jump LABEL185
LABEL136: LABEL152:
iconst 94 iconst 94
iconst 13 iconst 13
inv_getobj inv_getobj
iconst 11212 iconst 11212
if_icmpeq LABEL157 if_icmpeq LABEL173
iconst 94 iconst 94
iconst 13 iconst 13
inv_getobj inv_getobj
iconst 11227 iconst 11227
if_icmpeq LABEL157 if_icmpeq LABEL173
iconst 94 iconst 94
iconst 13 iconst 13
inv_getobj inv_getobj
iconst 11228 iconst 11228
if_icmpeq LABEL157 if_icmpeq LABEL173
iconst 94 iconst 94
iconst 13 iconst 13
inv_getobj inv_getobj
iconst 11229 iconst 11229
if_icmpeq LABEL157 if_icmpeq LABEL173
jump LABEL169 jump LABEL185
LABEL157: LABEL173:
sconst "Descent of Dragons: Deal a double attack with dragon arrows that inflicts up to 50% more damage (minimum damage of 8 per hit). (" sconst "Descent of Dragons: Deal a double attack with dragon arrows that inflicts up to 50% more damage (minimum damage of 8 per hit). ("
iconst 111 iconst 111
iconst 105 iconst 105
iconst 906 iconst 906
iload 4 iload 4
enum enum
iconst 10 iconst 10
div div
tostring tostring
sconst "%)" sconst "%)"
join_string 3 join_string 3
sstore 0 sstore 0
LABEL169: LABEL185:
iconst 526 iconst 526
iconst -2147483645 iconst -2147483645
iconst -1 iconst -1
@@ -218,17 +236,17 @@ LABEL169:
iconst 160 iconst 160
sconst "IiIsii" sconst "IiIsii"
iconst 38862883 iconst 38862883
if_setonmouserepeat if_setonmouserepeat
iconst 40 iconst 40
iconst 38862890 iconst 38862890
sconst "I" sconst "I"
iconst 38862883 iconst 38862883
if_setonmouseleave if_setonmouseleave
jump LABEL189 jump LABEL205
LABEL185: LABEL201:
iconst -1 iconst -1
sconst "" sconst ""
iconst 38862883 iconst 38862883
if_setonmouserepeat if_setonmouserepeat
LABEL189: LABEL205:
return return

View File

@@ -52,8 +52,10 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import org.mockito.Mock; import org.mockito.Mock;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@@ -95,6 +97,9 @@ public class IdleNotifierPluginTest
@Mock @Mock
private NPC randomEvent; private NPC randomEvent;
@Mock
private NPC fishingSpot;
@Mock @Mock
private Player player; private Player player;
@@ -115,6 +120,13 @@ public class IdleNotifierPluginTest
when(randomEventComp.getActions()).thenReturn(randomEventActions); when(randomEventComp.getActions()).thenReturn(randomEventActions);
when(randomEvent.getDefinition()).thenReturn(randomEventComp); when(randomEvent.getDefinition()).thenReturn(randomEventComp);
// Mock Fishing Spot
final String[] fishingSpotActions = new String[] { "Use-rod", "Examine" };
final NPCDefinition fishingSpotComp = mock(NPCDefinition.class);
when(fishingSpotComp.getActions()).thenReturn(fishingSpotActions);
when(fishingSpot.getDefinition()).thenReturn(fishingSpotComp);
when(fishingSpot.getName()).thenReturn("Fishing spot");
// Mock player // Mock player
when(player.getName()).thenReturn(PLAYER_NAME); when(player.getName()).thenReturn(PLAYER_NAME);
when(player.getAnimation()).thenReturn(AnimationID.IDLE); when(player.getAnimation()).thenReturn(AnimationID.IDLE);
@@ -271,6 +283,31 @@ public class IdleNotifierPluginTest
verify(notifier, times(1)).notify(any()); verify(notifier, times(1)).notify(any());
} }
@Test
public void testSendOneNotificationForAnimationAndInteract()
{
when(player.getInteracting()).thenReturn(fishingSpot);
when(player.getAnimation()).thenReturn(AnimationID.FISHING_POLE_CAST);
AnimationChanged animationChanged = new AnimationChanged();
animationChanged.setActor(player);
plugin.onInteractingChanged(new InteractingChanged(player, fishingSpot));
plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, never()).notify(anyString());
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
lenient().when(player.getInteracting()).thenReturn(null);
plugin.onAnimationChanged(animationChanged);
plugin.onInteractingChanged(new InteractingChanged(player, null));
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!");
}
@Test @Test
public void testSpecRegen() public void testSpecRegen()
{ {