Make Kourend library use hidden field instead of manager

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-09-07 10:03:07 +02:00
parent f96941fa4f
commit 3ad4aa942b
2 changed files with 15 additions and 2 deletions

View File

@@ -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)
{

View File

@@ -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();
}