Merge pull request #201 from l2-/chatcommandsv1

recolor chat command messages when chatbox transparency changes
This commit is contained in:
Adam
2017-11-10 13:58:03 -05:00
committed by GitHub
16 changed files with 537 additions and 68 deletions

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2017. l2-
*
* 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.api;
public interface ChatLineBuffer
{
/**
* @return the MessageNode arrays which contain the messages in the chatbox
*/
MessageNode[] getLines();
/**
* @return the length of the MessageNode array getLines()
*/
int getLength();
}

View File

@@ -26,6 +26,7 @@ package net.runelite.api;
import java.awt.Canvas; import java.awt.Canvas;
import java.util.List; import java.util.List;
import java.util.Map;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
@@ -144,5 +145,7 @@ public interface Client
void refreshChat(); void refreshChat();
Map<Integer, ChatLineBuffer> getChatLineMap();
Widget getViewportWidget(); Widget getViewportWidget();
} }

View File

@@ -33,4 +33,8 @@ public interface MessageNode
String getValue(); String getValue();
void setValue(String value); void setValue(String value);
String getRuneLiteFormatMessage();
void setRuneLiteFormatMessage(String runeLiteFormatMessage);
} }

View File

@@ -26,6 +26,12 @@ package net.runelite.api;
public enum Varbits public enum Varbits
{ {
/*
* If chatbox is transparent or not
*/
TRANSPARANT_CHATBOX(4608, 1055, 9, 9),
SPLIT_CHAT(287, 0, 0),
/** /**
* Runecraft pouches * Runecraft pouches
*/ */

View File

@@ -45,6 +45,7 @@ class WidgetID
static final int COMBAT_GROUP_ID = 593; static final int COMBAT_GROUP_ID = 593;
static final int DIALOG_NPC_GROUP_ID = 231; static final int DIALOG_NPC_GROUP_ID = 231;
static final int SLAYER_REWARDS_GROUP_ID = 426; static final int SLAYER_REWARDS_GROUP_ID = 426;
static final int PRIVATE_CHAT = 163;
static class SlayerRewards static class SlayerRewards
{ {

View File

@@ -88,6 +88,8 @@ public enum WidgetInfo
DIALOG_NPC_HEAD_MODEL(WidgetID.DIALOG_NPC_GROUP_ID, WidgetID.DialogNPC.HEAD_MODEL), DIALOG_NPC_HEAD_MODEL(WidgetID.DIALOG_NPC_GROUP_ID, WidgetID.DialogNPC.HEAD_MODEL),
DIALOG_NPC_CONTINUE(WidgetID.DIALOG_NPC_GROUP_ID, WidgetID.DialogNPC.CONTINUE), DIALOG_NPC_CONTINUE(WidgetID.DIALOG_NPC_GROUP_ID, WidgetID.DialogNPC.CONTINUE),
PRIVATE_CHAT_MESSAGE(WidgetID.PRIVATE_CHAT, 0),
SLAYER_REWARDS_TOPBAR(WidgetID.SLAYER_REWARDS_GROUP_ID, WidgetID.SlayerRewards.TOP_BAR); SLAYER_REWARDS_TOPBAR(WidgetID.SLAYER_REWARDS_GROUP_ID, WidgetID.SlayerRewards.TOP_BAR);

View File

@@ -149,6 +149,20 @@ public class Hooks
runelite.getEventBus().post(gameStateChange); runelite.getEventBus().post(gameStateChange);
break; break;
} }
case "varbitChanged":
{
VarbitChanged varbitChanged = new VarbitChanged();
runelite.getEventBus().post(varbitChanged);
break;
}
case "resizeChanged":
{
//maybe couple with varbitChanged. resizeable may not be a varbit but it would fit with the other client settings.
ResizeableChanged resizeableChanged = new ResizeableChanged();
resizeableChanged.setResized(RuneLite.getClient().isResized());
runelite.getEventBus().post(resizeableChanged);
break;
}
default: default:
logger.warn("Unknown event {} triggered on {}", name, object); logger.warn("Unknown event {} triggered on {}", name, object);
return; return;

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2017. l2-
*
* 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.events;
public class ResizeableChanged
{
private boolean isResized;
public void setResized(boolean isResized)
{
this.isResized = isResized;
}
public boolean isResized()
{
return this.isResized;
}
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2017. l2-
*
* 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.events;
public class VarbitChanged
{
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2017. l2-
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.chatcommands;
import java.awt.Color;
import net.runelite.api.ChatMessageType;
class ChatColor
{
Color color;
ChatMessageType type;
boolean transparent;
boolean highlight;
ChatColor(Color color, ChatMessageType type, boolean transparent, boolean highlight)
{
this.color = color;
this.type = type;
this.transparent = transparent;
this.highlight = highlight;
}
}

View File

@@ -28,15 +28,23 @@ package net.runelite.client.plugins.chatcommands;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import java.awt.Color; import java.awt.Color;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.api.MessageNode; import net.runelite.api.MessageNode;
import net.runelite.api.Varbits;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import net.runelite.client.events.SetMessage; import net.runelite.client.events.SetMessage;
import net.runelite.client.events.ResizeableChanged;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.events.VarbitChanged;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -58,14 +66,17 @@ public class ChatCommands extends Plugin
{ {
private static final Logger logger = LoggerFactory.getLogger(ChatCommands.class); private static final Logger logger = LoggerFactory.getLogger(ChatCommands.class);
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
private final String colKeyword = "<colRegular>";
private final String colKeywordHighLight = "<colHighlight>";
private final ChatCommandsConfig config = RuneLite.getRunelite().getConfigManager().getConfig(ChatCommandsConfig.class); private final ChatCommandsConfig config = RuneLite.getRunelite().getConfigManager().getConfig(ChatCommandsConfig.class);
private final ItemManager itemManager = RuneLite.getRunelite().getItemManager(); private final ItemManager itemManager = RuneLite.getRunelite().getItemManager();
private final ItemClient itemClient = new ItemClient(); private final ItemClient itemClient = new ItemClient();
private final RuneLite runelite = RuneLite.getRunelite(); private final RuneLite runelite = RuneLite.getRunelite();
private final Client client = RuneLite.getClient(); private final Client client = RuneLite.getClient();
private final HiscoreClient hiscoreClient = new HiscoreClient(); private final HiscoreClient hiscoreClient = new HiscoreClient();
private int transparancyVarbit = -1;
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
@@ -77,6 +88,63 @@ public class ChatCommands extends Plugin
{ {
} }
/**
* Checks if the chatbox is no longer transparent and if messages need
* to be recolored
*
* @param event the event object
*/
@Subscribe
public void onVarbitChange(VarbitChanged event)
{
if (transparancyVarbit == -1)
{
transparancyVarbit = client.getSetting(Varbits.TRANSPARANT_CHATBOX);
}
else if (transparancyVarbit != client.getSetting(Varbits.TRANSPARANT_CHATBOX))
{
transparancyVarbit = client.getSetting(Varbits.TRANSPARANT_CHATBOX);
ScheduledExecutorService executor = runelite.getExecutor();
executor.submit(() -> recolorChat());
}
}
@Subscribe
public void onResizableChanged(ResizeableChanged event)
{
ScheduledExecutorService executor = runelite.getExecutor();
executor.submit(() -> recolorChat());
}
/**
* get the MessageNodes that have a runeltie message
*
* @return
*/
private Collection<MessageNode> getRuneliteMessages()
{
return client.getChatLineMap().values().stream()
.filter(Objects::nonNull)
.flatMap(clb -> Arrays.stream(clb.getLines()))
.filter(Objects::nonNull)
.filter(mn -> mn.getRuneLiteFormatMessage() != null)
.collect(Collectors.toList());
}
/**
* Updates the ingame recolored messages to the new config recolorChat
* cannot color messages without color tags because it won't know what
* to replace.
*
* @param event the event object
*/
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
ScheduledExecutorService executor = runelite.getExecutor();
executor.submit(() -> recolorChat());
}
/** /**
* Checks if the chat message is a command. * Checks if the chat message is a command.
* *
@@ -102,6 +170,11 @@ public class ChatCommands extends Plugin
} }
String message = setMessage.getValue(); String message = setMessage.getValue();
MessageNode messageNode = setMessage.getMessageNode();
// clear runelite formatted messsage as the message node is
// being reused
messageNode.setRuneLiteFormatMessage(null);
if (config.lvl() && message.toLowerCase().equals("!total")) if (config.lvl() && message.toLowerCase().equals("!total"))
{ {
@@ -171,35 +244,27 @@ public class ChatCommands extends Plugin
return; return;
} }
Color color1 = getColor(type),
color2 = getColorH(type);
String hexColor1 = "", hexColor2 = "";
if (config.recolorEnabled() && color1 != null && color2 != null)
{
hexColor1 = toHexCol(color1);
hexColor2 = toHexCol(color2);
}
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("<col=").append(hexColor1).append(">").append("Price of ") builder.append(colKeyword).append("Price of ")
.append("<col=").append(hexColor2).append(">").append(item.getName()) .append(colKeywordHighLight).append(item.getName())
.append("<col=").append(hexColor1).append(">").append(": GE average ") .append(colKeyword).append(": GE average ")
.append("<col=").append(hexColor2).append(">").append(String.format("%,d", itemPrice.getPrice())); .append(colKeywordHighLight).append(String.format("%,d", itemPrice.getPrice()));
ItemComposition itemComposition = client.getItemDefinition(itemId); ItemComposition itemComposition = client.getItemDefinition(itemId);
if (itemComposition != null) if (itemComposition != null)
{ {
int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT); int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT);
builder.append("<col=").append(hexColor1).append(">").append(" HA value ") builder.append(colKeyword).append(" HA value ")
.append("<col=").append(hexColor2).append(">").append(String.format("%,d", alchPrice)); .append(colKeywordHighLight).append(String.format("%,d", alchPrice));
} }
logger.debug("Setting response {}", builder.toString()); String response = builder.toString();
logger.debug("Setting response {}", response);
// XXX hopefully messageNode hasn't been reused yet? // XXX hopefully messageNode hasn't been reused yet?
messageNode.setValue(builder.toString()); messageNode.setRuneLiteFormatMessage(response);
messageNode.setValue(recolorMessage(messageNode.getType(), response));
client.refreshChat(); client.refreshChat();
} }
} }
@@ -213,8 +278,15 @@ public class ChatCommands extends Plugin
*/ */
private void playerSkillLookup(ChatMessageType type, SetMessage setMessage, String search) private void playerSkillLookup(ChatMessageType type, SetMessage setMessage, String search)
{ {
String player = sanitize(setMessage.getName()); String player;
if (type.equals(ChatMessageType.PRIVATE_MESSAGE_SENT))
{
player = client.getLocalPlayer().getName();
}
else
{
player = sanitize(setMessage.getName());
}
try try
{ {
search = SkillAbbreviations.valueOf(search.toUpperCase()).getName(); search = SkillAbbreviations.valueOf(search.toUpperCase()).getName();
@@ -238,30 +310,20 @@ public class ChatCommands extends Plugin
SingleHiscoreSkillResult result = hiscoreClient.lookup(player, skill); SingleHiscoreSkillResult result = hiscoreClient.lookup(player, skill);
Skill hiscoreSkill = result.getSkill(); Skill hiscoreSkill = result.getSkill();
Color color1 = getColor(type),
color2 = getColorH(type);
String hexColor1 = "", hexColor2 = "";
if (config.recolorEnabled() && color1 != null && color2 != null)
{
hexColor1 = toHexCol(color1);
hexColor2 = toHexCol(color2);
}
String response = new StringBuilder() String response = new StringBuilder()
.append("<col=").append(hexColor1).append(">").append("Level ") .append(colKeyword).append("Level ")
.append("<col=").append(hexColor2).append(">").append(skill.getName()).append(": ").append(hiscoreSkill.getLevel()) .append(colKeywordHighLight).append(skill.getName()).append(": ").append(hiscoreSkill.getLevel())
.append("<col=").append(hexColor1).append(">").append(" Experience: ") .append(colKeyword).append(" Experience: ")
.append("<col=").append(hexColor2).append(">").append(String.format("%,d", hiscoreSkill.getExperience())) .append(colKeywordHighLight).append(String.format("%,d", hiscoreSkill.getExperience()))
.append("<col=").append(hexColor1).append(">").append(" Rank: ") .append(colKeyword).append(" Rank: ")
.append("<col=").append(hexColor2).append(">").append(String.format("%,d", hiscoreSkill.getRank())) .append(colKeywordHighLight).append(String.format("%,d", hiscoreSkill.getRank()))
.toString(); .toString();
logger.debug("Setting response {}", response); logger.debug("Setting response {}", response);
// XXX hopefully messageNode hasn't been reused yet? // XXX hopefully messageNode hasn't been reused yet?
setMessage.getMessageNode().setValue(response); setMessage.getMessageNode().setRuneLiteFormatMessage(response);
setMessage.getMessageNode().setValue(recolorMessage(setMessage.getType(), response));
client.refreshChat(); client.refreshChat();
} }
catch (IOException ex) catch (IOException ex)
@@ -291,40 +353,106 @@ public class ChatCommands extends Plugin
return null; return null;
} }
private Color getColor(ChatMessageType type) private ChatColor getChatColor(ChatMessageType type)
{ {
switch (type) if ((type == ChatMessageType.PRIVATE_MESSAGE_SENT || type == ChatMessageType.PRIVATE_MESSAGE_RECEIVED) && !config.isPrivateRecolor())
{ {
case PUBLIC: return null;
return config.getPublicRecolor(); }
case CLANCHAT: if (client.getSetting(Varbits.TRANSPARANT_CHATBOX) == 0 || !client.isResized() || !config.transparancyRecolor())
return config.getCcRecolor(); {
case PRIVATE_MESSAGE_RECEIVED: switch (type)
case PRIVATE_MESSAGE_SENT: {
return config.getPrivateRecolor(); case PUBLIC:
return new ChatColor(config.getPublicRecolor(), type, false, false);
case PRIVATE_MESSAGE_RECEIVED:
case PRIVATE_MESSAGE_SENT:
return new ChatColor(config.getPrivateRecolor(), type, false, false);
case CLANCHAT:
return new ChatColor(config.getCcRecolor(), type, false, false);
}
}
else
{
switch (type)
{
case PUBLIC:
return new ChatColor(config.getTransparentPublicRecolor(), type, true, false);
case PRIVATE_MESSAGE_RECEIVED:
case PRIVATE_MESSAGE_SENT:
return new ChatColor(config.getTransparentPrivateRecolor(), type, true, false);
case CLANCHAT:
return new ChatColor(config.getTransparentCcRecolor(), type, true, false);
}
} }
return null; return null;
} }
private Color getColorH(ChatMessageType type) private ChatColor getChatColorH(ChatMessageType type)
{ {
switch (type) if ((type == ChatMessageType.PRIVATE_MESSAGE_SENT || type == ChatMessageType.PRIVATE_MESSAGE_RECEIVED) && !config.isPrivateRecolor())
{ {
case PUBLIC: return null;
return config.getPublicHRecolor(); }
case CLANCHAT: if (client.getSetting(Varbits.TRANSPARANT_CHATBOX) == 0 || !client.isResized() || !config.transparancyRecolor())
return config.getCcHRecolor(); {
case PRIVATE_MESSAGE_RECEIVED: switch (type)
case PRIVATE_MESSAGE_SENT: {
return config.getPrivateHRecolor(); case PUBLIC:
return new ChatColor(config.getPublicHRecolor(), type, false, true);
case PRIVATE_MESSAGE_RECEIVED:
case PRIVATE_MESSAGE_SENT:
return new ChatColor(config.getPrivateHRecolor(), type, false, true);
case CLANCHAT:
return new ChatColor(config.getCcHRecolor(), type, false, true);
}
}
else
{
switch (type)
{
case PUBLIC:
return new ChatColor(config.getTransparentPublicHRecolor(), type, true, true);
case PRIVATE_MESSAGE_RECEIVED:
case PRIVATE_MESSAGE_SENT:
return new ChatColor(config.getTransparentPrivateHRecolor(), type, true, true);
case CLANCHAT:
return new ChatColor(config.getTransparentCcHRecolor(), type, true, true);
}
} }
return null; return null;
} }
private static String toHexCol(Color color) private String recolorMessage(ChatMessageType type, String value)
{ {
// <col> doesn't support alpha ChatColor chatcolor = getChatColor(type);
return color == null ? "" : Integer.toHexString(color.getRGB() & 0xFFFFFF); ChatColor chatColorH = getChatColorH(type);
if (config.recolorEnabled() && chatcolor != null && chatColorH != null)
{
value = value.replace(colKeyword, getColTag(chatcolor.color))
.replace(colKeywordHighLight, getColTag(chatColorH.color));
}
else
{
value = value.replace(colKeyword, "")
.replace(colKeywordHighLight, "");
}
return value;
}
private void recolorChat()
{
Collection<MessageNode> nodes = getRuneliteMessages();
for (MessageNode message : nodes)
{
message.setValue(recolorMessage(message.getType(), message.getRuneLiteFormatMessage()));
}
client.refreshChat();
}
public static String getColTag(Color color)
{
return color == null ? "" : "<col=" + Integer.toHexString(color.getRGB() & 0xFFFFFF) + ">";
} }
/** /**

View File

@@ -70,6 +70,17 @@ public interface ChatCommandsConfig
@ConfigItem( @ConfigItem(
position = 3, position = 3,
keyName = "enablePrivateRecolor",
name = "enable private recolor",
description = "enable private recolor"
)
default boolean isPrivateRecolor()
{
return false;
}
@ConfigItem(
position = 4,
keyName = "hexColorPublic", keyName = "hexColorPublic",
name = "Public chat", name = "Public chat",
description = "Color of Public chat" description = "Color of Public chat"
@@ -80,7 +91,7 @@ public interface ChatCommandsConfig
} }
@ConfigItem( @ConfigItem(
position = 4, position = 5,
keyName = "hexColorPublicH", keyName = "hexColorPublicH",
name = "Public chat highlight", name = "Public chat highlight",
description = "Color of Public chat highlight" description = "Color of Public chat highlight"
@@ -91,7 +102,7 @@ public interface ChatCommandsConfig
} }
@ConfigItem( @ConfigItem(
position = 5, position = 6,
keyName = "hexColorPrivate", keyName = "hexColorPrivate",
name = "Private chat", name = "Private chat",
description = "Color of Private chat" description = "Color of Private chat"
@@ -102,7 +113,7 @@ public interface ChatCommandsConfig
} }
@ConfigItem( @ConfigItem(
position = 6, position = 7,
keyName = "hexColorPrivateH", keyName = "hexColorPrivateH",
name = "Private chat highlight", name = "Private chat highlight",
description = "Color of Private chat highlight" description = "Color of Private chat highlight"
@@ -113,18 +124,18 @@ public interface ChatCommandsConfig
} }
@ConfigItem( @ConfigItem(
position = 7, position = 8,
keyName = "hexColorCc", keyName = "hexColorCc",
name = "Clan chat", name = "Clan chat",
description = "Color of Clan chat" description = "Color of Clan chat"
) )
default Color getCcRecolor() default Color getCcRecolor()
{ {
return Color.decode("#900000"); return Color.decode("#7f0000");
} }
@ConfigItem( @ConfigItem(
position = 8, position = 9,
keyName = "hexColorCcH", keyName = "hexColorCcH",
name = "Clan chat Highlight", name = "Clan chat Highlight",
description = "Color of Clan chat highlight" description = "Color of Clan chat highlight"
@@ -133,4 +144,81 @@ public interface ChatCommandsConfig
{ {
return Color.decode("#000000"); return Color.decode("#000000");
} }
@ConfigItem(
position = 10,
keyName = "transparancyRecolor",
name = "Different colors for transparent chatbox",
description = "Configures whether colors are different for transparent chatbox"
)
default boolean transparancyRecolor()
{
return true;
}
@ConfigItem(
position = 11,
keyName = "transparentHexColorPublic",
name = "Transparent public chat",
description = "Color of Public chat"
)
default Color getTransparentPublicRecolor()
{
return Color.decode("#9090FF");
}
@ConfigItem(
position = 12,
keyName = "transparentHexColorPublicH",
name = "Transparent public chat highlight",
description = "Color of Public chat highlight"
)
default Color getTransparentPublicHRecolor()
{
return Color.decode("#FFFFFF");
}
@ConfigItem(
position = 13,
keyName = "transparentHexColorPrivate",
name = "Transparent private chat",
description = "Color of Private chat"
)
default Color getTransparentPrivateRecolor()
{
return Color.decode("#FFFFFF");
}
@ConfigItem(
position = 14,
keyName = "transparentHexColorPrivateH",
name = "Transparent private chat highlight",
description = "Color of Private chat highlight"
)
default Color getTransparentPrivateHRecolor()
{
return Color.decode("#00FFFF");
}
@ConfigItem(
position = 15,
keyName = "transparentHexColorCc",
name = "Transparent clan chat",
description = "Color of Clan chat"
)
default Color getTransparentCcRecolor()
{
return Color.decode("#Ef5050");
}
@ConfigItem(
position = 16,
keyName = "transparentHexColorCcH",
name = "Transparent clan chat Highlight",
description = "Color of Clan chat highlight"
)
default Color getTransparentCcHRecolor()
{
return Color.decode("#FFFFFF");
}
} }

View File

@@ -33,6 +33,7 @@ enum SkillAbbreviations
RANGE("Ranged"), RANGE("Ranged"),
WC("Woodcutting"), WC("Woodcutting"),
FM("Firemaking"), FM("Firemaking"),
RUNECRAFTING("Runecraft"),
RC("Runecraft"), RC("Runecraft"),
CON("Construction"), CON("Construction"),
TOTAL("Overall"); TOTAL("Overall");

View File

@@ -32,10 +32,27 @@ import net.runelite.rs.api.RSMessageNode;
@Mixin(RSMessageNode.class) @Mixin(RSMessageNode.class)
public abstract class RSMessageNodeMixin implements RSMessageNode public abstract class RSMessageNodeMixin implements RSMessageNode
{ {
@Inject
private String runeLiteFormatMessage;
@Inject @Inject
@Override @Override
public ChatMessageType getType() public ChatMessageType getType()
{ {
return ChatMessageType.of(getRSType()); return ChatMessageType.of(getRSType());
} }
@Inject
@Override
public String getRuneLiteFormatMessage()
{
return runeLiteFormatMessage;
}
@Inject
@Override
public void setRuneLiteFormatMessage(String runeLiteFormatMessage)
{
this.runeLiteFormatMessage = runeLiteFormatMessage;
}
} }

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2017. l2-
*
* 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.rs.api;
import net.runelite.api.ChatLineBuffer;
import net.runelite.api.MessageNode;
import net.runelite.mapping.Import;
public interface RSChatLineBuffer extends ChatLineBuffer
{
@Import("lines")
@Override
MessageNode[] getLines();
@Import("length")
@Override
int getLength();
}

View File

@@ -24,6 +24,7 @@
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import java.util.Map;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
@@ -258,6 +259,10 @@ public interface RSClient extends RSGameEngine, Client
@Import("packetHandler") @Import("packetHandler")
void packetHandler(); void packetHandler();
@Import("chatLineMap")
@Override
Map getChatLineMap();
@Import("revision") @Import("revision")
@Override @Override
int getRevision(); int getRevision();