Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2020-06-12 11:47:08 +02:00
14 changed files with 1484 additions and 224 deletions

View File

@@ -96,9 +96,8 @@ public class ItemManager implements ItemProvider
public void java(File java) throws IOException public void java(File java) throws IOException
{ {
java.mkdirs(); java.mkdirs();
try (IDClass ids = IDClass.create(java, "ItemID")) try (IDClass ids = IDClass.create(java, "ItemID");
{ IDClass nulls = IDClass.create(java, "NullItemID"))
try (IDClass nulls = IDClass.create(java, "NullItemID"))
{ {
for (ItemDefinition def : items.values()) for (ItemDefinition def : items.values())
{ {
@@ -113,7 +112,6 @@ public class ItemManager implements ItemProvider
} }
} }
} }
}
@Override @Override
public ItemDefinition provide(int itemId) public ItemDefinition provide(int itemId)

View File

@@ -95,17 +95,20 @@ public class NpcManager
public void java(File java) throws IOException public void java(File java) throws IOException
{ {
java.mkdirs(); java.mkdirs();
try (IDClass ids = IDClass.create(java, "NpcID")) try (IDClass ids = IDClass.create(java, "NpcID");
IDClass nulls = IDClass.create(java, "NullNpcID"))
{ {
for (NpcDefinition def : npcs.values()) for (NpcDefinition def : npcs.values())
{ {
if (def.name.equalsIgnoreCase("NULL")) if (def.name.equalsIgnoreCase("NULL"))
{ {
continue; nulls.add(def.name, def.id);
} }
else
{
ids.add(def.name, def.id); ids.add(def.name, def.id);
} }
} }
} }
} }
}

View File

@@ -95,9 +95,8 @@ public class ObjectManager
public void java(File java) throws IOException public void java(File java) throws IOException
{ {
java.mkdirs(); java.mkdirs();
try (IDClass ids = IDClass.create(java, "ObjectID")) try (IDClass ids = IDClass.create(java, "ObjectID");
{ IDClass nulls = IDClass.create(java, "NullObjectID"))
try (IDClass nulls = IDClass.create(java, "NullObjectID"))
{ {
for (ObjectDefinition def : objects.values()) for (ObjectDefinition def : objects.values())
{ {
@@ -113,4 +112,3 @@ public class ObjectManager
} }
} }
} }
}

View File

@@ -38,6 +38,7 @@ public class GrandExchangeTrade
private int dqty; private int dqty;
private int total; private int total;
private int spent; private int spent;
private int dspent;
private int offer; private int offer;
private int slot; private int slot;
private WorldType worldType; private WorldType worldType;

File diff suppressed because it is too large Load Diff

View File

@@ -36,4 +36,10 @@ public interface TileItem extends Entity
int getId(); int getId();
int getQuantity(); int getQuantity();
/**
* Time in game ticks when the item spawned (relative to us)
* @return
*/
int getSpawnTime();
} }

View File

@@ -31,6 +31,8 @@ import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.WordUtils; import org.apache.commons.text.WordUtils;
import org.apache.commons.text.similarity.JaroWinklerDistance; import org.apache.commons.text.similarity.JaroWinklerDistance;
@@ -38,6 +40,7 @@ import org.apache.commons.text.similarity.JaroWinklerDistance;
public class Text public class Text
{ {
private static final StringBuilder SB = new StringBuilder(64); private static final StringBuilder SB = new StringBuilder(64);
private static final Pattern TAG_REGEXP = Pattern.compile("<[^>]*>");
public static final JaroWinklerDistance DISTANCE = new JaroWinklerDistance(); public static final JaroWinklerDistance DISTANCE = new JaroWinklerDistance();
public static final Splitter COMMA_SPLITTER = Splitter public static final Splitter COMMA_SPLITTER = Splitter
.on(",") .on(",")
@@ -150,6 +153,32 @@ public class Text
return removeTags(str, false); return removeTags(str, false);
} }
/**
* Remove tags from the given string, except for &lt;lt&gt; and &lt;gt&gt;
*
* @param str The string to remove formatting tags from.
* @return The given string with all formatting tags removed from it.
*/
public static String removeFormattingTags(String str)
{
StringBuilder stringBuilder = new StringBuilder();
Matcher matcher = TAG_REGEXP.matcher(str);
while (matcher.find())
{
matcher.appendReplacement(stringBuilder, "");
String match = matcher.group(0);
switch (match)
{
case "<lt>":
case "<gt>":
stringBuilder.append(match);
break;
}
}
matcher.appendTail(stringBuilder);
return stringBuilder.toString();
}
/** /**
* In addition to removing all tags, replaces nbsp with space, trims string and lowercases it * In addition to removing all tags, replaces nbsp with space, trims string and lowercases it

View File

@@ -250,6 +250,16 @@ public interface Widget
*/ */
int getSpriteId(); int getSpriteId();
/**
* Gets if sprites are repeated or stretched
*/
boolean getSpriteTiling();
/**
* Sets if sprites are repeated or stretched
*/
void setSpriteTiling(boolean tiling);
/** /**
* Sets the sprite ID displayed in the widget. * Sets the sprite ID displayed in the widget.
* *
@@ -288,18 +298,18 @@ public interface Widget
int getIndex(); int getIndex();
/** /**
* Gets the model ID displayed in the widget. * Gets the Model/NPC/Item ID displayed in the widget.
* *
* @return the model ID * @see WidgetModelType
*/ */
int getModelId(); int getModelId();
/** /**
* Sets the model ID displayed in the widget * Sets the Model/NPC/Item ID displayed in the widget.
* *
* @param modelId the new model ID * @see WidgetModelType
*/ */
void setModelId(int modelId); void setModelId(int id);
/** /**
* Gets the model type of the widget. * Gets the model type of the widget.
@@ -316,6 +326,20 @@ public interface Widget
*/ */
void setModelType(int type); void setModelType(int type);
/**
* Gets the sequence ID used to animate the model in the widget
*
* @see net.runelite.api.AnimationID
*/
int getAnimationId();
/**
* Sets the sequence ID used to animate the model in the widget
*
* @see net.runelite.api.AnimationID
*/
void setAnimationId(int animationId);
/** /**
* Gets the x rotation of the model displayed in the widget * Gets the x rotation of the model displayed in the widget
* *

View File

@@ -49,4 +49,18 @@ public class TextTest
{ {
assertEquals("Whoever This Is Lmao", Text.toJagexName("-__- - \u00A0\u00A0 Whoever\uABCD\uABCD\u00A0T\uABBBhis Is-Lmao")); assertEquals("Whoever This Is Lmao", Text.toJagexName("-__- - \u00A0\u00A0 Whoever\uABCD\uABCD\u00A0T\uABBBhis Is-Lmao"));
} }
@Test
public void removeFormattingTags()
{
assertEquals("Test", Text.removeFormattingTags("<col=FFFFFF>Test</col>"));
assertEquals("Test", Text.removeFormattingTags("<img=1><s>Test</s>"));
assertEquals("Zezima (level-126)", Text.removeFormattingTags("<col=ffffff><img=2>Zezima<col=00ffff> (level-126)"));
assertEquals("", Text.removeFormattingTags("<colrandomtext test>"));
assertEquals("Not so much.", Text.removeFormattingTags("<col=FFFFFF This is a very special message.</col>Not so much."));
assertEquals("Use Item -> Man", Text.removeFormattingTags("Use Item -> Man"));
assertEquals("a < b", Text.removeFormattingTags("a < b"));
assertEquals("a <lt> b", Text.removeFormattingTags("a <lt> b"));
assertEquals("Remove no tags", Text.removeFormattingTags("Remove no tags"));
}
} }

View File

@@ -30,19 +30,43 @@ import net.runelite.client.ui.JagexColors;
@ConfigGroup("textrecolor") @ConfigGroup("textrecolor")
public interface ChatColorConfig extends Config public interface ChatColorConfig extends Config
{ {
@ConfigTitleSection(
keyName = "opaqueTitle",
name = "Opaque",
description = "",
position = 1
)
default Title opaqueTitle()
{
return new Title();
}
@ConfigTitleSection(
keyName = "transparentTitle",
name = "Transparent",
description = "",
position = 1
)
default Title transparentTitle()
{
return new Title();
}
@ConfigItem( @ConfigItem(
position = 31, position = 1,
keyName = "opaquePublicChat", keyName = "opaquePublicChat",
name = "Public chat", name = "Public chat",
description = "Color of Public chat" description = "Color of Public chat",
titleSection = "opaqueTitle"
) )
Color opaquePublicChat(); Color opaquePublicChat();
@ConfigItem( @ConfigItem(
position = 32, position = 2,
keyName = "opaquePublicChatHighlight", keyName = "opaquePublicChatHighlight",
name = "Public chat highlight", name = "Public chat highlight",
description = "Color of highlights in Public chat" description = "Color of highlights in Public chat",
titleSection = "opaqueTitle"
) )
default Color opaquePublicChatHighlight() default Color opaquePublicChatHighlight()
{ {
@@ -50,18 +74,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 33, position = 3,
keyName = "opaquePrivateMessageSent", keyName = "opaquePrivateMessageSent",
name = "Sent private messages", name = "Sent private messages",
description = "Color of Private messages you've sent" description = "Color of Private messages you've sent",
titleSection = "opaqueTitle"
) )
Color opaquePrivateMessageSent(); Color opaquePrivateMessageSent();
@ConfigItem( @ConfigItem(
position = 34, position = 4,
keyName = "opaquePrivateMessageSentHighlight", keyName = "opaquePrivateMessageSentHighlight",
name = "Sent private messages highlight", name = "Sent private messages highlight",
description = "Color of highlights in Private messages you've sent" description = "Color of highlights in Private messages you've sent",
titleSection = "opaqueTitle"
) )
default Color opaquePrivateMessageSentHighlight() default Color opaquePrivateMessageSentHighlight()
{ {
@@ -69,18 +95,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 35, position = 5,
keyName = "opaquePrivateMessageReceived", keyName = "opaquePrivateMessageReceived",
name = "Received private messages", name = "Received private messages",
description = "Color of Private messages you've received" description = "Color of Private messages you've received",
titleSection = "opaqueTitle"
) )
Color opaquePrivateMessageReceived(); Color opaquePrivateMessageReceived();
@ConfigItem( @ConfigItem(
position = 36, position = 6,
keyName = "opaquePrivateMessageReceivedHighlight", keyName = "opaquePrivateMessageReceivedHighlight",
name = "Received private messages highlight", name = "Received private messages highlight",
description = "Color of highlights in Private messages you've received" description = "Color of highlights in Private messages you've received",
titleSection = "opaqueTitle"
) )
default Color opaquePrivateMessageReceivedHighlight() default Color opaquePrivateMessageReceivedHighlight()
{ {
@@ -88,10 +116,11 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 37, position = 7,
keyName = "opaqueClanChatInfo", keyName = "opaqueClanChatInfo",
name = "Clan chat info", name = "Clan chat info",
description = "Clan Chat Information (eg. when joining a channel)" description = "Clan Chat Information (eg. when joining a channel)",
titleSection = "opaqueTitle"
) )
default Color opaqueClanChatInfo() default Color opaqueClanChatInfo()
{ {
@@ -99,10 +128,11 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 38, position = 8,
keyName = "opaqueClanChatInfoHighlight", keyName = "opaqueClanChatInfoHighlight",
name = "Clan chat info highlight", name = "Clan chat info highlight",
description = "Clan Chat Information highlight (used for the Raids plugin)" description = "Clan Chat Information highlight (used for the Raids plugin)",
titleSection = "opaqueTitle"
) )
default Color opaqueClanChatInfoHighlight() default Color opaqueClanChatInfoHighlight()
{ {
@@ -110,18 +140,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 39, position = 9,
keyName = "opaqueClanChatMessage", keyName = "opaqueClanChatMessage",
name = "Clan chat message", name = "Clan chat message",
description = "Color of Clan Chat Messages" description = "Color of Clan Chat Messages",
titleSection = "opaqueTitle"
) )
Color opaqueClanChatMessage(); Color opaqueClanChatMessage();
@ConfigItem( @ConfigItem(
position = 40, position = 10,
keyName = "opaqueClanChatMessageHighlight", keyName = "opaqueClanChatMessageHighlight",
name = "Clan chat message highlight", name = "Clan chat message highlight",
description = "Color of highlights in Clan Chat Messages" description = "Color of highlights in Clan Chat Messages",
titleSection = "opaqueTitle"
) )
default Color opaqueClanChatMessageHighlight() default Color opaqueClanChatMessageHighlight()
{ {
@@ -129,66 +161,74 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 41, position = 11,
keyName = "opaqueAutochatMessage", keyName = "opaqueAutochatMessage",
name = "Autochat", name = "Autochat",
description = "Color of Autochat messages" description = "Color of Autochat messages",
titleSection = "opaqueTitle"
) )
Color opaqueAutochatMessage(); Color opaqueAutochatMessage();
@ConfigItem( @ConfigItem(
position = 42, position = 12,
keyName = "opaqueAutochatMessageHighlight", keyName = "opaqueAutochatMessageHighlight",
name = "Autochat highlight", name = "Autochat highlight",
description = "Color of highlights in Autochat messages" description = "Color of highlights in Autochat messages",
titleSection = "opaqueTitle"
) )
Color opaqueAutochatMessageHighlight(); Color opaqueAutochatMessageHighlight();
@ConfigItem( @ConfigItem(
position = 43, position = 13,
keyName = "opaqueTradeChatMessage", keyName = "opaqueTradeChatMessage",
name = "Trade chat", name = "Trade chat",
description = "Color of Trade Chat Messages" description = "Color of Trade Chat Messages",
titleSection = "opaqueTitle"
) )
Color opaqueTradeChatMessage(); Color opaqueTradeChatMessage();
@ConfigItem( @ConfigItem(
position = 44, position = 14,
keyName = "opaqueTradeChatMessageHighlight", keyName = "opaqueTradeChatMessageHighlight",
name = "Trade chat highlight", name = "Trade chat highlight",
description = "Color of highlights in Trade Chat Messages" description = "Color of highlights in Trade Chat Messages",
titleSection = "opaqueTitle"
) )
Color opaqueTradeChatMessageHighlight(); Color opaqueTradeChatMessageHighlight();
@ConfigItem( @ConfigItem(
position = 45, position = 15,
keyName = "opaqueServerMessage", keyName = "opaqueServerMessage",
name = "Server message", name = "Server message",
description = "Color of Server Messages (eg. 'Welcome to RuneScape')" description = "Color of Server Messages (eg. 'Welcome to RuneScape')",
titleSection = "opaqueTitle"
) )
Color opaqueServerMessage(); Color opaqueServerMessage();
@ConfigItem( @ConfigItem(
position = 46, position = 16,
keyName = "opaqueServerMessageHighlight", keyName = "opaqueServerMessageHighlight",
name = "Server message highlight", name = "Server message highlight",
description = "Color of highlights in Server Messages" description = "Color of highlights in Server Messages",
titleSection = "opaqueTitle"
) )
Color opaqueServerMessageHighlight(); Color opaqueServerMessageHighlight();
@ConfigItem( @ConfigItem(
position = 47, position = 17,
keyName = "opaqueGameMessage", keyName = "opaqueGameMessage",
name = "Game message", name = "Game message",
description = "Color of Game Messages" description = "Color of Game Messages",
titleSection = "opaqueTitle"
) )
Color opaqueGameMessage(); Color opaqueGameMessage();
@ConfigItem( @ConfigItem(
position = 48, position = 18,
keyName = "opaqueGameMessageHighlight", keyName = "opaqueGameMessageHighlight",
name = "Game message highlight", name = "Game message highlight",
description = "Color of highlights in Game Messages" description = "Color of highlights in Game Messages",
titleSection = "opaqueTitle"
) )
default Color opaqueGameMessageHighlight() default Color opaqueGameMessageHighlight()
{ {
@@ -196,18 +236,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 49, position = 19,
keyName = "opaqueExamine", keyName = "opaqueExamine",
name = "Examine", name = "Examine",
description = "Color of Examine Text" description = "Color of Examine Text",
titleSection = "opaqueTitle"
) )
Color opaqueExamine(); Color opaqueExamine();
@ConfigItem( @ConfigItem(
position = 50, position = 20,
keyName = "opaqueExamineHighlight", keyName = "opaqueExamineHighlight",
name = "Examine highlight", name = "Examine highlight",
description = "Color of highlights in Examine Text" description = "Color of highlights in Examine Text",
titleSection = "opaqueTitle"
) )
default Color opaqueExamineHighlight() default Color opaqueExamineHighlight()
{ {
@@ -215,74 +257,83 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 51, position = 21,
keyName = "opaqueFiltered", keyName = "opaqueFiltered",
name = "Filtered", name = "Filtered",
description = "Color of Filtered Text (messages that aren't shown when Game messages are filtered)" description = "Color of Filtered Text (messages that aren't shown when Game messages are filtered)",
titleSection = "opaqueTitle"
) )
Color opaqueFiltered(); Color opaqueFiltered();
@ConfigItem( @ConfigItem(
position = 52, position = 22,
keyName = "opaqueFilteredHighlight", keyName = "opaqueFilteredHighlight",
name = "Filtered highlight", name = "Filtered highlight",
description = "Color of highlights in Filtered Text" description = "Color of highlights in Filtered Text",
titleSection = "opaqueTitle"
) )
Color opaqueFilteredHighlight(); Color opaqueFilteredHighlight();
@ConfigItem( @ConfigItem(
position = 53, position = 23,
keyName = "opaqueUsername", keyName = "opaqueUsername",
name = "Usernames", name = "Usernames",
description = "Color of Usernames" description = "Color of Usernames",
titleSection = "opaqueTitle"
) )
Color opaqueUsername(); Color opaqueUsername();
@ConfigItem( @ConfigItem(
position = 54, position = 24,
keyName = "opaquePrivateUsernames", keyName = "opaquePrivateUsernames",
name = "Private chat usernames", name = "Private chat usernames",
description = "Color of Usernames in Private Chat" description = "Color of Usernames in Private Chat",
titleSection = "opaqueTitle"
) )
Color opaquePrivateUsernames(); Color opaquePrivateUsernames();
@ConfigItem( @ConfigItem(
position = 55, position = 25,
keyName = "opaqueClanChannelName", keyName = "opaqueClanChannelName",
name = "Clan channel name", name = "Clan channel name",
description = "Color of Clan Channel Name" description = "Color of Clan Channel Name",
titleSection = "opaqueTitle"
) )
Color opaqueClanChannelName(); Color opaqueClanChannelName();
@ConfigItem( @ConfigItem(
position = 56, position = 26,
keyName = "opaqueClanUsernames", keyName = "opaqueClanUsernames",
name = "Clan usernames", name = "Clan usernames",
description = "Color of Usernames in Clan Chat" description = "Color of Usernames in Clan Chat",
titleSection = "opaqueTitle"
) )
Color opaqueClanUsernames(); Color opaqueClanUsernames();
@ConfigItem( @ConfigItem(
position = 57, position = 27,
keyName = "opaquePublicFriendUsernames", keyName = "opaquePublicFriendUsernames",
name = "Public friend usernames", name = "Public friend usernames",
description = "Color of Friend Usernames in Public Chat" description = "Color of Friend Usernames in Public Chat",
titleSection = "opaqueTitle"
) )
Color opaquePublicFriendUsernames(); Color opaquePublicFriendUsernames();
@ConfigItem( @ConfigItem(
position = 61, position = 51,
keyName = "transparentPublicChat", keyName = "transparentPublicChat",
name = "Public chat (transparent)", name = "Public chat (transparent)",
description = "Color of Public chat (transparent)" description = "Color of Public chat (transparent)",
titleSection = "transparentTitle"
) )
Color transparentPublicChat(); Color transparentPublicChat();
@ConfigItem( @ConfigItem(
position = 62, position = 52,
keyName = "transparentPublicChatHighlight", keyName = "transparentPublicChatHighlight",
name = "Public chat highlight (transparent)", name = "Public chat highlight (transparent)",
description = "Color of highlights in Public chat (transparent)" description = "Color of highlights in Public chat (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentPublicChatHighlight() default Color transparentPublicChatHighlight()
{ {
@@ -290,18 +341,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 63, position = 53,
keyName = "transparentPrivateMessageSent", keyName = "transparentPrivateMessageSent",
name = "Sent private messages (transparent)", name = "Sent private messages (transparent)",
description = "Color of Private messages you've sent (transparent)" description = "Color of Private messages you've sent (transparent)",
titleSection = "transparentTitle"
) )
Color transparentPrivateMessageSent(); Color transparentPrivateMessageSent();
@ConfigItem( @ConfigItem(
position = 64, position = 54,
keyName = "transparentPrivateMessageSentHighlight", keyName = "transparentPrivateMessageSentHighlight",
name = "Sent private messages highlight (transparent)", name = "Sent private messages highlight (transparent)",
description = "Color of highlights in Private messages you've sent (transparent)" description = "Color of highlights in Private messages you've sent (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentPrivateMessageSentHighlight() default Color transparentPrivateMessageSentHighlight()
{ {
@@ -309,18 +362,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 65, position = 55,
keyName = "transparentPrivateMessageReceived", keyName = "transparentPrivateMessageReceived",
name = "Received private messages (transparent)", name = "Received private messages (transparent)",
description = "Color of Private messages you've received (transparent)" description = "Color of Private messages you've received (transparent)",
titleSection = "transparentTitle"
) )
Color transparentPrivateMessageReceived(); Color transparentPrivateMessageReceived();
@ConfigItem( @ConfigItem(
position = 66, position = 56,
keyName = "transparentPrivateMessageReceivedHighlight", keyName = "transparentPrivateMessageReceivedHighlight",
name = "Received private messages highlight (transparent)", name = "Received private messages highlight (transparent)",
description = "Color of highlights in Private messages you've received (transparent)" description = "Color of highlights in Private messages you've received (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentPrivateMessageReceivedHighlight() default Color transparentPrivateMessageReceivedHighlight()
{ {
@@ -328,10 +383,11 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 67, position = 57,
keyName = "transparentClanChatInfo", keyName = "transparentClanChatInfo",
name = "Clan chat info (transparent)", name = "Clan chat info (transparent)",
description = "Clan Chat Information (eg. when joining a channel) (transparent)" description = "Clan Chat Information (eg. when joining a channel) (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentClanChatInfo() default Color transparentClanChatInfo()
{ {
@@ -339,10 +395,11 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 68, position = 58,
keyName = "transparentClanChatInfoHighlight", keyName = "transparentClanChatInfoHighlight",
name = "Clan chat info highlight (transparent)", name = "Clan chat info highlight (transparent)",
description = "Clan Chat Information highlight (used for the Raids plugin) (transparent)" description = "Clan Chat Information highlight (used for the Raids plugin) (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentClanChatInfoHighlight() default Color transparentClanChatInfoHighlight()
{ {
@@ -350,18 +407,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 69, position = 59,
keyName = "transparentClanChatMessage", keyName = "transparentClanChatMessage",
name = "Clan chat message (transparent)", name = "Clan chat message (transparent)",
description = "Color of Clan Chat Messages (transparent)" description = "Color of Clan Chat Messages (transparent)",
titleSection = "transparentTitle"
) )
Color transparentClanChatMessage(); Color transparentClanChatMessage();
@ConfigItem( @ConfigItem(
position = 70, position = 60,
keyName = "transparentClanChatMessageHighlight", keyName = "transparentClanChatMessageHighlight",
name = "Clan chat message highlight (transparent)", name = "Clan chat message highlight (transparent)",
description = "Color of highlights in Clan Chat Messages (transparent)" description = "Color of highlights in Clan Chat Messages (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentClanChatMessageHighlight() default Color transparentClanChatMessageHighlight()
{ {
@@ -369,66 +428,74 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 71, position = 61,
keyName = "transparentAutochatMessage", keyName = "transparentAutochatMessage",
name = "Autochat (transparent)", name = "Autochat (transparent)",
description = "Color of Autochat messages (transparent)" description = "Color of Autochat messages (transparent)",
titleSection = "transparentTitle"
) )
Color transparentAutochatMessage(); Color transparentAutochatMessage();
@ConfigItem( @ConfigItem(
position = 72, position = 62,
keyName = "transparentAutochatMessageHighlight", keyName = "transparentAutochatMessageHighlight",
name = "Autochat highlight (transparent)", name = "Autochat highlight (transparent)",
description = "Color of highlights in Autochat messages (transparent)" description = "Color of highlights in Autochat messages (transparent)",
titleSection = "transparentTitle"
) )
Color transparentAutochatMessageHighlight(); Color transparentAutochatMessageHighlight();
@ConfigItem( @ConfigItem(
position = 73, position = 63,
keyName = "transparentTradeChatMessage", keyName = "transparentTradeChatMessage",
name = "Trade chat (transparent)", name = "Trade chat (transparent)",
description = "Color of Trade Chat Messages (transparent)" description = "Color of Trade Chat Messages (transparent)",
titleSection = "transparentTitle"
) )
Color transparentTradeChatMessage(); Color transparentTradeChatMessage();
@ConfigItem( @ConfigItem(
position = 74, position = 64,
keyName = "transparentTradeChatMessageHighlight", keyName = "transparentTradeChatMessageHighlight",
name = "Trade chat highlight (transparent)", name = "Trade chat highlight (transparent)",
description = "Color of highlights in Trade Chat Messages (transparent)" description = "Color of highlights in Trade Chat Messages (transparent)",
titleSection = "transparentTitle"
) )
Color transparentTradeChatMessageHighlight(); Color transparentTradeChatMessageHighlight();
@ConfigItem( @ConfigItem(
position = 75, position = 65,
keyName = "transparentServerMessage", keyName = "transparentServerMessage",
name = "Server message (transparent)", name = "Server message (transparent)",
description = "Color of Server Messages (eg. 'Welcome to RuneScape') (transparent)" description = "Color of Server Messages (eg. 'Welcome to RuneScape') (transparent)",
titleSection = "transparentTitle"
) )
Color transparentServerMessage(); Color transparentServerMessage();
@ConfigItem( @ConfigItem(
position = 76, position = 66,
keyName = "transparentServerMessageHighlight", keyName = "transparentServerMessageHighlight",
name = "Server message highlight (transparent)", name = "Server message highlight (transparent)",
description = "Color of highlights in Server Messages (transparent)" description = "Color of highlights in Server Messages (transparent)",
titleSection = "transparentTitle"
) )
Color transparentServerMessageHighlight(); Color transparentServerMessageHighlight();
@ConfigItem( @ConfigItem(
position = 77, position = 67,
keyName = "transparentGameMessage", keyName = "transparentGameMessage",
name = "Game message (transparent)", name = "Game message (transparent)",
description = "Color of Game Messages (transparent)" description = "Color of Game Messages (transparent)",
titleSection = "transparentTitle"
) )
Color transparentGameMessage(); Color transparentGameMessage();
@ConfigItem( @ConfigItem(
position = 78, position = 68,
keyName = "transparentGameMessageHighlight", keyName = "transparentGameMessageHighlight",
name = "Game message highlight (transparent)", name = "Game message highlight (transparent)",
description = "Color of highlights in Game Messages (transparent)" description = "Color of highlights in Game Messages (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentGameMessageHighlight() default Color transparentGameMessageHighlight()
{ {
@@ -436,18 +503,20 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 79, position = 69,
keyName = "transparentExamine", keyName = "transparentExamine",
name = "Examine (transparent)", name = "Examine (transparent)",
description = "Color of Examine Text (transparent)" description = "Color of Examine Text (transparent)",
titleSection = "transparentTitle"
) )
Color transparentExamine(); Color transparentExamine();
@ConfigItem( @ConfigItem(
position = 80, position = 70,
keyName = "transparentExamineHighlight", keyName = "transparentExamineHighlight",
name = "Examine highlight (transparent)", name = "Examine highlight (transparent)",
description = "Color of highlights in Examine Text (transparent)" description = "Color of highlights in Examine Text (transparent)",
titleSection = "transparentTitle"
) )
default Color transparentExamineHighlight() default Color transparentExamineHighlight()
{ {
@@ -455,58 +524,65 @@ public interface ChatColorConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 81, position = 71,
keyName = "transparentFiltered", keyName = "transparentFiltered",
name = "Filtered (transparent)", name = "Filtered (transparent)",
description = "Color of Filtered Text (messages that aren't shown when Game messages are filtered) (transparent)" description = "Color of Filtered Text (messages that aren't shown when Game messages are filtered) (transparent)",
titleSection = "transparentTitle"
) )
Color transparentFiltered(); Color transparentFiltered();
@ConfigItem( @ConfigItem(
position = 82, position = 72,
keyName = "transparentFilteredHighlight", keyName = "transparentFilteredHighlight",
name = "Filtered highlight (transparent)", name = "Filtered highlight (transparent)",
description = "Color of highlights in Filtered Text (transparent)" description = "Color of highlights in Filtered Text (transparent)",
titleSection = "transparentTitle"
) )
Color transparentFilteredHighlight(); Color transparentFilteredHighlight();
@ConfigItem( @ConfigItem(
position = 83, position = 73,
keyName = "transparentUsername", keyName = "transparentUsername",
name = "Usernames (transparent)", name = "Usernames (transparent)",
description = "Color of Usernames (transparent)" description = "Color of Usernames (transparent)",
titleSection = "transparentTitle"
) )
Color transparentUsername(); Color transparentUsername();
@ConfigItem( @ConfigItem(
position = 84, position = 74,
keyName = "transparentPrivateUsernames", keyName = "transparentPrivateUsernames",
name = "Private chat usernames (transparent)", name = "Private chat usernames (transparent)",
description = "Color of Usernames in Private Chat (transparent)" description = "Color of Usernames in Private Chat (transparent)",
titleSection = "transparentTitle"
) )
Color transparentPrivateUsernames(); Color transparentPrivateUsernames();
@ConfigItem( @ConfigItem(
position = 85, position = 75,
keyName = "transparentClanChannelName", keyName = "transparentClanChannelName",
name = "Clan channel name (transparent)", name = "Clan channel name (transparent)",
description = "Color of Clan Channel Name (transparent)" description = "Color of Clan Channel Name (transparent)",
titleSection = "transparentTitle"
) )
Color transparentClanChannelName(); Color transparentClanChannelName();
@ConfigItem( @ConfigItem(
position = 86, position = 76,
keyName = "transparentClanUsernames", keyName = "transparentClanUsernames",
name = "Clan usernames (transparent)", name = "Clan usernames (transparent)",
description = "Color of Usernames in Clan Chat (transparent)" description = "Color of Usernames in Clan Chat (transparent)",
titleSection = "transparentTitle"
) )
Color transparentClanUsernames(); Color transparentClanUsernames();
@ConfigItem( @ConfigItem(
position = 87, position = 77,
keyName = "transparentPublicFriendUsernames", keyName = "transparentPublicFriendUsernames",
name = "Public friend usernames (transparent)", name = "Public friend usernames (transparent)",
description = "Color of Friend Usernames in Public Chat (transparent)" description = "Color of Friend Usernames in Public Chat (transparent)",
titleSection = "transparentTitle"
) )
Color transparentPublicFriendUsernames(); Color transparentPublicFriendUsernames();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Shingyx <https://github.com/Shingyx> * Copyright (c) 2020, Shingyx <https://github.com/Shingyx>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -31,24 +31,20 @@ import java.awt.Point;
import java.awt.dnd.DragSource; import java.awt.dnd.DragSource;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JLayeredPane; import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
/** /**
* Pane which allows reordering its components via drag and drop. * Pane which allows reordering its components via drag and drop.
* <p>
* For child components' popup menus, implement the PopupMenuOwner interface in the child components.
*/ */
public class DragAndDropReorderPane extends JLayeredPane public class DragAndDropReorderPane extends JLayeredPane
{ {
private Point dragStartPoint; private Point dragStartPoint;
private Component draggingComponent; private Component draggingComponent;
private int dragYOffset = 0;
private int dragIndex = -1; private int dragIndex = -1;
private final Map<Integer, PopupMenuOwner> popupMenuCandidates = new HashMap<>(); // keyed by mouse button
public DragAndDropReorderPane() public DragAndDropReorderPane()
{ {
super(); super();
@@ -76,6 +72,7 @@ public class DragAndDropReorderPane extends JLayeredPane
dragStartPoint = null; dragStartPoint = null;
return; return;
} }
dragYOffset = SwingUtilities.convertPoint(this, dragStartPoint, draggingComponent).y;
dragIndex = getPosition(draggingComponent); dragIndex = getPosition(draggingComponent);
setLayer(draggingComponent, DRAG_LAYER); setLayer(draggingComponent, DRAG_LAYER);
moveDraggingComponent(point); moveDraggingComponent(point);
@@ -85,7 +82,13 @@ public class DragAndDropReorderPane extends JLayeredPane
{ {
moveDraggingComponent(point); moveDraggingComponent(point);
Component component = getDefaultLayerComponentAt(point); // reorder components overlapping with the dragging components mid-point
Point draggingComponentMidPoint = SwingUtilities.convertPoint(
draggingComponent,
new Point(draggingComponent.getWidth() / 2, draggingComponent.getHeight() / 2),
this
);
Component component = getDefaultLayerComponentAt(draggingComponentMidPoint);
if (component != null) if (component != null)
{ {
int index = getPosition(component); int index = getPosition(component);
@@ -99,17 +102,18 @@ public class DragAndDropReorderPane extends JLayeredPane
if (draggingComponent != null) if (draggingComponent != null)
{ {
setLayer(draggingComponent, DEFAULT_LAYER, dragIndex); setLayer(draggingComponent, DEFAULT_LAYER, dragIndex);
draggingComponent = null;
dragYOffset = 0;
dragIndex = -1;
revalidate(); revalidate();
} }
dragStartPoint = null; dragStartPoint = null;
draggingComponent = null;
dragIndex = -1;
} }
private void moveDraggingComponent(Point point) private void moveDraggingComponent(Point point)
{ {
// place the center of the dragging component onto the mouse cursor // shift the dragging component to match it's earlier y offset with the mouse
int y = point.y - draggingComponent.getHeight() / 2; int y = point.y - dragYOffset;
// clamp the height to stay within the pane // clamp the height to stay within the pane
y = Math.max(y, 0); y = Math.max(y, 0);
y = Math.min(y, getHeight() - draggingComponent.getHeight()); y = Math.min(y, getHeight() - draggingComponent.getHeight());
@@ -160,88 +164,36 @@ public class DragAndDropReorderPane extends JLayeredPane
@Override @Override
public void mousePressed(MouseEvent e) public void mousePressed(MouseEvent e)
{ {
Point point = e.getPoint(); if (SwingUtilities.isLeftMouseButton(e) && getComponentCount() > 1)
int mouseButton = e.getButton();
if (mouseButton == MouseEvent.BUTTON1)
{ {
// candidate for dragging dragStartPoint = e.getPoint();
if (popupMenuCandidates.isEmpty() && getComponentCount() > 1)
{
dragStartPoint = point;
}
}
else
{
if (dragStartPoint != null)
{
finishDragging();
}
else
{
// candidate for child popup menu
Component component = getDefaultLayerComponentAt(point);
if (component instanceof PopupMenuOwner)
{
PopupMenuOwner popupMenuCandidate = (PopupMenuOwner) component;
if (e.isPopupTrigger())
{
popupMenuCandidate.getPopupMenu().show(DragAndDropReorderPane.this, point.x, point.y);
}
else
{
popupMenuCandidates.put(mouseButton, popupMenuCandidate);
}
}
}
} }
} }
@Override @Override
public void mouseDragged(MouseEvent e) public void mouseDragged(MouseEvent e)
{ {
if (dragStartPoint == null) if (SwingUtilities.isLeftMouseButton(e) && dragStartPoint != null)
{ {
return;
}
Point point = e.getPoint(); Point point = e.getPoint();
if (contains(point)) if (draggingComponent != null)
{
if (draggingComponent == null)
{
if (point.distance(dragStartPoint) > DragSource.getDragThreshold())
{
startDragging(point);
}
}
else
{ {
drag(point); drag(point);
} }
} else if (point.distance(dragStartPoint) > DragSource.getDragThreshold())
else
{ {
finishDragging(); startDragging(point);
}
} }
} }
@Override @Override
public void mouseReleased(MouseEvent e) public void mouseReleased(MouseEvent e)
{ {
Point point = e.getPoint(); if (SwingUtilities.isLeftMouseButton(e))
int mouseButton = e.getButton();
if (mouseButton == MouseEvent.BUTTON1)
{ {
finishDragging(); finishDragging();
} }
else
{
PopupMenuOwner popupMenuCandidate = popupMenuCandidates.remove(mouseButton);
if (popupMenuCandidate != null && e.isPopupTrigger())
{
popupMenuCandidate.getPopupMenu().show(DragAndDropReorderPane.this, point.x, point.y);
}
}
} }
} }
} }

View File

@@ -29,7 +29,6 @@ package net.runelite.client.ui.components;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
@@ -38,6 +37,8 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@@ -77,6 +78,8 @@ public class IconTextField extends JPanel
@Getter @Getter
private final DefaultListModel<String> suggestionListModel; private final DefaultListModel<String> suggestionListModel;
private final List<Runnable> clearListeners = new ArrayList<>();
public IconTextField() public IconTextField()
{ {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
@@ -124,7 +127,15 @@ public class IconTextField extends JPanel
clearButton = createRHSButton(ColorScheme.PROGRESS_ERROR_COLOR, Color.PINK); clearButton = createRHSButton(ColorScheme.PROGRESS_ERROR_COLOR, Color.PINK);
clearButton.setText("×"); clearButton.setText("×");
clearButton.addActionListener(evt -> setText(null)); clearButton.addActionListener(evt ->
{
setText(null);
for (Runnable l : clearListeners)
{
l.run();
}
});
suggestionListModel = new DefaultListModel<>(); suggestionListModel = new DefaultListModel<>();
suggestionListModel.addListDataListener(new ListDataListener() suggestionListModel.addListDataListener(new ListDataListener()
@@ -318,9 +329,9 @@ public class IconTextField extends JPanel
textField.addKeyListener(keyListener); textField.addKeyListener(keyListener);
} }
public void addClearListener(Consumer<ActionEvent> actionEventConsumer) public void addClearListener(Runnable clearListener)
{ {
clearButton.addActionListener(actionEventConsumer::accept); clearListeners.add(clearListener);
} }
public void addKeyListener(Consumer<KeyEvent> keyEventConsumer) public void addKeyListener(Consumer<KeyEvent> keyEventConsumer)

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2020, Shingyx <https://github.com/Shingyx>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.ui.components;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities;
/**
* Forwards left mouse button drag events to the target Component.
*/
public class MouseDragEventForwarder extends MouseAdapter
{
private final Component target;
public MouseDragEventForwarder(Component target)
{
this.target = target;
}
@Override
public void mousePressed(MouseEvent e)
{
processEvent(e);
}
@Override
public void mouseDragged(MouseEvent e)
{
processEvent(e);
}
@Override
public void mouseReleased(MouseEvent e)
{
processEvent(e);
}
private void processEvent(MouseEvent e)
{
if (SwingUtilities.isLeftMouseButton(e))
{
MouseEvent eventForTarget = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, target);
target.dispatchEvent(eventForTarget);
}
}
}

View File

@@ -6,9 +6,6 @@
; callback "confirmClanKick" ; callback "confirmClanKick"
; Used by the ClanChat plugin to show a chatbox panel confirming the requested kick ; Used by the ClanChat plugin to show a chatbox panel confirming the requested kick
; Also requires the "confirmKicks" option of ClanChatConfig to be enabled ; Also requires the "confirmKicks" option of ClanChatConfig to be enabled
; callback "sendKickName"
; Used by the ClanChat plugin to modify the kick message to include player name
; Also requires the "kickWithName" option of ClanChatConfig to be enabled
invoke 1942 invoke 1942
iconst 1 iconst 1
if_icmpeq LABEL4 if_icmpeq LABEL4
@@ -19,10 +16,6 @@ LABEL4:
return return
LABEL7: LABEL7:
sconst "-Attempting to kick player from friends chat..." sconst "-Attempting to kick player from friends chat..."
sload 0 ; Username we are kicking
sconst "sendKickName"
runelite_callback
pop_string ; Username we are kicking
iconst 2 iconst 2
invoke 96 invoke 96
sload 0 sload 0