Merge pull request #3607 from Abextm/library-hide-tab
kourendlibrary: Hide navbutton when not in the library
This commit is contained in:
@@ -53,7 +53,6 @@ public class KourendLibraryOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
private final static WorldPoint LIBRARY_CENTER = new WorldPoint(1632, 3807, 1);
|
private final static WorldPoint LIBRARY_CENTER = new WorldPoint(1632, 3807, 1);
|
||||||
private final static int MAXIMUM_DISTANCE = 24;
|
private final static int MAXIMUM_DISTANCE = 24;
|
||||||
private final static int ROUGH_ENABLE_DISTANCE = 45;
|
|
||||||
|
|
||||||
private final Library library;
|
private final Library library;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
@@ -79,7 +78,7 @@ public class KourendLibraryOverlay extends Overlay
|
|||||||
|
|
||||||
WorldPoint playerLoc = player.getWorldLocation();
|
WorldPoint playerLoc = player.getWorldLocation();
|
||||||
|
|
||||||
if (playerLoc.distanceTo2D(LIBRARY_CENTER) > ROUGH_ENABLE_DISTANCE)
|
if (playerLoc.getRegionID() != KourendLibraryPlugin.REGION)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.AnimationID;
|
import net.runelite.api.AnimationID;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
@@ -55,6 +56,8 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class KourendLibraryPlugin extends Plugin
|
public class KourendLibraryPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
final static int REGION = 6459;
|
||||||
|
|
||||||
final static boolean debug = false;
|
final static boolean debug = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -77,6 +80,7 @@ public class KourendLibraryPlugin extends Plugin
|
|||||||
|
|
||||||
private KourendLibraryPanel panel;
|
private KourendLibraryPanel panel;
|
||||||
private NavigationButton navButton;
|
private NavigationButton navButton;
|
||||||
|
private boolean buttonAttached = false;
|
||||||
|
|
||||||
private WorldPoint lastBookcaseClick = null;
|
private WorldPoint lastBookcaseClick = null;
|
||||||
private WorldPoint lastBookcaseAnimatedOn = null;
|
private WorldPoint lastBookcaseAnimatedOn = null;
|
||||||
@@ -102,14 +106,13 @@ public class KourendLibraryPlugin extends Plugin
|
|||||||
.icon(icon)
|
.icon(icon)
|
||||||
.panel(panel)
|
.panel(panel)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
pluginToolbar.addNavigation(navButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown()
|
protected void shutDown()
|
||||||
{
|
{
|
||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
|
|
||||||
pluginToolbar.removeNavigation(navButton);
|
pluginToolbar.removeNavigation(navButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +154,28 @@ public class KourendLibraryPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
void onTick(GameTick tick)
|
void onTick(GameTick tick)
|
||||||
{
|
{
|
||||||
|
boolean inRegion = client.getLocalPlayer().getWorldLocation().getRegionID() == REGION;
|
||||||
|
if (inRegion != buttonAttached)
|
||||||
|
{
|
||||||
|
SwingUtilities.invokeLater(() ->
|
||||||
|
{
|
||||||
|
if (inRegion)
|
||||||
|
{
|
||||||
|
pluginToolbar.addNavigation(navButton);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pluginToolbar.removeNavigation(navButton);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonAttached = inRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inRegion)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (lastBookcaseAnimatedOn != null)
|
if (lastBookcaseAnimatedOn != null)
|
||||||
{
|
{
|
||||||
Widget find = client.getWidget(WidgetInfo.DIALOG_SPRITE_SPRITE);
|
Widget find = client.getWidget(WidgetInfo.DIALOG_SPRITE_SPRITE);
|
||||||
|
|||||||
Reference in New Issue
Block a user