Merge pull request #2064 from MESLewis/world-map-overlay
Add world map overlay to clue scroll plugin
This commit is contained in:
@@ -24,8 +24,16 @@
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
public interface RenderOverview
|
||||
{
|
||||
Point getWorldMapPosition();
|
||||
|
||||
float getWorldMapZoom();
|
||||
|
||||
void setWorldMapPositionTarget(WorldPoint worldPoint);
|
||||
|
||||
WorldMapManager getWorldMapManager();
|
||||
|
||||
void initializeWorldMap(WorldMapData var1);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class WidgetID
|
||||
public static final int PUZZLE_BOX_GROUP_ID = 306;
|
||||
public static final int NIGHTMARE_ZONE_GROUP_ID = 202;
|
||||
public static final int BLAST_FURNACE_GROUP_ID = 474;
|
||||
public static final int WORLD_MAP = 595;
|
||||
public static final int WORLD_MAP_GROUP_ID = 595;
|
||||
public static final int PYRAMID_PLUNDER_GROUP_ID = 428;
|
||||
public static final int RAIDS_REWARD_GROUP_ID = 539;
|
||||
public static final int EXPERIENCE_TRACKER_GROUP_ID = 122;
|
||||
@@ -88,6 +88,8 @@ public class WidgetID
|
||||
static class WorldMap
|
||||
{
|
||||
static final int OPTION = 36;
|
||||
static final int TOOLTIP = 35;
|
||||
static final int MAPVIEW = 3;
|
||||
}
|
||||
|
||||
static class SlayerRewards
|
||||
|
||||
@@ -45,6 +45,8 @@ public enum WidgetInfo
|
||||
RAIDING_PARTY(WidgetID.RAIDING_PARTY_GROUP_ID, 0),
|
||||
|
||||
WORLD_MAP(WidgetID.WORLD_MAP_MENU_GROUP_ID, WidgetID.WorldMap.OPTION),
|
||||
WORLD_MAP_TOOLTIP(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.TOOLTIP),
|
||||
WORLD_MAP_VIEW(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.MAPVIEW),
|
||||
|
||||
CLUE_SCROLL_TEXT(WidgetID.CLUE_SCROLL_GROUP_ID, WidgetID.Cluescroll.CLUE_TEXT),
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ import com.google.common.eventbus.EventBus;
|
||||
import com.google.inject.Injector;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.RenderingHints;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
@@ -63,7 +63,7 @@ import net.runelite.api.events.PostItemComposition;
|
||||
import net.runelite.api.events.ProjectileMoved;
|
||||
import net.runelite.api.events.SetMessage;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import static net.runelite.api.widgets.WidgetID.WORLD_MAP;
|
||||
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
@@ -158,7 +158,7 @@ public class Hooks
|
||||
*/
|
||||
private static void checkWorldMap()
|
||||
{
|
||||
Widget widget = client.getWidget(WORLD_MAP, 0);
|
||||
Widget widget = client.getWidget(WORLD_MAP);
|
||||
if (widget != null)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -28,11 +28,14 @@ package net.runelite.client.plugins.cluescrolls;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Stream;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -77,8 +80,9 @@ import net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.TextClueScroll;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Clue Scroll"
|
||||
@@ -88,6 +92,11 @@ public class ClueScrollPlugin extends Plugin
|
||||
{
|
||||
private static final Duration WAIT_DURATION = Duration.ofMinutes(4);
|
||||
|
||||
public static final BufferedImage CLUE_SCROLL_IMAGE;
|
||||
public static final BufferedImage MAP_ARROW;
|
||||
public static final BufferedImage EMOTE_IMAGE;
|
||||
public static final BufferedImage SPADE_IMAGE;
|
||||
|
||||
@Getter
|
||||
private ClueScroll clue;
|
||||
|
||||
@@ -125,15 +134,49 @@ public class ClueScrollPlugin extends Plugin
|
||||
@Inject
|
||||
private ClueScrollConfig config;
|
||||
|
||||
@Inject
|
||||
private WorldMapPointManager worldMapPointManager;
|
||||
|
||||
private ClueScrollWorldMapPoint worldMapPoint;
|
||||
|
||||
private Integer clueItemId;
|
||||
private boolean clueItemChanged = false;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
CLUE_SCROLL_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("clue_scroll.png"));
|
||||
MAP_ARROW = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("clue_arrow.png"));
|
||||
EMOTE_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("emote.png"));
|
||||
SPADE_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("spade.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
ClueScrollConfig getConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(ClueScrollConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
clearMapPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Overlay> getOverlays()
|
||||
{
|
||||
@@ -222,6 +265,8 @@ public class ClueScrollPlugin extends Plugin
|
||||
{
|
||||
client.setHintArrow(location);
|
||||
}
|
||||
|
||||
setMapPoint(location);
|
||||
}
|
||||
|
||||
if (clue instanceof NpcClueScroll)
|
||||
@@ -234,9 +279,14 @@ 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 (config.displayHintArrows() && npcsToMark.length >= 1)
|
||||
if (npcsToMark.length >= 1)
|
||||
{
|
||||
client.setHintArrow(npcsToMark[0]);
|
||||
if (config.displayHintArrows())
|
||||
{
|
||||
client.setHintArrow(npcsToMark[0]);
|
||||
}
|
||||
|
||||
setMapPoint(npcsToMark[0].getWorldLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,6 +372,8 @@ public class ClueScrollPlugin extends Plugin
|
||||
clueItemChanged = false;
|
||||
clue = null;
|
||||
|
||||
clearMapPoint();
|
||||
|
||||
if (config.displayHintArrows())
|
||||
{
|
||||
client.clearHintArrow();
|
||||
@@ -468,4 +520,23 @@ public class ClueScrollPlugin extends Plugin
|
||||
|
||||
return new WorldPoint(x2, y2, 0);
|
||||
}
|
||||
|
||||
private void setMapPoint(WorldPoint point)
|
||||
{
|
||||
if (worldMapPoint == null)
|
||||
{
|
||||
worldMapPoint = new ClueScrollWorldMapPoint();
|
||||
worldMapPointManager.add(worldMapPoint);
|
||||
}
|
||||
worldMapPoint.setWorldPoint(point);
|
||||
}
|
||||
|
||||
private void clearMapPoint()
|
||||
{
|
||||
if (worldMapPoint != null)
|
||||
{
|
||||
worldMapPointManager.remove(worldMapPoint);
|
||||
worldMapPoint = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* 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 java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||
|
||||
class ClueScrollWorldMapPoint extends WorldMapPoint
|
||||
{
|
||||
private final BufferedImage worldMapImage;
|
||||
private final Point imagePoint;
|
||||
private final BufferedImage edgeSnapImage;
|
||||
|
||||
ClueScrollWorldMapPoint()
|
||||
{
|
||||
super(null, null);
|
||||
|
||||
this.setSnapToEdge(true);
|
||||
this.setJumpOnClick(true);
|
||||
|
||||
worldMapImage = new BufferedImage(ClueScrollPlugin.MAP_ARROW.getWidth(), ClueScrollPlugin.MAP_ARROW.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics graphics = worldMapImage.getGraphics();
|
||||
graphics.drawImage(ClueScrollPlugin.MAP_ARROW, 0, 0, null);
|
||||
graphics.drawImage(ClueScrollPlugin.CLUE_SCROLL_IMAGE, 0, 2, null);
|
||||
|
||||
imagePoint = new Point(worldMapImage.getWidth() / 2, worldMapImage.getHeight());
|
||||
this.setImage(worldMapImage);
|
||||
this.setImagePoint(imagePoint);
|
||||
|
||||
edgeSnapImage = ClueScrollPlugin.CLUE_SCROLL_IMAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEdgeSnap()
|
||||
{
|
||||
this.setImage(edgeSnapImage);
|
||||
this.setImagePoint(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEdgeUnsnap()
|
||||
{
|
||||
this.setImage(worldMapImage);
|
||||
this.setImagePoint(imagePoint);
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,6 @@ package net.runelite.client.plugins.cluescrolls;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.ClueScroll;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
@@ -40,33 +37,12 @@ public class ClueScrollWorldOverlay extends Overlay
|
||||
{
|
||||
public static final int IMAGE_Z_OFFSET = 30;
|
||||
|
||||
public static final BufferedImage EMOTE_IMAGE;
|
||||
public static final BufferedImage CLUE_SCROLL_IMAGE;
|
||||
public static final BufferedImage SPADE_IMAGE;
|
||||
|
||||
public static final Color CLICKBOX_BORDER_COLOR = Color.ORANGE;
|
||||
public static final Color CLICKBOX_HOVER_BORDER_COLOR = CLICKBOX_BORDER_COLOR.darker();
|
||||
public static final Color CLICKBOX_FILL_COLOR = new Color(0, 255, 0, 20);
|
||||
|
||||
private final ClueScrollPlugin plugin;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
EMOTE_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("emote.png"));
|
||||
CLUE_SCROLL_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("clue_scroll.png"));
|
||||
SPADE_IMAGE = ImageIO.read(ClueScrollPlugin.class.getResourceAsStream("spade.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
public ClueScrollWorldOverlay(ClueScrollPlugin plugin)
|
||||
{
|
||||
|
||||
@@ -31,12 +31,12 @@ import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
|
||||
|
||||
@Getter
|
||||
public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueScroll, LocationClueScroll
|
||||
|
||||
@@ -31,12 +31,12 @@ import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
|
||||
|
||||
@Getter
|
||||
public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScroll, LocationClueScroll
|
||||
|
||||
@@ -31,9 +31,9 @@ import lombok.Getter;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPADE_IMAGE;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -32,19 +32,19 @@ import lombok.Getter;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.ObjectComposition;
|
||||
import static net.runelite.api.ObjectID.*;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import static net.runelite.api.ObjectID.*;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_BORDER_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_HOVER_BORDER_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPADE_IMAGE;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
@Getter
|
||||
public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueScroll, ObjectClueScroll
|
||||
|
||||
@@ -30,26 +30,34 @@ import java.awt.Graphics2D;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.EquipmentInventorySlot;
|
||||
import static net.runelite.api.EquipmentInventorySlot.AMULET;
|
||||
import static net.runelite.api.EquipmentInventorySlot.BODY;
|
||||
import static net.runelite.api.EquipmentInventorySlot.BOOTS;
|
||||
import static net.runelite.api.EquipmentInventorySlot.CAPE;
|
||||
import static net.runelite.api.EquipmentInventorySlot.GLOVES;
|
||||
import static net.runelite.api.EquipmentInventorySlot.HEAD;
|
||||
import static net.runelite.api.EquipmentInventorySlot.LEGS;
|
||||
import static net.runelite.api.EquipmentInventorySlot.RING;
|
||||
import static net.runelite.api.EquipmentInventorySlot.SHIELD;
|
||||
import static net.runelite.api.EquipmentInventorySlot.WEAPON;
|
||||
import net.runelite.api.Item;
|
||||
import static net.runelite.api.ItemID.*;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.Emote;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.ItemRequirement;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.AnyRequirementCollection;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.AllRequirementsCollection;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.RangeItemRequirement;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.SlotLimitationRequirement;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import static net.runelite.api.EquipmentInventorySlot.*;
|
||||
import static net.runelite.api.EquipmentInventorySlot.LEGS;
|
||||
import static net.runelite.api.ItemID.*;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.EMOTE_IMAGE;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.EMOTE_IMAGE;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.AllRequirementsCollection;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.AnyRequirementCollection;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.Emote;
|
||||
import static net.runelite.client.plugins.cluescrolls.clues.emote.Emote.*;
|
||||
import static net.runelite.client.plugins.cluescrolls.clues.emote.Emote.BULL_ROARER;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.ItemRequirement;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.RangeItemRequirement;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.SingleItemRequirement;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.emote.SlotLimitationRequirement;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
@Getter
|
||||
public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClueScroll
|
||||
|
||||
@@ -31,11 +31,11 @@ import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPADE_IMAGE;
|
||||
|
||||
@Getter
|
||||
public class FairyRingClue extends ClueScroll implements TextClueScroll, LocationClueScroll
|
||||
|
||||
@@ -36,12 +36,12 @@ import static net.runelite.api.ObjectID.*;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollPlugin.SPADE_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_BORDER_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_FILL_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLICKBOX_HOVER_BORDER_COLOR;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.CLUE_SCROLL_IMAGE;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.IMAGE_Z_OFFSET;
|
||||
import static net.runelite.client.plugins.cluescrolls.ClueScrollWorldOverlay.SPADE_IMAGE;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* 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.worldmaptest;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Inject;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.CommandExecuted;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "WorldMapOverlayTest",
|
||||
developerPlugin = true,
|
||||
enabledByDefault = false
|
||||
)
|
||||
public class WorldMapOverlayTestPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private WorldMapPointManager worldMapPointManager;
|
||||
|
||||
private BufferedImage markerImage;
|
||||
|
||||
private WorldMapPoint playerDot;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
markerImage = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics markGraphics = markerImage.getGraphics();
|
||||
markGraphics.setColor(Color.ORANGE);
|
||||
markGraphics.fillOval(0, 0, 10, 10);
|
||||
|
||||
BufferedImage playerImage = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
|
||||
playerImage.getGraphics().setColor(Color.WHITE);
|
||||
playerImage.getGraphics().fillRect(0, 0, 5, 5);
|
||||
playerDot = new WorldMapPoint(null, playerImage);
|
||||
|
||||
worldMapPointManager.add(playerDot);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
worldMapPointManager.remove(playerDot);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
void onTick(GameTick tick)
|
||||
{
|
||||
WorldPoint wp = client.getLocalPlayer().getWorldLocation();
|
||||
playerDot.setWorldPoint(new WorldPoint(wp.getX(), wp.getY(), 0));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onCommand(CommandExecuted commandExecuted)
|
||||
{
|
||||
String[] args = commandExecuted.getArguments();
|
||||
|
||||
if (commandExecuted.getCommand().equals("mappos"))
|
||||
{
|
||||
if (args.length >= 2)
|
||||
{
|
||||
int x = Integer.parseInt(args[0]);
|
||||
int y = Integer.parseInt(args[1]);
|
||||
|
||||
WorldPoint worldPoint = new WorldPoint(x, y, 0);
|
||||
WorldMapPoint marker = new WorldMapPoint(worldPoint, markerImage);
|
||||
worldMapPointManager.add(marker);
|
||||
client.getRenderOverview().setWorldMapPositionTarget(worldPoint);
|
||||
if (args.length >= 3)
|
||||
{
|
||||
marker.setTooltip(args[2]);
|
||||
}
|
||||
}
|
||||
WorldPoint wp = client.getLocalPlayer().getWorldLocation();
|
||||
Point mapPoint = client.getRenderOverview().getWorldMapPosition();
|
||||
int diffX = mapPoint.getX() - wp.getX();
|
||||
int diffY = mapPoint.getY() - wp.getY();
|
||||
client.addChatMessage(ChatMessageType.SERVER, "", "Coordinate Difference:" + diffX + ", " + diffY, null);
|
||||
client.addChatMessage(ChatMessageType.SERVER, "", "Current Map Coordinates:" + mapPoint.getX() + ", " + mapPoint.getY(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxOverlay;
|
||||
import net.runelite.client.ui.overlay.tooltip.TooltipOverlay;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -91,6 +92,7 @@ public class OverlayRenderer extends MouseListener implements KeyListener
|
||||
private final ConfigManager configManager;
|
||||
private final RuneLiteConfig runeLiteConfig;
|
||||
private final TooltipOverlay tooltipOverlay;
|
||||
private final WorldMapOverlay worldMapOverlay;
|
||||
private final List<Overlay> allOverlays = new CopyOnWriteArrayList<>();
|
||||
private final String runeliteGroupName = RuneLiteConfig.class.getAnnotation(ConfigGroup.class).keyName();
|
||||
|
||||
@@ -117,6 +119,7 @@ public class OverlayRenderer extends MouseListener implements KeyListener
|
||||
final KeyManager keyManager,
|
||||
final TooltipOverlay tooltipOverlay,
|
||||
final InfoBoxOverlay infoBoxOverlay,
|
||||
final WorldMapOverlay worldMapOverlay,
|
||||
final ConfigManager configManager,
|
||||
final RuneLiteConfig runeLiteConfig)
|
||||
{
|
||||
@@ -124,6 +127,7 @@ public class OverlayRenderer extends MouseListener implements KeyListener
|
||||
this.pluginManager = pluginManager;
|
||||
this.tooltipOverlay = tooltipOverlay;
|
||||
this.infoBoxOverlay = infoBoxOverlay;
|
||||
this.worldMapOverlay = worldMapOverlay;
|
||||
this.configManager = configManager;
|
||||
this.runeLiteConfig = runeLiteConfig;
|
||||
keyManager.registerKeyListener(this);
|
||||
@@ -169,7 +173,7 @@ public class OverlayRenderer extends MouseListener implements KeyListener
|
||||
.stream()
|
||||
.filter(pluginManager::isPluginEnabled)
|
||||
.flatMap(plugin -> plugin.getOverlays().stream()),
|
||||
Stream.of(infoBoxOverlay, tooltipOverlay))
|
||||
Stream.of(infoBoxOverlay, tooltipOverlay, worldMapOverlay))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* 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.ui.overlay.worldmap;
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.RenderOverview;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.input.MouseManager;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
public class WorldMapOverlay extends Overlay
|
||||
{
|
||||
private static final Color TOOLTIP_BACKGROUND = new Color(255, 255, 160);
|
||||
private static final int TOOLTIP_OFFSET_HEIGHT = 25;
|
||||
private static final int TOOLTIP_OFFSET_WIDTH = 5;
|
||||
private static final int TOOLTIP_PADDING_HEIGHT = 1;
|
||||
private static final int TOOLTIP_PADDING_WIDTH = 2;
|
||||
|
||||
private final WorldMapPointManager worldMapPointManager;
|
||||
private final Provider<Client> clientProvider;
|
||||
|
||||
@Inject
|
||||
private WorldMapOverlay(Provider<Client> clientProvider, WorldMapPointManager worldMapPointManager,
|
||||
MouseManager mouseManager, WorldMapOverlayMouseListener worldMapOverlayMouseListener)
|
||||
{
|
||||
this.clientProvider = clientProvider;
|
||||
this.worldMapPointManager = worldMapPointManager;
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
setLayer(OverlayLayer.ALWAYS_ON_TOP);
|
||||
mouseManager.registerMouseListener(worldMapOverlayMouseListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
final List<WorldMapPoint> points = worldMapPointManager.getWorldMapPoints();
|
||||
|
||||
if (points.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final Client client = clientProvider.get();
|
||||
|
||||
Widget widget = client.getWidget(WidgetInfo.WORLD_MAP_VIEW);
|
||||
if (widget == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final Rectangle worldMapRectangle = widget.getBounds();
|
||||
WorldMapPoint tooltipPoint = null;
|
||||
|
||||
for (WorldMapPoint worldPoint : points)
|
||||
{
|
||||
BufferedImage image = worldPoint.getImage();
|
||||
WorldPoint point = worldPoint.getWorldPoint();
|
||||
|
||||
if (image != null && point != null)
|
||||
{
|
||||
Point drawPoint = mapWorldPointToGraphicsPoint(point);
|
||||
|
||||
if (worldPoint.isSnapToEdge())
|
||||
{
|
||||
Canvas canvas = client.getCanvas();
|
||||
graphics.setClip(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
|
||||
if (worldMapRectangle.contains(drawPoint.getX(), drawPoint.getY()))
|
||||
{
|
||||
if (worldPoint.isCurrentlyEdgeSnapped())
|
||||
{
|
||||
worldPoint.setCurrentlyEdgeSnapped(false);
|
||||
worldPoint.onEdgeUnsnap();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
drawPoint = clipToRectangle(drawPoint, worldMapRectangle);
|
||||
if (!worldPoint.isCurrentlyEdgeSnapped())
|
||||
{
|
||||
worldPoint.setCurrentlyEdgeSnapped(true);
|
||||
worldPoint.onEdgeSnap();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.setClip(worldMapRectangle);
|
||||
}
|
||||
|
||||
int drawX = drawPoint.getX();
|
||||
int drawY = drawPoint.getY();
|
||||
|
||||
if (worldPoint.getImagePoint() == null)
|
||||
{
|
||||
drawX -= image.getWidth() / 2;
|
||||
drawY -= image.getHeight() / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawX -= worldPoint.getImagePoint().getX();
|
||||
drawY -= worldPoint.getImagePoint().getY();
|
||||
}
|
||||
|
||||
graphics.drawImage(image, drawX, drawY, null);
|
||||
Rectangle clickbox = new Rectangle(drawX, drawY, image.getWidth(), image.getHeight());
|
||||
worldPoint.setClickbox(clickbox);
|
||||
|
||||
if (worldPoint.isTooltipVisible())
|
||||
{
|
||||
tooltipPoint = worldPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tooltipPoint != null)
|
||||
{
|
||||
drawTooltip(graphics, tooltipPoint);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Point mapWorldPointToGraphicsPoint(WorldPoint worldPoint)
|
||||
{
|
||||
RenderOverview ro = clientProvider.get().getRenderOverview();
|
||||
Float pixelsPerTile = ro.getWorldMapZoom();
|
||||
|
||||
Point worldMapPosition = ro.getWorldMapPosition();
|
||||
int xWorldDiff = worldPoint.getX() - worldMapPosition.getX();
|
||||
int yWorldDiff = worldPoint.getY() - worldMapPosition.getY();
|
||||
yWorldDiff = -yWorldDiff;
|
||||
|
||||
Widget map = clientProvider.get().getWidget(WidgetInfo.WORLD_MAP_VIEW);
|
||||
if (map != null)
|
||||
{
|
||||
Rectangle worldMapRect = map.getBounds();
|
||||
int xGraphDiff = (int) (xWorldDiff * pixelsPerTile + worldMapRect.getWidth() / 2 + worldMapRect.getX());
|
||||
int yGraphDiff = (int) (yWorldDiff * pixelsPerTile + worldMapRect.getHeight() / 2 + worldMapRect.getY());
|
||||
|
||||
return new Point(xGraphDiff, yGraphDiff);
|
||||
}
|
||||
return new Point(0, 0);
|
||||
}
|
||||
|
||||
private void drawTooltip(Graphics2D graphics, WorldMapPoint worldPoint)
|
||||
{
|
||||
String tooltip = worldPoint.getTooltip();
|
||||
if (tooltip == null || tooltip.length() <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Point drawPoint = mapWorldPointToGraphicsPoint(worldPoint.getWorldPoint());
|
||||
drawPoint = new Point(drawPoint.getX() + TOOLTIP_OFFSET_WIDTH, drawPoint.getY() + TOOLTIP_OFFSET_HEIGHT);
|
||||
|
||||
graphics.setClip(0, 0, clientProvider.get().getCanvas().getWidth(), clientProvider.get().getCanvas().getHeight());
|
||||
graphics.setColor(TOOLTIP_BACKGROUND);
|
||||
graphics.setFont(FontManager.getRunescapeFont());
|
||||
FontMetrics fm = graphics.getFontMetrics();
|
||||
int width = fm.stringWidth(tooltip);
|
||||
int height = fm.getHeight();
|
||||
|
||||
Rectangle tooltipRect = new Rectangle(drawPoint.getX() - TOOLTIP_PADDING_WIDTH, drawPoint.getY() - TOOLTIP_PADDING_HEIGHT, width + TOOLTIP_PADDING_WIDTH * 2, height + TOOLTIP_PADDING_HEIGHT * 2);
|
||||
graphics.fillRect((int) tooltipRect.getX(), (int) tooltipRect.getY(), (int) tooltipRect.getWidth(), (int) tooltipRect.getHeight());
|
||||
|
||||
graphics.setColor(Color.black);
|
||||
graphics.drawRect((int) tooltipRect.getX(), (int) tooltipRect.getY(), (int) tooltipRect.getWidth(), (int) tooltipRect.getHeight());
|
||||
graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + height);
|
||||
}
|
||||
|
||||
private Point clipToRectangle(Point drawPoint, Rectangle mapDisplayRectangle)
|
||||
{
|
||||
int clippedX = drawPoint.getX();
|
||||
|
||||
if (drawPoint.getX() < mapDisplayRectangle.getX())
|
||||
{
|
||||
clippedX = (int) mapDisplayRectangle.getX();
|
||||
}
|
||||
|
||||
if (drawPoint.getX() > mapDisplayRectangle.getX() + mapDisplayRectangle.getWidth())
|
||||
{
|
||||
clippedX = (int) (mapDisplayRectangle.getX() + mapDisplayRectangle.getWidth());
|
||||
}
|
||||
|
||||
int clippedY = drawPoint.getY();
|
||||
|
||||
if (drawPoint.getY() < mapDisplayRectangle.getY())
|
||||
{
|
||||
clippedY = (int) mapDisplayRectangle.getY();
|
||||
}
|
||||
|
||||
if (drawPoint.getY() > mapDisplayRectangle.getY() + mapDisplayRectangle.getHeight())
|
||||
{
|
||||
clippedY = (int) (mapDisplayRectangle.getY() + mapDisplayRectangle.getHeight());
|
||||
}
|
||||
|
||||
return new Point(clippedX, clippedY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* 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.ui.overlay.worldmap;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.RenderOverview;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.input.MouseListener;
|
||||
|
||||
@Singleton
|
||||
public class WorldMapOverlayMouseListener extends MouseListener
|
||||
{
|
||||
private final Provider<Client> clientProvider;
|
||||
private final WorldMapPointManager worldMapPointManager;
|
||||
private WorldMapPoint tooltipPoint = null;
|
||||
|
||||
@Inject
|
||||
private WorldMapOverlayMouseListener(Provider<Client> clientProvider, WorldMapPointManager worldMapPointManager)
|
||||
{
|
||||
this.clientProvider = clientProvider;
|
||||
this.worldMapPointManager = worldMapPointManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MouseEvent mousePressed(MouseEvent e)
|
||||
{
|
||||
List<WorldMapPoint> worldMapPoints = worldMapPointManager.getWorldMapPoints();
|
||||
if (SwingUtilities.isLeftMouseButton(e) && !worldMapPoints.isEmpty())
|
||||
{
|
||||
Point mousePos = clientProvider.get().getMouseCanvasPosition();
|
||||
|
||||
for (WorldMapPoint worldMapPoint : worldMapPoints)
|
||||
{
|
||||
Rectangle clickbox = worldMapPoint.getClickbox();
|
||||
if (clickbox != null && clickbox.contains(mousePos.getX(), mousePos.getY()))
|
||||
{
|
||||
if (worldMapPoint.isJumpOnClick())
|
||||
{
|
||||
// jump map to position of point
|
||||
WorldPoint target = worldMapPoint.getWorldPoint();
|
||||
Client client = clientProvider.get();
|
||||
RenderOverview renderOverview = client.getRenderOverview();
|
||||
renderOverview.setWorldMapPositionTarget(target);
|
||||
}
|
||||
return worldMapPoint.onClick(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MouseEvent mouseMoved(MouseEvent mouseEvent)
|
||||
{
|
||||
List<WorldMapPoint> worldMapPoints = worldMapPointManager.getWorldMapPoints();
|
||||
if (worldMapPoints.isEmpty())
|
||||
{
|
||||
return mouseEvent;
|
||||
}
|
||||
|
||||
final Client client = clientProvider.get();
|
||||
final Point mousePos = client.getMouseCanvasPosition();
|
||||
final Widget view = client.getWidget(WidgetInfo.WORLD_MAP_VIEW);
|
||||
|
||||
if (view == null)
|
||||
{
|
||||
return mouseEvent;
|
||||
}
|
||||
|
||||
final Rectangle worldMapDisplay = view.getBounds();
|
||||
|
||||
if (worldMapDisplay == null || !worldMapDisplay.contains(mousePos.getX(), mousePos.getY()))
|
||||
{
|
||||
if (tooltipPoint != null)
|
||||
{
|
||||
tooltipPoint.setTooltipVisible(false);
|
||||
tooltipPoint = null;
|
||||
final Widget rsTooltip = client.getWidget(WidgetInfo.WORLD_MAP_TOOLTIP);
|
||||
if (rsTooltip != null)
|
||||
{
|
||||
rsTooltip.setHidden(false);
|
||||
}
|
||||
}
|
||||
return mouseEvent;
|
||||
}
|
||||
|
||||
if (tooltipPoint != null)
|
||||
{
|
||||
if (tooltipPoint.getClickbox() != null
|
||||
&& tooltipPoint.getClickbox().contains(mousePos.getX(), mousePos.getY()))
|
||||
{
|
||||
return mouseEvent;
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltipPoint.setTooltipVisible(false);
|
||||
tooltipPoint = null;
|
||||
final Widget rsTooltip = client.getWidget(WidgetInfo.WORLD_MAP_TOOLTIP);
|
||||
if (rsTooltip != null)
|
||||
{
|
||||
rsTooltip.setHidden(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldMapPoint worldMapPoint : worldMapPointManager.getWorldMapPoints())
|
||||
{
|
||||
if (worldMapPoint.getClickbox() != null
|
||||
&& worldMapPoint.getClickbox().contains(mousePos.getX(), mousePos.getY())
|
||||
&& worldMapPoint.getTooltip() != null)
|
||||
{
|
||||
worldMapPoint.setTooltipVisible(true);
|
||||
tooltipPoint = worldMapPoint;
|
||||
final Widget rsTooltip = client.getWidget(WidgetInfo.WORLD_MAP_TOOLTIP);
|
||||
if (rsTooltip != null)
|
||||
{
|
||||
rsTooltip.setHidden(true);
|
||||
}
|
||||
return mouseEvent;
|
||||
}
|
||||
}
|
||||
return mouseEvent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* 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.ui.overlay.worldmap;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import lombok.Data;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
@Data
|
||||
public class WorldMapPoint
|
||||
{
|
||||
private BufferedImage image;
|
||||
|
||||
private WorldPoint worldPoint;
|
||||
|
||||
/**
|
||||
* The point on the image that will be drawn at WorldPoint
|
||||
* WorldMapPointManager will center the image if imagePoint is null
|
||||
*/
|
||||
private Point imagePoint;
|
||||
|
||||
private Rectangle clickbox;
|
||||
|
||||
private boolean snapToEdge;
|
||||
|
||||
private boolean currentlyEdgeSnapped;
|
||||
|
||||
/**
|
||||
* Whether or not the map jumps to worldPoint when the overlay is clicked
|
||||
*/
|
||||
private boolean jumpOnClick;
|
||||
|
||||
private boolean tooltipVisible;
|
||||
|
||||
private String tooltip;
|
||||
|
||||
public WorldMapPoint(WorldPoint worldPoint, BufferedImage image)
|
||||
{
|
||||
this.worldPoint = worldPoint;
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public MouseEvent onClick(MouseEvent e)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
|
||||
public void onEdgeSnap()
|
||||
{
|
||||
}
|
||||
|
||||
public void onEdgeUnsnap()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* 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.ui.overlay.worldmap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
|
||||
@Singleton
|
||||
public class WorldMapPointManager
|
||||
{
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final List<WorldMapPoint> worldMapPoints = new ArrayList<>();
|
||||
|
||||
public void add(WorldMapPoint worldMapPoint)
|
||||
{
|
||||
worldMapPoints.add(worldMapPoint);
|
||||
}
|
||||
|
||||
public void remove(WorldMapPoint worldMapPoint)
|
||||
{
|
||||
worldMapPoints.remove(worldMapPoint);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 368 B |
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* 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.mixins;
|
||||
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.rs.api.RSRenderOverview;
|
||||
import net.runelite.rs.api.RSWorldMapManager;
|
||||
|
||||
@Mixin(RSRenderOverview.class)
|
||||
public abstract class WorldMapMixin implements RSRenderOverview
|
||||
{
|
||||
@Override
|
||||
@Inject
|
||||
public Point getWorldMapPosition()
|
||||
{
|
||||
RSWorldMapManager worldMapManager = getWorldMapManager();
|
||||
int worldX = getWorldMapX() + worldMapManager.getSurfaceOffsetX();
|
||||
int worldY = getWorldMapY() + worldMapManager.getSurfaceOffsetY();
|
||||
return new Point(worldX, worldY);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setWorldMapPositionTarget(WorldPoint worldPoint)
|
||||
{
|
||||
setWorldMapPositionTarget(worldPoint.getX(), worldPoint.getY());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,39 @@ import net.runelite.mapping.Import;
|
||||
|
||||
public interface RSRenderOverview extends RenderOverview
|
||||
{
|
||||
@Import("worldMapX")
|
||||
int getWorldMapX();
|
||||
|
||||
@Import("worldMapY")
|
||||
int getWorldMapY();
|
||||
|
||||
@Import("worldMapZoom")
|
||||
float getWorldMapZoom();
|
||||
|
||||
@Import("worldMapTargetX")
|
||||
int getWorldMapTargetX();
|
||||
|
||||
@Import("worldMapTargetY")
|
||||
int getWorldMapTargetY();
|
||||
|
||||
@Import("worldMapDisplayWidth")
|
||||
int getWorldMapDisplayWidth();
|
||||
|
||||
@Import("worldMapDisplayHeight")
|
||||
int getWorldMapDisplayHeight();
|
||||
|
||||
@Import("worldMapDisplayX")
|
||||
int getWorldMapDisplayX();
|
||||
|
||||
@Import("worldMapDisplayY")
|
||||
int getWorldMapDisplayY();
|
||||
|
||||
@Import("setWorldMapPosition")
|
||||
void setWorldMapPosition(int worldMapX, int worldMapY, boolean changedSurface);
|
||||
|
||||
@Import("setWorldMapPositionTarget")
|
||||
void setWorldMapPositionTarget(int worldPointX, int worldPointY);
|
||||
|
||||
@Import("worldMapManager")
|
||||
@Override
|
||||
RSWorldMapManager getWorldMapManager();
|
||||
|
||||
@@ -32,4 +32,10 @@ public interface RSWorldMapManager extends WorldMapManager
|
||||
@Import("loaded")
|
||||
@Override
|
||||
boolean isLoaded();
|
||||
|
||||
@Import("mapSurfaceBaseOffsetX")
|
||||
int getSurfaceOffsetX();
|
||||
|
||||
@Import("mapSurfaceBaseOffsetY")
|
||||
int getSurfaceOffsetY();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user