coxhelper: add scaling to infobox (#1295)
* coxhelper: add scaling to infobox, and remove local config caching. * coxhelper: revert config changes.
This commit is contained in:
@@ -41,7 +41,7 @@ public interface CoxConfig extends Config
|
||||
{
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum FontStyle
|
||||
enum FontStyle
|
||||
{
|
||||
BOLD("Bold", Font.BOLD),
|
||||
ITALIC("Italic", Font.ITALIC),
|
||||
@@ -67,6 +67,7 @@ public interface CoxConfig extends Config
|
||||
{
|
||||
return new Stub();
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "muttadile",
|
||||
@@ -207,6 +208,22 @@ public interface CoxConfig extends Config
|
||||
return true;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 40,
|
||||
max = 100
|
||||
)
|
||||
@ConfigItem(
|
||||
position = 11,
|
||||
keyName = "prayAgainstOlmSize",
|
||||
name = "Olm Prayer Size",
|
||||
description = "Change the Size of the Olm Infobox.",
|
||||
parent = "olmStub"
|
||||
)
|
||||
default int prayAgainstOlmSize()
|
||||
{
|
||||
return 40;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 12,
|
||||
keyName = "timers",
|
||||
|
||||
@@ -26,7 +26,6 @@ package net.runelite.client.plugins.coxhelper;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -46,6 +45,7 @@ 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;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@Singleton
|
||||
public class CoxInfoBox extends Overlay
|
||||
@@ -65,7 +65,6 @@ public class CoxInfoBox extends Overlay
|
||||
this.spriteManager = spriteManager;
|
||||
setPosition(OverlayPosition.BOTTOM_RIGHT);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,17 +84,21 @@ public class CoxInfoBox extends Overlay
|
||||
|
||||
if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null)
|
||||
{
|
||||
final int scale = plugin.getPrayAgainstSize();
|
||||
InfoBoxComponent prayComponent = new InfoBoxComponent();
|
||||
BufferedImage prayImg = scaleImg(getPrayerImage(plugin.getPrayAgainstOlm()));
|
||||
BufferedImage prayImg = ImageUtil.resizeImage(
|
||||
getPrayerImage(plugin.getPrayAgainstOlm()), scale, scale
|
||||
);
|
||||
prayComponent.setImage(prayImg);
|
||||
prayComponent.setColor(Color.WHITE);
|
||||
prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer())
|
||||
? ComponentConstants.STANDARD_BACKGROUND_COLOR
|
||||
: NOT_ACTIVATED_BACKGROUND_COLOR);
|
||||
prayComponent.setPreferredSize(new Dimension(40, 40));
|
||||
: NOT_ACTIVATED_BACKGROUND_COLOR
|
||||
);
|
||||
prayComponent.setPreferredSize(new Dimension(scale + 4, scale + 4));
|
||||
prayAgainstPanel.getChildren().add(prayComponent);
|
||||
|
||||
prayAgainstPanel.setPreferredSize(new Dimension(40, 40));
|
||||
prayAgainstPanel.setPreferredSize(new Dimension(scale + 4, scale + 4));
|
||||
prayAgainstPanel.setBorder(new Rectangle(0, 0, 0, 0));
|
||||
return prayAgainstPanel.render(graphics);
|
||||
}
|
||||
@@ -155,28 +158,8 @@ public class CoxInfoBox extends Overlay
|
||||
return spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MELEE, 0);
|
||||
case RANGED:
|
||||
return spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0);
|
||||
default:
|
||||
return spriteManager.getSprite(SpriteID.BARBARIAN_ASSAULT_EAR_ICON, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedImage scaleImg(final BufferedImage img)
|
||||
{
|
||||
if (img == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final double width = img.getWidth(null);
|
||||
final double height = img.getHeight(null);
|
||||
final double size = 36; // Limit size to 2 as that is minimum size not causing breakage
|
||||
final double scalex = size / width;
|
||||
final double scaley = size / height;
|
||||
final double scale = Math.min(scalex, scaley);
|
||||
final int newWidth = (int) (width * scale);
|
||||
final int newHeight = (int) (height * scale);
|
||||
final BufferedImage scaledImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
final Graphics g = scaledImage.createGraphics();
|
||||
g.drawImage(img, 0, 0, newWidth, newHeight, null);
|
||||
g.dispose();
|
||||
return scaledImage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import javax.inject.Singleton;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NPCDefinition;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
@@ -55,9 +54,7 @@ import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
@Singleton
|
||||
public class CoxOverlay extends Overlay
|
||||
{
|
||||
private static final Set<Integer> GAP = ImmutableSet.of(
|
||||
34, 33, 26, 25, 18, 17, 10, 9, 2, 1
|
||||
);
|
||||
private static final Set<Integer> GAP = ImmutableSet.of(34, 33, 26, 25, 18, 17, 10, 9, 2, 1);
|
||||
private final Client client;
|
||||
private final CoxPlugin plugin;
|
||||
|
||||
@@ -76,13 +73,13 @@ public class CoxOverlay extends Overlay
|
||||
{
|
||||
for (WorldPoint point : plugin.getOlm_Heal())
|
||||
{
|
||||
drawTile(graphics, point, plugin.getTpColor(), 2, 150, 50);
|
||||
drawTile(graphics, point, plugin.getTpColor(), 2, 150);
|
||||
}
|
||||
|
||||
for (WorldPoint point : plugin.getOlm_TP())
|
||||
{
|
||||
client.setHintArrow(point);
|
||||
drawTile(graphics, point, plugin.getTpColor(), 2, 150, 50);
|
||||
drawTile(graphics, point, plugin.getTpColor(), 2, 150);
|
||||
}
|
||||
|
||||
if (plugin.inRaid())
|
||||
@@ -105,11 +102,14 @@ public class CoxOverlay extends Overlay
|
||||
hitSquares = getHitSquares(npcs.getNpc().getWorldLocation(), npcs.getNpcSize(), 1, false);
|
||||
for (WorldPoint p : hitSquares)
|
||||
{
|
||||
drawTile(graphics, p, plugin.getTektonColor(), 0, 0, 50);
|
||||
drawTile(graphics, p, plugin.getTektonColor(), 0, 0);
|
||||
}
|
||||
if (plugin.isTektonTickCounter())
|
||||
{
|
||||
ticksLeft = npcs.getTicksUntilAttack();
|
||||
final int attackTicksleft = plugin.getTektonAttackTicks();
|
||||
String attacksLeftStr;
|
||||
Color attackcolor;
|
||||
if (ticksLeft > 0)
|
||||
{
|
||||
if (ticksLeft == 1)
|
||||
@@ -124,12 +124,6 @@ public class CoxOverlay extends Overlay
|
||||
Point canvasPoint = npcs.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0);
|
||||
renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), color, canvasPoint);
|
||||
}
|
||||
}
|
||||
if (plugin.isTektonTickCounter())
|
||||
{
|
||||
final int attackTicksleft = plugin.getTektonAttackTicks();
|
||||
String attacksLeftStr;
|
||||
Color attackcolor;
|
||||
if (attackTicksleft >= 0 && plugin.isTektonActive())
|
||||
{
|
||||
if (attackTicksleft <= 1)
|
||||
@@ -160,7 +154,7 @@ public class CoxOverlay extends Overlay
|
||||
hitSquares = getHitSquares(npcs.getNpc().getWorldLocation(), npcs.getNpcSize(), 1, false);
|
||||
for (WorldPoint p : hitSquares)
|
||||
{
|
||||
drawTile(graphics, p, plugin.getMuttaColor(), 0, 0, 50);
|
||||
drawTile(graphics, p, plugin.getMuttaColor(), 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -173,7 +167,7 @@ public class CoxOverlay extends Overlay
|
||||
hitSquares = getHitSquares(npcs.getNpc().getWorldLocation(), npcs.getNpcSize(), 2, true);
|
||||
for (WorldPoint p : hitSquares)
|
||||
{
|
||||
drawTile(graphics, p, plugin.getGuardColor(), 0, 0, 50);
|
||||
drawTile(graphics, p, plugin.getGuardColor(), 0, 0);
|
||||
}
|
||||
}
|
||||
if (plugin.isGuardinTickCounter())
|
||||
@@ -274,7 +268,7 @@ public class CoxOverlay extends Overlay
|
||||
Point canvasPoint = victim.getPlayer().getCanvasTextLocation(graphics, ticksLeftStr, 0);
|
||||
renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint);
|
||||
}
|
||||
renderActorOverlay(graphics, victim.getPlayer(), new Color(193, 255, 245, 255), 2, 100, 10);
|
||||
renderActorOverlay(graphics, victim.getPlayer(), new Color(193, 255, 245, 255));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -290,9 +284,9 @@ public class CoxOverlay extends Overlay
|
||||
{
|
||||
if (boss != null)
|
||||
{
|
||||
int tick = plugin.getOlm_TicksUntilAction();
|
||||
int cycle = plugin.getOlm_ActionCycle();
|
||||
int spec = plugin.getOlm_NextSpec();
|
||||
final int tick = plugin.getOlm_TicksUntilAction();
|
||||
final int cycle = plugin.getOlm_ActionCycle();
|
||||
final int spec = plugin.getOlm_NextSpec();
|
||||
final String tickStr = String.valueOf(tick);
|
||||
String cycleStr = "?";
|
||||
switch (cycle)
|
||||
@@ -341,7 +335,7 @@ public class CoxOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
private void drawTile(Graphics2D graphics, WorldPoint point, Color color, int strokeWidth, int outlineAlpha, int fillAlpha)
|
||||
private void drawTile(Graphics2D graphics, WorldPoint point, Color color, int strokeWidth, int outlineAlpha)
|
||||
{
|
||||
WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation();
|
||||
if (point.distanceTo(playerLocation) >= 32)
|
||||
@@ -363,43 +357,22 @@ public class CoxOverlay extends Overlay
|
||||
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.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 50));
|
||||
graphics.fill(poly);
|
||||
}
|
||||
|
||||
private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha)
|
||||
private void renderActorOverlay(Graphics2D graphics, Actor actor, Color color)
|
||||
{
|
||||
int size = 1;
|
||||
NPCDefinition composition = actor.getTransformedDefinition();
|
||||
if (composition != null)
|
||||
{
|
||||
size = composition.getSize();
|
||||
}
|
||||
LocalPoint lp = actor.getLocalLocation();
|
||||
Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);
|
||||
final int size = 1;
|
||||
final LocalPoint lp = actor.getLocalLocation();
|
||||
final 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.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 100));
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.draw(tilePoly);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
|
||||
graphics.fill(tilePoly);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderActorOverlay(Graphics2D graphics, Actor actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha)
|
||||
{
|
||||
int size = 1;
|
||||
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.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 10));
|
||||
graphics.fill(tilePoly);
|
||||
}
|
||||
}
|
||||
@@ -444,8 +417,8 @@ public class CoxOverlay 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();
|
||||
final List<WorldPoint> little = new WorldArea(npcLoc, npcSize, npcSize).toWorldPointList();
|
||||
final 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);
|
||||
|
||||
@@ -141,6 +141,7 @@ public class CoxPlugin extends Plugin
|
||||
private boolean timers;
|
||||
private boolean tpOverlay;
|
||||
private boolean olmTick;
|
||||
private int prayAgainstSize;
|
||||
private Color muttaColor;
|
||||
private Color guardColor;
|
||||
private Color tektonColor;
|
||||
@@ -162,7 +163,6 @@ public class CoxPlugin extends Plugin
|
||||
{
|
||||
updateConfig();
|
||||
addSubscriptions();
|
||||
|
||||
overlayManager.add(coxOverlay);
|
||||
overlayManager.add(coxInfoBox);
|
||||
handCripple = false;
|
||||
@@ -651,5 +651,6 @@ public class CoxPlugin extends Plugin
|
||||
this.fontStyle = config.fontStyle();
|
||||
this.textSize = config.textSize();
|
||||
this.shadows = config.shadows();
|
||||
this.prayAgainstSize = config.prayAgainstOlmSize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ class NPCContainer
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private Actor npcInteracting;
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private Specials specials;
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private Attackstyle attackStyle;
|
||||
|
||||
|
||||
@@ -66,7 +64,6 @@ class NPCContainer
|
||||
this.ticksUntilAttack = 0;
|
||||
this.intermissionPeriod = 0;
|
||||
this.attackStyle = Attackstyle.UNKNOWN;
|
||||
this.specials = Specials.UNKNOWN;
|
||||
final NPCDefinition composition = npc.getTransformedDefinition();
|
||||
|
||||
if (composition != null)
|
||||
@@ -75,19 +72,6 @@ class NPCContainer
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
public enum Specials
|
||||
{
|
||||
PORTALS("Portals"),
|
||||
LIGHTNING("Lightning"),
|
||||
CRYSTALS("Crystals"),
|
||||
HEAL("Heal"),
|
||||
UNKNOWN("Unknown");
|
||||
|
||||
private String name = "";
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
public enum Attackstyle
|
||||
|
||||
Reference in New Issue
Block a user