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