This commit is contained in:
Kyleeld
2019-06-11 22:02:08 +01:00
committed by GitHub
parent 3b3ebce7f4
commit f84d5b8568

View File

@@ -6,10 +6,10 @@
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this * 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * 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 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.SpriteID; import net.runelite.api.SpriteID;
import net.runelite.client.game.SpriteManager; import net.runelite.client.game.SpriteManager;
@@ -40,48 +41,47 @@ import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.PanelComponent;
public class InfernoJadOverlay extends Overlay public class InfernoJadOverlay extends Overlay
{ {
private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150); private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150);
private final Client client;
private final InfernoPlugin plugin;
private final SpriteManager spriteManager;
private final PanelComponent imagePanelComponent = new PanelComponent();
private final Client client; @Inject
private final InfernoPlugin plugin; private InfernoJadOverlay(Client client, InfernoPlugin plugin, SpriteManager spriteManager)
private final SpriteManager spriteManager; {
private final PanelComponent imagePanelComponent = new PanelComponent(); setPosition(OverlayPosition.BOTTOM_RIGHT);
setPriority(OverlayPriority.HIGH);
this.client = client;
this.plugin = plugin;
this.spriteManager = spriteManager;
}
@Inject @Override
private InfernoJadOverlay(Client client, InfernoPlugin plugin, SpriteManager spriteManager) public Dimension render(Graphics2D graphics)
{ {
setPosition(OverlayPosition.BOTTOM_RIGHT); final InfernoJadAttack attack = plugin.getAttack();
setPriority(OverlayPriority.HIGH);
this.client = client;
this.plugin = plugin;
this.spriteManager = spriteManager;
}
@Override if (attack == null)
public Dimension render(Graphics2D graphics) {
{ return null;
final InfernoJadAttack attack = plugin.getAttack(); }
if (attack == null) final BufferedImage prayerImage = getPrayerImage(attack);
{
return null;
}
final BufferedImage prayerImage = getPrayerImage(attack); imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(prayerImage));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(attack.getPrayer())
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
imagePanelComponent.getChildren().clear(); return imagePanelComponent.render(graphics);
imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); }
imagePanelComponent.setBackgroundColor(client.isPrayerActive(attack.getPrayer())
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics); private BufferedImage getPrayerImage(InfernoJadAttack attack)
} {
final int prayerSpriteID = attack == InfernoJadAttack.MAGIC ? SpriteID.PRAYER_PROTECT_FROM_MAGIC : SpriteID.PRAYER_PROTECT_FROM_MISSILES;
private BufferedImage getPrayerImage(InfernoJadAttack attack) return spriteManager.getSprite(prayerSpriteID, 0);
{ }
final int prayerSpriteID = attack == InfernoJadAttack.MAGIC ? SpriteID.PRAYER_PROTECT_FROM_MAGIC : SpriteID.PRAYER_PROTECT_FROM_MISSILES; }
return spriteManager.getSprite(prayerSpriteID, 0);
}
}