From 32c8c497bda4c7256b86705df93c7c1ee11e18ae Mon Sep 17 00:00:00 2001 From: Max Weber Date: Thu, 23 Jan 2020 04:58:17 -0700 Subject: [PATCH] wiki: Use jagex's sprite, but hide their wiki banner Ours has more functionality (lookuping items in interfaces, and a predictive search interface) --- .../main/java/net/runelite/api/SpriteID.java | 2 + .../net/runelite/api/widgets/WidgetID.java | 1 + .../net/runelite/api/widgets/WidgetInfo.java | 1 + .../client/plugins/wiki/WikiPlugin.java | 37 +++++++++++---- .../client/plugins/wiki/WikiSprite.java | 44 ------------------ .../wiki/fixed_mode_minimap_clickmask.png | Bin 654 -> 0 bytes .../net/runelite/client/plugins/wiki/wiki.png | Bin 3092 -> 0 bytes .../client/plugins/wiki/wiki_selected.png | Bin 3025 -> 0 bytes 8 files changed, 33 insertions(+), 52 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java delete mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/wiki/fixed_mode_minimap_clickmask.png delete mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/wiki/wiki.png delete mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/wiki/wiki_selected.png diff --git a/runelite-api/src/main/java/net/runelite/api/SpriteID.java b/runelite-api/src/main/java/net/runelite/api/SpriteID.java index 962089c146..8e4373ba71 100644 --- a/runelite-api/src/main/java/net/runelite/api/SpriteID.java +++ b/runelite-api/src/main/java/net/runelite/api/SpriteID.java @@ -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; } diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index d155904e7b..a97f9b7124 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -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 diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index a1354618f8..770895b1ed 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -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), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java index e135b1eefa..9458d5077f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java @@ -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; @@ -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); @@ -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); }); @@ -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 @@ -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 @@ -183,6 +195,15 @@ 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); @@ -190,7 +211,7 @@ private void onDeselect() wikiSelected = false; if (icon != null) { - icon.setSpriteId(WikiSprite.WIKI_ICON.getSpriteId()); + icon.setSpriteId(SpriteID.WIKI_DESELECTED); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java deleted file mode 100644 index 188d54837b..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018 Abex - * 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.plugins.wiki; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import net.runelite.api.SpriteID; -import net.runelite.client.game.SpriteOverride; - -@RequiredArgsConstructor -public enum WikiSprite implements SpriteOverride -{ - WIKI_ICON(-300, "wiki.png"), - WIKI_SELECTED_ICON(-301, "wiki_selected.png"), - FIXED_MODE_MINIMAP_CLICKMASK(SpriteID.MINIMAP_CLICK_MASK, "fixed_mode_minimap_clickmask.png"); - - @Getter - private final int spriteId; - - @Getter - private final String fileName; -} diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/wiki/fixed_mode_minimap_clickmask.png b/runelite-client/src/main/resources/net/runelite/client/plugins/wiki/fixed_mode_minimap_clickmask.png deleted file mode 100644 index ba5a23c151ace7ac3e7ae774066ffc82b91c66ea..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 654 zcmeAS@N?(olHy`uVBq!ia0vp^lYn>z2OE&&f3V>NkYY)9^mSxl*x1kgCy^D%=PdAu zEM{QfI|Ravq8eTeKtYKT*NBqf{Irtt#G+J&g2c?c61}|C5(N`ILp{?J_XwcLOgx@0 zjv*CsZ*My0-F6URb^QIWy)1!+No13$if&`FVW@+C+TZ(mc0jP-%3_II33u6Q#=A{- zvmCx3)H9v;J7K!id7~R4ha=f$XIY5yT+PsuSamVPAY}2%gcWYV2LpPSH7%6#Wpy^4 z#nqN&f~)|n<8(qW?{m8wOOF-HzX^K0lXdsihJDS>Jsr~xRN@XbRB$RY0lh&CXn0;* z_m_8Gk@O_Tk5isb$UCTLx+r=>H17+L;hTBPt`>kCX2T`7>L8ftX$nb}WLp@(!^3o1;Djul z{-*XUgZ^K~zgLU=pDyJyHTkCW_3*`!(;oluj0xv`zE9?eaiOp2ylBgo@FQQZH0(Rg zxW{PS(=Uv7kC)D|o0l5nBK!T#js~kYHwzg{Z%BT8_G*RkqqA27(~rzvz4%<0c^La# z(fl=hR@(O>WJ|()HvYN$!?X56q@gSC;|$!iq@gcJ{t7z1IeC@Tv5UVpq#qA4?OFUa z@qEwAED875kLQW*cLHg6VEpL%ibR>0pI`G&jEwnsHTL)xP>6fF`njxgN@xNAE|mj6 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/wiki/wiki.png b/runelite-client/src/main/resources/net/runelite/client/plugins/wiki/wiki.png deleted file mode 100644 index ef2ff20ff0d56badacfabd605f90a2e8a4ad39e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3092 zcmcIm30Mxa46!9fH5jwbZ(M#Btkgk&>#X1u*ym&-64S_9g}c79tem!A~?W! zAjb%ZhzR0=g5tylWx-)p@L&`L2R$(tFF7>xB1fP?y6U>-v9rvsTTJDfup=4E5gnr0FKKMYX?a|m3`gm_<` z2i^fyAb4vc0}xQ?R6G+TQW#{AO1HvO$rL7u%p_500GYxjGuSi`Kl&kHvngO9+tYE? z=v>$vhagg^(z38RcpB^RM8R4GC~ z5yyDAr-O7r>AT`Zw?}l5NfS7cdHog%Mu@< zF`gf`Kqw&dLAnqCK?)OK3g|EZ(wJDNLK>4V#(!a$rzE1_PiHDH_vbGO%!6#7eBf5u?k<3)wvS zBoX6>y~&0InkB&@2sB*L1UuN}Bg!1Rb_utpxDMDtoDGuCpPlZup~<7se%m+e8nt*y6Q(}P zBF7U~wxvF?k1-6{+r9geVO&6cz=ac%pfu%9otd-p4g&gy$J~>Oq1u4CRe8qu<1>?o ze)?%jY<$BU|1*`g?%Uei!XoS1o1%XCeJ~Ao^*K^>Xx_?$Ss*;=j z7bDNO$7Z4gPn}za^R6Guhy~p16ZON^KJ*-_Nu%weh|DTl6|(dhuz+(@Ou=;Qr*TR=!CWpY+(hpR(z$Byu1KUv+d4UV9vA zkGi~0mR(n^47{Kndp9B56Wl|8sUyuD9Xp-tqz7uAYqbWWSzMiiwUKhE=c_!v=%rvxZGS3Jm6_;M>1BQ@$q!dJsvmNqVU13W34*&g>E{#e{2Cg zqNhEPuQjvFaVL5dY{TUTD!U?Q&Yh_j>ycb=e8}7Xf^v0ODpxt_>emCCLlCCU;p6e| zy|#P#cLoJtiEQfUWtYr7s8(C<(k)CY+EUbaJ2v4Cu8R%l&b2 z)!N@fg0-UqlA;ezIviurSQ^=vt=(Y-yV>Cu_EJxn$Z@Uwj$8emleeGHUToW6R8ri0 z)i37Jw$9Sl0nuU~y&r!+diOi&&I%QMYWQ2X1lztBb?v4VEZ=(}d7<~5YD>z_6ue!$ z?c18fnyzV2E10UIV8ahjC#mft9@_lF=3z6-@W<)7(-mO}MwNne(>j1yzun~Ng2MFh^xsmZqs0_f_! zlOO2!?KE%gt=n<9cZ*(Nf1~OChKv(SZkPu^UFQ#^yh~Yhvan`dsLHp-=-dioPdX~~ zI}FdJ?f%=Hs0#(J9+e>uo6h)347jCeMZe)JtthMYDYn9;Ez;Z~`3+0G6*))hH`hgX zdZ?e75pQ$2&a2%gzno6*bWG6`$HNLXlnml-<>0QQF&Sk?MCOO+nvaq&$ujYTdtCPE9p?yH~ALf0np8x;= diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/wiki/wiki_selected.png b/runelite-client/src/main/resources/net/runelite/client/plugins/wiki/wiki_selected.png deleted file mode 100644 index 80838fb5c4f5f4406f0570212fb7e9825664b7ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3025 zcmcIm3s@6Z8V#VxLoA?(unHkytCq=|yh;>EKq5pbusp;ElbHzwl1#`1608)#7b=1l z7b>(A5d|Mu1XNg-mx9=86(4AqsuZo7x+se%MHJi#uXVfXy8C^bFO!+M_uO;O`Tzgk zn{7eMms(jkS`Y{XE0Mo27{4#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