add wilderness level lines to multiindicators plugin (also remove collision filter toggle) (#739)

* testing

* add wilderness level lines to multiindicators plugin

* remove test file

* fix checkstyle violation
This commit is contained in:
Enza-Denino
2019-06-25 00:35:29 -05:00
committed by James
parent 2006f52219
commit 7a740fa91f
6 changed files with 161 additions and 38 deletions

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, Woox <https://github.com/wooxsolo> * Copyright (c) 2018, Woox <https://github.com/wooxsolo>
* Copyright (c) 2019, Enza-Denino <https://github.com/Enza-Denino>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -34,11 +35,12 @@ import net.runelite.api.Constants;
public class MapLocations public class MapLocations
{ {
private static final List<Shape>[] MULTICOMBAT = new List[Constants.MAX_Z]; private static final List<Shape>[] MULTICOMBAT = new List[Constants.MAX_Z];
private static final List<Shape>[] NOT_MULTICOMBAT = new List[Constants.MAX_Z]; private static final List<Shape>[] NOT_MULTICOMBAT = new List[Constants.MAX_Z];
private static final List<Shape>[] ROUGH_WILDERNESS = new List[Constants.MAX_Z]; private static final List<Shape>[] ROUGH_WILDERNESS = new List[Constants.MAX_Z];
private static final List<Shape>[] DEADMAN_SAFE_ZONES = new List[Constants.MAX_Z]; private static final List<Shape>[] WILDERNESS_LEVEL_LINES = new List[Constants.MAX_Z];
private static final List<Shape>[] PVP_WORLD_SAFE_ZONES = new List[Constants.MAX_Z]; private static final List<Shape>[] DEADMAN_SAFE_ZONES = new List[Constants.MAX_Z];
private static final List<Shape>[] PVP_WORLD_SAFE_ZONES = new List[Constants.MAX_Z];
private static Area getArea(List<Shape> shapes) private static Area getArea(List<Shape> shapes)
{ {
@@ -87,6 +89,16 @@ public class MapLocations
return getArea(ROUGH_WILDERNESS[plane], view); return getArea(ROUGH_WILDERNESS[plane], view);
} }
public static Area getWildernessLevelLines(int plane)
{
return getArea(WILDERNESS_LEVEL_LINES[plane]);
}
public static Area getWildernessLevelLines(Rectangle view, int plane)
{
return getArea(WILDERNESS_LEVEL_LINES[plane], view);
}
public static Area getDeadmanSafeZones(int plane) public static Area getDeadmanSafeZones(int plane)
{ {
return getArea(DEADMAN_SAFE_ZONES[plane]); return getArea(DEADMAN_SAFE_ZONES[plane]);
@@ -107,33 +119,28 @@ public class MapLocations
return getArea(PVP_WORLD_SAFE_ZONES[plane], view); return getArea(PVP_WORLD_SAFE_ZONES[plane], view);
} }
private static void initializeWithEmptyLists(List<Shape>[] array)
{
for (int i = 0; i < array.length; i++)
{
array[i] = new ArrayList<>();
}
}
static static
{ {
for (int i = 0; i < MULTICOMBAT.length; i++) initializeWithEmptyLists(MULTICOMBAT);
{ initializeWithEmptyLists(NOT_MULTICOMBAT);
MULTICOMBAT[i] = new ArrayList<>(); initializeWithEmptyLists(ROUGH_WILDERNESS);
} initializeWithEmptyLists(WILDERNESS_LEVEL_LINES);
for (int i = 0; i < NOT_MULTICOMBAT.length; i++) initializeWithEmptyLists(DEADMAN_SAFE_ZONES);
{ initializeWithEmptyLists(PVP_WORLD_SAFE_ZONES);
NOT_MULTICOMBAT[i] = new ArrayList<>();
}
for (int i = 0; i < ROUGH_WILDERNESS.length; i++)
{
ROUGH_WILDERNESS[i] = new ArrayList<>();
}
for (int i = 0; i < DEADMAN_SAFE_ZONES.length; i++)
{
DEADMAN_SAFE_ZONES[i] = new ArrayList<>();
}
for (int i = 0; i < PVP_WORLD_SAFE_ZONES.length; i++)
{
PVP_WORLD_SAFE_ZONES[i] = new ArrayList<>();
}
defineMulticombatAreas(); defineMulticombatAreas();
defineDeadmanSafeZones(); defineDeadmanSafeZones();
definePvpSafeZones(); definePvpSafeZones();
defineWilderness(); defineWilderness();
defineWildernessLevelLines();
} }
private static void defineMulticombatAreas() private static void defineMulticombatAreas()
@@ -3441,6 +3448,33 @@ public class MapLocations
3264, 9918); 3264, 9918);
} }
private static void defineWildernessLevelLines()
{
int wildyLeftX = 2944;
int wildyRightX = 3392;
int wildyBottomY = 3525;
int wildyTopY = 3971;
// define wilderness level lines at ground level
int accumulatedY = 0;
for (int level = 1; level <= 56; level++)
{
int levelTiles = level == 1 ? 3 : 8;
// only draw every 2 levels, otherwise lines on two adjacent levels will collide
// and it will not show up
if (level % 2 != 0)
{
addPolygonTo(WILDERNESS_LEVEL_LINES,
wildyLeftX, wildyBottomY + accumulatedY,
wildyRightX, wildyBottomY + accumulatedY,
wildyRightX, wildyBottomY + accumulatedY + levelTiles,
wildyLeftX, wildyBottomY + accumulatedY + levelTiles);
}
accumulatedY += levelTiles;
}
}
private static void addPolygonTo(List<Shape>[] shapes, int... coords) private static void addPolygonTo(List<Shape>[] shapes, int... coords)
{ {
Polygon poly = new Polygon(); Polygon poly = new Polygon();
@@ -3476,4 +3510,4 @@ public class MapLocations
shapes[i].add(poly); shapes[i].add(poly);
} }
} }
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, Woox <https://github.com/wooxsolo> * Copyright (c) 2018, Woox <https://github.com/wooxsolo>
* Copyright (c) 2019, Enza-Denino <https://github.com/Enza-Denino>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -66,14 +67,14 @@ public interface MultiIndicatorsConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "collisionDetection", keyName = "wildernessLevelLines",
name = "Collision detection", name = "Wilderness level lines",
description = "Only show lines where they can be walked through", description = "Show wilderness level lines",
position = 4 position = 4
) )
default boolean collisionDetection() default boolean showWildernessLevelLines()
{ {
return false; return true;
} }
@ConfigItem( @ConfigItem(
@@ -108,4 +109,16 @@ public interface MultiIndicatorsConfig extends Config
{ {
return Color.GREEN; return Color.GREEN;
} }
@ConfigItem(
keyName = "wildernessLevelLinesColor",
name = "Wilderness level lines color",
description = "Choose color to use for marking wilderness level lines",
position = 8
)
default Color wildernessLevelLinesColor()
{
return Color.WHITE;
}
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, Woox <https://github.com/wooxsolo> * Copyright (c) 2018, Woox <https://github.com/wooxsolo>
* Copyright (c) 2019, Enza-Denino <https://github.com/Enza-Denino>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -102,6 +103,7 @@ public class MultiIndicatorsMinimapOverlay extends Overlay
GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()]; GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()];
GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()]; GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()];
GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()];
if (config.multicombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null) if (config.multicombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null)
{ {
@@ -111,6 +113,10 @@ public class MultiIndicatorsMinimapOverlay extends Overlay
{ {
renderPath(graphics, pvpPath, getTransparentColorVersion(config.safeZoneColor())); renderPath(graphics, pvpPath, getTransparentColorVersion(config.safeZoneColor()));
} }
if (config.showWildernessLevelLines() && wildernessLevelLinesPath != null)
{
renderPath(graphics, wildernessLevelLinesPath, getTransparentColorVersion(config.wildernessLevelLinesColor()));
}
return null; return null;
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, Woox <https://github.com/wooxsolo> * Copyright (c) 2018, Woox <https://github.com/wooxsolo>
* Copyright (c) 2019, Enza-Denino <https://github.com/Enza-Denino>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -98,6 +99,7 @@ public class MultiIndicatorsOverlay extends Overlay
{ {
GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()]; GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()];
GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()]; GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()];
GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()];
if (config.multicombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null) if (config.multicombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null)
{ {
@@ -107,6 +109,10 @@ public class MultiIndicatorsOverlay extends Overlay
{ {
renderPath(graphics, pvpPath, getTransparentColorVersion(config.safeZoneColor())); renderPath(graphics, pvpPath, getTransparentColorVersion(config.safeZoneColor()));
} }
if (config.showWildernessLevelLines() && wildernessLevelLinesPath != null)
{
renderPath(graphics, wildernessLevelLinesPath, getTransparentColorVersion(config.wildernessLevelLinesColor()));
}
return null; return null;
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, Woox <https://github.com/wooxsolo> * Copyright (c) 2018, Woox <https://github.com/wooxsolo>
* Copyright (c) 2019, Enza-Denino <https://github.com/Enza-Denino>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -27,6 +28,7 @@ package net.runelite.client.plugins.multiindicators;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.GeneralPath; import java.awt.geom.GeneralPath;
import java.time.temporal.ChronoUnit;
import java.util.Arrays; import java.util.Arrays;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
@@ -50,6 +52,7 @@ import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
import net.runelite.client.task.Schedule;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@PluginDescriptor( @PluginDescriptor(
@@ -86,6 +89,9 @@ public class MultiIndicatorsPlugin extends Plugin
@Getter @Getter
private GeneralPath[] pvpPathToDisplay; private GeneralPath[] pvpPathToDisplay;
@Getter
private GeneralPath[] wildernessLevelLinesPathToDisplay;
@Getter @Getter
private boolean inPvp; private boolean inPvp;
@@ -106,8 +112,7 @@ public class MultiIndicatorsPlugin extends Plugin
overlayManager.add(overlay); overlayManager.add(overlay);
overlayManager.add(minimapOverlay); overlayManager.add(minimapOverlay);
multicombatPathToDisplay = new GeneralPath[Constants.MAX_Z]; initializePaths();
pvpPathToDisplay = new GeneralPath[Constants.MAX_Z];
clientThread.invokeLater(() -> clientThread.invokeLater(() ->
{ {
@@ -124,8 +129,37 @@ public class MultiIndicatorsPlugin extends Plugin
overlayManager.remove(overlay); overlayManager.remove(overlay);
overlayManager.remove(minimapOverlay); overlayManager.remove(minimapOverlay);
uninitializePaths();
}
private void initializePaths()
{
multicombatPathToDisplay = new GeneralPath[Constants.MAX_Z];
pvpPathToDisplay = new GeneralPath[Constants.MAX_Z];
wildernessLevelLinesPathToDisplay = new GeneralPath[Constants.MAX_Z];
}
private void uninitializePaths()
{
multicombatPathToDisplay = null; multicombatPathToDisplay = null;
pvpPathToDisplay = null; pvpPathToDisplay = null;
wildernessLevelLinesPathToDisplay = null;
}
// sometimes the lines get offset (seems to happen when there is a delay
// due to map reloading when walking/running "Loading - please wait")
// resetting the lines generation logic fixes this
@Schedule(
period = 1800,
unit = ChronoUnit.MILLIS
)
public void update()
{
if (client.getGameState() == GameState.LOGGED_IN)
{
findLinesInScene();
}
} }
private void transformWorldToLocal(float[] coords) private void transformWorldToLocal(float[] coords)
@@ -134,7 +168,6 @@ public class MultiIndicatorsPlugin extends Plugin
coords[0] = lp.getX() - Perspective.LOCAL_TILE_SIZE / 2; coords[0] = lp.getX() - Perspective.LOCAL_TILE_SIZE / 2;
coords[1] = lp.getY() - Perspective.LOCAL_TILE_SIZE / 2; coords[1] = lp.getY() - Perspective.LOCAL_TILE_SIZE / 2;
} }
private boolean isOpenableAt(WorldPoint wp) private boolean isOpenableAt(WorldPoint wp)
{ {
int sceneX = wp.getX() - client.getBaseX(); int sceneX = wp.getX() - client.getBaseX();
@@ -153,6 +186,7 @@ public class MultiIndicatorsPlugin extends Plugin
} }
ObjectDefinition objectComposition = client.getObjectDefinition(wallObject.getId()); ObjectDefinition objectComposition = client.getObjectDefinition(wallObject.getId());
if (objectComposition == null) if (objectComposition == null)
{ {
return false; return false;
@@ -240,7 +274,7 @@ public class MultiIndicatorsPlugin extends Plugin
lines = Geometry.clipPath(lines, MapLocations.getRoughWilderness(i)); lines = Geometry.clipPath(lines, MapLocations.getRoughWilderness(i));
} }
lines = Geometry.splitIntoSegments(lines, 1); lines = Geometry.splitIntoSegments(lines, 1);
if (config.collisionDetection()) if (useCollisionLogic())
{ {
lines = Geometry.filterPath(lines, this::collisionFilter); lines = Geometry.filterPath(lines, this::collisionFilter);
} }
@@ -267,7 +301,7 @@ public class MultiIndicatorsPlugin extends Plugin
{ {
safeZonePath = Geometry.clipPath(safeZonePath, sceneRect); safeZonePath = Geometry.clipPath(safeZonePath, sceneRect);
safeZonePath = Geometry.splitIntoSegments(safeZonePath, 1); safeZonePath = Geometry.splitIntoSegments(safeZonePath, 1);
if (config.collisionDetection()) if (useCollisionLogic())
{ {
safeZonePath = Geometry.filterPath(safeZonePath, this::collisionFilter); safeZonePath = Geometry.filterPath(safeZonePath, this::collisionFilter);
} }
@@ -275,6 +309,35 @@ public class MultiIndicatorsPlugin extends Plugin
} }
pvpPathToDisplay[i] = safeZonePath; pvpPathToDisplay[i] = safeZonePath;
} }
// Generate wilderness level lines
for (int i = 0; i < wildernessLevelLinesPathToDisplay.length; i++)
{
currentPlane = i;
GeneralPath wildernessLevelLinesPath = null;
if (config.showWildernessLevelLines())
{
wildernessLevelLinesPath = new GeneralPath(MapLocations.getWildernessLevelLines(sceneRect, i));
}
if (wildernessLevelLinesPath != null)
{
wildernessLevelLinesPath = Geometry.clipPath(wildernessLevelLinesPath, sceneRect);
wildernessLevelLinesPath = Geometry.splitIntoSegments(wildernessLevelLinesPath, 1);
if (useCollisionLogic())
{
wildernessLevelLinesPath = Geometry.filterPath(wildernessLevelLinesPath, this::collisionFilter);
}
wildernessLevelLinesPath = Geometry.transformPath(wildernessLevelLinesPath, this::transformWorldToLocal);
}
wildernessLevelLinesPathToDisplay[i] = wildernessLevelLinesPath;
}
}
private boolean useCollisionLogic()
{
// currently prevents overlay lines from showing up if this is ever enabled right now
return false;
} }
@Subscribe @Subscribe
@@ -283,7 +346,8 @@ public class MultiIndicatorsPlugin extends Plugin
if (event.getKey().equals("collisionDetection") || if (event.getKey().equals("collisionDetection") ||
event.getKey().equals("multicombatZoneVisibility") || event.getKey().equals("multicombatZoneVisibility") ||
event.getKey().equals("deadmanSafeZones") || event.getKey().equals("deadmanSafeZones") ||
event.getKey().equals("pvpSafeZones")) event.getKey().equals("pvpSafeZones") ||
event.getKey().equals("wildernessLevelLines"))
{ {
findLinesInScene(); findLinesInScene();
} }

View File

@@ -40,4 +40,4 @@ public enum ZoneVisibility
{ {
return visibility; return visibility;
} }
} }