diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java index 031fd1fd34..201fe30234 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java @@ -69,6 +69,21 @@ public @interface ConfigItem boolean parse() default false; + /** + * For Config items that have a value of multiple enums, + * @return the number of rows that are display in the item without having to scroll. + */ + int displayRows() default 2; + Class clazz() default void.class; + String method() default ""; + + /** + * Use this to indicate the enum class that is going to be used in the multiple select config. + * This implementation made debugging problems with multiple selects a lot easier + * @return The Enum that will be used for the multiple select + */ + Class enumClass() default Enum.class; + } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index 7b4bf545a5..d33e4e5575 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -48,6 +48,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -66,6 +67,7 @@ import net.runelite.client.RuneLite; import static net.runelite.client.RuneLite.PROFILES_DIR; import net.runelite.client.eventbus.EventBus; import net.runelite.client.util.ColorUtil; +import org.apache.commons.lang3.StringUtils; @Singleton @Slf4j @@ -535,6 +537,40 @@ public class ConfigManager { return Duration.ofMillis(Long.parseLong(str)); } + if (type == int[].class) + { + if (str.contains(",")) + { + return Arrays.stream(str.split(",")).mapToInt(Integer::valueOf).toArray(); + } + return new int[] {Integer.parseInt(str)}; + } + if (type == EnumSet.class) + { + try + { + String substring = str.substring(str.indexOf("{") + 1, str.length() - 1); + String[] splitStr = substring.split(", "); + final Class enumClass; + if (!str.contains("{")) + { + return null; + } + enumClass = (Class) Class.forName(str.substring(0, str.indexOf("{"))); + EnumSet enumSet = EnumSet.noneOf(enumClass); + for (String s : splitStr) + { + enumSet.add(Enum.valueOf(enumClass, s.replace("[", "").replace("]", ""))); + } + return enumSet; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + + } if (type == Map.class) { Map output = new HashMap<>(); @@ -597,6 +633,18 @@ public class ConfigManager { return Long.toString(((Duration) object).toMillis()); } + if (object instanceof int[]) + { + if (((int[]) object).length == 0) + { + return String.valueOf(object); + } + return StringUtils.join(object, ","); + } + if (object instanceof EnumSet) + { + return ((EnumSet) object).toArray()[0].getClass().getCanonicalName() + "{" + object.toString() + "}"; + } return object.toString(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index f7b03a7138..8d51106ee5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.config; import com.google.common.base.Splitter; import com.google.common.base.Strings; +import com.google.common.collect.Lists; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -45,6 +46,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.EnumSet; import java.util.List; import java.util.Objects; import java.util.concurrent.ScheduledExecutorService; @@ -58,6 +60,7 @@ import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFormattedTextField; import javax.swing.JLabel; +import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; @@ -66,6 +69,7 @@ import javax.swing.JSlider; import javax.swing.JSpinner; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.ListSelectionModel; import javax.swing.ScrollPaneConstants; import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; @@ -743,6 +747,7 @@ public class ConfigPanel extends PluginPanel configEntryName.setToolTipText("" + name + ":
" + cid.getItem().description() + ""); item.add(configEntryName, cid.getType() != String.class ? BorderLayout.CENTER : BorderLayout.NORTH); + if (cid.getType() == Stub.class) { Border border = item.getBorder(); @@ -1064,6 +1069,53 @@ public class ConfigPanel extends PluginPanel item.add(button, BorderLayout.EAST); } + + else if (cid.getType() == EnumSet.class) + { + + int displayRows = cid.getItem().displayRows(); + + Class enumType = cid.getItem().enumClass(); + + EnumSet enumSet = configManager.getConfiguration(cd.getGroup().value(), + cid.getItem().keyName(), EnumSet.class); + if (enumSet == null || enumSet.contains(null)) + { + enumSet = EnumSet.noneOf(enumType); + } + JList jList = new JList(enumType.getEnumConstants()); + jList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + + if (!enumSet.isEmpty() && enumSet.size() > 1) + { + int[] selected = new int[enumSet.size()]; + for (int i = 0; i < enumSet.size(); i++) + { + if (enumSet.contains(EnumSet.allOf(enumType).toArray()[i])) + { + selected[i] = Lists.newArrayList(EnumSet.allOf(enumType)).indexOf(enumSet.toArray()[i]); + } + } + jList.setSelectedIndices(selected); + } + if (enumSet.size() == 1) + { + enumSet.forEach(anObject -> jList.setSelectedValue(anObject, true)); + } + jList.setVisibleRowCount(displayRows); + jList.setPrototypeCellValue("XXXXXXXXXX"); + jList.setCellRenderer(new ComboBoxListRenderer()); + jList.setLayoutOrientation(JList.VERTICAL); + jList.setSelectionBackground(Color.decode("708090")); + jList.addListSelectionListener(e -> + changeConfiguration(listItem, config, jList, cd, cid)); + JScrollPane jScrollPane = new JScrollPane(); + jScrollPane.setViewportView(jList); + jScrollPane.setViewportBorder(BorderFactory.createLoweredSoftBevelBorder()); + + item.add(jScrollPane, BorderLayout.SOUTH); + + } mainPanel.add(item); } @@ -1225,6 +1277,57 @@ public class ConfigPanel extends PluginPanel } } } + else if (component instanceof JList) + { + JList jList = (JList) component; + + Class enumType = cid.getItem().enumClass(); + EnumSet enumSet = configManager.getConfiguration(cd.getGroup().value(), + cid.getItem().keyName(), EnumSet.class) != null ? configManager.getConfiguration(cd.getGroup().value(), + cid.getItem().keyName(), EnumSet.class) : EnumSet.noneOf(enumType); + if (enumSet == null || enumSet.contains(null)) + { + enumSet = EnumSet.noneOf(enumType); + } + enumSet.clear(); + + EnumSet finalEnumSet = enumSet; + jList.getSelectedValuesList().forEach(value -> + finalEnumSet.add(Enum.valueOf(cid.getItem().enumClass(), value.toString()))); + + + configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), finalEnumSet); + + for (ConfigItemDescriptor cid2 : cd.getItems()) + { + if (cid2.getItem().hidden() || !cid2.getItem().hide().isEmpty()) + { + List itemHide = Splitter + .onPattern("\\|\\|") + .trimResults() + .omitEmptyStrings() + .splitToList(String.format("%s || %s", cid2.getItem().unhide(), cid2.getItem().hide())); + + if (itemHide.contains(cid.getItem().keyName())) + { + reloadPluginlist(listItem, config, cd); + } + + String changedVal = String.valueOf(( jList.getSelectedValues())); + + if (cid2.getItem().enabledBy().contains(cid.getItem().keyName()) && cid2.getItem().enabledByValue().equals(changedVal)) + { + configManager.setConfiguration(cd.getGroup().value(), cid2.getItem().keyName(), "true"); + reloadPluginlist(listItem, config, cd); + } + else if (cid2.getItem().disabledBy().contains(cid.getItem().keyName()) && cid2.getItem().disabledByValue().equals(changedVal)) + { + configManager.setConfiguration(cd.getGroup().value(), cid2.getItem().keyName(), "false"); + reloadPluginlist(listItem, config, cd); + } + } + } + } else if (component instanceof HotkeyButton) { HotkeyButton hotkeyButton = (HotkeyButton) component; @@ -1326,6 +1429,7 @@ public class ConfigPanel extends PluginPanel return new Dimension(PANEL_WIDTH + SCROLLBAR_WIDTH, super.getPreferredSize().height); } + private static class FixedWidthPanel extends JPanel { @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicationLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicationLocation.java new file mode 100644 index 0000000000..3d63e8faa7 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicationLocation.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2019 RuneLitePlus + * Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file. + * If there are any questions comments, or feedback about this software, please direct all inquiries directly to the file authors: + * ST0NEWALL#9112 + * RuneLitePlus Discord: https://discord.gg/Q7wFtCe + * RuneLitePlus website: https://runelitepl.us + ******************************************************************************/ + +package net.runelite.client.plugins.playerindicators; + +import com.google.common.collect.ImmutableList; + +public enum PlayerIndicationLocation +{ + /** + * Indicates the player by rendering their username above their head + */ + ABOVE_HEAD, + /** + * Indicates the player by outlining the player model's hull. + * NOTE: this may cause FPS lag if enabled for lots of players + */ + HULL, + /** + * Indicates the player by rendering their username on the minimap + */ + MINIMAP, + /** + * Indicates the player by colorizing their right click menu + */ + MENU, + /** + * Indicates the player by rendering a tile marker underneath them + */ + TILE; + + /** + * + */ + public static final ImmutableList SCENE_LOCATIONS = ImmutableList.of(ABOVE_HEAD, HULL); +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java index 060ecf03cc..88f1ff5a64 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java @@ -25,10 +25,12 @@ package net.runelite.client.plugins.playerindicators; import java.awt.Color; +import java.util.EnumSet; import net.runelite.api.ClanMemberRank; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Stub; @ConfigGroup("playerindicators") public interface PlayerIndicatorsConfig extends Config @@ -37,7 +39,8 @@ public interface PlayerIndicatorsConfig extends Config position = 0, keyName = "drawOwnName", name = "Highlight own player", - description = "Configures whether or not your own player should be highlighted" + description = "Configures whether or not your own player should be highlighted", + group = "Yourself" ) default boolean highlightOwnPlayer() { @@ -48,7 +51,8 @@ public interface PlayerIndicatorsConfig extends Config position = 1, keyName = "ownNameColor", name = "Own player color", - description = "Color of your own player" + description = "Color of your own player", + group = "Yourself" ) default Color getOwnPlayerColor() { @@ -57,9 +61,23 @@ public interface PlayerIndicatorsConfig extends Config @ConfigItem( position = 2, + keyName = "selfIndicatorModes", + name = "Indicator Mode", + description = "Location(s) of the overlay", + group = "Yourself", + enumClass = PlayerIndicationLocation.class + ) + default EnumSet selfIndicatorModes() + { + return EnumSet.allOf(PlayerIndicationLocation.class); + } + + @ConfigItem( + position = 3, keyName = "drawFriendNames", name = "Highlight friends", - description = "Configures whether or not friends should be highlighted" + description = "Configures whether or not friends should be highlighted", + group = "Friends" ) default boolean highlightFriends() { @@ -67,10 +85,11 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 3, + position = 4, keyName = "friendNameColor", name = "Friend color", - description = "Color of friend names" + description = "Color of friend names", + group = "Friends" ) default Color getFriendColor() { @@ -78,149 +97,63 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 4, - keyName = "drawClanMemberNames", - name = "Highlight clan members", - description = "Configures whether or clan members should be highlighted" + position = 5, + keyName = "friendIndicatorMode", + name = "Indicator Mode", + description = "Location(s) of the overlay", + group = "Friends", + enumClass = PlayerIndicationLocation.class + ) - default boolean drawClanMemberNames() + default EnumSet friendIndicatorMode() + { + return EnumSet.allOf(PlayerIndicationLocation.class); + } + + @ConfigItem( + position = 6, + keyName = "highlightClan", + name = "Highlight clan members", + description = "Configures whether or clan members should be highlighted", + group = "Clan" + ) + default boolean highlightClan() { return true; } @ConfigItem( - position = 5, + position = 7, keyName = "clanMemberColor", name = "Clan member color", - description = "Color of clan members" + description = "Color of clan members", + group = "Clan" ) - default Color getClanMemberColor() + default Color getClanColor() { return new Color(170, 0, 255); } - @ConfigItem( - position = 6, - keyName = "drawTeamMemberNames", - name = "Highlight team members", - description = "Configures whether or not team members should be highlighted" - ) - default boolean highlightTeamMembers() - { - return false; - } - - @ConfigItem( - position = 7, - keyName = "teamMemberColor", - name = "Team member color", - description = "Color of team members" - ) - default Color getTeamMemberColor() - { - return new Color(19, 110, 247); - } - @ConfigItem( position = 8, - keyName = "drawNonClanMemberNames", - name = "Highlight non-clan members", - description = "Configures whether or not non-clan members should be highlighted" + keyName = "clanIndicatorModes", + name = "Indicator Mode", + description = "Location(s) of the overlay", + group = "Clan", + enumClass = PlayerIndicationLocation.class + ) - default boolean highlightNonClanMembers() + default EnumSet clanIndicatorModes() { - return false; + return EnumSet.allOf(PlayerIndicationLocation.class); } @ConfigItem( position = 9, - keyName = "nonClanMemberColor", - name = "Non-clan member color", - description = "Color of non-clan member names" - ) - default Color getNonClanMemberColor() - { - return Color.RED; - } - - @ConfigItem( - position = 10, - keyName = "drawPlayerTiles", - name = "Draw tiles under players", - description = "Configures whether or not tiles under highlighted players should be drawn" - ) - default boolean drawTiles() - { - return false; - } - - @ConfigItem( - position = 11, - keyName = "playerNamePosition", - name = "Name position", - description = "Configures the position of drawn player names, or if they should be disabled" - ) - default PlayerNameLocation playerNamePosition() - { - return PlayerNameLocation.ABOVE_HEAD; - } - - @ConfigItem( - position = 12, - keyName = "drawMinimapNames", - name = "Draw names on minimap", - description = "Configures whether or not minimap names for players with rendered names should be drawn", - group = "Minimap" - ) - default boolean drawMinimapNames() - { - return false; - } - - @ConfigItem( - position = 13, - keyName = "drawFriendMinimapNames", - name = "Draw Friendnames on minimap", - description = "Configures whether or not minimap names for Friends with rendered names should be drawn", - group = "Minimap", - hidden = true, - unhide = "drawMinimapNames" - ) - default boolean drawFriendMinimapNames() - { - return false; - } - - @ConfigItem( - position = 14, - keyName = "drawClanMinimapNames", - name = "Draw clan Friend names on minimap", - description = "Configures whether or not minimap names for Clan Members with rendered names should be drawn", - group = "Minimap", - hidden = true, - unhide = "drawMinimapNames" - ) - default boolean drawClanMinimapNames() - { - return false; - } - - @ConfigItem( - position = 13, - keyName = "colorPlayerMenu", - name = "Colorize player menu", - description = "Color right click menu for players" - ) - default boolean colorPlayerMenu() - { - return false; - } - - @ConfigItem( - position = 14, keyName = "clanMenuIcons", name = "Show clan ranks", - description = "Add clan rank to right click menu and next to player names" + description = "Add clan rank to right click menu and next to player names", + group = "Clan" ) default boolean showClanRanks() { @@ -228,59 +161,87 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 15, - keyName = "highlightTargets", - name = "Highlight attackable players in wilderness on the minimap", - description = "Highlights players on the minimap that the current player can attack based on combat/wilderness levels", - group = "Target Indicator" + position = 10, + keyName = "drawTeamMemberNames", + name = "Highlight team members", + description = "Configures whether or not team members should be highlighted", + group = "Team" + ) + default boolean highlightTeamMembers() + { + return false; + } + + @ConfigItem( + position = 11, + keyName = "teamMemberColor", + name = "Team member color", + description = "Color of team members", + group = "Team" + ) + default Color getTeamcolor() + { + return new Color(19, 110, 247); + } + + @ConfigItem( + position = 12, + keyName = "teamIndicatorModes", + name = "Indicator Mode", + description = "Location(s) of the overlay", + group = "Team", + enumClass = PlayerIndicationLocation.class + + ) + default EnumSet teamIndicatorModes() + { + return EnumSet.allOf(PlayerIndicationLocation.class); + } + + @ConfigItem( + position = 13, + keyName = "drawTargetsNames", + name = "Highlight attackable targets", + description = "Configures whether or not attackable targets should be highlighted", + group = "Target" ) default boolean highlightTargets() { return false; } -// @ConfigItem( -// position = 16, -// keyName = "highlightOverheadTargets", -// name = "Highlights attackable players over their head", -// description = "Highlights players over their head that the current player can attack based on combat/wilderness levels", -// group = "Target Indicator" -// ) -// default boolean highlightOverheadTargets() -// { -// return false; -// } - @ConfigItem( - position = 17, + position = 14, keyName = "targetColor", - name = "Target color", + name = "Target member color", description = "Color of attackable targets", - group = "Target Indicator" + group = "Target" ) - default Color getTargetColor() + default Color getTargetsColor() { - return Color.RED; + return new Color(19, 110, 247); } @ConfigItem( - position = 18, - keyName = "showCombat", - name = "Show Combat Levels", - description = "Show the combat level of attackable players next to their name.", - group = "Target Indicator" + position = 15, + keyName = "targetsIndicatorModes", + name = "Indicator Mode", + description = "Location(s) of the overlay", + group = "Target", + enumClass = PlayerIndicationLocation.class + ) - default boolean showCombatLevel() + default EnumSet targetsIndicatorModes() { - return false; + return EnumSet.allOf(PlayerIndicationLocation.class); } @ConfigItem( - position = 19, + position = 16, keyName = "showAgility", name = "Show Agility Levels", description = "Show the agility level of attackable players next to their name while in the wilderness.", - group = "Target Indicator" + group = "Target" ) default boolean showAgilityLevel() { @@ -288,11 +249,11 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 20, + position = 17, keyName = "agilityFormat", name = "Format", description = "Whether to show the agility level as text, or as icons (1 skull >= 1st threshold, 2 skulls >= 2nd threshold).", - group = "Target Indicator" + group = "Target" ) default PlayerIndicatorsPlugin.AgilityFormats agilityFormat() { @@ -300,11 +261,11 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 21, + position = 18, keyName = "agilityFirstThreshold", name = "First Threshold", description = "When showing agility as icons, show one icon for agility >= this level.", - group = "Target Indicator" + group = "Target" ) default int agilityFirstThreshold() { @@ -312,11 +273,11 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 22, + position = 19, keyName = "agilitySecondThreshold", name = "Second Threshold", description = "When showing agility as icons, show two icons for agility >= this level.", - group = "Target Indicator" + group = "Target" ) default int agilitySecondThreshold() { @@ -324,11 +285,11 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 23, + position = 20, keyName = "playerSkull", name = "Show Skull Information", - description = "Indicate of the player is skulled.", - group = "Target Indicator" + description = "shows", + group = "Target" ) default boolean playerSkull() { @@ -336,11 +297,11 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 24, + position = 21, keyName = "minimapSkullLocation", name = "Skull Icon Location", description = "The location of the skull icon for skulled players", - group = "Target Indicator" + group = "Target" ) default PlayerIndicatorsPlugin.MinimapSkullLocations skullLocation() { @@ -348,75 +309,90 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 25, - keyName = "skulledTargetsOnly", - name = "Tag Skulls Only", - description = "Only indicate skulled targets (which are also attackable)", - group = "Target Indicator" - ) - default boolean skulledTargetsOnly() - { - return false; - } - - @ConfigItem( - position = 26, + position = 22, keyName = "targetRisk", name = "Indicate Target Risk", description = "Indicates the risk (in K GP) of the target", - group = "Target Indicator" + group = "Target" ) default boolean targetRisk() { return false; } - -/* @ConfigItem( - position = 23, - keyName = "rightClickOverhead", - name = "Add Overheads to Right Click Menu", - description = "Feature shows a player's overhead prayer in the right click menu. Useful for DDs, or extremely crowded areas." - ) - default boolean rightClickOverhead() - { - return false; - }*/ @ConfigItem( - position = 27, - keyName = "useClanchatRanks", - name = "Use Ranks as Callers", - description = "Uses clanchat ranks as the list of callers", - group = "Callers" + position = 23, + keyName = "showCombat", + name = "Show Combat Levels", + description = "Show the combat level of attackable players next to their name.", + group = "Target" ) - default boolean useClanchatRanks() + default boolean showCombatLevel() { return false; } @ConfigItem( - position = 28, - keyName = "callerRank", - name = "Minimum rank for Clan Caller", - description = "Chooses the minimum rank to use as clanchat callers.", - group = "Callers" + position = 24, + keyName = "drawOtherPlayerNames", + name = "Highlight other players", + description = "Configures whether or not other players should be highlighted", + group = "Other" ) - default ClanMemberRank callerRank() + default boolean highlightOtherPlayers() { - return ClanMemberRank.CAPTAIN; + return false; } @ConfigItem( - position = 29, - keyName = "callers", - name = "List of callers to highlight", - description = "Highlights callers, only highlights one at a time. Separate each entry with a comma and enter" + - " in the order you want them highlighted.", + position = 25, + keyName = "otherPlayerColor", + name = "Other player color", + description = "Color of other players' names", + group = "Other" + ) + default Color getOtherColor() + { + return Color.RED; + } + + @ConfigItem( + position = 26, + keyName = "otherIndicatorModes", + name = "Indicator Mode", + description = "Location(s) of the overlay", + group = "Other", + enumClass = PlayerIndicationLocation.class + + ) + default EnumSet otherIndicatorModes() + { + return EnumSet.allOf(PlayerIndicationLocation.class); + } + + + @ConfigItem( + position = 11, + keyName = "playerNamePosition", + name = "Name position", + description = "Configures the position of drawn player names, or if they should be disabled", + parent = "Other Settings" + ) + default PlayerNameLocation playerNamePosition() + { + return PlayerNameLocation.ABOVE_HEAD; + } + + @ConfigItem( + position = 5, + keyName = "callerConfiguration", + name = "Caller Configuration", + description = "", group = "Callers" ) - default String callers() + default Stub callerConfiguration() { - return " "; + return new Stub(); } @ConfigItem( @@ -424,19 +400,73 @@ public interface PlayerIndicatorsConfig extends Config keyName = "highlightCallers", name = "Highlight Callers", description = "Highlights Callers Onscreen", - group = "Callers" + group = "Callers", + parent = "callerConfiguration" ) default boolean highlightCallers() { return false; } + @ConfigItem( + position = 31, + keyName = "useClanchatRanks", + name = "Use Ranks as Callers", + description = "Uses clanchat ranks as the list of callers", + group = "Callers", + parent = "callerConfiguration" + ) + default boolean useClanchatRanks() + { + return false; + } + + @ConfigItem( + position = 32, + keyName = "callerRank", + name = "Minimum rank for Clan Caller", + description = "Chooses the minimum rank to use as clanchat callers.", + group = "Callers", + parent = "callerConfiguration" + ) + default ClanMemberRank callerRank() + { + return ClanMemberRank.CAPTAIN; + } + + @ConfigItem( + position = 33, + keyName = "callers", + name = "List of callers to highlight", + description = "Highlights callers, only highlights one at a time. Separate each entry with a comma and enter" + + " in the order you want them highlighted.", + group = "Callers", + parent = "callerConfiguration" + ) + default String callers() + { + return " "; + } + + @ConfigItem( + position = 5, + keyName = "callerIndicators", + name = "Caller Indicators", + description = "", + group = "Callers" + ) + default Stub callerIndicators() + { + return new Stub(); + } + @ConfigItem( position = 31, keyName = "callerColor", name = "Caller Color", description = "Color of Indicated Callers", - group = "Callers" + group = "Callers", + parent = "callerIndicators" ) default Color callerColor() { @@ -445,9 +475,77 @@ public interface PlayerIndicatorsConfig extends Config @ConfigItem( position = 32, + keyName = "callerHighlightOptions", + name = "Caller indication methods", + description = "Location(s) of the overlay", + group = "Callers", + parent = "callerIndicators", + enumClass = PlayerIndicationLocation.class + ) + default EnumSet callerHighlightOptions() + { + return EnumSet.allOf(PlayerIndicationLocation.class); + } + + @ConfigItem( + position = 5, + keyName = "callerTargetIndicators", + name = "Caller Target Indicators", + description = "", + group = "Callers" + ) + default Stub callerTargetIndicators() + { + return new Stub(); + } + + @ConfigItem( + position = 33, + keyName = "callersTargets", + name = "Calllers' targets", + description = "Highlights the targets of callers", + group = "Callers", + parent = "callerTargetIndicators" + ) + default boolean callersTargets() + { + return true; + } + + @ConfigItem( + position = 34, + keyName = "callerTargetColor", + name = "Callers' targets color", + description = "Color of the the targets of callers", + group = "Callers", + parent = "callerTargetIndicators" + ) + default Color callerTargetColor() + { + return Color.WHITE.darker(); + } + + @ConfigItem( + position = 35, + keyName = "callerTargetHighlightOptions", + name = "Pile indication methods", + description = "How to highlight the callers' target", + group = "Callers", + parent = "callerTargetIndicators", + enumClass = PlayerIndicationLocation.class + ) + default EnumSet callerTargetHighlightOptions() + { + return EnumSet.allOf(PlayerIndicationLocation.class); + } + + + @ConfigItem( + position = 36, keyName = "unchargedGlory", name = "Uncharged Glory Indication", - description = "Indicates if players have an uncharged glory" + description = "Indicates if players have an uncharged glory", + parent = "Other Settings" ) default boolean unchargedGlory() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java index f50e55a576..072566f90f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java @@ -28,6 +28,8 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; +import java.util.Arrays; +import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Player; @@ -59,27 +61,16 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay setPriority(OverlayPriority.HIGH); } - @Override - public Dimension render(Graphics2D graphics) + private void renderMinimapOverlays(Graphics2D graphics, Player actor, PlayerRelation relation) { - playerIndicatorsService.forEachPlayer((player, color) -> + if (!plugin.getLocationHashMap().containsKey(relation)) { - if (plugin.isDrawFriendMinimapNames() && !player.isFriend()) - { - return; - } - if (plugin.isDrawClanMinimapNames() && !player.isClanMember()) - { - return; - } - renderPlayerOverlay(graphics, player, color); - }); - return null; - } + return; + } + final List indicationLocations = Arrays.asList(plugin.getLocationHashMap().get(relation)); + final Color color = plugin.getRelationColorHashMap().get(relation); - private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) - { - if (plugin.isDrawMinimapNames()) + if (indicationLocations.contains(PlayerIndicationLocation.MINIMAP)) { String name = actor.getName().replace('\u00A0', ' '); String tag = ""; @@ -99,31 +90,36 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay { name += "-(" + actor.getCombatLevel() + ")"; } - if (plugin.isDrawMinimapNames()) + if (actor.getSkullIcon() != null && plugin.isPlayerSkull() && actor.getSkullIcon() == SkullIcon.SKULL) { - - if (actor.getSkullIcon() != null && plugin.isPlayerSkull() && actor.getSkullIcon() == SkullIcon.SKULL) + int width = graphics.getFontMetrics().stringWidth(name); + int height = graphics.getFontMetrics().getHeight(); + if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME)) { - int width = graphics.getFontMetrics().stringWidth(name); - int height = graphics.getFontMetrics().getHeight(); - if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME)) - { - OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX() - + width, minimapLocation.getY() - height), - ImageUtil.resizeImage(skullIcon, height, height)); - } - else - { - OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX(), - minimapLocation.getY() - height), - ImageUtil.resizeImage(skullIcon, height, height)); - minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(), - minimapLocation.getY()); - } + OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX() + + width, minimapLocation.getY() - height), + ImageUtil.resizeImage(skullIcon, height, height)); + } + else + { + OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX(), + minimapLocation.getY() - height), + ImageUtil.resizeImage(skullIcon, height, height)); + minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(), + minimapLocation.getY()); } - OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); } + OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); } + } + + } + + @Override + public Dimension render(Graphics2D graphics) + { + playerIndicatorsService.forEachPlayer((player, playerRelation) -> renderMinimapOverlays(graphics, player, playerRelation)); + return null; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 6a5a0e48de..b5372ad0a6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -28,65 +28,48 @@ package net.runelite.client.plugins.playerindicators; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; +import java.awt.Polygon; import java.awt.image.BufferedImage; +import java.util.Arrays; +import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; -import net.runelite.api.ClanMemberRank; +import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; -import net.runelite.api.ItemDefinition; +import net.runelite.api.ItemID; import net.runelite.api.Player; import net.runelite.api.Point; -import net.runelite.api.SkullIcon; import net.runelite.api.Varbits; import net.runelite.api.WorldType; import net.runelite.api.kit.KitType; -import net.runelite.client.game.ClanManager; -import net.runelite.client.game.HiscoreManager; -import net.runelite.client.game.ItemManager; -import net.runelite.client.plugins.friendtagging.FriendTaggingPlugin; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.ImageUtil; -import net.runelite.client.util.PvPUtil; -import net.runelite.http.api.hiscore.HiscoreResult; -import net.runelite.http.api.hiscore.HiscoreSkill; -import net.runelite.http.api.hiscore.HiscoreEndpoint; -import static net.runelite.client.util.StackFormatter.formatNumber; -import net.runelite.api.util.Text; +@Slf4j @Singleton public class PlayerIndicatorsOverlay extends Overlay { private static final int ACTOR_OVERHEAD_TEXT_MARGIN = 40; private static final int ACTOR_HORIZONTAL_TEXT_MARGIN = 10; - - private final PlayerIndicatorsService playerIndicatorsService; - private final ClanManager clanManager; - private final HiscoreManager hiscoreManager; - private final PlayerIndicatorsPlugin plugin; private final BufferedImage agilityIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, "agility.png"); private final BufferedImage noAgilityIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, "no-agility.png"); private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, "skull.png"); + private PlayerIndicatorsPlugin plugin; + private PlayerIndicatorsService playerIndicatorsService; @Inject private Client client; - @Inject - private PlayerIndicatorsPlugin playerIndicatorsPlugin; - @Inject - private ItemManager itemManager; @Inject - private PlayerIndicatorsOverlay(final PlayerIndicatorsPlugin plugin, final PlayerIndicatorsService playerIndicatorsService, - final ClanManager clanManager, final HiscoreManager hiscoreManager) + public PlayerIndicatorsOverlay(PlayerIndicatorsPlugin plugin, PlayerIndicatorsService playerIndicatorsService) { this.plugin = plugin; this.playerIndicatorsService = playerIndicatorsService; - this.clanManager = clanManager; - this.hiscoreManager = hiscoreManager; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.MED); } @@ -94,205 +77,72 @@ public class PlayerIndicatorsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - playerIndicatorsService.forEachPlayer((player, color) -> renderPlayerOverlay(graphics, player, color)); + playerIndicatorsService.forEachPlayer((player, playerRelation) -> drawSceneOverlays(graphics, player, playerRelation)); return null; } - private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) + private void drawSceneOverlays(Graphics2D graphics, Player actor, PlayerRelation relation) { - final PlayerNameLocation drawPlayerNamesConfig = plugin.getPlayerNamePosition(); - if (drawPlayerNamesConfig == PlayerNameLocation.DISABLED) + if (!plugin.getLocationHashMap().containsKey(relation)) { return; } + final List indicationLocations = Arrays.asList(plugin.getLocationHashMap().get(relation)); + final Color color = plugin.getRelationColorHashMap().get(relation); - final int zOffset; - switch (drawPlayerNamesConfig) + if (indicationLocations.contains(PlayerIndicationLocation.ABOVE_HEAD)) { - case MODEL_CENTER: - case MODEL_RIGHT: - zOffset = actor.getLogicalHeight() / 2; - break; - default: - zOffset = actor.getLogicalHeight() + ACTOR_OVERHEAD_TEXT_MARGIN; + String name = actor.getName(); + final boolean skulls = plugin.isPlayerSkull(); + final int zOffset = actor.getLogicalHeight() + ACTOR_OVERHEAD_TEXT_MARGIN; + Point textLocation = actor.getCanvasTextLocation(graphics, name, zOffset); + if (plugin.isShowCombatLevel()) + { + name = name + " (" + actor.getCombatLevel() + ")"; + } + if (plugin.isUnchargedGlory()) + { + if (actor.getPlayerAppearance().getEquipmentId(KitType.AMULET) == ItemID.AMULET_OF_GLORY) + { + name += " (glory)"; + } + } + if (plugin.isPlayerSkull() && actor.getSkullIcon() != null) + { + int x = graphics.getFontMetrics().stringWidth(name); + int y = graphics.getFontMetrics().getHeight(); + OverlayUtil.renderActorTextAndImage(graphics, actor, name, color, + ImageUtil.resizeImage(skullIcon, y, y), 0, x); + } + + else + { + OverlayUtil.renderActorTextOverlay(graphics, actor, name, color); + } } - - String name = Text.sanitize(actor.getName()); - Point textLocation = actor.getCanvasTextLocation(graphics, name, zOffset); - - if (drawPlayerNamesConfig == PlayerNameLocation.MODEL_RIGHT) + if (Arrays.asList(plugin.getLocationHashMap().get(relation)).contains(PlayerIndicationLocation.HULL)) { - textLocation = actor.getCanvasTextLocation(graphics, "", zOffset); - - if (textLocation == null) + if (actor.getConvexHull() == null) { return; } - - textLocation = new Point(textLocation.getX() + ACTOR_HORIZONTAL_TEXT_MARGIN, textLocation.getY()); + OverlayUtil.renderPolygon(graphics, actor.getConvexHull(), color); } - if (textLocation == null) + if (Arrays.asList(plugin.getLocationHashMap().get(relation)).contains(PlayerIndicationLocation.TILE)) { - return; - } - - if (plugin.isShowClanRanks() && actor.isClanMember()) - { - final ClanMemberRank rank = clanManager.getRank(name); - - if (rank != ClanMemberRank.UNRANKED) + final Polygon poly = actor.getCanvasTilePoly(); + if (poly != null) { - final BufferedImage clanchatImage = clanManager.getClanImage(rank); - - if (clanchatImage != null) - { - final int clanImageWidth = clanchatImage.getWidth(); - final int clanImageTextMargin; - final int clanImageNegativeMargin; - - if (drawPlayerNamesConfig == PlayerNameLocation.MODEL_RIGHT) - { - clanImageTextMargin = clanImageWidth; - clanImageNegativeMargin = 0; - } - else - { - clanImageTextMargin = clanImageWidth / 2; - clanImageNegativeMargin = clanImageWidth / 2; - } - - final int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent(); - final Point imageLocation = new Point(textLocation.getX() - clanImageNegativeMargin - 1, textLocation.getY() - textHeight / 2 - clanchatImage.getHeight() / 2); - OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); - - // move text - textLocation = new Point(textLocation.getX() + clanImageTextMargin, textLocation.getY()); - } + OverlayUtil.renderPolygon(graphics, poly, color); } } - - String tag; - String prefix = "tag_"; - if (FriendTaggingPlugin.taggedFriends.containsKey(prefix + name.trim().toLowerCase())) - { - tag = " [" + FriendTaggingPlugin.taggedFriends.get(prefix + name.trim().toLowerCase()) + "] "; - name += tag; - } - - if (plugin.isHighlightCallers() && playerIndicatorsPlugin.isCaller(actor)) - { - name = "[C] " + name; - } - if (plugin.isShowCombatLevel()) - { - name += " (" + actor.getCombatLevel() + ")"; - } - if (plugin.isTargetRisk() && PvPUtil.isAttackable(client, actor) && actor.getPlayerAppearance() != null) - { - long totalValue = 0; - int newValue; - StringBuilder stringBuilder = new StringBuilder(" "); - for (KitType kitType : KitType.values()) - { - if (kitType == KitType.RING || kitType == KitType.AMMUNITION) - { - continue; - } - - ItemDefinition itemComposition = itemManager.getItemDefinition(actor.getPlayerAppearance().getEquipmentId(kitType)); - if (itemComposition != null && itemComposition.getName() != null) - { - totalValue = totalValue + itemComposition.getPrice(); - } - } - newValue = (int) (totalValue / 1000); - if (newValue != 0) - { - stringBuilder.append("(").append(formatNumber(newValue)).append("K)"); - name = name + stringBuilder; - } - } - if (plugin.isUnchargedGlory() && actor.getPlayerAppearance() != null) - { - ItemDefinition itemComposition = itemManager.getItemDefinition(actor.getPlayerAppearance().getEquipmentId(KitType.AMULET)); - if (itemComposition != null && itemComposition.getId() == 1704) //1704 is uncharged glory, to be certain - { - name = name + " cGLORY"; - } - } - - if (actor.getSkullIcon() != null && plugin.isPlayerSkull() && actor.getSkullIcon() == SkullIcon.SKULL) - { - int width = graphics.getFontMetrics().stringWidth(name); - int height = graphics.getFontMetrics().getHeight(); - if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME)) - { - OverlayUtil.renderImageLocation(graphics, new Point(textLocation.getX() - + width, textLocation.getY() - height), - ImageUtil.resizeImage(skullIcon, height, height)); - } - else - { - OverlayUtil.renderImageLocation(graphics, new Point(textLocation.getX(), - textLocation.getY() - height), - ImageUtil.resizeImage(skullIcon, height, height)); - textLocation = new Point(textLocation.getX() + skullIcon.getWidth(), - textLocation.getY()); - } - } - - if (plugin.isShowAgilityLevel() && checkWildy()) - { - final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(actor.getName(), HiscoreEndpoint.NORMAL); - if (hiscoreResult != null) - { - int level = hiscoreResult.getSkill(HiscoreSkill.AGILITY).getLevel(); - if (plugin.getAgilityFormat() == PlayerIndicatorsPlugin.AgilityFormats.ICONS) - { - int width = graphics.getFontMetrics().stringWidth(name); - int height = graphics.getFontMetrics().getHeight(); - if (level >= plugin.getAgilityFirstThreshold()) - { - OverlayUtil.renderImageLocation(graphics, - new Point(textLocation.getX() + 5 + width, - textLocation.getY() - height), - ImageUtil.resizeImage(agilityIcon, height, height)); - } - if (level >= plugin.getAgilitySecondThreshold()) - { - OverlayUtil.renderImageLocation(graphics, - new Point(textLocation.getX() + agilityIcon.getWidth() + width, - textLocation.getY() - height), - ImageUtil.resizeImage(agilityIcon, height, height)); - } - if (level < plugin.getAgilityFirstThreshold()) - { - OverlayUtil.renderImageLocation(graphics, - new Point(textLocation.getX() + 5 + width, - textLocation.getY() - height), - ImageUtil.resizeImage(noAgilityIcon, height, height)); - } - } - else - { - name += " " + level; - - int width = graphics.getFontMetrics().stringWidth(name); - int height = graphics.getFontMetrics().getHeight(); - OverlayUtil.renderImageLocation(graphics, - new Point(textLocation.getX() + 5 + width, - textLocation.getY() - height), - ImageUtil.resizeImage(agilityIcon, height, height)); - } - } - } - - OverlayUtil.renderTextLocation(graphics, textLocation, name, color); } private boolean checkWildy() { return client.getVar(Varbits.IN_WILDERNESS) == 1 || WorldType.isAllPvpWorld(client.getWorldType()); } + + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index 8600678ca6..24f356d1b6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -28,34 +28,27 @@ import com.google.inject.Provides; import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; +import java.util.EnumSet; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; +import net.runelite.api.Actor; import net.runelite.api.ClanMember; import net.runelite.api.ClanMemberRank; import static net.runelite.api.ClanMemberRank.UNRANKED; import net.runelite.api.Client; -import static net.runelite.api.MenuOpcode.FOLLOW; -import static net.runelite.api.MenuOpcode.ITEM_USE_ON_PLAYER; -import static net.runelite.api.MenuOpcode.PLAYER_EIGTH_OPTION; -import static net.runelite.api.MenuOpcode.PLAYER_FIFTH_OPTION; -import static net.runelite.api.MenuOpcode.PLAYER_FIRST_OPTION; -import static net.runelite.api.MenuOpcode.PLAYER_FOURTH_OPTION; -import static net.runelite.api.MenuOpcode.PLAYER_SECOND_OPTION; -import static net.runelite.api.MenuOpcode.PLAYER_SEVENTH_OPTION; -import static net.runelite.api.MenuOpcode.PLAYER_SIXTH_OPTION; -import static net.runelite.api.MenuOpcode.PLAYER_THIRD_OPTION; -import static net.runelite.api.MenuOpcode.RUNELITE; -import static net.runelite.api.MenuOpcode.SPELL_CAST_ON_PLAYER; -import static net.runelite.api.MenuOpcode.TRADE; import net.runelite.api.MenuEntry; +import static net.runelite.api.MenuOpcode.*; import net.runelite.api.Player; import net.runelite.api.events.ClanMemberJoined; import net.runelite.api.events.ClanMemberLeft; import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.InteractingChanged; import net.runelite.api.events.MenuEntryAdded; +import net.runelite.api.util.Text; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.EventBus; import net.runelite.client.game.ClanManager; @@ -73,6 +66,7 @@ import net.runelite.client.util.PvPUtil; @Singleton public class PlayerIndicatorsPlugin extends Plugin { + @Inject private OverlayManager overlayManager; @@ -82,9 +76,6 @@ public class PlayerIndicatorsPlugin extends Plugin @Inject private PlayerIndicatorsOverlay playerIndicatorsOverlay; - @Inject - private PlayerIndicatorsTileOverlay playerIndicatorsTileOverlay; - @Inject private PlayerIndicatorsMinimapOverlay playerIndicatorsMinimapOverlay; @@ -100,41 +91,18 @@ public class PlayerIndicatorsPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private boolean highlightOwnPlayer; @Getter(AccessLevel.PACKAGE) - private Color getOwnPlayerColor; - @Getter(AccessLevel.PACKAGE) private boolean highlightFriends; @Getter(AccessLevel.PACKAGE) - private Color getFriendColor; + private boolean highlightClan; @Getter(AccessLevel.PACKAGE) - private boolean drawClanMemberNames; + private boolean highlightTeam; @Getter(AccessLevel.PACKAGE) - private Color getClanMemberColor; - @Getter(AccessLevel.PACKAGE) - private boolean highlightTeamMembers; - @Getter(AccessLevel.PACKAGE) - private Color getTeamMemberColor; - @Getter(AccessLevel.PACKAGE) - private boolean highlightNonClanMembers; - @Getter(AccessLevel.PACKAGE) - private Color getNonClanMemberColor; - @Getter(AccessLevel.PACKAGE) - private boolean drawTiles; - @Getter(AccessLevel.PACKAGE) - private PlayerNameLocation playerNamePosition; - @Getter(AccessLevel.PACKAGE) - private boolean drawMinimapNames; - @Getter(AccessLevel.PACKAGE) - private boolean drawFriendMinimapNames; - @Getter(AccessLevel.PACKAGE) - private boolean drawClanMinimapNames; - private boolean colorPlayerMenu; + private boolean highlightOther; @Getter(AccessLevel.PACKAGE) private boolean showClanRanks; @Getter(AccessLevel.PACKAGE) private boolean highlightTargets; @Getter(AccessLevel.PACKAGE) - private Color getTargetColor; - @Getter(AccessLevel.PACKAGE) private boolean showAgilityLevel; @Getter(AccessLevel.PACKAGE) private int agilityFirstThreshold; @@ -149,8 +117,6 @@ public class PlayerIndicatorsPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private PlayerIndicatorsPlugin.MinimapSkullLocations skullLocation; @Getter(AccessLevel.PACKAGE) - private boolean skulledTargetsOnly; - @Getter(AccessLevel.PACKAGE) private boolean targetRisk; private boolean useClanchatRanks; private ClanMemberRank callerRank; @@ -158,10 +124,22 @@ public class PlayerIndicatorsPlugin extends Plugin private String configCallers; @Getter(AccessLevel.PACKAGE) private boolean highlightCallers; - @Getter(AccessLevel.PACKAGE) - private Color callerColor; + @Getter + private boolean highlightCallerTargets; @Getter(AccessLevel.PACKAGE) private boolean unchargedGlory; + @Getter + private ConcurrentHashMap callerPiles = new ConcurrentHashMap<>(); + @Getter + private ConcurrentHashMap relationColorHashMap = new ConcurrentHashMap<>(); + + @Getter + private ConcurrentHashMap locationHashMap = new ConcurrentHashMap<>(); + + @Getter + private ConcurrentHashMap colorizedMenus = new ConcurrentHashMap<>(); + @Getter + private List callers = new ArrayList<>(); @Provides PlayerIndicatorsConfig provideConfig(ConfigManager configManager) @@ -172,11 +150,11 @@ public class PlayerIndicatorsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); addSubscriptions(); - + overlayManager.add(playerIndicatorsOverlay); - overlayManager.add(playerIndicatorsTileOverlay); overlayManager.add(playerIndicatorsMinimapOverlay); getCallerList(); } @@ -187,7 +165,6 @@ public class PlayerIndicatorsPlugin extends Plugin eventBus.unregister(this); overlayManager.remove(playerIndicatorsOverlay); - overlayManager.remove(playerIndicatorsTileOverlay); overlayManager.remove(playerIndicatorsMinimapOverlay); } @@ -197,9 +174,43 @@ public class PlayerIndicatorsPlugin extends Plugin eventBus.subscribe(ClanMemberJoined.class, this, this::onClanMemberJoined); eventBus.subscribe(ClanMemberLeft.class, this, this::onClanMemberLeft); eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded); + eventBus.subscribe(InteractingChanged.class, this, this::onInteractingChanged); } - private List callers = new ArrayList<>(); + private void onInteractingChanged(InteractingChanged event) + { + if (!this.highlightCallerTargets || event.getSource() == null) + { + return; + } + if (callers.isEmpty()) + { + return; + } + if (!isCaller(event.getSource())) + { + return; + } + + final Actor caller = event.getSource(); + + if (this.callerPiles.containsKey(caller.getName())) + { + if (event.getTarget() == null) + { + callerPiles.remove(caller.getName()); + } + else + { + callerPiles.replace(caller.getName(), event.getTarget()); + } + } + else + { + callerPiles.put(caller.getName(), event.getTarget()); + } + + } private void onConfigChanged(ConfigChanged event) { @@ -209,11 +220,6 @@ public class PlayerIndicatorsPlugin extends Plugin } updateConfig(); - - if (this.configCallers != null && !this.configCallers.trim().equals("")) - { - getCallerList(); - } } private void onClanMemberJoined(ClanMemberJoined event) @@ -226,49 +232,6 @@ public class PlayerIndicatorsPlugin extends Plugin getCallerList(); } - private void getCallerList() - { - callers.clear(); - if (this.useClanchatRanks && client.getClanMembers() != null) - { - for (ClanMember clanMember : client.getClanMembers()) - { - if (clanMember.getRank().getValue() > this.callerRank.getValue()) - { - callers.add(clanMember.getUsername()); - } - } - } - if (this.configCallers.contains(",")) - { - callers.addAll(Arrays.asList(this.configCallers.split(","))); - } - else - { - if (!this.configCallers.equals("")) - { - callers.add(this.configCallers); - } - } - } - - boolean isCaller(Player player) - { - if (callers != null) - { - for (String name : callers) - { - String finalName = name.toLowerCase().replace("_", " "); - if (player.getName().toLowerCase().replace("_", " ").equals(finalName)) - { - return true; - } - } - } - - return false; - } - private void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { int type = menuEntryAdded.getType(); @@ -309,13 +272,19 @@ public class PlayerIndicatorsPlugin extends Plugin int image2 = -1; Color color = null; - if (this.colorPlayerMenu && client.isFriended(player.getName(), false)) + if (this.highlightFriends && client.isFriended(player.getName(), false)) { - color = this.getFriendColor; + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.FRIEND)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.FRIEND); + } } - else if (this.colorPlayerMenu && player.isClanMember()) + else if (this.highlightClan && player.isClanMember()) { - color = this.getClanMemberColor; + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CLAN)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.CLAN); + } ClanMemberRank rank = clanManager.getRank(player.getName()); if (rank != UNRANKED) @@ -323,64 +292,55 @@ public class PlayerIndicatorsPlugin extends Plugin image = clanManager.getIconNumber(rank); } } - else if (this.colorPlayerMenu && player.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) + else if (this.highlightTeam && player.getTeam() > 0 && (localPlayer != null ? localPlayer.getTeam() : -1) == player.getTeam()) { - color = this.getTeamMemberColor; + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TEAM)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.TEAM); + } } - else if (this.highlightNonClanMembers && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) + else if (this.highlightOther && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) { - color = this.getNonClanMemberColor; + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.OTHER)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.OTHER); + } } - else if (this.colorPlayerMenu && !player.isClanMember() && client.isFriended(player.getName(), false) && PvPUtil.isAttackable(client, player)) + else if (this.highlightTargets && !player.isClanMember() && !client.isFriended(player.getName(), + false) && PvPUtil.isAttackable(client, player)) { - color = this.getTargetColor; + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TARGET)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.TARGET); + } } - else if (this.colorPlayerMenu && PvPUtil.isAttackable(client, player) && !player.isClanMember() && !player.isFriend()) + else if (this.highlightCallers && isCaller(player)) { - color = this.getTargetColor; + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.CALLER); + } } -/* if (config.rightClickOverhead() && !player.isClanMember() && player.getOverheadIcon() != null) + else if (this.highlightCallerTargets && isPile(player)) { - if (player.getOverheadIcon().equals(HeadIcon.MAGIC)) + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER_TARGET)).contains(PlayerIndicationLocation.MENU)) { - image = 29; + color = relationColorHashMap.get(PlayerRelation.CALLER_TARGET); } - else if (player.getOverheadIcon().equals(HeadIcon.RANGED)) - { - image = 30; - } - else if (player.getOverheadIcon().equals(HeadIcon.MELEE)) - { - image = 31; - } - else if (player.getOverheadIcon().equals(HeadIcon.REDEMPTION)) - { - image = 32; - } - else if (player.getOverheadIcon().equals(HeadIcon.RETRIBUTION)) - { - image = 33; - } - else if (player.getOverheadIcon().equals(HeadIcon.SMITE)) - { - image = 34; - } - }*/ + } + if (this.playerSkull && !player.isClanMember() && player.getSkullIcon() != null) { image2 = 35; } - if (this.colorPlayerMenu && this.highlightCallers && this.isCaller(player)) - { - color = this.callerColor; - } + if (image != -1 || color != null) { MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; - if (color != null && this.colorPlayerMenu) + if (color != null) { // strip out existing this.callerRank.getValue()) + { + callers.add(Text.standardize(clanMember.getUsername())); + } + } + } + if (this.configCallers.contains(",")) + { + callers.addAll(Arrays.asList(this.configCallers.split(","))); + } + else + { + if (!this.configCallers.equals("")) + { + callers.add(this.configCallers); + } + } + } + + /** + * Checks if a player is a caller + * @param player The player to check + * @return true if they are, false otherwise + */ + public boolean isCaller(Actor player) + { + if (player == null || player.getName() == null) + { + return false; + } + if (callers.size() > 0) + { + for (String name : callers) + { + String finalName = Text.standardize(name.trim()); + if (Text.standardize(player.getName()).equals(finalName)) + { + return true; + } + } + } + + return false; + } + + /** + * Checks if a player is currently a target of any of the current callers + * @param actor The player to check + * @return true if they are a target, false otherwise + */ + public boolean isPile(Actor actor) + { + if (!(actor instanceof Player)) + { + return false; + } + if (callerPiles.containsValue(actor)) + { + return true; + } + return false; + } + + + private void updateConfig() + { + locationHashMap.clear(); + relationColorHashMap.clear(); + this.highlightOwnPlayer = config.highlightOwnPlayer(); + if (this.highlightOwnPlayer) + { + relationColorHashMap.put(PlayerRelation.SELF, config.getOwnPlayerColor()); + locationHashMap.put(PlayerRelation.SELF, EnumSet.copyOf(config.selfIndicatorModes()).toArray()); + } + + this.highlightFriends = config.highlightFriends(); + if (this.highlightFriends) + { + relationColorHashMap.put(PlayerRelation.FRIEND, config.getFriendColor()); + locationHashMap.put(PlayerRelation.FRIEND, config.friendIndicatorMode().toArray()); + } + + this.highlightClan = config.highlightClan(); + if (this.highlightClan) + { + relationColorHashMap.put(PlayerRelation.CLAN, config.getClanColor()); + locationHashMap.put(PlayerRelation.CLAN, config.clanIndicatorModes().toArray()); + } + + this.highlightTeam = config.highlightTeamMembers(); + if (this.highlightTeam) + { + relationColorHashMap.put(PlayerRelation.TEAM, config.getTeamcolor()); + locationHashMap.put(PlayerRelation.TEAM, config.teamIndicatorModes().toArray()); + } + + this.highlightOther = config.highlightOtherPlayers(); + if (this.highlightOther) + { + relationColorHashMap.put(PlayerRelation.OTHER, config.getOtherColor()); + locationHashMap.put(PlayerRelation.OTHER, EnumSet.copyOf(config.otherIndicatorModes()).toArray()); + } + + this.highlightTargets = config.highlightTargets(); + if (this.highlightTargets) + { + relationColorHashMap.put(PlayerRelation.TARGET, config.getTargetsColor()); + locationHashMap.put(PlayerRelation.TARGET, config.targetsIndicatorModes().toArray()); + } + + this.highlightCallers = config.highlightCallers(); + if (this.highlightCallers) + { + this.callerRank = config.callerRank(); + + this.configCallers = config.callers(); + relationColorHashMap.put(PlayerRelation.CALLER, config.callerColor()); + locationHashMap.put(PlayerRelation.CALLER, config.callerHighlightOptions().toArray()); + getCallerList(); + } + + this.highlightCallerTargets = config.callersTargets(); + if (this.highlightCallerTargets) + { + relationColorHashMap.put(PlayerRelation.CALLER_TARGET, config.callerTargetColor()); + locationHashMap.put(PlayerRelation.CALLER_TARGET, config.callerTargetHighlightOptions().toArray()); + } + + this.showClanRanks = config.showClanRanks(); + this.showCombatLevel = config.showCombatLevel(); + this.showAgilityLevel = config.showAgilityLevel(); + this.agilityFirstThreshold = config.agilityFirstThreshold(); + this.agilitySecondThreshold = config.agilitySecondThreshold(); + this.agilityFormat = config.agilityFormat(); + this.playerSkull = config.playerSkull(); + this.skullLocation = config.skullLocation(); + this.targetRisk = config.targetRisk(); + this.useClanchatRanks = config.useClanchatRanks(); + this.unchargedGlory = config.unchargedGlory(); + } + public enum MinimapSkullLocations { BEFORE_NAME, @@ -418,42 +530,6 @@ public class PlayerIndicatorsPlugin extends Plugin TEXT, ICONS } - - private void updateConfig() - { - this.highlightOwnPlayer = config.highlightOwnPlayer(); - this.getOwnPlayerColor = config.getOwnPlayerColor(); - this.highlightFriends = config.highlightFriends(); - this.getFriendColor = config.getFriendColor(); - this.drawClanMemberNames = config.drawClanMemberNames(); - this.getClanMemberColor = config.getClanMemberColor(); - this.highlightTeamMembers = config.highlightTeamMembers(); - this.getTeamMemberColor = config.getTeamMemberColor(); - this.highlightNonClanMembers = config.highlightNonClanMembers(); - this.getNonClanMemberColor = config.getNonClanMemberColor(); - this.drawTiles = config.drawTiles(); - this.playerNamePosition = config.playerNamePosition(); - this.drawMinimapNames = config.drawMinimapNames(); - this.drawFriendMinimapNames = config.drawFriendMinimapNames(); - this.drawClanMinimapNames = config.drawClanMinimapNames(); - this.colorPlayerMenu = config.colorPlayerMenu(); - this.showClanRanks = config.showClanRanks(); - this.highlightTargets = config.highlightTargets(); - this.getTargetColor = config.getTargetColor(); - this.showCombatLevel = config.showCombatLevel(); - this.showAgilityLevel = config.showAgilityLevel(); - this.agilityFirstThreshold = config.agilityFirstThreshold(); - this.agilitySecondThreshold = config.agilitySecondThreshold(); - this.agilityFormat = config.agilityFormat(); - this.playerSkull = config.playerSkull(); - this.skullLocation = config.skullLocation(); - this.skulledTargetsOnly = config.skulledTargetsOnly(); - this.targetRisk = config.targetRisk(); - this.useClanchatRanks = config.useClanchatRanks(); - this.callerRank = config.callerRank(); - this.configCallers = config.callers(); - this.highlightCallers = config.highlightCallers(); - this.callerColor = config.callerColor(); - this.unchargedGlory = config.unchargedGlory(); - } + + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index 54a2589782..3be0a5435a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -24,10 +24,14 @@ */ package net.runelite.client.plugins.playerindicators; -import java.awt.Color; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; import java.util.function.BiConsumer; +import java.util.function.Predicate; import javax.inject.Inject; import javax.inject.Singleton; +import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.Player; import net.runelite.client.util.PvPUtil; @@ -38,72 +42,93 @@ public class PlayerIndicatorsService private final Client client; private final PlayerIndicatorsPlugin plugin; + public Predicate self; + public Predicate friend; + public Predicate clan; + public Predicate team; + public Predicate target; + public Predicate other; + public Predicate caller; + public Predicate callerTarget; + + + private List piles = new ArrayList<>(); + + @Inject private PlayerIndicatorsService(final Client client, final PlayerIndicatorsPlugin plugin) { this.client = client; this.plugin = plugin; + + self = (player) -> Objects.equals(client.getLocalPlayer(), player); + friend = (player) -> (!player.equals(client.getLocalPlayer()) && client.isFriended(player.getName(), false)); + clan = Player::isClanMember; + team = (player) -> (Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0 && + client.getLocalPlayer().getTeam() == player.getTeam()); + target = (player) -> PvPUtil.isAttackable(client, player); + other = Objects::nonNull; + caller = plugin::isCaller; + callerTarget = piles::contains; } - public void forEachPlayer(final BiConsumer consumer) + + public void forEachPlayer(final BiConsumer consumer) { - if (!plugin.isHighlightOwnPlayer() && !plugin.isDrawClanMemberNames() - && !plugin.isHighlightFriends() && !plugin.isHighlightNonClanMembers() && !plugin.isHighlightTargets() && !plugin.isHighlightCallers() && !plugin.isHighlightTeamMembers()) + if (!highlight()) { return; } + piles.clear(); - final Player localPlayer = client.getLocalPlayer(); - - for (Player player : client.getPlayers()) + final List players = client.getPlayers(); + if (plugin.isHighlightOwnPlayer()) { - if (player == null || player.getName() == null) + players.stream().filter(self).forEach(p -> consumer.accept(p, PlayerRelation.SELF)); + } + if (plugin.isHighlightFriends()) + { + players.stream().filter(friend.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.FRIEND)); + } + if (plugin.isHighlightClan()) + { + players.stream().filter(clan.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.CLAN)); + } + if (plugin.isHighlightTeam()) + { + players.stream().filter(team.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.TEAM)); + } + if (plugin.isHighlightTargets()) + { + players.stream().filter(target.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.TARGET)); + } + if (plugin.isHighlightOther()) + { + players.stream().filter(other.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.OTHER)); + } + if (plugin.isHighlightCallers()) + { + players.stream().filter(caller).forEach(p -> { - continue; - } - - boolean isClanMember = player.isClanMember(); - - if (player.equals(localPlayer)) - { - if (plugin.isHighlightOwnPlayer()) + consumer.accept(p, PlayerRelation.CALLER); + if (p.getInteracting() != null) { - consumer.accept(player, plugin.getGetOwnPlayerColor()); + piles.add(p.getInteracting()); } - } - else if (plugin.isHighlightFriends() && client.isFriended(player.getName(), false)) - { - consumer.accept(player, plugin.getGetFriendColor()); - } - else if (plugin.isDrawClanMemberNames() && isClanMember) - { - consumer.accept(player, plugin.getGetClanMemberColor()); - } - else if (plugin.isHighlightTeamMembers() && localPlayer.getTeam() > 0 && - localPlayer.getTeam() == player.getTeam()) - { - consumer.accept(player, plugin.getGetTeamMemberColor()); - } - else if (plugin.isHighlightNonClanMembers() && !isClanMember) - { - consumer.accept(player, plugin.getGetNonClanMemberColor()); - } - else if (plugin.isHighlightTargets() && PvPUtil.isAttackable(client, player) && - !client.isFriended(player.getName(), false) && !player.isClanMember()) - { - if (plugin.isSkulledTargetsOnly() && player.getSkullIcon() != null) - { - consumer.accept(player, plugin.getGetTargetColor()); - } - else if (!plugin.isSkulledTargetsOnly()) - { - consumer.accept(player, plugin.getGetTargetColor()); - } - } - if (plugin.isHighlightCallers() && plugin.getConfigCallers() != null && plugin.isCaller(player)) - { - consumer.accept(player, plugin.getCallerColor()); - } + }); + } + if (plugin.isHighlightCallerTargets()) + { + players.stream().filter(callerTarget).forEach(p -> + consumer.accept(p, PlayerRelation.CALLER_TARGET)); } } + + + private boolean highlight() + { + return plugin.isHighlightOwnPlayer() || plugin.isHighlightClan() + || plugin.isHighlightFriends() || plugin.isHighlightOther() || plugin.isHighlightTargets() + || plugin.isHighlightCallers() || plugin.isHighlightTeam() || plugin.isHighlightCallerTargets(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsTileOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsTileOverlay.java deleted file mode 100644 index c3b35626bf..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsTileOverlay.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2018, Kamiel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.runelite.client.plugins.playerindicators; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Polygon; -import javax.inject.Inject; -import javax.inject.Singleton; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; - -@Singleton -public class PlayerIndicatorsTileOverlay extends Overlay -{ - private final PlayerIndicatorsService playerIndicatorsService; - private final PlayerIndicatorsPlugin playerIndicatorsPlugin; - - @Inject - private PlayerIndicatorsTileOverlay(final PlayerIndicatorsService playerIndicatorsService, final PlayerIndicatorsPlugin plugin) - { - this.playerIndicatorsService = playerIndicatorsService; - this.playerIndicatorsPlugin = plugin; - setLayer(OverlayLayer.ABOVE_SCENE); - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.MED); - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (!playerIndicatorsPlugin.isDrawTiles() /*&& !config.drawPlayerHull()*/) - { - return null; - } - else - { - playerIndicatorsService.forEachPlayer((player, color) -> - { - final Polygon poly = player.getCanvasTilePoly(); - - if (poly != null) - { - OverlayUtil.renderPolygon(graphics, poly, color); - } - }); - } - return null; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerRelation.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerRelation.java new file mode 100644 index 0000000000..b1e6f82c7d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerRelation.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2019 RuneLitePlus + * Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file. + * If there are any questions comments, or feedback about this software, please direct all inquiries directly to the file authors: + * ST0NEWALL#9112 + * RuneLitePlus Discord: https://discord.gg/Q7wFtCe + * RuneLitePlus website: https://runelitepl.us + ******************************************************************************/ + +package net.runelite.client.plugins.playerindicators; + +public enum PlayerRelation +{ + SELF, + FRIEND, + CLAN, + TEAM, + TARGET, + OTHER, + CALLER, + CALLER_TARGET +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/ComboBoxListRenderer.java b/runelite-client/src/main/java/net/runelite/client/ui/components/ComboBoxListRenderer.java index d2154c893c..5a457aeb10 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/ComboBoxListRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/ComboBoxListRenderer.java @@ -59,7 +59,7 @@ public final class ComboBoxListRenderer extends JLabel implements ListCellRender setForeground(ColorScheme.LIGHT_GRAY_COLOR); } - setBorder(new EmptyBorder(5, 5, 5, 0)); + setBorder(new EmptyBorder(5, 10, 5, 10)); setIcon(null); String text; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java index 9acdf92131..df910aebcb 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java @@ -139,6 +139,15 @@ public class OverlayUtil } } + public static void renderActorTextOverlay(Graphics2D graphics, Actor actor, String text, Color color) + { + Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight() + 40); + if (textLocation != null) + { + renderTextLocation(graphics, textLocation, text, color); + } + } + public static void renderActorOverlayImage(Graphics2D graphics, Actor actor, BufferedImage image, Color color, int zOffset) { Polygon poly = actor.getCanvasTilePoly();