Use backgroundComponent for drawing border of map
- Add new property fill to background component, if set to false, background is not drawn, only borders - Use backgroundComponent for drawing instance map borders Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.instancemap;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -68,6 +69,7 @@ import static net.runelite.client.plugins.instancemap.WallOffset.TOP_RIGHT;
|
|||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
import net.runelite.client.ui.overlay.components.BackgroundComponent;
|
||||||
|
|
||||||
class InstanceMapOverlay extends Overlay
|
class InstanceMapOverlay extends Overlay
|
||||||
{
|
{
|
||||||
@@ -109,6 +111,7 @@ class InstanceMapOverlay extends Overlay
|
|||||||
*/
|
*/
|
||||||
private volatile BufferedImage mapImage;
|
private volatile BufferedImage mapImage;
|
||||||
private volatile boolean showMap = false;
|
private volatile boolean showMap = false;
|
||||||
|
private final BackgroundComponent backgroundComponent = new BackgroundComponent();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
InstanceMapOverlay(Client client, InstanceMapPlugin plugin)
|
InstanceMapOverlay(Client client, InstanceMapPlugin plugin)
|
||||||
@@ -297,10 +300,9 @@ class InstanceMapOverlay extends Overlay
|
|||||||
|
|
||||||
Dimension mapOverlaySize = new Dimension(tiles.length * TILE_SIZE, tiles[0].length * TILE_SIZE);
|
Dimension mapOverlaySize = new Dimension(tiles.length * TILE_SIZE, tiles[0].length * TILE_SIZE);
|
||||||
|
|
||||||
graphics.setColor(Color.black);
|
backgroundComponent.setFill(false);
|
||||||
graphics.fillRect(0, 0, mapOverlaySize.width, mapOverlaySize.height);//draw background
|
backgroundComponent.setRectangle(new Rectangle(0, 0, mapOverlaySize.width, mapOverlaySize.height));
|
||||||
graphics.setColor(Color.white);
|
backgroundComponent.render(graphics, new java.awt.Point());
|
||||||
graphics.drawRect(0, 0, mapOverlaySize.width - 1, mapOverlaySize.height - 1);//draw outline
|
|
||||||
|
|
||||||
//These loops are seperated on purpose to prevent layering issues. This is how it's written in the client
|
//These loops are seperated on purpose to prevent layering issues. This is how it's written in the client
|
||||||
//Draw the base colors first
|
//Draw the base colors first
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ public class BackgroundComponent implements RenderableEntity
|
|||||||
@Setter
|
@Setter
|
||||||
private Rectangle rectangle = new Rectangle();
|
private Rectangle rectangle = new Rectangle();
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private boolean fill = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics, Point parent)
|
public Dimension render(Graphics2D graphics, Point parent)
|
||||||
{
|
{
|
||||||
@@ -76,8 +79,11 @@ public class BackgroundComponent implements RenderableEntity
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Render background
|
// Render background
|
||||||
graphics.setColor(backgroundColor);
|
if (fill)
|
||||||
graphics.fill(rectangle);
|
{
|
||||||
|
graphics.setColor(backgroundColor);
|
||||||
|
graphics.fill(rectangle);
|
||||||
|
}
|
||||||
|
|
||||||
// Render outside stroke
|
// Render outside stroke
|
||||||
final Rectangle outsideStroke = new Rectangle();
|
final Rectangle outsideStroke = new Rectangle();
|
||||||
|
|||||||
Reference in New Issue
Block a user