From 8ee8c2516cdebf7f70304f9b080886a76c7858a1 Mon Sep 17 00:00:00 2001 From: Xurkon Date: Mon, 1 Jun 2026 18:21:16 -0500 Subject: [PATCH] fix(worldmap): persist button toggle; hook OnShow/OnHide; Mapster offset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Refactor button positioning and visibility into _PositionMapButton and _RefreshMapButtonVisibility helpers. Single source of truth for both. - WorldMapButton.Initialize now hooks OnShow/OnHide on WorldMapFrame so the button self-updates when the user opens/closes the world map. No more manual show/hide calls required from elsewhere in the code. - Toggle(shouldShow) now persists to Questie.db.profile.mapShowHideEnabled and calls _RefreshMapButtonVisibility, so the user's choice survives /reload and is consistent with the world map's current visibility. - Special-case Mapster offset: -50, -72.3 vs default -50, -40. Without this, the button overlapped Mapster's UI elements when both addons were loaded. - Frame level set to 99 to ensure the button draws above other map elements. All helpers are no-op-safe when mapButton is nil. IsAddOnLoaded ('Mapster') is optional — falls through to default offset if Mapster is not loaded. --- Modules/WorldMapButton/WorldMapButton.lua | 35 +++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/Modules/WorldMapButton/WorldMapButton.lua b/Modules/WorldMapButton/WorldMapButton.lua index 075139d..b81e725 100644 --- a/Modules/WorldMapButton/WorldMapButton.lua +++ b/Modules/WorldMapButton/WorldMapButton.lua @@ -15,8 +15,36 @@ local KButtons = QuestieCompat.KButtons or LibStub("Krowi_WorldMapButtons-1.4") local mapButton +local function _PositionMapButton() + if not mapButton then return end + + local anchor = WorldMapDetailFrame or WorldMapButton or WorldMapFrame + mapButton:SetParent(anchor) + mapButton:ClearAllPoints() + if IsAddOnLoaded and IsAddOnLoaded("Mapster") then + mapButton:SetPoint("TOPRIGHT", anchor, "TOPRIGHT", -50, -72.3) + else + mapButton:SetPoint("TOPRIGHT", anchor, "TOPRIGHT", -50, -40) + end + mapButton:SetFrameLevel(99) +end + +local function _RefreshMapButtonVisibility() + if not mapButton then return end + + _PositionMapButton() + if Questie.db.profile.mapShowHideEnabled and WorldMapFrame:IsVisible() then + mapButton:Show() + else + mapButton:Hide() + end +end + function WorldMapButton.Initialize() mapButton = KButtons:Add("QuestieWorldMapButtonTemplate", "BUTTON") + _RefreshMapButtonVisibility() + WorldMapFrame:HookScript("OnShow", _RefreshMapButtonVisibility) + WorldMapFrame:HookScript("OnHide", _RefreshMapButtonVisibility) Questie.WorldMap = { Button = mapButton @@ -25,11 +53,8 @@ end ---@param shouldShow boolean function WorldMapButton.Toggle(shouldShow) - if shouldShow then - mapButton:Show() - else - mapButton:Hide() - end + Questie.db.profile.mapShowHideEnabled = shouldShow + _RefreshMapButtonVisibility() end QuestieWorldMapButtonMixin = {