Skip to content

Commit

Permalink
maybe add point menu entry, idk
Browse files Browse the repository at this point in the history
Signed-off-by: Ron Young <[email protected]>
  • Loading branch information
raiyni committed May 1, 2024
1 parent 1f3a816 commit cf7ebb9
Showing 1 changed file with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ protected void onClientTick(ClientTick t)
lastHoveredOverlay = curHoveredOverlay;

final Overlay overlay = curHoveredOverlay;

if (overlay == null || client.isMenuOpen() )
{
return;
Expand All @@ -204,6 +205,17 @@ protected void onClientTick(ClientTick t)
.setOption("Reset")
.setTarget((ColorUtil.wrapWithColorTag("Overlay", JagexColors.MENU_TARGET)))
.onClick(e -> overlayManager.resetOverlay(overlay));
return;
}

if (inOverlayDraggingMode && currentManagedOverlay == null && !client.isMenuOpen())
{
log.debug("open this shit");
client.createMenuEntry(-1)
.setOption("Add snap point")
.setTarget((ColorUtil.wrapWithColorTag("Overlay", JagexColors.MENU_TARGET)))
.onClick(e -> addSnapPoint(client.getMouseCanvasPosition()));
return;
}

final boolean shift = client.isKeyPressed(KeyCode.KC_SHIFT);
Expand Down Expand Up @@ -480,14 +492,14 @@ else if (inOverlayDraggingMode && overlay.isDragTargetable() && currentManagedOv
}
}

private void addSnapPoint(Point p)
private void addSnapPoint(net.runelite.api.Point p)
{
String name = RandomStringUtils.random(12, true, true);
log.debug("Adding snap point at {}, id={}", p, name);
SnapPoint snapPoint = new SnapPoint(client, name, p);
SnapPoint snapPoint = new SnapPoint(client, name, new Point(p.getX(), p.getY()));
userSnapPoints.add(snapPoint);
overlayManager.add(snapPoint);
snapPoint.setPreferredLocation(p);
snapPoint.setPreferredLocation(new Point(p.getX(), p.getY()));
}

@Override
Expand All @@ -503,12 +515,15 @@ public MouseEvent mousePressed(MouseEvent mouseEvent)

// See if we've clicked on an overlay
currentManagedOverlay = lastHoveredOverlay;
if (SwingUtilities.isRightMouseButton(mouseEvent))
{
log.debug("managedOverlay={}", currentManagedOverlay);
}

if (currentManagedOverlay == null && SwingUtilities.isRightMouseButton(mouseEvent))
{
client.createMenuEntry(-1)
.setOption("Add snap point")
.setTarget((ColorUtil.wrapWithColorTag("Overlay", JagexColors.MENU_TARGET)))
.onClick(e -> addSnapPoint(mouseEvent.getPoint()));


}

if (currentManagedOverlay == null || !currentManagedOverlay.isMovable())
Expand Down

0 comments on commit cf7ebb9

Please sign in to comment.