Merge pull request #5481 from Nightfirecat/world-map-overlay-clipping
world map overlay: Move below right-click menu and clip to not draw over world map menus and widgets
This commit is contained in:
@@ -119,10 +119,12 @@ public class WidgetID
|
|||||||
|
|
||||||
static class WorldMap
|
static class WorldMap
|
||||||
{
|
{
|
||||||
static final int OPTION = 42;
|
|
||||||
static final int TOOLTIP = 35;
|
|
||||||
static final int MAPVIEW = 3;
|
static final int MAPVIEW = 3;
|
||||||
|
static final int OVERVIEW_MAP = 6;
|
||||||
static final int SEARCH = 21;
|
static final int SEARCH = 21;
|
||||||
|
static final int SURFACE_SELECTOR = 29;
|
||||||
|
static final int TOOLTIP = 35;
|
||||||
|
static final int OPTION = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SlayerRewards
|
static class SlayerRewards
|
||||||
|
|||||||
@@ -48,10 +48,12 @@ public enum WidgetInfo
|
|||||||
CLAN_CHAT(WidgetID.CLAN_CHAT_GROUP_ID, 0),
|
CLAN_CHAT(WidgetID.CLAN_CHAT_GROUP_ID, 0),
|
||||||
RAIDING_PARTY(WidgetID.RAIDING_PARTY_GROUP_ID, 0),
|
RAIDING_PARTY(WidgetID.RAIDING_PARTY_GROUP_ID, 0),
|
||||||
|
|
||||||
WORLD_MAP_OPTION(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),
|
WORLD_MAP_VIEW(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.MAPVIEW),
|
||||||
|
WORLD_MAP_OVERVIEW_MAP(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.OVERVIEW_MAP),
|
||||||
WORLD_MAP_SEARCH(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.SEARCH),
|
WORLD_MAP_SEARCH(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.SEARCH),
|
||||||
|
WORLD_MAP_SURFACE_SELECTOR(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.SURFACE_SELECTOR),
|
||||||
|
WORLD_MAP_TOOLTIP(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.TOOLTIP),
|
||||||
|
WORLD_MAP_OPTION(WidgetID.WORLD_MAP_MENU_GROUP_ID, WidgetID.WorldMap.OPTION),
|
||||||
|
|
||||||
CLUE_SCROLL_TEXT(WidgetID.CLUE_SCROLL_GROUP_ID, WidgetID.Cluescroll.CLUE_TEXT),
|
CLUE_SCROLL_TEXT(WidgetID.CLUE_SCROLL_GROUP_ID, WidgetID.Cluescroll.CLUE_TEXT),
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,12 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.ui.overlay.worldmap;
|
package net.runelite.client.ui.overlay.worldmap;
|
||||||
|
|
||||||
import java.awt.Canvas;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.geom.Area;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -70,7 +70,7 @@ public class WorldMapOverlay extends Overlay
|
|||||||
this.worldMapPointManager = worldMapPointManager;
|
this.worldMapPointManager = worldMapPointManager;
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
setPriority(OverlayPriority.HIGHEST);
|
setPriority(OverlayPriority.HIGHEST);
|
||||||
setLayer(OverlayLayer.ALWAYS_ON_TOP);
|
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||||
mouseManager.registerMouseListener(worldMapOverlayMouseListener);
|
mouseManager.registerMouseListener(worldMapOverlayMouseListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +91,8 @@ public class WorldMapOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Rectangle worldMapRectangle = widget.getBounds();
|
final Rectangle worldMapRectangle = widget.getBounds();
|
||||||
|
final Area mapViewArea = getWorldMapClipArea(worldMapRectangle);
|
||||||
|
final Area canvasViewArea = getWorldMapClipArea(client.getCanvas().getBounds());
|
||||||
WorldMapPoint tooltipPoint = null;
|
WorldMapPoint tooltipPoint = null;
|
||||||
|
|
||||||
for (WorldMapPoint worldPoint : points)
|
for (WorldMapPoint worldPoint : points)
|
||||||
@@ -110,8 +112,7 @@ public class WorldMapOverlay extends Overlay
|
|||||||
|
|
||||||
if (worldPoint.isSnapToEdge())
|
if (worldPoint.isSnapToEdge())
|
||||||
{
|
{
|
||||||
Canvas canvas = client.getCanvas();
|
graphics.setClip(canvasViewArea);
|
||||||
graphics.setClip(0, 0, canvas.getWidth(), canvas.getHeight());
|
|
||||||
|
|
||||||
if (worldMapRectangle.contains(drawPoint.getX(), drawPoint.getY()))
|
if (worldMapRectangle.contains(drawPoint.getX(), drawPoint.getY()))
|
||||||
{
|
{
|
||||||
@@ -133,7 +134,7 @@ public class WorldMapOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics.setClip(worldMapRectangle);
|
graphics.setClip(mapViewArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
int drawX = drawPoint.getX();
|
int drawX = drawPoint.getX();
|
||||||
@@ -216,6 +217,33 @@ public class WorldMapOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a clip area which excludes the area of widgets which overlay the world map.
|
||||||
|
*
|
||||||
|
* @param baseRectangle The base area to clip from
|
||||||
|
* @return An {@link Area} representing <code>baseRectangle</code>, with the area
|
||||||
|
* of visible widgets overlaying the world map clipped from it.
|
||||||
|
*/
|
||||||
|
private Area getWorldMapClipArea(Rectangle baseRectangle)
|
||||||
|
{
|
||||||
|
final Widget overview = client.getWidget(WidgetInfo.WORLD_MAP_OVERVIEW_MAP);
|
||||||
|
final Widget surfaceSelector = client.getWidget(WidgetInfo.WORLD_MAP_SURFACE_SELECTOR);
|
||||||
|
|
||||||
|
Area clipArea = new Area(baseRectangle);
|
||||||
|
|
||||||
|
if (overview != null && !overview.isHidden())
|
||||||
|
{
|
||||||
|
clipArea.subtract(new Area(overview.getBounds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (surfaceSelector != null && !surfaceSelector.isHidden())
|
||||||
|
{
|
||||||
|
clipArea.subtract(new Area(surfaceSelector.getBounds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return clipArea;
|
||||||
|
}
|
||||||
|
|
||||||
private void drawTooltip(Graphics2D graphics, WorldMapPoint worldPoint)
|
private void drawTooltip(Graphics2D graphics, WorldMapPoint worldPoint)
|
||||||
{
|
{
|
||||||
String tooltip = worldPoint.getTooltip();
|
String tooltip = worldPoint.getTooltip();
|
||||||
@@ -227,7 +255,7 @@ public class WorldMapOverlay extends Overlay
|
|||||||
|
|
||||||
drawPoint = new Point(drawPoint.getX() + TOOLTIP_OFFSET_WIDTH, drawPoint.getY() + TOOLTIP_OFFSET_HEIGHT);
|
drawPoint = new Point(drawPoint.getX() + TOOLTIP_OFFSET_WIDTH, drawPoint.getY() + TOOLTIP_OFFSET_HEIGHT);
|
||||||
|
|
||||||
graphics.setClip(0, 0, client.getCanvas().getWidth(), client.getCanvas().getHeight());
|
graphics.setClip(client.getCanvas().getBounds());
|
||||||
graphics.setColor(TOOLTIP_BACKGROUND);
|
graphics.setColor(TOOLTIP_BACKGROUND);
|
||||||
graphics.setFont(FontManager.getRunescapeFont());
|
graphics.setFont(FontManager.getRunescapeFont());
|
||||||
FontMetrics fm = graphics.getFontMetrics();
|
FontMetrics fm = graphics.getFontMetrics();
|
||||||
|
|||||||
Reference in New Issue
Block a user