diff --git a/.luacheckrc b/.luacheckrc index d5bd2f1..df580da 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -119,4 +119,8 @@ globals = { "tAppendAll", "GetInstanceInfo", "C_PvP", + "C_UnitAuras", + "AuraUtil", + "C_Spell", + "Settings", } diff --git a/Frame.lua b/Frame.lua index 9ba549d..7cd6b35 100644 --- a/Frame.lua +++ b/Frame.lua @@ -230,6 +230,91 @@ local function FloatingIconHeader_Reconfigure(hdr, unit) hdr:SetSize(dbh.auraSize, dbh.auraSize) end + +local CreateFramePool = nil +do + local ObjectPool = { + -- creationFunc = function(self) + -- return self.parent:CreateMaskTexture() + -- end, + -- resetterFunc = function(self, mask) + -- mask:Hide() + -- mask:ClearAllPoints() + -- end, + AddObject = function(self, object) + local dummy = true + self.activeObjects[object] = dummy + self.activeObjectCount = self.activeObjectCount + 1 + end, + ReclaimObject = function(self, object) + tinsert(self.inactiveObjects, object) + self.activeObjects[object] = nil + self.activeObjectCount = self.activeObjectCount - 1 + end, + Release = function(self, object) + local active = self.activeObjects[object] ~= nil + if active then + self:resetterFunc(object) + self:ReclaimObject(object) + end + return active + end, + Acquire = function(self) + local object = tremove(self.inactiveObjects) + local new = object == nil + if new then + object = self:creationFunc() + self:resetterFunc(object, new) + end + self:AddObject(object) + return object, new + end, + ReleaseAll = function(self) + for obj in pairs(self.activeObjects) do + self:Release(obj); + end + end, + Init = function(self, parent) + self.activeObjects = {} + self.inactiveObjects = {} + self.activeObjectCount = 0 + self.parent = parent + end + } + + local function Pool_HideAndClearAnchors(framePool, frame) + frame:Hide(); + frame:ClearAllPoints(); + end + local TextureDefaultReset = Pool_HideAndClearAnchors + local TextureDefaultCreate = function(texturePool) + return texturePool.parent:CreateTexture(nil, texturePool.layer, texturePool.textureTemplate, texturePool.subLayer); + end + -- local FrameDefaultResetter = Pool_HideAndClearAnchors + + -- local function CreateTexturePool(parent, layer, subLayer, textureTemplate, resetterFunc) + -- local texturePool = setmetatable({}, { __index = ObjectPool }) + -- texturePool:Init(parent) + + -- texturePool.layer = layer; + -- texturePool.subLayer = subLayer; + -- texturePool.textureTemplate = textureTemplate; + -- texturePool.creationFunc = TextureDefaultCreate + -- texturePool.resetterFunc = TextureDefaultReset + + -- return texturePool; + -- end + + CreateFramePool = function(frameType, parent, frameTemplate, resetterFunc) + local framePool = setmetatable({}, { __index = ObjectPool }) + framePool:Init(parent) + framePool.frameType = frameType; + framePool.frameTemplate = frameTemplate; + framePool.resetterFunc = resetterFunc or Pool_HideAndClearAnchors + return framePool + end +end + function NugPlateAuras:CreateFloatingIconPool(parent) local hdr = CreateFrame("Frame", "$parentNPAHeaderBuffGains", parent) diff --git a/NugPlateAuras-Cata.toc b/NugPlateAuras-Cata.toc new file mode 100644 index 0000000..b02780a --- /dev/null +++ b/NugPlateAuras-Cata.toc @@ -0,0 +1,24 @@ +## Interface: 40400 + +## Title: NugPlateAuras +## SavedVariables: NugPlateAurasDB +## Author: d87 +## OptionalDeps: Masque + +## X-WoWI-ID: 25439 +## X-Curse-Project-ID: 351554 +## X-Wago-ID: RXKqnDGy + +Libs\LibStub\LibStub.lua +Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua +Libs\AceGUI-3.0\AceGUI-3.0.xml +Libs\AceConfig-3.0\AceConfig-3.0.xml +Libs\AceDB-3.0\AceDB-3.0.xml +Libs\LibAuraTypes\LibAuraTypes.lua +Libs\LibSpellLocks\LibSpellLocks.lua +Libs\LibCustomGlow\LibCustomGlow-1.0.xml + +NugPlateAuras.lua +Frame.lua +Options.lua +Migrations.lua diff --git a/NugPlateAuras-Mainline.toc b/NugPlateAuras-Mainline.toc index 490983f..88d1a1b 100644 --- a/NugPlateAuras-Mainline.toc +++ b/NugPlateAuras-Mainline.toc @@ -1,4 +1,4 @@ -## Interface: 100105 +## Interface: 110000 ## Title: NugPlateAuras ## SavedVariables: NugPlateAurasDB diff --git a/NugPlateAuras.lua b/NugPlateAuras.lua index 11188cd..6b27192 100644 --- a/NugPlateAuras.lua +++ b/NugPlateAuras.lua @@ -19,8 +19,18 @@ local Masque = LibStub("Masque", true) local MasqueGroup NugPlateAuras:RegisterEvent("ADDON_LOADED") +local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex +local UnpackAuraData = AuraUtil.UnpackAuraData +local DeprecatedUnitAura = function(unitToken, index, filter) + local auraData = GetAuraDataByIndex(unitToken, index, filter); + if not auraData then + return nil; + end + + return UnpackAuraData(auraData); +end -local UnitAura = _G.UnitAura +local UnitAura = DeprecatedUnitAura local activePlateUnits = {} local PlateGUIDtoUnit = {} @@ -257,6 +267,20 @@ function NugPlateAuras:CreateHeader(parent, headerType) end +if C_Spell.GetSpellInfo then + local C_Spell_GetSpellInfo = C_Spell.GetSpellInfo + ns.GetSpellInfo = function(spellId) + local info = C_Spell_GetSpellInfo(spellId) + if info then + return info.name, nil, info.iconID + end + end + ns.GetSpellTexture = C_Spell.GetSpellTexture +else + ns.GetSpellInfo = _G.GetSpellInfo + ns.GetSpellTexture = _G.GetSpellTexture +end +local GetSpellInfo = ns.GetSpellInfo local function MakeFakeAuraFromID(spellID, filter) local now = GetTime() local name, rank, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(spellID) @@ -607,6 +631,15 @@ local helpMessage = { } + +local function InterfaceOptionsFrame_OpenToCategory(categoryIDOrFrame) + if type(categoryIDOrFrame) == "table" then + local categoryID = categoryIDOrFrame.name; + return Settings.OpenToCategory(categoryID); + else + return Settings.OpenToCategory(categoryIDOrFrame); + end +end NugPlateAuras.Commands = { ["gui"] = function(v) if not NugPlateAuras.optionsPanel then