Add support for map for hot/cold clues
- Create new interface for clues that will return multiple locations, have update and reset methods for clues with undetermined location - Implement new LocationsClueScroll and LocationClueScroll to HotColdClue to add support for displaying all the points on world map - Handle the LocationsClueScroll to add each WorldPoint to the world map when found - Add new removeIf method to the WorldMapPointsManager Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -34,6 +34,7 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
@@ -76,6 +77,7 @@ import net.runelite.client.plugins.cluescrolls.clues.EmoteClue;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.FairyRingClue;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.HotColdClue;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.LocationClueScroll;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.LocationsClueScroll;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.MapClue;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll;
|
||||
@@ -138,10 +140,9 @@ public class ClueScrollPlugin extends Plugin
|
||||
@Inject
|
||||
private WorldMapPointManager worldMapPointManager;
|
||||
|
||||
private ClueScrollWorldMapPoint worldMapPoint;
|
||||
|
||||
private Integer clueItemId;
|
||||
private boolean clueItemChanged = false;
|
||||
private boolean worldMapPointsSet = false;
|
||||
|
||||
static
|
||||
{
|
||||
@@ -187,9 +188,9 @@ public class ClueScrollPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (clue instanceof HotColdClue)
|
||||
if (clue instanceof LocationsClueScroll)
|
||||
{
|
||||
((HotColdClue)clue).update(event.getMessage(), this);
|
||||
((LocationsClueScroll)clue).update(event.getMessage(), this);
|
||||
}
|
||||
|
||||
if (!event.getMessage().equals("The strange device cools as you find your treasure.")
|
||||
@@ -257,6 +258,12 @@ public class ClueScrollPlugin extends Plugin
|
||||
objectsToMark = null;
|
||||
equippedItems = null;
|
||||
|
||||
if (clue instanceof LocationsClueScroll)
|
||||
{
|
||||
final List<WorldPoint> locations = ((LocationsClueScroll) clue).getLocations();
|
||||
addMapPoints(locations.toArray(new WorldPoint[locations.size()]));
|
||||
}
|
||||
|
||||
// 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)
|
||||
@@ -268,7 +275,7 @@ public class ClueScrollPlugin extends Plugin
|
||||
client.setHintArrow(location);
|
||||
}
|
||||
|
||||
setMapPoint(location);
|
||||
addMapPoints(location);
|
||||
}
|
||||
|
||||
if (clue instanceof NpcClueScroll)
|
||||
@@ -288,7 +295,7 @@ public class ClueScrollPlugin extends Plugin
|
||||
client.setHintArrow(npcsToMark[0]);
|
||||
}
|
||||
|
||||
setMapPoint(npcsToMark[0].getWorldLocation());
|
||||
addMapPoints(npcsToMark[0].getWorldLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,19 +388,15 @@ public class ClueScrollPlugin extends Plugin
|
||||
clueItemId = null;
|
||||
}
|
||||
|
||||
if (clue instanceof HotColdClue)
|
||||
if (clue instanceof LocationsClueScroll)
|
||||
{
|
||||
((HotColdClue) clue).resetHotCold();
|
||||
((LocationsClueScroll) clue).reset();
|
||||
}
|
||||
|
||||
clueItemChanged = false;
|
||||
clue = null;
|
||||
|
||||
if (worldMapPoint != null)
|
||||
{
|
||||
worldMapPointManager.remove(worldMapPoint);
|
||||
worldMapPoint = null;
|
||||
}
|
||||
worldMapPointManager.removeIf(point -> point instanceof ClueScrollWorldMapPoint);
|
||||
worldMapPointsSet = false;
|
||||
|
||||
if (config.displayHintArrows())
|
||||
{
|
||||
@@ -549,12 +552,18 @@ public class ClueScrollPlugin extends Plugin
|
||||
return new WorldPoint(x2, y2, 0);
|
||||
}
|
||||
|
||||
private void setMapPoint(WorldPoint point)
|
||||
private void addMapPoints(WorldPoint... points)
|
||||
{
|
||||
if (worldMapPoint == null)
|
||||
if (worldMapPointsSet)
|
||||
{
|
||||
worldMapPoint = new ClueScrollWorldMapPoint(point);
|
||||
worldMapPointManager.add(worldMapPoint);
|
||||
return;
|
||||
}
|
||||
|
||||
worldMapPointsSet = true;
|
||||
|
||||
for (final WorldPoint point : points)
|
||||
{
|
||||
worldMapPointManager.add(new ClueScrollWorldMapPoint(point));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.cluescrolls.clues;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -58,7 +59,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueScroll
|
||||
public class HotColdClue extends ClueScroll implements LocationClueScroll, LocationsClueScroll, TextClueScroll, NpcClueScroll
|
||||
{
|
||||
private static final Pattern INITIAL_STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*)");
|
||||
private static final Pattern STRANGE_DEVICE_MESSAGE = Pattern.compile("The device is (.*), (.*) last time\\.");
|
||||
@@ -76,6 +77,22 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc
|
||||
private WorldPoint location;
|
||||
private WorldPoint lastWorldPoint;
|
||||
|
||||
public static HotColdClue forText(String text)
|
||||
{
|
||||
if (CLUE.text.equalsIgnoreCase(text))
|
||||
{
|
||||
return CLUE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorldPoint> getLocations()
|
||||
{
|
||||
return Lists.transform(digLocations, HotColdLocation::getWorldPoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plugin)
|
||||
{
|
||||
@@ -230,16 +247,7 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc
|
||||
}
|
||||
}
|
||||
|
||||
public static HotColdClue forText(String text)
|
||||
{
|
||||
if (CLUE.text.equalsIgnoreCase(text))
|
||||
{
|
||||
return CLUE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final String message, final ClueScrollPlugin plugin)
|
||||
{
|
||||
if (!message.startsWith("The device is"))
|
||||
@@ -285,6 +293,13 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
this.lastWorldPoint = null;
|
||||
digLocations.clear();
|
||||
}
|
||||
|
||||
private void updatePossibleArea(WorldPoint currentWp, String temperature, String difference)
|
||||
{
|
||||
this.location = null;
|
||||
@@ -400,12 +415,6 @@ public class HotColdClue extends ClueScroll implements TextClueScroll, NpcClueSc
|
||||
private void markFinalSpot(WorldPoint wp)
|
||||
{
|
||||
this.location = wp;
|
||||
resetHotCold();
|
||||
}
|
||||
|
||||
public void resetHotCold()
|
||||
{
|
||||
this.lastWorldPoint = null;
|
||||
digLocations.clear();
|
||||
reset();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 java.util.List;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
|
||||
public interface LocationsClueScroll
|
||||
{
|
||||
void update(String message, ClueScrollPlugin plugin);
|
||||
|
||||
void reset();
|
||||
|
||||
List<WorldPoint> getLocations();
|
||||
}
|
||||
@@ -56,7 +56,8 @@ public class WorldMapOverlayMouseListener extends MouseListener
|
||||
@Override
|
||||
public MouseEvent mousePressed(MouseEvent e)
|
||||
{
|
||||
List<WorldMapPoint> worldMapPoints = worldMapPointManager.getWorldMapPoints();
|
||||
final List<WorldMapPoint> worldMapPoints = worldMapPointManager.getWorldMapPoints();
|
||||
|
||||
if (SwingUtilities.isLeftMouseButton(e) && !worldMapPoints.isEmpty())
|
||||
{
|
||||
Point mousePos = clientProvider.get().getMouseCanvasPosition();
|
||||
@@ -84,7 +85,8 @@ public class WorldMapOverlayMouseListener extends MouseListener
|
||||
@Override
|
||||
public MouseEvent mouseMoved(MouseEvent mouseEvent)
|
||||
{
|
||||
List<WorldMapPoint> worldMapPoints = worldMapPointManager.getWorldMapPoints();
|
||||
final List<WorldMapPoint> worldMapPoints = worldMapPointManager.getWorldMapPoints();
|
||||
|
||||
if (worldMapPoints.isEmpty())
|
||||
{
|
||||
return mouseEvent;
|
||||
|
||||
@@ -26,6 +26,7 @@ package net.runelite.client.ui.overlay.worldmap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
@@ -45,4 +46,9 @@ public class WorldMapPointManager
|
||||
{
|
||||
worldMapPoints.remove(worldMapPoint);
|
||||
}
|
||||
|
||||
public void removeIf(Predicate<WorldMapPoint> filter)
|
||||
{
|
||||
worldMapPoints.removeIf(filter);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user