fishing plugin: move minimap overlay to own overlay
To render above the minimap in resizable, it must be above widgets
This commit is contained in:
@@ -25,23 +25,32 @@
|
|||||||
package net.runelite.client.plugins.fishing;
|
package net.runelite.client.plugins.fishing;
|
||||||
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
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.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Fishing plugin"
|
name = "Fishing plugin"
|
||||||
@@ -49,6 +58,14 @@ import net.runelite.client.ui.overlay.Overlay;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class FishingPlugin extends Plugin
|
public class FishingPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
private final List<Integer> spotIds = new ArrayList<>();
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
|
private NPC[] fishingSpots;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private QueryRunner queryRunner;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private FishingConfig config;
|
private FishingConfig config;
|
||||||
|
|
||||||
@@ -58,6 +75,9 @@ public class FishingPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private FishingSpotOverlay spotOverlay;
|
private FishingSpotOverlay spotOverlay;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private FishingSpotMinimapOverlay fishingSpotMinimapOverlay;
|
||||||
|
|
||||||
private final FishingSession session = new FishingSession();
|
private final FishingSession session = new FishingSession();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,13 +96,13 @@ public class FishingPlugin extends Plugin
|
|||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
// Initialize overlay config
|
// Initialize overlay config
|
||||||
spotOverlay.updateConfig();
|
updateConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Overlay> getOverlays()
|
public Collection<Overlay> getOverlays()
|
||||||
{
|
{
|
||||||
return Arrays.asList(overlay, spotOverlay);
|
return Arrays.asList(overlay, spotOverlay, fishingSpotMinimapOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FishingSession getSession()
|
public FishingSession getSession()
|
||||||
@@ -107,7 +127,56 @@ public class FishingPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void updateConfig(ConfigChanged event)
|
public void updateConfig(ConfigChanged event)
|
||||||
{
|
{
|
||||||
spotOverlay.updateConfig();
|
updateConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateConfig()
|
||||||
|
{
|
||||||
|
spotIds.clear();
|
||||||
|
if (config.showShrimp())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.SHRIMP.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showLobster())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.LOBSTER.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showShark())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.SHARK.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showMonkfish())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.MONKFISH.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showSalmon())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.SALMON.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showBarb())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.BARB_FISH.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showAngler())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.ANGLERFISH.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showMinnow())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.MINNOW.getIds()));
|
||||||
|
}
|
||||||
|
if (config.showInfernalEel())
|
||||||
|
{
|
||||||
|
spotIds.addAll(Ints.asList(FishingSpot.INFERNAL_EEL.getIds()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void checkSpots(GameTick event)
|
||||||
|
{
|
||||||
|
NPCQuery query = new NPCQuery()
|
||||||
|
.idEquals(Ints.toArray(spotIds));
|
||||||
|
fishingSpots = queryRunner.runQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schedule(
|
@Schedule(
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||||
|
* 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.fishing;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.NPC;
|
||||||
|
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;
|
||||||
|
|
||||||
|
class FishingSpotMinimapOverlay extends Overlay
|
||||||
|
{
|
||||||
|
private final FishingPlugin plugin;
|
||||||
|
private final FishingConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public FishingSpotMinimapOverlay(FishingPlugin plugin, FishingConfig config)
|
||||||
|
{
|
||||||
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
|
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension render(Graphics2D graphics, Point parent)
|
||||||
|
{
|
||||||
|
if (!config.enabled())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
NPC[] fishingSpots = plugin.getFishingSpots();
|
||||||
|
if (fishingSpots == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NPC npc : fishingSpots)
|
||||||
|
{
|
||||||
|
FishingSpot spot = FishingSpot.getSpot(npc.getId());
|
||||||
|
|
||||||
|
if (spot == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color color = npc.getId() == FishingSpot.FLYING_FISH ? Color.RED : Color.CYAN;
|
||||||
|
|
||||||
|
net.runelite.api.Point minimapLocation = npc.getMinimapLocation();
|
||||||
|
if (minimapLocation != null)
|
||||||
|
{
|
||||||
|
OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,40 +24,33 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.fishing;
|
package net.runelite.client.plugins.fishing;
|
||||||
|
|
||||||
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.Point;
|
import java.awt.Point;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
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;
|
|
||||||
|
|
||||||
class FishingSpotOverlay extends Overlay
|
class FishingSpotOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final List<Integer> ids = new ArrayList<>();
|
private final FishingPlugin plugin;
|
||||||
|
|
||||||
private final QueryRunner queryRunner;
|
|
||||||
private final FishingConfig config;
|
private final FishingConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ItemManager itemManager;
|
ItemManager itemManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FishingSpotOverlay(QueryRunner queryRunner, FishingConfig config)
|
public FishingSpotOverlay(FishingPlugin plugin, FishingConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||||
this.queryRunner = queryRunner;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,11 +62,13 @@ class FishingSpotOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NPCQuery query = new NPCQuery()
|
NPC[] fishingSpots = plugin.getFishingSpots();
|
||||||
.idEquals(Ints.toArray(ids));
|
if (fishingSpots == null)
|
||||||
NPC[] npcs = queryRunner.runQuery(query);
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
for (NPC npc : npcs)
|
for (NPC npc : fishingSpots)
|
||||||
{
|
{
|
||||||
FishingSpot spot = FishingSpot.getSpot(npc.getId());
|
FishingSpot spot = FishingSpot.getSpot(npc.getId());
|
||||||
|
|
||||||
@@ -81,6 +76,7 @@ class FishingSpotOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color color = npc.getId() == FishingSpot.FLYING_FISH ? Color.RED : Color.CYAN;
|
Color color = npc.getId() == FishingSpot.FLYING_FISH ? Color.RED : Color.CYAN;
|
||||||
if (config.showIcons())
|
if (config.showIcons())
|
||||||
{
|
{
|
||||||
@@ -105,45 +101,4 @@ class FishingSpotOverlay extends Overlay
|
|||||||
BufferedImage fishImage = itemManager.getImage(spot.getFishSpriteId());
|
BufferedImage fishImage = itemManager.getImage(spot.getFishSpriteId());
|
||||||
return fishImage;
|
return fishImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateConfig()
|
|
||||||
{
|
|
||||||
ids.clear();
|
|
||||||
if (config.showShrimp())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.SHRIMP.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showLobster())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.LOBSTER.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showShark())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.SHARK.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showMonkfish())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.MONKFISH.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showSalmon())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.SALMON.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showBarb())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.BARB_FISH.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showAngler())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.ANGLERFISH.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showMinnow())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.MINNOW.getIds()));
|
|
||||||
}
|
|
||||||
if (config.showInfernalEel())
|
|
||||||
{
|
|
||||||
ids.addAll(Ints.asList(FishingSpot.INFERNAL_EEL.getIds()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,12 +244,6 @@ public class OverlayUtil
|
|||||||
renderPolygon(graphics, poly, color);
|
renderPolygon(graphics, poly, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point minimapLocation = actor.getMinimapLocation();
|
|
||||||
if (minimapLocation != null)
|
|
||||||
{
|
|
||||||
renderMinimapLocation(graphics, minimapLocation, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight() + 40);
|
Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight() + 40);
|
||||||
if (textLocation != null)
|
if (textLocation != null)
|
||||||
{
|
{
|
||||||
@@ -265,12 +259,6 @@ public class OverlayUtil
|
|||||||
renderPolygon(graphics, poly, color);
|
renderPolygon(graphics, poly, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point minimapLocation = actor.getMinimapLocation();
|
|
||||||
if (minimapLocation != null)
|
|
||||||
{
|
|
||||||
renderMinimapLocation(graphics, minimapLocation, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
Point imageLocation = actor.getCanvasImageLocation(graphics, image, actor.getLogicalHeight());
|
Point imageLocation = actor.getCanvasImageLocation(graphics, image, actor.getLogicalHeight());
|
||||||
if (imageLocation != null)
|
if (imageLocation != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user