ground markers: add configurable border width
This commit is contained in:
@@ -375,6 +375,20 @@ class ConfigPanel extends PluginPanel
|
|||||||
item.add(spinner, BorderLayout.EAST);
|
item.add(spinner, BorderLayout.EAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (cid.getType() == double.class)
|
||||||
|
{
|
||||||
|
double value = configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName(), double.class);
|
||||||
|
|
||||||
|
SpinnerModel model = new SpinnerNumberModel(value, 0, Double.MAX_VALUE, 0.1);
|
||||||
|
JSpinner spinner = new JSpinner(model);
|
||||||
|
Component editor = spinner.getEditor();
|
||||||
|
JFormattedTextField spinnerTextField = ((JSpinner.DefaultEditor) editor).getTextField();
|
||||||
|
spinnerTextField.setColumns(SPINNER_FIELD_WIDTH);
|
||||||
|
spinner.addChangeListener(ce -> changeConfiguration(spinner, cd, cid));
|
||||||
|
|
||||||
|
item.add(spinner, BorderLayout.EAST);
|
||||||
|
}
|
||||||
|
|
||||||
if (cid.getType() == String.class)
|
if (cid.getType() == String.class)
|
||||||
{
|
{
|
||||||
JTextComponent textField;
|
JTextComponent textField;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public interface GroundMarkerConfig extends Config
|
|||||||
@Alpha
|
@Alpha
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "markerColor",
|
keyName = "markerColor",
|
||||||
name = "Color of the tile",
|
name = "Tile color",
|
||||||
description = "Configures the color of marked tile"
|
description = "Configures the color of marked tile"
|
||||||
)
|
)
|
||||||
default Color markerColor()
|
default Color markerColor()
|
||||||
@@ -88,4 +88,14 @@ public interface GroundMarkerConfig extends Config
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "borderWidth",
|
||||||
|
name = "Border Width",
|
||||||
|
description = "Width of the marked tile border"
|
||||||
|
)
|
||||||
|
default double borderWidth()
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,12 @@
|
|||||||
package net.runelite.client.plugins.groundmarkers;
|
package net.runelite.client.plugins.groundmarkers;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import java.awt.BasicStroke;
|
||||||
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.Polygon;
|
import java.awt.Polygon;
|
||||||
|
import java.awt.Stroke;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -67,6 +69,12 @@ public class GroundMarkerOverlay extends Overlay
|
|||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
final Collection<ColorTileMarker> points = plugin.getPoints();
|
final Collection<ColorTileMarker> points = plugin.getPoints();
|
||||||
|
if (points.isEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Stroke stroke = new BasicStroke((float) config.borderWidth());
|
||||||
for (final ColorTileMarker point : points)
|
for (final ColorTileMarker point : points)
|
||||||
{
|
{
|
||||||
WorldPoint worldPoint = point.getWorldPoint();
|
WorldPoint worldPoint = point.getWorldPoint();
|
||||||
@@ -82,13 +90,13 @@ public class GroundMarkerOverlay extends Overlay
|
|||||||
tileColor = config.markerColor();
|
tileColor = config.markerColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
drawTile(graphics, worldPoint, tileColor, point.getLabel());
|
drawTile(graphics, worldPoint, tileColor, point.getLabel(), stroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawTile(Graphics2D graphics, WorldPoint point, Color color, @Nullable String label)
|
private void drawTile(Graphics2D graphics, WorldPoint point, Color color, @Nullable String label, Stroke borderStroke)
|
||||||
{
|
{
|
||||||
WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation();
|
WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation();
|
||||||
|
|
||||||
@@ -106,7 +114,7 @@ public class GroundMarkerOverlay extends Overlay
|
|||||||
Polygon poly = Perspective.getCanvasTilePoly(client, lp);
|
Polygon poly = Perspective.getCanvasTilePoly(client, lp);
|
||||||
if (poly != null)
|
if (poly != null)
|
||||||
{
|
{
|
||||||
OverlayUtil.renderPolygon(graphics, poly, color);
|
OverlayUtil.renderPolygon(graphics, poly, color, borderStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Strings.isNullOrEmpty(label))
|
if (!Strings.isNullOrEmpty(label))
|
||||||
|
|||||||
@@ -42,20 +42,21 @@ import net.runelite.api.TileObject;
|
|||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Kyle Fricilone on Jun 09, 2017.
|
|
||||||
*/
|
|
||||||
public class OverlayUtil
|
public class OverlayUtil
|
||||||
{
|
{
|
||||||
private static final int MINIMAP_DOT_RADIUS = 4;
|
private static final int MINIMAP_DOT_RADIUS = 4;
|
||||||
private static final double UNIT = Math.PI / 1024.0d;
|
private static final double UNIT = Math.PI / 1024.0d;
|
||||||
|
|
||||||
public static void renderPolygon(Graphics2D graphics, Shape poly, Color color)
|
public static void renderPolygon(Graphics2D graphics, Shape poly, Color color)
|
||||||
|
{
|
||||||
|
renderPolygon(graphics, poly, color, new BasicStroke(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderPolygon(Graphics2D graphics, Shape poly, Color color, Stroke borderStroke)
|
||||||
{
|
{
|
||||||
graphics.setColor(color);
|
graphics.setColor(color);
|
||||||
final Stroke originalStroke = graphics.getStroke();
|
final Stroke originalStroke = graphics.getStroke();
|
||||||
graphics.setStroke(new BasicStroke(2));
|
graphics.setStroke(borderStroke);
|
||||||
graphics.draw(poly);
|
graphics.draw(poly);
|
||||||
graphics.setColor(new Color(0, 0, 0, 50));
|
graphics.setColor(new Color(0, 0, 0, 50));
|
||||||
graphics.fill(poly);
|
graphics.fill(poly);
|
||||||
|
|||||||
Reference in New Issue
Block a user