|
|
|
|
@@ -52,6 +52,7 @@ import net.runelite.api.events.MenuEntryAdded;
|
|
|
|
|
import net.runelite.api.events.MenuOptionClicked;
|
|
|
|
|
import net.runelite.client.config.ConfigManager;
|
|
|
|
|
import net.runelite.client.eventbus.Subscribe;
|
|
|
|
|
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
|
|
|
|
import net.runelite.client.input.KeyManager;
|
|
|
|
|
import net.runelite.client.plugins.Plugin;
|
|
|
|
|
import net.runelite.client.plugins.PluginDescriptor;
|
|
|
|
|
@@ -68,6 +69,7 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
private static final String CONFIG_GROUP = "groundMarker";
|
|
|
|
|
private static final String MARK = "Mark tile";
|
|
|
|
|
private static final String UNMARK = "Unmark tile";
|
|
|
|
|
private static final String LABEL = "Label tile";
|
|
|
|
|
private static final String WALK_HERE = "Walk here";
|
|
|
|
|
private static final String REGION_PREFIX = "region_";
|
|
|
|
|
|
|
|
|
|
@@ -97,6 +99,9 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
@Inject
|
|
|
|
|
private KeyManager keyManager;
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
private ChatboxPanelManager chatboxPanelManager;
|
|
|
|
|
|
|
|
|
|
private void savePoints(int regionId, Collection<GroundMarkerPoint> points)
|
|
|
|
|
{
|
|
|
|
|
if (points == null || points.isEmpty())
|
|
|
|
|
@@ -166,15 +171,31 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
return points.stream()
|
|
|
|
|
.map(point -> new ColorTileMarker(
|
|
|
|
|
WorldPoint.fromRegion(point.getRegionId(), point.getRegionX(), point.getRegionY(), point.getZ()),
|
|
|
|
|
point.getColor()))
|
|
|
|
|
point.getColor(), point.getLabel()))
|
|
|
|
|
.flatMap(colorTile ->
|
|
|
|
|
{
|
|
|
|
|
final Collection<WorldPoint> localWorldPoints = WorldPoint.toLocalInstance(client, colorTile.getWorldPoint());
|
|
|
|
|
return localWorldPoints.stream().map(wp -> new ColorTileMarker(wp, colorTile.getColor()));
|
|
|
|
|
return localWorldPoints.stream().map(wp -> new ColorTileMarker(wp, colorTile.getColor(), colorTile.getLabel()));
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void startUp()
|
|
|
|
|
{
|
|
|
|
|
overlayManager.add(overlay);
|
|
|
|
|
overlayManager.add(minimapOverlay);
|
|
|
|
|
loadPoints();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void shutDown()
|
|
|
|
|
{
|
|
|
|
|
overlayManager.remove(overlay);
|
|
|
|
|
overlayManager.remove(minimapOverlay);
|
|
|
|
|
points.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Subscribe
|
|
|
|
|
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
|
|
|
|
{
|
|
|
|
|
@@ -200,17 +221,26 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
|
|
|
|
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
|
|
|
|
|
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
|
|
|
|
|
|
|
|
|
final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, selectedSceneTile.getLocalLocation());
|
|
|
|
|
final int regionId = worldPoint.getRegionID();
|
|
|
|
|
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor());
|
|
|
|
|
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
|
|
|
|
final boolean exists = getPoints(regionId).contains(point);
|
|
|
|
|
|
|
|
|
|
menuEntry.setOption(getPoints(regionId).contains(point) ? UNMARK : MARK);
|
|
|
|
|
menuEntry.setTarget(event.getTarget());
|
|
|
|
|
menuEntry.setType(MenuAction.RUNELITE.getId());
|
|
|
|
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
|
|
|
|
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + (exists ? 2 : 1));
|
|
|
|
|
|
|
|
|
|
MenuEntry mark = menuEntries[menuEntries.length - 1] = new MenuEntry();
|
|
|
|
|
mark.setOption(exists ? UNMARK : MARK);
|
|
|
|
|
mark.setTarget(event.getTarget());
|
|
|
|
|
mark.setType(MenuAction.RUNELITE.getId());
|
|
|
|
|
|
|
|
|
|
if (exists)
|
|
|
|
|
{
|
|
|
|
|
MenuEntry label = menuEntries[menuEntries.length - 2] = new MenuEntry();
|
|
|
|
|
label.setOption(LABEL);
|
|
|
|
|
label.setTarget(event.getTarget());
|
|
|
|
|
label.setType(MenuAction.RUNELITE.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client.setMenuEntries(menuEntries);
|
|
|
|
|
}
|
|
|
|
|
@@ -219,8 +249,7 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
@Subscribe
|
|
|
|
|
public void onMenuOptionClicked(MenuOptionClicked event)
|
|
|
|
|
{
|
|
|
|
|
if (event.getMenuAction().getId() != MenuAction.RUNELITE.getId() ||
|
|
|
|
|
!(event.getMenuOption().equals(MARK) || event.getMenuOption().equals(UNMARK)))
|
|
|
|
|
if (event.getMenuAction().getId() != MenuAction.RUNELITE.getId())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -230,23 +259,16 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
markTile(target.getLocalLocation());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void startUp()
|
|
|
|
|
{
|
|
|
|
|
overlayManager.add(overlay);
|
|
|
|
|
overlayManager.add(minimapOverlay);
|
|
|
|
|
loadPoints();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void shutDown()
|
|
|
|
|
{
|
|
|
|
|
overlayManager.remove(overlay);
|
|
|
|
|
overlayManager.remove(minimapOverlay);
|
|
|
|
|
points.clear();
|
|
|
|
|
final String option = event.getMenuOption();
|
|
|
|
|
if (option.equals(MARK) || option.equals(UNMARK))
|
|
|
|
|
{
|
|
|
|
|
markTile(target.getLocalLocation());
|
|
|
|
|
}
|
|
|
|
|
else if (option.equals(LABEL))
|
|
|
|
|
{
|
|
|
|
|
labelTile(target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void markTile(LocalPoint localPoint)
|
|
|
|
|
@@ -259,7 +281,7 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
|
|
|
|
|
|
|
|
|
int regionId = worldPoint.getRegionID();
|
|
|
|
|
GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor());
|
|
|
|
|
GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor(), null);
|
|
|
|
|
log.debug("Updating point: {} - {}", point, worldPoint);
|
|
|
|
|
|
|
|
|
|
List<GroundMarkerPoint> groundMarkerPoints = new ArrayList<>(getPoints(regionId));
|
|
|
|
|
@@ -276,4 +298,35 @@ public class GroundMarkerPlugin extends Plugin
|
|
|
|
|
|
|
|
|
|
loadPoints();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void labelTile(Tile tile)
|
|
|
|
|
{
|
|
|
|
|
LocalPoint localPoint = tile.getLocalLocation();
|
|
|
|
|
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
|
|
|
|
final int regionId = worldPoint.getRegionID();
|
|
|
|
|
|
|
|
|
|
chatboxPanelManager.openTextInput("Tile label")
|
|
|
|
|
.onDone((input) ->
|
|
|
|
|
{
|
|
|
|
|
input = Strings.emptyToNull(input);
|
|
|
|
|
|
|
|
|
|
GroundMarkerPoint searchPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
|
|
|
|
Collection<GroundMarkerPoint> points = getPoints(regionId);
|
|
|
|
|
GroundMarkerPoint existing = points.stream()
|
|
|
|
|
.filter(p -> p.equals(searchPoint))
|
|
|
|
|
.findFirst().orElse(null);
|
|
|
|
|
if (existing == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GroundMarkerPoint newPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), existing.getColor(), input);
|
|
|
|
|
points.remove(searchPoint);
|
|
|
|
|
points.add(newPoint);
|
|
|
|
|
savePoints(regionId, points);
|
|
|
|
|
|
|
|
|
|
loadPoints();
|
|
|
|
|
})
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|