Merge pull request #958 from runelite-extended/agility-update

agility: Add config option for distance cap on agility plugin
This commit is contained in:
Tyler Bochard
2019-07-11 01:25:49 -04:00
committed by GitHub
8 changed files with 232 additions and 187 deletions

View File

@@ -28,15 +28,42 @@ import java.awt.Color;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Stub;
@ConfigGroup("agility")
public interface AgilityConfig extends Config
{
@ConfigItem(
position = 0,
keyName = "mainConfig",
name = "Main Config",
description = ""
)
default Stub mainConfig()
{
return new Stub();
}
@ConfigItem(
keyName = "removeDistanceCap",
name = "Remove Distance Cap",
description = "This will remove the distance cap on rendering overlays for agility.",
warning = "<html><center>Enabling this setting on a low end machine may severely affect your fps." +
"<br>Click yes to enable this setting, knowing it might affect performance.</center></html>",
position = 1,
parent = "mainConfig"
)
default boolean removeDistanceCap()
{
return false;
}
@ConfigItem(
keyName = "showLapCount",
name = "Show Lap Count",
description = "Enable/disable the lap counter",
position = 1
position = 2,
parent = "mainConfig"
)
default boolean showLapCount()
{
@@ -45,9 +72,12 @@ public interface AgilityConfig extends Config
@ConfigItem(
keyName = "lapTimeout",
name = "Hide Lap Count (minutes)",
description = "Time until the lap counter hides/resets",
position = 2
name = "Hide Lap Count",
description = "Time in minutes until the lap counter hides/resets",
position = 3,
parent = "mainConfig",
hidden = true,
unhide = "showLapCount"
)
default int lapTimeout()
{
@@ -58,106 +88,36 @@ public interface AgilityConfig extends Config
keyName = "lapsToLevel",
name = "Show Laps Until Level",
description = "Show number of laps remaining until next level is reached.",
position = 3
position = 4,
parent = "mainConfig",
hidden = true,
unhide = "showLapCount"
)
default boolean lapsToLevel()
{
return true;
return false;
}
@ConfigItem(
keyName = "lapsToGoal",
name = "Show Laps Until Goal",
description = "Show number of laps remaining until experience tracker goal is reached",
position = 4
position = 5,
parent = "mainConfig",
hidden = true,
unhide = "showLapCount"
)
default boolean lapsToGoal()
{
return false;
}
@ConfigItem(
keyName = "overlayColor",
name = "Overlay Color",
description = "Color of Agility overlay",
position = 5
)
default Color getOverlayColor()
{
return Color.GREEN;
}
@ConfigItem(
keyName = "highlightMarks",
name = "Highlight Marks of Grace",
description = "Enable/disable the highlighting of retrievable Marks of Grace",
position = 6
)
default boolean highlightMarks()
{
return true;
}
@ConfigItem(
keyName = "markHighlight",
name = "Mark Highlight Color",
description = "Color of highlighted Marks of Grace",
position = 7
)
default Color getMarkColor()
{
return Color.RED;
}
@ConfigItem(
keyName = "highlightShortcuts",
name = "Highlight Agility Shortcuts",
description = "Enable/disable the highlighting of Agility shortcuts",
position = 8
)
default boolean highlightShortcuts()
{
return true;
}
@ConfigItem(
keyName = "trapOverlay",
name = "Show Trap Overlay",
description = "Enable/disable the highlighting of traps on Agility courses",
position = 9
)
default boolean showTrapOverlay()
{
return true;
}
@ConfigItem(
keyName = "trapHighlight",
name = "Trap Overlay Color",
description = "Color of Agility trap overlay",
position = 10
)
default Color getTrapColor()
{
return Color.RED;
}
@ConfigItem(
keyName = "agilityArenaNotifier",
name = "Agility Arena notifier",
description = "Notify on ticket location change in Agility Arena",
position = 11
)
default boolean notifyAgilityArena()
{
return true;
}
@ConfigItem(
keyName = "agilityArenaTimer",
name = "Agility Arena timer",
description = "Configures whether Agility Arena timer is displayed",
position = 12
position = 6,
parent = "mainConfig"
)
default boolean showAgilityArenaTimer()
{
@@ -166,12 +126,112 @@ public interface AgilityConfig extends Config
@ConfigItem(
keyName = "addLevelsToShortcutOptions",
name = "Show shortcut agility req. in options",
name = "Show Shortcut Agility Reqs",
description = "Enable/disable showing shortcut agility level requirements in right-click options",
position = 13
position = 7,
parent = "mainConfig"
)
default boolean showShortcutLevel()
{
return false;
}
@ConfigItem(
position = 8,
keyName = "miscConfig",
name = "Misc Config",
description = ""
)
default Stub miscConfig()
{
return new Stub();
}
@ConfigItem(
keyName = "highlightMarks",
name = "Highlight Marks of Grace",
description = "Enable/disable the highlighting of retrievable Marks of Grace",
position = 9,
parent = "miscConfig"
)
default boolean highlightMarks()
{
return true;
}
@ConfigItem(
keyName = "highlightShortcuts",
name = "Highlight Agility Shortcuts",
description = "Enable/disable the highlighting of Agility shortcuts",
position = 10,
parent = "miscConfig"
)
default boolean highlightShortcuts()
{
return true;
}
@ConfigItem(
keyName = "showTrapOverlay",
name = "Highlight Traps",
description = "Enable/disable the highlighting of traps on Agility courses",
position = 11,
parent = "miscConfig"
)
default boolean showTrapOverlay()
{
return false;
}
@ConfigItem(
keyName = "agilityArenaNotifier",
name = "Agility Arena notifier",
description = "Notify on ticket location change in Agility Arena",
position = 12,
parent = "miscConfig"
)
default boolean notifyAgilityArena()
{
return false;
}
@ConfigItem(
keyName = "overlayColor",
name = "Global Overlay Color",
description = "Color of Agility overlay",
position = 13,
parent = "miscConfig"
)
default Color getOverlayColor()
{
return Color.GREEN;
}
@ConfigItem(
keyName = "trapHighlight",
name = "Trap Overlay Color",
description = "Color of Agility trap overlay",
position = 14,
parent = "miscConfig",
hidden = true,
unhide = "showTrapOverlay"
)
default Color getTrapColor()
{
return Color.RED;
}
@ConfigItem(
keyName = "markHighlight",
name = "Mark Highlight Color",
description = "Color of highlighted Marks of Grace",
position = 15,
parent = "miscConfig",
hidden = true,
unhide = "highlightMarks"
)
default Color getMarkColor()
{
return Color.RED;
}
}

View File

@@ -77,8 +77,8 @@ class AgilityOverlay extends Overlay
}
Tile tile = obstacle.getTile();
if (tile.getPlane() == client.getPlane()
&& object.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
if (tile.getPlane() == client.getPlane() && checkDistance(object.getLocalLocation(), playerLocation))
{
// This assumes that the obstacle is not clickable.
if (Obstacles.TRAP_OBSTACLE_IDS.contains(object.getId()))
@@ -100,18 +100,7 @@ class AgilityOverlay extends Overlay
configColor = plugin.getMarkColor();
}
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
{
graphics.setColor(configColor.darker());
}
else
{
graphics.setColor(configColor);
}
graphics.draw(objectClickbox);
graphics.setColor(new Color(configColor.getRed(), configColor.getGreen(), configColor.getBlue(), 50));
graphics.fill(objectClickbox);
OverlayUtil.renderClickBox(graphics, mousePosition, objectClickbox, configColor);
}
}
@@ -122,7 +111,7 @@ class AgilityOverlay extends Overlay
for (Tile markOfGraceTile : marksOfGrace)
{
if (markOfGraceTile.getPlane() == client.getPlane() && markOfGraceTile.getItemLayer() != null
&& markOfGraceTile.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
&& checkDistance(markOfGraceTile.getLocalLocation(), playerLocation))
{
final Polygon poly = markOfGraceTile.getItemLayer().getCanvasTilePoly();
@@ -138,4 +127,13 @@ class AgilityOverlay extends Overlay
return null;
}
private boolean checkDistance(LocalPoint localPoint, LocalPoint playerPoint)
{
if (plugin.isRemoveDistanceCap())
{
return true;
}
return localPoint.distanceTo(playerPoint) < MAX_DISTANCE;
}
}

View File

@@ -137,6 +137,8 @@ public class AgilityPlugin extends Plugin
// Config values
@Getter(AccessLevel.PACKAGE)
private boolean removeDistanceCap;
@Getter(AccessLevel.PACKAGE)
private boolean showLapCount;
@Getter(AccessLevel.PACKAGE)
private int lapTimeout;
@@ -224,6 +226,7 @@ public class AgilityPlugin extends Plugin
public void updateConfig()
{
this.removeDistanceCap = config.removeDistanceCap();
this.showLapCount = config.showLapCount();
this.lapTimeout = config.lapTimeout();
this.lapsToLevel = config.lapsToLevel();

View File

@@ -73,22 +73,22 @@ public class AoeWarningOverlay extends Overlay
WorldPoint lp = client.getLocalPlayer().getWorldLocation();
for (WorldPoint point : plugin.getLightningTrail())
{
OverlayUtil.drawTile(graphics, client, point, lp, new Color(0, 150, 200), 2, 150, 50);
OverlayUtil.drawTiles(graphics, client, point, lp, new Color(0, 150, 200), 2, 150, 50);
}
for (WorldPoint point : plugin.getAcidTrail())
{
OverlayUtil.drawTile(graphics, client, point, lp, new Color(69, 241, 44), 2, 150, 50);
OverlayUtil.drawTiles(graphics, client, point, lp, new Color(69, 241, 44), 2, 150, 50);
}
for (WorldPoint point : plugin.getCrystalSpike())
{
OverlayUtil.drawTile(graphics, client, point, lp, new Color(255, 0, 84), 2, 150, 50);
OverlayUtil.drawTiles(graphics, client, point, lp, new Color(255, 0, 84), 2, 150, 50);
}
for (WorldPoint point : plugin.getWintertodtSnowFall())
{
OverlayUtil.drawTile(graphics, client, point, lp, new Color(255, 0, 84), 2, 150, 50);
OverlayUtil.drawTiles(graphics, client, point, lp, new Color(255, 0, 84), 2, 150, 50);
}
Instant now = Instant.now();

View File

@@ -33,7 +33,6 @@ import java.text.NumberFormat;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.ObjectDefinition;
@@ -42,19 +41,19 @@ import net.runelite.api.Tile;
import net.runelite.api.TileObject;
import net.runelite.api.Varbits;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import static net.runelite.client.plugins.pyramidplunder.PyramidPlunderPlugin.CLOSED_DOOR;
import static net.runelite.client.plugins.pyramidplunder.PyramidPlunderPlugin.OPENED_DOOR;
import static net.runelite.client.plugins.pyramidplunder.PyramidPlunderPlugin.TRAP;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.ui.overlay.components.table.TableComponent;
import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.ui.overlay.components.table.TableComponent;
import net.runelite.client.util.ColorUtil;
@Singleton
@@ -135,18 +134,7 @@ public class PyramidPlunderOverlay extends Overlay
break;
}
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
{
graphics.setColor(configColor.darker());
}
else
{
graphics.setColor(configColor);
}
graphics.draw(objectClickbox);
graphics.setColor(new Color(configColor.getRed(), configColor.getGreen(), configColor.getBlue(), 50));
graphics.fill(objectClickbox);
OverlayUtil.renderClickBox(graphics, mousePosition, objectClickbox, configColor);
}
}
}

View File

@@ -1,6 +1,5 @@
package net.runelite.client.plugins.theatre;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
@@ -8,7 +7,6 @@ import java.awt.Polygon;
import java.util.Map;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.NPCDefinition;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.Projectile;
@@ -51,11 +49,7 @@ public abstract class RoomHandler
return;
}
//OverlayUtil.renderPolygon(graphics, poly, color);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
graphics.setStroke(new BasicStroke(strokeWidth));
graphics.draw(poly);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
graphics.fill(poly);
OverlayUtil.drawStrokeAndFillPoly(graphics, color, strokeWidth, outlineAlpha, fillAlpha, poly);
}
@@ -91,51 +85,12 @@ public abstract class RoomHandler
{
WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation();
if (point.distanceTo(playerLocation) >= 32)
{
return;
}
LocalPoint lp = LocalPoint.fromWorld(client, point);
if (lp == null)
{
return;
}
Polygon poly = Perspective.getCanvasTilePoly(client, lp);
if (poly == null)
{
return;
}
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
graphics.setStroke(new BasicStroke(strokeWidth));
graphics.draw(poly);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
graphics.fill(poly);
OverlayUtil.drawTiles(graphics, client, point, playerLocation, color, strokeWidth, outlineAlpha, fillAlpha);
}
protected void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha)
{
int size = 1;
NPCDefinition composition = actor.getTransformedDefinition();
if (composition != null)
{
size = composition.getSize();
}
LocalPoint lp = actor.getLocalLocation();
Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);
if (tilePoly != null)
{
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
graphics.setStroke(new BasicStroke(outlineWidth));
graphics.draw(tilePoly);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
graphics.fill(tilePoly);
}
OverlayUtil.renderNpcOverlay(graphics, actor, color, outlineWidth, outlineAlpha, fillAlpha, client);
}
protected void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint)

View File

@@ -34,7 +34,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Point;
import net.runelite.api.coords.WorldArea;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
@@ -69,14 +68,14 @@ public class TimersOverlay extends Overlay
}
int ticksLeft = npc.getTicksUntilAttack();
final List<WorldPoint> hitSquares = getHitSquares(npc.getNpc().getWorldLocation(), npc.getNpcSize(), 1, false);
final List<WorldPoint> hitSquares = OverlayUtil.getHitSquares(npc.getNpc().getWorldLocation(), npc.getNpcSize(), 1, false);
final NPCContainer.AttackStyle attackStyle = npc.getAttackStyle();
if (plugin.isShowHitSquares() && attackStyle.getName().equals("Melee"))
{
for (WorldPoint p : hitSquares)
{
OverlayUtil.drawTile(graphics, client, p, client.getLocalPlayer().getWorldLocation(), attackStyle.getColor(), 0, 0, 50);
OverlayUtil.drawTiles(graphics, client, p, client.getLocalPlayer().getWorldLocation(), attackStyle.getColor(), 0, 0, 50);
}
}
@@ -131,17 +130,6 @@ public class TimersOverlay extends Overlay
}
}
private List<WorldPoint> getHitSquares(WorldPoint npcLoc, int npcSize, int thickness, boolean includeUnder)
{
List<WorldPoint> little = new WorldArea(npcLoc, npcSize, npcSize).toWorldPointList();
List<WorldPoint> big = new WorldArea(npcLoc.getX() - thickness, npcLoc.getY() - thickness, npcSize + (thickness * 2), npcSize + (thickness * 2), npcLoc.getPlane()).toWorldPointList();
if (!includeUnder)
{
big.removeIf(little::contains);
}
return big;
}
private Point centerPoint(Rectangle rect)
{
int x = (int) (rect.getX() + rect.getWidth() / 2);

View File

@@ -36,13 +36,17 @@ import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.geom.Area;
import java.awt.image.BufferedImage;
import java.util.List;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.NPCDefinition;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
import net.runelite.api.TileObject;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldArea;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.widgets.Widget;
@@ -295,7 +299,23 @@ public class OverlayUtil
}
}
public static void drawTile(Graphics2D graphics, Client client, WorldPoint point, WorldPoint playerPoint, Color color, int strokeWidth, int outlineAlpha, int fillAlpha)
public static void renderClickBox(Graphics2D graphics, Point mousePosition, Area objectClickbox, Color configColor)
{
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
{
graphics.setColor(configColor.darker());
}
else
{
graphics.setColor(configColor);
}
graphics.draw(objectClickbox);
graphics.setColor(new Color(configColor.getRed(), configColor.getGreen(), configColor.getBlue(), 50));
graphics.fill(objectClickbox);
}
public static void drawTiles(Graphics2D graphics, Client client, WorldPoint point, WorldPoint playerPoint, Color color, int strokeWidth, int outlineAlpha, int fillAlpha)
{
if (point.distanceTo(playerPoint) >= 32)
{
@@ -312,6 +332,11 @@ public class OverlayUtil
{
return;
}
drawStrokeAndFillPoly(graphics, color, strokeWidth, outlineAlpha, fillAlpha, poly);
}
public static void drawStrokeAndFillPoly(Graphics2D graphics, Color color, int strokeWidth, int outlineAlpha, int fillAlpha, Polygon poly)
{
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
graphics.setStroke(new BasicStroke(strokeWidth));
graphics.draw(poly);
@@ -340,4 +365,32 @@ public class OverlayUtil
return new Polygon(xpoints, ypoints, 4);
}
public static List<WorldPoint> getHitSquares(WorldPoint npcLoc, int npcSize, int thickness, boolean includeUnder)
{
List<WorldPoint> little = new WorldArea(npcLoc, npcSize, npcSize).toWorldPointList();
List<WorldPoint> big = new WorldArea(npcLoc.getX() - thickness, npcLoc.getY() - thickness, npcSize + (thickness * 2), npcSize + (thickness * 2), npcLoc.getPlane()).toWorldPointList();
if (!includeUnder)
{
big.removeIf(little::contains);
}
return big;
}
public static void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha, Client client)
{
int size = 1;
NPCDefinition composition = actor.getTransformedDefinition();
if (composition != null)
{
size = composition.getSize();
}
LocalPoint lp = actor.getLocalLocation();
Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);
if (tilePoly != null)
{
OverlayUtil.drawStrokeAndFillPoly(graphics, color, outlineWidth, outlineAlpha, fillAlpha, tilePoly);
}
}
}