herbiboar: Fix FPS drops by removing clickbox option (#1509)
* Add option to Herbiboar plugin to only show the most recent trail * Optimize finding Herbiboar to highlight * Fix checkstyle violation * Use ModelOutlineRenderer to draw Herbiboar and fix review comments * herbiboar: Improve performance by removing clickbox option * Update HerbiboarOverlay.java * Update HerbiboarConfig.java * Update HerbiboarOverlay.java * Update HerbiboarPlugin.java * Create RenderStyle.java
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
|
||||
* Copyright (c) 2019, Gamer1120 <https://github.com/Gamer1120>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,17 +46,30 @@ public interface HerbiboarConfig extends Config
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "showClickboxes",
|
||||
name = "Show Clickboxes",
|
||||
description = "Show clickboxes on trail objects and tunnels instead of tiles"
|
||||
keyName = "showOutline",
|
||||
name = "Show Outlines",
|
||||
description = "Show outlines on trail objects and tunnels instead of tiles"
|
||||
)
|
||||
default boolean showClickBoxes()
|
||||
default boolean showOutlines()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "highlightStyle",
|
||||
name = "Outline Style",
|
||||
description = "Outline setting",
|
||||
hidden = true,
|
||||
unhide = "showOutline"
|
||||
)
|
||||
default RenderStyle outlineStyle()
|
||||
{
|
||||
return RenderStyle.THIN_OUTLINE;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "colorStart",
|
||||
name = "Start Color",
|
||||
description = "Color for rocks that start the trails"
|
||||
@@ -66,7 +80,7 @@ public interface HerbiboarConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
position = 4,
|
||||
keyName = "showTunnel",
|
||||
name = "Show End Tunnels",
|
||||
description = "Show highlights for tunnels with herbiboars"
|
||||
@@ -77,7 +91,7 @@ public interface HerbiboarConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
position = 5,
|
||||
keyName = "colorTunnel",
|
||||
name = "Tunnel Color",
|
||||
description = "Color for tunnels with herbiboars"
|
||||
@@ -88,7 +102,7 @@ public interface HerbiboarConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
position = 6,
|
||||
keyName = "showObject",
|
||||
name = "Show Trail Objects",
|
||||
description = "Show highlights for mushrooms, mud, seaweed, etc"
|
||||
@@ -99,7 +113,7 @@ public interface HerbiboarConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
position = 7,
|
||||
keyName = "colorGameObject",
|
||||
name = "Trail Object Color",
|
||||
description = "Color for mushrooms, mud, seaweed, etc"
|
||||
@@ -110,7 +124,7 @@ public interface HerbiboarConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 7,
|
||||
position = 8,
|
||||
keyName = "showTrail",
|
||||
name = "Show Trail",
|
||||
description = "Show highlights for trail prints"
|
||||
@@ -121,7 +135,18 @@ public interface HerbiboarConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 8,
|
||||
position = 9,
|
||||
keyName = "showOnlyCurrentTrail",
|
||||
name = "Show Current Trail Only",
|
||||
description = "Only show the trail that you currently have to follow to get to the next object you have to inspect. Requires that the \"Show Trail\" option is enabled"
|
||||
)
|
||||
default boolean isOnlyCurrentTrailShown()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 10,
|
||||
keyName = "colorTrail",
|
||||
name = "Trail Color",
|
||||
description = "Color for mushrooms, mud, seaweed, etc"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Kamiel
|
||||
* Copyright (c) 2019, Gamer1120 <https://github.com/Gamer1120>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -55,7 +56,15 @@ public class HerbiboarMinimapOverlay extends Overlay
|
||||
{
|
||||
HerbiboarTrail currentTrail = plugin.getCurrentTrail();
|
||||
int finishId = plugin.getFinishId();
|
||||
Set<Integer> shownTrailIds = plugin.getShownTrails();
|
||||
Set<Integer> shownTrailIds;
|
||||
if (plugin.isOnlyCurrentTrailShown())
|
||||
{
|
||||
shownTrailIds = plugin.getCurrentTrailIds();
|
||||
}
|
||||
else
|
||||
{
|
||||
shownTrailIds = plugin.getShownTrails();
|
||||
}
|
||||
|
||||
for (TileObject tileObject : plugin.getTrails().values())
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
|
||||
* Copyright (c) 2019, Gamer1120 <https://github.com/Gamer1120>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -29,10 +30,13 @@ import com.google.inject.Singleton;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Area;
|
||||
import java.util.Set;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.TileObject;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.graphics.ModelOutlineRenderer;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
@@ -41,14 +45,21 @@ import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
@Singleton
|
||||
class HerbiboarOverlay extends Overlay
|
||||
{
|
||||
private static final Color TRANSPARENT = new Color(0, 0, 0, 0);
|
||||
|
||||
private Client client;
|
||||
|
||||
private final HerbiboarPlugin plugin;
|
||||
private final ModelOutlineRenderer modelOutlineRenderer;
|
||||
|
||||
@Inject
|
||||
public HerbiboarOverlay(final HerbiboarPlugin plugin)
|
||||
public HerbiboarOverlay(final HerbiboarPlugin plugin, ModelOutlineRenderer modelOutlineRenderer, Client client)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
this.plugin = plugin;
|
||||
this.modelOutlineRenderer = modelOutlineRenderer;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,16 +75,24 @@ class HerbiboarOverlay extends Overlay
|
||||
int finishId = plugin.getFinishId();
|
||||
|
||||
// Draw start objects
|
||||
if (plugin.isStartShown() && (currentTrail == null && finishId == 0))
|
||||
if (plugin.isStartShown() && currentTrail == null && finishId == 0 && !plugin.isHerbiboarRendered())
|
||||
{
|
||||
plugin.getStarts().values().forEach((obj) ->
|
||||
OverlayUtil.renderTileOverlay(graphics, obj, "", plugin.getGetStartColor()));
|
||||
}
|
||||
|
||||
// Draw trails
|
||||
Set<Integer> shownTrailIds;
|
||||
if (plugin.isTrailShown())
|
||||
{
|
||||
Set<Integer> shownTrailIds = plugin.getShownTrails();
|
||||
if (plugin.isOnlyCurrentTrailShown())
|
||||
{
|
||||
shownTrailIds = plugin.getCurrentTrailIds();
|
||||
}
|
||||
else
|
||||
{
|
||||
shownTrailIds = plugin.getShownTrails();
|
||||
}
|
||||
plugin.getTrails().values().forEach((x) ->
|
||||
{
|
||||
int id = x.getId();
|
||||
@@ -97,18 +116,12 @@ class HerbiboarOverlay extends Overlay
|
||||
}
|
||||
|
||||
TileObject object = plugin.getTrailObjects().get(trailLoc);
|
||||
|
||||
if (object != null)
|
||||
{
|
||||
if (plugin.isShowClickBoxes())
|
||||
if (plugin.isShowOutlines())
|
||||
{
|
||||
Area clickbox = object.getClickbox();
|
||||
if (clickbox != null)
|
||||
{
|
||||
graphics.setColor(plugin.getGetObjectColor());
|
||||
graphics.draw(clickbox);
|
||||
graphics.setColor(new Color(255, 0, 255, 20));
|
||||
graphics.fill(clickbox);
|
||||
}
|
||||
renderOutline(object, new Color(255, 0, 255, 20));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -125,17 +138,10 @@ class HerbiboarOverlay extends Overlay
|
||||
TileObject object = plugin.getTunnels().get(finishLoc);
|
||||
if (object != null)
|
||||
{
|
||||
if (plugin.isShowClickBoxes())
|
||||
if (plugin.isShowOutlines())
|
||||
{
|
||||
Area clickbox = object.getClickbox();
|
||||
if (clickbox != null)
|
||||
{
|
||||
Color col = plugin.getGetObjectColor();
|
||||
graphics.setColor(col);
|
||||
graphics.draw(clickbox);
|
||||
graphics.setColor(new Color(col.getRed(), col.getGreen(), col.getBlue(), 20));
|
||||
graphics.fill(clickbox);
|
||||
}
|
||||
Color col = plugin.getGetObjectColor();
|
||||
renderOutline(object, new Color(col.getRed(), col.getGreen(), col.getBlue(), 20));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -144,6 +150,39 @@ class HerbiboarOverlay extends Overlay
|
||||
}
|
||||
}
|
||||
|
||||
// Draw herbiboar
|
||||
if (plugin.isHerbiboarRendered())
|
||||
{
|
||||
for (NPC npc : client.getNpcs())
|
||||
{
|
||||
if (npc.getId() == NpcID.HERBIBOAR || npc.getId() == NpcID.HERBIBOAR_7786)
|
||||
{
|
||||
modelOutlineRenderer.drawOutline(npc, 2, plugin.getGetObjectColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void renderOutline(TileObject object, Color color)
|
||||
{
|
||||
switch (plugin.getOutlineStyle())
|
||||
{
|
||||
case THIN_OUTLINE:
|
||||
modelOutlineRenderer.drawOutline(object, 1, color);
|
||||
break;
|
||||
|
||||
case OUTLINE:
|
||||
modelOutlineRenderer.drawOutline(object, 2, color);
|
||||
break;
|
||||
|
||||
case THIN_GLOW:
|
||||
modelOutlineRenderer.drawOutline(object, 4, color, TRANSPARENT);
|
||||
break;
|
||||
|
||||
case GLOW:
|
||||
modelOutlineRenderer.drawOutline(object, 8, color, TRANSPARENT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NpcID;
|
||||
import static net.runelite.api.ObjectID.DRIFTWOOD_30523;
|
||||
import static net.runelite.api.ObjectID.MUSHROOM_30520;
|
||||
import static net.runelite.api.ObjectID.ROCK_30519;
|
||||
@@ -47,6 +49,7 @@ import net.runelite.api.Tile;
|
||||
import net.runelite.api.TileObject;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.GameObjectChanged;
|
||||
import net.runelite.api.events.GameObjectDespawned;
|
||||
@@ -146,11 +149,21 @@ public class HerbiboarPlugin extends Plugin
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int finishId;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Set<Integer> previousShownTrailIds;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Integer previousTrailId = null;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean herbiboarRendered = false;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean isStartShown;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean showClickBoxes;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Color getStartColor;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean isTunnelShown;
|
||||
@@ -164,6 +177,12 @@ public class HerbiboarPlugin extends Plugin
|
||||
private boolean isTrailShown;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Color getTrailColor;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean isOnlyCurrentTrailShown;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean showOutlines;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private RenderStyle outlineStyle;
|
||||
|
||||
@Provides
|
||||
HerbiboarConfig getConfig(ConfigManager configManager)
|
||||
@@ -196,6 +215,7 @@ public class HerbiboarPlugin extends Plugin
|
||||
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
||||
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
|
||||
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
|
||||
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
|
||||
eventBus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
|
||||
eventBus.subscribe(GameObjectChanged.class, this, this::onGameObjectChanged);
|
||||
eventBus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
|
||||
@@ -242,6 +262,44 @@ public class HerbiboarPlugin extends Plugin
|
||||
{
|
||||
resetTrailData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Set<Integer> getCurrentTrailIds()
|
||||
{
|
||||
Set<Integer> shownTrailIds;
|
||||
if (currentTrail == null)
|
||||
{
|
||||
if (finishId <= 0)
|
||||
{
|
||||
previousTrailId = null;
|
||||
shownTrailIds = new HashSet<>();
|
||||
}
|
||||
else
|
||||
{
|
||||
shownTrailIds = new HashSet<>();
|
||||
shownTrailIds.add(previousTrailId);
|
||||
shownTrailIds.add(previousTrailId + 1);
|
||||
}
|
||||
}
|
||||
else if (previousTrailId == null)
|
||||
{
|
||||
previousTrailId = currentTrail.getTrailId();
|
||||
shownTrailIds = getShownTrails();
|
||||
}
|
||||
else if (currentTrail.getTrailId() == previousTrailId)
|
||||
{
|
||||
shownTrailIds = previousShownTrailIds;
|
||||
}
|
||||
else
|
||||
{
|
||||
shownTrailIds = new HashSet<>();
|
||||
shownTrailIds.add(previousTrailId);
|
||||
shownTrailIds.add(previousTrailId + 1);
|
||||
previousTrailId = currentTrail.getTrailId();
|
||||
}
|
||||
previousShownTrailIds = shownTrailIds;
|
||||
return shownTrailIds;
|
||||
}
|
||||
|
||||
private void resetTrailData()
|
||||
@@ -290,6 +348,31 @@ public class HerbiboarPlugin extends Plugin
|
||||
onGameObject(event.getTile(), null, event.getGameObject());
|
||||
}
|
||||
|
||||
public void onAnimationChanged(AnimationChanged event)
|
||||
{
|
||||
if (!(event.getActor() instanceof NPC))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NPC npc = (NPC) event.getActor();
|
||||
// Herbiboar spawns
|
||||
if (npc.getId() == NpcID.HERBIBOAR_7786 && npc.getAnimation() == 7687)
|
||||
{
|
||||
herbiboarRendered = true;
|
||||
}
|
||||
// Herbiboar is stunned
|
||||
else if (npc.getId() == NpcID.HERBIBOAR && npc.getAnimation() == 7689)
|
||||
{
|
||||
herbiboarRendered = true;
|
||||
}
|
||||
// Herbiboar is harvested
|
||||
else if (npc.getId() == NpcID.HERBIBOAR_7786 && npc.getAnimation() == 7690)
|
||||
{
|
||||
herbiboarRendered = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void onGameObjectChanged(GameObjectChanged event)
|
||||
{
|
||||
onGameObject(event.getTile(), event.getPrevious(), event.getGameObject());
|
||||
@@ -404,7 +487,6 @@ public class HerbiboarPlugin extends Plugin
|
||||
private void updateConfig()
|
||||
{
|
||||
this.isStartShown = config.isStartShown();
|
||||
this.showClickBoxes = config.showClickBoxes();
|
||||
this.getStartColor = config.getStartColor();
|
||||
this.isTunnelShown = config.isTunnelShown();
|
||||
this.getTunnelColor = config.getTunnelColor();
|
||||
@@ -412,5 +494,8 @@ public class HerbiboarPlugin extends Plugin
|
||||
this.getObjectColor = config.getObjectColor();
|
||||
this.isTrailShown = config.isTrailShown();
|
||||
this.getTrailColor = config.getTrailColor();
|
||||
this.isOnlyCurrentTrailShown = config.isOnlyCurrentTrailShown();
|
||||
this.showOutlines = config.showOutlines();
|
||||
this.outlineStyle = config.outlineStyle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.runelite.client.plugins.herbiboars;
|
||||
|
||||
public enum RenderStyle
|
||||
{
|
||||
THIN_OUTLINE("Thin outline"),
|
||||
OUTLINE("Outline"),
|
||||
THIN_GLOW("Thin glow"),
|
||||
GLOW("Glow");
|
||||
|
||||
private final String name;
|
||||
|
||||
RenderStyle(final String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user