api: make MenuEntry an interface
This adds a new createMenuEntry api method to make MenuEntries instead. Menu entries now have an associated callback called when they are clicked on, avoiding most plugins from having to hook separately to detect the menu click. Additionally get/set type has changed to take a MenuAction.
This commit is contained in:
@@ -593,6 +593,13 @@ public interface Client extends GameEngine
|
|||||||
*/
|
*/
|
||||||
World[] getWorldList();
|
World[] getWorldList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new menu entry
|
||||||
|
* @param idx the index to create the menu entry at. Accepts negative indexes eg. -1 inserts at the end.
|
||||||
|
* @return the newly created menu entry
|
||||||
|
*/
|
||||||
|
MenuEntry createMenuEntry(int idx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an array of currently open right-click menu entries that can be
|
* Gets an array of currently open right-click menu entries that can be
|
||||||
* clicked and activated.
|
* clicked and activated.
|
||||||
|
|||||||
@@ -24,46 +24,72 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api;
|
package net.runelite.api;
|
||||||
|
|
||||||
import lombok.Data;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A menu entry in a right-click menu.
|
* A menu entry in a right-click menu.
|
||||||
*/
|
*/
|
||||||
@Data
|
public interface MenuEntry
|
||||||
public class MenuEntry
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The option text added to the menu. (ie. "Walk here", "Use")
|
* The option text added to the menu. (ie. "Walk here", "Use")
|
||||||
*/
|
*/
|
||||||
private String option;
|
String getOption();
|
||||||
|
MenuEntry setOption(String option);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target of the action. (ie. Item or Actor name)
|
* The target of the action. (ie. Item or Actor name)
|
||||||
* <p>
|
* <p>
|
||||||
* If the option does not apply to any target, this field
|
* If the option does not apply to any target, this field
|
||||||
* will be set to empty string.
|
* will be set to empty string.
|
||||||
*/
|
*/
|
||||||
private String target;
|
String getTarget();
|
||||||
|
MenuEntry setTarget(String target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An identifier value for the target of the action.
|
* An identifier value for the target of the action.
|
||||||
*/
|
*/
|
||||||
private int identifier;
|
int getIdentifier();
|
||||||
|
MenuEntry setIdentifier(int identifier);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The action the entry will trigger.
|
* The action the entry will trigger.
|
||||||
*/
|
*/
|
||||||
private int type;
|
MenuAction getType();
|
||||||
|
MenuEntry setType(MenuAction type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An additional parameter for the action.
|
* An additional parameter for the action.
|
||||||
*/
|
*/
|
||||||
private int param0;
|
int getParam0();
|
||||||
|
MenuEntry setParam0(int param0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A second additional parameter for the action.
|
* A second additional parameter for the action.
|
||||||
*/
|
*/
|
||||||
private int param1;
|
int getParam1();
|
||||||
|
MenuEntry setParam1(int param1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this field is true and you have single mouse button on and this entry is
|
* If this is true and you have single mouse button on and this entry is
|
||||||
* the top entry the right click menu will not be opened when you left click
|
* the top entry the right click menu will not be opened when you left click
|
||||||
*
|
*
|
||||||
* This is used for shift click
|
* This is used for shift click
|
||||||
*/
|
*/
|
||||||
private boolean forceLeftClick;
|
boolean isForceLeftClick();
|
||||||
|
MenuEntry setForceLeftClick(boolean forceLeftClick);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprioritized menus are sorted in the menu to be below the other menu entries.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isDeprioritized();
|
||||||
|
void setDeprioritized(boolean deprioritized);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a callback to be called when this menu option is clicked
|
||||||
|
* @param callback
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MenuEntry onClick(Consumer<MenuEntry> callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* 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.api.events;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import lombok.Data;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A MenuManager widget menu was clicked. This event is fired only for MenuManager managed custom menus.
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class WidgetMenuOptionClicked
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The clicked menu option.
|
|
||||||
*/
|
|
||||||
private String menuOption;
|
|
||||||
/**
|
|
||||||
* The clicked menu target.
|
|
||||||
*/
|
|
||||||
private String menuTarget;
|
|
||||||
/**
|
|
||||||
* The WidgetInfo of the widget that was clicked, if available.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
private WidgetInfo widget;
|
|
||||||
/**
|
|
||||||
* The widget id of the widget that was clicked.
|
|
||||||
*/
|
|
||||||
private int widgetId;
|
|
||||||
}
|
|
||||||
@@ -326,7 +326,6 @@ public class RuneLite
|
|||||||
// Add core overlays
|
// Add core overlays
|
||||||
WidgetOverlay.createOverlays(overlayManager, client).forEach(overlayManager::add);
|
WidgetOverlay.createOverlays(overlayManager, client).forEach(overlayManager::add);
|
||||||
overlayManager.add(worldMapOverlay.get());
|
overlayManager.add(worldMapOverlay.get());
|
||||||
eventBus.register(worldMapOverlay.get());
|
|
||||||
overlayManager.add(tooltipOverlay.get());
|
overlayManager.add(tooltipOverlay.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ package net.runelite.client.menus;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.LinkedHashMultimap;
|
import com.google.common.collect.LinkedHashMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -38,9 +38,7 @@ import net.runelite.api.Client;
|
|||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.events.PlayerMenuOptionsChanged;
|
import net.runelite.api.events.PlayerMenuOptionsChanged;
|
||||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
|
||||||
@@ -55,7 +53,6 @@ public class MenuManager
|
|||||||
private static final int IDX_UPPER = 8;
|
private static final int IDX_UPPER = 8;
|
||||||
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final EventBus eventBus;
|
|
||||||
|
|
||||||
//Maps the indexes that are being used to the menu option.
|
//Maps the indexes that are being used to the menu option.
|
||||||
private final Map<Integer, String> playerMenuIndexMap = new HashMap<>();
|
private final Map<Integer, String> playerMenuIndexMap = new HashMap<>();
|
||||||
@@ -66,7 +63,6 @@ public class MenuManager
|
|||||||
private MenuManager(Client client, EventBus eventBus)
|
private MenuManager(Client client, EventBus eventBus)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.eventBus = eventBus;
|
|
||||||
eventBus.register(this);
|
eventBus.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +70,12 @@ public class MenuManager
|
|||||||
* Adds a CustomMenuOption to the list of managed menu options.
|
* Adds a CustomMenuOption to the list of managed menu options.
|
||||||
*
|
*
|
||||||
* @param customMenuOption The custom menu to add
|
* @param customMenuOption The custom menu to add
|
||||||
|
* @param callback callback to be called when the menu is clicked
|
||||||
*/
|
*/
|
||||||
public void addManagedCustomMenu(WidgetMenuOption customMenuOption)
|
public void addManagedCustomMenu(WidgetMenuOption customMenuOption, Consumer<MenuEntry> callback)
|
||||||
{
|
{
|
||||||
managedMenuOptions.put(customMenuOption.getWidgetId(), customMenuOption);
|
managedMenuOptions.put(customMenuOption.getWidgetId(), customMenuOption);
|
||||||
|
customMenuOption.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,11 +120,10 @@ public class MenuManager
|
|||||||
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
|
|
||||||
MenuEntry[] newMenuEntries = Arrays.copyOf(menuEntries, menuEntries.length + options.size());
|
|
||||||
// Menu entries are sorted with higher-index entries appearing toward the top of the minimenu, so insert older
|
// Menu entries are sorted with higher-index entries appearing toward the top of the minimenu, so insert older
|
||||||
// managed menu entries at higher indices and work backward for newer entries so newly-added entries appear at
|
// managed menu entries at higher indices and work backward for newer entries so newly-added entries appear at
|
||||||
// the bottom
|
// the bottom
|
||||||
int insertIdx = newMenuEntries.length - 1;
|
int insertIdx = -1;
|
||||||
for (WidgetMenuOption currentMenu : options)
|
for (WidgetMenuOption currentMenu : options)
|
||||||
{
|
{
|
||||||
// Exit if we've inserted the managed menu entries already
|
// Exit if we've inserted the managed menu entries already
|
||||||
@@ -135,16 +132,13 @@ public class MenuManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry menuEntry = new MenuEntry();
|
client.createMenuEntry(insertIdx--)
|
||||||
menuEntry.setOption(currentMenu.getMenuOption());
|
.setOption(currentMenu.getMenuOption())
|
||||||
menuEntry.setParam1(widgetId);
|
.setTarget(currentMenu.getMenuTarget())
|
||||||
menuEntry.setTarget(currentMenu.getMenuTarget());
|
.setType(MenuAction.RUNELITE)
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
.setParam1(widgetId)
|
||||||
|
.onClick(currentMenu.callback);
|
||||||
newMenuEntries[insertIdx--] = menuEntry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setMenuEntries(newMenuEntries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerMenuItem(String menuText)
|
public void addPlayerMenuItem(String menuText)
|
||||||
@@ -198,33 +192,6 @@ public class MenuManager
|
|||||||
addPlayerMenuItem(newIdx, menuText);
|
addPlayerMenuItem(newIdx, menuText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
|
||||||
if (event.getMenuAction() != MenuAction.RUNELITE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int widgetId = event.getParam1();
|
|
||||||
Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
|
|
||||||
|
|
||||||
for (WidgetMenuOption curMenuOption : options)
|
|
||||||
{
|
|
||||||
if (curMenuOption.getMenuTarget().equals(event.getMenuTarget())
|
|
||||||
&& curMenuOption.getMenuOption().equals(event.getMenuOption()))
|
|
||||||
{
|
|
||||||
WidgetMenuOptionClicked customMenu = new WidgetMenuOptionClicked();
|
|
||||||
customMenu.setMenuOption(event.getMenuOption());
|
|
||||||
customMenu.setMenuTarget(event.getMenuTarget());
|
|
||||||
customMenu.setWidget(curMenuOption.getWidget());
|
|
||||||
customMenu.setWidgetId(curMenuOption.getWidgetId());
|
|
||||||
eventBus.post(customMenu);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPlayerMenuItem(int playerOptionIndex, String menuText)
|
private void addPlayerMenuItem(int playerOptionIndex, String menuText)
|
||||||
{
|
{
|
||||||
client.getPlayerOptions()[playerOptionIndex] = menuText;
|
client.getPlayerOptions()[playerOptionIndex] = menuText;
|
||||||
|
|||||||
@@ -25,9 +25,11 @@
|
|||||||
package net.runelite.client.menus;
|
package net.runelite.client.menus;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.ui.JagexColors;
|
import net.runelite.client.ui.JagexColors;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
@@ -65,6 +67,8 @@ public final class WidgetMenuOption
|
|||||||
@Getter
|
@Getter
|
||||||
private final int widgetId;
|
private final int widgetId;
|
||||||
|
|
||||||
|
Consumer<MenuEntry> callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a menu to be added to right click menus. The menu will only be added if match is found within the menu options
|
* Creates a menu to be added to right click menus. The menu will only be added if match is found within the menu options
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -341,8 +341,6 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuEntryAdded(MenuEntryAdded event)
|
public void onMenuEntryAdded(MenuEntryAdded event)
|
||||||
{
|
{
|
||||||
MenuEntry[] entries = client.getMenuEntries();
|
|
||||||
|
|
||||||
if (event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
|
if (event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
|
||||||
&& event.getOption().equals("Examine"))
|
&& event.getOption().equals("Examine"))
|
||||||
{
|
{
|
||||||
@@ -357,30 +355,22 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
|
|||||||
text += " (" + tagCount + ")";
|
text += " (" + tagCount + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry editTags = new MenuEntry();
|
client.createMenuEntry(-1)
|
||||||
editTags.setParam0(event.getActionParam0());
|
.setParam0(event.getActionParam0())
|
||||||
editTags.setParam1(event.getActionParam1());
|
.setParam1(event.getActionParam1())
|
||||||
editTags.setTarget(event.getTarget());
|
.setTarget(event.getTarget())
|
||||||
editTags.setOption(text);
|
.setOption(text)
|
||||||
editTags.setType(MenuAction.RUNELITE.getId());
|
.setType(MenuAction.RUNELITE)
|
||||||
editTags.setIdentifier(event.getIdentifier());
|
.setIdentifier(event.getIdentifier())
|
||||||
entries = Arrays.copyOf(entries, entries.length + 1);
|
.onClick(this::editTags);
|
||||||
entries[entries.length - 1] = editTags;
|
|
||||||
client.setMenuEntries(entries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tabInterface.handleAdd(event);
|
tabInterface.handleAdd(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
private void editTags(MenuEntry entry)
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
{
|
||||||
if (event.getParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
|
int inventoryIndex = entry.getParam0();
|
||||||
&& event.getMenuAction() == MenuAction.RUNELITE
|
|
||||||
&& event.getMenuOption().startsWith(EDIT_TAGS_MENU_OPTION))
|
|
||||||
{
|
|
||||||
event.consume();
|
|
||||||
int inventoryIndex = event.getParam0();
|
|
||||||
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
|
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
|
||||||
if (bankContainer == null)
|
if (bankContainer == null)
|
||||||
{
|
{
|
||||||
@@ -434,11 +424,12 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
|
|||||||
}))
|
}))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
@Subscribe
|
||||||
|
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||||
{
|
{
|
||||||
tabInterface.handleClick(event);
|
tabInterface.handleClick(event);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onConfigChanged(ConfigChanged configChanged)
|
public void onConfigChanged(ConfigChanged configChanged)
|
||||||
|
|||||||
@@ -618,38 +618,32 @@ public class TabInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] entries = client.getMenuEntries();
|
|
||||||
|
|
||||||
if (activeTab != null
|
if (activeTab != null
|
||||||
&& event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
|
&& event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
|
||||||
&& event.getOption().equals("Examine"))
|
&& event.getOption().equals("Examine"))
|
||||||
{
|
{
|
||||||
entries = createMenuEntry(event, REMOVE_TAG + " (" + activeTab.getTag() + ")", event.getTarget(), entries);
|
createMenuEntry(event, REMOVE_TAG + " (" + activeTab.getTag() + ")", event.getTarget());
|
||||||
client.setMenuEntries(entries);
|
|
||||||
}
|
}
|
||||||
else if (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId()
|
else if (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId()
|
||||||
&& event.getOption().equals("Deposit inventory"))
|
&& event.getOption().equals("Deposit inventory"))
|
||||||
{
|
{
|
||||||
entries = createMenuEntry(event, TAG_INVENTORY, event.getTarget(), entries);
|
createMenuEntry(event, TAG_INVENTORY, event.getTarget());
|
||||||
|
|
||||||
if (activeTab != null)
|
if (activeTab != null)
|
||||||
{
|
{
|
||||||
entries = createMenuEntry(event, TAG_INVENTORY, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR), entries);
|
createMenuEntry(event, TAG_INVENTORY, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setMenuEntries(entries);
|
|
||||||
}
|
}
|
||||||
else if (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId()
|
else if (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId()
|
||||||
&& event.getOption().equals("Deposit worn items"))
|
&& event.getOption().equals("Deposit worn items"))
|
||||||
{
|
{
|
||||||
entries = createMenuEntry(event, TAG_GEAR, event.getTarget(), entries);
|
createMenuEntry(event, TAG_GEAR, event.getTarget());
|
||||||
|
|
||||||
if (activeTab != null)
|
if (activeTab != null)
|
||||||
{
|
{
|
||||||
entries = createMenuEntry(event, TAG_GEAR, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR), entries);
|
createMenuEntry(event, TAG_GEAR, ColorUtil.wrapWithColorTag(activeTab.getTag(), HILIGHT_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setMenuEntries(entries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,7 +767,6 @@ public class TabInterface
|
|||||||
{
|
{
|
||||||
entry.setOption(TAG_SEARCH + Text.removeTags(entry.getTarget()) + (shiftDown ? VAR_TAG_SUFFIX : ""));
|
entry.setOption(TAG_SEARCH + Text.removeTags(entry.getTarget()) + (shiftDown ? VAR_TAG_SUFFIX : ""));
|
||||||
entry.setTarget(draggedWidget.getName());
|
entry.setTarget(draggedWidget.getName());
|
||||||
client.setMenuEntries(entries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getOption().equals(SCROLL_UP))
|
if (entry.getOption().equals(SCROLL_UP))
|
||||||
@@ -1195,17 +1188,14 @@ public class TabInterface
|
|||||||
searchButtonBackground.setSpriteId(SpriteID.EQUIPMENT_SLOT_TILE);
|
searchButtonBackground.setSpriteId(SpriteID.EQUIPMENT_SLOT_TILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MenuEntry[] createMenuEntry(MenuEntryAdded event, String option, String target, MenuEntry[] entries)
|
private void createMenuEntry(MenuEntryAdded event, String option, String target)
|
||||||
{
|
{
|
||||||
final MenuEntry entry = new MenuEntry();
|
client.createMenuEntry(-1)
|
||||||
entry.setParam0(event.getActionParam0());
|
.setParam0(event.getActionParam0())
|
||||||
entry.setParam1(event.getActionParam1());
|
.setParam1(event.getActionParam1())
|
||||||
entry.setTarget(target);
|
.setTarget(target)
|
||||||
entry.setOption(option);
|
.setOption(option)
|
||||||
entry.setType(MenuAction.RUNELITE.getId());
|
.setType(MenuAction.RUNELITE)
|
||||||
entry.setIdentifier(event.getIdentifier());
|
.setIdentifier(event.getIdentifier());
|
||||||
entries = Arrays.copyOf(entries, entries.length + 1);
|
|
||||||
entries[entries.length - 1] = entry;
|
|
||||||
return entries;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
|
|||||||
{
|
{
|
||||||
for (MenuEntry menuEntry : menuEntries)
|
for (MenuEntry menuEntry : menuEntries)
|
||||||
{
|
{
|
||||||
MenuAction action = MenuAction.of(menuEntry.getType());
|
MenuAction action = menuEntry.getType();
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case CANCEL:
|
case CANCEL:
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.chathistory;
|
package net.runelite.client.plugins.chathistory;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.collect.EvictingQueue;
|
import com.google.common.collect.EvictingQueue;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
@@ -83,8 +82,6 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
|
|||||||
private Queue<MessageNode> messageQueue;
|
private Queue<MessageNode> messageQueue;
|
||||||
private Deque<String> friends;
|
private Deque<String> friends;
|
||||||
|
|
||||||
private String currentMessage = null;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@@ -121,7 +118,6 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
|
|||||||
messageQueue = null;
|
messageQueue = null;
|
||||||
friends.clear();
|
friends.clear();
|
||||||
friends = null;
|
friends = null;
|
||||||
currentMessage = null;
|
|
||||||
keyManager.unregisterKeyListener(this);
|
keyManager.unregisterKeyListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +191,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
|
|||||||
// Use second entry as first one can be walk here with transparent chatbox
|
// Use second entry as first one can be walk here with transparent chatbox
|
||||||
final MenuEntry entry = event.getMenuEntries()[event.getMenuEntries().length - 2];
|
final MenuEntry entry = event.getMenuEntries()[event.getMenuEntries().length - 2];
|
||||||
|
|
||||||
if (entry.getType() != MenuAction.CC_OP_LOW_PRIORITY.getId() && entry.getType() != MenuAction.RUNELITE.getId())
|
if (entry.getType() != MenuAction.CC_OP_LOW_PRIORITY && entry.getType() != MenuAction.RUNELITE)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -236,16 +232,17 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentMessage = messageContents.getText();
|
String currentMessage = messageContents.getText();
|
||||||
|
|
||||||
final MenuEntry menuEntry = new MenuEntry();
|
client.createMenuEntry(1)
|
||||||
menuEntry.setOption(COPY_TO_CLIPBOARD);
|
.setOption(COPY_TO_CLIPBOARD)
|
||||||
menuEntry.setTarget(entry.getTarget());
|
.setTarget(entry.getTarget())
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
.setType(MenuAction.RUNELITE)
|
||||||
menuEntry.setParam0(entry.getParam0());
|
.onClick(e ->
|
||||||
menuEntry.setParam1(entry.getParam1());
|
{
|
||||||
menuEntry.setIdentifier(entry.getIdentifier());
|
final StringSelection stringSelection = new StringSelection(Text.removeTags(currentMessage));
|
||||||
client.setMenuEntries(ArrayUtils.insert(1, client.getMenuEntries(), menuEntry));
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -258,11 +255,6 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
|
|||||||
{
|
{
|
||||||
clearChatboxHistory(ChatboxTab.of(event.getParam1()));
|
clearChatboxHistory(ChatboxTab.of(event.getParam1()));
|
||||||
}
|
}
|
||||||
else if (COPY_TO_CLIPBOARD.equals(menuOption) && !Strings.isNullOrEmpty(currentMessage))
|
|
||||||
{
|
|
||||||
final StringSelection stringSelection = new StringSelection(Text.removeTags(currentMessage));
|
|
||||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -279,10 +271,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MenuEntry clearEntry = new MenuEntry();
|
final MenuEntry clearEntry = client.createMenuEntry(-2)
|
||||||
clearEntry.setTarget("");
|
.setType(MenuAction.RUNELITE_HIGH_PRIORITY);
|
||||||
clearEntry.setType(MenuAction.RUNELITE_HIGH_PRIORITY.getId());
|
|
||||||
clearEntry.setParam0(entry.getActionParam0());
|
|
||||||
clearEntry.setParam1(entry.getActionParam1());
|
clearEntry.setParam1(entry.getActionParam1());
|
||||||
|
|
||||||
final StringBuilder optionBuilder = new StringBuilder();
|
final StringBuilder optionBuilder = new StringBuilder();
|
||||||
@@ -299,9 +289,6 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
|
|||||||
|
|
||||||
optionBuilder.append(CLEAR_HISTORY);
|
optionBuilder.append(CLEAR_HISTORY);
|
||||||
clearEntry.setOption(optionBuilder.toString());
|
clearEntry.setOption(optionBuilder.toString());
|
||||||
|
|
||||||
final MenuEntry[] menuEntries = client.getMenuEntries();
|
|
||||||
client.setMenuEntries(ArrayUtils.insert(menuEntries.length - 1, menuEntries, clearEntry));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearMessageQueue(ChatboxTab tab)
|
private void clearMessageQueue(ChatboxTab tab)
|
||||||
|
|||||||
@@ -488,7 +488,6 @@ public class DevToolsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET));
|
entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET));
|
||||||
client.setMenuEntries(entries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ class WidgetInspector extends DevToolsFrame
|
|||||||
client.setSpellSelected(false);
|
client.setSpellSelected(false);
|
||||||
ev.consume();
|
ev.consume();
|
||||||
|
|
||||||
Object target = getWidgetOrWidgetItemForMenuOption(ev.getMenuAction().getId(), ev.getParam0(), ev.getParam1());
|
Object target = getWidgetOrWidgetItemForMenuOption(ev.getMenuAction(), ev.getParam0(), ev.getParam1());
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -516,8 +516,8 @@ class WidgetInspector extends DevToolsFrame
|
|||||||
for (int i = 0; i < menuEntries.length; i++)
|
for (int i = 0; i < menuEntries.length; i++)
|
||||||
{
|
{
|
||||||
MenuEntry entry = menuEntries[i];
|
MenuEntry entry = menuEntries[i];
|
||||||
if (entry.getType() != MenuAction.ITEM_USE_ON_WIDGET.getId()
|
if (entry.getType() != MenuAction.ITEM_USE_ON_WIDGET
|
||||||
&& entry.getType() != MenuAction.SPELL_CAST_ON_WIDGET.getId())
|
&& entry.getType() != MenuAction.SPELL_CAST_ON_WIDGET)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -532,8 +532,6 @@ class WidgetInspector extends DevToolsFrame
|
|||||||
|
|
||||||
entry.setTarget(ColorUtil.wrapWithColorTag(name, color));
|
entry.setTarget(ColorUtil.wrapWithColorTag(name, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color colorForWidget(int index, int length)
|
Color colorForWidget(int index, int length)
|
||||||
@@ -543,9 +541,9 @@ class WidgetInspector extends DevToolsFrame
|
|||||||
return Color.getHSBColor(h, 1, 1);
|
return Color.getHSBColor(h, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object getWidgetOrWidgetItemForMenuOption(int type, int param0, int param1)
|
Object getWidgetOrWidgetItemForMenuOption(MenuAction type, int param0, int param1)
|
||||||
{
|
{
|
||||||
if (type == MenuAction.SPELL_CAST_ON_WIDGET.getId())
|
if (type == MenuAction.SPELL_CAST_ON_WIDGET)
|
||||||
{
|
{
|
||||||
Widget w = client.getWidget(param1);
|
Widget w = client.getWidget(param1);
|
||||||
if (param0 != -1)
|
if (param0 != -1)
|
||||||
@@ -555,7 +553,7 @@ class WidgetInspector extends DevToolsFrame
|
|||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
else if (type == MenuAction.ITEM_USE_ON_WIDGET.getId())
|
else if (type == MenuAction.ITEM_USE_ON_WIDGET)
|
||||||
{
|
{
|
||||||
Widget w = client.getWidget(param1);
|
Widget w = client.getWidget(param1);
|
||||||
return w.getWidgetItem(param0);
|
return w.getWidgetItem(param0);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
package net.runelite.client.plugins.friendnotes;
|
package net.runelite.client.plugins.friendnotes;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ObjectArrays;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@@ -43,12 +42,10 @@ import net.runelite.api.GameState;
|
|||||||
import net.runelite.api.Ignore;
|
import net.runelite.api.Ignore;
|
||||||
import net.runelite.api.IndexedSprite;
|
import net.runelite.api.IndexedSprite;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
|
||||||
import net.runelite.api.Nameable;
|
import net.runelite.api.Nameable;
|
||||||
import net.runelite.api.ScriptID;
|
import net.runelite.api.ScriptID;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.events.NameableNameChanged;
|
import net.runelite.api.events.NameableNameChanged;
|
||||||
import net.runelite.api.events.RemovedFriend;
|
import net.runelite.api.events.RemovedFriend;
|
||||||
import net.runelite.api.events.ScriptCallbackEvent;
|
import net.runelite.api.events.ScriptCallbackEvent;
|
||||||
@@ -245,42 +242,14 @@ public class FriendNotesPlugin extends Plugin
|
|||||||
setHoveredFriend(Text.toJagexName(Text.removeTags(event.getTarget())));
|
setHoveredFriend(Text.toJagexName(Text.removeTags(event.getTarget())));
|
||||||
|
|
||||||
// Build "Add Note" or "Edit Note" menu entry
|
// Build "Add Note" or "Edit Note" menu entry
|
||||||
final MenuEntry addNote = new MenuEntry();
|
client.createMenuEntry(-1)
|
||||||
addNote.setOption(hoveredFriend == null || hoveredFriend.getNote() == null ? ADD_NOTE : EDIT_NOTE);
|
.setOption(hoveredFriend == null || hoveredFriend.getNote() == null ? ADD_NOTE : EDIT_NOTE)
|
||||||
addNote.setType(MenuAction.RUNELITE.getId());
|
.setType(MenuAction.RUNELITE)
|
||||||
addNote.setTarget(event.getTarget()); //Preserve color codes here
|
.setTarget(event.getTarget()) //Preserve color codes here
|
||||||
addNote.setParam0(event.getActionParam0());
|
.onClick(e ->
|
||||||
addNote.setParam1(event.getActionParam1());
|
|
||||||
|
|
||||||
// Add menu entry
|
|
||||||
final MenuEntry[] menuEntries = ObjectArrays.concat(client.getMenuEntries(), addNote);
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
|
||||||
else if (hoveredFriend != null)
|
|
||||||
{
|
{
|
||||||
hoveredFriend = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
|
||||||
final int groupId = WidgetInfo.TO_GROUP(event.getParam1());
|
|
||||||
|
|
||||||
if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.IGNORE_LIST.getGroupId())
|
|
||||||
{
|
|
||||||
if (Strings.isNullOrEmpty(event.getMenuTarget()))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle clicks on "Add Note" or "Edit Note"
|
|
||||||
if (event.getMenuOption().equals(ADD_NOTE) || event.getMenuOption().equals(EDIT_NOTE))
|
|
||||||
{
|
|
||||||
event.consume();
|
|
||||||
|
|
||||||
//Friends have color tags
|
//Friends have color tags
|
||||||
final String sanitizedTarget = Text.toJagexName(Text.removeTags(event.getMenuTarget()));
|
final String sanitizedTarget = Text.toJagexName(Text.removeTags(e.getTarget()));
|
||||||
final String note = getFriendNote(sanitizedTarget);
|
final String note = getFriendNote(sanitizedTarget);
|
||||||
|
|
||||||
// Open the new chatbox input dialog
|
// Open the new chatbox input dialog
|
||||||
@@ -297,9 +266,12 @@ public class FriendNotesPlugin extends Plugin
|
|||||||
log.debug("Set note for '{}': '{}'", sanitizedTarget, content);
|
log.debug("Set note for '{}': '{}'", sanitizedTarget, content);
|
||||||
setFriendNote(sanitizedTarget, content);
|
setFriendNote(sanitizedTarget, content);
|
||||||
}).build();
|
}).build();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
else if (hoveredFriend != null)
|
||||||
|
{
|
||||||
|
hoveredFriend = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
@@ -574,8 +574,7 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
case WidgetID.GRAND_EXCHANGE_INVENTORY_GROUP_ID:
|
case WidgetID.GRAND_EXCHANGE_INVENTORY_GROUP_ID:
|
||||||
case WidgetID.SHOP_INVENTORY_GROUP_ID:
|
case WidgetID.SHOP_INVENTORY_GROUP_ID:
|
||||||
menuEntry.setOption(SEARCH_GRAND_EXCHANGE);
|
menuEntry.setOption(SEARCH_GRAND_EXCHANGE);
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
menuEntry.setType(MenuAction.RUNELITE);
|
||||||
client.setMenuEntries(entries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,14 +115,6 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
static final int MAX_QUANTITY = 65535;
|
static final int MAX_QUANTITY = 65535;
|
||||||
// ItemID for coins
|
// ItemID for coins
|
||||||
private static final int COINS = ItemID.COINS_995;
|
private static final int COINS = ItemID.COINS_995;
|
||||||
// Ground item menu options
|
|
||||||
private static final int FIRST_OPTION = MenuAction.GROUND_ITEM_FIRST_OPTION.getId();
|
|
||||||
private static final int SECOND_OPTION = MenuAction.GROUND_ITEM_SECOND_OPTION.getId();
|
|
||||||
private static final int THIRD_OPTION = MenuAction.GROUND_ITEM_THIRD_OPTION.getId(); // this is Take
|
|
||||||
private static final int FOURTH_OPTION = MenuAction.GROUND_ITEM_FOURTH_OPTION.getId();
|
|
||||||
private static final int FIFTH_OPTION = MenuAction.GROUND_ITEM_FIFTH_OPTION.getId();
|
|
||||||
private static final int EXAMINE_ITEM = MenuAction.EXAMINE_ITEM_GROUND.getId();
|
|
||||||
private static final int CAST_ON_ITEM = MenuAction.SPELL_CAST_ON_GROUND_ITEM.getId();
|
|
||||||
|
|
||||||
private static final String TELEGRAB_TEXT = ColorUtil.wrapWithColorTag("Telekinetic Grab", Color.GREEN) + ColorUtil.prependColorTag(" -> ", Color.WHITE);
|
private static final String TELEGRAB_TEXT = ColorUtil.wrapWithColorTag("Telekinetic Grab", Color.GREEN) + ColorUtil.prependColorTag(" -> ", Color.WHITE);
|
||||||
|
|
||||||
@@ -344,9 +336,10 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
MenuEntry menuEntry = menuEntries[i];
|
MenuEntry menuEntry = menuEntries[i];
|
||||||
|
|
||||||
int menuType = menuEntry.getType();
|
MenuAction menuType = menuEntry.getType();
|
||||||
if (menuType == FIRST_OPTION || menuType == SECOND_OPTION || menuType == THIRD_OPTION
|
if (menuType == MenuAction.GROUND_ITEM_FIRST_OPTION || menuType == MenuAction.GROUND_ITEM_SECOND_OPTION
|
||||||
|| menuType == FOURTH_OPTION || menuType == FIFTH_OPTION || menuType == EXAMINE_ITEM)
|
|| menuType == MenuAction.GROUND_ITEM_THIRD_OPTION || menuType == MenuAction.GROUND_ITEM_FOURTH_OPTION
|
||||||
|
|| menuType == MenuAction.GROUND_ITEM_FIFTH_OPTION || menuType == MenuAction.SPELL_CAST_ON_GROUND_ITEM)
|
||||||
{
|
{
|
||||||
for (MenuEntryWithCount entryWCount : newEntries)
|
for (MenuEntryWithCount entryWCount : newEntries)
|
||||||
{
|
{
|
||||||
@@ -490,8 +483,8 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (config.itemHighlightMode() == ItemHighlightMode.MENU || config.itemHighlightMode() == ItemHighlightMode.BOTH)
|
if (config.itemHighlightMode() == ItemHighlightMode.MENU || config.itemHighlightMode() == ItemHighlightMode.BOTH)
|
||||||
{
|
{
|
||||||
final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == CAST_ON_ITEM;
|
final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == MenuAction.SPELL_CAST_ON_GROUND_ITEM.getId();
|
||||||
if (!(event.getOption().equals("Take") && event.getType() == THIRD_OPTION) && !telegrabEntry)
|
if (!(event.getOption().equals("Take") && event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId()) && !telegrabEntry)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -548,8 +541,6 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")");
|
lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -44,13 +43,11 @@ import net.runelite.api.Client;
|
|||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.KeyCode;
|
import net.runelite.api.KeyCode;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
|
||||||
import net.runelite.api.Tile;
|
import net.runelite.api.Tile;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
@@ -243,49 +240,35 @@ public class GroundMarkerPlugin extends Plugin
|
|||||||
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
||||||
final boolean exists = getPoints(regionId).contains(point);
|
final boolean exists = getPoints(regionId).contains(point);
|
||||||
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
client.createMenuEntry(-1)
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + (exists ? 2 : 1));
|
.setOption(exists ? UNMARK : MARK)
|
||||||
|
.setTarget(event.getTarget())
|
||||||
MenuEntry mark = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
.setType(MenuAction.RUNELITE)
|
||||||
mark.setOption(exists ? UNMARK : MARK);
|
.onClick(e ->
|
||||||
mark.setTarget(event.getTarget());
|
|
||||||
mark.setType(MenuAction.RUNELITE.getId());
|
|
||||||
|
|
||||||
if (exists)
|
|
||||||
{
|
{
|
||||||
MenuEntry label = menuEntries[menuEntries.length - 2] = new MenuEntry();
|
|
||||||
label.setOption(LABEL);
|
|
||||||
label.setTarget(event.getTarget());
|
|
||||||
label.setType(MenuAction.RUNELITE.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
|
||||||
if (event.getMenuAction().getId() != MenuAction.RUNELITE.getId())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile target = client.getSelectedSceneTile();
|
Tile target = client.getSelectedSceneTile();
|
||||||
if (target == null)
|
if (target != null)
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String option = event.getMenuOption();
|
|
||||||
if (option.equals(MARK) || option.equals(UNMARK))
|
|
||||||
{
|
{
|
||||||
markTile(target.getLocalLocation());
|
markTile(target.getLocalLocation());
|
||||||
}
|
}
|
||||||
else if (option.equals(LABEL))
|
});
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
client.createMenuEntry(-2)
|
||||||
|
.setOption(LABEL)
|
||||||
|
.setTarget(event.getTarget())
|
||||||
|
.setType(MenuAction.RUNELITE)
|
||||||
|
.onClick(e ->
|
||||||
|
{
|
||||||
|
Tile target = client.getSelectedSceneTile();
|
||||||
|
if (target != null)
|
||||||
{
|
{
|
||||||
labelTile(target);
|
labelTile(target);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
@@ -45,11 +45,10 @@ import javax.inject.Inject;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
import net.runelite.api.MenuEntry;
|
||||||
import static net.runelite.api.widgets.WidgetInfo.MINIMAP_WORLDMAP_OPTIONS;
|
import static net.runelite.api.widgets.WidgetInfo.MINIMAP_WORLDMAP_OPTIONS;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.chat.QueuedMessage;
|
import net.runelite.client.chat.QueuedMessage;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
||||||
import net.runelite.client.menus.MenuManager;
|
import net.runelite.client.menus.MenuManager;
|
||||||
import net.runelite.client.menus.WidgetMenuOption;
|
import net.runelite.client.menus.WidgetMenuOption;
|
||||||
@@ -82,13 +81,13 @@ class GroundMarkerSharingManager
|
|||||||
|
|
||||||
void addImportExportMenuOptions()
|
void addImportExportMenuOptions()
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(EXPORT_MARKERS_OPTION);
|
menuManager.addManagedCustomMenu(EXPORT_MARKERS_OPTION, this::exportGroundMarkers);
|
||||||
menuManager.addManagedCustomMenu(IMPORT_MARKERS_OPTION);
|
menuManager.addManagedCustomMenu(IMPORT_MARKERS_OPTION, this::promptForImport);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addClearMenuOption()
|
void addClearMenuOption()
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(CLEAR_MARKERS_OPTION);
|
menuManager.addManagedCustomMenu(CLEAR_MARKERS_OPTION, this::promptForClear);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeMenuOptions()
|
void removeMenuOptions()
|
||||||
@@ -98,36 +97,7 @@ class GroundMarkerSharingManager
|
|||||||
menuManager.removeManagedCustomMenu(CLEAR_MARKERS_OPTION);
|
menuManager.removeManagedCustomMenu(CLEAR_MARKERS_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean widgetMenuClickedEquals(final WidgetMenuOptionClicked event, final WidgetMenuOption target)
|
private void exportGroundMarkers(MenuEntry menuEntry)
|
||||||
{
|
|
||||||
return event.getMenuTarget().equals(target.getMenuTarget()) &&
|
|
||||||
event.getMenuOption().equals(target.getMenuOption());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event)
|
|
||||||
{
|
|
||||||
// ensure that the option clicked is the export markers option
|
|
||||||
if (event.getWidget() != MINIMAP_WORLDMAP_OPTIONS)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widgetMenuClickedEquals(event, EXPORT_MARKERS_OPTION))
|
|
||||||
{
|
|
||||||
exportGroundMarkers();
|
|
||||||
}
|
|
||||||
else if (widgetMenuClickedEquals(event, IMPORT_MARKERS_OPTION))
|
|
||||||
{
|
|
||||||
promptForImport();
|
|
||||||
}
|
|
||||||
else if (widgetMenuClickedEquals(event, CLEAR_MARKERS_OPTION))
|
|
||||||
{
|
|
||||||
promptForClear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void exportGroundMarkers()
|
|
||||||
{
|
{
|
||||||
int[] regions = client.getMapRegions();
|
int[] regions = client.getMapRegions();
|
||||||
if (regions == null)
|
if (regions == null)
|
||||||
@@ -156,7 +126,7 @@ class GroundMarkerSharingManager
|
|||||||
sendChatMessage(activePoints.size() + " ground markers were copied to your clipboard.");
|
sendChatMessage(activePoints.size() + " ground markers were copied to your clipboard.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void promptForImport()
|
private void promptForImport(MenuEntry menuEntry)
|
||||||
{
|
{
|
||||||
final String clipboardText;
|
final String clipboardText;
|
||||||
try
|
try
|
||||||
@@ -244,7 +214,7 @@ class GroundMarkerSharingManager
|
|||||||
sendChatMessage(importPoints.size() + " ground markers were imported from the clipboard.");
|
sendChatMessage(importPoints.size() + " ground markers were imported from the clipboard.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void promptForClear()
|
private void promptForClear(MenuEntry entry)
|
||||||
{
|
{
|
||||||
int[] regions = client.getMapRegions();
|
int[] regions = client.getMapRegions();
|
||||||
if (regions == null)
|
if (regions == null)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.hiscore;
|
package net.runelite.client.plugins.hiscore;
|
||||||
|
|
||||||
import com.google.common.collect.ObjectArrays;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@@ -39,7 +38,6 @@ import net.runelite.api.ChatMessageType;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.IconID;
|
import net.runelite.api.IconID;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.WorldType;
|
import net.runelite.api.WorldType;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
@@ -59,7 +57,6 @@ import net.runelite.client.ui.NavigationButton;
|
|||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "HiScore",
|
name = "HiScore",
|
||||||
@@ -169,27 +166,26 @@ public class HiscorePlugin extends Plugin
|
|||||||
|| groupId == WidgetID.GROUP_IRON_GROUP_ID && (option.equals("Add friend") || option.equals("Remove friend") || option.equals("Remove ignore"))
|
|| groupId == WidgetID.GROUP_IRON_GROUP_ID && (option.equals("Add friend") || option.equals("Remove friend") || option.equals("Remove ignore"))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
final MenuEntry lookup = new MenuEntry();
|
client.createMenuEntry(-2)
|
||||||
lookup.setOption(LOOKUP);
|
.setOption(LOOKUP)
|
||||||
lookup.setTarget(event.getTarget());
|
.setTarget(event.getTarget())
|
||||||
lookup.setType(MenuAction.RUNELITE.getId());
|
.setType(MenuAction.RUNELITE)
|
||||||
lookup.setParam0(event.getActionParam0());
|
.setIdentifier(event.getIdentifier())
|
||||||
lookup.setParam1(event.getActionParam1());
|
.onClick(e ->
|
||||||
lookup.setIdentifier(event.getIdentifier());
|
{
|
||||||
|
// Determine proper endpoint from player name.
|
||||||
insertMenuEntry(lookup, client.getMenuEntries());
|
// TODO: look at target's world and determine if tournament/dmm endpoint should be used instead.
|
||||||
|
HiscoreEndpoint endpoint = findHiscoreEndpointFromPlayerName(e.getTarget());
|
||||||
|
String target = Text.removeTags(e.getTarget());
|
||||||
|
lookupPlayer(target, endpoint);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||||
{
|
{
|
||||||
if ((event.getMenuAction() == MenuAction.RUNELITE || event.getMenuAction() == MenuAction.RUNELITE_PLAYER)
|
if (event.getMenuAction() == MenuAction.RUNELITE_PLAYER && event.getMenuOption().equals(LOOKUP))
|
||||||
&& event.getMenuOption().equals(LOOKUP))
|
|
||||||
{
|
|
||||||
final String target;
|
|
||||||
HiscoreEndpoint endpoint;
|
|
||||||
if (event.getMenuAction() == MenuAction.RUNELITE_PLAYER)
|
|
||||||
{
|
{
|
||||||
// The player id is included in the event, so we can use that to get the player name,
|
// The player id is included in the event, so we can use that to get the player name,
|
||||||
// which avoids having to parse out the combat level and any icons preceding the name.
|
// which avoids having to parse out the combat level and any icons preceding the name.
|
||||||
@@ -199,16 +195,8 @@ public class HiscorePlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint = getWorldEndpoint();
|
String target = player.getName();
|
||||||
target = player.getName();
|
HiscoreEndpoint endpoint = getWorldEndpoint();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Determine proper endpoint from player name.
|
|
||||||
// TODO: look at target's world and determine if tournament/dmm endpoint should be used instead.
|
|
||||||
endpoint = findHiscoreEndpointFromPlayerName(event.getMenuTarget());
|
|
||||||
target = Text.removeTags(event.getMenuTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
lookupPlayer(target, endpoint);
|
lookupPlayer(target, endpoint);
|
||||||
}
|
}
|
||||||
@@ -236,14 +224,6 @@ public class HiscorePlugin extends Plugin
|
|||||||
localHiscoreEndpoint = findHiscoreEndpointFromLocalPlayer();
|
localHiscoreEndpoint = findHiscoreEndpointFromLocalPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries)
|
|
||||||
{
|
|
||||||
MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry);
|
|
||||||
int menuEntryCount = newMenu.length;
|
|
||||||
ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2);
|
|
||||||
client.setMenuEntries(newMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lookupPlayer(String playerName, HiscoreEndpoint endpoint)
|
private void lookupPlayer(String playerName, HiscoreEndpoint endpoint)
|
||||||
{
|
{
|
||||||
SwingUtilities.invokeLater(() ->
|
SwingUtilities.invokeLater(() ->
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.instancemap;
|
|||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
|
||||||
import static net.runelite.api.widgets.WidgetInfo.MINIMAP_WORLDMAP_OPTIONS;
|
import static net.runelite.api.widgets.WidgetInfo.MINIMAP_WORLDMAP_OPTIONS;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
@@ -72,7 +71,17 @@ public class InstanceMapPlugin extends Plugin
|
|||||||
|
|
||||||
private void addCustomOptions()
|
private void addCustomOptions()
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(openMapOption);
|
menuManager.addManagedCustomMenu(openMapOption, entry ->
|
||||||
|
{
|
||||||
|
if (overlay.isMapShown())
|
||||||
|
{
|
||||||
|
closeMap();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showMap();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeCustomOptions()
|
private void removeCustomOptions()
|
||||||
@@ -107,32 +116,6 @@ public class InstanceMapPlugin extends Plugin
|
|||||||
overlay.onGameStateChange(event);
|
overlay.onGameStateChange(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean clickedOptionEquals(WidgetMenuOptionClicked event, WidgetMenuOption widgetMenuOption)
|
|
||||||
{
|
|
||||||
return event.getMenuOption().equals(widgetMenuOption.getMenuOption()) && event.getMenuTarget().equals(widgetMenuOption.getMenuTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event)
|
|
||||||
{
|
|
||||||
if (event.getWidget() != MINIMAP_WORLDMAP_OPTIONS)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clickedOptionEquals(event, openMapOption))
|
|
||||||
{
|
|
||||||
if (overlay.isMapShown())
|
|
||||||
{
|
|
||||||
closeMap();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
showMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showMap()
|
public void showMap()
|
||||||
{
|
{
|
||||||
overlay.setShowMap(true);
|
overlay.setShowMap(true);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class InteractHighlightOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry top = menuEntries[menuEntries.length - 1];
|
MenuEntry top = menuEntries[menuEntries.length - 1];
|
||||||
MenuAction menuAction = MenuAction.of(top.getType());
|
MenuAction menuAction = top.getType();
|
||||||
|
|
||||||
switch (menuAction)
|
switch (menuAction)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,14 +28,13 @@ import com.google.common.base.MoreObjects;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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 net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.events.MenuOpened;
|
import net.runelite.api.events.MenuOpened;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
@@ -46,7 +45,6 @@ import net.runelite.client.plugins.Plugin;
|
|||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.Text;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Inventory Tags",
|
name = "Inventory Tags",
|
||||||
@@ -157,44 +155,11 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onWidgetMenuOptionClicked(final WidgetMenuOptionClicked event)
|
|
||||||
{
|
|
||||||
if (event.getWidget() == WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB
|
|
||||||
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB
|
|
||||||
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB)
|
|
||||||
{
|
|
||||||
editorMode = event.getMenuOption().equals(CONFIGURE) && Text.removeTags(event.getMenuTarget()).equals(MENU_TARGET);
|
|
||||||
refreshInventoryMenuOptions();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(final MenuOptionClicked event)
|
|
||||||
{
|
|
||||||
if (event.getMenuAction() != MenuAction.RUNELITE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String selectedMenu = Text.removeTags(event.getMenuTarget());
|
|
||||||
|
|
||||||
if (event.getMenuOption().equals(MENU_SET))
|
|
||||||
{
|
|
||||||
setTag(event.getId(), selectedMenu);
|
|
||||||
}
|
|
||||||
else if (event.getMenuOption().equals(MENU_REMOVE))
|
|
||||||
{
|
|
||||||
unsetTag(event.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuOpened(final MenuOpened event)
|
public void onMenuOpened(final MenuOpened event)
|
||||||
{
|
{
|
||||||
final MenuEntry firstEntry = event.getFirstEntry();
|
final MenuEntry firstEntry = event.getFirstEntry();
|
||||||
|
if (firstEntry == null || !editorMode)
|
||||||
if (firstEntry == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -202,7 +167,7 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
final int widgetId = firstEntry.getParam1();
|
final int widgetId = firstEntry.getParam1();
|
||||||
|
|
||||||
// Inventory item menu
|
// Inventory item menu
|
||||||
if (widgetId == WidgetInfo.INVENTORY.getId() && editorMode)
|
if (widgetId == WidgetInfo.INVENTORY.getId())
|
||||||
{
|
{
|
||||||
int itemId = firstEntry.getIdentifier();
|
int itemId = firstEntry.getIdentifier();
|
||||||
|
|
||||||
@@ -211,26 +176,30 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] menuList = new MenuEntry[GROUPS.size() + 1];
|
// Set menu to only be Cancel
|
||||||
int num = 0;
|
client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), 1));
|
||||||
|
|
||||||
// preserve the 'Cancel' option as the client will reuse the first entry for Cancel and only resets option/action
|
|
||||||
menuList[num++] = event.getMenuEntries()[0];
|
|
||||||
|
|
||||||
for (final String groupName : GROUPS)
|
for (final String groupName : GROUPS)
|
||||||
{
|
{
|
||||||
final String group = getTag(itemId);
|
final String group = getTag(itemId);
|
||||||
final MenuEntry newMenu = new MenuEntry();
|
|
||||||
final Color color = getGroupNameColor(groupName);
|
final Color color = getGroupNameColor(groupName);
|
||||||
newMenu.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET);
|
|
||||||
newMenu.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE)));
|
|
||||||
newMenu.setIdentifier(itemId);
|
|
||||||
newMenu.setParam1(widgetId);
|
|
||||||
newMenu.setType(MenuAction.RUNELITE.getId());
|
|
||||||
menuList[num++] = newMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
client.setMenuEntries(menuList);
|
client.createMenuEntry(-1)
|
||||||
|
.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET)
|
||||||
|
.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE)))
|
||||||
|
.setType(MenuAction.RUNELITE)
|
||||||
|
.onClick(e ->
|
||||||
|
{
|
||||||
|
if (e.getOption().equals(MENU_SET))
|
||||||
|
{
|
||||||
|
setTag(itemId, groupName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsetTag(itemId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,15 +239,27 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
removeInventoryMenuOptions();
|
removeInventoryMenuOptions();
|
||||||
if (editorMode)
|
if (editorMode)
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE);
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE, this::save);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE);
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE, this::save);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE);
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE, this::save);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE);
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE, this::configure);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE);
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE, this::configure);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE);
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE, this::configure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void save(MenuEntry menuEntry)
|
||||||
|
{
|
||||||
|
editorMode = false;
|
||||||
|
refreshInventoryMenuOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configure(MenuEntry menuEntry)
|
||||||
|
{
|
||||||
|
editorMode = true;
|
||||||
|
refreshInventoryMenuOptions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class ItemPricesOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
final MenuEntry menuEntry = menuEntries[last];
|
final MenuEntry menuEntry = menuEntries[last];
|
||||||
final MenuAction action = MenuAction.of(menuEntry.getType());
|
final MenuAction action = menuEntry.getType();
|
||||||
final int widgetId = menuEntry.getParam1();
|
final int widgetId = menuEntry.getParam1();
|
||||||
final int groupId = WidgetInfo.TO_GROUP(widgetId);
|
final int groupId = WidgetInfo.TO_GROUP(widgetId);
|
||||||
final boolean isAlching = menuEntry.getOption().equals("Cast") && menuEntry.getTarget().contains("High Level Alchemy");
|
final boolean isAlching = menuEntry.getOption().equals("Cast") && menuEntry.getTarget().contains("High Level Alchemy");
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import net.runelite.api.events.MenuEntryAdded;
|
|||||||
import net.runelite.api.events.MenuOpened;
|
import net.runelite.api.events.MenuOpened;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
import net.runelite.api.events.MenuOptionClicked;
|
||||||
import net.runelite.api.events.PostItemComposition;
|
import net.runelite.api.events.PostItemComposition;
|
||||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
|
||||||
import net.runelite.api.widgets.WidgetID;
|
import net.runelite.api.widgets.WidgetID;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
@@ -74,7 +73,6 @@ import static net.runelite.client.plugins.menuentryswapper.MenuEntrySwapperConfi
|
|||||||
import static net.runelite.client.plugins.menuentryswapper.MenuEntrySwapperConfig.MorytaniaLegsMode;
|
import static net.runelite.client.plugins.menuentryswapper.MenuEntrySwapperConfig.MorytaniaLegsMode;
|
||||||
import static net.runelite.client.plugins.menuentryswapper.MenuEntrySwapperConfig.RadasBlessingMode;
|
import static net.runelite.client.plugins.menuentryswapper.MenuEntrySwapperConfig.RadasBlessingMode;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Menu Entry Swapper",
|
name = "Menu Entry Swapper",
|
||||||
@@ -506,24 +504,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
clientThread.invoke(this::resetItemCompositionCache);
|
clientThread.invoke(this::resetItemCompositionCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event)
|
|
||||||
{
|
|
||||||
if (event.getWidget() == WidgetInfo.FIXED_VIEWPORT_INVENTORY_TAB
|
|
||||||
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB
|
|
||||||
|| event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB)
|
|
||||||
{
|
|
||||||
String option = event.getMenuOption();
|
|
||||||
String target = Text.removeTags(event.getMenuTarget());
|
|
||||||
if ((option.equals(CONFIGURE) || option.equals(SAVE)) && (target.equals(LEFT_CLICK_MENU_TARGET) || target.equals(SHIFT_CLICK_MENU_TARGET)))
|
|
||||||
{
|
|
||||||
configuringShiftClick = option.equals(CONFIGURE) && target.equals(SHIFT_CLICK_MENU_TARGET);
|
|
||||||
configuringLeftClick = option.equals(CONFIGURE) && target.equals(LEFT_CLICK_MENU_TARGET);
|
|
||||||
rebuildCustomizationMenus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuOpened(MenuOpened event)
|
public void onMenuOpened(MenuOpened event)
|
||||||
{
|
{
|
||||||
@@ -591,11 +571,11 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
|
|
||||||
for (MenuEntry entry : entries)
|
for (MenuEntry entry : entries)
|
||||||
{
|
{
|
||||||
final MenuAction menuAction = MenuAction.of(entry.getType());
|
final MenuAction menuAction = entry.getType();
|
||||||
|
|
||||||
if (ITEM_MENU_TYPES.contains(menuAction) && entry.getIdentifier() == itemId)
|
if (ITEM_MENU_TYPES.contains(menuAction) && entry.getIdentifier() == itemId)
|
||||||
{
|
{
|
||||||
entry.setType(MenuAction.RUNELITE.getId());
|
entry.setType(MenuAction.RUNELITE);
|
||||||
|
|
||||||
if (activeAction == menuAction)
|
if (activeAction == menuAction)
|
||||||
{
|
{
|
||||||
@@ -604,13 +584,11 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final MenuEntry resetShiftClickEntry = new MenuEntry();
|
client.createMenuEntry(-1)
|
||||||
resetShiftClickEntry.setOption(RESET);
|
.setOption(RESET)
|
||||||
resetShiftClickEntry.setTarget(configuringShiftClick ? SHIFT_CLICK_MENU_TARGET : LEFT_CLICK_MENU_TARGET);
|
.setTarget(configuringShiftClick ? SHIFT_CLICK_MENU_TARGET : LEFT_CLICK_MENU_TARGET)
|
||||||
resetShiftClickEntry.setIdentifier(itemId);
|
.setType(MenuAction.RUNELITE)
|
||||||
resetShiftClickEntry.setParam1(widgetId);
|
.onClick(e -> unsetSwapConfig(configuringShiftClick, itemId));
|
||||||
resetShiftClickEntry.setType(MenuAction.RUNELITE.getId());
|
|
||||||
client.setMenuEntries(ArrayUtils.addAll(entries, resetShiftClickEntry));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -636,8 +614,8 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
final int opId = isDepositBoxPlayerInventory ? shiftDepositMode.getIdentifierDepositBox()
|
final int opId = isDepositBoxPlayerInventory ? shiftDepositMode.getIdentifierDepositBox()
|
||||||
: isChambersOfXericStorageUnitPlayerInventory ? shiftDepositMode.getIdentifierChambersStorageUnit()
|
: isChambersOfXericStorageUnitPlayerInventory ? shiftDepositMode.getIdentifierChambersStorageUnit()
|
||||||
: shiftDepositMode.getIdentifier();
|
: shiftDepositMode.getIdentifier();
|
||||||
final int actionId = opId >= 6 ? MenuAction.CC_OP_LOW_PRIORITY.getId() : MenuAction.CC_OP.getId();
|
final MenuAction action = opId >= 6 ? MenuAction.CC_OP_LOW_PRIORITY : MenuAction.CC_OP;
|
||||||
bankModeSwap(actionId, opId);
|
bankModeSwap(action, opId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap to shift-click withdraw behavior
|
// Swap to shift-click withdraw behavior
|
||||||
@@ -647,22 +625,23 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
&& menuEntryAdded.getOption().startsWith("Withdraw"))
|
&& menuEntryAdded.getOption().startsWith("Withdraw"))
|
||||||
{
|
{
|
||||||
ShiftWithdrawMode shiftWithdrawMode = config.bankWithdrawShiftClick();
|
ShiftWithdrawMode shiftWithdrawMode = config.bankWithdrawShiftClick();
|
||||||
final int actionId, opId;
|
final MenuAction action;
|
||||||
|
final int opId;
|
||||||
if (widgetGroupId == WidgetID.CHAMBERS_OF_XERIC_STORAGE_UNIT_PRIVATE_GROUP_ID || widgetGroupId == WidgetID.CHAMBERS_OF_XERIC_STORAGE_UNIT_SHARED_GROUP_ID)
|
if (widgetGroupId == WidgetID.CHAMBERS_OF_XERIC_STORAGE_UNIT_PRIVATE_GROUP_ID || widgetGroupId == WidgetID.CHAMBERS_OF_XERIC_STORAGE_UNIT_SHARED_GROUP_ID)
|
||||||
{
|
{
|
||||||
actionId = MenuAction.CC_OP.getId();
|
action = MenuAction.CC_OP;
|
||||||
opId = shiftWithdrawMode.getIdentifierChambersStorageUnit();
|
opId = shiftWithdrawMode.getIdentifierChambersStorageUnit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
actionId = shiftWithdrawMode.getMenuAction().getId();
|
action = shiftWithdrawMode.getMenuAction();
|
||||||
opId = shiftWithdrawMode.getIdentifier();
|
opId = shiftWithdrawMode.getIdentifier();
|
||||||
}
|
}
|
||||||
bankModeSwap(actionId, opId);
|
bankModeSwap(action, opId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bankModeSwap(int entryTypeId, int entryIdentifier)
|
private void bankModeSwap(MenuAction entryType, int entryIdentifier)
|
||||||
{
|
{
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
|
|
||||||
@@ -670,10 +649,10 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
MenuEntry entry = menuEntries[i];
|
MenuEntry entry = menuEntries[i];
|
||||||
|
|
||||||
if (entry.getType() == entryTypeId && entry.getIdentifier() == entryIdentifier)
|
if (entry.getType() == entryType && entry.getIdentifier() == entryIdentifier)
|
||||||
{
|
{
|
||||||
// Raise the priority of the op so it doesn't get sorted later
|
// Raise the priority of the op so it doesn't get sorted later
|
||||||
entry.setType(MenuAction.CC_OP.getId());
|
entry.setType(MenuAction.CC_OP);
|
||||||
|
|
||||||
menuEntries[i] = menuEntries[menuEntries.length - 1];
|
menuEntries[i] = menuEntries[menuEntries.length - 1];
|
||||||
menuEntries[menuEntries.length - 1] = entry;
|
menuEntries[menuEntries.length - 1] = entry;
|
||||||
@@ -703,17 +682,6 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
String target = event.getMenuTarget();
|
String target = event.getMenuTarget();
|
||||||
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
|
|
||||||
if (option.equals(RESET) && target.equals(SHIFT_CLICK_MENU_TARGET))
|
|
||||||
{
|
|
||||||
unsetSwapConfig(true, itemId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (option.equals(RESET) && target.equals(LEFT_CLICK_MENU_TARGET))
|
|
||||||
{
|
|
||||||
unsetSwapConfig(false, itemId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!itemComposition.getName().equals(Text.removeTags(target)))
|
if (!itemComposition.getName().equals(Text.removeTags(target)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -741,7 +709,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
private void swapMenuEntry(MenuEntry[] menuEntries, int index, MenuEntry menuEntry)
|
private void swapMenuEntry(MenuEntry[] menuEntries, int index, MenuEntry menuEntry)
|
||||||
{
|
{
|
||||||
final int eventId = menuEntry.getIdentifier();
|
final int eventId = menuEntry.getIdentifier();
|
||||||
final MenuAction menuAction = MenuAction.of(menuEntry.getType());
|
final MenuAction menuAction = menuEntry.getType();
|
||||||
final String option = Text.removeTags(menuEntry.getOption()).toLowerCase();
|
final String option = Text.removeTags(menuEntry.getOption()).toLowerCase();
|
||||||
final String target = Text.removeTags(menuEntry.getTarget()).toLowerCase();
|
final String target = Text.removeTags(menuEntry.getTarget()).toLowerCase();
|
||||||
final NPC hintArrowNpc = client.getHintArrowNpc();
|
final NPC hintArrowNpc = client.getHintArrowNpc();
|
||||||
@@ -968,31 +936,31 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
removeCusomizationMenus();
|
removeCusomizationMenus();
|
||||||
if (configuringLeftClick)
|
if (configuringLeftClick)
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_LC);
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_LC, this::save);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_LC);
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_LC, this::save);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_LC);
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_LC, this::save);
|
||||||
}
|
}
|
||||||
else if (configuringShiftClick)
|
else if (configuringShiftClick)
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_SC);
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_SAVE_SC, this::save);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_SC);
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE_SC, this::save);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_SC);
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_SAVE_SC, this::save);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Left click
|
// Left click
|
||||||
if (config.leftClickCustomization())
|
if (config.leftClickCustomization())
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_LC);
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_LC, this::configure);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_LC);
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_LC, this::configure);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_LC);
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_LC, this::configure);
|
||||||
}
|
}
|
||||||
// Shift click
|
// Shift click
|
||||||
if (config.shiftClickCustomization())
|
if (config.shiftClickCustomization())
|
||||||
{
|
{
|
||||||
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_SC);
|
menuManager.addManagedCustomMenu(FIXED_INVENTORY_TAB_CONFIGURE_SC, this::configure);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_SC);
|
menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE_SC, this::configure);
|
||||||
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_SC);
|
menuManager.addManagedCustomMenu(RESIZABLE_INVENTORY_TAB_CONFIGURE_SC, this::configure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1001,4 +969,18 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return client.isKeyPressed(KeyCode.KC_SHIFT);
|
return client.isKeyPressed(KeyCode.KC_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void save(MenuEntry menuEntry)
|
||||||
|
{
|
||||||
|
configuringLeftClick = configuringShiftClick = false;
|
||||||
|
rebuildCustomizationMenus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configure(MenuEntry menuEntry)
|
||||||
|
{
|
||||||
|
String target = Text.removeTags(menuEntry.getTarget());
|
||||||
|
configuringShiftClick = target.equals(SHIFT_CLICK_MENU_TARGET);
|
||||||
|
configuringLeftClick = target.equals(LEFT_CLICK_MENU_TARGET);
|
||||||
|
rebuildCustomizationMenus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class MouseHighlightOverlay extends Overlay
|
|||||||
MenuEntry menuEntry = menuEntries[last];
|
MenuEntry menuEntry = menuEntries[last];
|
||||||
String target = menuEntry.getTarget();
|
String target = menuEntry.getTarget();
|
||||||
String option = menuEntry.getOption();
|
String option = menuEntry.getOption();
|
||||||
MenuAction type = MenuAction.of(menuEntry.getType());
|
MenuAction type = menuEntry.getType();
|
||||||
|
|
||||||
if (type == MenuAction.RUNELITE_OVERLAY || type == MenuAction.CC_OP_LOW_PRIORITY)
|
if (type == MenuAction.RUNELITE_OVERLAY || type == MenuAction.CC_OP_LOW_PRIORITY)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.google.inject.Provides;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -57,7 +56,6 @@ import net.runelite.api.events.GameStateChanged;
|
|||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.GraphicsObjectCreated;
|
import net.runelite.api.events.GraphicsObjectCreated;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.events.NpcChanged;
|
import net.runelite.api.events.NpcChanged;
|
||||||
import net.runelite.api.events.NpcDespawned;
|
import net.runelite.api.events.NpcDespawned;
|
||||||
import net.runelite.api.events.NpcSpawned;
|
import net.runelite.api.events.NpcSpawned;
|
||||||
@@ -271,7 +269,6 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
final MenuEntry menuEntry = menuEntries[menuEntries.length - 1];
|
final MenuEntry menuEntry = menuEntries[menuEntries.length - 1];
|
||||||
final String target = ColorUtil.prependColorTag(Text.removeTags(event.getTarget()), color);
|
final String target = ColorUtil.prependColorTag(Text.removeTags(event.getTarget()), color);
|
||||||
menuEntry.setTarget(target);
|
menuEntry.setTarget(target);
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (menuAction == MenuAction.EXAMINE_NPC && client.isKeyPressed(KeyCode.KC_SHIFT))
|
else if (menuAction == MenuAction.EXAMINE_NPC && client.isKeyPressed(KeyCode.KC_SHIFT))
|
||||||
@@ -291,48 +288,29 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
.filter(highlight -> !highlight.equalsIgnoreCase(npcName))
|
.filter(highlight -> !highlight.equalsIgnoreCase(npcName))
|
||||||
.anyMatch(highlight -> WildcardMatcher.matches(highlight, npcName));
|
.anyMatch(highlight -> WildcardMatcher.matches(highlight, npcName));
|
||||||
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
|
||||||
|
|
||||||
// Only add Untag-All option to npcs not highlighted by a wildcard entry, because untag-all will not remove wildcards
|
// Only add Untag-All option to npcs not highlighted by a wildcard entry, because untag-all will not remove wildcards
|
||||||
if (!matchesList)
|
if (!matchesList)
|
||||||
{
|
{
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 2);
|
client.createMenuEntry(-1)
|
||||||
final MenuEntry tagAllEntry = menuEntries[menuEntries.length - 2] = new MenuEntry();
|
.setOption(highlights.stream().anyMatch(npcName::equalsIgnoreCase) ? UNTAG_ALL : TAG_ALL)
|
||||||
tagAllEntry.setOption(highlights.stream().anyMatch(npcName::equalsIgnoreCase) ? UNTAG_ALL : TAG_ALL);
|
.setTarget(event.getTarget())
|
||||||
tagAllEntry.setTarget(event.getTarget());
|
.setIdentifier(event.getIdentifier())
|
||||||
tagAllEntry.setParam0(event.getActionParam0());
|
.setType(MenuAction.RUNELITE)
|
||||||
tagAllEntry.setParam1(event.getActionParam1());
|
.onClick(this::tag);
|
||||||
tagAllEntry.setIdentifier(event.getIdentifier());
|
|
||||||
tagAllEntry.setType(MenuAction.RUNELITE.getId());
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
client.createMenuEntry(-1)
|
||||||
|
.setOption(npcTags.contains(npc.getIndex()) ? UNTAG : TAG)
|
||||||
|
.setTarget(event.getTarget())
|
||||||
|
.setIdentifier(event.getIdentifier())
|
||||||
|
.setType(MenuAction.RUNELITE)
|
||||||
|
.onClick(this::tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tag(MenuEntry entry)
|
||||||
{
|
{
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
final int id = entry.getIdentifier();
|
||||||
}
|
|
||||||
|
|
||||||
final MenuEntry tagEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
|
||||||
tagEntry.setOption(npcTags.contains(npc.getIndex()) ? UNTAG : TAG);
|
|
||||||
tagEntry.setTarget(event.getTarget());
|
|
||||||
tagEntry.setParam0(event.getActionParam0());
|
|
||||||
tagEntry.setParam1(event.getActionParam1());
|
|
||||||
tagEntry.setIdentifier(event.getIdentifier());
|
|
||||||
tagEntry.setType(MenuAction.RUNELITE.getId());
|
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(MenuOptionClicked click)
|
|
||||||
{
|
|
||||||
if (click.getMenuAction() != MenuAction.RUNELITE ||
|
|
||||||
!(click.getMenuOption().equals(TAG) || click.getMenuOption().equals(UNTAG) ||
|
|
||||||
click.getMenuOption().equals(TAG_ALL) || click.getMenuOption().equals(UNTAG_ALL)))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int id = click.getId();
|
|
||||||
final NPC[] cachedNPCs = client.getCachedNPCs();
|
final NPC[] cachedNPCs = client.getCachedNPCs();
|
||||||
final NPC npc = cachedNPCs[id];
|
final NPC npc = cachedNPCs[id];
|
||||||
|
|
||||||
@@ -341,7 +319,7 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (click.getMenuOption().equals(TAG) || click.getMenuOption().equals(UNTAG))
|
if (entry.getOption().equals(TAG) || entry.getOption().equals(UNTAG))
|
||||||
{
|
{
|
||||||
final boolean removed = npcTags.remove(id);
|
final boolean removed = npcTags.remove(id);
|
||||||
|
|
||||||
@@ -371,8 +349,6 @@ public class NpcIndicatorsPlugin extends Plugin
|
|||||||
// this trips a config change which triggers the overlay rebuild
|
// this trips a config change which triggers the overlay rebuild
|
||||||
updateNpcsToHighlight(name);
|
updateNpcsToHighlight(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
click.consume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -65,7 +64,6 @@ import net.runelite.api.events.GameStateChanged;
|
|||||||
import net.runelite.api.events.GroundObjectDespawned;
|
import net.runelite.api.events.GroundObjectDespawned;
|
||||||
import net.runelite.api.events.GroundObjectSpawned;
|
import net.runelite.api.events.GroundObjectSpawned;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.events.WallObjectChanged;
|
import net.runelite.api.events.WallObjectChanged;
|
||||||
import net.runelite.api.events.WallObjectDespawned;
|
import net.runelite.api.events.WallObjectDespawned;
|
||||||
import net.runelite.api.events.WallObjectSpawned;
|
import net.runelite.api.events.WallObjectSpawned;
|
||||||
@@ -230,35 +228,26 @@ public class ObjectIndicatorsPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
client.createMenuEntry(-1)
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
.setOption(objects.stream().anyMatch(o -> o.getTileObject() == tileObject) ? UNMARK : MARK)
|
||||||
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
.setTarget(event.getTarget())
|
||||||
menuEntry.setOption(objects.stream().anyMatch(o -> o.getTileObject() == tileObject) ? UNMARK : MARK);
|
.setParam0(event.getActionParam0())
|
||||||
menuEntry.setTarget(event.getTarget());
|
.setParam1(event.getActionParam1())
|
||||||
menuEntry.setParam0(event.getActionParam0());
|
.setIdentifier(event.getIdentifier())
|
||||||
menuEntry.setParam1(event.getActionParam1());
|
.setType(MenuAction.RUNELITE)
|
||||||
menuEntry.setIdentifier(event.getIdentifier());
|
.onClick(this::markObject);
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
private void markObject(MenuEntry entry)
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
{
|
||||||
if (event.getMenuAction() != MenuAction.RUNELITE
|
|
||||||
|| !(event.getMenuOption().equals(MARK) || event.getMenuOption().equals(UNMARK)))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Scene scene = client.getScene();
|
Scene scene = client.getScene();
|
||||||
Tile[][][] tiles = scene.getTiles();
|
Tile[][][] tiles = scene.getTiles();
|
||||||
final int x = event.getParam0();
|
final int x = entry.getParam0();
|
||||||
final int y = event.getParam1();
|
final int y = entry.getParam1();
|
||||||
final int z = client.getPlane();
|
final int z = client.getPlane();
|
||||||
final Tile tile = tiles[z][x][y];
|
final Tile tile = tiles[z][x][y];
|
||||||
|
|
||||||
TileObject object = findTileObject(tile, event.getId());
|
TileObject object = findTileObject(tile, entry.getIdentifier());
|
||||||
if (object == null)
|
if (object == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ public class OpponentInfoPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
menuEntries[menuEntries.length - 1].setTarget("*" + menuEntries[menuEntries.length - 1].getTarget());
|
menuEntries[menuEntries.length - 1].setTarget("*" + menuEntries[menuEntries.length - 1].getTarget());
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import lombok.Value;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.FriendsChatRank;
|
import net.runelite.api.FriendsChatRank;
|
||||||
import static net.runelite.api.FriendsChatRank.UNRANKED;
|
import static net.runelite.api.FriendsChatRank.UNRANKED;
|
||||||
|
import net.runelite.api.MenuAction;
|
||||||
import static net.runelite.api.MenuAction.ITEM_USE_ON_PLAYER;
|
import static net.runelite.api.MenuAction.ITEM_USE_ON_PLAYER;
|
||||||
import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET;
|
|
||||||
import static net.runelite.api.MenuAction.PLAYER_EIGTH_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_EIGTH_OPTION;
|
||||||
import static net.runelite.api.MenuAction.PLAYER_FIFTH_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_FIFTH_OPTION;
|
||||||
import static net.runelite.api.MenuAction.PLAYER_FIRST_OPTION;
|
import static net.runelite.api.MenuAction.PLAYER_FIRST_OPTION;
|
||||||
@@ -118,29 +118,23 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
boolean modified = false;
|
|
||||||
|
|
||||||
for (MenuEntry entry : menuEntries)
|
for (MenuEntry entry : menuEntries)
|
||||||
{
|
{
|
||||||
int type = entry.getType();
|
MenuAction type = entry.getType();
|
||||||
|
|
||||||
if (type >= MENU_ACTION_DEPRIORITIZE_OFFSET)
|
if (type == WALK
|
||||||
{
|
|| type == SPELL_CAST_ON_PLAYER
|
||||||
type -= MENU_ACTION_DEPRIORITIZE_OFFSET;
|
|| type == ITEM_USE_ON_PLAYER
|
||||||
}
|
|| type == PLAYER_FIRST_OPTION
|
||||||
|
|| type == PLAYER_SECOND_OPTION
|
||||||
if (type == WALK.getId()
|
|| type == PLAYER_THIRD_OPTION
|
||||||
|| type == SPELL_CAST_ON_PLAYER.getId()
|
|| type == PLAYER_FOURTH_OPTION
|
||||||
|| type == ITEM_USE_ON_PLAYER.getId()
|
|| type == PLAYER_FIFTH_OPTION
|
||||||
|| type == PLAYER_FIRST_OPTION.getId()
|
|| type == PLAYER_SIXTH_OPTION
|
||||||
|| type == PLAYER_SECOND_OPTION.getId()
|
|| type == PLAYER_SEVENTH_OPTION
|
||||||
|| type == PLAYER_THIRD_OPTION.getId()
|
|| type == PLAYER_EIGTH_OPTION
|
||||||
|| type == PLAYER_FOURTH_OPTION.getId()
|
|| type == RUNELITE_PLAYER)
|
||||||
|| type == PLAYER_FIFTH_OPTION.getId()
|
|
||||||
|| type == PLAYER_SIXTH_OPTION.getId()
|
|
||||||
|| type == PLAYER_SEVENTH_OPTION.getId()
|
|
||||||
|| type == PLAYER_EIGTH_OPTION.getId()
|
|
||||||
|| type == RUNELITE_PLAYER.getId())
|
|
||||||
{
|
{
|
||||||
Player[] players = client.getCachedPlayers();
|
Player[] players = client.getCachedPlayers();
|
||||||
Player player = null;
|
Player player = null;
|
||||||
@@ -149,7 +143,7 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
|
|
||||||
// 'Walk here' identifiers are offset by 1 because the default
|
// 'Walk here' identifiers are offset by 1 because the default
|
||||||
// identifier for this option is 0, which is also a player index.
|
// identifier for this option is 0, which is also a player index.
|
||||||
if (type == WALK.getId())
|
if (type == WALK)
|
||||||
{
|
{
|
||||||
identifier--;
|
identifier--;
|
||||||
}
|
}
|
||||||
@@ -175,14 +169,8 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
String newTarget = decorateTarget(oldTarget, decorations);
|
String newTarget = decorateTarget(oldTarget, decorations);
|
||||||
|
|
||||||
entry.setTarget(newTarget);
|
entry.setTarget(newTarget);
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modified)
|
|
||||||
{
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Decorations getDecorations(Player player)
|
private Decorations getDecorations(Player player)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ import okhttp3.HttpUrl;
|
|||||||
)
|
)
|
||||||
public class WikiPlugin extends Plugin
|
public class WikiPlugin extends Plugin
|
||||||
{
|
{
|
||||||
static final HttpUrl WIKI_BASE = HttpUrl.parse("https://oldschool.runescape.wiki");
|
static final HttpUrl WIKI_BASE = HttpUrl.get("https://oldschool.runescape.wiki");
|
||||||
static final HttpUrl WIKI_API = WIKI_BASE.newBuilder().addPathSegments("api.php").build();
|
static final HttpUrl WIKI_API = WIKI_BASE.newBuilder().addPathSegments("api.php").build();
|
||||||
static final String UTM_SORUCE_KEY = "utm_source";
|
static final String UTM_SORUCE_KEY = "utm_source";
|
||||||
static final String UTM_SORUCE_VALUE = "runelite";
|
static final String UTM_SORUCE_VALUE = "runelite";
|
||||||
@@ -335,20 +335,6 @@ public class WikiPlugin extends Plugin
|
|||||||
LinkBrowser.browse(url.toString());
|
LinkBrowser.browse(url.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.getMenuAction() == MenuAction.RUNELITE)
|
|
||||||
{
|
|
||||||
switch (ev.getMenuOption())
|
|
||||||
{
|
|
||||||
case MENUOP_WIKI:
|
|
||||||
LinkBrowser.browse(WIKI_BASE.newBuilder()
|
|
||||||
.addPathSegment("w")
|
|
||||||
.addPathSegment(Text.removeTags(ev.getMenuTarget()))
|
|
||||||
.addQueryParameter(UTM_SORUCE_KEY, UTM_SORUCE_VALUE)
|
|
||||||
.build().toString());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSearchInput()
|
private void openSearchInput()
|
||||||
@@ -372,17 +358,17 @@ public class WikiPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
int widgetIndex = event.getActionParam0();
|
int widgetIndex = event.getActionParam0();
|
||||||
int widgetID = event.getActionParam1();
|
int widgetID = event.getActionParam1();
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
|
||||||
|
|
||||||
if (wikiSelected && event.getType() == MenuAction.SPELL_CAST_ON_WIDGET.getId())
|
if (wikiSelected && event.getType() == MenuAction.SPELL_CAST_ON_WIDGET.getId())
|
||||||
{
|
{
|
||||||
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
Widget w = getWidget(widgetID, widgetIndex);
|
Widget w = getWidget(widgetID, widgetIndex);
|
||||||
if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1)
|
if (w.getType() == WidgetType.GRAPHIC && w.getItemId() != -1)
|
||||||
{
|
{
|
||||||
for (int ourEntry = menuEntries.length - 1;ourEntry >= 0; ourEntry--)
|
for (int ourEntry = menuEntries.length - 1;ourEntry >= 0; ourEntry--)
|
||||||
{
|
{
|
||||||
MenuEntry entry = menuEntries[ourEntry];
|
MenuEntry entry = menuEntries[ourEntry];
|
||||||
if (entry.getType() == MenuAction.SPELL_CAST_ON_WIDGET.getId())
|
if (entry.getType() == MenuAction.SPELL_CAST_ON_WIDGET)
|
||||||
{
|
{
|
||||||
int id = itemManager.canonicalize(w.getItemId());
|
int id = itemManager.canonicalize(w.getItemId());
|
||||||
String name = itemManager.getItemComposition(id).getName();
|
String name = itemManager.getItemComposition(id).getName();
|
||||||
@@ -390,7 +376,6 @@ public class WikiPlugin extends Plugin
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -400,7 +385,7 @@ public class WikiPlugin extends Plugin
|
|||||||
MenuEntry[] oldEntries = menuEntries;
|
MenuEntry[] oldEntries = menuEntries;
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length - 1);
|
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length - 1);
|
||||||
for (int ourEntry = oldEntries.length - 1;
|
for (int ourEntry = oldEntries.length - 1;
|
||||||
ourEntry >= 2 && oldEntries[oldEntries.length - 1].getType() != MenuAction.SPELL_CAST_ON_WIDGET.getId();
|
ourEntry >= 2 && oldEntries[oldEntries.length - 1].getType() != MenuAction.SPELL_CAST_ON_WIDGET;
|
||||||
ourEntry--)
|
ourEntry--)
|
||||||
{
|
{
|
||||||
menuEntries[ourEntry - 1] = oldEntries[ourEntry];
|
menuEntries[ourEntry - 1] = oldEntries[ourEntry];
|
||||||
@@ -425,16 +410,15 @@ public class WikiPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
client.createMenuEntry(-1)
|
||||||
|
.setTarget(action.replace("View ", "").replace(" guide", ""))
|
||||||
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
.setOption(MENUOP_WIKI)
|
||||||
menuEntry.setTarget(action.replace("View ", "").replace(" guide", ""));
|
.setType(MenuAction.RUNELITE)
|
||||||
menuEntry.setOption(MENUOP_WIKI);
|
.onClick(ev -> LinkBrowser.browse(WIKI_BASE.newBuilder()
|
||||||
menuEntry.setParam0(widgetIndex);
|
.addPathSegment("w")
|
||||||
menuEntry.setParam1(widgetID);
|
.addPathSegment(Text.removeTags(ev.getTarget()))
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
.addQueryParameter(UTM_SORUCE_KEY, UTM_SORUCE_VALUE)
|
||||||
|
.build().toString()));
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ package net.runelite.client.plugins.worldhopper;
|
|||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ObjectArrays;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -54,7 +53,6 @@ import net.runelite.api.FriendsChatManager;
|
|||||||
import net.runelite.api.FriendsChatMember;
|
import net.runelite.api.FriendsChatMember;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
|
||||||
import net.runelite.api.NameableContainer;
|
import net.runelite.api.NameableContainer;
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.clan.ClanChannel;
|
import net.runelite.api.clan.ClanChannel;
|
||||||
@@ -63,7 +61,6 @@ import net.runelite.api.events.ChatMessage;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.api.events.WorldListLoad;
|
import net.runelite.api.events.WorldListLoad;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
@@ -92,7 +89,6 @@ import net.runelite.client.util.WorldUtil;
|
|||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldResult;
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
import net.runelite.http.api.worlds.WorldType;
|
import net.runelite.http.api.worlds.WorldType;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "World Hopper",
|
name = "World Hopper",
|
||||||
@@ -397,43 +393,19 @@ public class WorldHopperPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MenuEntry hopTo = new MenuEntry();
|
client.createMenuEntry(after ? -2 : -1)
|
||||||
hopTo.setOption(HOP_TO);
|
.setOption(HOP_TO)
|
||||||
hopTo.setTarget(event.getTarget());
|
.setTarget(event.getTarget())
|
||||||
hopTo.setType(MenuAction.RUNELITE.getId());
|
.setType(MenuAction.RUNELITE)
|
||||||
hopTo.setParam0(event.getActionParam0());
|
.onClick(e ->
|
||||||
hopTo.setParam1(event.getActionParam1());
|
|
||||||
|
|
||||||
insertMenuEntry(hopTo, client.getMenuEntries(), after);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries, boolean after)
|
|
||||||
{
|
{
|
||||||
MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry);
|
ChatPlayer p = getChatPlayerFromName(e.getTarget());
|
||||||
|
|
||||||
if (after)
|
if (p != null)
|
||||||
{
|
{
|
||||||
int menuEntryCount = newMenu.length;
|
hop(p.getWorld());
|
||||||
ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
client.setMenuEntries(newMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
|
||||||
if (event.getMenuAction() != MenuAction.RUNELITE || !event.getMenuOption().equals(HOP_TO))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatPlayer player = getChatPlayerFromName(event.getMenuTarget());
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
hop(player.getWorld());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import com.google.inject.Binder;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -45,7 +44,6 @@ import net.runelite.api.Client;
|
|||||||
import net.runelite.api.Experience;
|
import net.runelite.api.Experience;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
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.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
@@ -54,7 +52,6 @@ import net.runelite.api.WorldType;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.events.NpcDespawned;
|
import net.runelite.api.events.NpcDespawned;
|
||||||
import net.runelite.api.events.StatChanged;
|
import net.runelite.api.events.StatChanged;
|
||||||
import net.runelite.api.widgets.WidgetID;
|
import net.runelite.api.widgets.WidgetID;
|
||||||
@@ -521,48 +518,21 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
final String skillText = event.getOption().split(" ")[1];
|
final String skillText = event.getOption().split(" ")[1];
|
||||||
final Skill skill = Skill.valueOf(Text.removeTags(skillText).toUpperCase());
|
final Skill skill = Skill.valueOf(Text.removeTags(skillText).toUpperCase());
|
||||||
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
client.createMenuEntry(-1)
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
.setTarget(skillText)
|
||||||
|
.setOption(hasOverlay(skill) ? MENUOP_REMOVE_CANVAS_TRACKER : MENUOP_ADD_CANVAS_TRACKER)
|
||||||
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
.setType(MenuAction.RUNELITE)
|
||||||
menuEntry.setTarget(skillText);
|
.onClick(e ->
|
||||||
menuEntry.setOption(hasOverlay(skill) ? MENUOP_REMOVE_CANVAS_TRACKER : MENUOP_ADD_CANVAS_TRACKER);
|
|
||||||
menuEntry.setParam0(event.getActionParam0());
|
|
||||||
menuEntry.setParam1(widgetID);
|
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
{
|
||||||
if (event.getMenuAction().getId() != MenuAction.RUNELITE.getId()
|
if (hasOverlay(skill))
|
||||||
|| TO_GROUP(event.getParam1()) != WidgetID.SKILLS_GROUP_ID)
|
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Skill skill;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
skill = Skill.valueOf(Text.removeTags(event.getMenuTarget()).toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex)
|
|
||||||
{
|
|
||||||
log.debug(null, ex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (event.getMenuOption())
|
|
||||||
{
|
|
||||||
case MENUOP_ADD_CANVAS_TRACKER:
|
|
||||||
addOverlay(skill);
|
|
||||||
break;
|
|
||||||
case MENUOP_REMOVE_CANVAS_TRACKER:
|
|
||||||
removeOverlay(skill);
|
removeOverlay(skill);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addOverlay(skill);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
XpStateSingle getSkillState(Skill skill)
|
XpStateSingle getSkillState(Skill skill)
|
||||||
|
|||||||
@@ -40,17 +40,13 @@ import javax.inject.Singleton;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.runelite.api.MenuAction;
|
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.widgets.WidgetID;
|
import net.runelite.api.widgets.WidgetID;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.events.OverlayMenuClicked;
|
|
||||||
import net.runelite.client.events.PluginChanged;
|
import net.runelite.client.events.PluginChanged;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,14 +104,12 @@ public class OverlayManager
|
|||||||
private ArrayListMultimap<Object, Overlay> overlayMap = ArrayListMultimap.create();
|
private ArrayListMultimap<Object, Overlay> overlayMap = ArrayListMultimap.create();
|
||||||
|
|
||||||
private final ConfigManager configManager;
|
private final ConfigManager configManager;
|
||||||
private final EventBus eventBus;
|
|
||||||
private final RuneLiteConfig runeLiteConfig;
|
private final RuneLiteConfig runeLiteConfig;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager(final ConfigManager configManager, final EventBus eventBus, final RuneLiteConfig runeLiteConfig)
|
private OverlayManager(final ConfigManager configManager, final RuneLiteConfig runeLiteConfig)
|
||||||
{
|
{
|
||||||
this.configManager = configManager;
|
this.configManager = configManager;
|
||||||
this.eventBus = eventBus;
|
|
||||||
this.runeLiteConfig = runeLiteConfig;
|
this.runeLiteConfig = runeLiteConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,32 +131,6 @@ public class OverlayManager
|
|||||||
rebuildOverlayLayers();
|
rebuildOverlayLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
||||||
{
|
|
||||||
MenuAction menuAction = event.getMenuAction();
|
|
||||||
if (menuAction != MenuAction.RUNELITE_OVERLAY && menuAction != MenuAction.RUNELITE_OVERLAY_CONFIG)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.consume();
|
|
||||||
|
|
||||||
Overlay overlay = overlays.get(event.getId());
|
|
||||||
if (overlay != null)
|
|
||||||
{
|
|
||||||
List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries();
|
|
||||||
OverlayMenuEntry overlayMenuEntry = menuEntries.stream()
|
|
||||||
.filter(me -> me.getOption().equals(event.getMenuOption()))
|
|
||||||
.findAny()
|
|
||||||
.orElse(null);
|
|
||||||
if (overlayMenuEntry != null)
|
|
||||||
{
|
|
||||||
eventBus.post(new OverlayMenuClicked(overlayMenuEntry, overlay));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all of the overlays on a layer sorted by priority and position
|
* Gets all of the overlays on a layer sorted by priority and position
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.KeyCode;
|
import net.runelite.api.KeyCode;
|
||||||
import net.runelite.api.MenuEntry;
|
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.events.BeforeRender;
|
import net.runelite.api.events.BeforeRender;
|
||||||
import net.runelite.api.events.ClientTick;
|
import net.runelite.api.events.ClientTick;
|
||||||
@@ -60,6 +59,7 @@ import net.runelite.api.widgets.WidgetItem;
|
|||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.events.OverlayMenuClicked;
|
||||||
import net.runelite.client.input.KeyListener;
|
import net.runelite.client.input.KeyListener;
|
||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
import net.runelite.client.input.MouseAdapter;
|
import net.runelite.client.input.MouseAdapter;
|
||||||
@@ -86,10 +86,12 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
|||||||
private static final Color MOVING_OVERLAY_ACTIVE_COLOR = new Color(255, 255, 0, 200);
|
private static final Color MOVING_OVERLAY_ACTIVE_COLOR = new Color(255, 255, 0, 200);
|
||||||
private static final Color MOVING_OVERLAY_TARGET_COLOR = Color.RED;
|
private static final Color MOVING_OVERLAY_TARGET_COLOR = Color.RED;
|
||||||
private static final Color MOVING_OVERLAY_RESIZING_COLOR = new Color(255, 0, 255, 200);
|
private static final Color MOVING_OVERLAY_RESIZING_COLOR = new Color(255, 0, 255, 200);
|
||||||
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final OverlayManager overlayManager;
|
private final OverlayManager overlayManager;
|
||||||
private final RuneLiteConfig runeLiteConfig;
|
private final RuneLiteConfig runeLiteConfig;
|
||||||
private final ClientUI clientUI;
|
private final ClientUI clientUI;
|
||||||
|
private final EventBus eventBus;
|
||||||
|
|
||||||
// Overlay movement variables
|
// Overlay movement variables
|
||||||
private final Point overlayOffset = new Point();
|
private final Point overlayOffset = new Point();
|
||||||
@@ -101,7 +103,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
|||||||
private boolean inOverlayResizingMode;
|
private boolean inOverlayResizingMode;
|
||||||
private boolean inOverlayDraggingMode;
|
private boolean inOverlayDraggingMode;
|
||||||
private boolean startedMovingOverlay;
|
private boolean startedMovingOverlay;
|
||||||
private MenuEntry[] menuEntries;
|
private Overlay hoveredOverlay; // for building menu entries
|
||||||
|
|
||||||
// Overlay state validation
|
// Overlay state validation
|
||||||
private Rectangle viewportBounds;
|
private Rectangle viewportBounds;
|
||||||
@@ -124,6 +126,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
|||||||
this.overlayManager = overlayManager;
|
this.overlayManager = overlayManager;
|
||||||
this.runeLiteConfig = runeLiteConfig;
|
this.runeLiteConfig = runeLiteConfig;
|
||||||
this.clientUI = clientUI;
|
this.clientUI = clientUI;
|
||||||
|
this.eventBus = eventBus;
|
||||||
keyManager.registerKeyListener(this);
|
keyManager.registerKeyListener(this);
|
||||||
mouseManager.registerMouseListener(this);
|
mouseManager.registerMouseListener(this);
|
||||||
eventBus.register(this);
|
eventBus.register(this);
|
||||||
@@ -140,14 +143,15 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
|||||||
resetOverlayManagementMode();
|
resetOverlayManagementMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
menuEntries = null;
|
hoveredOverlay = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
protected void onClientTick(ClientTick t)
|
protected void onClientTick(ClientTick t)
|
||||||
{
|
{
|
||||||
if (menuEntries == null)
|
final Overlay overlay = hoveredOverlay;
|
||||||
|
if (overlay == null || client.isMenuOpen())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -158,24 +162,29 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.isMenuOpen())
|
List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries();
|
||||||
|
if (menuEntries.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] clientMenuEntries = client.getMenuEntries();
|
// Add in reverse order so they display correctly in the right-click menu
|
||||||
MenuEntry[] newEntries = new MenuEntry[clientMenuEntries.length + menuEntries.length];
|
for (int i = menuEntries.size() - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
OverlayMenuEntry overlayMenuEntry = menuEntries.get(i);
|
||||||
|
|
||||||
newEntries[0] = clientMenuEntries[0]; // Keep cancel at 0
|
client.createMenuEntry(-1)
|
||||||
System.arraycopy(menuEntries, 0, newEntries, 1, menuEntries.length); // Add overlay menu entries
|
.setOption(overlayMenuEntry.getOption())
|
||||||
System.arraycopy(clientMenuEntries, 1, newEntries, menuEntries.length + 1, clientMenuEntries.length - 1); // Add remaining menu entries
|
.setTarget(ColorUtil.wrapWithColorTag(overlayMenuEntry.getTarget(), JagexColors.MENU_TARGET))
|
||||||
client.setMenuEntries(newEntries);
|
.setType(overlayMenuEntry.getMenuAction())
|
||||||
|
.onClick(e -> eventBus.post(new OverlayMenuClicked(overlayMenuEntry, overlay)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onBeforeRender(BeforeRender event)
|
public void onBeforeRender(BeforeRender event)
|
||||||
{
|
{
|
||||||
menuEntries = null;
|
hoveredOverlay = null;
|
||||||
|
|
||||||
if (client.getGameState() == GameState.LOGGED_IN)
|
if (client.getGameState() == GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
@@ -349,11 +358,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
|||||||
|
|
||||||
if (!client.isMenuOpen() && !client.getSpellSelected() && bounds.contains(mouse))
|
if (!client.isMenuOpen() && !client.getSpellSelected() && bounds.contains(mouse))
|
||||||
{
|
{
|
||||||
if (menuEntries == null)
|
hoveredOverlay = overlay;
|
||||||
{
|
|
||||||
menuEntries = createRightClickMenuEntries(overlay);
|
|
||||||
}
|
|
||||||
|
|
||||||
overlay.onMouseOver();
|
overlay.onMouseOver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -902,33 +907,6 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
|||||||
new Rectangle(canvasTopRightPoint, SNAP_CORNER_SIZE));
|
new Rectangle(canvasTopRightPoint, SNAP_CORNER_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MenuEntry[] createRightClickMenuEntries(Overlay overlay)
|
|
||||||
{
|
|
||||||
List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries();
|
|
||||||
if (menuEntries.isEmpty())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final MenuEntry[] entries = new MenuEntry[menuEntries.size()];
|
|
||||||
|
|
||||||
// Add in reverse order so they display correctly in the right-click menu
|
|
||||||
for (int i = menuEntries.size() - 1; i >= 0; --i)
|
|
||||||
{
|
|
||||||
OverlayMenuEntry overlayMenuEntry = menuEntries.get(i);
|
|
||||||
|
|
||||||
final MenuEntry entry = new MenuEntry();
|
|
||||||
entry.setOption(overlayMenuEntry.getOption());
|
|
||||||
entry.setTarget(ColorUtil.wrapWithColorTag(overlayMenuEntry.getTarget(), JagexColors.MENU_TARGET));
|
|
||||||
entry.setType(overlayMenuEntry.getMenuAction().getId());
|
|
||||||
entry.setIdentifier(overlayManager.getOverlays().indexOf(overlay)); // overlay id
|
|
||||||
|
|
||||||
entries[i] = entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust the given overlay position to be within its parent's bounds.
|
* Adjust the given overlay position to be within its parent's bounds.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.ui.overlay.worldmap;
|
package net.runelite.client.ui.overlay.worldmap;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@@ -32,23 +33,18 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
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.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.RenderOverview;
|
import net.runelite.api.RenderOverview;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
|
||||||
import net.runelite.api.widgets.JavaScriptCallback;
|
import net.runelite.api.widgets.JavaScriptCallback;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetID;
|
import net.runelite.api.widgets.WidgetID;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.JagexColors;
|
import net.runelite.client.ui.JagexColors;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
@@ -73,7 +69,7 @@ public class WorldMapOverlay extends Overlay
|
|||||||
private final WorldMapPointManager worldMapPointManager;
|
private final WorldMapPointManager worldMapPointManager;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
|
|
||||||
private final List<MenuEntry> mapMenuEntries = new ArrayList<>();
|
private WorldMapPoint hoveredPoint;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private WorldMapOverlay(
|
private WorldMapOverlay(
|
||||||
@@ -107,19 +103,18 @@ public class WorldMapOverlay extends Overlay
|
|||||||
|
|
||||||
bottomBar.setOnTimerListener((JavaScriptCallback) ev ->
|
bottomBar.setOnTimerListener((JavaScriptCallback) ev ->
|
||||||
{
|
{
|
||||||
if (client.isMenuOpen() || mapMenuEntries.isEmpty())
|
WorldMapPoint worldPoint = hoveredPoint;
|
||||||
|
if (client.isMenuOpen() || worldPoint == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] entries = client.getMenuEntries();
|
client.createMenuEntry(-1)
|
||||||
int end = entries.length;
|
.setTarget(ColorUtil.wrapWithColorTag(worldPoint.getName(), JagexColors.MENU_TARGET))
|
||||||
entries = Arrays.copyOf(entries, end + mapMenuEntries.size());
|
.setOption(FOCUS_ON)
|
||||||
for (int i = 0; i < mapMenuEntries.size(); i++)
|
.setType(MenuAction.RUNELITE)
|
||||||
{
|
.onClick(m -> client.getRenderOverview().setWorldMapPositionTarget(
|
||||||
entries[end + i] = mapMenuEntries.get(i);
|
MoreObjects.firstNonNull(worldPoint.getTarget(), worldPoint.getWorldPoint())));
|
||||||
}
|
|
||||||
client.setMenuEntries(entries);
|
|
||||||
});
|
});
|
||||||
bottomBar.setHasListener(true);
|
bottomBar.setHasListener(true);
|
||||||
|
|
||||||
@@ -135,7 +130,7 @@ public class WorldMapOverlay extends Overlay
|
|||||||
mousePos = null;
|
mousePos = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapMenuEntries.clear();
|
hoveredPoint = null;
|
||||||
|
|
||||||
WorldMapPoint tooltipPoint = null;
|
WorldMapPoint tooltipPoint = null;
|
||||||
|
|
||||||
@@ -227,19 +222,7 @@ public class WorldMapOverlay extends Overlay
|
|||||||
if (worldPoint.isJumpOnClick())
|
if (worldPoint.isJumpOnClick())
|
||||||
{
|
{
|
||||||
assert worldPoint.getName() != null;
|
assert worldPoint.getName() != null;
|
||||||
|
hoveredPoint = worldPoint;
|
||||||
WorldPoint target = worldPoint.getTarget();
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
target = worldPoint.getWorldPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuEntry entry = new MenuEntry();
|
|
||||||
entry.setType(MenuAction.RUNELITE.getId());
|
|
||||||
entry.setOption(FOCUS_ON);
|
|
||||||
entry.setTarget(ColorUtil.wrapWithColorTag(worldPoint.getName(), JagexColors.MENU_TARGET));
|
|
||||||
entry.setIdentifier(target.getPlane() << 28 | target.getX() << 14 | target.getY());
|
|
||||||
mapMenuEntries.add(entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,21 +242,6 @@ public class WorldMapOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
private void onMenuOptionClicked(MenuOptionClicked ev)
|
|
||||||
{
|
|
||||||
if (ev.getMenuAction() == MenuAction.RUNELITE && FOCUS_ON.equals(ev.getMenuOption()))
|
|
||||||
{
|
|
||||||
int pxy = ev.getId();
|
|
||||||
WorldPoint wp = new WorldPoint(
|
|
||||||
pxy >> 14 & 0x3fff,
|
|
||||||
pxy & 0x3fff,
|
|
||||||
pxy >> 28);
|
|
||||||
|
|
||||||
client.getRenderOverview().setWorldMapPositionTarget(wp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the screen coordinates for a WorldPoint on the world map
|
* Get the screen coordinates for a WorldPoint on the world map
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.menus;
|
package net.runelite.client.menus;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.testing.fieldbinder.Bind;
|
import com.google.inject.testing.fieldbinder.Bind;
|
||||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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;
|
||||||
@@ -38,24 +41,18 @@ import static net.runelite.api.widgets.WidgetInfo.MINIMAP_WORLDMAP_OPTIONS;
|
|||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import org.mockito.ArgumentMatchers;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class MenuManagerTest
|
public class MenuManagerTest
|
||||||
{
|
{
|
||||||
private static final MenuEntry CANCEL = new MenuEntry();
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private MenuManager menuManager;
|
private MenuManager menuManager;
|
||||||
|
|
||||||
@@ -63,14 +60,18 @@ public class MenuManagerTest
|
|||||||
@Bind
|
@Bind
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
private MenuEntry[] clientMenuEntries = {CANCEL};
|
private final MenuEntry CANCEL = createMenuEntry("Cancel", "", MenuAction.CANCEL, MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
||||||
|
|
||||||
@BeforeClass
|
private final List<MenuEntry> createdMenuEntries = new ArrayList<>();
|
||||||
public static void beforeClass()
|
|
||||||
|
private static MenuEntry createMenuEntry(String option, String target, MenuAction type, int param1)
|
||||||
{
|
{
|
||||||
CANCEL.setOption("Cancel");
|
MenuEntry menuEntry = new TestMenuEntry();
|
||||||
CANCEL.setType(MenuAction.CANCEL.getId());
|
menuEntry.setOption(option);
|
||||||
CANCEL.setParam1(MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
menuEntry.setTarget(target);
|
||||||
|
menuEntry.setType(type);
|
||||||
|
menuEntry.setParam1(param1);
|
||||||
|
return menuEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -78,35 +79,25 @@ public class MenuManagerTest
|
|||||||
{
|
{
|
||||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||||
|
|
||||||
doAnswer((Answer<Void>) invocationOnMock ->
|
when(client.createMenuEntry(anyInt()))
|
||||||
|
.thenAnswer(a ->
|
||||||
{
|
{
|
||||||
clientMenuEntries = invocationOnMock.getArgument(0, MenuEntry[].class);
|
MenuEntry e = new TestMenuEntry();
|
||||||
return null;
|
createdMenuEntries.add(e);
|
||||||
}).when(client).setMenuEntries(ArgumentMatchers.any(MenuEntry[].class));
|
return e;
|
||||||
when(client.getMenuEntries()).thenAnswer((Answer<MenuEntry[]>) invocationMock -> clientMenuEntries);
|
});
|
||||||
|
when(client.getMenuEntries()).thenReturn(new MenuEntry[]{CANCEL});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testManagedMenuOrder()
|
public void testManagedMenuOrder()
|
||||||
{
|
{
|
||||||
final MenuEntry first = new MenuEntry();
|
final MenuEntry first = createMenuEntry("Test", "First Entry", RUNELITE, MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
||||||
final MenuEntry second = new MenuEntry();
|
final MenuEntry second = createMenuEntry("Test", "Second Entry", RUNELITE, MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
||||||
final MenuEntry third = new MenuEntry();
|
final MenuEntry third = createMenuEntry("Test", "Third Entry", RUNELITE, MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
||||||
first.setOption("Test");
|
menuManager.addManagedCustomMenu(new WidgetMenuOption(first.getOption(), first.getTarget(), MINIMAP_WORLDMAP_OPTIONS), null);
|
||||||
first.setTarget("First Entry");
|
menuManager.addManagedCustomMenu(new WidgetMenuOption(second.getOption(), second.getTarget(), MINIMAP_WORLDMAP_OPTIONS), null);
|
||||||
first.setParam1(MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
menuManager.addManagedCustomMenu(new WidgetMenuOption(third.getOption(), third.getTarget(), MINIMAP_WORLDMAP_OPTIONS), null);
|
||||||
first.setType(RUNELITE.getId());
|
|
||||||
second.setOption("Test");
|
|
||||||
second.setTarget("Second Entry");
|
|
||||||
second.setParam1(MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
|
||||||
second.setType(RUNELITE.getId());
|
|
||||||
third.setOption("Test");
|
|
||||||
third.setTarget("Third Entry");
|
|
||||||
third.setParam1(MINIMAP_WORLDMAP_OPTIONS.getPackedId());
|
|
||||||
third.setType(RUNELITE.getId());
|
|
||||||
menuManager.addManagedCustomMenu(new WidgetMenuOption(first.getOption(), first.getTarget(), MINIMAP_WORLDMAP_OPTIONS));
|
|
||||||
menuManager.addManagedCustomMenu(new WidgetMenuOption(second.getOption(), second.getTarget(), MINIMAP_WORLDMAP_OPTIONS));
|
|
||||||
menuManager.addManagedCustomMenu(new WidgetMenuOption(third.getOption(), third.getTarget(), MINIMAP_WORLDMAP_OPTIONS));
|
|
||||||
|
|
||||||
menuManager.onMenuEntryAdded(new MenuEntryAdded(
|
menuManager.onMenuEntryAdded(new MenuEntryAdded(
|
||||||
CANCEL.getOption(),
|
CANCEL.getOption(),
|
||||||
@@ -116,12 +107,10 @@ public class MenuManagerTest
|
|||||||
CANCEL.getParam0(),
|
CANCEL.getParam0(),
|
||||||
CANCEL.getParam1()));
|
CANCEL.getParam1()));
|
||||||
|
|
||||||
ArgumentCaptor<MenuEntry[]> captor = ArgumentCaptor.forClass(MenuEntry[].class);
|
verify(client, times(3)).createMenuEntry(anyInt());
|
||||||
verify(client, atLeastOnce()).setMenuEntries(captor.capture());
|
|
||||||
|
|
||||||
final MenuEntry[] resultMenuEntries = captor.getValue();
|
|
||||||
// Strip color tags from menu options before array comparison
|
// Strip color tags from menu options before array comparison
|
||||||
for (MenuEntry resultEntry : resultMenuEntries)
|
for (MenuEntry resultEntry : createdMenuEntries)
|
||||||
{
|
{
|
||||||
final String resultTarget = resultEntry.getTarget();
|
final String resultTarget = resultEntry.getTarget();
|
||||||
if (resultTarget != null)
|
if (resultTarget != null)
|
||||||
@@ -130,6 +119,7 @@ public class MenuManagerTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assertArrayEquals(new MenuEntry[]{CANCEL, third, second, first}, resultMenuEntries);
|
assertArrayEquals(new MenuEntry[]{third, second, first},
|
||||||
|
Lists.reverse(createdMenuEntries).toArray(new MenuEntry[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Adam <Adam@sigterm.info>
|
||||||
|
* 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.menus;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import net.runelite.api.MenuAction;
|
||||||
|
import net.runelite.api.MenuEntry;
|
||||||
|
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class TestMenuEntry implements MenuEntry
|
||||||
|
{
|
||||||
|
private String option;
|
||||||
|
private String target;
|
||||||
|
private int identifier;
|
||||||
|
private int type;
|
||||||
|
private int param0;
|
||||||
|
private int param1;
|
||||||
|
private boolean forceLeftClick;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOption()
|
||||||
|
{
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry setOption(String option)
|
||||||
|
{
|
||||||
|
this.option = option;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTarget()
|
||||||
|
{
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry setTarget(String target)
|
||||||
|
{
|
||||||
|
this.target = target;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIdentifier()
|
||||||
|
{
|
||||||
|
return this.identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry setIdentifier(int identifier)
|
||||||
|
{
|
||||||
|
this.identifier = identifier;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuAction getType()
|
||||||
|
{
|
||||||
|
return MenuAction.of(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry setType(MenuAction type)
|
||||||
|
{
|
||||||
|
this.type = type.getId();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getParam0()
|
||||||
|
{
|
||||||
|
return this.param0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry setParam0(int param0)
|
||||||
|
{
|
||||||
|
this.param0 = param0;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getParam1()
|
||||||
|
{
|
||||||
|
return this.param1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry setParam1(int param1)
|
||||||
|
{
|
||||||
|
this.param1 = param1;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isForceLeftClick()
|
||||||
|
{
|
||||||
|
return this.forceLeftClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry setForceLeftClick(boolean forceLeftClick)
|
||||||
|
{
|
||||||
|
this.forceLeftClick = forceLeftClick;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDeprioritized()
|
||||||
|
{
|
||||||
|
return type >= MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDeprioritized(boolean deprioritized)
|
||||||
|
{
|
||||||
|
if (deprioritized)
|
||||||
|
{
|
||||||
|
if (type < MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET)
|
||||||
|
{
|
||||||
|
type += MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (type >= MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET)
|
||||||
|
{
|
||||||
|
type -= MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuEntry onClick(Consumer<MenuEntry> callback)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ import com.google.inject.Guice;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.testing.fieldbinder.Bind;
|
import com.google.inject.testing.fieldbinder.Bind;
|
||||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||||
|
import java.util.Arrays;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.KeyCode;
|
import net.runelite.api.KeyCode;
|
||||||
@@ -37,6 +38,7 @@ import net.runelite.api.events.ClientTick;
|
|||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
|
import net.runelite.client.menus.TestMenuEntry;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -88,9 +90,7 @@ public class MenuEntrySwapperPluginTest
|
|||||||
{
|
{
|
||||||
// The menu implementation returns a copy of the array, which causes swap() to not
|
// The menu implementation returns a copy of the array, which causes swap() to not
|
||||||
// modify the same array being iterated in onClientTick
|
// modify the same array being iterated in onClientTick
|
||||||
MenuEntry[] copy = new MenuEntry[entries.length];
|
return Arrays.copyOf(entries, entries.length);
|
||||||
System.arraycopy(entries, 0, copy, 0, entries.length);
|
|
||||||
return copy;
|
|
||||||
});
|
});
|
||||||
doAnswer((Answer<Void>) invocationOnMock ->
|
doAnswer((Answer<Void>) invocationOnMock ->
|
||||||
{
|
{
|
||||||
@@ -109,10 +109,10 @@ public class MenuEntrySwapperPluginTest
|
|||||||
|
|
||||||
private static MenuEntry menu(String option, String target, MenuAction menuAction, int identifier)
|
private static MenuEntry menu(String option, String target, MenuAction menuAction, int identifier)
|
||||||
{
|
{
|
||||||
MenuEntry menuEntry = new MenuEntry();
|
MenuEntry menuEntry = new TestMenuEntry();
|
||||||
menuEntry.setOption(option);
|
menuEntry.setOption(option);
|
||||||
menuEntry.setTarget(target);
|
menuEntry.setTarget(target);
|
||||||
menuEntry.setType(menuAction.getId());
|
menuEntry.setType(menuAction);
|
||||||
menuEntry.setIdentifier(identifier);
|
menuEntry.setIdentifier(identifier);
|
||||||
return menuEntry;
|
return menuEntry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ 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;
|
||||||
import net.runelite.api.events.NpcSpawned;
|
import net.runelite.api.events.NpcSpawned;
|
||||||
|
import net.runelite.client.menus.TestMenuEntry;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -48,7 +49,6 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
@@ -109,13 +109,12 @@ public class NpcIndicatorsPluginTest
|
|||||||
|
|
||||||
when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0
|
when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0
|
||||||
|
|
||||||
when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()});
|
MenuEntry entry = new TestMenuEntry();
|
||||||
|
when(client.getMenuEntries()).thenReturn(new MenuEntry[]{entry});
|
||||||
MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
|
MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
|
||||||
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
||||||
|
|
||||||
MenuEntry target = new MenuEntry();
|
assertEquals("<col=ff0000>Goblin", entry.getTarget()); // red
|
||||||
target.setTarget("<col=ff0000>Goblin"); // red
|
|
||||||
verify(client).setMenuEntries(new MenuEntry[]{target});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -133,13 +132,12 @@ public class NpcIndicatorsPluginTest
|
|||||||
|
|
||||||
when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0
|
when(client.getCachedNPCs()).thenReturn(new NPC[]{npc}); // id 0
|
||||||
|
|
||||||
when(client.getMenuEntries()).thenReturn(new MenuEntry[]{new MenuEntry()});
|
MenuEntry entry = new TestMenuEntry();
|
||||||
|
when(client.getMenuEntries()).thenReturn(new MenuEntry[]{entry});
|
||||||
MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
|
MenuEntryAdded menuEntryAdded = new MenuEntryAdded("", "Goblin", MenuAction.NPC_FIRST_OPTION.getId(), 0, -1, -1);
|
||||||
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
npcIndicatorsPlugin.onMenuEntryAdded(menuEntryAdded);
|
||||||
|
|
||||||
MenuEntry target = new MenuEntry();
|
assertEquals("<col=0000ff>Goblin", entry.getTarget()); // blue
|
||||||
target.setTarget("<col=0000ff>Goblin"); // blue
|
|
||||||
verify(client).setMenuEntries(new MenuEntry[]{target});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user