Skip to content

Commit

Permalink
Update pin frame pool for 11.x compat
Browse files Browse the repository at this point in the history
This is a bit ugly since the exposed frame pools use a secure pool that
we can't mess with, so instead create an unsecure texture pool (because
frame or even object pools are not exposed, thanks Blizzard), and
repurpose it to be a frame pool once again.
  • Loading branch information
Nevcairiel committed Jun 19, 2024
1 parent 6a0a022 commit 4ac00ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ read_globals = {

-- FrameXML functions
"CreateFramePool",
"CreateSecureFramePool",
"CreateUnsecuredTexturePool",
"CreateFromMixins",
"CreateVector2D",
"FramePool_HideAndClearAnchors",
"Mixin",

-- FrameXML Frames
Expand Down
28 changes: 22 additions & 6 deletions HereBeDragons-Pins-2.0.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- HereBeDragons-Pins is a library to show pins/icons on the world map and minimap

local MAJOR, MINOR = "HereBeDragons-Pins-2.0", 12
local MAJOR, MINOR = "HereBeDragons-Pins-2.0", 13
assert(LibStub, MAJOR .. " requires LibStub")

local pins, _oldversion = LibStub:NewLibrary(MAJOR, MINOR)
Expand All @@ -20,10 +20,21 @@ pins.minimapPinRegistry = pins.minimapPinRegistry or {}
-- and worldmap pins
pins.worldmapPins = pins.worldmapPins or {}
pins.worldmapPinRegistry = pins.worldmapPinRegistry or {}
pins.worldmapPinsPool = pins.worldmapPinsPool or CreateFramePool("FRAME")

pins.worldmapProvider = pins.worldmapProvider or CreateFromMixins(MapCanvasDataProviderMixin)
pins.worldmapProviderPin = pins.worldmapProviderPin or CreateFromMixins(MapCanvasPinMixin)

if not pins.worldmapPinsPool then
-- new frame pools in WoW 11.x
if CreateFramePool == CreateSecureFramePool then
-- the proper unsecure frame pool type isn't exposed (not even a plain object pool), so create a texture pool and replace its innards
pins.worldmapPinsPool = CreateUnsecuredTexturePool(nil, nil, nil, "HereBeDragonsPinsTemplate")
pins.worldmapPinsPool.createFunc = nil
else
pins.worldmapPinsPool = CreateFramePool("FRAME")
end
end

-- store a reference to the active minimap object
pins.Minimap = pins.Minimap or Minimap

Expand Down Expand Up @@ -333,19 +344,24 @@ end

-- setup pin pool
worldmapPinsPool.parent = WorldMapFrame:GetCanvas()
worldmapPinsPool.creationFunc = function(framePool)
local frame = CreateFrame(framePool.frameType, nil, framePool.parent)
worldmapPinsPool.createFunc = function()
local frame = CreateFrame("Frame", nil, WorldMapFrame:GetCanvas())
frame:SetSize(1, 1)
return Mixin(frame, worldmapProviderPin)
end
worldmapPinsPool.resetterFunc = function(pinPool, pin)
FramePool_HideAndClearAnchors(pinPool, pin)
worldmapPinsPool.resetFunc = function(pinPool, pin)
pin:Hide()
pin:ClearAllPoints()
pin:OnReleased()

pin.pinTemplate = nil
pin.owningMap = nil
end

-- pre-11.x func names
worldmapPinsPool.creationFunc = worldmapPinsPool.createFunc
worldmapPinsPool.resetterFunc = worldmapPinsPool.resetFunc

-- register pin pool with the world map
WorldMapFrame.pinPools["HereBeDragonsPinsTemplate"] = worldmapPinsPool

Expand Down

0 comments on commit 4ac00ed

Please sign in to comment.