From cbb23cf3019a7bd0b3993784ed666e2008517a22 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 28 May 2018 13:52:41 -0400 Subject: [PATCH] runelite-client: add chat color config --- .../net/runelite/client/RuneLiteModule.java | 8 + .../net/runelite/client/chat/ChatColor.java | 18 +- .../client/chat/ChatMessageManager.java | 416 +++++++++++++++- .../client/config/ChatColorConfig.java | 459 ++++++++++++++++++ .../client/plugins/config/ConfigPanel.java | 24 +- .../client/plugins/config/ConfigPlugin.java | 6 +- 6 files changed, 903 insertions(+), 28 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java b/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java index 3110e16736..0a5e8ae515 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java @@ -35,6 +35,7 @@ import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.client.account.SessionManager; import net.runelite.client.chat.ChatMessageManager; +import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ConfigManager; import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.game.ItemManager; @@ -73,6 +74,13 @@ public class RuneLiteModule extends AbstractModule return configManager.getConfig(RuneLiteConfig.class); } + @Provides + @Singleton + ChatColorConfig provideChatColorConfig(ConfigManager configManager) + { + return configManager.getConfig(ChatColorConfig.class); + } + @Provides @Singleton EventBus provideEventBus() diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java index c47266b65b..0a6dfdfaf2 100644 --- a/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java +++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java @@ -25,16 +25,28 @@ package net.runelite.client.chat; import java.awt.Color; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @Data -@AllArgsConstructor -@EqualsAndHashCode(exclude = "color") +@EqualsAndHashCode(exclude = {"color", "isDefault"}) public class ChatColor { private ChatColorType type; private Color color; private boolean transparent; + private boolean isDefault; + + public ChatColor(ChatColorType type, Color color, boolean transparent) + { + this(type, color, transparent, false); + } + + public ChatColor(ChatColorType type, Color color, boolean transparent, boolean isDefault) + { + this.type = type; + this.color = color; + this.transparent = transparent; + this.isDefault = isDefault; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java index 08e02a904f..871c05e464 100644 --- a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java +++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java @@ -26,14 +26,14 @@ package net.runelite.client.chat; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import com.google.common.eventbus.Subscribe; +import java.awt.Color; import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; +import java.util.Collection; import java.util.Objects; import java.util.Queue; -import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.atomic.AtomicReference; @@ -46,24 +46,30 @@ import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.MessageNode; import net.runelite.api.Varbits; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ResizeableChanged; +import net.runelite.api.events.SetMessage; import net.runelite.api.events.VarbitChanged; +import net.runelite.client.config.ChatColorConfig; @Slf4j @Singleton public class ChatMessageManager { - private final Map> colorCache = new HashMap<>(); + private final Multimap colorCache = HashMultimap.create(); private final Provider clientProvider; private final ScheduledExecutorService executor; + private final ChatColorConfig chatColorConfig; private int transparencyVarbit = -1; private final Queue queuedMessages = new ConcurrentLinkedQueue<>(); @Inject - public ChatMessageManager(Provider clientProvider, ScheduledExecutorService executor) + private ChatMessageManager(Provider clientProvider, ScheduledExecutorService executor, + ChatColorConfig chatColorConfig) { this.clientProvider = clientProvider; this.executor = executor; + this.chatColorConfig = chatColorConfig; } @Subscribe @@ -84,14 +90,390 @@ public class ChatMessageManager refreshAll(); } - public ChatMessageManager cacheColor(final ChatColor chatColor, final ChatMessageType... types) + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("textrecolor")) + { + loadColors(); + refreshAll(); + } + } + + @Subscribe + public void onSetMessage(SetMessage setMessage) + { + final Client client = clientProvider.get(); + MessageNode messageNode = setMessage.getMessageNode(); + ChatMessageType chatMessageType = setMessage.getType(); + + boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1; + Color usernameColor = null; + Color senderColor = null; + + switch (chatMessageType) + { + case PRIVATE_MESSAGE_RECEIVED_MOD: + case PRIVATE_MESSAGE_RECEIVED: + case PRIVATE_MESSAGE_SENT: + usernameColor = isChatboxTransparent ? chatColorConfig.transparentPrivateUsernames() : chatColorConfig.opaquePrivateUsernames(); + break; + + case TRADE: + case AUTOCHAT: + case PUBLIC: + usernameColor = isChatboxTransparent ? chatColorConfig.transparentUsername() : chatColorConfig.opaqueUsername(); + break; + + case CLANCHAT: + usernameColor = isChatboxTransparent ? chatColorConfig.transparentClanUsernames() : chatColorConfig.opaqueClanUsernames(); + break; + } + + senderColor = isChatboxTransparent ? chatColorConfig.transparentClanChannelName() : chatColorConfig.opaqueClanChannelName(); + + if (usernameColor != null) + { + messageNode.setName(wrapTextWithColour(messageNode.getName(), usernameColor)); + } + + String sender = setMessage.getSender(); + if (senderColor != null && !Strings.isNullOrEmpty(sender)) + { + messageNode.setSender(wrapTextWithColour(sender, senderColor)); + } + + final Collection chatColors = colorCache.get(chatMessageType); + for (ChatColor chatColor : chatColors) + { + if (chatColor.isTransparent() != isChatboxTransparent || chatColor.getType() != ChatColorType.NORMAL || chatColor.isDefault()) + { + continue; + } + + messageNode.setValue(wrapTextWithColour(messageNode.getValue(), chatColor.getColor())); + break; + } + } + + private static String wrapTextWithColour(String text, Color colour) + { + return "" + text + ""; + } + + private static Color getDefaultColor(ChatMessageType type, boolean transparent) + { + if (!transparent) + { + switch (type) + { + case PUBLIC: + return Color.decode("#0000FF"); + case PRIVATE_MESSAGE_SENT: + case PRIVATE_MESSAGE_RECEIVED: + return Color.decode("#00FFFF"); + case CLANCHAT: + return Color.decode("#7F0000"); + } + } + else + { + switch (type) + { + case PUBLIC: + return Color.decode("#9090FF"); + case PRIVATE_MESSAGE_SENT: + case PRIVATE_MESSAGE_RECEIVED: + return Color.decode("#00FFFF"); + case CLANCHAT: + return Color.decode("#7F0000"); + } + } + + return null; + } + + private void loadColors() + { + colorCache.clear(); + + // Apply defaults + for (ChatMessageType chatMessageType : ChatMessageType.values()) + { + Color defaultTransparent = getDefaultColor(chatMessageType, true); + if (defaultTransparent != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, defaultTransparent, true, true), chatMessageType); + } + + Color defaultOpaque = getDefaultColor(chatMessageType, false); + if (defaultOpaque != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, defaultOpaque, false, true), chatMessageType); + } + } + + if (chatColorConfig.opaquePublicChat() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaquePublicChat(), false), + ChatMessageType.PUBLIC); + } + if (chatColorConfig.opaquePublicChatHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaquePublicChatHighlight(), false), + ChatMessageType.PUBLIC); + } + if (chatColorConfig.opaquePrivateMessageSent() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaquePrivateMessageSent(), false), + ChatMessageType.PRIVATE_MESSAGE_SENT); + } + if (chatColorConfig.opaquePrivateMessageSentHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaquePrivateMessageSentHighlight(), false), + ChatMessageType.PRIVATE_MESSAGE_SENT); + } + if (chatColorConfig.opaquePrivateMessageReceived() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaquePrivateMessageReceived(), false), + ChatMessageType.PRIVATE_MESSAGE_RECEIVED); + } + if (chatColorConfig.opaquePrivateMessageReceivedHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaquePrivateMessageReceivedHighlight(), false), + ChatMessageType.PRIVATE_MESSAGE_RECEIVED); + } + if (chatColorConfig.opaqueClanChatInfo() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueClanChatInfo(), false), + ChatMessageType.CLANCHAT_INFO); + } + if (chatColorConfig.opaqueClanChatMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueClanChatMessage(), false), + ChatMessageType.CLANCHAT); + } + if (chatColorConfig.opaqueClanChatMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueClanChatMessageHighlight(), false), + ChatMessageType.CLANCHAT); + } + if (chatColorConfig.opaqueAutochatMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueAutochatMessage(), false), + ChatMessageType.AUTOCHAT); + } + if (chatColorConfig.opaqueAutochatMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueAutochatMessageHighlight(), false), + ChatMessageType.AUTOCHAT); + } + if (chatColorConfig.opaqueTradeChatMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueTradeChatMessage(), false), + ChatMessageType.TRADE); + } + if (chatColorConfig.opaqueTradeChatMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueTradeChatMessageHighlight(), false), + ChatMessageType.TRADE); + } + if (chatColorConfig.opaqueServerMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueServerMessage(), false), + ChatMessageType.SERVER); + } + if (chatColorConfig.opaqueServerMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueServerMessageHighlight(), false), + ChatMessageType.SERVER); + } + if (chatColorConfig.opaqueGameMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueGameMessage(), false), + ChatMessageType.GAME); + } + if (chatColorConfig.opaqueGameMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueGameMessageHighlight(), false), + ChatMessageType.GAME); + } + if (chatColorConfig.opaqueExamine() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueExamine(), false), + ChatMessageType.EXAMINE_OBJECT); + } + if (chatColorConfig.opaqueExamineHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueExamineHighlight(), false), + ChatMessageType.EXAMINE_OBJECT); + } + if (chatColorConfig.opaqueExamine() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueExamine(), false), + ChatMessageType.EXAMINE_NPC); + } + if (chatColorConfig.opaqueExamineHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueExamineHighlight(), false), + ChatMessageType.EXAMINE_NPC); + } + if (chatColorConfig.opaqueExamine() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueExamine(), false), + ChatMessageType.EXAMINE_ITEM); + } + if (chatColorConfig.opaqueExamineHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueExamineHighlight(), false), + ChatMessageType.EXAMINE_ITEM); + } + if (chatColorConfig.opaqueFiltered() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.opaqueFiltered(), false), + ChatMessageType.FILTERED); + } + if (chatColorConfig.opaqueFilteredHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.opaqueFilteredHighlight(), false), + ChatMessageType.FILTERED); + } + + //Transparent Chat Colours + if (chatColorConfig.transparentPublicChat() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentPublicChat(), true), + ChatMessageType.PUBLIC); + } + if (chatColorConfig.transparentPublicChatHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentPublicChatHighlight(), true), + ChatMessageType.PUBLIC); + } + if (chatColorConfig.transparentPrivateMessageSent() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentPrivateMessageSent(), true), + ChatMessageType.PRIVATE_MESSAGE_SENT); + } + if (chatColorConfig.transparentPrivateMessageSentHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentPrivateMessageSentHighlight(), true), + ChatMessageType.PRIVATE_MESSAGE_SENT); + } + if (chatColorConfig.transparentPrivateMessageReceived() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentPrivateMessageReceived(), true), + ChatMessageType.PRIVATE_MESSAGE_RECEIVED); + } + if (chatColorConfig.transparentPrivateMessageReceivedHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentPrivateMessageReceivedHighlight(), true), + ChatMessageType.PRIVATE_MESSAGE_RECEIVED); + } + if (chatColorConfig.transparentClanChatInfo() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentClanChatInfo(), true), + ChatMessageType.CLANCHAT_INFO); + } + if (chatColorConfig.transparentClanChatMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentClanChatMessage(), true), + ChatMessageType.CLANCHAT); + } + if (chatColorConfig.transparentClanChatMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentClanChatMessageHighlight(), true), + ChatMessageType.CLANCHAT); + } + if (chatColorConfig.transparentAutochatMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentAutochatMessage(), true), + ChatMessageType.AUTOCHAT); + } + if (chatColorConfig.transparentAutochatMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentAutochatMessageHighlight(), true), + ChatMessageType.AUTOCHAT); + } + if (chatColorConfig.transparentTradeChatMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentTradeChatMessage(), true), + ChatMessageType.TRADE); + } + if (chatColorConfig.transparentTradeChatMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentTradeChatMessageHighlight(), true), + ChatMessageType.TRADE); + } + if (chatColorConfig.transparentServerMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentServerMessage(), true), + ChatMessageType.SERVER); + } + if (chatColorConfig.transparentServerMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentServerMessageHighlight(), true), + ChatMessageType.SERVER); + } + if (chatColorConfig.transparentGameMessage() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentGameMessage(), true), + ChatMessageType.GAME); + } + if (chatColorConfig.transparentGameMessageHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentGameMessageHighlight(), true), + ChatMessageType.GAME); + } + if (chatColorConfig.transparentExamine() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentExamine(), true), + ChatMessageType.EXAMINE_OBJECT); + } + if (chatColorConfig.transparentExamineHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentExamineHighlight(), true), + ChatMessageType.EXAMINE_OBJECT); + } + if (chatColorConfig.transparentExamine() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentExamine(), true), + ChatMessageType.EXAMINE_NPC); + } + if (chatColorConfig.transparentExamineHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentExamineHighlight(), true), + ChatMessageType.EXAMINE_NPC); + } + if (chatColorConfig.transparentExamine() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentExamine(), true), + ChatMessageType.EXAMINE_ITEM); + } + if (chatColorConfig.transparentExamineHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentExamineHighlight(), true), + ChatMessageType.EXAMINE_ITEM); + } + if (chatColorConfig.transparentFiltered() != null) + { + cacheColor(new ChatColor(ChatColorType.NORMAL, chatColorConfig.transparentFiltered(), true), + ChatMessageType.FILTERED); + } + if (chatColorConfig.transparentFilteredHighlight() != null) + { + cacheColor(new ChatColor(ChatColorType.HIGHLIGHT, chatColorConfig.transparentFilteredHighlight(), true), + ChatMessageType.FILTERED); + } + } + + private ChatMessageManager cacheColor(final ChatColor chatColor, final ChatMessageType... types) { for (ChatMessageType chatMessageType : types) { - colorCache.putIfAbsent(chatMessageType, new HashSet<>()); - final Set chatColors = colorCache.get(chatMessageType); - chatColors.remove(chatColor); - chatColors.add(chatColor); + // color is excluded from equals/hashCode on ChatColor + colorCache.remove(chatMessageType, chatColor); + colorCache.put(chatMessageType, chatColor); } return this; @@ -117,10 +499,10 @@ public class ChatMessageManager // this updates chat cycle client.addChatMessage( - message.getType(), - MoreObjects.firstNonNull(message.getName(), ""), - MoreObjects.firstNonNull(message.getValue(), message.getRuneLiteFormattedMessage()), - message.getSender()); + message.getType(), + MoreObjects.firstNonNull(message.getName(), ""), + MoreObjects.firstNonNull(message.getValue(), message.getRuneLiteFormattedMessage()), + message.getSender()); // Get last message from line buffer (the one we just added) final ChatLineBuffer chatLineBuffer = client.getChatLineMap().get(message.getType().getType()); @@ -141,7 +523,7 @@ public class ChatMessageManager final Client client = clientProvider.get(); final boolean transparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) != 0; - final Set chatColors = colorCache.get(target.getType()); + final Collection chatColors = colorCache.get(target.getType()); // If we do not have any colors cached, simply set clean message if (chatColors == null || chatColors.isEmpty()) @@ -155,7 +537,7 @@ public class ChatMessageManager private String recolorMessage(boolean transparent, String message, ChatMessageType messageType) { - final Set chatColors = colorCache.get(messageType); + final Collection chatColors = colorCache.get(messageType); final AtomicReference resultMessage = new AtomicReference<>(message); // Replace custom formatting with actual colors diff --git a/runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java b/runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java new file mode 100644 index 0000000000..dd3f4aca9f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/config/ChatColorConfig.java @@ -0,0 +1,459 @@ +/* + * Copyright (c) 2018, Hydrox6 + * 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.awt.Color; + +@ConfigGroup( + keyName = "textrecolor", + name = "Chat Text Recolor", + description = "Configuration for chat text recoloring" +) +public interface ChatColorConfig extends Config +{ + @ConfigItem( + position = 31, + keyName = "opaquePublicChat", + name = "Public chat", + description = "Color of Public chat" + ) + Color opaquePublicChat(); + + @ConfigItem( + position = 32, + keyName = "opaquePublicChatHighlight", + name = "Public chat highlight", + description = "Color of highlights in Public chat" + ) + default Color opaquePublicChatHighlight() + { + return Color.decode("#000000"); + } + + @ConfigItem( + position = 33, + keyName = "opaquePrivateMessageSent", + name = "Sent private messages", + description = "Color of Private messages you've sent" + ) + Color opaquePrivateMessageSent(); + + @ConfigItem( + position = 34, + keyName = "opaquePrivateMessageSentHighlight", + name = "Sent private messages highlight", + description = "Color of highlights in Private messages you've sent" + ) + default Color opaquePrivateMessageSentHighlight() + { + return Color.decode("#002783"); + } + + @ConfigItem( + position = 35, + keyName = "opaquePrivateMessageReceived", + name = "Recieved private messages", + description = "Color of Private messages you've received" + ) + Color opaquePrivateMessageReceived(); + + @ConfigItem( + position = 36, + keyName = "opaquePrivateMessageReceivedHighlight", + name = "Received private messages highlight", + description = "Color of highlights in Private messages you've received" + ) + default Color opaquePrivateMessageReceivedHighlight() + { + return Color.decode("#002783"); + } + + @ConfigItem( + position = 37, + keyName = "opaqueClanChatInfo", + name = "Clan chat info", + description = "Clan Chat Information (eg. when joining a channel)" + ) + Color opaqueClanChatInfo(); + + @ConfigItem( + position = 38, + keyName = "opaqueClanChatMessage", + name = "Clan chat message", + description = "Color of Clan Chat Messages" + ) + Color opaqueClanChatMessage(); + + @ConfigItem( + position = 39, + keyName = "opaqueClanChatMessageHighlight", + name = "Clan chat message highlight", + description = "Color of highlights in Clan Chat Messages" + ) + default Color opaqueClanChatMessageHighlight() + { + return Color.decode("#000000"); + } + + @ConfigItem( + position = 40, + keyName = "opaqueAutochatMessage", + name = "Autochat", + description = "Color of Autochat messages" + ) + Color opaqueAutochatMessage(); + + @ConfigItem( + position = 41, + keyName = "opaqueAutochatMessageHighlight", + name = "Autochat highlight", + description = "Color of highlights in Autochat messages" + ) + Color opaqueAutochatMessageHighlight(); + + @ConfigItem( + position = 42, + keyName = "opaqueTradeChatMessage", + name = "Trade chat", + description = "Color of Trade Chat Messages" + ) + Color opaqueTradeChatMessage(); + + @ConfigItem( + position = 43, + keyName = "opaqueTradeChatMessageHighlight", + name = "Trade chat highlight", + description = "Color of highlights in Trade Chat Messages" + ) + Color opaqueTradeChatMessageHighlight(); + + @ConfigItem( + position = 44, + keyName = "opaqueServerMessage", + name = "Server message", + description = "Color of Server Messages (eg. 'Welcome to Runescape')" + ) + Color opaqueServerMessage(); + + @ConfigItem( + position = 45, + keyName = "opaqueServerMessageHighlight", + name = "Server message highlight", + description = "Color of highlights in Server Messages" + ) + Color opaqueServerMessageHighlight(); + + @ConfigItem( + position = 46, + keyName = "opaqueGameMessage", + name = "Game message", + description = "Color of Game Messages" + ) + Color opaqueGameMessage(); + + @ConfigItem( + position = 47, + keyName = "opaqueGameMessageHighlight", + name = "Game message highlight", + description = "Color of highlights in Game Messages" + ) + Color opaqueGameMessageHighlight(); + + @ConfigItem( + position = 48, + keyName = "opaqueExamine", + name = "Examine", + description = "Color of Examine Text" + ) + Color opaqueExamine(); + + @ConfigItem( + position = 49, + keyName = "opaqueExamineHighlight", + name = "Examine Highlight", + description = "Color of highlights in Examine Text" + ) + Color opaqueExamineHighlight(); + + @ConfigItem( + position = 50, + keyName = "opaqueFiltered", + name = "Filtered", + description = "Color of Filtered Text (messages that aren't shown when Game messages are filtered)" + ) + Color opaqueFiltered(); + + @ConfigItem( + position = 51, + keyName = "opaqueFilteredHighlight", + name = "Filtered Highlight", + description = "Color of highlights in Filtered Text" + ) + Color opaqueFilteredHighlight(); + + @ConfigItem( + position = 52, + keyName = "opaqueUsername", + name = "Usernames", + description = "Color of Usernames" + ) + Color opaqueUsername(); + + @ConfigItem( + position = 53, + keyName = "opaquePrivateUsernames", + name = "Private chat usernames", + description = "Color of Usernames in Private Chat" + ) + Color opaquePrivateUsernames(); + + @ConfigItem( + position = 54, + keyName = "opaqueClanChannelName", + name = "Chan channel Name", + description = "Color of Clan Channel Name" + ) + Color opaqueClanChannelName(); + + @ConfigItem( + position = 55, + keyName = "opaqueClanUsernames", + name = "Clan usernames", + description = "Color of Usernames in Clan Chat" + ) + Color opaqueClanUsernames(); + + @ConfigItem( + position = 61, + keyName = "transparentPublicChat", + name = "Public chat (transparent)", + description = "Color of Public chat (transparent)" + ) + Color transparentPublicChat(); + + @ConfigItem( + position = 62, + keyName = "transparentPublicChatHighlight", + name = "Public chat highlight (transparent)", + description = "Color of highlights in Public chat (transparent)" + ) + default Color transparentPublicChatHighlight() + { + return Color.decode("#FFFFFF"); + } + + @ConfigItem( + position = 63, + keyName = "transparentPrivateMessageSent", + name = "Sent private messages (transparent)", + description = "Color of Private messages you've sent (transparent)" + ) + Color transparentPrivateMessageSent(); + + @ConfigItem( + position = 64, + keyName = "transparentPrivateMessageSentHighlight", + name = "Sent private messages highlight (transparent)", + description = "Color of highlights in Private messages you've sent (transparent)" + ) + default Color transparentPrivateMessageSentHighlight() + { + return Color.decode("#FFFFFF"); + } + + @ConfigItem( + position = 65, + keyName = "transparentPrivateMessageReceived", + name = "Received private messages (transparent)", + description = "Color of Private messages you've received (transparent)" + ) + Color transparentPrivateMessageReceived(); + + @ConfigItem( + position = 66, + keyName = "transparentPrivateMessageReceivedHighlight", + name = "Received private messages highlight (transparent)", + description = "Color of highlights in Private messages you've received (transparent)" + ) + default Color transparentPrivateMessageReceivedHighlight() + { + return Color.decode("#FFFFFF"); + } + + @ConfigItem( + position = 67, + keyName = "transparentClanChatInfo", + name = "Clan chat info (transparent)", + description = "Clan Chat Information (eg. when joining a channel) (transparent)" + ) + Color transparentClanChatInfo(); + + @ConfigItem( + position = 68, + keyName = "transparentClanChatMessage", + name = "Clan chat message (transparent)", + description = "Color of Clan Chat Messages (transparent)" + ) + Color transparentClanChatMessage(); + + @ConfigItem( + position = 69, + keyName = "transparentClanChatMessageHighlight", + name = "Clan chat message highlight (transparent)", + description = "Color of highlights in Clan Chat Messages (transparent)" + ) + default Color transparentClanChatMessageHighlight() + { + return Color.decode("#FFFFFF"); + } + + @ConfigItem( + position = 70, + keyName = "transparentAutochatMessage", + name = "Autochat (transparent)", + description = "Color of Autochat messages (transparent)" + ) + Color transparentAutochatMessage(); + + @ConfigItem( + position = 71, + keyName = "transparentAutochatMessageHighlight", + name = "Autochat highlight (transparent)", + description = "Color of highlights in Autochat messages (transparent)" + ) + Color transparentAutochatMessageHighlight(); + + @ConfigItem( + position = 72, + keyName = "transparentTradeChatMessage", + name = "Trade chat (transparent)", + description = "Color of Trade Chat Messages (transparent)" + ) + Color transparentTradeChatMessage(); + + @ConfigItem( + position = 73, + keyName = "transparentTradeChatMessageHighlight", + name = "Trade chat highlight (transparent)", + description = "Color of highlights in Trade Chat Messages (transparent)" + ) + Color transparentTradeChatMessageHighlight(); + + @ConfigItem( + position = 74, + keyName = "transparentServerMessage", + name = "Server message (transparent)", + description = "Color of Server Messages (eg. 'Welcome to Runescape') (transparent)" + ) + Color transparentServerMessage(); + + @ConfigItem( + position = 75, + keyName = "transparentServerMessageHighlight", + name = "Server message highlight (transparent)", + description = "Color of highlights in Server Messages (transparent)" + ) + Color transparentServerMessageHighlight(); + + @ConfigItem( + position = 76, + keyName = "transparentGameMessage", + name = "Game message (transparent)", + description = "Color of Game Messages (transparent)" + ) + Color transparentGameMessage(); + + @ConfigItem( + position = 77, + keyName = "transparentGameMessageHighlight", + name = "Game message highlight (transparent)", + description = "Color of highlights in Game Messages (transparent)" + ) + Color transparentGameMessageHighlight(); + + @ConfigItem( + position = 78, + keyName = "transparentExamine", + name = "Examine (transparent)", + description = "Color of Examine Text (transparent)" + ) + Color transparentExamine(); + + @ConfigItem( + position = 79, + keyName = "transparentExamineHighlight", + name = "Examine Highlight (transparent)", + description = "Color of highlights in Examine Text (transparent)" + ) + Color transparentExamineHighlight(); + + @ConfigItem( + position = 80, + keyName = "transparentFiltered", + name = "Filtered (transparent)", + description = "Color of Filtered Text (messages that aren't shown when Game messages are filtered) (transparent)" + ) + Color transparentFiltered(); + + @ConfigItem( + position = 81, + keyName = "transparentFilteredHighlight", + name = "Filtered Highlight (transparent)", + description = "Color of highlights in Filtered Text (transparent)" + ) + Color transparentFilteredHighlight(); + + @ConfigItem( + position = 82, + keyName = "transparentUsername", + name = "Usernames (transparent)", + description = "Color of Usernames (transparent)" + ) + Color transparentUsername(); + + @ConfigItem( + position = 83, + keyName = "transparentPrivateUsernames", + name = "Private chat usernames (transparent)", + description = "Color of Usernames in Private Chat (transparent)" + ) + Color transparentPrivateUsernames(); + + @ConfigItem( + position = 84, + keyName = "transparentClanChannelName", + name = "Chan channel Name (transparent)", + description = "Color of Clan Channel Name (transparent)" + ) + Color transparentClanChannelName(); + + @ConfigItem( + position = 85, + keyName = "transparentClanUsernames", + name = "Clan usernames (transparent)", + description = "Color of Usernames in Clan Chat (transparent)" + ) + Color transparentClanUsernames(); +} 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 bff19d4c23..320bb84c48 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 @@ -67,6 +67,7 @@ import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import lombok.extern.slf4j.Slf4j; +import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigDescriptor; import net.runelite.client.config.ConfigItem; @@ -119,17 +120,20 @@ public class ConfigPanel extends PluginPanel private final ConfigManager configManager; private final ScheduledExecutorService executorService; private final RuneLiteConfig runeLiteConfig; + private final ChatColorConfig chatColorConfig; private final IconTextField searchBar = new IconTextField(); private Map children = new TreeMap<>(); private int scrollBarPosition = 0; - public ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService, RuneLiteConfig runeLiteConfig) + public ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService, + RuneLiteConfig runeLiteConfig, ChatColorConfig chatColorConfig) { super(); this.pluginManager = pluginManager; this.configManager = configManager; this.executorService = executorService; this.runeLiteConfig = runeLiteConfig; + this.chatColorConfig = chatColorConfig; searchBar.setIcon(SEARCH); searchBar.setPreferredSize(new Dimension(100, 30)); @@ -198,9 +202,18 @@ public class ConfigPanel extends PluginPanel newChildren.put(pluginName, groupPanel); }); + addCoreConfig(newChildren, "RuneLite", runeLiteConfig); + addCoreConfig(newChildren, "Chat Color", chatColorConfig); + + children = newChildren; + openConfigList(); + } + + private void addCoreConfig(Map newChildren, String configName, Config config) + { final JPanel groupPanel = buildGroupPanel(); - JLabel name = new JLabel("RuneLite"); + JLabel name = new JLabel(configName); name.setForeground(Color.WHITE); groupPanel.add(name, BorderLayout.CENTER); @@ -209,17 +222,14 @@ public class ConfigPanel extends PluginPanel buttonPanel.setLayout(new GridLayout(1, 2)); groupPanel.add(buttonPanel, BorderLayout.LINE_END); - final JLabel editConfigButton = buildConfigButton(runeLiteConfig); + final JLabel editConfigButton = buildConfigButton(config); buttonPanel.add(editConfigButton); final JLabel toggleButton = buildToggleButton(null); toggleButton.setVisible(false); buttonPanel.add(toggleButton); - newChildren.put("RuneLite", groupPanel); - - children = newChildren; - openConfigList(); + newChildren.put(configName, groupPanel); } private JPanel buildGroupPanel() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java index 242ff2d6f5..f61c244c97 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java @@ -30,6 +30,7 @@ import java.util.concurrent.ScheduledExecutorService; import javax.imageio.ImageIO; import javax.inject.Inject; import javax.swing.SwingUtilities; +import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ConfigManager; import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.events.PluginChanged; @@ -61,13 +62,16 @@ public class ConfigPlugin extends Plugin @Inject private RuneLiteConfig runeLiteConfig; + @Inject + private ChatColorConfig chatColorConfig; + private ConfigPanel configPanel; private NavigationButton navButton; @Override protected void startUp() throws Exception { - configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig); + configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, chatColorConfig); BufferedImage icon; synchronized (ImageIO.class)