From e0f97ffce49c3c4cdb48f22b2b385b94d3d325f6 Mon Sep 17 00:00:00 2001 From: d87 Date: Tue, 23 Jul 2024 19:06:37 +0700 Subject: [PATCH] TWW API Update --- .luacheckrc | 2 ++ Frame.lua | 58 +++++++++++++++++++++++++++++++++++++ NugKeyFeedback-Mainline.toc | 2 +- NugKeyFeedback.lua | 19 +++++++++++- 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 42e379b..299cb25 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -118,4 +118,6 @@ globals = { "UnitChannelInfo", "CastingInfo", "ChannelInfo", + "C_Spell", + "C_AddOns", } diff --git a/Frame.lua b/Frame.lua index ef5af72..4c86601 100644 --- a/Frame.lua +++ b/Frame.lua @@ -275,6 +275,64 @@ local function PoolIconResetterFunc(pool, f) f:SetPoint(scaleOrigin, parent, revOrigin, 0,0) end + +local FramePool = { + -- 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 CreateFramePool(frameType, parent, frameTemplate, resetterFunc, frameInitFunc) + local self = setmetatable({}, { __index = FramePool }) + self:Init(parent) + self.frameType = frameType; + -- self.parent = parent; + self.frameTemplate = frameTemplate; + return self +end + function NugKeyFeedback:CreateLastSpellIconLine(parent) local template = nil local resetterFunc = PoolIconResetterFunc diff --git a/NugKeyFeedback-Mainline.toc b/NugKeyFeedback-Mainline.toc index 8a75650..4d5cdc5 100644 --- a/NugKeyFeedback-Mainline.toc +++ b/NugKeyFeedback-Mainline.toc @@ -1,4 +1,4 @@ -## Interface: 100002 +## Interface: 110000 ## Title: NugKeyFeedback ## SavedVariables: NugKeyFeedbackDB ## OptionalDeps: Masque, Bartender4, Neuron, ElvUI diff --git a/NugKeyFeedback.lua b/NugKeyFeedback.lua index 9fcdd81..28b0f4d 100644 --- a/NugKeyFeedback.lua +++ b/NugKeyFeedback.lua @@ -22,6 +22,22 @@ local defaults = { forceUseActionHook = false, } + +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 APILevel = math.floor(select(4,GetBuildInfo())/10000) local isClassic = APILevel < 5 --WOW_PROJECT_ID == WOW_PROJECT_CLASSIC local dummy = function() end @@ -32,6 +48,7 @@ if isClassic then UnitCastingInfo = CastingInfo UnitChannelInfo = ChannelInfo end +local IsAddOnLoaded = IsAddOnLoaded or C_AddOns.IsAddOnLoaded local firstTimeUse = false @@ -267,7 +284,7 @@ function NugKeyFeedback:RefreshSettings() local pool = self.iconPool pool:ReleaseAll() - for i,f in pool:EnumerateInactive() do + for i,f in ipairs(pool.inactiveObjects) do -- f:SetHeight(db.lineIconSize) -- f:SetWidth(db.lineIconSize) pool:resetterFunc(f)