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,20 +96,18 @@ public class ItemManager implements ItemProvider
public void java(File java) throws IOException
{
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())
if (def.name.equalsIgnoreCase("NULL"))
{
if (def.name.equalsIgnoreCase("NULL"))
{
nulls.add(def.name, def.id);
}
else
{
ids.add(def.name, def.id);
}
nulls.add(def.name, def.id);
}
else
{
ids.add(def.name, def.id);
}
}
}

View File

@@ -95,16 +95,19 @@ public class NpcManager
public void java(File java) throws IOException
{
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())
{
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,20 +95,18 @@ public class ObjectManager
public void java(File java) throws IOException
{
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())
if ("null".equals(def.getName()))
{
if ("null".equals(def.getName()))
{
nulls.add(def.getName(), def.getId());
}
else
{
ids.add(def.getName(), def.getId());
}
nulls.add(def.getName(), def.getId());
}
else
{
ids.add(def.getName(), def.getId());
}
}
}

View File

@@ -38,6 +38,7 @@ public class GrandExchangeTrade
private int dqty;
private int total;
private int spent;
private int dspent;
private int offer;
private int slot;
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 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 java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.WordUtils;
import org.apache.commons.text.similarity.JaroWinklerDistance;
@@ -38,6 +40,7 @@ import org.apache.commons.text.similarity.JaroWinklerDistance;
public class Text
{
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 Splitter COMMA_SPLITTER = Splitter
.on(",")
@@ -150,6 +153,32 @@ public class Text
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

View File

@@ -250,6 +250,16 @@ public interface Widget
*/
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.
*
@@ -288,18 +298,18 @@ public interface Widget
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();
/**
* 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.
@@ -316,6 +326,20 @@ public interface Widget
*/
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
*

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

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.
*
* 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.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.BoxLayout;
import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
/**
* 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
{
private Point dragStartPoint;
private Component draggingComponent;
private int dragYOffset = 0;
private int dragIndex = -1;
private final Map<Integer, PopupMenuOwner> popupMenuCandidates = new HashMap<>(); // keyed by mouse button
public DragAndDropReorderPane()
{
super();
@@ -76,6 +72,7 @@ public class DragAndDropReorderPane extends JLayeredPane
dragStartPoint = null;
return;
}
dragYOffset = SwingUtilities.convertPoint(this, dragStartPoint, draggingComponent).y;
dragIndex = getPosition(draggingComponent);
setLayer(draggingComponent, DRAG_LAYER);
moveDraggingComponent(point);
@@ -85,7 +82,13 @@ public class DragAndDropReorderPane extends JLayeredPane
{
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)
{
int index = getPosition(component);
@@ -99,17 +102,18 @@ public class DragAndDropReorderPane extends JLayeredPane
if (draggingComponent != null)
{
setLayer(draggingComponent, DEFAULT_LAYER, dragIndex);
draggingComponent = null;
dragYOffset = 0;
dragIndex = -1;
revalidate();
}
dragStartPoint = null;
draggingComponent = null;
dragIndex = -1;
}
private void moveDraggingComponent(Point point)
{
// place the center of the dragging component onto the mouse cursor
int y = point.y - draggingComponent.getHeight() / 2;
// shift the dragging component to match it's earlier y offset with the mouse
int y = point.y - dragYOffset;
// clamp the height to stay within the pane
y = Math.max(y, 0);
y = Math.min(y, getHeight() - draggingComponent.getHeight());
@@ -160,88 +164,36 @@ public class DragAndDropReorderPane extends JLayeredPane
@Override
public void mousePressed(MouseEvent e)
{
Point point = e.getPoint();
int mouseButton = e.getButton();
if (mouseButton == MouseEvent.BUTTON1)
if (SwingUtilities.isLeftMouseButton(e) && getComponentCount() > 1)
{
// candidate for dragging
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);
}
}
}
dragStartPoint = e.getPoint();
}
}
@Override
public void mouseDragged(MouseEvent e)
{
if (dragStartPoint == null)
if (SwingUtilities.isLeftMouseButton(e) && dragStartPoint != null)
{
return;
}
Point point = e.getPoint();
if (contains(point))
{
if (draggingComponent == null)
{
if (point.distance(dragStartPoint) > DragSource.getDragThreshold())
{
startDragging(point);
}
}
else
Point point = e.getPoint();
if (draggingComponent != null)
{
drag(point);
}
}
else
{
finishDragging();
else if (point.distance(dragStartPoint) > DragSource.getDragThreshold())
{
startDragging(point);
}
}
}
@Override
public void mouseReleased(MouseEvent e)
{
Point point = e.getPoint();
int mouseButton = e.getButton();
if (mouseButton == MouseEvent.BUTTON1)
if (SwingUtilities.isLeftMouseButton(e))
{
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.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
@@ -38,6 +37,8 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
@@ -77,6 +78,8 @@ public class IconTextField extends JPanel
@Getter
private final DefaultListModel<String> suggestionListModel;
private final List<Runnable> clearListeners = new ArrayList<>();
public IconTextField()
{
setLayout(new BorderLayout());
@@ -124,7 +127,15 @@ public class IconTextField extends JPanel
clearButton = createRHSButton(ColorScheme.PROGRESS_ERROR_COLOR, Color.PINK);
clearButton.setText("×");
clearButton.addActionListener(evt -> setText(null));
clearButton.addActionListener(evt ->
{
setText(null);
for (Runnable l : clearListeners)
{
l.run();
}
});
suggestionListModel = new DefaultListModel<>();
suggestionListModel.addListDataListener(new ListDataListener()
@@ -318,9 +329,9 @@ public class IconTextField extends JPanel
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)

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"
; Used by the ClanChat plugin to show a chatbox panel confirming the requested kick
; 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
iconst 1
if_icmpeq LABEL4
@@ -19,10 +16,6 @@ LABEL4:
return
LABEL7:
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
invoke 96
sload 0