From 246861b5e11d6d3dc1ff60056de73a3da966c0b9 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 24 Nov 2024 14:15:09 +0100 Subject: [PATCH 1/2] refactor: Consolidate quest shutdown to a single function --- .../questhelper/managers/QuestManager.java | 40 ++++++------------- .../questhelper/panel/QuestOverviewPanel.java | 3 +- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/questhelper/managers/QuestManager.java b/src/main/java/com/questhelper/managers/QuestManager.java index fe0be56992..c01154acc0 100644 --- a/src/main/java/com/questhelper/managers/QuestManager.java +++ b/src/main/java/com/questhelper/managers/QuestManager.java @@ -36,6 +36,7 @@ import com.questhelper.steps.QuestStep; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.QuestState; @@ -59,6 +60,7 @@ * Responsible for initializing, updating, and shutting down quests. */ @Singleton +@Slf4j public class QuestManager { @Inject @@ -320,32 +322,6 @@ private void initializeNewQuest(QuestHelper questHelper, boolean shouldOpenSideb } } - /** - * Shuts down the quest from the sidebar. - * Unregisters the quest and removes it from the panel. - */ - public void shutDownQuestFromSidebar() - { - if (selectedQuest != null) - { - selectedQuest.shutDown(); - questBankManager.shutDownQuest(); - SwingUtilities.invokeLater(panel::removeQuest); - unregisterQuestFromEventBus(selectedQuest); - - // If closing the item checking helper and should still check in background, start it back up in background - if (selectedQuest.getQuest() == QuestHelperQuest.CHECK_ITEMS && config.highlightItemsBackground()) - { - selectedQuest = null; - startUpBackgroundQuest(QuestHelperQuest.CHECK_ITEMS.getName()); - } - else - { - selectedQuest = null; - } - } - } - private void shutDownPreviousQuest() { shutDownQuest(true); @@ -370,7 +346,17 @@ public void shutDownQuest(boolean shouldUpdateList) questBankManager.shutDownQuest(); SwingUtilities.invokeLater(panel::removeQuest); unregisterQuestFromEventBus(selectedQuest); - selectedQuest = null; + + // If closing the item checking helper and should still check in background, start it back up in background + if (selectedQuest.getQuest() == QuestHelperQuest.CHECK_ITEMS && config.highlightItemsBackground()) + { + selectedQuest = null; + startUpBackgroundQuest(QuestHelperQuest.CHECK_ITEMS.getName()); + } + else + { + selectedQuest = null; + } } } diff --git a/src/main/java/com/questhelper/panel/QuestOverviewPanel.java b/src/main/java/com/questhelper/panel/QuestOverviewPanel.java index 93b107d1e4..f88ff74000 100644 --- a/src/main/java/com/questhelper/panel/QuestOverviewPanel.java +++ b/src/main/java/com/questhelper/panel/QuestOverviewPanel.java @@ -375,9 +375,10 @@ public void removeQuest() revalidate(); } + /// The quest helper's X is clicked private void closeHelper() { - questManager.shutDownQuestFromSidebar(); + questManager.shutDownQuest(false); } void updateCollapseText() From cb021c088a64e9d3f7fed6d06107091171d1cb1e Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 24 Nov 2024 14:15:50 +0100 Subject: [PATCH 2/2] fix: ensure last step is reset when a quest is shut down this ensures `panel.updateHighlight` is always called once when the quest is started --- src/main/java/com/questhelper/managers/QuestManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/questhelper/managers/QuestManager.java b/src/main/java/com/questhelper/managers/QuestManager.java index c01154acc0..b79b7d3b84 100644 --- a/src/main/java/com/questhelper/managers/QuestManager.java +++ b/src/main/java/com/questhelper/managers/QuestManager.java @@ -358,6 +358,8 @@ public void shutDownQuest(boolean shouldUpdateList) selectedQuest = null; } } + + this.lastStep = null; } public void activateShortestPath()