player indicators: decorate player name in trade window
Co-authored-by: Vandager <66982484+Vandager@users.noreply.github.com>
This commit is contained in:
@@ -408,4 +408,10 @@ public final class ScriptID
|
||||
|
||||
@ScriptArguments(integer = 6)
|
||||
public static final int INVENTORY_DRAWITEM = 6011;
|
||||
|
||||
/**
|
||||
* Initializes the trade interface
|
||||
*/
|
||||
@ScriptArguments(integer = 6)
|
||||
public static final int TRADE_MAIN_INIT = 755;
|
||||
}
|
||||
@@ -174,6 +174,7 @@ public final class WidgetID
|
||||
public static final int GROUP_STORAGE_INVENTORY_GROUP_ID = 725;
|
||||
public static final int GROUP_STORAGE_GROUP_ID = 724;
|
||||
public static final int WILDERNESS_LOOT_CHEST = 742;
|
||||
public static final int TRADE_WINDOW_GROUP_ID = 335;
|
||||
|
||||
static class WorldMap
|
||||
{
|
||||
@@ -936,4 +937,9 @@ public final class WidgetID
|
||||
static final int HEADER = 1;
|
||||
static final int MEMBERS = 6;
|
||||
}
|
||||
|
||||
static class Trade
|
||||
{
|
||||
static final int HEADER = 31;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,6 +561,8 @@ public enum WidgetInfo
|
||||
CLAN_GUEST_MEMBER_LIST(WidgetID.CLAN_GUEST_GROUP_ID, WidgetID.ClanGuest.MEMBERS),
|
||||
|
||||
POH_TREASURE_CHEST_INVENTORY_CONTAINER(WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID, 0),
|
||||
|
||||
TRADE_WINDOW_HEADER(WidgetID.TRADE_WINDOW_GROUP_ID, WidgetID.Trade.HEADER),
|
||||
;
|
||||
|
||||
private final int groupId;
|
||||
|
||||
@@ -42,12 +42,17 @@ import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION;
|
||||
import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION;
|
||||
import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION;
|
||||
import static net.runelite.api.MenuAction.RUNELITE_PLAYER;
|
||||
import static net.runelite.api.MenuAction.WIDGET_TARGET_ON_PLAYER;
|
||||
import static net.runelite.api.MenuAction.WALK;
|
||||
import static net.runelite.api.MenuAction.WIDGET_TARGET_ON_PLAYER;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.ScriptID;
|
||||
import net.runelite.api.clan.ClanTitle;
|
||||
import net.runelite.api.events.ClientTick;
|
||||
import net.runelite.api.events.ScriptPostFired;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.game.ChatIconManager;
|
||||
@@ -63,6 +68,8 @@ import net.runelite.client.util.ColorUtil;
|
||||
)
|
||||
public class PlayerIndicatorsPlugin extends Plugin
|
||||
{
|
||||
private static final String TRADING_WITH_TEXT = "Trading with: ";
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@@ -87,6 +94,9 @@ public class PlayerIndicatorsPlugin extends Plugin
|
||||
@Inject
|
||||
private ChatIconManager chatIconManager;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Provides
|
||||
PlayerIndicatorsConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -249,6 +259,44 @@ public class PlayerIndicatorsPlugin extends Plugin
|
||||
return newTarget;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onScriptPostFired(ScriptPostFired event)
|
||||
{
|
||||
if (event.getScriptId() == ScriptID.TRADE_MAIN_INIT)
|
||||
{
|
||||
clientThread.invokeLater(() ->
|
||||
{
|
||||
Widget tradeTitle = client.getWidget(WidgetInfo.TRADE_WINDOW_HEADER);
|
||||
String header = tradeTitle.getText();
|
||||
String playerName = header.substring(TRADING_WITH_TEXT.length());
|
||||
|
||||
Player targetPlayer = findPlayer(playerName);
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Decorations playerColor = getDecorations(targetPlayer);
|
||||
if (playerColor != null)
|
||||
{
|
||||
tradeTitle.setText(TRADING_WITH_TEXT + ColorUtil.wrapWithColorTag(playerName, playerColor.color));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Player findPlayer(String name)
|
||||
{
|
||||
for (Player player : client.getPlayers())
|
||||
{
|
||||
if (player.getName().equals(name))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class Decorations
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user