From 931cb7adf26a3c4166cd3d49aa2c713421a0d222 Mon Sep 17 00:00:00 2001 From: rfick Date: Thu, 19 Mar 2020 11:44:56 -0700 Subject: [PATCH 1/2] kourendlibrary: Indicate books not in inventory This commit changes the Kourend library panel to show a different color for books which are not the target based on whether they are in the player's inventory or not. Previously, the target book would be shown in green and all other books would be listed in white. Now, non-target books in the player's inventory are shown in white and those the player does not have are shown in orange. Co-authored-by: Jordan Atwood --- .../client/plugins/kourendlibrary/BookPanel.java | 10 +++++++++- .../plugins/kourendlibrary/KourendLibraryPanel.java | 10 ++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java index a82cee5814..6842b34e7d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java @@ -77,6 +77,14 @@ class BookPanel extends JPanel void setIsTarget(boolean target) { - location.setForeground(target ? Color.GREEN : Color.WHITE); + location.setForeground(target ? Color.GREEN : Color.ORANGE); + } + + void setIsHeld(boolean held) + { + if (held) + { + location.setForeground(Color.WHITE); + } } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPanel.java index 8480328c47..bf5cffb417 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPanel.java @@ -52,6 +52,7 @@ class KourendLibraryPanel extends PluginPanel private static final ImageIcon RESET_ICON; private static final ImageIcon RESET_HOVER_ICON; + private final KourendLibraryPlugin plugin; private final KourendLibraryConfig config; private final Library library; @@ -65,10 +66,11 @@ class KourendLibraryPanel extends PluginPanel } @Inject - KourendLibraryPanel(KourendLibraryConfig config, Library library) + KourendLibraryPanel(KourendLibraryPlugin plugin, KourendLibraryConfig config, Library library) { super(); + this.plugin = plugin; this.config = config; this.library = library; } @@ -117,7 +119,11 @@ class KourendLibraryPanel extends PluginPanel Book customerBook = library.getCustomerBook(); for (Map.Entry b : bookPanels.entrySet()) { - b.getValue().setIsTarget(customerBook == b.getKey()); + final Book book = b.getKey(); + final BookPanel panel = b.getValue(); + + panel.setIsTarget(customerBook == book); + panel.setIsHeld(plugin.doesPlayerContainBook(book)); } HashMap> bookLocations = new HashMap<>(); From 4369d8baa8edcd5526528a73f8c1fa3a04d95de4 Mon Sep 17 00:00:00 2001 From: rfick Date: Thu, 19 Mar 2020 11:49:14 -0700 Subject: [PATCH 2/2] kourendlibrary: Show a hint arrow above target book This commit adds a configuration to the Kourend library plugin to display a hint arrow above the target bookcase. (when it is known) Co-authored-by: Jordan Atwood --- .../kourendlibrary/KourendLibraryConfig.java | 10 ++++ .../kourendlibrary/KourendLibraryPlugin.java | 60 +++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryConfig.java index 2abb7c2255..6c2bd860d3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryConfig.java @@ -72,4 +72,14 @@ public interface KourendLibraryConfig extends Config { return true; } + + @ConfigItem( + keyName = "showTargetHintArrow", + name = "Show target book arrow", + description = "Show a hint arrow pointing to the target bookcase" + ) + default boolean showTargetHintArrow() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java index a6221462c3..6b81bd9f18 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java @@ -199,6 +199,15 @@ public class KourendLibraryPlugin extends Plugin } }); } + else if (ev.getKey().equals("showTargetHintArrow")) + { + if (client.getLocalPlayer() == null || client.getLocalPlayer().getWorldLocation().getRegionID() != REGION) + { + return; + } + + updateBookcaseHintArrow(); + } } @Subscribe @@ -227,7 +236,7 @@ public class KourendLibraryPlugin extends Plugin if (event.getMessage().equals("You don't find anything useful here.")) { library.mark(lastBookcaseAnimatedOn, null); - panel.update(); + updateBooksPanel(); lastBookcaseAnimatedOn = null; } } @@ -277,7 +286,7 @@ public class KourendLibraryPlugin extends Plugin if (book != null) { library.mark(lastBookcaseAnimatedOn, book); - panel.update(); + updateBooksPanel(); lastBookcaseAnimatedOn = null; } } @@ -302,12 +311,12 @@ public class KourendLibraryPlugin extends Plugin } library.setCustomer(npcHead.getModelId(), book); - panel.update(); + updateBooksPanel(); } else if (text.contains("You can have this other book") || text.contains("please accept a token of my thanks.") || text.contains("Thanks, I'll get on with reading it.")) { library.setCustomer(-1, null); - panel.update(); + updateBooksPanel(); } } } @@ -361,6 +370,49 @@ public class KourendLibraryPlugin extends Plugin } } + private void updateBooksPanel() + { + panel.update(); + updateBookcaseHintArrow(); + } + + private void updateBookcaseHintArrow() + { + final Book customerBook = library.getCustomerBook(); + final SolvedState state = library.getState(); + + // Clear the hint arrow if the player has no book requested of them + // or if the player is already holding the correct book + // or if this plugin is configured not to show the target book hint arrow + if (customerBook == null || doesPlayerContainBook(customerBook) || !config.showTargetHintArrow()) + { + client.clearHintArrow(); + } + else if (state == SolvedState.COMPLETE && client.getHintArrowPoint() == null) + { + // Show a hint arrow pointing toward the target book if all book locations are known + // and a hint arrow is not already being displayed + for (Bookcase bookcase : library.getBookcases()) + { + final Set books = bookcase.getPossibleBooks(); + + if (!books.isEmpty()) + { + final Book book = books.iterator().next(); + + // Each bookcase in a complete solved state will contain only one book. If that book is the book + // the customer wants, mark the bookcase which contains it with a hint arrow. + if (book == customerBook) + { + WorldPoint correctLocation = bookcase.getLocation(); + client.setHintArrow(correctLocation); + break; + } + } + } + } + } + static boolean isLibraryCustomer(int npcId) { return npcId == NpcID.VILLIA || npcId == NpcID.PROFESSOR_GRACKLEBONE || npcId == NpcID.SAM_7049;