wiki: Always include item names in widget optarget lookups
Normally the client includes Widget::name in the target param, but for widgets that don't normally have menu entries this is often empty so the lookup string would just be `Lookup `
This commit is contained in:
@@ -47,6 +47,7 @@ import net.runelite.api.widgets.WidgetTextAlignment;
|
||||
import net.runelite.api.widgets.WidgetType;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.JagexColors;
|
||||
|
||||
@Singleton
|
||||
public class ChatboxItemSearch extends ChatboxTextInput
|
||||
@@ -141,7 +142,7 @@ public class ChatboxItemSearch extends ChatboxTextInput
|
||||
item.setOriginalY(y + FONT_SIZE * 2);
|
||||
item.setOriginalHeight(ICON_HEIGHT);
|
||||
item.setOriginalWidth(ICON_WIDTH);
|
||||
item.setName("<col=ff9040>" + itemComposition.getName());
|
||||
item.setName(JagexColors.MENU_TARGET_TAG + itemComposition.getName());
|
||||
item.setItemId(itemComposition.getId());
|
||||
item.setItemQuantity(10000);
|
||||
item.setItemQuantityMode(ItemQuantityMode.NEVER);
|
||||
|
||||
@@ -58,6 +58,7 @@ import net.runelite.client.game.SpriteManager;
|
||||
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.JagexColors;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
import net.runelite.client.util.Text;
|
||||
import okhttp3.HttpUrl;
|
||||
@@ -370,7 +371,22 @@ public class WikiPlugin extends Plugin
|
||||
if (wikiSelected && event.getType() == MenuAction.SPELL_CAST_ON_WIDGET.getId())
|
||||
{
|
||||
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--)
|
||||
{
|
||||
MenuEntry entry = menuEntries[ourEntry];
|
||||
if (entry.getType() == MenuAction.SPELL_CAST_ON_WIDGET.getId())
|
||||
{
|
||||
int id = itemManager.canonicalize(w.getItemId());
|
||||
String name = itemManager.getItemComposition(id).getName();
|
||||
entry.setTarget(JagexColors.MENU_TARGET_TAG + name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
client.setMenuEntries(menuEntries);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't support this widget
|
||||
// remove the last SPELL_CAST_ON_WIDGET; we can't blindly remove the top action because some other
|
||||
|
||||
@@ -48,6 +48,7 @@ import net.runelite.api.widgets.WidgetType;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
||||
import net.runelite.client.game.chatbox.ChatboxTextInput;
|
||||
import net.runelite.client.ui.JagexColors;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
@@ -221,7 +222,7 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput
|
||||
bg.setOriginalWidth(16);
|
||||
bg.setWidthMode(WidgetSizeMode.MINUS);
|
||||
bg.revalidate();
|
||||
bg.setName("<col=ff9040>" + pred);
|
||||
bg.setName(JagexColors.MENU_TARGET_TAG + pred);
|
||||
bg.setAction(0, "Open");
|
||||
bg.setHasListener(true);
|
||||
bg.setOnOpListener((JavaScriptCallback) ev -> search(pred));
|
||||
|
||||
@@ -54,7 +54,8 @@ public class JagexColors
|
||||
/*
|
||||
* Colors relating to right-click menus.
|
||||
*/
|
||||
public static final Color MENU_TARGET = new Color(255, 144, 64);
|
||||
public static final Color MENU_TARGET = new Color(0xFF9040);
|
||||
public static final String MENU_TARGET_TAG = "<col=ff9040>";
|
||||
|
||||
/*
|
||||
* Colors relating to tooltips.
|
||||
|
||||
Reference in New Issue
Block a user