Skip to content

Commit

Permalink
devtools: cleanup location overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Jan 25, 2024
1 parent 861d20b commit dcea566
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;

public class CameraOverlay extends OverlayPanel
{
Expand All @@ -54,23 +53,15 @@ public Dimension render(Graphics2D graphics)
return null;
}

panelComponent.getChildren().add(TitleComponent.builder()
.text("Camera")
.build());

panelComponent.getChildren().add(LineComponent.builder()
.left("X")
.right("" + client.getCameraX())
.build());
panelComponent.setPreferredSize(new Dimension(175, 0));

panelComponent.getChildren().add(LineComponent.builder()
.left("Y")
.right("" + client.getCameraY())
.build());
int camX = client.getCameraX();
int camY = client.getCameraZ();
int camZ = client.getCameraY();

panelComponent.getChildren().add(LineComponent.builder()
.left("Z")
.right("" + client.getCameraZ())
.left("Camera")
.right(camX + ", " + camY + ", " + camZ)
.build());

panelComponent.getChildren().add(LineComponent.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,12 @@ private void renderTileTooltip(Graphics2D graphics, Tile tile)
Polygon poly = Perspective.getCanvasTilePoly(client, tileLocalLocation);
if (poly != null && poly.contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY()))
{
WorldPoint worldLocation = tile.getWorldLocation();
Point sceneLocation = tile.getSceneLocation();
WorldPoint worldLocation = WorldPoint.fromLocalInstance(client, tileLocalLocation);
byte flags = client.getTileSettings()[tile.getRenderLevel()][tile.getSceneLocation().getX()][tile.getSceneLocation().getY()];
String tooltip = String.format("World location: %d, %d, %d</br>" +
"Scene location: %d, %d</br>" +
"Region ID: %d location: %d, %d",
"Flags: %d",
worldLocation.getX(), worldLocation.getY(), worldLocation.getPlane(),
sceneLocation.getX(), sceneLocation.getY(),
(client.isInInstancedRegion() ? WorldPoint.fromLocalInstance(client, tileLocalLocation).getRegionID() : worldLocation.getRegionID()), worldLocation.getRegionX(), worldLocation.getRegionY());
flags);
toolTipManager.add(new Tooltip(tooltip));
OverlayUtil.renderPolygon(graphics, poly, GREEN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.inject.Inject;
import net.runelite.api.Client;
import static net.runelite.api.Constants.CHUNK_SIZE;
import static net.runelite.api.Constants.SCENE_SIZE;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.ui.overlay.OverlayPanel;
Expand Down Expand Up @@ -57,61 +58,80 @@ public Dimension render(Graphics2D graphics)
return null;
}

WorldPoint localWorld = client.getLocalPlayer().getWorldLocation();
WorldPoint worldPoint = client.getLocalPlayer().getWorldLocation();
LocalPoint localPoint = client.getLocalPlayer().getLocalLocation();

int regionID = localWorld.getRegionID();

if (client.isInInstancedRegion())
{
regionID = WorldPoint.fromLocalInstance(client, localPoint).getRegionID();
worldPoint = WorldPoint.fromLocalInstance(client, localPoint);

panelComponent.getChildren().add(LineComponent.builder()
.left("Instance")
.build());

int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks();
int z = client.getPlane();
int chunkData = instanceTemplateChunks[z][localPoint.getSceneX() / CHUNK_SIZE][localPoint.getSceneY() / CHUNK_SIZE];

int rotation = chunkData >> 1 & 0x3;
int chunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE;
int chunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE;

panelComponent.getChildren().add(LineComponent.builder()
.left("Chunk " + localPoint.getSceneX() / CHUNK_SIZE + "," + localPoint.getSceneY() / CHUNK_SIZE)
.right(rotation + " " + chunkX + " " + chunkY)
.build());
}

panelComponent.getChildren().add(LineComponent.builder()
.left("Base")
.right(client.getBaseX() + ", " + client.getBaseY())
.build());

panelComponent.getChildren().add(LineComponent.builder()
.left("Local")
.right(localPoint.getX() + ", " + localPoint.getY())
.build());
.left("Local")
.right(localPoint.getX() + ", " + localPoint.getY())
.build());

panelComponent.getChildren().add(LineComponent.builder()
.left("Scene")
.right(localPoint.getSceneX() + ", " + localPoint.getSceneY())
.build());
.left("World")
.right(worldPoint.getX() + ", " + worldPoint.getY() + ", " + client.getPlane())
.build());

panelComponent.getChildren().add(LineComponent.builder()
.left("Tile")
.right(localWorld.getX() + ", " + localWorld.getY() + ", " + client.getPlane())
.left("Scene")
.right(localPoint.getSceneX() + ", " + localPoint.getSceneY())
.build());

if (client.isInInstancedRegion())
{
int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks();
int z = client.getPlane();
for (int cy = 0; cy < SCENE_SIZE / CHUNK_SIZE; ++cy)
{
for (int cx = 0; cx < SCENE_SIZE / CHUNK_SIZE; ++cx)
{
int chunkData = instanceTemplateChunks[z][cx][cy];

if (chunkData == -1)
{
continue;
}

int rotation = chunkData >> 1 & 0x3; // NOPMD
int chunkY = (chunkData >> 3 & 0x7FF);
int chunkX = (chunkData >> 14 & 0x3FF);
int chunkPlane = chunkData >> 24 & 0x3;

boolean myChunk = cx == localPoint.getSceneX() / CHUNK_SIZE && cy == localPoint.getSceneY() / CHUNK_SIZE;
panelComponent.getChildren().add(LineComponent.builder()
.left("Chunk")
.right(chunkX + ", " + chunkY + ", " + chunkPlane)
.rightColor(myChunk ? Color.GREEN : Color.WHITE)
.build());
}
}
}
else
{
panelComponent.getChildren().add(LineComponent.builder()
.left("Base")
.right(client.getBaseX() + ", " + client.getBaseY())
.build());
}

for (int i = 0; i < client.getMapRegions().length; i++)
{
int region = client.getMapRegions()[i];
int mx = region >> 8;
int my = region & 0xff;

panelComponent.getChildren().add(LineComponent.builder()
.left((i == 0) ? "Map regions" : " ")
.right(String.valueOf(region))
.rightColor((region == regionID) ? Color.GREEN : Color.WHITE)
.right(mx + ", " + my)
.rightColor((region == worldPoint.getRegionID()) ? Color.GREEN : Color.WHITE)
.build());
}

Expand Down

0 comments on commit dcea566

Please sign in to comment.