Add model outline renderer
Add the option to outline models to the npc and object indicator plugins Co-authored-by: Adam <Adam@sigterm.info> Co-authored-by: Max Weber <mii7303@gmail.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.ConfigSection;
|
||||
import net.runelite.client.config.Range;
|
||||
|
||||
@ConfigGroup("npcindicators")
|
||||
public interface NpcIndicatorsConfig extends Config
|
||||
@@ -79,6 +80,59 @@ public interface NpcIndicatorsConfig extends Config
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "highlightOutline",
|
||||
name = "Highlight outline",
|
||||
description = "Configures whether or not the model of the NPC should be highlighted by outline",
|
||||
section = renderStyleSection
|
||||
)
|
||||
default boolean highlightOutline()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Alpha
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "npcColor",
|
||||
name = "Highlight Color",
|
||||
description = "Color of the NPC highlight",
|
||||
section = renderStyleSection
|
||||
)
|
||||
default Color getHighlightColor()
|
||||
{
|
||||
return Color.CYAN;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "borderWidth",
|
||||
name = "Border Width",
|
||||
description = "Width of the highlighted NPC border",
|
||||
section = renderStyleSection
|
||||
)
|
||||
default double borderWidth()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
keyName = "outlineFeather",
|
||||
name = "Outline feather",
|
||||
description = "Specify between 0-4 how much of the model outline should be faded",
|
||||
section = renderStyleSection
|
||||
)
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 4
|
||||
)
|
||||
default int outlineFeather()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 7,
|
||||
keyName = "npcToHighlight",
|
||||
name = "NPCs to Highlight",
|
||||
description = "List of NPC names to highlight"
|
||||
@@ -95,31 +149,8 @@ public interface NpcIndicatorsConfig extends Config
|
||||
)
|
||||
void setNpcToHighlight(String npcsToHighlight);
|
||||
|
||||
@Alpha
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "npcColor",
|
||||
name = "Highlight Color",
|
||||
description = "Color of the NPC highlight"
|
||||
)
|
||||
default Color getHighlightColor()
|
||||
{
|
||||
return Color.CYAN;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "borderWidth",
|
||||
name = "Border Width",
|
||||
description = "Width of the highlighted NPC border"
|
||||
)
|
||||
default double borderWidth()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
position = 8,
|
||||
keyName = "drawNames",
|
||||
name = "Draw names above NPC",
|
||||
description = "Configures whether or not NPC names should be drawn above the NPC"
|
||||
@@ -130,7 +161,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 7,
|
||||
position = 9,
|
||||
keyName = "drawMinimapNames",
|
||||
name = "Draw names on minimap",
|
||||
description = "Configures whether or not NPC names should be drawn on the minimap"
|
||||
@@ -141,7 +172,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 8,
|
||||
position = 10,
|
||||
keyName = "highlightMenuNames",
|
||||
name = "Highlight menu names",
|
||||
description = "Highlight NPC names in right click menu"
|
||||
@@ -152,7 +183,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 9,
|
||||
position = 11,
|
||||
keyName = "ignoreDeadNpcs",
|
||||
name = "Ignore dead NPCs",
|
||||
description = "Prevents highlighting NPCs after they are dead"
|
||||
@@ -163,7 +194,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 10,
|
||||
position = 12,
|
||||
keyName = "deadNpcMenuColor",
|
||||
name = "Dead NPC menu color",
|
||||
description = "Color of the NPC menus for dead NPCs"
|
||||
@@ -171,7 +202,7 @@ public interface NpcIndicatorsConfig extends Config
|
||||
Color deadNpcMenuColor();
|
||||
|
||||
@ConfigItem(
|
||||
position = 11,
|
||||
position = 13,
|
||||
keyName = "showRespawnTimer",
|
||||
name = "Show respawn timer",
|
||||
description = "Show respawn timer of tagged NPCs")
|
||||
|
||||
@@ -48,6 +48,7 @@ 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.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.outline.ModelOutlineRenderer;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
@@ -67,13 +68,16 @@ public class NpcSceneOverlay extends Overlay
|
||||
private final Client client;
|
||||
private final NpcIndicatorsConfig config;
|
||||
private final NpcIndicatorsPlugin plugin;
|
||||
private final ModelOutlineRenderer modelOutlineRenderer;
|
||||
|
||||
@Inject
|
||||
NpcSceneOverlay(Client client, NpcIndicatorsConfig config, NpcIndicatorsPlugin plugin)
|
||||
NpcSceneOverlay(Client client, NpcIndicatorsConfig config, NpcIndicatorsPlugin plugin,
|
||||
ModelOutlineRenderer modelOutlineRenderer)
|
||||
{
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
this.plugin = plugin;
|
||||
this.modelOutlineRenderer = modelOutlineRenderer;
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
}
|
||||
@@ -181,6 +185,11 @@ public class NpcSceneOverlay extends Overlay
|
||||
renderPoly(graphics, color, southWestTilePoly);
|
||||
}
|
||||
|
||||
if (config.highlightOutline())
|
||||
{
|
||||
modelOutlineRenderer.drawOutline(actor, (int)config.borderWidth(), color, config.outlineFeather());
|
||||
}
|
||||
|
||||
if (config.drawNames() && actor.getName() != null)
|
||||
{
|
||||
String npcName = Text.removeTags(actor.getName());
|
||||
|
||||
@@ -30,15 +30,50 @@ import net.runelite.client.config.Alpha;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.ConfigSection;
|
||||
import net.runelite.client.config.Range;
|
||||
|
||||
@ConfigGroup("objectindicators")
|
||||
public interface ObjectIndicatorsConfig extends Config
|
||||
{
|
||||
@ConfigSection(
|
||||
name = "Render style",
|
||||
description = "The render style of object highlighting",
|
||||
position = 0
|
||||
)
|
||||
String renderStyleSection = "renderStyleSection";
|
||||
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "highlightHull",
|
||||
name = "Highlight hull",
|
||||
description = "Configures whether or not object should be highlighted by hull",
|
||||
section = renderStyleSection
|
||||
)
|
||||
default boolean highlightHull()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "highlightOutline",
|
||||
name = "Highlight outline",
|
||||
description = "Configures whether or not the model of the object should be highlighted by outline",
|
||||
section = renderStyleSection
|
||||
)
|
||||
default boolean highlightOutline()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Alpha
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "markerColor",
|
||||
name = "Marker color",
|
||||
description = "Configures the color of object marker"
|
||||
description = "Configures the color of object marker",
|
||||
section = renderStyleSection
|
||||
)
|
||||
default Color markerColor()
|
||||
{
|
||||
@@ -46,6 +81,35 @@ public interface ObjectIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "borderWidth",
|
||||
name = "Border Width",
|
||||
description = "Width of the marked object border",
|
||||
section = renderStyleSection
|
||||
)
|
||||
default double borderWidth()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "outlineFeather",
|
||||
name = "Outline feather",
|
||||
description = "Specify between 0-4 how much of the model outline should be faded",
|
||||
section = renderStyleSection
|
||||
)
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 4
|
||||
)
|
||||
default int outlineFeather()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "rememberObjectColors",
|
||||
name = "Remember color per object",
|
||||
description = "Color objects using the color from time of marking"
|
||||
@@ -54,14 +118,4 @@ public interface ObjectIndicatorsConfig extends Config
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "borderWidth",
|
||||
name = "Border Width",
|
||||
description = "Width of the marked object border"
|
||||
)
|
||||
default double borderWidth()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,19 +43,23 @@ import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.outline.ModelOutlineRenderer;
|
||||
|
||||
class ObjectIndicatorsOverlay extends Overlay
|
||||
{
|
||||
private final Client client;
|
||||
private final ObjectIndicatorsConfig config;
|
||||
private final ObjectIndicatorsPlugin plugin;
|
||||
private final ModelOutlineRenderer modelOutlineRenderer;
|
||||
|
||||
@Inject
|
||||
private ObjectIndicatorsOverlay(Client client, ObjectIndicatorsConfig config, ObjectIndicatorsPlugin plugin)
|
||||
private ObjectIndicatorsOverlay(Client client, ObjectIndicatorsConfig config, ObjectIndicatorsPlugin plugin,
|
||||
ModelOutlineRenderer modelOutlineRenderer)
|
||||
{
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
this.plugin = plugin;
|
||||
this.modelOutlineRenderer = modelOutlineRenderer;
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.LOW);
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
@@ -93,43 +97,56 @@ class ObjectIndicatorsOverlay extends Overlay
|
||||
color = config.markerColor();
|
||||
}
|
||||
|
||||
final Shape polygon;
|
||||
Shape polygon2 = null;
|
||||
|
||||
if (object instanceof GameObject)
|
||||
if (config.highlightHull())
|
||||
{
|
||||
polygon = ((GameObject) object).getConvexHull();
|
||||
}
|
||||
else if (object instanceof WallObject)
|
||||
{
|
||||
polygon = ((WallObject) object).getConvexHull();
|
||||
polygon2 = ((WallObject) object).getConvexHull2();
|
||||
}
|
||||
else if (object instanceof DecorativeObject)
|
||||
{
|
||||
polygon = ((DecorativeObject) object).getConvexHull();
|
||||
polygon2 = ((DecorativeObject) object).getConvexHull2();
|
||||
}
|
||||
else if (object instanceof GroundObject)
|
||||
{
|
||||
polygon = ((GroundObject) object).getConvexHull();
|
||||
}
|
||||
else
|
||||
{
|
||||
polygon = object.getCanvasTilePoly();
|
||||
renderConvexHull(graphics, object, color, stroke);
|
||||
}
|
||||
|
||||
if (polygon != null)
|
||||
if (config.highlightOutline())
|
||||
{
|
||||
OverlayUtil.renderPolygon(graphics, polygon, color, stroke);
|
||||
}
|
||||
|
||||
if (polygon2 != null)
|
||||
{
|
||||
OverlayUtil.renderPolygon(graphics, polygon2, color, stroke);
|
||||
modelOutlineRenderer.drawOutline(object, (int)config.borderWidth(), color, config.outlineFeather());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderConvexHull(Graphics2D graphics, TileObject object, Color color, Stroke stroke)
|
||||
{
|
||||
final Shape polygon;
|
||||
Shape polygon2 = null;
|
||||
|
||||
if (object instanceof GameObject)
|
||||
{
|
||||
polygon = ((GameObject) object).getConvexHull();
|
||||
}
|
||||
else if (object instanceof WallObject)
|
||||
{
|
||||
polygon = ((WallObject) object).getConvexHull();
|
||||
polygon2 = ((WallObject) object).getConvexHull2();
|
||||
}
|
||||
else if (object instanceof DecorativeObject)
|
||||
{
|
||||
polygon = ((DecorativeObject) object).getConvexHull();
|
||||
polygon2 = ((DecorativeObject) object).getConvexHull2();
|
||||
}
|
||||
else if (object instanceof GroundObject)
|
||||
{
|
||||
polygon = ((GroundObject) object).getConvexHull();
|
||||
}
|
||||
else
|
||||
{
|
||||
polygon = object.getCanvasTilePoly();
|
||||
}
|
||||
|
||||
if (polygon != null)
|
||||
{
|
||||
OverlayUtil.renderPolygon(graphics, polygon, color, stroke);
|
||||
}
|
||||
|
||||
if (polygon2 != null)
|
||||
{
|
||||
OverlayUtil.renderPolygon(graphics, polygon2, color, stroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Woox <https://github.com/wooxsolo>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.ui.overlay.outline;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A class which manages 1024-sized blocks of memory.
|
||||
*/
|
||||
class IntBlockBuffer
|
||||
{
|
||||
public static final int BLOCK_BITS = 10;
|
||||
public static final int BLOCK_SIZE = 1 << BLOCK_BITS;
|
||||
|
||||
private int[] memory = new int[0];
|
||||
private int[] unusedBlockIndices = new int[0];
|
||||
private int unusedBlockIndicesLength;
|
||||
|
||||
private void increaseBlockCount()
|
||||
{
|
||||
int currBlockCount = memory.length >> BLOCK_BITS;
|
||||
int newBlockCount = Math.max(1, currBlockCount * 2);
|
||||
memory = Arrays.copyOf(memory, newBlockCount * BLOCK_SIZE);
|
||||
unusedBlockIndices = Arrays.copyOf(unusedBlockIndices, newBlockCount);
|
||||
for (int i = currBlockCount; i < newBlockCount; i++)
|
||||
{
|
||||
unusedBlockIndices[unusedBlockIndicesLength++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the whole memory buffer.
|
||||
*/
|
||||
public int[] getMemory()
|
||||
{
|
||||
return memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a new block as used.
|
||||
*
|
||||
* @return The index of the block.
|
||||
*/
|
||||
public int useNewBlock()
|
||||
{
|
||||
if (unusedBlockIndicesLength == 0)
|
||||
{
|
||||
increaseBlockCount();
|
||||
}
|
||||
|
||||
return unusedBlockIndices[--unusedBlockIndicesLength];
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a block as unused.
|
||||
*
|
||||
* @param index The index of the block. The block should be in use before calling this method.
|
||||
*/
|
||||
public void freeBlock(int index)
|
||||
{
|
||||
unusedBlockIndices[unusedBlockIndicesLength++] = index;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user