impling plugin: Move minimap overlay into it's own overlay
to render above minimap on resizable, the overlay must be rendered above widgets
This commit is contained in:
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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.implings;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.NPC;
|
||||||
|
import net.runelite.api.Point;
|
||||||
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
|
|
||||||
|
public class ImplingMinimapOverlay extends Overlay
|
||||||
|
{
|
||||||
|
private final ImplingsPlugin plugin;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ImplingMinimapOverlay(ImplingsPlugin plugin)
|
||||||
|
{
|
||||||
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
|
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension render(Graphics2D graphics)
|
||||||
|
{
|
||||||
|
NPC[] imps = plugin.getImplings();
|
||||||
|
if (imps == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NPC imp : imps)
|
||||||
|
{
|
||||||
|
Point minimapLocation = imp.getMinimapLocation();
|
||||||
|
if (minimapLocation != null)
|
||||||
|
{
|
||||||
|
OverlayUtil.renderMinimapLocation(graphics, minimapLocation, plugin.getIds().get(imp.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,25 +24,18 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.implings;
|
package net.runelite.client.plugins.implings;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
|
||||||
import net.runelite.api.Actor;
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NpcID;
|
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
|
||||||
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.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -50,107 +43,40 @@ import net.runelite.client.util.QueryRunner;
|
|||||||
*/
|
*/
|
||||||
public class ImplingsOverlay extends Overlay
|
public class ImplingsOverlay extends Overlay
|
||||||
{
|
{
|
||||||
|
private final ImplingsPlugin plugin;
|
||||||
// Impling spawns in PuroPuro. Not in NpcID.
|
|
||||||
private static final int STATIC_SPAWN = 1618;
|
|
||||||
private static final int DYNAMIC_SPAWN = 1633;
|
|
||||||
|
|
||||||
private final QueryRunner queryRunner;
|
|
||||||
private final ImplingsConfig config;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Map<Integer, Color> ids = new HashMap<>();
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ImplingsOverlay(QueryRunner queryRunner, ImplingsConfig config)
|
private ImplingsOverlay(ImplingsPlugin plugin)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||||
this.queryRunner = queryRunner;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids.keySet()));
|
NPC[] imps = plugin.getImplings();
|
||||||
NPC[] implings = queryRunner.runQuery(implingQuery);
|
if (imps == null)
|
||||||
for (NPC imp : implings)
|
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NPC imp : imps)
|
||||||
|
{
|
||||||
|
if (imp == null || imp.getName() == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Spawns have the name "null", so they get changed to "Spawn"
|
//Spawns have the name "null", so they get changed to "Spawn"
|
||||||
String text = imp.getName().equals("null") ? "Spawn" : imp.getName();
|
String text = imp.getName().equals("null") ? "Spawn" : imp.getName();
|
||||||
drawImp(graphics, imp, text, ids.get(imp.getId()));
|
drawImp(graphics, imp, text, plugin.getIds().get(imp.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I am aware this is ugly. As always, feedback is welcome
|
|
||||||
public void updateConfig()
|
|
||||||
{
|
|
||||||
ids.clear();
|
|
||||||
if (config.showBaby())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.BABY_IMPLING, config.getBabyColor());
|
|
||||||
ids.put(NpcID.BABY_IMPLING_1645, config.getBabyColor());
|
|
||||||
}
|
|
||||||
if (config.showYoung())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.YOUNG_IMPLING, config.getYoungColor());
|
|
||||||
ids.put(NpcID.YOUNG_IMPLING_1646, config.getYoungColor());
|
|
||||||
}
|
|
||||||
if (config.showGourmet())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.GOURMET_IMPLING, config.getGourmetColor());
|
|
||||||
ids.put(NpcID.GOURMET_IMPLING_1647, config.getGourmetColor());
|
|
||||||
}
|
|
||||||
if (config.showEarth())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.EARTH_IMPLING, config.getEarthColor());
|
|
||||||
ids.put(NpcID.EARTH_IMPLING_1648, config.getEarthColor());
|
|
||||||
}
|
|
||||||
if (config.showEssence())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.ESSENCE_IMPLING, config.getEssenceColor());
|
|
||||||
ids.put(NpcID.ESSENCE_IMPLING_1649, config.getEssenceColor());
|
|
||||||
}
|
|
||||||
if (config.showEclectic())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.ECLECTIC_IMPLING, config.getEclecticColor());
|
|
||||||
ids.put(NpcID.ECLECTIC_IMPLING_1650, config.getEclecticColor());
|
|
||||||
}
|
|
||||||
if (config.showNature())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.NATURE_IMPLING, config.getNatureColor());
|
|
||||||
ids.put(NpcID.NATURE_IMPLING_1651, config.getNatureColor());
|
|
||||||
}
|
|
||||||
if (config.showMagpie())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.MAGPIE_IMPLING, config.getMapgieColor());
|
|
||||||
ids.put(NpcID.MAGPIE_IMPLING_1652, config.getMapgieColor());
|
|
||||||
}
|
|
||||||
if (config.showNinja())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.NINJA_IMPLING, config.getNinjaColor());
|
|
||||||
ids.put(NpcID.NINJA_IMPLING_1653, config.getNinjaColor());
|
|
||||||
}
|
|
||||||
if (config.showDragon())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.DRAGON_IMPLING, config.getDragonColor());
|
|
||||||
ids.put(NpcID.DRAGON_IMPLING_1654, config.getDragonColor());
|
|
||||||
}
|
|
||||||
if (config.showLucky())
|
|
||||||
{
|
|
||||||
ids.put(NpcID.LUCKY_IMPLING, config.getLuckyColor());
|
|
||||||
ids.put(NpcID.LUCKY_IMPLING_7302, config.getLuckyColor());
|
|
||||||
}
|
|
||||||
if (config.showSpawn())
|
|
||||||
{
|
|
||||||
ids.put(STATIC_SPAWN, config.getSpawnColor());
|
|
||||||
ids.put(DYNAMIC_SPAWN, config.getSpawnColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawImp(Graphics2D graphics, Actor actor, String text, Color color)
|
private void drawImp(Graphics2D graphics, Actor actor, String text, Color color)
|
||||||
{
|
{
|
||||||
Polygon poly = actor.getCanvasTilePoly();
|
Polygon poly = actor.getCanvasTilePoly();
|
||||||
@@ -159,12 +85,6 @@ public class ImplingsOverlay extends Overlay
|
|||||||
OverlayUtil.renderPolygon(graphics, poly, color);
|
OverlayUtil.renderPolygon(graphics, poly, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point minimapLocation = actor.getMinimapLocation();
|
|
||||||
if (minimapLocation != null)
|
|
||||||
{
|
|
||||||
OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight());
|
Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight());
|
||||||
if (textLocation != null)
|
if (textLocation != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,13 +25,26 @@
|
|||||||
package net.runelite.client.plugins.implings;
|
package net.runelite.client.plugins.implings;
|
||||||
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.runelite.api.NPC;
|
||||||
|
import net.runelite.api.NpcID;
|
||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
|
import net.runelite.api.events.GameTick;
|
||||||
|
import net.runelite.api.queries.NPCQuery;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -42,9 +55,28 @@ import net.runelite.client.ui.overlay.Overlay;
|
|||||||
)
|
)
|
||||||
public class ImplingsPlugin extends Plugin
|
public class ImplingsPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
// Impling spawns in PuroPuro. Not in NpcID.
|
||||||
|
private static final int STATIC_SPAWN = 1618;
|
||||||
|
private static final int DYNAMIC_SPAWN = 1633;
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private NPC[] implings;
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private final Map<Integer, Color> ids = new HashMap<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ImplingsOverlay overlay;
|
private ImplingsOverlay overlay;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ImplingMinimapOverlay minimapOverlay;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ImplingsConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private QueryRunner queryRunner;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
ImplingsConfig getConfig(ConfigManager configManager)
|
ImplingsConfig getConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -55,19 +87,92 @@ public class ImplingsPlugin extends Plugin
|
|||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
// Initialize overlay config
|
// Initialize overlay config
|
||||||
overlay.updateConfig();
|
updateConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Overlay getOverlay()
|
public Collection<Overlay> getOverlays()
|
||||||
{
|
{
|
||||||
return overlay;
|
return Arrays.asList(overlay, minimapOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void updateConfig(ConfigChanged event)
|
public void updateConfig(ConfigChanged event)
|
||||||
{
|
{
|
||||||
overlay.updateConfig();
|
updateConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onGameTick(GameTick event)
|
||||||
|
{
|
||||||
|
NPCQuery implingQuery = new NPCQuery()
|
||||||
|
.idEquals(Ints.toArray(ids.keySet()));
|
||||||
|
implings = queryRunner.runQuery(implingQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateConfig()
|
||||||
|
{
|
||||||
|
ids.clear();
|
||||||
|
if (config.showBaby())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.BABY_IMPLING, config.getBabyColor());
|
||||||
|
ids.put(NpcID.BABY_IMPLING_1645, config.getBabyColor());
|
||||||
|
}
|
||||||
|
if (config.showYoung())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.YOUNG_IMPLING, config.getYoungColor());
|
||||||
|
ids.put(NpcID.YOUNG_IMPLING_1646, config.getYoungColor());
|
||||||
|
}
|
||||||
|
if (config.showGourmet())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.GOURMET_IMPLING, config.getGourmetColor());
|
||||||
|
ids.put(NpcID.GOURMET_IMPLING_1647, config.getGourmetColor());
|
||||||
|
}
|
||||||
|
if (config.showEarth())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.EARTH_IMPLING, config.getEarthColor());
|
||||||
|
ids.put(NpcID.EARTH_IMPLING_1648, config.getEarthColor());
|
||||||
|
}
|
||||||
|
if (config.showEssence())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.ESSENCE_IMPLING, config.getEssenceColor());
|
||||||
|
ids.put(NpcID.ESSENCE_IMPLING_1649, config.getEssenceColor());
|
||||||
|
}
|
||||||
|
if (config.showEclectic())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.ECLECTIC_IMPLING, config.getEclecticColor());
|
||||||
|
ids.put(NpcID.ECLECTIC_IMPLING_1650, config.getEclecticColor());
|
||||||
|
}
|
||||||
|
if (config.showNature())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.NATURE_IMPLING, config.getNatureColor());
|
||||||
|
ids.put(NpcID.NATURE_IMPLING_1651, config.getNatureColor());
|
||||||
|
}
|
||||||
|
if (config.showMagpie())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.MAGPIE_IMPLING, config.getMapgieColor());
|
||||||
|
ids.put(NpcID.MAGPIE_IMPLING_1652, config.getMapgieColor());
|
||||||
|
}
|
||||||
|
if (config.showNinja())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.NINJA_IMPLING, config.getNinjaColor());
|
||||||
|
ids.put(NpcID.NINJA_IMPLING_1653, config.getNinjaColor());
|
||||||
|
}
|
||||||
|
if (config.showDragon())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.DRAGON_IMPLING, config.getDragonColor());
|
||||||
|
ids.put(NpcID.DRAGON_IMPLING_1654, config.getDragonColor());
|
||||||
|
}
|
||||||
|
if (config.showLucky())
|
||||||
|
{
|
||||||
|
ids.put(NpcID.LUCKY_IMPLING, config.getLuckyColor());
|
||||||
|
ids.put(NpcID.LUCKY_IMPLING_7302, config.getLuckyColor());
|
||||||
|
}
|
||||||
|
if (config.showSpawn())
|
||||||
|
{
|
||||||
|
ids.put(STATIC_SPAWN, config.getSpawnColor());
|
||||||
|
ids.put(DYNAMIC_SPAWN, config.getSpawnColor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user