Gauntlet: various updates (#1246)

* Gauntlet: various updates

* Renamed config options.

* Added config option to turn off projectile overlay.

* added back the prayer infobox.

* added back counter display

* added back the option to display counters over the boss, in the info box, on both or never.

* update

* gauntlet: Unwrap if (can't be null)

* gauntlet: Access can be weaker

* ty 4 help ganom

ty 4 help ganom
This commit is contained in:
Kyleeld
2019-08-03 21:32:05 +01:00
committed by Ganom
parent f26154c4bc
commit 36050a2b3b
5 changed files with 414 additions and 115 deletions

View File

@@ -1,14 +1,34 @@
/* /*
* THIS SOFTWARE WRITTEN BY A KEYBOARD-WIELDING MONKEY BOI * Copyright (c) 2019, kThisIsCvpv <https://github.com/kThisIsCvpv>
* No rights reserved. Use, redistribute, and modify at your own discretion, * Copyright (c) 2019, ganom <https://github.com/Ganom>
* and in accordance with Yagex and RuneLite guidelines. * Copyright (c) 2019, kyle <https://github.com/Kyleeld>
* However, aforementioned monkey would prefer if you don't sell this plugin for profit. * All rights reserved.
* Good luck on your raids! *
* 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.gauntlet; package net.runelite.client.plugins.gauntlet;
import java.awt.Color; import java.awt.Color;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
@@ -19,6 +39,24 @@ import net.runelite.client.config.Stub;
public interface GauntletConfig extends Config public interface GauntletConfig extends Config
{ {
@Getter
@AllArgsConstructor
enum CounterDisplay
{
ONBOSS("On Boss"),
INFOBOX("Info Box"),
BOTH("Both"),
NONE("None");
private String name;
@Override
public String toString()
{
return getName();
}
}
@ConfigItem( @ConfigItem(
position = 0, position = 0,
keyName = "resources", keyName = "resources",
@@ -33,13 +71,13 @@ public interface GauntletConfig extends Config
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "highlightResources", keyName = "highlightResources",
name = "Highlight Resources", name = "Highlight Resources (Outline)",
description = "Highlights all the resources in each room with a color.", description = "Highlights all the resources in each room with an outline.",
parent = "resources" parent = "resources"
) )
default boolean highlightResources() default boolean highlightResources()
{ {
return true; return false;
} }
@ConfigItem( @ConfigItem(
@@ -59,7 +97,7 @@ public interface GauntletConfig extends Config
@ConfigItem( @ConfigItem(
position = 3, position = 3,
keyName = "highlightResourcesIcons", keyName = "highlightResourcesIcons",
name = "Highlight Resources with an Icon", name = "Highlight Resources (Icon)",
description = "Highlights all the icons in each room with an icon.", description = "Highlights all the icons in each room with an icon.",
parent = "resources", parent = "resources",
hidden = true, hidden = true,
@@ -67,7 +105,7 @@ public interface GauntletConfig extends Config
) )
default boolean highlightResourcesIcons() default boolean highlightResourcesIcons()
{ {
return true; return false;
} }
@Range( @Range(
@@ -101,80 +139,80 @@ public interface GauntletConfig extends Config
@ConfigItem( @ConfigItem(
position = 6, position = 6,
keyName = "countBossAttacks", keyName = "countAttacks",
name = "Count Boss Attacks", name = "Count Attacks Display",
description = "Count the attacks until the boss switches their style.", description = "Count the attacks until the Hunllef switches their attack style and prayer.",
parent = "boss" parent = "boss"
) )
default boolean countBossAttacks() default CounterDisplay countAttacks()
{ {
return true; return CounterDisplay.NONE;
} }
@ConfigItem( @ConfigItem(
position = 7, position = 7,
keyName = "countPlayerAttacks",
name = "Count Player Attacks",
description = "Count the player attacks until the boss switches their prayer.",
parent = "boss"
)
default boolean countPlayerAttacks()
{
return true;
}
@ConfigItem(
position = 8,
keyName = "highlightWidget", keyName = "highlightWidget",
name = "Highlight Correct Prayer", name = "Highlight Prayer (Prayer Tab)",
description = "Highlights correct prayer in your prayer book.", description = "Highlights the correct prayer to use in your prayer book.",
parent = "boss" parent = "boss"
) )
default boolean highlightWidget() default boolean highlightWidget()
{ {
return true; return false;
} }
@ConfigItem( @ConfigItem(
position = 8, position = 8,
keyName = "highlightPrayerInfobox",
name = "Highlight Prayer (InfoBox)",
description = "Highlights the correct prayer to use in an Infobox.",
parent = "boss"
)
default boolean highlightPrayerInfobox()
{
return false;
}
@ConfigItem(
position = 9,
keyName = "flashOnWrongAttack", keyName = "flashOnWrongAttack",
name = "Flash on Wrong Attack", name = "Flash screen on Wrong Attack",
description = "This will flash your screen if you attack with the wrong stlye.", description = "This will flash your screen if you attack with the wrong stlye.",
parent = "boss" parent = "boss"
) )
default boolean flashOnWrongAttack() default boolean flashOnWrongAttack()
{ {
return true; return false;
} }
@ConfigItem( @ConfigItem(
position = 9, position = 10,
keyName = "uniquePrayerAudio", keyName = "uniquePrayerAudio",
name = "Unique Prayer Audio", name = "Prayer Audio Warning",
description = "Plays a unique sound whenever the boss is about to shut down your prayer.", description = "Plays a unique sound whenever the boss is about to shut down your prayer.",
parent = "boss" parent = "boss"
) )
default boolean uniquePrayerAudio() default boolean uniquePrayerAudio()
{ {
return true; return false;
} }
@ConfigItem( @ConfigItem(
position = 10, position = 11,
keyName = "uniquePrayerVisual", keyName = "uniquePrayerVisual",
name = "Unique Prayer Visual", name = "Prayer Attack (Icon)",
description = "Prayer attacks will have a unique overlay visual.", description = "Prayer attacks will have a unique overlay visual.",
parent = "boss" parent = "boss"
) )
default boolean uniquePrayerVisual() default boolean uniquePrayerVisual()
{ {
return true; return false;
} }
@ConfigItem( @ConfigItem(
position = 11, position = 12,
keyName = "uniqueAttackVisual", keyName = "uniqueAttackVisual",
name = "Unique Magic & Range Visuals", name = "Magic & Range Attack (Icon)",
description = "Magic and Range attacks will have a unique overlay visual.", description = "Magic and Range attacks will have a unique overlay visual.",
parent = "boss" parent = "boss"
) )
@@ -184,22 +222,35 @@ public interface GauntletConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 12, position = 13,
keyName = "attackVisualOutline",
name = "Hunllefs' attacks (Outline)",
description = "Outline the Hunllefs' attacks.",
parent = "boss"
)
default boolean attackVisualOutline()
{
return false;
}
@ConfigItem(
position = 14,
keyName = "overlayBoss", keyName = "overlayBoss",
name = "Overlay the Boss (Color)", name = "Outline Hunllef (Color)",
description = "Overlay the boss with an color denoting it's current attack style.", description = "Overlay Hunllef while you are on the wrong prayer with an color denoting it's current attack style.",
parent = "boss" parent = "boss"
) )
default boolean overlayBoss() default boolean overlayBoss()
{ {
return true; return false;
} }
@ConfigItem( @ConfigItem(
position = 13, position = 15,
keyName = "overlayBossPrayer", keyName = "overlayBossPrayer",
name = "Overlay the Boss (Icon)", name = "Hunllef Overlay (Icons)",
description = "Overlay the boss with an icon denoting it's current attack style.", description = "Overlay the Hunllef with an icon denoting it's current attack style.",
parent = "boss" parent = "boss"
) )
default boolean overlayBossPrayer() default boolean overlayBossPrayer()
@@ -208,7 +259,7 @@ public interface GauntletConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 14, position = 16,
keyName = "overlayTornadoes", keyName = "overlayTornadoes",
name = "Show Tornado Decay", name = "Show Tornado Decay",
description = "Display the amount of ticks left until the tornadoes decay.", description = "Display the amount of ticks left until the tornadoes decay.",
@@ -216,7 +267,7 @@ public interface GauntletConfig extends Config
) )
default boolean overlayTornadoes() default boolean overlayTornadoes()
{ {
return true; return false;
} }
@Range( @Range(
@@ -224,9 +275,9 @@ public interface GauntletConfig extends Config
max = 50 max = 50
) )
@ConfigItem( @ConfigItem(
position = 15, position = 17,
keyName = "projectileIconSize", keyName = "projectileIconSize",
name = "Boss Projectile Icon Size", name = "Hunllef Projectile Icon Size",
description = " change the size of Projectile icons.", description = " change the size of Projectile icons.",
parent = "boss" parent = "boss"
) )
@@ -236,7 +287,7 @@ public interface GauntletConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 16, position = 18,
keyName = "timer", keyName = "timer",
name = "Timer", name = "Timer",
description = "" description = ""
@@ -247,26 +298,26 @@ public interface GauntletConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 17, position = 19,
keyName = "displayTimerWidget", keyName = "displayTimerWidget",
name = "Show Custom Timer (Widget)", name = "Show Gauntlet timer overlay",
description = "Display a timer widget that tracks your gauntlet progress.", description = "Display a timer widget that tracks your gauntlet progress.",
parent = "timer" parent = "timer"
) )
default boolean displayTimerWidget() default boolean displayTimerWidget()
{ {
return true; return false;
} }
@ConfigItem( @ConfigItem(
position = 18, position = 20,
keyName = "displayTimerChat", keyName = "displayTimerChat",
name = "Show Custom Timer (Chat)", name = "Show Gauntlet timer chat message",
description = "Display a chat message that tracks your gauntlet progress.", description = "Display a chat message that tracks your gauntlet progress.",
parent = "timer" parent = "timer"
) )
default boolean displayTimerChat() default boolean displayTimerChat()
{ {
return true; return false;
} }
} }

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2019, ganom <https://github.com/Ganom>
* 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.gauntlet;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.inject.Inject;
import javax.inject.Singleton;
import static net.runelite.client.plugins.gauntlet.GauntletConfig.CounterDisplay.NONE;
import static net.runelite.client.plugins.gauntlet.GauntletConfig.CounterDisplay.ONBOSS;
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.PanelComponent;
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;
@Singleton
public class GauntletCounter extends Overlay
{
private final GauntletPlugin plugin;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
GauntletCounter(final GauntletPlugin plugin)
{
this.plugin = plugin;
setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT);
setPriority(OverlayPriority.HIGH);
}
@Override
public Dimension render(Graphics2D graphics)
{
panelComponent.getChildren().clear();
final Hunllef hunllef = plugin.getHunllef();
if (!plugin.fightingBoss() ||
hunllef == null ||
plugin.getCountAttacks() == NONE ||
plugin.getCountAttacks() == ONBOSS)
{
return null;
}
panelComponent.getChildren().add(TitleComponent.builder()
.text("Hunllef")
.color(Color.pink)
.build());
Color color = hunllef.getPlayerAttacks() == 1 ? Color.RED : Color.WHITE;
final String pHits = ColorUtil.prependColorTag(Integer.toString(hunllef.getPlayerAttacks()), color);
TableComponent tableComponent = new TableComponent();
tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
tableComponent.addRow("Hunllef Hits: ", Integer.toString(hunllef.getBossAttacks()));
tableComponent.addRow("Player Hits Left: ", pHits);
panelComponent.getChildren().add(tableComponent);
return panelComponent.render(graphics);
}
}

View File

@@ -0,0 +1,134 @@
/*
* Copyright (c) 2019, ganom <https://github.com/Ganom>
* Copyright (c) 2019, kyle <https://github.com/Kyleeld>
* 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.gauntlet;
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;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.Prayer;
import net.runelite.api.SpriteID;
import net.runelite.client.game.SpriteManager;
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.ComponentConstants;
import net.runelite.client.ui.overlay.components.InfoBoxComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
public class GauntletInfoBoxOverlay extends Overlay
{
private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150);
private final Client client;
private final GauntletPlugin plugin;
private final PanelComponent panelComponent = new PanelComponent();
private final SpriteManager spriteManager;
@Inject
GauntletInfoBoxOverlay(final Client client, final GauntletPlugin plugin, final SpriteManager spriteManager)
{
this.client = client;
this.plugin = plugin;
this.spriteManager = spriteManager;
setPosition(OverlayPosition.BOTTOM_RIGHT);
setPriority(OverlayPriority.HIGH);
}
@Override
public Dimension render(Graphics2D graphics)
{
panelComponent.getChildren().clear();
if (!plugin.isHighlightPrayerInfobox() || !plugin.fightingBoss() || plugin.getHunllef() == null)
{
return null;
}
final Hunllef hunllef = plugin.getHunllef();
final Hunllef.BossAttackPhase phase = hunllef.getCurrentPhase();
Prayer prayer = phase.getPrayer();
if (plugin.getHunllef() == null || !plugin.startedGauntlet())
{
return null;
}
if (prayer == null)
{
return null;
}
InfoBoxComponent prayComponent = new InfoBoxComponent();
BufferedImage prayImg = scaleImg(getPrayerImage(prayer));
prayComponent.setImage(prayImg);
prayComponent.setColor(Color.WHITE);
prayComponent.setBackgroundColor(client.isPrayerActive(prayer)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
prayComponent.setPreferredSize(new Dimension(40, 40));
panelComponent.getChildren().add(prayComponent);
panelComponent.setPreferredSize(new Dimension(40, 40));
panelComponent.setBorder(new Rectangle(0, 0, 0, 0));
return panelComponent.render(graphics);
}
private BufferedImage getPrayerImage(Prayer prayer)
{
switch (prayer)
{
case PROTECT_FROM_MAGIC:
return spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0);
case PROTECT_FROM_MELEE:
return spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MELEE, 0);
case PROTECT_FROM_MISSILES:
return spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0);
}
return null;
}
private static 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;
}
}

View File

@@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2019, kThisIsCvpv <https://github.com/kThisIsCvpv> * Copyright (c) 2019, kThisIsCvpv <https://github.com/kThisIsCvpv>
* Copyright (c) 2019, ganom <https://github.com/Ganom> * Copyright (c) 2019, ganom <https://github.com/Ganom>
* Copyright (c) 2019, kyle <https://github.com/Kyleeld>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -46,8 +47,11 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.model.Jarvis; import net.runelite.api.model.Jarvis;
import net.runelite.api.model.Vertex; import net.runelite.api.model.Vertex;
import net.runelite.client.graphics.ModelOutlineRenderer; import net.runelite.client.graphics.ModelOutlineRenderer;
import static net.runelite.client.plugins.gauntlet.GauntletConfig.CounterDisplay.BOTH;
import static net.runelite.client.plugins.gauntlet.GauntletConfig.CounterDisplay.ONBOSS;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
@@ -55,18 +59,24 @@ import static net.runelite.client.util.ImageUtil.resizeImage;
public class GauntletOverlay extends Overlay public class GauntletOverlay extends Overlay
{ {
@Inject
private OverlayManager overlayManager;
@Inject
private GauntletCounter GauntletCounter;
private static final Color FLASH_COLOR = new Color(255, 0, 0, 70); private static final Color FLASH_COLOR = new Color(255, 0, 0, 70);
private static final int MAX_DISTANCE = 2400; private static final int MAX_DISTANCE = 2400;
private final Client client; private final Client client;
private final GauntletPlugin plugin; private final GauntletPlugin plugin;
private final GauntletConfig config;
private final ModelOutlineRenderer outlineRenderer; private final ModelOutlineRenderer outlineRenderer;
private int timeout; private int timeout;
@Inject @Inject
private GauntletOverlay(Client client, GauntletPlugin plugin, ModelOutlineRenderer outlineRenderer) private GauntletOverlay(Client client, GauntletConfig config, GauntletPlugin plugin, ModelOutlineRenderer outlineRenderer)
{ {
this.client = client; this.client = client;
this.plugin = plugin; this.plugin = plugin;
this.config = config;
this.outlineRenderer = outlineRenderer; this.outlineRenderer = outlineRenderer;
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
@@ -115,10 +125,13 @@ public class GauntletOverlay extends Overlay
} }
else else
{ {
graphics.setColor(color); if (plugin.isAttackVisualOutline())
graphics.draw(polygon); {
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 50)); graphics.setColor(color);
graphics.fill(polygon); graphics.draw(polygon);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 50));
graphics.fill(polygon);
}
if (plugin.isUniqueAttackVisual()) if (plugin.isUniqueAttackVisual())
{ {
Rectangle bounds = polygon.getBounds(); Rectangle bounds = polygon.getBounds();
@@ -172,7 +185,7 @@ public class GauntletOverlay extends Overlay
final NPC boss = hunllef.getNpc(); final NPC boss = hunllef.getNpc();
final LocalPoint point = boss.getLocalLocation(); final LocalPoint point = boss.getLocalLocation();
if (plugin.isFlash()) if (plugin.isFlash() && plugin.isFlashOnWrongAttack())
{ {
final Color flash = graphics.getColor(); final Color flash = graphics.getColor();
graphics.setColor(FLASH_COLOR); graphics.setColor(FLASH_COLOR);
@@ -249,48 +262,46 @@ public class GauntletOverlay extends Overlay
} }
} }
// This section handles any text overlays. if (plugin.getCountAttacks() == ONBOSS || plugin.getCountAttacks() == BOTH)
String textOverlay = "";
// Handles the counter for the boss.
if (plugin.isCountBossAttacks())
{ {
String textOverlay;
textOverlay = Integer.toString(hunllef.getBossAttacks()); textOverlay = Integer.toString(hunllef.getBossAttacks());
}
// Handles the counter for the player.
if (plugin.isCountPlayerAttacks())
{
if (textOverlay.length() > 0) if (textOverlay.length() > 0)
{ {
textOverlay += " | "; textOverlay += " | ";
} }
textOverlay += Integer.toString(hunllef.getPlayerAttacks()); textOverlay += Integer.toString(hunllef.getPlayerAttacks());
}
// Handles drawing the text onto the boss. if (textOverlay.length() > 0)
if (textOverlay.length() > 0)
{
Point textLoc = Perspective.getCanvasTextLocation(client, graphics, point, textOverlay, boss.getLogicalHeight() / 2);
if (textLoc == null)
{ {
return null; Point textLoc = Perspective.getCanvasTextLocation(client, graphics, point, textOverlay, boss.getLogicalHeight() / 2);
if (textLoc == null)
{
return null;
}
textLoc = new Point(textLoc.getX(), textLoc.getY() + 35);
Font oldFont = graphics.getFont();
graphics.setFont(new Font("Arial", Font.BOLD, 20));
Point pointShadow = new Point(textLoc.getX() + 1, textLoc.getY() + 1);
OverlayUtil.renderTextLocation(graphics, pointShadow, textOverlay, Color.BLACK);
OverlayUtil.renderTextLocation(graphics, textLoc, textOverlay, phase.getColor());
graphics.setFont(oldFont);
} }
textLoc = new Point(textLoc.getX(), textLoc.getY() + 35);
Font oldFont = graphics.getFont();
graphics.setFont(new Font("Arial", Font.BOLD, 20));
Point pointShadow = new Point(textLoc.getX() + 1, textLoc.getY() + 1);
OverlayUtil.renderTextLocation(graphics, pointShadow, textOverlay, Color.BLACK);
OverlayUtil.renderTextLocation(graphics, textLoc, textOverlay, phase.getColor());
graphics.setFont(oldFont);
} }
} }
if (plugin.getHunllef() == null)
{
overlayManager.remove(GauntletCounter);
}
} }
else else
{ {
@@ -320,14 +331,10 @@ public class GauntletOverlay extends Overlay
if (plugin.isHighlightResourcesIcons()) if (plugin.isHighlightResourcesIcons())
{ {
BufferedImage icon = resizeImage(object.getImage(), plugin.getResourceIconSize(), plugin.getResourceIconSize()); BufferedImage icon = resizeImage(object.getImage(), plugin.getResourceIconSize(), plugin.getResourceIconSize());
Rectangle bounds = polygon.getBounds();
if (icon != null) int startX = (int) bounds.getCenterX() - (icon.getWidth() / 2);
{ int startY = (int) bounds.getCenterY() - (icon.getHeight() / 2);
Rectangle bounds = polygon.getBounds(); graphics.drawImage(icon, startX, startY, null);
int startX = (int) bounds.getCenterX() - (icon.getWidth() / 2);
int startY = (int) bounds.getCenterY() - (icon.getHeight() / 2);
graphics.drawImage(icon, startX, startY, null);
}
} }
} }
}); });

View File

@@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2019, kThisIsCvpv <https://github.com/kThisIsCvpv> * Copyright (c) 2019, kThisIsCvpv <https://github.com/kThisIsCvpv>
* Copyright (c) 2019, ganom <https://github.com/Ganom> * Copyright (c) 2019, ganom <https://github.com/Ganom>
* Copyright (c) 2019, kyle <https://github.com/Kyleeld>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -32,6 +33,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
@@ -117,6 +119,9 @@ public class GauntletPlugin extends Plugin
private GauntletOverlay overlay; private GauntletOverlay overlay;
@Inject @Inject
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
private GauntletInfoBoxOverlay infoboxoverlay;
@Inject
@Getter(AccessLevel.NONE)
private GauntletConfig config; private GauntletConfig config;
@Inject @Inject
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@@ -127,34 +132,40 @@ public class GauntletPlugin extends Plugin
@Inject @Inject
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
private SkillIconManager skillIconManager; private SkillIconManager skillIconManager;
@Inject
@Getter(AccessLevel.NONE)
private GauntletCounter GauntletCounter;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Nullable
private Hunllef hunllef; private Hunllef hunllef;
private final Set<Resources> resources = new HashSet<>(); private boolean attackVisualOutline;
private final Set<Missiles> projectiles = new HashSet<>();
private final Map<String, Integer> items = new HashMap<>();
private Set<Tornado> tornadoes = new HashSet<>();
private boolean completeStartup = false; private boolean completeStartup = false;
private boolean countBossAttacks;
private boolean countPlayerAttacks;
private boolean displayTimerChat; private boolean displayTimerChat;
private boolean displayTimerWidget;
@Setter(AccessLevel.PACKAGE)
private boolean flash;
private boolean flashOnWrongAttack;
private boolean highlightPrayerInfobox;
private boolean highlightResources; private boolean highlightResources;
private boolean highlightResourcesIcons; private boolean highlightResourcesIcons;
private boolean highlightWidget; private boolean highlightWidget;
private boolean overlayBoss; private boolean overlayBoss;
private boolean overlayBossPrayer; private boolean overlayBossPrayer;
private boolean overlayTornadoes; private boolean overlayTornadoes;
@Setter(AccessLevel.PACKAGE)
private boolean flash;
private boolean flashOnWrongAttack;
private Color highlightResourcesColor;
private boolean displayTimerWidget;
private boolean timerVisible = true; private boolean timerVisible = true;
private boolean uniqueAttackVisual; private boolean uniqueAttackVisual;
private boolean uniquePrayerAudio; private boolean uniquePrayerAudio;
private boolean uniquePrayerVisual; private boolean uniquePrayerVisual;
private Color highlightResourcesColor;
private final Map<String, Integer> items = new HashMap<>();
private final Set<Missiles> projectiles = new HashSet<>();
private final Set<Resources> resources = new HashSet<>();
private GauntletConfig.CounterDisplay countAttacks;
private int resourceIconSize; private int resourceIconSize;
private Set<Tornado> tornadoes = new HashSet<>();
private int projectileIconSize; private int projectileIconSize;
@Provides @Provides
GauntletConfig getConfig(ConfigManager configManager) GauntletConfig getConfig(ConfigManager configManager)
{ {
@@ -166,13 +177,15 @@ public class GauntletPlugin extends Plugin
{ {
addSubscriptions(); addSubscriptions();
updateConfig(); updateConfig();
overlayManager.add(overlay);
overlayManager.add(infoboxoverlay);
overlayManager.add(GauntletCounter);
timerVisible = this.displayTimerWidget; timerVisible = this.displayTimerWidget;
timer.resetStates(); timer.resetStates();
if (timerVisible) if (timerVisible)
{ {
overlayManager.add(timer); overlayManager.add(timer);
} }
overlayManager.add(overlay);
if (client.getGameState() != GameState.STARTING && client.getGameState() != GameState.UNKNOWN) if (client.getGameState() != GameState.STARTING && client.getGameState() != GameState.UNKNOWN)
{ {
completeStartup = false; completeStartup = false;
@@ -198,6 +211,8 @@ public class GauntletPlugin extends Plugin
timerVisible = false; timerVisible = false;
} }
overlayManager.remove(overlay); overlayManager.remove(overlay);
overlayManager.remove(infoboxoverlay);
overlayManager.remove(GauntletCounter);
resources.clear(); resources.clear();
projectiles.clear(); projectiles.clear();
tornadoes.clear(); tornadoes.clear();
@@ -220,6 +235,11 @@ public class GauntletPlugin extends Plugin
private void onAnimationChanged(AnimationChanged event) private void onAnimationChanged(AnimationChanged event)
{ {
if (hunllef == null)
{
return;
}
final Actor actor = event.getActor(); final Actor actor = event.getActor();
// This section handles the player counter. // This section handles the player counter.
@@ -437,8 +457,7 @@ public class GauntletPlugin extends Plugin
this.highlightWidget = config.highlightWidget(); this.highlightWidget = config.highlightWidget();
this.resourceIconSize = config.resourceIconSize(); this.resourceIconSize = config.resourceIconSize();
this.projectileIconSize = config.projectileIconSize(); this.projectileIconSize = config.projectileIconSize();
this.countBossAttacks = config.countBossAttacks(); this.countAttacks = config.countAttacks();
this.countPlayerAttacks = config.countPlayerAttacks();
this.uniquePrayerAudio = config.uniquePrayerAudio(); this.uniquePrayerAudio = config.uniquePrayerAudio();
this.uniquePrayerVisual = config.uniquePrayerVisual(); this.uniquePrayerVisual = config.uniquePrayerVisual();
this.uniqueAttackVisual = config.uniqueAttackVisual(); this.uniqueAttackVisual = config.uniqueAttackVisual();
@@ -447,5 +466,7 @@ public class GauntletPlugin extends Plugin
this.overlayTornadoes = config.overlayTornadoes(); this.overlayTornadoes = config.overlayTornadoes();
this.displayTimerWidget = config.displayTimerWidget(); this.displayTimerWidget = config.displayTimerWidget();
this.displayTimerChat = config.displayTimerChat(); this.displayTimerChat = config.displayTimerChat();
this.attackVisualOutline = config.attackVisualOutline();
this.highlightPrayerInfobox = config.highlightPrayerInfobox();
} }
} }