diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 index c5b6ff7..6dbbc23 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to Quest Log Header Expander are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses [Semantic Versioning](https://semver.org/) (pre-1.0 while the game is in beta). + +## [0.5.0] - 2026-10-01 + +### Added + +- Option to remember previous quest log state. Keeps state of the quest log headers from when the map is closed. + +### Changed + +- + +### Fixed + +- + ## [0.4.1] - 2026-09-31 First public release. @@ -11,7 +26,7 @@ First public release. ### Added - `+ All` / `- All` button next to the quest counter that expands or collapses every zone header at once. -- Startup behaviour applied each time the map opens: Default (Blizzard), Always collapsed, Always expanded, or Remember my last choice. +- Startup behaviour applied each time the map opens: Default (Blizzard), Always collapsed, Always expanded - Right-click menu on the button for switching modes. - Options panel under *Options → AddOns → Quest Log Header Expander*. - Quest log search box is resized so the button fits alongside it. @@ -25,4 +40,5 @@ First public release. - Search box resize now retries until the box exists, since it isn't created until the map is first opened. - Duplicate `OnShow` hooks on the search box are no longer added repeatedly. -[0.4.1]: https://gitea.recka.tech/bepis/QuestLogHeaderExpander/releases/tag/v0.4 \ No newline at end of file +[0.4.1]: https://gitea.recka.tech/bepis/QuestLogHeaderExpander/releases/tag/v0.4 +[0.5.0]: https://gitea.recka.tech/bepis/QuestLogHeaderExpander/releases/tag/v0.5 \ No newline at end of file diff --git a/QuestLogHeaderExpander.lua b/QuestLogHeaderExpander.lua index c1f41e3..869e679 100755 --- a/QuestLogHeaderExpander.lua +++ b/QuestLogHeaderExpander.lua @@ -11,7 +11,7 @@ local modeSetting local DEFAULTS = { mode = "default", - lastState = nil, + -- lastState = nil, } local MODES = { @@ -19,7 +19,7 @@ local MODES = { { value = "collapsed", label = "Always collapsed" }, { value = "expanded", label = "Always expanded" }, -- Not working, to fix later - -- { value = "remember", label = "Remember previous state" }, + { value = "remember", label = "Remember previous state" }, } local function InitDB() @@ -92,18 +92,44 @@ local function SetAllHeaders(expand) end end +local function SnapshotHeaders() + local state = {} + for i = 1, C_QuestLog.GetNumQuestLogEntries() do + local info = C_QuestLog.GetInfo(i) + if info and info.isHeader then + state[info.title] = info.isCollapsed and true or false + end + end + QuestLogHeaderExpanderDB.headerState = state +end + +local function RestoreHeaders() + local saved = QuestLogHeaderExpanderDB.headerState + if not saved then return end + + -- Go backwards: expanding/collapsing shifts the indices after it + for i = C_QuestLog.GetNumQuestLogEntries(), 1, -1 do + local info = C_QuestLog.GetInfo(i) + if info and info.isHeader then + local wantCollapsed = saved[info.title] + if wantCollapsed ~= nil and wantCollapsed ~= info.isCollapsed then + if wantCollapsed then + CollapseQuestHeader(i) + else + ExpandQuestHeader(i) + end + end + end + end +end + local function ApplyDefaultState() local mode = GetMode() - local target if mode == "expanded" or mode == "collapsed" then - target = mode - -- elseif mode == "remember" then - -- target = QuestLogHeaderExpanderDB.lastState - end - - if target then - SetAllHeaders(target == "expanded") + SetAllHeaders(mode == "expanded") + elseif mode == "remember" then + RestoreHeaders() end end @@ -171,6 +197,12 @@ local function CreateExpandButton() local parent = QuestMapFrame and QuestMapFrame.QuestsFrame if not parent then return end + QuestMapFrame:HookScript("OnHide", function() + if GetMode() == "remember" then + SnapshotHeaders() + end + end) + button = CreateFrame("Button", "QuestLogHeaderExpanderButton", parent, "UIPanelButtonTemplate") button:SetSize(50, 20) @@ -190,7 +222,7 @@ local function CreateExpandButton() local expanding = not AreAllHeadersExpanded() SetAllHeaders(expanding) - QuestLogHeaderExpanderDB.lastState = expanding and "expanded" or "collapsed" + -- QuestLogHeaderExpanderDB.lastState = expanding and "expanded" or "collapsed" end) button:SetScript("OnEnter", function(self) diff --git a/QuestLogHeaderExpander.toc b/QuestLogHeaderExpander.toc index 569e477..ef4feab 100755 --- a/QuestLogHeaderExpander.toc +++ b/QuestLogHeaderExpander.toc @@ -1,8 +1,10 @@ ## Interface: 16001 ## Title: Quest Log Header Expander ## SavedVariables: QuestLogHeaderExpanderDB +## X-License: MIT +## X-Website: https://github.com/Recka50/QuestLogHeaderExpander ## Notes: Adds an Expand All button to the quest log. ## Author: Drink_Bepis -## Version: 0.4.1 +## Version: 0.5.0 QuestLogHeaderExpander.lua diff --git a/README.md b/README.md index 69153bd..390f9ce 100755 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ Built for **World of Warcraft Forever** using the retail UI API. Interface versi - **Always collapsed** - **Always expanded** - **Right-click the button** for a quick context menu to change the mode. -- **Options panel** under *Options → AddOns → Quest Expand All* with the same setting. +- **Options panel** under *Options → AddOns → Quest Log Header Expander* with the same setting. - Resizes the quest log search box so the button fits alongside it. ## Installation -1. Download the latest release from the [releases](https://gitea.recka.tech/bepis/QuestLogHeaderExpander/releases) page. Don't use "Source code (zip)", as it has the wrong folder name. +1. Download the latest release from the [releases](https://github.com/Recka50/QuestLogHeaderExpander/releases) page. Don't use "Source code (zip)", as it has the wrong folder name. 2. Extract it into your `Interface/AddOns/` folder so you end up with `Interface/AddOns/QuestLogHeaderExpander/`. 3. Fully restart the game (Required for first-time run). @@ -47,7 +47,7 @@ QuestLogHeaderExpander/ | --- | --- | | Left-click the button | Expand or collapse all zone headers | | Right-click the button | Open the mode context menu | -| Options → AddOns → Quest Expand All | Choose the startup mode from a dropdown | +| Options → AddOns → Quest Log Header Expander | Choose the startup mode from a dropdown | ## Configuration