Merge remote-tracking branch 'runelite/master'
This commit is contained in:
@@ -123,6 +123,27 @@ public interface MenuEntry
|
|||||||
@Nullable
|
@Nullable
|
||||||
Widget getWidget();
|
Widget getWidget();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link NPC} this menu entry is targeting, if any.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
NPC getNpc();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link Player} this menu entry is targeting, if any.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
Player getPlayer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link Actor} this menu entry is targeting, if any.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
Actor getActor();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
int getOpcode();
|
int getOpcode();
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -183,6 +183,14 @@ public interface Widget
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
void setRelativeY(int y);
|
void setRelativeY(int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a forced position for the widget. This position overrides the relative x/y for the
|
||||||
|
* widget, even if the widget is revalidated. To clear the forced position pass -1 for x/y.
|
||||||
|
* @param x x pos relative to the parent
|
||||||
|
* @param y y pos relative to the parent
|
||||||
|
*/
|
||||||
|
void setForcedPosition(int x, int y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the text displayed on this widget.
|
* Gets the text displayed on this widget.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -118,9 +118,8 @@ public class CrowdsourcingThieving
|
|||||||
{
|
{
|
||||||
if (event.getMenuOption().equals("Pickpocket") || event.getMenuOption().equals("Knock-Out"))
|
if (event.getMenuOption().equals("Pickpocket") || event.getMenuOption().equals("Knock-Out"))
|
||||||
{
|
{
|
||||||
NPC[] cachedNPCs = client.getCachedNPCs();
|
NPC npc = event.getMenuEntry().getNpc();
|
||||||
NPC npc = cachedNPCs[event.getId()];
|
lastPickpocketTarget = npc != null ? npc.getId() : -1;
|
||||||
lastPickpocketTarget = npc.getId();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,7 +476,8 @@ public class DevToolsPlugin extends Plugin
|
|||||||
|
|
||||||
if (action == MenuAction.EXAMINE_NPC)
|
if (action == MenuAction.EXAMINE_NPC)
|
||||||
{
|
{
|
||||||
NPC npc = client.getCachedNPCs()[identifier];
|
NPC npc = entry.getNpc();
|
||||||
|
assert npc != null;
|
||||||
info += npc.getId();
|
info += npc.getId();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class SceneUploader
|
|||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
int sceneId = (int) (System.currentTimeMillis() / 1000L);
|
int sceneId = (int) System.nanoTime();
|
||||||
private int offset;
|
private int offset;
|
||||||
private int uvoffset;
|
private int uvoffset;
|
||||||
|
|
||||||
|
|||||||
@@ -185,9 +185,7 @@ public class HiscorePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (event.getMenuAction() == MenuAction.RUNELITE_PLAYER && event.getMenuOption().equals(LOOKUP))
|
if (event.getMenuAction() == MenuAction.RUNELITE_PLAYER && event.getMenuOption().equals(LOOKUP))
|
||||||
{
|
{
|
||||||
// The player id is included in the event, so we can use that to get the player name,
|
Player player = event.getMenuEntry().getPlayer();
|
||||||
// which avoids having to parse out the combat level and any icons preceding the name.
|
|
||||||
Player player = client.getCachedPlayers()[event.getId()];
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -114,8 +114,7 @@ class InteractHighlightOverlay extends Overlay
|
|||||||
case NPC_FIFTH_OPTION:
|
case NPC_FIFTH_OPTION:
|
||||||
case EXAMINE_NPC:
|
case EXAMINE_NPC:
|
||||||
{
|
{
|
||||||
int id = entry.getIdentifier();
|
NPC npc = entry.getNpc();
|
||||||
NPC npc = plugin.findNpc(id);
|
|
||||||
if (npc != null && config.npcShowHover() && (npc != plugin.getInteractedTarget() || !config.npcShowInteract()))
|
if (npc != null && config.npcShowHover() && (npc != plugin.getInteractedTarget() || !config.npcShowInteract()))
|
||||||
{
|
{
|
||||||
Color highlightColor = menuAction == MenuAction.NPC_SECOND_OPTION
|
Color highlightColor = menuAction == MenuAction.NPC_SECOND_OPTION
|
||||||
|
|||||||
@@ -167,9 +167,8 @@ public class InteractHighlightPlugin extends Plugin
|
|||||||
case NPC_FOURTH_OPTION:
|
case NPC_FOURTH_OPTION:
|
||||||
case NPC_FIFTH_OPTION:
|
case NPC_FIFTH_OPTION:
|
||||||
{
|
{
|
||||||
int id = menuOptionClicked.getId();
|
|
||||||
interactedObject = null;
|
interactedObject = null;
|
||||||
interactedNpc = findNpc(id);
|
interactedNpc = menuOptionClicked.getMenuEntry().getNpc();
|
||||||
attacked = menuOptionClicked.getMenuAction() == MenuAction.NPC_SECOND_OPTION ||
|
attacked = menuOptionClicked.getMenuAction() == MenuAction.NPC_SECOND_OPTION ||
|
||||||
menuOptionClicked.getMenuAction() == MenuAction.WIDGET_TARGET_ON_NPC && WidgetInfo.TO_GROUP(client.getSelectedWidget().getId()) == WidgetID.SPELLBOOK_GROUP_ID;
|
menuOptionClicked.getMenuAction() == MenuAction.WIDGET_TARGET_ON_NPC && WidgetInfo.TO_GROUP(client.getSelectedWidget().getId()) == WidgetID.SPELLBOOK_GROUP_ID;
|
||||||
clickTick = client.getTickCount();
|
clickTick = client.getTickCount();
|
||||||
@@ -242,11 +241,6 @@ public class InteractHighlightPlugin extends Plugin
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NPC findNpc(int id)
|
|
||||||
{
|
|
||||||
return client.getCachedNPCs()[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
Actor getInteractedTarget()
|
Actor getInteractedTarget()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -723,11 +723,11 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
final MenuEntry entry = entries[idx];
|
final MenuEntry entry = entries[idx];
|
||||||
final MenuAction type = entry.getType();
|
final MenuAction type = entry.getType();
|
||||||
final int id = entry.getIdentifier();
|
|
||||||
|
|
||||||
if (type == MenuAction.EXAMINE_NPC)
|
if (type == MenuAction.EXAMINE_NPC)
|
||||||
{
|
{
|
||||||
final NPC npc = client.getCachedNPCs()[id];
|
final NPC npc = entry.getNpc();
|
||||||
|
assert npc != null;
|
||||||
final NPCComposition composition = npc.getTransformedComposition();
|
final NPCComposition composition = npc.getTransformedComposition();
|
||||||
final String[] actions = composition.getActions();
|
final String[] actions = composition.getActions();
|
||||||
|
|
||||||
@@ -977,7 +977,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
|
|
||||||
if (NPC_MENU_TYPES.contains(menuAction))
|
if (NPC_MENU_TYPES.contains(menuAction))
|
||||||
{
|
{
|
||||||
final NPC npc = client.getCachedNPCs()[eventId];
|
final NPC npc = menuEntry.getNpc();
|
||||||
|
assert npc != null;
|
||||||
final NPCComposition composition = npc.getTransformedComposition();
|
final NPCComposition composition = npc.getTransformedComposition();
|
||||||
|
|
||||||
Integer customOption = getNpcSwapConfig(composition.getId());
|
Integer customOption = getNpcSwapConfig(composition.getId());
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
package net.runelite.client.plugins.npchighlight;
|
package net.runelite.client.plugins.npchighlight;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -48,7 +47,6 @@ import net.runelite.api.GraphicID;
|
|||||||
import net.runelite.api.GraphicsObject;
|
import net.runelite.api.GraphicsObject;
|
||||||
import net.runelite.api.KeyCode;
|
import net.runelite.api.KeyCode;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET;
|
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
@@ -89,10 +87,6 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
private static final String TAG_ALL = "Tag-All";
|
private static final String TAG_ALL = "Tag-All";
|
||||||
private static final String UNTAG_ALL = "Un-tag-All";
|
private static final String UNTAG_ALL = "Un-tag-All";
|
||||||
|
|
||||||
private static final Set<MenuAction> NPC_MENU_ACTIONS = ImmutableSet.of(MenuAction.NPC_FIRST_OPTION, MenuAction.NPC_SECOND_OPTION,
|
|
||||||
MenuAction.NPC_THIRD_OPTION, MenuAction.NPC_FOURTH_OPTION, MenuAction.NPC_FIFTH_OPTION, MenuAction.WIDGET_TARGET_ON_NPC,
|
|
||||||
MenuAction.ITEM_USE_ON_NPC);
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@@ -239,46 +233,19 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuEntryAdded(MenuEntryAdded event)
|
public void onMenuEntryAdded(MenuEntryAdded event)
|
||||||
{
|
{
|
||||||
int type = event.getType();
|
final MenuEntry menuEntry = event.getMenuEntry();
|
||||||
|
final MenuAction menuAction = menuEntry.getType();
|
||||||
|
final NPC npc = menuEntry.getNpc();
|
||||||
|
|
||||||
if (type >= MENU_ACTION_DEPRIORITIZE_OFFSET)
|
if (npc == null)
|
||||||
{
|
{
|
||||||
type -= MENU_ACTION_DEPRIORITIZE_OFFSET;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MenuAction menuAction = MenuAction.of(type);
|
if (menuAction == MenuAction.EXAMINE_NPC && client.isKeyPressed(KeyCode.KC_SHIFT))
|
||||||
|
|
||||||
if (NPC_MENU_ACTIONS.contains(menuAction))
|
|
||||||
{
|
|
||||||
NPC npc = client.getCachedNPCs()[event.getIdentifier()];
|
|
||||||
|
|
||||||
Color color = null;
|
|
||||||
if (npc.isDead())
|
|
||||||
{
|
|
||||||
color = config.deadNpcMenuColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color == null && highlightedNpcs.containsKey(npc) && config.highlightMenuNames() && (!npc.isDead() || !config.ignoreDeadNpcs()))
|
|
||||||
{
|
|
||||||
color = config.highlightColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color != null)
|
|
||||||
{
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
|
||||||
final MenuEntry menuEntry = menuEntries[menuEntries.length - 1];
|
|
||||||
final String target = ColorUtil.prependColorTag(Text.removeTags(event.getTarget()), color);
|
|
||||||
menuEntry.setTarget(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (menuAction == MenuAction.EXAMINE_NPC && client.isKeyPressed(KeyCode.KC_SHIFT))
|
|
||||||
{
|
{
|
||||||
// Add tag and tag-all options
|
// Add tag and tag-all options
|
||||||
final int id = event.getIdentifier();
|
if (npc.getName() == null)
|
||||||
final NPC[] cachedNPCs = client.getCachedNPCs();
|
|
||||||
final NPC npc = cachedNPCs[id];
|
|
||||||
|
|
||||||
if (npc == null || npc.getName() == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -306,6 +273,25 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
.setType(MenuAction.RUNELITE)
|
.setType(MenuAction.RUNELITE)
|
||||||
.onClick(this::tag);
|
.onClick(this::tag);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Color color = null;
|
||||||
|
if (npc.isDead())
|
||||||
|
{
|
||||||
|
color = config.deadNpcMenuColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color == null && highlightedNpcs.containsKey(npc) && config.highlightMenuNames() && (!npc.isDead() || !config.ignoreDeadNpcs()))
|
||||||
|
{
|
||||||
|
color = config.highlightColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color != null)
|
||||||
|
{
|
||||||
|
final String target = ColorUtil.prependColorTag(Text.removeTags(event.getTarget()), color);
|
||||||
|
menuEntry.setTarget(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tag(MenuEntry entry)
|
private void tag(MenuEntry entry)
|
||||||
|
|||||||
@@ -159,8 +159,7 @@ public class OpponentInfoPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int npcIndex = menuEntryAdded.getIdentifier();
|
NPC npc = menuEntryAdded.getMenuEntry().getNpc();
|
||||||
NPC npc = client.getCachedNPCs()[npcIndex];
|
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class PrayerBarOverlay extends Overlay
|
|||||||
graphics.fillRect(barX + xOffset, barY + HD_PRAYER_BAR_PADDING, 1, barHeight - HD_PRAYER_BAR_PADDING * 2);
|
graphics.fillRect(barX + xOffset, barY + HD_PRAYER_BAR_PADDING, 1, barHeight - HD_PRAYER_BAR_PADDING * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Dimension(barWidth, barHeight);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw bar
|
// Draw bar
|
||||||
@@ -145,7 +145,7 @@ class PrayerBarOverlay extends Overlay
|
|||||||
graphics.fillRect(barX + xOffset, barY, 1, barHeight);
|
graphics.fillRect(barX + xOffset, barY, 1, barHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Dimension(barWidth, barHeight);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onTick()
|
void onTick()
|
||||||
|
|||||||
@@ -151,8 +151,7 @@ class PrayerDoseOverlay extends Overlay
|
|||||||
graphics.setColor(ColorUtil.colorLerp(START_COLOR, END_COLOR, Math.sin(t)));
|
graphics.setColor(ColorUtil.colorLerp(START_COLOR, END_COLOR, Math.sin(t)));
|
||||||
graphics.setStroke(new BasicStroke(2));
|
graphics.setStroke(new BasicStroke(2));
|
||||||
graphics.drawOval(orbInnerX, orbInnerY, orbInnerSize, orbInnerSize);
|
graphics.drawOval(orbInnerX, orbInnerY, orbInnerSize, orbInnerSize);
|
||||||
|
return null;
|
||||||
return new Dimension((int) bounds.getWidth(), (int) bounds.getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ class PrayerFlickOverlay extends Overlay
|
|||||||
|
|
||||||
graphics.setColor(Color.cyan);
|
graphics.setColor(Color.cyan);
|
||||||
graphics.fillRect(orbInnerX + xOffset, orbInnerY + yOffset, 1, indicatorHeight);
|
graphics.fillRect(orbInnerX + xOffset, orbInnerY + yOffset, 1, indicatorHeight);
|
||||||
|
return null;
|
||||||
return new Dimension((int) bounds.getWidth(), (int) bounds.getHeight());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public class RandomEventPlugin extends Plugin
|
|||||||
&& event.getType() <= MenuAction.NPC_FIFTH_OPTION.getId()
|
&& event.getType() <= MenuAction.NPC_FIFTH_OPTION.getId()
|
||||||
&& EVENT_OPTIONS.contains(event.getOption()))
|
&& EVENT_OPTIONS.contains(event.getOption()))
|
||||||
{
|
{
|
||||||
NPC npc = client.getCachedNPCs()[event.getIdentifier()];
|
NPC npc = event.getMenuEntry().getNpc();
|
||||||
if (npc != null && EVENT_NPCS.contains(npc.getId()) && npc != currentRandomEvent && config.removeMenuOptions())
|
if (npc != null && EVENT_NPCS.contains(npc.getId()) && npc != currentRandomEvent && config.removeMenuOptions())
|
||||||
{
|
{
|
||||||
client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), client.getMenuEntries().length - 1));
|
client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), client.getMenuEntries().length - 1));
|
||||||
|
|||||||
@@ -279,7 +279,8 @@ public class WikiPlugin extends Plugin
|
|||||||
case WIDGET_TARGET_ON_NPC:
|
case WIDGET_TARGET_ON_NPC:
|
||||||
{
|
{
|
||||||
type = "npc";
|
type = "npc";
|
||||||
NPC npc = client.getCachedNPCs()[ev.getId()];
|
NPC npc = ev.getMenuEntry().getNpc();
|
||||||
|
assert npc != null;
|
||||||
NPCComposition nc = npc.getTransformedComposition();
|
NPCComposition nc = npc.getTransformedComposition();
|
||||||
id = nc.getId();
|
id = nc.getId();
|
||||||
name = nc.getName();
|
name = nc.getName();
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ public class OverlayRenderer extends MouseAdapter
|
|||||||
|
|
||||||
if (!bounds.isEmpty())
|
if (!bounds.isEmpty())
|
||||||
{
|
{
|
||||||
if (inOverlayManagingMode)
|
if (inOverlayManagingMode && overlay.isMovable())
|
||||||
{
|
{
|
||||||
Color boundsColor;
|
Color boundsColor;
|
||||||
if (inOverlayResizingMode && currentManagedOverlay == overlay)
|
if (inOverlayResizingMode && currentManagedOverlay == overlay)
|
||||||
@@ -407,7 +407,7 @@ public class OverlayRenderer extends MouseAdapter
|
|||||||
|
|
||||||
// See if we've clicked on an overlay
|
// See if we've clicked on an overlay
|
||||||
currentManagedOverlay = lastHoveredOverlay;
|
currentManagedOverlay = lastHoveredOverlay;
|
||||||
if (currentManagedOverlay == null)
|
if (currentManagedOverlay == null || !currentManagedOverlay.isMovable())
|
||||||
{
|
{
|
||||||
return mouseEvent;
|
return mouseEvent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,8 +136,7 @@ public class WidgetOverlay extends Overlay
|
|||||||
if (getPreferredLocation() != null || getPreferredPosition() != null)
|
if (getPreferredLocation() != null || getPreferredPosition() != null)
|
||||||
{
|
{
|
||||||
// The widget relative pos is relative to the parent
|
// The widget relative pos is relative to the parent
|
||||||
widget.setRelativeX(bounds.x - parent.x);
|
widget.setForcedPosition(bounds.x - parent.x, bounds.y - parent.y);
|
||||||
widget.setRelativeY(bounds.y - parent.y);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -145,6 +144,7 @@ public class WidgetOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
revalidate = false;
|
revalidate = false;
|
||||||
log.debug("Revalidating {}", widgetInfo);
|
log.debug("Revalidating {}", widgetInfo);
|
||||||
|
widget.setForcedPosition(-1, -1);
|
||||||
// Revalidate the widget to reposition it back to its normal location after an overlay reset
|
// Revalidate the widget to reposition it back to its normal location after an overlay reset
|
||||||
widget.revalidate();
|
widget.revalidate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import java.util.List;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import static net.runelite.api.MenuAction.CC_OP;
|
|
||||||
import static net.runelite.api.MenuAction.RUNELITE;
|
import static net.runelite.api.MenuAction.RUNELITE;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
@@ -99,13 +98,7 @@ public class MenuManagerTest
|
|||||||
menuManager.addManagedCustomMenu(new WidgetMenuOption(second.getOption(), second.getTarget(), MINIMAP_WORLDMAP_OPTIONS), null);
|
menuManager.addManagedCustomMenu(new WidgetMenuOption(second.getOption(), second.getTarget(), MINIMAP_WORLDMAP_OPTIONS), null);
|
||||||
menuManager.addManagedCustomMenu(new WidgetMenuOption(third.getOption(), third.getTarget(), MINIMAP_WORLDMAP_OPTIONS), null);
|
menuManager.addManagedCustomMenu(new WidgetMenuOption(third.getOption(), third.getTarget(), MINIMAP_WORLDMAP_OPTIONS), null);
|
||||||
|
|
||||||
menuManager.onMenuEntryAdded(new MenuEntryAdded(
|
menuManager.onMenuEntryAdded(new MenuEntryAdded(createMenuEntry("Cancel", "", MenuAction.CC_OP, MINIMAP_WORLDMAP_OPTIONS.getPackedId())));
|
||||||
CANCEL.getOption(),
|
|
||||||
CANCEL.getTarget(),
|
|
||||||
CC_OP.getId(),
|
|
||||||
CANCEL.getIdentifier(),
|
|
||||||
CANCEL.getParam0(),
|
|
||||||
CANCEL.getParam1()));
|
|
||||||
|
|
||||||
verify(client, times(3)).createMenuEntry(anyInt());
|
verify(client, times(3)).createMenuEntry(anyInt());
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,11 @@ import java.util.function.Consumer;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
|
import net.runelite.api.NPC;
|
||||||
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@@ -48,6 +51,8 @@ public class TestMenuEntry implements MenuEntry
|
|||||||
private int itemId = -1;
|
private int itemId = -1;
|
||||||
@Setter
|
@Setter
|
||||||
private Widget widget;
|
private Widget widget;
|
||||||
|
@Setter
|
||||||
|
private Actor actor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOption()
|
public String getOption()
|
||||||
@@ -239,4 +244,25 @@ public class TestMenuEntry implements MenuEntry
|
|||||||
{
|
{
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public NPC getNpc()
|
||||||
|
{
|
||||||
|
return actor instanceof NPC ? (NPC) actor : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Player getPlayer()
|
||||||
|
{
|
||||||
|
return actor instanceof Player ? (Player) actor : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Actor getActor()
|
||||||
|
{
|
||||||
|
return actor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class MenuEntrySwapperPluginTest
|
|||||||
@Inject
|
@Inject
|
||||||
MenuEntrySwapperPlugin menuEntrySwapperPlugin;
|
MenuEntrySwapperPlugin menuEntrySwapperPlugin;
|
||||||
|
|
||||||
|
private NPC npc;
|
||||||
private MenuEntry[] entries;
|
private MenuEntry[] entries;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -96,10 +97,9 @@ public class MenuEntrySwapperPluginTest
|
|||||||
when(client.getGameState()).thenReturn(GameState.LOGGED_IN);
|
when(client.getGameState()).thenReturn(GameState.LOGGED_IN);
|
||||||
when(client.getObjectDefinition(anyInt())).thenReturn(mock(ObjectComposition.class));
|
when(client.getObjectDefinition(anyInt())).thenReturn(mock(ObjectComposition.class));
|
||||||
|
|
||||||
NPC npc = mock(NPC.class);
|
npc = mock(NPC.class);
|
||||||
NPCComposition composition = mock(NPCComposition.class);
|
NPCComposition composition = mock(NPCComposition.class);
|
||||||
when(npc.getTransformedComposition()).thenReturn(composition);
|
when(npc.getTransformedComposition()).thenReturn(composition);
|
||||||
when(client.getCachedNPCs()).thenReturn(new NPC[] { npc });
|
|
||||||
|
|
||||||
when(client.getMenuEntries()).thenAnswer((Answer<MenuEntry[]>) invocationOnMock ->
|
when(client.getMenuEntries()).thenAnswer((Answer<MenuEntry[]>) invocationOnMock ->
|
||||||
{
|
{
|
||||||
@@ -117,18 +117,19 @@ public class MenuEntrySwapperPluginTest
|
|||||||
menuEntrySwapperPlugin.setupSwaps();
|
menuEntrySwapperPlugin.setupSwaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MenuEntry menu(String option, String target, MenuAction menuAction)
|
private MenuEntry menu(String option, String target, MenuAction menuAction)
|
||||||
{
|
{
|
||||||
return menu(option, target, menuAction, 0);
|
return menu(option, target, menuAction, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MenuEntry menu(String option, String target, MenuAction menuAction, int identifier)
|
private MenuEntry menu(String option, String target, MenuAction menuAction, int identifier)
|
||||||
{
|
{
|
||||||
MenuEntry menuEntry = new TestMenuEntry();
|
TestMenuEntry menuEntry = new TestMenuEntry();
|
||||||
menuEntry.setOption(option);
|
menuEntry.setOption(option);
|
||||||
menuEntry.setTarget(target);
|
menuEntry.setTarget(target);
|
||||||
menuEntry.setType(menuAction);
|
menuEntry.setType(menuAction);
|
||||||
menuEntry.setIdentifier(identifier);
|
menuEntry.setIdentifier(identifier);
|
||||||
|
menuEntry.setActor(npc);
|
||||||
return menuEntry;
|
return menuEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.NpcChanged;
|
import net.runelite.api.events.NpcChanged;
|
||||||
@@ -109,11 +108,12 @@ public class NpcIndicatorsPluginTest
|
|||||||
when(npc.isDead()).thenReturn(true);
|
when(npc.isDead()).thenReturn(true);
|
||||||
npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));
|
npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));
|
||||||
|
|
||||||
when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0
|
TestMenuEntry entry = new TestMenuEntry();
|
||||||
|
entry.setTarget("Goblin");
|
||||||
|
entry.setIdentifier(MenuAction.NPC_FIRST_OPTION.getId());
|
||||||
|
entry.setActor(npc);
|
||||||
|
|
||||||
MenuEntry entry = new TestMenuEntry();
|
MenuEntryAdded menuEntryAdded = new MenuEntryAdded(entry);
|
||||||
when(client.getMenuEntries()).thenReturn(new MenuEntry[]{entry});
|
|
||||||
MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
|
|
||||||
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
||||||
|
|
||||||
assertEquals("<col=ff0000>Goblin", entry.getTarget()); // red
|
assertEquals("<col=ff0000>Goblin", entry.getTarget()); // red
|
||||||
@@ -133,11 +133,12 @@ public class NpcIndicatorsPluginTest
|
|||||||
when(npc.getName()).thenReturn("Goblin");
|
when(npc.getName()).thenReturn("Goblin");
|
||||||
npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));
|
npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));
|
||||||
|
|
||||||
when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0
|
TestMenuEntry entry = new TestMenuEntry();
|
||||||
|
entry.setTarget("Goblin");
|
||||||
|
entry.setIdentifier(MenuAction.NPC_FIRST_OPTION.getId());
|
||||||
|
entry.setActor(npc);
|
||||||
|
|
||||||
MenuEntry entry = new TestMenuEntry();
|
MenuEntryAdded menuEntryAdded = new MenuEntryAdded(entry);
|
||||||
when(client.getMenuEntries()).thenReturn(new MenuEntry[]{entry});
|
|
||||||
MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
|
|
||||||
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
||||||
|
|
||||||
assertEquals("<col=0000ff>Goblin", entry.getTarget()); // blue
|
assertEquals("<col=0000ff>Goblin", entry.getTarget()); // blue
|
||||||
|
|||||||
Reference in New Issue
Block a user