Merge pull request #1532 from sethtroll/addbarrowsoverlay
barrows overlay: Replace existing slain brother overlay with our own
This commit is contained in:
@@ -83,6 +83,7 @@ public class WidgetID
|
||||
public static final int EXPERIENCE_TRACKER_GROUP_ID = 122;
|
||||
public static final int TITHE_FARM_GROUP_ID = 241;
|
||||
public static final int KINGDOM_GROUP_ID = 392;
|
||||
public static final int BARROWS_GROUP_ID = 24;
|
||||
|
||||
static class WorldMap
|
||||
{
|
||||
@@ -414,4 +415,10 @@ public class WidgetID
|
||||
{
|
||||
static final int FAIRY_QUEEN_HIDEOUT = 139;
|
||||
}
|
||||
|
||||
static class Barrows
|
||||
{
|
||||
static final int BARROWS_BROTHERS = 8;
|
||||
static final int BARROWS_POTENTIAL = 9;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,11 @@ public enum WidgetInfo
|
||||
EXPERIENCE_TRACKER(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.WIDGET),
|
||||
EXPERIENCE_TRACKER_BOTTOM_BAR(WidgetID.EXPERIENCE_TRACKER_GROUP_ID, WidgetID.ExperienceTracker.BOTTOM_BAR),
|
||||
|
||||
TITHE_FARM(WidgetID.TITHE_FARM_GROUP_ID, 1);
|
||||
TITHE_FARM(WidgetID.TITHE_FARM_GROUP_ID, 1),
|
||||
|
||||
BARROWS_INFO(WidgetID.BARROWS_GROUP_ID, 0),
|
||||
BARROWS_BROTHERS(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_BROTHERS),
|
||||
BARROWS_POTENTIAL(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_POTENTIAL);
|
||||
|
||||
private final int groupId;
|
||||
private final int childId;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Seth <http://github.com/sethtroll>
|
||||
* 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.barrows;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
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;
|
||||
|
||||
public class BarrowsBrotherSlainOverlay extends Overlay
|
||||
{
|
||||
private final Client client;
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
|
||||
@Inject
|
||||
private BarrowsBrotherSlainOverlay(Client client)
|
||||
{
|
||||
setPosition(OverlayPosition.TOP_LEFT);
|
||||
setPriority(OverlayPriority.LOW);
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
// Do not display overlay if potential is null/hidden
|
||||
Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL);
|
||||
if (potential == null || potential.isHidden())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Hide original overlay
|
||||
Widget barrowsBrothers = client.getWidget(WidgetInfo.BARROWS_BROTHERS);
|
||||
if (barrowsBrothers != null)
|
||||
{
|
||||
barrowsBrothers.setHidden(true);
|
||||
}
|
||||
|
||||
panelComponent.getLines().clear();
|
||||
|
||||
for (BarrowsBrothers brother : BarrowsBrothers.values())
|
||||
{
|
||||
String slain = client.getSetting(brother.getKilledVarbit()) > 0 ? "✓" : "";
|
||||
panelComponent.getLines().add(new PanelComponent.Line(
|
||||
brother.getName(),
|
||||
Color.WHITE,
|
||||
slain,
|
||||
slain.isEmpty() ? Color.WHITE : Color.GREEN
|
||||
));
|
||||
}
|
||||
|
||||
return panelComponent.render(graphics);
|
||||
}
|
||||
}
|
||||
@@ -32,12 +32,12 @@ import net.runelite.api.coords.WorldPoint;
|
||||
@RequiredArgsConstructor
|
||||
public enum BarrowsBrothers
|
||||
{
|
||||
VERAC("V", new WorldPoint(3557, 3298, 0), Varbits.BARROWS_KILLED_VERAC),
|
||||
DHAROK("D", new WorldPoint(3575, 3298, 0), Varbits.BARROWS_KILLED_DHAROK),
|
||||
AHRIM("A", new WorldPoint(3566, 3289, 0) , Varbits.BARROWS_KILLED_AHRIM),
|
||||
TORAG("T", new WorldPoint(3553, 3283, 0), Varbits.BARROWS_KILLED_TORAG),
|
||||
KARIL("K", new WorldPoint(3566, 3275, 0), Varbits.BARROWS_KILLED_KARIL),
|
||||
GUTHAN("G", new WorldPoint(3577, 3283, 0), Varbits.BARROWS_KILLED_GUTHAN);
|
||||
AHRIM("Ahrim", new WorldPoint(3566, 3289, 0), Varbits.BARROWS_KILLED_AHRIM),
|
||||
DHAROK("Dharok", new WorldPoint(3575, 3298, 0), Varbits.BARROWS_KILLED_DHAROK),
|
||||
GUTHAN("Guthan", new WorldPoint(3577, 3283, 0), Varbits.BARROWS_KILLED_GUTHAN),
|
||||
KARIL("Karil", new WorldPoint(3566, 3275, 0), Varbits.BARROWS_KILLED_KARIL),
|
||||
TORAG("Torag", new WorldPoint(3553, 3283, 0), Varbits.BARROWS_KILLED_TORAG),
|
||||
VERAC("Verac", new WorldPoint(3557, 3298, 0), Varbits.BARROWS_KILLED_VERAC);
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
@@ -169,13 +169,14 @@ class BarrowsOverlay extends Overlay
|
||||
continue;
|
||||
}
|
||||
|
||||
String brotherLetter = Character.toString(brother.getName().charAt(0));
|
||||
net.runelite.api.Point minimapText = Perspective.getCanvasTextMiniMapLocation(client, graphics,
|
||||
localLocation, brother.getName());
|
||||
localLocation, brotherLetter);
|
||||
|
||||
if (minimapText != null)
|
||||
{
|
||||
graphics.setColor(Color.black);
|
||||
graphics.drawString(brother.getName(), minimapText.getX() + 1, minimapText.getY() + 1);
|
||||
graphics.drawString(brotherLetter, minimapText.getX() + 1, minimapText.getY() + 1);
|
||||
|
||||
if (client.getSetting(brother.getKilledVarbit()) > 0)
|
||||
{
|
||||
@@ -186,7 +187,7 @@ class BarrowsOverlay extends Overlay
|
||||
graphics.setColor(config.brotherLocColor());
|
||||
}
|
||||
|
||||
graphics.drawString(brother.getName(), minimapText.getX(), minimapText.getY());
|
||||
graphics.drawString(brotherLetter, minimapText.getX(), minimapText.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ package net.runelite.client.plugins.barrows;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
@@ -70,7 +72,10 @@ public class BarrowsPlugin extends Plugin
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final Set<GameObject> ladders = new HashSet<>();
|
||||
@Inject
|
||||
BarrowsOverlay barrowsOverlay;
|
||||
private BarrowsOverlay barrowsOverlay;
|
||||
|
||||
@Inject
|
||||
private BarrowsBrotherSlainOverlay brotherOverlay;
|
||||
|
||||
@Provides
|
||||
BarrowsConfig provideConfig(ConfigManager configManager)
|
||||
@@ -79,9 +84,9 @@ public class BarrowsPlugin extends Plugin
|
||||
}
|
||||
|
||||
@Override
|
||||
public Overlay getOverlay()
|
||||
public Collection<Overlay> getOverlays()
|
||||
{
|
||||
return barrowsOverlay;
|
||||
return Arrays.asList(barrowsOverlay, brotherOverlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user