use of net.runelite.api.MenuEntry in project runelite by runelite.
the class PlayerIndicatorsPlugin method onMenuEntryAdd.
@Subscribe
public void onMenuEntryAdd(MenuEntryAdded menuEntryAdded) {
int type = menuEntryAdded.getType();
int identifier = menuEntryAdded.getIdentifier();
if (type == FOLLOW.getId() || type == TRADE.getId() || type == SPELL_CAST_ON_PLAYER.getId() || type == ITEM_USE_ON_PLAYER.getId() || type == PLAYER_FIRST_OPTION.getId() || type == PLAYER_SECOND_OPTION.getId() || type == PLAYER_THIRD_OPTION.getId() || type == PLAYER_FOURTH_OPTION.getId() || type == PLAYER_FIFTH_OPTION.getId() || type == PLAYER_SIXTH_OPTION.getId() || type == PLAYER_SEVENTH_OPTION.getId() || type == PLAYER_EIGTH_OPTION.getId()) {
final Player localPlayer = client.getLocalPlayer();
Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length) {
player = players[identifier];
}
if (player == null) {
return;
}
int image = -1;
Color color = null;
if (config.drawFriendNames() && player.isFriend()) {
color = config.getFriendNameColor();
} else if (config.drawClanMemberNames() && player.isClanMember()) {
color = config.getClanMemberColor();
ClanMemberRank rank = clanManager.getRank(player.getName());
if (rank != UNRANKED) {
image = clanManager.getIconNumber(rank);
}
} else if (config.drawTeamMemberNames() && player.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) {
color = config.getTeamMemberColor();
} else if (config.drawNonClanMemberNames() && !player.isClanMember()) {
color = config.getNonClanMemberColor();
}
if (image != -1 || color != null) {
MenuEntry[] menuEntries = client.getMenuEntries();
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
if (color != null) {
// strip out existing <col...
String target = lastEntry.getTarget();
int idx = target.indexOf('>');
if (idx != -1) {
target = target.substring(idx + 1);
}
lastEntry.setTarget("<col=" + Integer.toHexString(color.getRGB() & 0xFFFFFF) + ">" + target);
}
if (image != -1) {
lastEntry.setTarget("<img=" + image + ">" + lastEntry.getTarget());
}
client.setMenuEntries(menuEntries);
}
}
}
use of net.runelite.api.MenuEntry in project runelite by runelite.
the class RSClientMixin method setMenuEntries.
@Inject
@Override
public void setMenuEntries(MenuEntry[] entries) {
int count = 0;
String[] menuOptions = getMenuOptions();
String[] menuTargets = getMenuTargets();
int[] menuIdentifiers = getMenuIdentifiers();
int[] menuTypes = getMenuTypes();
int[] params0 = getMenuActionParams0();
int[] params1 = getMenuActionParams1();
for (MenuEntry entry : entries) {
menuOptions[count] = entry.getOption();
menuTargets[count] = entry.getTarget();
menuIdentifiers[count] = entry.getIdentifier();
menuTypes[count] = entry.getType();
params0[count] = entry.getParam0();
params1[count] = entry.getParam1();
++count;
}
setMenuOptionCount(count);
}
use of net.runelite.api.MenuEntry in project runelite by runelite.
the class MenuManager method menuContainsCustomMenu.
private boolean menuContainsCustomMenu(WidgetMenuOption customMenuOption) {
Client client = clientProvider.get();
if (client == null) {
return false;
}
for (MenuEntry menuEntry : client.getMenuEntries()) {
String option = menuEntry.getOption();
String target = menuEntry.getTarget();
if (option.equals(customMenuOption.getMenuOption()) && target.equals(customMenuOption.getMenuTarget())) {
return true;
}
}
return false;
}
use of net.runelite.api.MenuEntry in project runelite by runelite.
the class MenuEntrySwapperPlugin method swap.
private void swap(String optionA, String optionB, String target, boolean strict) {
MenuEntry[] entries = client.getMenuEntries();
int idxA = searchIndex(entries, optionA, target, strict);
int idxB = searchIndex(entries, optionB, target, strict);
if (idxA >= 0 && idxB >= 0) {
MenuEntry entry = entries[idxA];
entries[idxA] = entries[idxB];
entries[idxB] = entry;
client.setMenuEntries(entries);
}
}
use of net.runelite.api.MenuEntry in project runelite by runelite.
the class GroundItemsPlugin method onMenuEntryAdded.
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event) {
if ((config.highlightMenuOption() || config.highlightMenuItemName()) && event.getOption().equals("Take") && event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId()) {
int itemId = event.getIdentifier();
ItemComposition itemComposition = client.getItemDefinition(itemId);
if (isHidden(itemComposition.getName())) {
return;
}
Region region = client.getRegion();
Tile tile = region.getTiles()[client.getPlane()][event.getActionParam0()][event.getActionParam1()];
ItemLayer itemLayer = tile.getItemLayer();
if (itemLayer == null) {
return;
}
MenuEntry[] menuEntries = client.getMenuEntries();
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
int quantity = 1;
Node current = itemLayer.getBottom();
while (current instanceof Item) {
Item item = (Item) current;
if (item.getId() == itemId) {
quantity = item.getQuantity();
}
current = current.getNext();
}
ItemPrice itemPrice = getItemPrice(itemComposition);
int price = itemPrice == null ? itemComposition.getPrice() : itemPrice.getPrice();
int cost = quantity * price;
Color color = overlay.getCostColor(cost, isHighlighted(itemComposition.getName()), isHidden(itemComposition.getName()));
if (!color.equals(config.defaultColor())) {
String hexColor = Integer.toHexString(color.getRGB() & 0xFFFFFF);
String colTag = "<col=" + hexColor + ">";
if (config.highlightMenuOption()) {
lastEntry.setOption(colTag + "Take");
}
if (config.highlightMenuItemName()) {
String target = lastEntry.getTarget().substring(lastEntry.getTarget().indexOf(">") + 1);
lastEntry.setTarget(colTag + target);
}
}
if (config.showMenuItemQuantities() && itemComposition.isStackable() && quantity > 1) {
lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")");
}
client.setMenuEntries(menuEntries);
}
}
Aggregations