Merge pull request #2022 from sethtroll/addhintarrowtoggle

clue scroll: Add toggle for hint arrows
This commit is contained in:
Tomas Slusny
2018-04-30 11:49:18 +02:00
committed by GitHub
3 changed files with 77 additions and 5 deletions

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, Seth <http://github.com/sethtroll>
* 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;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup(
name = "Clue Scroll",
keyName = "cluescroll",
description = "Configuration for the clue scroll plugin"
)
public interface ClueScrollConfig extends Config
{
@ConfigItem(
keyName = "displayHintArrows",
name = "Display hint arrows",
description = "Configures whether or not to display hint arrows for clues"
)
default boolean displayHintArrows()
{
return true;
}
}

View File

@@ -27,6 +27,7 @@
package net.runelite.client.plugins.cluescrolls;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
@@ -50,6 +51,7 @@ import net.runelite.api.Tile;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.ItemContainerChanged;
@@ -58,6 +60,7 @@ import net.runelite.api.queries.InventoryItemQuery;
import net.runelite.api.queries.NPCQuery;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@@ -119,9 +122,18 @@ public class ClueScrollPlugin extends Plugin
@Inject
private ClueScrollWorldOverlay clueScrollWorldOverlay;
@Inject
private ClueScrollConfig config;
private Integer clueItemId;
private boolean clueItemChanged = false;
@Provides
ClueScrollConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(ClueScrollConfig.class);
}
@Override
public Collection<Overlay> getOverlays()
{
@@ -175,6 +187,15 @@ public class ClueScrollPlugin extends Plugin
}
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("cluescroll") && !config.displayHintArrows())
{
client.clearHintArrow();
}
}
@Subscribe
public void onGameStateChanged(final GameStateChanged event)
{
@@ -197,7 +218,7 @@ public class ClueScrollPlugin extends Plugin
{
final WorldPoint location = ((LocationClueScroll) clue).getLocation();
if (location != null)
if (config.displayHintArrows() && location != null)
{
client.setHintArrow(location);
}
@@ -213,7 +234,7 @@ public class ClueScrollPlugin extends Plugin
npcsToMark = queryRunner.runQuery(query);
// Set hint arrow to first NPC found as there can only be 1 hint arrow
if (npcsToMark.length >= 1)
if (config.displayHintArrows() && npcsToMark.length >= 1)
{
client.setHintArrow(npcsToMark[0]);
}
@@ -245,7 +266,7 @@ public class ClueScrollPlugin extends Plugin
.toArray(GameObject[]::new);
// Set hint arrow to first object found as there can only be 1 hint arrow
if (objectsToMark.length >= 1)
if (config.displayHintArrows() && objectsToMark.length >= 1)
{
client.setHintArrow(objectsToMark[0].getWorldLocation());
}
@@ -300,7 +321,11 @@ public class ClueScrollPlugin extends Plugin
clueItemChanged = false;
clue = null;
client.clearHintArrow();
if (config.displayHintArrows())
{
client.clearHintArrow();
}
}
private ClueScroll findClueScroll()

View File

@@ -86,7 +86,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("The dead, red dragon watches over this chest. He must really dig the view.", "Barbarian", 375, new WorldPoint(3353, 3332, 0), "Search the chest underneath the Red Dragon's head in the Exam Centre. Kill a MALE Barbarian in Barbarian Village or Barbarian Outpost to receive the key."),
new CrypticClue("My home is grey, and made of stone; A castle with a search for a meal. Hidden in some drawers I am, across from a wooden wheel.", DRAWERS_5618, new WorldPoint(3213, 3216, 1), "Open the drawers inside the room with the spinning wheel on the first floor of Lumbridge Castle."),
new CrypticClue("Come to the evil ledge, Yew know yew want to. Try not to get stung.", new WorldPoint(3089, 3468, 0), "Dig in Edgeville, just east of the Southern Yew tree."),
new CrypticClue("Look in the ground floor crates of houses in Falador.", NULL_5536, new WorldPoint(3027, 3356, 0), "The house east of the east bank."),
new CrypticClue("Look in the ground floor crates of houses in Falador.", CRATES_24088, new WorldPoint(3029, 3355, 0), "The house east of the east bank."),
new CrypticClue("You were 3 and I was the 6th. Come speak to me.", "Vannaka", new WorldPoint(3146, 9913, 0), "Speak to Vannaka in Edgeville Dungeon."),
new CrypticClue("Search the crates in Draynor Manor.", CRATE_11485, new WorldPoint(3105, 3369, 2), "Top floor of the manor"),
new CrypticClue("Search the crates near a cart in Varrock.", CRATE_5107, new WorldPoint(3226, 3452, 0), "South east of Varrock Palace, south of the tree farming patch."),