Centralize setting of hint arrows for clues

- Add new LocationClueScroll interface that will mark location-based
clues
- Move setting of the hint arrows to ClueScrollPlugin
- Properly prioritize hint arrows (always try location first, but then
override with NPC/object locations)

Closes #1609

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-04-13 16:43:24 +02:00
parent 33ece1071b
commit d5dacf9966
9 changed files with 65 additions and 54 deletions

View File

@@ -65,6 +65,7 @@ import net.runelite.client.plugins.cluescrolls.clues.CoordinateClue;
import net.runelite.client.plugins.cluescrolls.clues.CrypticClue;
import net.runelite.client.plugins.cluescrolls.clues.EmoteClue;
import net.runelite.client.plugins.cluescrolls.clues.FairyRingClue;
import net.runelite.client.plugins.cluescrolls.clues.LocationClueScroll;
import net.runelite.client.plugins.cluescrolls.clues.MapClue;
import net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll;
import net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll;
@@ -133,8 +134,7 @@ public class ClueScrollPlugin extends Plugin
return;
}
client.clearHintArrow();
clue = null;
resetClue();
}
@Subscribe
@@ -182,6 +182,18 @@ public class ClueScrollPlugin extends Plugin
objectsToMark = null;
equippedItems = null;
// If we have location clue, set world location before all other types of clues
// to allow NPCs and objects to override it when needed
if (clue instanceof LocationClueScroll)
{
final WorldPoint location = ((LocationClueScroll) clue).getLocation();
if (location != null)
{
client.setHintArrow(location);
}
}
if (clue instanceof NpcClueScroll)
{
String npc = ((NpcClueScroll) clue).getNpc();
@@ -190,6 +202,12 @@ public class ClueScrollPlugin extends Plugin
{
Query query = new NPCQuery().nameContains(npc);
npcsToMark = queryRunner.runQuery(query);
// Set hint arrow to first NPC found as there can only be 1 hint arrow
if (npcsToMark.length >= 1)
{
client.setHintArrow(npcsToMark[0]);
}
}
}
@@ -201,6 +219,12 @@ public class ClueScrollPlugin extends Plugin
{
GameObjectQuery query = new GameObjectQuery().idEquals(objectId);
objectsToMark = queryRunner.runQuery(query);
// Set hint arrow to first object found as there can only be 1 hint arrow
if (objectsToMark.length >= 1)
{
client.setHintArrow(objectsToMark[0].getWorldLocation());
}
}
}

View File

@@ -39,7 +39,7 @@ import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLU
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
@Getter
public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueScroll
public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueScroll, LocationClueScroll
{
private static final Set<AnagramClue> CLUES = ImmutableSet.of(
new AnagramClue("This anagram reveals who to speak to next: A BAKER", "Baraek", new WorldPoint(3217, 3434, 0), "Varrock square", "5"),
@@ -193,11 +193,6 @@ public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueSc
{
for (NPC npc : plugin.getNpcsToMark())
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(npc);
}
OverlayUtil.renderActorOverlayImage(graphics, npc, CLUE_SCROLL_IMAGE, Color.ORANGE, IMAGE_Z_OFFSET);
}
}

View File

@@ -39,7 +39,7 @@ import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLU
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
@Getter
public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScroll
public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScroll, LocationClueScroll
{
private static final Set<CipherClue> CLUES = ImmutableSet.of(
new CipherClue("The cipher reveals who to speak to next: BMJ UIF LFCBC TFMMFS", "Ali the Kebab seller", new WorldPoint(3354, 2974, 0), "Pollnivneach", "399"),
@@ -103,11 +103,6 @@ public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScr
{
for (NPC npc : plugin.getNpcsToMark())
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(npc);
}
OverlayUtil.renderActorOverlayImage(graphics, npc, CLUE_SCROLL_IMAGE, Color.ORANGE, IMAGE_Z_OFFSET);
}
}

View File

@@ -37,7 +37,7 @@ import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPA
@Getter
@AllArgsConstructor
public class CoordinateClue extends ClueScroll implements TextClueScroll
public class CoordinateClue extends ClueScroll implements TextClueScroll, LocationClueScroll
{
private String text;
private WorldPoint location;
@@ -57,11 +57,6 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll
@Override
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin)
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(getLocation());
}
LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
if (localLocation == null)

View File

@@ -47,7 +47,7 @@ import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMA
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPADE_IMAGE;
@Getter
public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueScroll, ObjectClueScroll
public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueScroll, ObjectClueScroll, LocationClueScroll
{
private static final Set<CrypticClue> CLUES = ImmutableSet.of(
new CrypticClue("Show this to Sherlock.", "Sherlock", new WorldPoint(2733, 3415, 0), "Sherlock is located to the east of the Sorcerer's tower in Seers' Village."),
@@ -371,11 +371,6 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
// Mark dig location
if (getLocation() != null && getNpc() == null && objectId == -1)
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(getLocation());
}
LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
if (localLocation != null)
@@ -389,11 +384,6 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
{
for (NPC npc : plugin.getNpcsToMark())
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(npc);
}
OverlayUtil.renderActorOverlayImage(graphics, npc, CLUE_SCROLL_IMAGE, Color.ORANGE, IMAGE_Z_OFFSET);
}
}
@@ -407,11 +397,6 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
{
for (GameObject gameObject : plugin.getObjectsToMark())
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(gameObject.getWorldLocation());
}
OverlayUtil.renderHoverableArea(graphics, gameObject.getClickbox(), mousePosition,
CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR);

View File

@@ -42,7 +42,7 @@ import static net.runelite.client.plugins.cluescrolls.clues.Emote.*;
import static net.runelite.client.plugins.cluescrolls.clues.Emote.BULL_ROARER;
@Getter
public class EmoteClue extends ClueScroll implements TextClueScroll
public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClueScroll
{
private static final Set<EmoteClue> CLUES = ImmutableSet.of(
new EmoteClue("Show your anger towards the Statue of Saradomin in Ellamaria's garden. Beware of double agents! Equip a zamorak godsword.", new WorldPoint(3230, 3478, 0), ANGRY, ZAMORAK_GODSWORD),
@@ -221,11 +221,6 @@ public class EmoteClue extends ClueScroll implements TextClueScroll
@Override
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin)
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(getLocation());
}
LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
if (localLocation == null)

View File

@@ -38,7 +38,7 @@ import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_C
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPADE_IMAGE;
@Getter
public class FairyRingClue extends ClueScroll implements TextClueScroll
public class FairyRingClue extends ClueScroll implements TextClueScroll, LocationClueScroll
{
private static final Set<FairyRingClue> CLUES = ImmutableSet.of(
new FairyRingClue("A I R 2 3 3 1", new WorldPoint(2702, 3246, 0)),
@@ -78,11 +78,6 @@ public class FairyRingClue extends ClueScroll implements TextClueScroll
@Override
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin)
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(getLocation());
}
LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
if (localLocation == null)

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* 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.cluescrolls.clues;
import net.runelite.api.coords.WorldPoint;
public interface LocationClueScroll
{
WorldPoint getLocation();
}

View File

@@ -48,7 +48,7 @@ import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMA
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPADE_IMAGE;
@Getter
public class MapClue extends ClueScroll implements ObjectClueScroll
public class MapClue extends ClueScroll implements ObjectClueScroll, LocationClueScroll
{
private static final Set<MapClue> CLUES = ImmutableSet.of(
new MapClue(CLUE_SCROLL_EASY_12179, new WorldPoint(3300, 3291, 0)),
@@ -126,11 +126,6 @@ public class MapClue extends ClueScroll implements ObjectClueScroll
@Override
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin)
{
if (!plugin.getClient().hasHintArrow())
{
plugin.getClient().setHintArrow(getLocation());
}
LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
if (localLocation == null)