use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class TitheFarmPlantOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
Widget viewport = client.getViewportWidget();
for (TitheFarmPlant plant : plugin.getPlants()) {
LocalPoint localLocation = LocalPoint.fromWorld(client, plant.getWorldLocation());
net.runelite.api.Point canvasLocation = Perspective.worldToCanvas(client, localLocation.getX(), localLocation.getY(), client.getPlane());
if (viewport != null && localLocation != null) {
switch(plant.getState()) {
case UNWATERED:
drawTimerOnPlant(graphics, plant, canvasLocation, config.getColorUnwatered());
break;
case WATERED:
drawTimerOnPlant(graphics, plant, canvasLocation, config.getColorWatered());
break;
case GROWN:
drawTimerOnPlant(graphics, plant, canvasLocation, config.getColorGrown());
break;
}
}
}
return null;
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class PestControlOverlay method renderPortalWidgets.
private void renderPortalWidgets(Graphics2D graphics) {
PortalContext purple = game.getPurple();
PortalContext blue = game.getBlue();
PortalContext yellow = game.getYellow();
PortalContext red = game.getRed();
Widget purpleShield = client.getWidget(PURPLE.getShield());
Widget blueShield = client.getWidget(BLUE.getShield());
Widget yellowShield = client.getWidget(YELLOW.getShield());
Widget redShield = client.getWidget(RED.getShield());
Widget purpleHealth = client.getWidget(PURPLE.getHitpoints());
Widget blueHealth = client.getWidget(BLUE.getHitpoints());
Widget yellowHealth = client.getWidget(YELLOW.getHitpoints());
Widget redHealth = client.getWidget(RED.getHitpoints());
assert purpleShield != null;
assert blueShield != null;
assert yellowShield != null;
assert redShield != null;
// Check for fallen portals
if (purpleShield.isHidden()) {
game.fall(purple);
}
if (blueShield.isHidden()) {
game.fall(blue);
}
if (yellowShield.isHidden()) {
game.fall(yellow);
}
if (redShield.isHidden()) {
game.fall(red);
}
// Check for dead portals
if (isZero(purpleHealth)) {
game.die(purple);
}
if (isZero(blueHealth)) {
game.die(blue);
}
if (isZero(yellowHealth)) {
game.die(yellow);
}
if (isZero(redHealth)) {
game.die(red);
}
// display "ATK" overlay on recorded portals without shields
renderAttack(graphics, purple);
renderAttack(graphics, blue);
renderAttack(graphics, yellow);
renderAttack(graphics, red);
// display "NEXT" overlay on predicted portals
for (Portal portal : game.getNextPortals()) {
renderWidgetOverlay(graphics, portal, "NEXT", Color.ORANGE);
}
renderProgressWidget(graphics);
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class PestControlOverlay method renderProgressWidget.
private void renderProgressWidget(Graphics2D graphics) {
Widget bar = client.getWidget(WidgetInfo.PESTCONTROL_ACTIVITY_BAR).getChild(0);
Rectangle2D bounds = bar.getBounds().getBounds2D();
Widget prgs = client.getWidget(WidgetInfo.PESTCONTROL_ACTIVITY_PROGRESS).getChild(0);
int perc = (int) ((prgs.getBounds().getWidth() / bounds.getWidth()) * 100);
Color color = Color.GREEN;
if (perc < 25) {
color = Color.RED;
}
String text = String.valueOf(perc) + "%";
FontMetrics fm = graphics.getFontMetrics();
Rectangle2D textBounds = fm.getStringBounds(text, graphics);
int x = (int) (bounds.getX() - textBounds.getWidth());
int y = (int) (bounds.getY() + fm.getHeight() - 2);
graphics.setColor(Color.BLACK);
graphics.drawString(text, x + 1, y + 1);
graphics.setColor(color);
graphics.drawString(text, x, y);
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class PrayerFlickOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
if (// If there are no prayers active we don't need to be flicking
!prayersActive) {
return null;
}
Widget xpOrb = client.getWidget(WidgetInfo.QUICK_PRAYER_ORB);
if (xpOrb == null) {
return null;
}
Rectangle2D bounds = xpOrb.getBounds().getBounds2D();
if (bounds.getX() <= 0) {
return null;
}
// Purposefully using height twice here as the bounds of the prayer orb includes the number sticking out the side
int orbInnerHeight = (int) bounds.getHeight();
int orbInnerWidth = orbInnerHeight;
// x pos of the inside of the prayer orb
int orbInnerX = (int) (bounds.getX() + 24);
// y pos of the inside of the prayer orb
int orbInnerY = (int) (bounds.getY() - 1);
long timeSinceLastTick = Duration.between(startOfLastTick, Instant.now()).toMillis();
float tickProgress = timeSinceLastTick / 600f;
// Cap to 1, so if a tick continues past the expected 600 we don't move the indicator off the orb
tickProgress = Math.min(tickProgress, 1);
// t on interval [0,pi]
double t = tickProgress * Math.PI;
int xOffset = (int) (-Math.cos(t) * orbInnerWidth / 2) + orbInnerWidth / 2;
int indicatorHeight = (int) (Math.sin(t) * orbInnerHeight);
int yOffset = (orbInnerHeight / 2) - (indicatorHeight / 2);
graphics.setColor(Color.cyan);
graphics.fillRect(orbInnerX + xOffset, orbInnerY + yOffset, 1, indicatorHeight);
return new Dimension((int) bounds.getWidth(), (int) bounds.getHeight());
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class TitheFarmSackOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
Widget sack = client.getWidget(WidgetInfo.TITHE_FARM);
if (sack == null) {
return null;
}
panelComponent.getLines().clear();
sack.setHidden(true);
if (config.showSack()) {
panelComponent.getLines().add(new PanelComponent.Line("Fruits in sack:", String.valueOf(client.getSetting(Varbits.TITHE_FARM_SACK_AMOUNT))));
panelComponent.getLines().add(new PanelComponent.Line("Points:", String.valueOf(client.getSetting(Varbits.TITHE_FARM_POINTS))));
}
return panelComponent.render(graphics);
}
Aggregations