Merge pull request #5365 from deathbeam/make-overlays-be-hidden-only
Make cannon, fishing & kourend overlay use hidden properties instead of overlay manager
This commit is contained in:
@@ -128,11 +128,13 @@ public class CannonPlugin extends Plugin
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
overlayManager.add(cannonOverlay);
|
||||
overlayManager.add(cannonSpotOverlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
cannonSpotOverlay.setHidden(true);
|
||||
overlayManager.remove(cannonOverlay);
|
||||
overlayManager.remove(cannonSpotOverlay);
|
||||
cannonPlaced = false;
|
||||
@@ -190,14 +192,7 @@ public class CannonPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
if (hasAll)
|
||||
{
|
||||
overlayManager.add(cannonSpotOverlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayManager.remove(cannonSpotOverlay);
|
||||
}
|
||||
cannonSpotOverlay.setHidden(!hasAll);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Client;
|
||||
import static net.runelite.api.ItemID.CANNONBALL;
|
||||
import net.runelite.api.Perspective;
|
||||
@@ -52,6 +54,9 @@ public class CannonSpotOverlay extends Overlay
|
||||
@Inject
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private boolean hidden;
|
||||
|
||||
@Inject
|
||||
CannonSpotOverlay(Client client, CannonPlugin plugin, CannonConfig config)
|
||||
{
|
||||
@@ -64,7 +69,7 @@ public class CannonSpotOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.showCannonSpots() || plugin.isCannonPlaced())
|
||||
if (hidden || !config.showCannonSpots() || plugin.isCannonPlaced())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -114,12 +114,16 @@ public class FishingPlugin extends Plugin
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
overlayManager.add(overlay);
|
||||
overlayManager.add(spotOverlay);
|
||||
overlayManager.add(fishingSpotMinimapOverlay);
|
||||
updateConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
spotOverlay.setHidden(true);
|
||||
fishingSpotMinimapOverlay.setHidden(true);
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.remove(spotOverlay);
|
||||
overlayManager.remove(fishingSpotMinimapOverlay);
|
||||
@@ -139,16 +143,8 @@ public class FishingPlugin extends Plugin
|
||||
|| canPlayerFish(client.getItemContainer(InventoryID.INVENTORY))
|
||||
|| canPlayerFish(client.getItemContainer(InventoryID.EQUIPMENT));
|
||||
|
||||
if (showOverlays)
|
||||
{
|
||||
overlayManager.add(spotOverlay);
|
||||
overlayManager.add(fishingSpotMinimapOverlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayManager.remove(spotOverlay);
|
||||
overlayManager.remove(fishingSpotMinimapOverlay);
|
||||
}
|
||||
spotOverlay.setHidden(!showOverlays);
|
||||
fishingSpotMinimapOverlay.setHidden(!showOverlays);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -162,8 +158,8 @@ public class FishingPlugin extends Plugin
|
||||
if (event.getMessage().contains("You catch a") || event.getMessage().contains("You catch some"))
|
||||
{
|
||||
session.setLastFishCaught(Instant.now());
|
||||
overlayManager.add(spotOverlay);
|
||||
overlayManager.add(fishingSpotMinimapOverlay);
|
||||
spotOverlay.setHidden(false);
|
||||
fishingSpotMinimapOverlay.setHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.inject.Inject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.GraphicID;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
@@ -39,6 +41,9 @@ class FishingSpotMinimapOverlay extends Overlay
|
||||
{
|
||||
private final FishingPlugin plugin;
|
||||
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private boolean hidden;
|
||||
|
||||
@Inject
|
||||
public FishingSpotMinimapOverlay(FishingPlugin plugin)
|
||||
{
|
||||
@@ -50,6 +55,11 @@ class FishingSpotMinimapOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (hidden)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
NPC[] fishingSpots = plugin.getFishingSpots();
|
||||
if (fishingSpots == null)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import javax.inject.Inject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GraphicID;
|
||||
import net.runelite.api.NPC;
|
||||
@@ -54,6 +56,9 @@ class FishingSpotOverlay extends Overlay
|
||||
private final Client client;
|
||||
private final ItemManager itemManager;
|
||||
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private boolean hidden;
|
||||
|
||||
@Inject
|
||||
private FishingSpotOverlay(FishingPlugin plugin, FishingConfig config, Client client, ItemManager itemManager)
|
||||
{
|
||||
@@ -68,6 +73,11 @@ class FishingSpotOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (hidden)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
NPC[] fishingSpots = plugin.getFishingSpots();
|
||||
if (fishingSpots == null)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Perspective;
|
||||
import static net.runelite.api.Perspective.getCanvasTilePoly;
|
||||
@@ -53,6 +55,9 @@ class KourendLibraryOverlay extends Overlay
|
||||
private final Library library;
|
||||
private final Client client;
|
||||
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private boolean hidden;
|
||||
|
||||
@Inject
|
||||
private KourendLibraryOverlay(Library library, Client client)
|
||||
{
|
||||
@@ -66,6 +71,11 @@ class KourendLibraryOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D g)
|
||||
{
|
||||
if (hidden)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Player player = client.getLocalPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
|
||||
@@ -118,6 +118,8 @@ public class KourendLibraryPlugin extends Plugin
|
||||
.panel(panel)
|
||||
.build();
|
||||
|
||||
overlayManager.add(overlay);
|
||||
|
||||
if (!config.hideButton())
|
||||
{
|
||||
clientToolbar.addNavigation(navButton);
|
||||
@@ -127,6 +129,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
overlay.setHidden(true);
|
||||
overlayManager.remove(overlay);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
buttonAttached = false;
|
||||
@@ -170,7 +173,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
if (MenuAction.GAME_OBJECT_FIRST_OPTION == menuOpt.getMenuAction() && menuOpt.getMenuTarget().contains("Bookshelf"))
|
||||
{
|
||||
lastBookcaseClick = WorldPoint.fromScene(client, menuOpt.getActionParam(), menuOpt.getWidgetId(), client.getPlane());
|
||||
overlayManager.add(overlay);
|
||||
overlay.setHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +259,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
overlayManager.add(overlay);
|
||||
overlay.setHidden(false);
|
||||
library.setCustomer(cust, book);
|
||||
panel.update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user