Skip to content

Commit

Permalink
wiki: Use jagex's sprite, but hide their wiki banner
Browse files Browse the repository at this point in the history
Ours has more functionality (lookuping items in interfaces, and a
predictive search interface)
  • Loading branch information
abextm committed Jan 23, 2020
1 parent 2b077f4 commit 32c8c49
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 52 deletions.
2 changes: 2 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/SpriteID.java
Original file line number Diff line number Diff line change
Expand Up @@ -1589,4 +1589,6 @@ public final class SpriteID
public static final int HEALTHBAR_DEFAULT_BACK_140PX = 2189;
public static final int HEALTHBAR_DEFAULT_FRONT_160PX = 2190;
public static final int HEALTHBAR_DEFAULT_BACK_160PX = 2191;
public static final int WIKI_DESELECTED = 2420;
public static final int WIKI_SELECTED = 2421;
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ static class Minimap
static final int RUN_ORB_TEXT = 23;
static final int SPEC_ORB = 28;
static final int WORLDMAP_ORB = 41;
static final int WIKI_BANNER = 43;
}

static class LoginClickToPlayScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public enum WidgetInfo
MINIMAP_HEALTH_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.HEALTH_ORB),
MINIMAP_SPEC_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.SPEC_ORB),
MINIMAP_WORLDMAP_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB),
MINIMAP_WIKI_BANNER(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WIKI_BANNER),

LOGIN_CLICK_TO_PLAY_SCREEN(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, 0),
LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, WidgetID.LoginClickToPlayScreen.MESSAGE_OF_THE_DAY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
import net.runelite.api.NPC;
import net.runelite.api.NPCComposition;
import net.runelite.api.ObjectComposition;
import net.runelite.api.SpriteID;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.WidgetHiddenChanged;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.JavaScriptCallback;
import net.runelite.api.widgets.Widget;
Expand Down Expand Up @@ -105,14 +107,12 @@ public class WikiPlugin extends Plugin
@Override
public void startUp()
{
spriteManager.addSpriteOverrides(WikiSprite.values());
clientThread.invokeLater(this::addWidgets);
}

@Override
public void shutDown()
{
spriteManager.removeSpriteOverrides(WikiSprite.values());
clientThread.invokeLater(() ->
{
Widget minimapOrbs = client.getWidget(WidgetInfo.MINIMAP_ORBS);
Expand All @@ -127,6 +127,12 @@ public void shutDown()
}
children[0] = null;

Widget vanilla = client.getWidget(WidgetInfo.MINIMAP_WIKI_BANNER);
if (vanilla != null)
{
vanilla.setHidden(false);
}

onDeselect();
client.setSpellSelected(false);
});
Expand All @@ -149,14 +155,20 @@ private void addWidgets()
return;
}

Widget vanilla = client.getWidget(WidgetInfo.MINIMAP_WIKI_BANNER);
if (vanilla != null)
{
vanilla.setHidden(true);
}

icon = minimapOrbs.createChild(0, WidgetType.GRAPHIC);
icon.setSpriteId(WikiSprite.WIKI_ICON.getSpriteId());
icon.setSpriteId(SpriteID.WIKI_DESELECTED);
icon.setOriginalX(0);
icon.setOriginalY(2);
icon.setOriginalY(0);
icon.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
icon.setYPositionMode(WidgetPositionMode.ABSOLUTE_BOTTOM);
icon.setOriginalWidth(42);
icon.setOriginalHeight(16);
icon.setOriginalWidth(40);
icon.setOriginalHeight(14);
icon.setTargetVerb("Lookup");
icon.setName("Wiki");
icon.setClickMask(WidgetConfig.USE_GROUND_ITEM | WidgetConfig.USE_ITEM | WidgetConfig.USE_NPC
Expand All @@ -165,7 +177,7 @@ private void addWidgets()
icon.setOnTargetEnterListener((JavaScriptCallback) ev ->
{
wikiSelected = true;
icon.setSpriteId(WikiSprite.WIKI_SELECTED_ICON.getSpriteId());
icon.setSpriteId(SpriteID.WIKI_SELECTED);
client.setAllWidgetsAreOpTargetable(true);
});
icon.setAction(5, "Search"); // Start at option 5 so the target op is ontop
Expand All @@ -183,14 +195,23 @@ private void addWidgets()
icon.revalidate();
}

@Subscribe
private void onWidgetHiddenChanged(WidgetHiddenChanged ev)
{
if (ev.getWidget().getId() == WidgetInfo.MINIMAP_WIKI_BANNER.getId())
{
ev.getWidget().setHidden(true);
}
}

private void onDeselect()
{
client.setAllWidgetsAreOpTargetable(false);

wikiSelected = false;
if (icon != null)
{
icon.setSpriteId(WikiSprite.WIKI_ICON.getSpriteId());
icon.setSpriteId(SpriteID.WIKI_DESELECTED);
}
}

Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 32c8c49

Please sign in to comment.