api: develop
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,14 @@
|
||||
package com.openosrs.client.ui.overlay;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Perspective;
|
||||
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.vars.InterfaceTab;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class OverlayUtil extends net.runelite.client.ui.overlay.OverlayUtil
|
||||
{
|
||||
@@ -39,4 +40,45 @@ public class OverlayUtil extends net.runelite.client.ui.overlay.OverlayUtil
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
|
||||
graphics.fill(poly);
|
||||
}
|
||||
|
||||
public static Rectangle renderPrayerOverlay(Graphics2D graphics, Client client, Prayer prayer, Color color)
|
||||
{
|
||||
Widget widget = client.getWidget(prayer.getWidgetInfo());
|
||||
|
||||
if (widget == null || client.getVar(VarClientInt.INVENTORY_TAB) != InterfaceTab.PRAYER.getId())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Rectangle bounds = widget.getBounds();
|
||||
renderPolygon(graphics, rectangleToPolygon(bounds), color);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
private static Polygon rectangleToPolygon(Rectangle rect)
|
||||
{
|
||||
int[] xpoints = {rect.x, rect.x + rect.width, rect.x + rect.width, rect.x};
|
||||
int[] ypoints = {rect.y, rect.y, rect.y + rect.height, rect.y + rect.height};
|
||||
|
||||
return new Polygon(xpoints, ypoints, 4);
|
||||
}
|
||||
|
||||
public static void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint, boolean shadows, int yOffset)
|
||||
{
|
||||
graphics.setFont(new Font("Arial", fontStyle, fontSize));
|
||||
if (canvasPoint != null)
|
||||
{
|
||||
final Point canvasCenterPoint = new Point(
|
||||
canvasPoint.getX(),
|
||||
canvasPoint.getY() + yOffset);
|
||||
final Point canvasCenterPoint_shadow = new Point(
|
||||
canvasPoint.getX() + 1,
|
||||
canvasPoint.getY() + 1 + yOffset);
|
||||
if (shadows)
|
||||
{
|
||||
renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK);
|
||||
}
|
||||
renderTextLocation(graphics, canvasCenterPoint, txtString, fontColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.openosrs.client.util;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.SpritePixels;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ImageUtil extends net.runelite.client.util.ImageUtil
|
||||
@@ -56,4 +60,134 @@ public class ImageUtil extends net.runelite.client.util.ImageUtil
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw fg centered on top of bg
|
||||
*/
|
||||
public static SpritePixels mergeSprites(final Client client, final SpritePixels bg, final SpritePixels fg)
|
||||
{
|
||||
assert fg.getHeight() <= bg.getHeight() && fg.getWidth() <= bg.getWidth() : "Background has to be larger than foreground";
|
||||
|
||||
final int[] canvas = Arrays.copyOf(bg.getPixels(), bg.getWidth() * bg.getHeight());
|
||||
final SpritePixels result = client.createSpritePixels(canvas, bg.getWidth(), bg.getHeight());
|
||||
|
||||
final int bgWid = bg.getWidth();
|
||||
final int fgHgt = fg.getHeight();
|
||||
final int fgWid = fg.getWidth();
|
||||
|
||||
final int xOffset = (bgWid - fgWid) / 2;
|
||||
final int yOffset = (bg.getHeight() - fgHgt) / 2;
|
||||
|
||||
final int[] fgPixels = fg.getPixels();
|
||||
|
||||
for (int y1 = yOffset, y2 = 0; y2 < fgHgt; y1++, y2++)
|
||||
{
|
||||
int i1 = y1 * bgWid + xOffset;
|
||||
int i2 = y2 * fgWid;
|
||||
|
||||
for (int x = 0; x < fgWid; x++, i1++, i2++)
|
||||
{
|
||||
if (fgPixels[i2] > 0)
|
||||
{
|
||||
canvas[i1] = fgPixels[i2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize Sprite sprite to given width (newW) and height (newH)
|
||||
*/
|
||||
public static SpritePixels resizeSprite(final Client client, final SpritePixels sprite, int newW, int newH)
|
||||
{
|
||||
assert newW > 0 && newH > 0;
|
||||
|
||||
final int oldW = sprite.getWidth();
|
||||
final int oldH = sprite.getHeight();
|
||||
|
||||
if (oldW == newW && oldH == newH)
|
||||
{
|
||||
return sprite;
|
||||
}
|
||||
|
||||
final int[] canvas = new int[newW * newH];
|
||||
final int[] pixels = sprite.getPixels();
|
||||
|
||||
final SpritePixels result = client.createSpritePixels(canvas, newW, newH);
|
||||
|
||||
int pixelX = 0;
|
||||
int pixelY = 0;
|
||||
|
||||
final int oldMaxW = sprite.getMaxWidth();
|
||||
final int oldMaxH = sprite.getMaxHeight();
|
||||
|
||||
final int pixelW = (oldMaxW << 16) / newW;
|
||||
final int pixelH = (oldMaxH << 16) / newH;
|
||||
|
||||
int xOffset = 0;
|
||||
int yOffset = 0;
|
||||
|
||||
int canvasIdx;
|
||||
if (sprite.getOffsetX() > 0)
|
||||
{
|
||||
canvasIdx = (pixelW + (sprite.getOffsetX() << 16) - 1) / pixelW;
|
||||
xOffset += canvasIdx;
|
||||
pixelX += canvasIdx * pixelW - (sprite.getOffsetX() << 16);
|
||||
}
|
||||
|
||||
if (sprite.getOffsetY() > 0)
|
||||
{
|
||||
canvasIdx = (pixelH + (sprite.getOffsetY() << 16) - 1) / pixelH;
|
||||
yOffset += canvasIdx;
|
||||
pixelY += canvasIdx * pixelH - (sprite.getOffsetY() << 16);
|
||||
}
|
||||
|
||||
if (oldW < oldMaxW)
|
||||
{
|
||||
newW = (pixelW + ((oldW << 16) - pixelX) - 1) / pixelW;
|
||||
}
|
||||
|
||||
if (oldH < oldMaxH)
|
||||
{
|
||||
newH = (pixelH + ((oldH << 16) - pixelY) - 1) / pixelH;
|
||||
}
|
||||
|
||||
canvasIdx = xOffset + yOffset * newW;
|
||||
int canvasOffset = 0;
|
||||
if (yOffset + newH > newH)
|
||||
{
|
||||
newH -= yOffset + newH - newH;
|
||||
}
|
||||
|
||||
int tmp;
|
||||
if (yOffset < 0)
|
||||
{
|
||||
tmp = -yOffset;
|
||||
newH -= tmp;
|
||||
canvasIdx += tmp * newW;
|
||||
pixelY += pixelH * tmp;
|
||||
}
|
||||
|
||||
if (newW + xOffset > newW)
|
||||
{
|
||||
tmp = newW + xOffset - newW;
|
||||
newW -= tmp;
|
||||
canvasOffset += tmp;
|
||||
}
|
||||
|
||||
if (xOffset < 0)
|
||||
{
|
||||
tmp = -xOffset;
|
||||
newW -= tmp;
|
||||
canvasIdx += tmp;
|
||||
pixelX += pixelW * tmp;
|
||||
canvasOffset += tmp;
|
||||
}
|
||||
|
||||
client.scaleSprite(canvas, pixels, 0, pixelX, pixelY, canvasIdx, canvasOffset, newW, newH, pixelW, pixelH, oldW);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package net.runelite.client.config;
|
||||
|
||||
import com.openosrs.client.OpenOSRS;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -48,4 +50,10 @@ public @interface ConfigItem
|
||||
boolean secret() default false;
|
||||
|
||||
String section() default "";
|
||||
|
||||
/*
|
||||
OpenOSRS Lazy Helpers tm
|
||||
*/
|
||||
Class<?> enumClass() default OpenOSRS.class;
|
||||
String unhide() default "";
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package net.runelite.client.config;
|
||||
|
||||
import com.openosrs.client.OpenOSRS;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -40,4 +42,9 @@ public @interface ConfigSection
|
||||
int position();
|
||||
|
||||
boolean closedByDefault() default false;
|
||||
|
||||
/*
|
||||
OpenOSRS Lazy Helpers tm
|
||||
*/
|
||||
String keyName() default "";
|
||||
}
|
||||
|
||||
@@ -42,8 +42,12 @@ public @interface Units
|
||||
String MINUTES = " mins";
|
||||
String PERCENT = "%";
|
||||
String PIXELS = "px";
|
||||
String POINTS = "pt";
|
||||
String SECONDS = "s";
|
||||
String TICKS = " ticks";
|
||||
String LEVELS = " lvls";
|
||||
String FPS = " fps";
|
||||
String GP = " GP";
|
||||
|
||||
String value();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user