wiki plugin: Add skill guide lookup
Signed-off-by: Will Thomas <github@willthoms.org.uk>
This commit is contained in:
@@ -126,6 +126,7 @@ public class WidgetID
|
|||||||
public static final int ENTERING_HOUSE_GROUP_ID = 71;
|
public static final int ENTERING_HOUSE_GROUP_ID = 71;
|
||||||
public static final int FULLSCREEN_MAP_GROUP_ID = 165;
|
public static final int FULLSCREEN_MAP_GROUP_ID = 165;
|
||||||
public static final int QUESTLIST_GROUP_ID = 399;
|
public static final int QUESTLIST_GROUP_ID = 399;
|
||||||
|
public static final int SKILLS_GROUP_ID = 320;
|
||||||
|
|
||||||
static class WorldMap
|
static class WorldMap
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ package net.runelite.client.plugins.wiki;
|
|||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -79,6 +81,9 @@ public class WikiPlugin extends Plugin
|
|||||||
|
|
||||||
private static final String MENUOP_GUIDE = "Guide";
|
private static final String MENUOP_GUIDE = "Guide";
|
||||||
private static final String MENUOP_QUICKGUIDE = "Quick Guide";
|
private static final String MENUOP_QUICKGUIDE = "Quick Guide";
|
||||||
|
private static final String MENUOP_WIKI_SKILL = "Wiki";
|
||||||
|
|
||||||
|
private static final Pattern SKILL_REGEX = Pattern.compile("([A-Za-z]+) guide");
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SpriteManager spriteManager;
|
private SpriteManager spriteManager;
|
||||||
@@ -246,6 +251,13 @@ public class WikiPlugin extends Plugin
|
|||||||
String quest = Text.removeTags(ev.getMenuTarget());
|
String quest = Text.removeTags(ev.getMenuTarget());
|
||||||
LinkBrowser.browse(WIKI_BASE + "/w/" + URLEncoder.encode(quest.replace(' ', '_')) + quickguide + "?" + UTM_PARAMS);
|
LinkBrowser.browse(WIKI_BASE + "/w/" + URLEncoder.encode(quest.replace(' ', '_')) + quickguide + "?" + UTM_PARAMS);
|
||||||
break;
|
break;
|
||||||
|
case MENUOP_WIKI_SKILL:
|
||||||
|
Matcher skillRegex = WikiPlugin.SKILL_REGEX.matcher(Text.removeTags(ev.getMenuTarget()));
|
||||||
|
|
||||||
|
if (skillRegex.find())
|
||||||
|
{
|
||||||
|
LinkBrowser.browse(WIKI_BASE + "/w/" + URLEncoder.encode(skillRegex.group(1)) + "?" + UTM_PARAMS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,29 +273,42 @@ 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 (!Ints.contains(QUESTLIST_WIDGET_IDS, widgetID) || !"Read Journal:".equals(event.getOption()))
|
if (Ints.contains(QUESTLIST_WIDGET_IDS, widgetID) && "Read Journal:".equals(event.getOption()))
|
||||||
{
|
{
|
||||||
return;
|
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 2);
|
||||||
|
|
||||||
|
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
||||||
|
menuEntry.setTarget(event.getTarget());
|
||||||
|
menuEntry.setOption(MENUOP_GUIDE);
|
||||||
|
menuEntry.setParam0(widgetIndex);
|
||||||
|
menuEntry.setParam1(widgetID);
|
||||||
|
menuEntry.setType(MenuAction.RUNELITE.getId());
|
||||||
|
|
||||||
|
menuEntry = menuEntries[menuEntries.length - 2] = new MenuEntry();
|
||||||
|
menuEntry.setTarget(event.getTarget());
|
||||||
|
menuEntry.setOption(MENUOP_QUICKGUIDE);
|
||||||
|
menuEntry.setParam0(widgetIndex);
|
||||||
|
menuEntry.setParam1(widgetID);
|
||||||
|
menuEntry.setType(MenuAction.RUNELITE.getId());
|
||||||
|
|
||||||
|
client.setMenuEntries(menuEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
if ((WidgetInfo.TO_GROUP(widgetID) == WidgetID.SKILLS_GROUP_ID) && event.getOption().startsWith("View"))
|
||||||
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 2);
|
{
|
||||||
|
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
||||||
|
|
||||||
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
||||||
menuEntry.setTarget(event.getTarget());
|
menuEntry.setTarget(event.getOption().replace("View ", ""));
|
||||||
menuEntry.setOption(MENUOP_GUIDE);
|
menuEntry.setOption(MENUOP_WIKI_SKILL);
|
||||||
menuEntry.setParam0(widgetIndex);
|
menuEntry.setParam0(widgetIndex);
|
||||||
menuEntry.setParam1(widgetID);
|
menuEntry.setParam1(widgetID);
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
menuEntry.setIdentifier(event.getIdentifier());
|
||||||
|
menuEntry.setType(MenuAction.RUNELITE.getId());
|
||||||
|
|
||||||
menuEntry = menuEntries[menuEntries.length - 2] = new MenuEntry();
|
client.setMenuEntries(menuEntries);
|
||||||
menuEntry.setTarget(event.getTarget());
|
}
|
||||||
menuEntry.setOption(MENUOP_QUICKGUIDE);
|
|
||||||
menuEntry.setParam0(widgetIndex);
|
|
||||||
menuEntry.setParam1(widgetID);
|
|
||||||
menuEntry.setType(MenuAction.RUNELITE.getId());
|
|
||||||
|
|
||||||
client.setMenuEntries(menuEntries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user