Merge pull request #271 from devinfrench/zulrah

Update zulrah plugin overlay
This commit is contained in:
Adam
2017-12-22 16:32:14 -05:00
committed by GitHub
13 changed files with 428 additions and 231 deletions

View File

@@ -29,6 +29,8 @@ package net.runelite.client.plugins.zulrah;
import com.google.inject.Binder;
import com.google.inject.Provides;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collection;
import javax.annotation.Nullable;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
@@ -41,6 +43,10 @@ import net.runelite.client.RuneLite;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.zulrah.overlays.ZulrahCurrentPhaseOverlay;
import net.runelite.client.plugins.zulrah.overlays.ZulrahNextPhaseOverlay;
import net.runelite.client.plugins.zulrah.overlays.ZulrahOverlay;
import net.runelite.client.plugins.zulrah.overlays.ZulrahPrayerOverlay;
import net.runelite.client.plugins.zulrah.patterns.ZulrahPattern;
import net.runelite.client.plugins.zulrah.patterns.ZulrahPatternA;
import net.runelite.client.plugins.zulrah.patterns.ZulrahPatternB;
@@ -69,6 +75,15 @@ public class ZulrahPlugin extends Plugin
@Inject
ZulrahOverlay overlay;
@Inject
ZulrahCurrentPhaseOverlay currentPhaseOverlay;
@Inject
ZulrahNextPhaseOverlay nextPhaseOverlay;
@Inject
ZulrahPrayerOverlay zulrahPrayerOverlay;
private final ZulrahPattern[] patterns = new ZulrahPattern[]
{
new ZulrahPatternA(),
@@ -92,9 +107,9 @@ public class ZulrahPlugin extends Plugin
}
@Override
public Overlay getOverlay()
public Collection<Overlay> getOverlays()
{
return overlay;
return Arrays.asList(overlay, currentPhaseOverlay, nextPhaseOverlay, zulrahPrayerOverlay);
}
@Schedule(

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* 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.plugins.zulrah.overlays;
import net.runelite.client.plugins.zulrah.ZulrahInstance;
import net.runelite.client.plugins.zulrah.ZulrahPlugin;
import net.runelite.client.plugins.zulrah.phase.ZulrahPhase;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.ImagePanelComponent;
import javax.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
public class ZulrahCurrentPhaseOverlay extends Overlay
{
private final ZulrahPlugin plugin;
@Inject
ZulrahCurrentPhaseOverlay(ZulrahPlugin plugin)
{
setPosition(OverlayPosition.BOTTOM_RIGHT);
setPriority(OverlayPriority.HIGH);
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
ZulrahInstance instance = plugin.getInstance();
if (instance == null)
{
return null;
}
ZulrahPhase currentPhase = instance.getPhase();
if (currentPhase == null)
{
return null;
}
String pattern = instance.getPattern() != null ? instance.getPattern().toString() : "Unknown";
String title = currentPhase.isJad() ? "JAD PHASE" : pattern;
Color backgroundColor = currentPhase.getColor();
BufferedImage zulrahImage = ZulrahImageManager.getZulrahBufferedImage(currentPhase.getType());
ImagePanelComponent imagePanelComponent = new ImagePanelComponent();
imagePanelComponent.setTitle(title);
imagePanelComponent.setBackgroundColor(backgroundColor);
imagePanelComponent.setImage(zulrahImage);
return imagePanelComponent.render(graphics, parent);
}
}

View File

@@ -0,0 +1,130 @@
/*
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* 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.plugins.zulrah.overlays;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Prayer;
import net.runelite.client.plugins.zulrah.ZulrahPlugin;
import net.runelite.client.plugins.zulrah.phase.ZulrahType;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
@Slf4j
public class ZulrahImageManager
{
private static final BufferedImage[] zulrahBufferedImages = new BufferedImage[3];
private static final BufferedImage[] smallZulrahBufferedImages = new BufferedImage[3];
private static final BufferedImage[] prayerBufferedImages = new BufferedImage[2];
public static BufferedImage getZulrahBufferedImage(ZulrahType type)
{
switch (type)
{
case RANGE:
if (zulrahBufferedImages[0] == null)
{
zulrahBufferedImages[0] = getBufferedImage("zulrah_range.png");
}
return zulrahBufferedImages[0];
case MAGIC:
if (zulrahBufferedImages[1] == null)
{
zulrahBufferedImages[1] = getBufferedImage("zulrah_magic.png");
}
return zulrahBufferedImages[1];
case MELEE:
if (zulrahBufferedImages[2] == null)
{
zulrahBufferedImages[2] = getBufferedImage("zulrah_melee.png");
}
return zulrahBufferedImages[2];
}
return null;
}
public static BufferedImage getSmallZulrahBufferedImage(ZulrahType type)
{
switch (type)
{
case RANGE:
if (smallZulrahBufferedImages[0] == null)
{
smallZulrahBufferedImages[0] = getBufferedImage("zulrah_range_sm.png");
}
return smallZulrahBufferedImages[0];
case MAGIC:
if (smallZulrahBufferedImages[1] == null)
{
smallZulrahBufferedImages[1] = getBufferedImage("zulrah_magic_sm.png");
}
return smallZulrahBufferedImages[1];
case MELEE:
if (smallZulrahBufferedImages[2] == null)
{
smallZulrahBufferedImages[2] = getBufferedImage("zulrah_melee_sm.png");
}
return smallZulrahBufferedImages[2];
}
return null;
}
public static BufferedImage getProtectionPrayerBufferedImage(Prayer prayer)
{
switch (prayer)
{
case PROTECT_FROM_MAGIC:
if (prayerBufferedImages[0] == null)
{
prayerBufferedImages[0] = getBufferedImage("/prayers/protect_from_magic.png");
}
return prayerBufferedImages[0];
case PROTECT_FROM_MISSILES:
if (prayerBufferedImages[1] == null)
{
prayerBufferedImages[1] = getBufferedImage("/prayers/protect_from_missiles.png");
}
return prayerBufferedImages[1];
}
return null;
}
private static BufferedImage getBufferedImage(String path)
{
BufferedImage image = null;
try
{
InputStream in = ZulrahPlugin.class.getResourceAsStream(path);
image = ImageIO.read(in);
}
catch (IOException e)
{
log.debug("Error loading image {}", e);
}
return image;
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* 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.plugins.zulrah.overlays;
import net.runelite.client.plugins.zulrah.ZulrahInstance;
import net.runelite.client.plugins.zulrah.ZulrahPlugin;
import net.runelite.client.plugins.zulrah.phase.ZulrahPhase;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.ImagePanelComponent;
import javax.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
public class ZulrahNextPhaseOverlay extends Overlay
{
private final ZulrahPlugin plugin;
@Inject
ZulrahNextPhaseOverlay(ZulrahPlugin plugin)
{
setPosition(OverlayPosition.BOTTOM_RIGHT);
setPriority(OverlayPriority.HIGH);
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
ZulrahInstance instance = plugin.getInstance();
if (instance == null)
{
return null;
}
ZulrahPhase nextPhase = instance.getNextPhase();
if (nextPhase == null)
{
return null;
}
Color backgroundColor = nextPhase.getColor();
BufferedImage zulrahImage = ZulrahImageManager.getSmallZulrahBufferedImage(nextPhase.getType());
ImagePanelComponent imagePanelComponent = new ImagePanelComponent();
imagePanelComponent.setTitle("Next");
imagePanelComponent.setBackgroundColor(backgroundColor);
imagePanelComponent.setImage(zulrahImage);
return imagePanelComponent.render(graphics, parent);
}
}

View File

@@ -23,7 +23,7 @@
* (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.plugins.zulrah;
package net.runelite.client.plugins.zulrah.overlays;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -32,44 +32,27 @@ import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.plugins.zulrah.ZulrahInstance;
import net.runelite.client.plugins.zulrah.ZulrahPlugin;
import net.runelite.client.plugins.zulrah.phase.ZulrahPhase;
import net.runelite.client.plugins.zulrah.phase.ZulrahType;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
@Slf4j
public class ZulrahOverlay extends Overlay
{
private static final int CURRENT_PHASE_WIDTH = 86;
private static final int NEXT_PHASE_WIDTH = 54;
private static final int SPACER = 6;
private static final int BOTTOM_BORDER = 4;
private static final Color TILE_BORDER_COLOR = new Color(0, 0, 0, 100);
private static final Color NEXT_TEXT_COLOR = new Color(255, 255, 255, 100);
private static final Color RANGE_BACKGROUND_COLOR = new Color(150, 255, 0, 100);
private static final Color MAGIC_BACKGROUND_COLOR = new Color(20, 170, 200, 100);
private static final Color MELEE_BACKGROUND_COLOR = new Color(180, 50, 20, 100);
private static final Color JAD_BACKGROUND_COLOR = new Color(255, 115, 0, 100);
private final Client client;
private final ZulrahPlugin plugin;
private final Image[] zulrahImages = new Image[3];
private final Image[] smallZulrahImages = new Image[3];
private final Image[] prayerImages = new Image[2];
@Inject
ZulrahOverlay(@Nullable Client client, ZulrahPlugin plugin)
@@ -89,12 +72,6 @@ public class ZulrahOverlay extends Overlay
return null;
}
Rectangle viewport = getViewportBounds();
if (viewport == null)
{
return null;
}
ZulrahPhase currentPhase = instance.getPhase();
ZulrahPhase nextPhase = instance.getNextPhase();
if (currentPhase == null)
@@ -102,7 +79,6 @@ public class ZulrahOverlay extends Overlay
return null;
}
String pattern = instance.getPattern() != null ? instance.getPattern().toString() : "Unknown";
Point startTile = instance.getStartLocation();
if (nextPhase != null && currentPhase.getStandLocation() == nextPhase.getStandLocation())
{
@@ -115,9 +91,6 @@ public class ZulrahOverlay extends Overlay
}
drawZulrahTileMinimap(graphics, startTile, currentPhase, false);
drawZulrahTileMinimap(graphics, startTile, nextPhase, true);
drawCurrentPhaseBox(graphics, viewport, currentPhase, pattern);
drawNextPhaseBox(graphics, viewport, nextPhase);
drawPrayerOutline(graphics, currentPhase.getPrayer());
return null;
}
@@ -132,8 +105,8 @@ public class ZulrahOverlay extends Overlay
Point textLoc = Perspective.getCanvasTextLocation(client, graphics, localTile, "Next", 0);
if (northPoly != null && southPoly != null && poly != null && textLoc != null)
{
Color northColor = getBackgroundColor(currentPhase.getType());
Color southColor = getBackgroundColor(nextPhase.getType());
Color northColor = currentPhase.getColor();
Color southColor = nextPhase.getColor();
graphics.setColor(northColor);
graphics.fillPolygon(northPoly);
graphics.setColor(southColor);
@@ -146,7 +119,7 @@ public class ZulrahOverlay extends Overlay
}
if (nextPhase.isJad())
{
Image jadPrayerImg = getProtectionPrayerImage(nextPhase.getPrayer());
Image jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(nextPhase.getPrayer());
if (jadPrayerImg != null)
{
Point imageLoc = Perspective.getCanvasImageLocation(client, graphics, localTile, (BufferedImage) jadPrayerImg, 0);
@@ -168,7 +141,7 @@ public class ZulrahOverlay extends Overlay
Point localTile = Perspective.worldToLocal(client, phase.getStandTile(startTile));
localTile = new Point(localTile.getX() + Perspective.LOCAL_TILE_SIZE / 2, localTile.getY() + Perspective.LOCAL_TILE_SIZE / 2);
Polygon poly = Perspective.getCanvasTilePoly(client, localTile);
Color color = getBackgroundColor(phase.getType());
Color color = phase.getColor();
if (poly != null)
{
graphics.setColor(TILE_BORDER_COLOR);
@@ -187,7 +160,7 @@ public class ZulrahOverlay extends Overlay
}
if (phase.isJad())
{
Image jadPrayerImg = getProtectionPrayerImage(phase.getPrayer());
Image jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(phase.getPrayer());
if (jadPrayerImg != null)
{
Point imageLoc = Perspective.getCanvasImageLocation(client, graphics, localTile, (BufferedImage) jadPrayerImg, 0);
@@ -208,7 +181,7 @@ public class ZulrahOverlay extends Overlay
}
Point zulrahLocalTile = Perspective.worldToLocal(client, phase.getZulrahTile(startTile));
Point zulrahMinimapPoint = Perspective.worldToMiniMap(client, zulrahLocalTile.getX(), zulrahLocalTile.getY());
Color color = getBackgroundColor(phase.getType());
Color color = phase.getColor();
graphics.setColor(color);
graphics.fillOval(zulrahMinimapPoint.getX(), zulrahMinimapPoint.getY(), 5, 5);
graphics.setColor(TILE_BORDER_COLOR);
@@ -222,98 +195,6 @@ public class ZulrahOverlay extends Overlay
}
}
private void drawCurrentPhaseBox(Graphics2D graphics, Rectangle viewport, ZulrahPhase phase, String pattern)
{
Image zulrahImg = getZulrahImage(phase.getType());
if (zulrahImg == null)
{
return;
}
FontMetrics fm = graphics.getFontMetrics();
int height = fm.getHeight() * 2 + zulrahImg.getHeight(null) + SPACER + BOTTOM_BORDER;
int bgX = (int) (viewport.getX() + viewport.getWidth() - CURRENT_PHASE_WIDTH);
int bgY = (int) (viewport.getY() + viewport.getHeight() - height);
Color backgroundColor = phase.isJad() ? JAD_BACKGROUND_COLOR : getBackgroundColor(phase.getType());
graphics.setColor(backgroundColor);
graphics.fillRect(bgX, bgY, CURRENT_PHASE_WIDTH, height);
graphics.setColor(Color.WHITE);
graphics.drawString(pattern, bgX + (CURRENT_PHASE_WIDTH - fm.stringWidth(pattern)) / 2, bgY + fm.getHeight());
graphics.drawImage(zulrahImg, bgX + (CURRENT_PHASE_WIDTH - zulrahImg.getWidth(null)) / 2, bgY + fm.getHeight() + SPACER, null);
if (phase.isJad())
{
graphics.setColor(Color.RED.darker());
graphics.drawString("JAD PHASE", bgX + (CURRENT_PHASE_WIDTH - fm.stringWidth("JAD PHASE")) / 2, bgY + height - BOTTOM_BORDER);
}
}
private void drawNextPhaseBox(Graphics2D graphics, Rectangle viewport, ZulrahPhase phase)
{
if (phase == null)
{
return;
}
Image zulrahImg = getSmallZulrahImage(phase.getType());
if (zulrahImg == null)
{
return;
}
FontMetrics fm = graphics.getFontMetrics();
int height = fm.getHeight() + zulrahImg.getHeight(null) + SPACER + BOTTOM_BORDER;
int bgX = (int) (viewport.getX() + viewport.getWidth() - NEXT_PHASE_WIDTH - CURRENT_PHASE_WIDTH);
int bgY = (int) (viewport.getY() + viewport.getHeight() - height);
Color backgroundColor = phase.isJad() ? JAD_BACKGROUND_COLOR : getBackgroundColor(phase.getType());
graphics.setColor(backgroundColor);
graphics.fillRect(bgX, bgY, NEXT_PHASE_WIDTH, height);
graphics.drawImage(zulrahImg, bgX + (NEXT_PHASE_WIDTH - zulrahImg.getWidth(null)) / 2, bgY + fm.getHeight() + SPACER, null);
if (phase.isJad())
{
Image jadFirstPrayerImg = getProtectionPrayerImage(phase.getPrayer());
graphics.drawImage(jadFirstPrayerImg, bgX + (NEXT_PHASE_WIDTH - zulrahImg.getWidth(null)) / 2, bgY + fm.getHeight() + SPACER, null);
graphics.setColor(Color.RED.darker());
graphics.drawString("Jad Next", bgX + (NEXT_PHASE_WIDTH - fm.stringWidth("Jad Next")) / 2, bgY + fm.getHeight());
}
else
{
graphics.setColor(Color.WHITE);
graphics.drawString("Next", bgX + (NEXT_PHASE_WIDTH - fm.stringWidth("Next")) / 2, bgY + fm.getHeight());
}
}
private Rectangle getViewportBounds()
{
Widget viewport = client.getViewportWidget();
return viewport != null ? viewport.getBounds() : null;
}
private void drawPrayerOutline(Graphics2D graphics, Prayer prayer)
{
if (prayer == null || client.isPrayerActive(prayer))
{
return;
}
Widget prayerWidget;
if (prayer == Prayer.PROTECT_FROM_MISSILES)
{
prayerWidget = client.getWidget(WidgetInfo.PRAYER_PROTECT_FROM_MISSILES);
}
else
{
prayerWidget = client.getWidget(WidgetInfo.PRAYER_PROTECT_FROM_MAGIC);
}
if (prayerWidget != null)
{
Rectangle prayerBounds = prayerWidget.getBounds();
if (prayerBounds != null)
{
graphics.setColor(Color.RED.darker());
graphics.draw(prayerBounds);
}
}
}
private Polygon getCanvasTileNorthPoly(Client client, Point localLocation)
{
int plane = client.getPlane();
@@ -357,105 +238,4 @@ public class ZulrahOverlay extends Overlay
return poly;
}
private Color getBackgroundColor(ZulrahType type)
{
switch (type)
{
case RANGE:
return RANGE_BACKGROUND_COLOR;
case MAGIC:
return MAGIC_BACKGROUND_COLOR;
case MELEE:
return MELEE_BACKGROUND_COLOR;
}
return Color.DARK_GRAY;
}
private Image getZulrahImage(ZulrahType type)
{
switch (type)
{
case RANGE:
if (zulrahImages[0] == null)
{
zulrahImages[0] = getImage("zulrah_range.png");
}
return zulrahImages[0];
case MAGIC:
if (zulrahImages[1] == null)
{
zulrahImages[1] = getImage("zulrah_magic.png");
}
return zulrahImages[1];
case MELEE:
if (zulrahImages[2] == null)
{
zulrahImages[2] = getImage("zulrah_melee.png");
}
return zulrahImages[2];
}
return null;
}
private Image getSmallZulrahImage(ZulrahType type)
{
switch (type)
{
case RANGE:
if (smallZulrahImages[0] == null)
{
smallZulrahImages[0] = getImage("zulrah_range_small.png");
}
return smallZulrahImages[0];
case MAGIC:
if (smallZulrahImages[1] == null)
{
smallZulrahImages[1] = getImage("zulrah_magic_small.png");
}
return smallZulrahImages[1];
case MELEE:
if (smallZulrahImages[2] == null)
{
smallZulrahImages[2] = getImage("zulrah_melee_small.png");
}
return smallZulrahImages[2];
}
return null;
}
private Image getProtectionPrayerImage(Prayer prayer)
{
switch (prayer)
{
case PROTECT_FROM_MAGIC:
if (prayerImages[0] == null)
{
prayerImages[0] = getImage("/prayers/protect_from_magic.png");
}
return prayerImages[0];
case PROTECT_FROM_MISSILES:
if (prayerImages[1] == null)
{
prayerImages[1] = getImage("/prayers/protect_from_missiles.png");
}
return prayerImages[1];
}
return null;
}
private Image getImage(String path)
{
Image image = null;
try
{
InputStream in = ZulrahOverlay.class.getResourceAsStream(path);
image = ImageIO.read(in);
}
catch (IOException e)
{
log.debug("Error loading image {}", e);
}
return image;
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* 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.plugins.zulrah.overlays;
import net.runelite.api.Client;
import net.runelite.api.Prayer;
import net.runelite.client.plugins.zulrah.ZulrahInstance;
import net.runelite.client.plugins.zulrah.ZulrahPlugin;
import net.runelite.client.plugins.zulrah.phase.ZulrahPhase;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.ImagePanelComponent;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
public class ZulrahPrayerOverlay extends Overlay
{
private final Client client;
private final ZulrahPlugin plugin;
@Inject
ZulrahPrayerOverlay(@Nullable Client client, ZulrahPlugin plugin)
{
setPosition(OverlayPosition.BOTTOM_RIGHT);
setPriority(OverlayPriority.MED);
this.client = client;
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
ZulrahInstance instance = plugin.getInstance();
if (client == null || instance == null)
{
return null;
}
ZulrahPhase currentPhase = instance.getPhase();
if (currentPhase == null)
{
return null;
}
Prayer prayer = currentPhase.isJad() ? null : currentPhase.getPrayer();
if (prayer == null || client.isPrayerActive(prayer))
{
return null;
}
BufferedImage prayerImage = ZulrahImageManager.getProtectionPrayerBufferedImage(prayer);
ImagePanelComponent imagePanelComponent = new ImagePanelComponent();
imagePanelComponent.setTitle("Switch!");
imagePanelComponent.setImage(prayerImage);
return imagePanelComponent.render(graphics, parent);
}
}

View File

@@ -29,8 +29,15 @@ import net.runelite.api.NPC;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
import java.awt.Color;
public class ZulrahPhase
{
private static final Color RANGE_COLOR = new Color(150, 255, 0, 100);
private static final Color MAGIC_COLOR = new Color(20, 170, 200, 100);
private static final Color MELEE_COLOR = new Color(180, 50, 20, 100);
private static final Color JAD_COLOR = new Color(255, 115, 0, 100);
private final ZulrahLocation zulrahLocation;
private final ZulrahType type;
private final boolean jad;
@@ -157,4 +164,25 @@ public class ZulrahPhase
ZulrahPhase other = (ZulrahPhase) obj;
return this.jad == other.jad && this.zulrahLocation == other.zulrahLocation && this.type == other.type;
}
public Color getColor()
{
if (jad)
{
return JAD_COLOR;
}
else
{
switch (type)
{
case RANGE:
return RANGE_COLOR;
case MAGIC:
return MAGIC_COLOR;
case MELEE:
return MELEE_COLOR;
}
}
return RANGE_COLOR;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB