Make KourendLibrary overlay show only on interact
Make KourendLibrary plugin overlay show only on interaction with bookcase or with customer after login, as by default the noise caused by the overlays is horrendous. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -29,7 +29,6 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import java.awt.Polygon;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.List;
|
||||
@@ -38,6 +37,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Perspective;
|
||||
import static net.runelite.api.Perspective.getCanvasTilePoly;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
@@ -47,17 +47,14 @@ import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
import static net.runelite.api.Perspective.getCanvasTilePoly;
|
||||
|
||||
class KourendLibraryOverlay extends Overlay
|
||||
{
|
||||
private final static int MAXIMUM_DISTANCE = 24;
|
||||
|
||||
private final Library library;
|
||||
private final Client client;
|
||||
|
||||
@Inject
|
||||
KourendLibraryOverlay(Library library, Client client)
|
||||
private KourendLibraryOverlay(Library library, Client client)
|
||||
{
|
||||
this.library = library;
|
||||
this.client = client;
|
||||
|
||||
@@ -49,8 +49,8 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@@ -62,6 +62,8 @@ import net.runelite.client.util.ImageUtil;
|
||||
@Slf4j
|
||||
public class KourendLibraryPlugin extends Plugin
|
||||
{
|
||||
private static final Pattern BOOK_EXTRACTOR = Pattern.compile("'<col=0000ff>(.*)</col>'");
|
||||
private static final Pattern TAG_MATCHER = Pattern.compile("(<[^>]*>)");
|
||||
final static int REGION = 6459;
|
||||
|
||||
final static boolean debug = false;
|
||||
@@ -90,7 +92,6 @@ public class KourendLibraryPlugin extends Plugin
|
||||
private KourendLibraryPanel panel;
|
||||
private NavigationButton navButton;
|
||||
private boolean buttonAttached = false;
|
||||
|
||||
private WorldPoint lastBookcaseClick = null;
|
||||
private WorldPoint lastBookcaseAnimatedOn = null;
|
||||
|
||||
@@ -103,7 +104,6 @@ public class KourendLibraryPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
overlayManager.add(overlay);
|
||||
Book.fillImages(itemManager);
|
||||
|
||||
panel = injector.getInstance(KourendLibraryPanel.class);
|
||||
@@ -124,6 +124,16 @@ public class KourendLibraryPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
buttonAttached = false;
|
||||
lastBookcaseClick = null;
|
||||
lastBookcaseAnimatedOn = null;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged ev)
|
||||
{
|
||||
@@ -154,25 +164,18 @@ public class KourendLibraryPlugin extends Plugin
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onMenuOptionClicked(MenuOptionClicked menuOpt)
|
||||
public void onMenuOptionClicked(MenuOptionClicked menuOpt)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged anim)
|
||||
public void onAnimationChanged(AnimationChanged anim)
|
||||
{
|
||||
if (anim.getActor() == client.getLocalPlayer() && anim.getActor().getAnimation() == AnimationID.LOOKING_INTO)
|
||||
{
|
||||
@@ -194,11 +197,8 @@ public class KourendLibraryPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern BOOK_EXTRACTOR = Pattern.compile("'<col=0000ff>(.*)</col>'");
|
||||
private static final Pattern TAG_MATCHER = Pattern.compile("(<[^>]*>)");
|
||||
|
||||
@Subscribe
|
||||
void onTick(GameTick tick)
|
||||
public void onTick(GameTick tick)
|
||||
{
|
||||
boolean inRegion = client.getLocalPlayer().getWorldLocation().getRegionID() == REGION;
|
||||
if (config.hideButton() && inRegion != buttonAttached)
|
||||
@@ -255,6 +255,8 @@ public class KourendLibraryPlugin extends Plugin
|
||||
log.warn("Book '{}' is not recognised", bookName);
|
||||
return;
|
||||
}
|
||||
|
||||
overlayManager.add(overlay);
|
||||
library.setCustomer(cust, book);
|
||||
panel.update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user