Skip to content

Commit

Permalink
fix: ensure last step is reset on quest shutdown (#1862)
Browse files Browse the repository at this point in the history
* refactor: Consolidate quest shutdown to a single function

* 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
  • Loading branch information
pajlada authored Nov 24, 2024
1 parent 321a8f7 commit c296cfb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
42 changes: 15 additions & 27 deletions src/main/java/com/questhelper/managers/QuestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -59,6 +60,7 @@
* Responsible for initializing, updating, and shutting down quests.
*/
@Singleton
@Slf4j
public class QuestManager
{
@Inject
Expand Down Expand Up @@ -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);
Expand All @@ -370,8 +346,20 @@ 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;
}
}

this.lastStep = null;
}

public void activateShortestPath()
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/questhelper/panel/QuestOverviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c296cfb

Please sign in to comment.