From 9e2fdf8b5f1c11345900d8cb44b803993f05d5f4 Mon Sep 17 00:00:00 2001 From: funkydude Date: Thu, 29 Oct 2020 01:12:29 +0000 Subject: [PATCH] Full support for the shadowlands 'HybridMinimap' should now be complete. --- Borders.lua | 77 +++++++++++++++++++++++++++++++---------------------- SexyMap.lua | 8 +++++- Shapes.lua | 15 +++++++---- 3 files changed, 62 insertions(+), 38 deletions(-) diff --git a/Borders.lua b/Borders.lua index 9592150..3d0bff8 100644 --- a/Borders.lua +++ b/Borders.lua @@ -950,43 +950,56 @@ function mod:SavePresetAs(name) self:RebuildPresets() end -local inc = 0 -function mod:CreateBorderFromParams(t) - inc = inc + 1 - local tex = tremove(texturePool) or Minimap:CreateTexture() - tex:SetTexture(t.texture) - tex:SetBlendMode(t.blendMode or "ADD") - tex:SetVertexColor(t.r or 1, t.g or 1, t.b or 1, t.a or 1) - tex:SetPoint("CENTER", Minimap, "CENTER", t.hNudge or 0, t.vNudge or 0) - tex:SetWidth((t.width or defaultSize) * (t.scale or 1)) - tex:SetHeight((t.height or defaultSize) * (t.scale or 1)) - tex:SetDrawLayer(t.drawLayer or "ARTWORK") +do + local inc = 0 + local backgroundFrame = CreateFrame("Frame") -- HybridMinimap compat + backgroundFrame:SetParent(Minimap) + backgroundFrame:SetFrameStrata("BACKGROUND") + backgroundFrame:SetFrameLevel(1) + backgroundFrame:Show() + function mod:CreateBorderFromParams(t) + inc = inc + 1 + local tex = tremove(texturePool) or Minimap:CreateTexture() - tex.rotSpeed = t.rotSpeed or 0 - tex.settings = t - tex:Show() - if t.disableRotation then - tex:SetTexCoord(0, 1, 0, 1) - else - if t.playerRotation and t.playerRotation ~= "none" then - rotateTextures[tex] = t.playerRotation + if t.drawLayer == "BACKGROUND" then -- Be compatible with HybridMinimap which sits at frame strata BACKGROUND level 100 + tex:SetParent(backgroundFrame) else - rotateTextures[tex] = t.rotSpeed ~= 0 and t.rotSpeed or nil + tex:SetParent(Minimap) end - RotateTexture(tex, t.rotation or 0, true) - end + tex:SetTexture(t.texture) + tex:SetBlendMode(t.blendMode or "ADD") + tex:SetVertexColor(t.r or 1, t.g or 1, t.b or 1, t.a or 1) + tex:SetPoint("CENTER", Minimap, "CENTER", t.hNudge or 0, t.vNudge or 0) + tex:SetWidth((t.width or defaultSize) * (t.scale or 1)) + tex:SetHeight((t.height or defaultSize) * (t.scale or 1)) + tex:SetDrawLayer(t.drawLayer or "ARTWORK") - local r,g,b,a = t.r or 1, t.g or 1, t.b or 1, t.a or 1 - tex:SetVertexColor(r,g,b,a) - textures["tex" .. inc] = tex + tex.rotSpeed = t.rotSpeed or 0 + tex.settings = t + tex:Show() + if t.disableRotation then + tex:SetTexCoord(0, 1, 0, 1) + else + if t.playerRotation and t.playerRotation ~= "none" then + rotateTextures[tex] = t.playerRotation + else + rotateTextures[tex] = t.rotSpeed ~= 0 and t.rotSpeed or nil + end + RotateTexture(tex, t.rotation or 0, true) + end - options.args.currentGroup.args.borders.args["tex" .. inc] = { - type = "group", - name = t.name or ("Border #" .. inc), - arg = "tex" .. inc, - args = borderOptions - } - return tex + local r,g,b,a = t.r or 1, t.g or 1, t.b or 1, t.a or 1 + tex:SetVertexColor(r,g,b,a) + textures["tex" .. inc] = tex + + options.args.currentGroup.args.borders.args["tex" .. inc] = { + type = "group", + name = t.name or ("Border #" .. inc), + arg = "tex" .. inc, + args = borderOptions + } + return tex + end end function mod:ClearWidgets() diff --git a/SexyMap.lua b/SexyMap.lua index f1fe98e..257e8e3 100644 --- a/SexyMap.lua +++ b/SexyMap.lua @@ -425,12 +425,18 @@ end Minimap:SetParent(UIParent) -- Undo the damage caused by automagic fuckery when a frame changes parent -- In other words, restore the minimap defaults to what they were, when it was parented to MinimapCluster -Minimap:SetFrameStrata("LOW") +Minimap:SetFrameStrata("LOW") -- Blizz Defaults patch 9.0.1 Minimap.xml Minimap:SetFrameLevel(1) -- Make sure the various minimap buttons follow the minimap -- We do this before login to prevent button placement issues MinimapBackdrop:ClearAllPoints() MinimapBackdrop:SetPoint("CENTER", Minimap, "CENTER", -8, -23) +-- This should never run as we should always load before it... unless someone force loads it early +-- If they did, the strata/level would also mess up from changing Minimap parent, so we restore it +if HybridMinimap then + HybridMinimap:SetFrameStrata("BACKGROUND") -- Blizz Defaults patch 9.0.1 Blizzard_HybridMinimap.xml + HybridMinimap:SetFrameLevel(100) +end function mod:SetupMap() local Minimap = Minimap diff --git a/Shapes.lua b/Shapes.lua index b957f2d..ddbf505 100644 --- a/Shapes.lua +++ b/Shapes.lua @@ -351,12 +351,17 @@ function mod:ApplyShape(shape) sm.buttons:UpdateDraggables() end -function sm.core:PLAYER_ENTERING_WORLD() -- XXX Investigate if it's safe to unregister this after the first application - if C_Minimap.ShouldUseHybridMinimap() then - mod:ApplyShape() - end +if not HybridMinimap then + local frame = CreateFrame("Frame") + frame:SetScript("OnEvent", function(self, event, addon) + if addon == "Blizzard_HybridMinimap" then + self:UnregisterEvent(event) + mod:ApplyShape() + self:SetScript("OnEvent", nil) + end + end) + frame:RegisterEvent("ADDON_LOADED") end -sm.core.frame:RegisterEvent("PLAYER_ENTERING_WORLD") -- Global function for other addons GetMinimapShape = function()