diff --git a/.snippets/ClickCastingTips.lua b/.snippets/ClickCastingTips.lua index 2c2216c0..c54a37fa 100644 --- a/.snippets/ClickCastingTips.lua +++ b/.snippets/ClickCastingTips.lua @@ -89,7 +89,7 @@ local function ShowTips() local bindKeyDisplay = strlen(bindKey) == 1 and bindKey or L[bindKey] local bindActionDisplay, icon - bindAction, _, icon = GetSpellInfo(bindAction) + bindAction, icon = F:GetSpellNameAndIcon(bindAction) if bindAction then bindActionDisplay = bindAction.." |T"..icon..":0|t" else diff --git a/.snippets/GenericRaidDebuffs.lua b/.snippets/GenericRaidDebuffs.lua index eee92d83..eb5443da 100644 --- a/.snippets/GenericRaidDebuffs.lua +++ b/.snippets/GenericRaidDebuffs.lua @@ -36,7 +36,7 @@ function F:GetDebuffList(instanceName) if loadedDebuffs[iId]["general"] then n = #loadedDebuffs[iId]["general"]["enabled"] for _, t in ipairs(loadedDebuffs[iId]["general"]["enabled"]) do - local spellName = GetSpellInfo(t["id"]) + local spellName = F:GetSpellNameAndIcon(t["id"]) if spellName then -- list[spellName/spellId] = {order, glowType, glowOptions} if t["trackByID"] then @@ -51,7 +51,7 @@ function F:GetDebuffList(instanceName) for bId, bTable in pairs(loadedDebuffs[iId]) do if bId ~= "general" then for _, st in pairs(bTable["enabled"]) do - local spellName = GetSpellInfo(st["id"]) + local spellName = F:GetSpellNameAndIcon(st["id"]) if spellName then -- check again if st["trackByID"] then list[st["id"]] = {["order"]=st["order"]+n+offset, ["condition"]=st["condition"], ["glowType"]=st["glowType"], ["glowOptions"]=st["glowOptions"], ["glowCondition"]=st["glowCondition"]} diff --git a/Cell.toc b/Cell.toc index fa743b3a..7bab684a 100644 --- a/Cell.toc +++ b/Cell.toc @@ -1,4 +1,4 @@ -## Interface: 100207 +## Interface: 100207,110000 ## Title: Cell ## Version: r229-release ## Author: enderneko diff --git a/Core.lua b/Core.lua index 86492f07..3ce50517 100644 --- a/Core.lua +++ b/Core.lua @@ -25,8 +25,8 @@ Cell.MIN_DEBUFFS_VERSION = 228 Cell.MIN_QUICKASSIST_VERSION = 227 --@debug@ -local debugMode = true ---@end-debug@ +-- local debugMode = true +--@end-debug@]==] function F:Debug(arg, ...) if debugMode then if type(arg) == "string" or type(arg) == "number" then @@ -227,8 +227,8 @@ function eventFrame:ADDON_LOADED(arg1) -- spellRequest --------------------------------------------------------------------------- if type(CellDB["spellRequest"]) ~= "table" then - local POWER_INFUSION, _, POWER_INFUSION_ICON = GetSpellInfo(10060) - local INNERVATE, _, INNERVATE_ICON = GetSpellInfo(29166) + local POWER_INFUSION, POWER_INFUSION_ICON = F:GetSpellNameAndIcon(10060) + local INNERVATE, INNERVATE_ICON = F:GetSpellNameAndIcon(29166) CellDB["spellRequest"] = { ["enabled"] = false, @@ -713,6 +713,28 @@ function eventFrame:PLAYER_ENTERING_WORLD() end end +local function registerGlobalClickCastings() + ClickCastFrames = ClickCastFrames or {} + + if ClickCastFrames then + for frame, options in pairs(ClickCastFrames) do + F:RegisterFrame(frame) + end + end + + ClickCastFrames = setmetatable({}, {__newindex = function(t, k, v) + if v == nil or v == false then + F:UnregisterFrame(k) + else + F:RegisterFrame(k) + end + end}) + + F:IterateAllUnitButtons(function (b) + ClickCastFrames[b] = true + end) +end + function eventFrame:PLAYER_LOGIN() F:Debug("|cffbbbbbb=== PLAYER_LOGIN ===") eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -742,6 +764,8 @@ function eventFrame:PLAYER_LOGIN() eventFrame:GROUP_ROSTER_UPDATE() -- update visibility Cell:Fire("UpdateVisibility") + -- register unitframes for click casting + registerGlobalClickCastings() -- update click-castings Cell:Fire("UpdateClickCastings") -- update indicators diff --git a/Core_Cata.lua b/Core_Cata.lua index 8b3d2fee..32d242fe 100644 --- a/Core_Cata.lua +++ b/Core_Cata.lua @@ -206,8 +206,8 @@ function eventFrame:ADDON_LOADED(arg1) -- spellRequest --------------------------------------------------------------------------- if type(CellDB["spellRequest"]) ~= "table" then - local POWER_INFUSION, _, POWER_INFUSION_ICON = GetSpellInfo(10060) - local INNERVATE, _, INNERVATE_ICON = GetSpellInfo(29166) + local POWER_INFUSION, POWER_INFUSION_ICON = F:GetSpellNameAndIcon(10060) + local INNERVATE, INNERVATE_ICON = F:GetSpellNameAndIcon(29166) CellDB["spellRequest"] = { ["enabled"] = false, diff --git a/Core_Vanilla.lua b/Core_Vanilla.lua index d63f010f..75c3a19a 100644 --- a/Core_Vanilla.lua +++ b/Core_Vanilla.lua @@ -23,9 +23,9 @@ Cell.MIN_LAYOUTS_VERSION = 228 Cell.MIN_INDICATORS_VERSION = 228 Cell.MIN_DEBUFFS_VERSION = 228 ---@debug@ +--[==[@debug@ local debugMode = true ---@end-debug@ +--@end-debug@]==] function F:Debug(arg, ...) if debugMode then if type(arg) == "string" or type(arg) == "number" then @@ -190,8 +190,8 @@ function eventFrame:ADDON_LOADED(arg1) -- spellRequest --------------------------------------------------------------------------- if type(CellDB["spellRequest"]) ~= "table" then - local POWER_INFUSION, _, POWER_INFUSION_ICON = GetSpellInfo(10060) - local INNERVATE, _, INNERVATE_ICON = GetSpellInfo(29166) + local POWER_INFUSION, POWER_INFUSION_ICON = F:GetSpellNameAndIcon(10060) + local INNERVATE, INNERVATE_ICON = F:GetSpellNameAndIcon(29166) CellDB["spellRequest"] = { ["enabled"] = false, diff --git a/Defaults/ClickCasting_DefaultSpells.lua b/Defaults/ClickCasting_DefaultSpells.lua index 535511a5..5bcefa4a 100644 --- a/Defaults/ClickCasting_DefaultSpells.lua +++ b/Defaults/ClickCasting_DefaultSpells.lua @@ -2,8 +2,6 @@ local _, Cell = ... local L = Cell.L local F = Cell.funcs -local GetSpellInfo = GetSpellInfo - ------------------------------------------------- -- click-castings ------------------------------------------------- @@ -321,7 +319,7 @@ function F:GetClickCastingSpellList(class, spec) spellType = L[spellType] end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) spells[i] = {icon, name, spellType, spellId} end @@ -366,12 +364,12 @@ local resurrections_for_dead = { do local temp = {} for _, id in pairs(resurrections_for_dead) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end resurrections_for_dead = temp end -local spell_soulstone = GetSpellInfo(20707) +local spell_soulstone = F:GetSpellNameAndIcon(20707) function F:IsSoulstone(spell) return spell == spell_soulstone end @@ -412,7 +410,7 @@ local resurrection_click_castings = { -- do -- for class, t in pairs(resurrection_click_castings) do -- for _, clickCasting in pairs(t) do --- clickCasting[3] = GetSpellInfo(clickCasting[3]) +-- clickCasting[3] = F:GetSpellNameAndIcon(clickCasting[3]) -- end -- end -- end @@ -454,7 +452,7 @@ local normalResurrection = { do for class, t in pairs(normalResurrection) do for condition, spell in pairs(t) do - t[condition] = GetSpellInfo(spell) + t[condition] = F:GetSpellNameAndIcon(spell) end end end @@ -472,7 +470,7 @@ local combatResurrection = { do for class, spell in pairs(combatResurrection) do - combatResurrection[class] = GetSpellInfo(spell) + combatResurrection[class] = F:GetSpellNameAndIcon(spell) end end diff --git a/Defaults/ClickCasting_DefaultSpells_Cata.lua b/Defaults/ClickCasting_DefaultSpells_Cata.lua index 9bf1c33d..a58c3658 100644 --- a/Defaults/ClickCasting_DefaultSpells_Cata.lua +++ b/Defaults/ClickCasting_DefaultSpells_Cata.lua @@ -2,8 +2,6 @@ local _, Cell = ... local L = Cell.L local F = Cell.funcs -local GetSpellInfo = GetSpellInfo - ------------------------------------------------- -- click-castings ------------------------------------------------- @@ -175,7 +173,7 @@ function F:GetClickCastingSpellList(class) spellType = L[spellType] end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) spells[i] = {icon, name, spellType, spellId} end @@ -207,7 +205,7 @@ local resurrections_for_dead = { do local temp = {} for _, id in pairs(resurrections_for_dead) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end resurrections_for_dead = temp end @@ -242,7 +240,7 @@ local resurrection_click_castings = { -- do -- for class, t in pairs(resurrection_click_castings) do -- for _, clickCasting in pairs(t) do --- clickCasting[3] = GetSpellInfo(clickCasting[3]) +-- clickCasting[3] = F:GetSpellNameAndIcon(clickCasting[3]) -- end -- end -- end @@ -263,7 +261,7 @@ local normalResurrection = { do for class, spell in pairs(normalResurrection) do - normalResurrection[class] = GetSpellInfo(spell) + normalResurrection[class] = F:GetSpellNameAndIcon(spell) end end @@ -278,7 +276,7 @@ local combatResurrection = { do for class, spell in pairs(combatResurrection) do - combatResurrection[class] = GetSpellInfo(spell) + combatResurrection[class] = F:GetSpellNameAndIcon(spell) end end diff --git a/Defaults/ClickCasting_DefaultSpells_Vanilla.lua b/Defaults/ClickCasting_DefaultSpells_Vanilla.lua index 1ceb0499..5973eb3e 100644 --- a/Defaults/ClickCasting_DefaultSpells_Vanilla.lua +++ b/Defaults/ClickCasting_DefaultSpells_Vanilla.lua @@ -2,8 +2,6 @@ local _, Cell = ... local L = Cell.L local F = Cell.funcs -local GetSpellInfo = GetSpellInfo - ------------------------------------------------- -- click-castings ------------------------------------------------- @@ -160,7 +158,7 @@ function F:GetClickCastingSpellList(class) spellType = L[spellType] end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) spells[i] = {icon, name, spellType, spellId} end @@ -188,7 +186,7 @@ local resurrections_for_dead = { do local temp = {} for _, id in pairs(resurrections_for_dead) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end resurrections_for_dead = temp end @@ -231,7 +229,7 @@ local normalResurrection = { do for class, spell in pairs(normalResurrection) do - normalResurrection[class] = GetSpellInfo(spell) + normalResurrection[class] = F:GetSpellNameAndIcon(spell) end end @@ -245,7 +243,7 @@ local combatResurrection = { do for class, spell in pairs(combatResurrection) do - combatResurrection[class] = GetSpellInfo(spell) + combatResurrection[class] = F:GetSpellNameAndIcon(spell) end end diff --git a/Defaults/Indicator_DefaultSpells.lua b/Defaults/Indicator_DefaultSpells.lua index 02e154e2..6535a07e 100644 --- a/Defaults/Indicator_DefaultSpells.lua +++ b/Defaults/Indicator_DefaultSpells.lua @@ -37,7 +37,7 @@ local debuffBlacklist = { function I.GetDefaultDebuffBlacklist() -- local temp = {} -- for i, id in pairs(debuffBlacklist) do - -- temp[i] = GetSpellInfo(id) + -- temp[i] = F:GetSpellNameAndIcon(id) -- end -- return temp return debuffBlacklist @@ -150,7 +150,7 @@ local aoeHealingIDs = { do local temp = {} for _, id in pairs(aoeHealings) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end aoeHealings = temp end @@ -175,7 +175,7 @@ local summonDuration = { do local temp = {} for id, duration in pairs(summonDuration) do - temp[GetSpellInfo(id)] = duration + temp[F:GetSpellNameAndIcon(id)] = duration end summonDuration = temp end @@ -269,7 +269,7 @@ local customExternals = {} local function UpdateExternals(id, trackByName) if trackByName then - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then builtInExternals[name] = true end @@ -299,7 +299,7 @@ function I.UpdateExternals(t) -- user created wipe(customExternals) for _, id in pairs(t["custom"]) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then customExternals[name] = true end @@ -307,7 +307,7 @@ function I.UpdateExternals(t) end local UnitIsUnit = UnitIsUnit -local bos = GetSpellInfo(6940) -- 牺牲祝福 +local bos = F:GetSpellNameAndIcon(6940) -- 牺牲祝福 function I.IsExternalCooldown(name, id, source, target) if name == bos then if source and target then @@ -433,7 +433,7 @@ function I.UpdateDefensives(t) for id, trackByName in pairs(spells) do if not t["disabled"][id] then -- not disabled if trackByName then - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then builtInDefensives[name] = true end @@ -447,7 +447,7 @@ function I.UpdateDefensives(t) -- user created wipe(customDefensives) for _, id in pairs(t["custom"]) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then customDefensives[name] = true end @@ -484,29 +484,29 @@ local tankActiveMitigations = { local tankActiveMitigationNames = { -- death knight - -- F:GetClassColorStr("DEATHKNIGHT")..GetSpellInfo(77535).."|r", -- 鲜血护盾 - F:GetClassColorStr("DEATHKNIGHT")..GetSpellInfo(195181).."|r", -- 白骨之盾 + -- F:GetClassColorStr("DEATHKNIGHT")..F:GetSpellNameAndIcon(77535).."|r", -- 鲜血护盾 + F:GetClassColorStr("DEATHKNIGHT")..F:GetSpellNameAndIcon(195181).."|r", -- 白骨之盾 -- demon hunter - F:GetClassColorStr("DEMONHUNTER")..GetSpellInfo(203720).."|r", -- 恶魔尖刺 + F:GetClassColorStr("DEMONHUNTER")..F:GetSpellNameAndIcon(203720).."|r", -- 恶魔尖刺 -- druid - F:GetClassColorStr("DRUID")..GetSpellInfo(192081).."|r", -- 铁鬃 + F:GetClassColorStr("DRUID")..F:GetSpellNameAndIcon(192081).."|r", -- 铁鬃 -- monk - F:GetClassColorStr("MONK")..GetSpellInfo(215479).."|r", -- 铁骨酒 + F:GetClassColorStr("MONK")..F:GetSpellNameAndIcon(215479).."|r", -- 铁骨酒 -- paladin - F:GetClassColorStr("PALADIN")..GetSpellInfo(132403).."|r", -- 正义盾击 + F:GetClassColorStr("PALADIN")..F:GetSpellNameAndIcon(132403).."|r", -- 正义盾击 -- warrior - F:GetClassColorStr("WARRIOR")..GetSpellInfo(2565).."|r", -- 盾牌格挡 + F:GetClassColorStr("WARRIOR")..F:GetSpellNameAndIcon(2565).."|r", -- 盾牌格挡 } do local temp = {} for _, id in pairs(tankActiveMitigations) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end tankActiveMitigations = temp end @@ -691,7 +691,7 @@ local drinks = { do local temp = {} for _, id in pairs(drinks) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end drinks = temp end @@ -774,7 +774,7 @@ local spells = { function F:FirstRun() local icons = "\n\n" for i, id in pairs(spells) do - local icon = select(3, GetSpellInfo(id)) + local icon = select(2, F:GetSpellNameAndIcon(id)) icons = icons .. "|T"..icon..":0|t" if i % 11 == 0 then icons = icons .. "\n" @@ -834,7 +834,7 @@ end -- wipe(cleuAuras) -- -- insert -- for _, c in pairs(t) do --- local icon = select(3, GetSpellInfo(c[1])) +-- local icon = select(2, F:GetSpellNameAndIcon(c[1])) -- cleuAuras[c[1]] = {c[2], icon} -- end -- end @@ -981,7 +981,7 @@ do local temp = {} for _, k in pairs(buffsOrder) do local id = missingBuffs[k] - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) if name then tinsert(temp, { ["id"] = id, @@ -1165,7 +1165,7 @@ function I.UpdateCrowdControls(t) for id, trackByName in pairs(spells) do if not t["disabled"][id] then -- not disabled if trackByName then - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then builtInCrowdControls[name] = true end @@ -1179,7 +1179,7 @@ function I.UpdateCrowdControls(t) -- user created wipe(customCrowdControls) for _, id in pairs(t["custom"]) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then customCrowdControls[name] = true end diff --git a/Defaults/Indicator_DefaultSpells_Cata.lua b/Defaults/Indicator_DefaultSpells_Cata.lua index bbc5e2cb..7dabfef9 100644 --- a/Defaults/Indicator_DefaultSpells_Cata.lua +++ b/Defaults/Indicator_DefaultSpells_Cata.lua @@ -26,7 +26,7 @@ local debuffBlacklist = { function I.GetDefaultDebuffBlacklist() -- local temp = {} -- for i, id in pairs(debuffBlacklist) do - -- temp[i] = GetSpellInfo(id) + -- temp[i] = F:GetSpellNameAndIcon(id) -- end -- return temp return debuffBlacklist @@ -72,7 +72,7 @@ local aoeHealings = { do local temp = {} for _, id in pairs(aoeHealings) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end aoeHealings = temp end @@ -89,7 +89,7 @@ local summonDuration = { do local temp = {} for id, duration in pairs(summonDuration) do - temp[GetSpellInfo(id)] = duration + temp[F:GetSpellNameAndIcon(id)] = duration end summonDuration = temp end @@ -143,7 +143,7 @@ function I.UpdateExternals(t) for id, trackByName in pairs(spells) do if not t["disabled"][id] then -- not disabled if trackByName then - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then builtInExternals[name] = true end @@ -157,7 +157,7 @@ function I.UpdateExternals(t) -- user created wipe(customExternals) for _, id in pairs(t["custom"]) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then customExternals[name] = true end @@ -238,7 +238,7 @@ function I.UpdateDefensives(t) for id, trackByName in pairs(spells) do if not t["disabled"][id] then -- not disabled if trackByName then - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then builtInDefensives[name] = true end @@ -252,7 +252,7 @@ function I.UpdateDefensives(t) -- user created wipe(customDefensives) for _, id in pairs(t["custom"]) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then customDefensives[name] = true end @@ -338,7 +338,7 @@ local drinks = { do local temp = {} for _, id in pairs(drinks) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end drinks = temp end @@ -373,7 +373,7 @@ local spells = { function F:FirstRun() local icons = "\n\n" for i, id in pairs(spells) do - local icon = select(3, GetSpellInfo(id)) + local icon = select(2, F:GetSpellNameAndIcon(id)) icons = icons .. "|T"..icon..":0|t" if i % 11 == 0 then icons = icons .. "\n" @@ -480,7 +480,7 @@ do local temp = {} for _, k in pairs(buffsOrder) do local id = missingBuffs[k] - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) if name then tinsert(temp, { ["id"] = id, diff --git a/Defaults/Indicator_DefaultSpells_Vanilla.lua b/Defaults/Indicator_DefaultSpells_Vanilla.lua index a4c70396..edad87c4 100644 --- a/Defaults/Indicator_DefaultSpells_Vanilla.lua +++ b/Defaults/Indicator_DefaultSpells_Vanilla.lua @@ -52,7 +52,7 @@ local aoeHealings = { do local temp = {} for _, id in pairs(aoeHealings) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end aoeHealings = temp end @@ -69,7 +69,7 @@ local summonDuration = { do local temp = {} for id, duration in pairs(summonDuration) do - temp[GetSpellInfo(id)] = duration + temp[F:GetSpellNameAndIcon(id)] = duration end summonDuration = temp end @@ -102,7 +102,7 @@ function I.UpdateExternals(t) for id, trackByName in pairs(spells) do if not t["disabled"][id] then -- not disabled if trackByName then - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then builtInExternals[name] = true end @@ -116,7 +116,7 @@ function I.UpdateExternals(t) -- user created wipe(customExternals) for _, id in pairs(t["custom"]) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then customExternals[name] = true end @@ -175,7 +175,7 @@ function I.UpdateDefensives(t) for id, trackByName in pairs(spells) do if not t["disabled"][id] then -- not disabled if trackByName then - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then builtInDefensives[name] = true end @@ -189,7 +189,7 @@ function I.UpdateDefensives(t) -- user created wipe(customDefensives) for _, id in pairs(t["custom"]) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then customDefensives[name] = true end @@ -242,7 +242,7 @@ local drinks = { do local temp = {} for _, id in pairs(drinks) do - temp[GetSpellInfo(id)] = true + temp[F:GetSpellNameAndIcon(id)] = true end drinks = temp end @@ -268,7 +268,7 @@ local spells = { function F:FirstRun() local icons = "\n\n" for i, id in pairs(spells) do - local icon = select(3, GetSpellInfo(id)) + local icon = select(2, F:GetSpellNameAndIcon(id)) icons = icons .. "|T"..icon..":0|t" if i % 11 == 0 then icons = icons .. "\n" @@ -377,7 +377,7 @@ do local temp = {} for _, k in pairs(buffsOrder) do local id = missingBuffs[k] - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) if name then tinsert(temp, { ["id"] = id, diff --git a/Indicators/Built-in.lua b/Indicators/Built-in.lua index 9f67a96b..a61cb83f 100644 --- a/Indicators/Built-in.lua +++ b/Indicators/Built-in.lua @@ -441,7 +441,7 @@ local function Debuffs_EnableBlacklistShortcut(debuffs, enabled) if button == "RightButton" and isInside and IsLeftAltKeyDown() and IsLeftControlKeyDown() and self.spellId and not F:TContains(CellDB["debuffBlacklist"], self.spellId) then -- print msg - local name, _, icon = GetSpellInfo(self.spellId) + local name, icon = F:GetSpellNameAndIcon(self.spellId) if name and icon then F:Print(L["Added |T%d:0|t|cFFFF3030%s(%d)|r into debuff blacklist."]:format(icon, name, self.spellId)) end @@ -1671,6 +1671,36 @@ local function GetTexCoordsForRoleSmall(role) end end +-- see https://www.townlong-yak.com/framexml/live/Blizzard_Deprecated/Deprecated_10_1_5.lua#43 +local function getSmallTextCoordsForRole(role) + if ( role == "TANK" ) then + return 0, 19/64, 22/64, 41/64; + elseif ( role == "HEALER" ) then + return 20/64, 39/64, 1/64, 20/64; + elseif ( role == "DAMAGER" ) then + return 20/64, 39/64, 22/64, 41/64; + else + error("Unknown role: "..tostring(role)); + end +end + +-- see https://www.townlong-yak.com/framexml/live/Blizzard_Deprecated/Deprecated_10_1_5.lua#11 +local function getTextCoordsForRole(role) + local textureHeight, textureWidth = 256, 256; + local roleHeight, roleWidth = 67, 67; + if ( role == "GUIDE" ) then + return GetTexCoordsByGrid(1, 1, textureWidth, textureHeight, roleWidth, roleHeight); + elseif ( role == "TANK" ) then + return GetTexCoordsByGrid(1, 2, textureWidth, textureHeight, roleWidth, roleHeight); + elseif ( role == "HEALER" ) then + return GetTexCoordsByGrid(2, 1, textureWidth, textureHeight, roleWidth, roleHeight); + elseif ( role == "DAMAGER" ) then + return GetTexCoordsByGrid(2, 2, textureWidth, textureHeight, roleWidth, roleHeight); + else + error("Unknown role: "..tostring(role)); + end +end; + local function RoleIcon_SetRole(self, role) self.tex:SetTexCoord(0, 1, 0, 1) self.tex:SetVertexColor(1, 1, 1) diff --git a/Indicators/Consumables.lua b/Indicators/Consumables.lua index 29c8c9c4..b5a45d2d 100644 --- a/Indicators/Consumables.lua +++ b/Indicators/Consumables.lua @@ -28,7 +28,7 @@ eventFrame:SetScript("OnEvent", function(self, event, unit, castGUID, spellID) if not (UnitInRaid(unit) or UnitInParty(unit) or unit == "player" or unit == "pet") then return end if Cell.vars.consumablesDebugModeEnabled then - local name = GetSpellInfo(spellID) + local name = F:GetSpellNameAndIcon(spellID) print("|cFFFF3030[Cell]|r |cFFB2B2B2"..event..":|r", unit, "|cFF00FF00"..(spellID or "nil").."|r", name) end diff --git a/Indicators/StatusIcon.lua b/Indicators/StatusIcon.lua index 43833933..339bfd9a 100644 --- a/Indicators/StatusIcon.lua +++ b/Indicators/StatusIcon.lua @@ -19,7 +19,7 @@ local function DiedWithSoulstone(b) end local rez = {} -local SOULSTONE = GetSpellInfo(20707) +local SOULSTONE = F:GetSpellNameAndIcon(20707) local soulstones = {} local cleuFrame = CreateFrame("Frame") diff --git a/Modules/ClickCastings.lua b/Modules/ClickCastings.lua index 76f6ea20..7cd5bcd8 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -3,8 +3,6 @@ local L = Cell.L local F = Cell.funcs local P = Cell.pixelPerfectFuncs -local GetSpellInfo = GetSpellInfo - local clickCastingsTab = Cell:CreateFrame("CellOptionsFrame_ClickCastingsTab", Cell.frames.optionsFrame, nil, nil, true) Cell.frames.clickCastingsTab = clickCastingsTab clickCastingsTab:SetAllPoints(Cell.frames.optionsFrame) @@ -56,7 +54,6 @@ local mouseKeyIDs = { -- ["ScrollUp"] = 6, -- ["ScrollDown"]= 14, } - local function GetBindingDisplay(modifier, key) modifier = modifier:gsub("%-", "|cff777777+|r") modifier = modifier:gsub("alt", "Alt") @@ -92,10 +89,16 @@ local function EncodeDB(modifier, bindKey, bindType, bindAction) if bindType == "spell" then attrType = "spell" attrAction = bindAction - elseif bindType == "macro" then attrType = "macro" attrAction = bindAction + elseif bindType == "click" then + attrType = "click" + attrAction = bindAction + + elseif bindType == "item" then + attrType = "item" + attrAction = bindAction else -- general attrType = bindAction @@ -402,8 +405,14 @@ local function ClearClickCastings(b) b:SetAttribute(bindKey, nil) local attr = string.gsub(bindKey, "type", "spell") b:SetAttribute(attr, nil) + attr = string.gsub(bindKey, "type", "macro") + b:SetAttribute(attr, nil) attr = string.gsub(bindKey, "type", "macrotext") b:SetAttribute(attr, nil) + attr = string.gsub(bindKey, "type", "click") + b:SetAttribute(attr, nil) + attr = string.gsub(bindKey, "type", "item") + b:SetAttribute(attr, nil) -- if t[2] == "spell" then -- local attr = string.gsub(bindKey, "type", "spell") -- b:SetAttribute(attr, nil) @@ -446,8 +455,12 @@ local function ApplyClickCastings(b) b:SetAttribute(bindKey, t[2]) end - if t[2] == "spell" then - local spellName = GetSpellInfo(t[3]) or "" + if Cell.isTWW and t[2] == "spell" then + local spellName = F:GetSpellNameAndIcon(t[3]) or "" + local attr = string.gsub(bindKey, "type", t[2]) + b:SetAttribute(attr, spellName) + elseif t[2] == "spell" then + local spellName = F:GetSpellNameAndIcon(t[3]) or "" -- NOTE: spell 在无效/过远的目标上会处于“等待选中目标”的状态,即鼠标指针有一圈灰色材质。用 macrotext 可以解决这个问题 -- NOTE: 但对于尸体状态(未释放)的目标,需要额外判断 @@ -495,16 +508,23 @@ local function ApplyClickCastings(b) else b:SetAttribute(attr, "/cast ["..unit..condition.."] "..spellName..sMaRt) end - if not Cell.isRetail then UpdatePlaceholder(b, attr) end end elseif t[2] == "macro" then - local attr = string.gsub(bindKey, "type", "macrotext") + local attr = "" + if Cell.isTWW then + attr = string.gsub(bindKey, "type", "macro") + else + attr = string.gsub(bindKey, "type", "macrotext") + end + b:SetAttribute(attr, t[3]) + else + local attr = string.gsub(bindKey, "type", t[2]) b:SetAttribute(attr, t[3]) end end end -local function UpdateClickCastings(noReload) +local function UpdateClickCastings(noReload, onlyqueued) F:Debug("|cff77ff77UpdateClickCastings:|r useCommon:", Cell.vars.clickCastings["useCommon"]) clickCastingTable = Cell.vars.clickCastings["useCommon"] and Cell.vars.clickCastings["common"] or Cell.vars.clickCastings[Cell.vars.playerSpecID] @@ -527,22 +547,32 @@ local function UpdateClickCastings(noReload) local snippet = GetBindingSnippet() F:Debug(snippet) - - F:IterateAllUnitButtons(function(b) + local clickFrames = Cell.clickCastFrames + if onlyqueued then + clickFrames = Cell.clickCastFrameQueue + end + for b, val in pairs(clickFrames) do + Cell.clickCastFrameQueue[b] = nil -- clear if attribute already set ClearClickCastings(b) - - -- update bindingClicks - b:SetAttribute("snippet", snippet) - SetBindingClicks(b) - - -- load db and set attribute - ApplyClickCastings(b) - end, false, true) + if val then + -- update bindingClicks + b:SetAttribute("snippet", snippet) + SetBindingClicks(b) + + -- load db and set attribute + ApplyClickCastings(b) + end + end previousClickCastings = F:Copy(clickCastingTable) end Cell:RegisterCallback("UpdateClickCastings", "UpdateClickCastings", UpdateClickCastings) +local function UpdateQueuedClickCastings() + UpdateClickCastings(true, true) +end +Cell:RegisterCallback("UpdateQueuedClickCastings", "UpdateQueuedClickCastings", UpdateQueuedClickCastings) + ------------------------------------------------- -- profiles dropdown ------------------------------------------------- @@ -589,7 +619,8 @@ local function CreateTargetingPane() targetingDropdown = Cell:CreateDropdown(targetingPane, 195) targetingDropdown:SetPoint("TOPLEFT", targetingPane, "TOPLEFT", 5, -27) - targetingDropdown:SetItems({ + + local items = { { ["text"] = L["Disabled"], ["value"] = "disabled", @@ -599,8 +630,11 @@ local function CreateTargetingPane() alwaysTargeting = "disabled" Cell:Fire("UpdateClickCastings", true) end, - }, - { + } + } + + if not Cell.isTWW then + tinsert(items, { ["text"] = L["Left Spell"], ["value"] = "left", ["onClick"] = function() @@ -609,8 +643,8 @@ local function CreateTargetingPane() alwaysTargeting = "left" Cell:Fire("UpdateClickCastings", true) end, - }, - { + }) + tinsert(items, { ["text"] = L["Any Spells"], ["value"] = "any", ["onClick"] = function() @@ -619,8 +653,9 @@ local function CreateTargetingPane() alwaysTargeting = "any" Cell:Fire("UpdateClickCastings", true) end, - }, - }) + }) + end + targetingDropdown:SetItems(items) Cell:SetTooltips(targetingDropdown, "ANCHOR_TOPLEFT", 0, 2, L["Always Targeting"], L["Only available for Spells"]) end @@ -636,32 +671,40 @@ local function CreateSmartResPane() smartResDropdown = Cell:CreateDropdown(smartResPane, 195) smartResDropdown:SetPoint("TOPLEFT", smartResPane, "TOPLEFT", 5, -27) - smartResDropdown:SetItems({ + local items = { { ["text"] = L["Disabled"], ["value"] = "disabled", ["onClick"] = function() Cell.vars.clickCastings["smartResurrection"] = "disabled" Cell:Fire("UpdateClickCastings", true) - end - }, - { - ["text"] = L["Normal"], - ["value"] = "normal", - ["onClick"] = function() - Cell.vars.clickCastings["smartResurrection"] = "normal" - Cell:Fire("UpdateClickCastings", true) - end - }, - { - ["text"] = L["Normal + Combat Res"], - ["value"] = "normal+combat", - ["onClick"] = function() - Cell.vars.clickCastings["smartResurrection"] = "normal+combat" - Cell:Fire("UpdateClickCastings", true) - end - }, - }) + end, + } + } + if not Cell.isTWW then + tinsert(items, + { + ["text"] = L["Normal"], + ["value"] = "normal", + ["onClick"] = function() + Cell.vars.clickCastings["smartResurrection"] = "normal" + Cell:Fire("UpdateClickCastings", true) + end, + } + ) + + tinsert(items, { + ["text"] = L["Normal + Combat Res"], + ["value"] = "normal+combat", + ["onClick"] = function() + Cell.vars.clickCastings["smartResurrection"] = "normal+combat" + Cell:Fire("UpdateClickCastings", true) + end, + } + ) + + end + smartResDropdown:SetItems(items) Cell:SetTooltips(smartResDropdown, "ANCHOR_TOPLEFT", 0, 2, L["Smart Resurrection"], L["Replace click-castings of Spell type with resurrection spells on dead units"]) end @@ -744,8 +787,7 @@ local function ShowTypesMenu(index, b) CheckChanges() b:HideSpellIcon() end, - }, - { + }, { ["text"] = L["Macro"], ["onClick"] = function() b.typeGrid:SetText(L["Macro"]) @@ -757,17 +799,17 @@ local function ShowTypesMenu(index, b) changed[index]["bindType"] = "macro" changed[index]["bindAction"] = "" b.actionGrid:SetText("") + b:HideSpellIcon() else changed[index]["bindType"] = nil changed[index]["bindAction"] = nil b.actionGrid:SetText(b.bindAction) + b:ShowMacroIcon(b.bindAction) end CheckChanged(index, b) CheckChanges() - b:HideSpellIcon() end, - }, - { + }, { ["text"] = L["Spell"], ["onClick"] = function() b.typeGrid:SetText(L["Spell"]) @@ -789,7 +831,51 @@ local function ShowTypesMenu(index, b) CheckChanged(index, b) CheckChanges() end, - }, + }, { + ["text"] = L["Item"], + ["onClick"] = function() + b.typeGrid:SetText(L["Item"]) + if clickCastingsTab.popupEditBox then clickCastingsTab.popupEditBox:Hide() end + + changed[index] = changed[index] or {b} + -- check type + if b.bindType ~= "item" then + changed[index]["bindType"] = "item" + changed[index]["bindAction"] = "" + b.actionGrid:SetText("") + b:HideSpellIcon() + else + changed[index]["bindType"] = nil + changed[index]["bindAction"] = nil + b.actionGrid:SetText(b.bindActionDisplay) + b:ShowItemIcon(b.bindAction) + end + CheckChanged(index, b) + CheckChanges() + end, + }, { + ["text"] = L["Click"], + ["onClick"] = function() + b.typeGrid:SetText(L["Click"]) + if clickCastingsTab.popupEditBox then clickCastingsTab.popupEditBox:Hide() end + + changed[index] = changed[index] or {b} + -- check type + if b.bindType ~= "click" then + changed[index]["bindType"] = "click" + changed[index]["bindAction"] = "" + b.actionGrid:SetText("") + b:HideSpellIcon() + else + changed[index]["bindType"] = nil + changed[index]["bindAction"] = nil + b.actionGrid:SetText(b.bindActionDisplay) + b:ShowSpellIcon(b.bindAction) + end + CheckChanged(index, b) + CheckChanges() + end, + } } menu:SetItems(items) @@ -899,8 +985,9 @@ local function ShowActionsMenu(index, b) } elseif bindType == "macro" then - items = { - { + items = {} + if not Cell.isTWW then + tinsert(items, { ["text"] = L["Edit"], ["onClick"] = function() local peb = Cell:CreatePopupEditBox(clickCastingsTab, function(text) @@ -937,8 +1024,8 @@ local function ShowActionsMenu(index, b) end peb:SetNumeric(false) end, - }, - { + }) + tinsert(items, { ["text"] = L["Extra Action Button"], ["onClick"] = function() changed[index] = changed[index] or {b} @@ -953,8 +1040,8 @@ local function ShowActionsMenu(index, b) CheckChanged(index, b) CheckChanges() end, - }, - { + }) + tinsert(items, { ["text"] = _G.INVTYPE_TRINKET.." 1", ["onClick"] = function() changed[index] = changed[index] or {b} @@ -969,8 +1056,8 @@ local function ShowActionsMenu(index, b) CheckChanged(index, b) CheckChanges() end, - }, - { + }) + tinsert(items, { ["text"] = _G.INVTYPE_TRINKET.." 2", ["onClick"] = function() changed[index] = changed[index] or {b} @@ -985,8 +1072,8 @@ local function ShowActionsMenu(index, b) CheckChanged(index, b) CheckChanges() end, - }, - { + }) + tinsert(items, { ["text"] = _G.INVTYPE_WRIST, ["onClick"] = function() changed[index] = changed[index] or {b} @@ -1001,8 +1088,8 @@ local function ShowActionsMenu(index, b) CheckChanged(index, b) CheckChanges() end, - }, - { + }) + tinsert(items, { ["text"] = _G.INVTYPE_HAND, ["onClick"] = function() changed[index] = changed[index] or {b} @@ -1017,12 +1104,12 @@ local function ShowActionsMenu(index, b) CheckChanged(index, b) CheckChanges() end, - }, - } + }) + end if (Cell.isVanilla or Cell.isCata) and Cell.vars.playerClass == "WARLOCK" then tinsert(items, { - ["text"] = GetSpellInfo(20707), + ["text"] = F:GetSpellNameAndIcon(20707), ["onClick"] = function() changed[index] = changed[index] or {b} local macrotext = "/stopcasting\n/target mouseover\n/use item:36895\n/targetlasttarget" @@ -1038,6 +1125,73 @@ local function ShowActionsMenu(index, b) end, }) end + if Cell.isTWW then + for idx=1,138 do + local name, iconTexture, _ = GetMacroInfo(idx) + if name then + tinsert(items, { + ["text"] = name, + ["icon"] = iconTexture, + ["onClick"] = function() + changed[index] = changed[index] or {b} + if b.bindAction ~= name then + changed[index]["bindAction"] = name + else + changed[index]["bindAction"] = nil + end + b.actionGrid:SetText(name) + b:ShowMacroIcon(name) + CheckChanged(index, b) + CheckChanges() + end, + }) + end + end + end + + elseif bindType == "item" then + items = {} + for slot=1,17 do + local itemId = GetInventoryItemID("player", slot) + if itemId and C_Item.IsUsableItem(itemId) then + local text = GetInventoryItemLink("player", slot) + tinsert(items, + { + ["text"] = text, + ["icon"] = GetInventoryItemTexture("player", slot), + ["onClick"] = function() + changed[index] = changed[index] or {b} + if b.bindAction ~= slot then + changed[index]["bindAction"] = slot + else + changed[index]["bindAction"] = nil + end + b.actionGrid:SetText(text) + b:ShowItemIcon(b.bindAction) + CheckChanged(index, b) + CheckChanges() + end, + }) + end + end + + + elseif bindType == "click" then + items = {{ + ["text"] = "ExtraActionButton1", + ["onClick"] = function() + changed[index] = changed[index] or {b} + if b.bindAction ~= "ExtraActionButton1" then + changed[index]["bindAction"] = "ExtraActionButton1" + b.actionGrid:SetText("ExtraActionButton1") + else + changed[index]["bindAction"] = nil + b.actionGrid:SetText(b.bindAction) + end + CheckChanged(index, b) + CheckChanges() + end, + }} else -- spell items = { @@ -1053,7 +1207,7 @@ local function ShowActionsMenu(index, b) b.actionGrid:SetText("") b:HideSpellIcon() else - b.actionGrid:SetText(GetSpellInfo(text) or "|cFFFF3030"..L["Invalid"]) + b.actionGrid:SetText(F:GetSpellNameAndIcon(text) or "|cFFFF3030"..L["Invalid"]) b:ShowSpellIcon(text) end else @@ -1083,7 +1237,7 @@ local function ShowActionsMenu(index, b) return end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -1267,6 +1421,10 @@ local function CreateListPane() -- restore icon if t[1].bindType == "spell" then t[1]:ShowSpellIcon(t[1].bindAction) + elseif t[1].bindType == "item" then + t[1]:ShowItemIcon(t[1].bindAction) + elseif t[1].bindType == "macro" and Cell.isTWW then + t[1]:ShowMacroIcon(t[1].bindAction) else t[1]:HideSpellIcon() end @@ -1304,13 +1462,19 @@ CreateBindingListButton = function(modifier, bindKey, bindType, bindAction, i) b.bindActionDisplay = "|cFFFF3030"..L["Invalid"] b:ShowSpellIcon() else - b.bindActionDisplay = GetSpellInfo(bindAction) or "|cFFFF3030"..L["Invalid"] + b.bindActionDisplay = F:GetSpellNameAndIcon(bindAction) or "|cFFFF3030"..L["Invalid"] b:ShowSpellIcon(bindAction) end else b.bindActionDisplay = "" b:HideSpellIcon() end + elseif bindType == "item" then + b.bindActionDisplay = GetInventoryItemLink("player", bindAction) + b:ShowItemIcon(bindAction) + elseif bindType == "macro" and Cell.isTWW then + b.bindActionDisplay = GetMacroInfo(bindAction) + b:ShowMacroIcon(bindAction) else b.bindActionDisplay = bindAction b:HideSpellIcon() diff --git a/Modules/Layouts.lua b/Modules/Layouts.lua index eb15a760..df527260 100644 --- a/Modules/Layouts.lua +++ b/Modules/Layouts.lua @@ -2077,7 +2077,7 @@ local function CreateRoleOrderWidget(parent) self:SetFrameStrata("LOW") -- self:Hide() --! Hide() will cause OnDragStop trigger TWICE!!! C_Timer.After(0.05, function() - local b = GetMouseFocus() + local b = F:GetMouseFoci() if b and b._role then local roleToIndex = F:ConvertTable(selectedLayoutTable["main"]["roleOrder"]) -- print(self._role, "->", b._role) diff --git a/Modules/RaidDebuffs.lua b/Modules/RaidDebuffs.lua index 02144684..f67e7de7 100644 --- a/Modules/RaidDebuffs.lua +++ b/Modules/RaidDebuffs.lua @@ -39,10 +39,10 @@ local encounterJournalList = { -- }, -- }, } ---@debug@ +--[==[@debug@ Cell_DevExpansionData = encounterJournalList Cell_DevExpansionNames = {} ---@end-debug@ +--@end-debug@]==] -- used to GetInstanceInfo/GetRealZoneText --> instanceId local instanceNameMapping = { @@ -100,9 +100,9 @@ local function LoadList() for tier = 1, num do local name = EJ_GetTierInfo(tier) encounterJournalList[name] = {} - --@debug@ + --[==[@debug@ tinsert(Cell_DevExpansionNames, 1, name) - --@end-debug@ + --@end-debug@]==] if tier ~= (num - 1) then -- don't load raid for "Current Season" LoadInstanceList(tier, "raid", encounterJournalList[name]) @@ -755,7 +755,7 @@ local function CreateDebuffsFrame() create:SetScript("OnClick", function() local popup = Cell:CreateConfirmPopup(debuffsTab, 200, L["Create new debuff (id)"], function(self) local id = tonumber(self.editBox:GetText()) or 0 - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if not name then F:Print(L["Invalid spell id."]) return @@ -816,7 +816,7 @@ local function CreateDebuffsFrame() return end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -920,7 +920,7 @@ local function RegisterForDrag(b) b:SetScript("OnDragStop", function(self) self:SetAlpha(1) dragged:Hide() - local newB = GetMouseFocus() + local newB = F:GetMouseFoci() -- move on a debuff button & not on currently moving button & not disabled if newB:GetParent() == debuffListFrame.scrollFrame.content and newB ~= self and newB.enabled then local temp, from, to = self, self.index, newB.index @@ -1063,7 +1063,7 @@ local function CreateDebuffButton(i, sTable) debuffButtons[i]:Show() - local name, _, icon = GetSpellInfo(sTable["id"]) + local name, icon = F:GetSpellNameAndIcon(sTable["id"]) if name then debuffButtons[i].icon:SetTexture(icon) debuffButtons[i].spellIcon = icon @@ -2076,8 +2076,7 @@ ShowDetails = function(spell) if selectedSpellId == spellId then return end selectedSpellId, selectedButtonIndex = spellId, buttonIndex - -- local name, icon, desc = F:GetSpellInfo(spellId) - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then return end detailsFrame.scrollFrame:ResetScroll() @@ -2093,7 +2092,7 @@ ShowDetails = function(spell) -- -- to ensure desc -- if timer then timer:Cancel() end -- timer = C_Timer.NewTimer(0.7, function() - -- SetSpellDesc(select(3, F:GetSpellInfo(spellId))) + -- SetSpellDesc(select(3, F:GetSpellNameAndIcon(spellId))) -- end) local isEnabled = selectedButtonIndex <= #currentBossTable["enabled"] @@ -2171,7 +2170,7 @@ function F:GetDebuffList(instanceName) if loadedDebuffs[iId]["general"] then n = #loadedDebuffs[iId]["general"]["enabled"] for _, t in ipairs(loadedDebuffs[iId]["general"]["enabled"]) do - local spellName = GetSpellInfo(t["id"]) + local spellName = F:GetSpellNameAndIcon(t["id"]) if spellName then -- list[spellName/spellId] = {order, glowType, glowOptions} list[t["trackByID"] and t["id"] or spellName] = { @@ -2189,7 +2188,7 @@ function F:GetDebuffList(instanceName) for bId, bTable in pairs(loadedDebuffs[iId]) do if bId ~= "general" then for _, t in pairs(bTable["enabled"]) do - local spellName = GetSpellInfo(t["id"]) + local spellName = F:GetSpellNameAndIcon(t["id"]) if spellName then -- check again list[t["trackByID"] and t["id"] or spellName] = { ["order"] = t["order"]+n, diff --git a/Modules/RaidDebuffs_Classic.lua b/Modules/RaidDebuffs_Classic.lua index b5624b63..02e8d780 100644 --- a/Modules/RaidDebuffs_Classic.lua +++ b/Modules/RaidDebuffs_Classic.lua @@ -650,7 +650,7 @@ local function CreateDebuffsFrame() create:SetScript("OnClick", function() local popup = Cell:CreateConfirmPopup(debuffsTab, 200, L["Create new debuff (id)"], function(self) local id = tonumber(self.editBox:GetText()) or 0 - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if not name then F:Print(L["Invalid spell id."]) return @@ -711,7 +711,7 @@ local function CreateDebuffsFrame() return end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -815,7 +815,7 @@ local function RegisterForDrag(b) b:SetScript("OnDragStop", function(self) self:SetAlpha(1) dragged:Hide() - local newB = GetMouseFocus() + local newB = F:GetMouseFoci() -- move on a debuff button & not on currently moving button & not disabled if newB:GetParent() == debuffListFrame.scrollFrame.content and newB ~= self and newB.enabled then local temp, from, to = self, self.index, newB.index @@ -958,7 +958,7 @@ local function CreateDebuffButton(i, sTable) debuffButtons[i]:Show() - local name, _, icon = GetSpellInfo(sTable["id"]) + local name, icon = F:GetSpellNameAndIcon(sTable["id"]) if name then debuffButtons[i].icon:SetTexture(icon) debuffButtons[i].spellIcon = icon @@ -1916,8 +1916,7 @@ ShowDetails = function(spell) if selectedSpellId == spellId then return end selectedSpellId, selectedButtonIndex = spellId, buttonIndex - -- local name, icon, desc = F:GetSpellInfo(spellId) - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then return end detailsFrame.scrollFrame:ResetScroll() @@ -2010,7 +2009,7 @@ function F:GetDebuffList(instanceName) if loadedDebuffs[iId]["general"] then n = #loadedDebuffs[iId]["general"]["enabled"] for _, t in ipairs(loadedDebuffs[iId]["general"]["enabled"]) do - local spellName = GetSpellInfo(t["id"]) + local spellName = F:GetSpellNameAndIcon(t["id"]) if spellName then -- list[spellName/spellId] = {order, glowType, glowOptions} list[t["trackByID"] and t["id"] or spellName] = { @@ -2028,7 +2027,7 @@ function F:GetDebuffList(instanceName) for bId, bTable in pairs(loadedDebuffs[iId]) do if bId ~= "general" then for _, t in pairs(bTable["enabled"]) do - local spellName = GetSpellInfo(t["id"]) + local spellName = F:GetSpellNameAndIcon(t["id"]) if spellName then -- check again list[t["trackByID"] and t["id"] or spellName] = { ["order"] = t["order"]+n, diff --git a/RaidFrames/Groups/SpotlightFrame.lua b/RaidFrames/Groups/SpotlightFrame.lua index f6f28957..1c06c603 100644 --- a/RaidFrames/Groups/SpotlightFrame.lua +++ b/RaidFrames/Groups/SpotlightFrame.lua @@ -181,7 +181,7 @@ local function CreateAssignmentButton(index) if InCombatLockdown() then return end - local f = GetMouseFocus() + local f = F:GetMouseFoci() if f == WorldFrame then f = F:GetUnitButtonByGUID(UnitGUID("mouseover") or "") diff --git a/RaidFrames/MainFrame.lua b/RaidFrames/MainFrame.lua index 71f95bc4..d2aa4644 100644 --- a/RaidFrames/MainFrame.lua +++ b/RaidFrames/MainFrame.lua @@ -177,7 +177,7 @@ P:Point(loadingBar, "BOTTOMRIGHT", options, -1, 1) ------------------------------------------------- -- MemoryUsage ------------------------------------------------- ---@debug@ +--[==[@debug@ -- local memUsage = CreateFrame("Frame", nil, cellMainFrame) -- memUsage:SetSize(10, 10) -- memUsage:SetPoint("LEFT", raid, "RIGHT", 5, 0) @@ -191,7 +191,7 @@ P:Point(loadingBar, "BOTTOMRIGHT", options, -1, 1) -- self.elapsed = 0 -- end -- end) ---@end-debug@ +--@end-debug@]==] ------------------------------------------------- -- fadeIn & fadeOut diff --git a/Revise.lua b/Revise.lua index de80212b..093a8667 100644 --- a/Revise.lua +++ b/Revise.lua @@ -2141,7 +2141,7 @@ function F:Revise() for _, t in pairs(CellDB["spellRequest"]["spells"]) do t["type"] = "icon" - t["icon"] = select(3, GetSpellInfo(t["spellId"])) + t["icon"] = select(2, F:GetSpellNameAndIcon(t["spellId"])) t["iconColor"] = t["glowOptions"][2][1] end diff --git a/Utilities/BuffTracker.lua b/Utilities/BuffTracker.lua index 5125b483..8ce96f4c 100644 --- a/Utilities/BuffTracker.lua +++ b/Utilities/BuffTracker.lua @@ -30,7 +30,7 @@ local buffs = { do for _, t in pairs(buffs) do - local name, _, icon = GetSpellInfo(t["id"]) + local name, icon = F:GetSpellNameAndIcon(t["id"]) t["name"] = name t["icon"] = icon end diff --git a/Utilities/BuffTracker_Cata.lua b/Utilities/BuffTracker_Cata.lua index f55ef30f..38c860e2 100644 --- a/Utilities/BuffTracker_Cata.lua +++ b/Utilities/BuffTracker_Cata.lua @@ -48,7 +48,7 @@ local buffs = { do for _, t in pairs(buffs) do - local name, _, icon = GetSpellInfo(t["id"]) + local name, icon = F:GetSpellNameAndIcon(t["id"]) t["name"] = name t["icon"] = icon end diff --git a/Utilities/BuffTracker_Vanilla.lua b/Utilities/BuffTracker_Vanilla.lua index 77d2c408..dac869dc 100644 --- a/Utilities/BuffTracker_Vanilla.lua +++ b/Utilities/BuffTracker_Vanilla.lua @@ -67,7 +67,7 @@ local buffs = { do for _, t in pairs(buffs) do for i, id in ipairs(t) do - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) t[i] = { -- ["id"] = id, ["name"] = name, diff --git a/Utilities/QuickAssist.lua b/Utilities/QuickAssist.lua index d2526e78..dcf159fd 100644 --- a/Utilities/QuickAssist.lua +++ b/Utilities/QuickAssist.lua @@ -123,7 +123,7 @@ end -- if t[1] == 0 then -- b:SetAttribute("type"..i, "target") -- elseif t[1] ~= -1 then --- local spellName = GetSpellInfo(t[1]) +-- local spellName = F:GetSpellNameAndIcon(t[1]) -- b:SetAttribute("type"..i, "macro") -- b:SetAttribute("macrotext"..i, "/cast [@mouseover] "..spellName) @@ -1205,7 +1205,7 @@ local function UpdateQuickAssist(which) for _, t in pairs(spellTable["mine"]["buffs"]) do if t[1] > 0 then - local spellName = GetSpellInfo(t[1]) + local spellName = F:GetSpellNameAndIcon(t[1]) if spellName then if t[2] == "icon" then myBuffs_icon[spellName] = t[3] diff --git a/Utilities/QuickAssist_Config.lua b/Utilities/QuickAssist_Config.lua index 013d6f00..215c7554 100644 --- a/Utilities/QuickAssist_Config.lua +++ b/Utilities/QuickAssist_Config.lua @@ -824,7 +824,7 @@ local function CreateQuickAssistPane() return end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -849,7 +849,7 @@ local function CreateQuickAssistPane() return end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -1011,7 +1011,7 @@ local function CreateClassFilter(parent) self:SetFrameStrata("LOW") -- self:Hide() --! Hide() will cause OnDragStop trigger TWICE!!! C_Timer.After(0.05, function() - local b = GetMouseFocus() + local b = F:GetMouseFoci() if b and b._class then local oldIndex, oldValue, newIndex for i, t in pairs(quickAssistTable["filters"][selectedFilter][2]) do @@ -1255,7 +1255,7 @@ local function CreateSpecFilter(parent) frames[class]:SetFrameStrata("LOW") -- self:Hide() --! Hide() will cause OnDragStop trigger TWICE!!! C_Timer.After(0.05, function() - local mf = GetMouseFocus() + local mf = F:GetMouseFoci() if mf then mf = mf:GetParent() end if mf and mf._class then local oldIndex, oldValue, newIndex @@ -1381,7 +1381,7 @@ local function CreateClassOrderWidget(parent) self:SetFrameStrata("LOW") -- self:Hide() --! Hide() will cause OnDragStop trigger TWICE!!! C_Timer.After(0.05, function() - local b = GetMouseFocus() + local b = F:GetMouseFoci() if b and b._class then local classToIndex = F:ConvertTable(layoutTable["order"]) -- print(self._class, "->", b._class) @@ -3009,7 +3009,7 @@ local function CreateMyBuffWidget(parent, index) if button == "LeftButton" then local popup = Cell:CreatePopupEditBox(qaPane, function(text) local spellId = tonumber(text) - local spellName, _, spellIcon = GetSpellInfo(spellId) + local spellName, spellIcon = F:GetSpellNameAndIcon(spellId) if spellId and spellName then b.id = spellId @@ -3194,7 +3194,7 @@ local function CreateSpellsPane() buffsAddBtn:SetScript("OnClick", function() local popup = Cell:CreatePopupEditBox(qaPane, function(text) local spellId = tonumber(text) - local spellName = GetSpellInfo(spellId) + local spellName = F:GetSpellNameAndIcon(spellId) if spellId and spellName then if not spellTable["offensives"]["buffs"][selectedClass] then spellTable["offensives"]["buffs"][selectedClass] = {} @@ -3224,7 +3224,7 @@ local function CreateSpellsPane() castsAddBtn:SetTexture("Interface\\AddOns\\Cell\\Media\\Icons\\create", {20, 20}, {"CENTER", 0, 0}) castsAddBtn:SetScript("OnClick", function() local popup = Cell:CreateDualPopupEditBox(qaPane, "ID", L["Duration"], true, function(spellId, duration) - local spellName = GetSpellInfo(spellId) + local spellName = F:GetSpellNameAndIcon(spellId) if spellId and spellName and duration then if not spellTable["offensives"]["casts"][selectedClass] then spellTable["offensives"]["casts"][selectedClass] = {} @@ -3411,7 +3411,7 @@ LoadMyBuff = function(b, t) b.tex:SetTexture("Interface\\AddOns\\Cell\\Media\\Icons\\create") b.tex:SetTexCoord(0, 1, 0, 1) else - local name, _, icon = GetSpellInfo(t[1]) + local name, icon = F:GetSpellNameAndIcon(t[1]) if name and icon then b:SetText(name) b.tex:SetTexture(icon) @@ -3481,7 +3481,7 @@ LoadList = function(parent, buttons, addBtn, t, separator) buttons[i].duration:SetText(duration) end - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) if not name then icon = 134400 end buttons[i].id = id buttons[i].icon = icon diff --git a/Utilities/QuickCast.lua b/Utilities/QuickCast.lua index 85fed0c7..923a378f 100644 --- a/Utilities/QuickCast.lua +++ b/Utilities/QuickCast.lua @@ -223,7 +223,7 @@ local function CreateQCPane() return end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -365,7 +365,7 @@ local function CreateSpellButton(parent, func) if button == "LeftButton" then local popup = Cell:CreatePopupEditBox(qcPane, function(text) local spellId = tonumber(text) - local spellName, _, spellIcon = GetSpellInfo(spellId) + local spellName, spellIcon = F:GetSpellNameAndIcon(spellId) if spellId and spellName then b.id = spellId b.icon = spellIcon @@ -515,7 +515,7 @@ local function LoadGlowList(parent, buttons, addBtn, anchorTo, t, separator) buttons[i].duration:SetText(duration) end - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) if not name then icon = 134400 end buttons[i].id = id buttons[i].icon = icon @@ -583,7 +583,7 @@ local function CreateGlowBuffsPane() qcGlowBuffsAddBtn:SetScript("OnClick", function() local popup = Cell:CreatePopupEditBox(qcPane, function(text) local spellId = tonumber(text) - local spellName = GetSpellInfo(spellId) + local spellName = F:GetSpellNameAndIcon(spellId) if spellId and spellName then tinsert(quickCastTable["glowBuffs"], spellId) LoadGlowList(qcGlowBuffsPane, qcGlowBuffsButtons, qcGlowBuffsAddBtn, qcGlowBuffsCP, quickCastTable["glowBuffs"]) @@ -628,7 +628,7 @@ local function CreateGlowCastsPane() return end - local name, _, icon = GetSpellInfo(spellId) + local name, icon = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -649,7 +649,7 @@ local function CreateGlowCastsPane() qcGlowCastsAddBtn:SetTexture("Interface\\AddOns\\Cell\\Media\\Icons\\create", {16, 16}, {"CENTER", 0, 0}) qcGlowCastsAddBtn:SetScript("OnClick", function() local popup = Cell:CreateDualPopupEditBox(qcGlowCastsPane, "ID", L["Duration"], true, function(spellId, duration) - local spellName = GetSpellInfo(spellId) + local spellName = F:GetSpellNameAndIcon(spellId) if spellId and spellName and duration then tinsert(quickCastTable["glowCasts"], spellId..":"..duration) LoadGlowList(qcGlowCastsPane, qcGlowCastsButtons, qcGlowCastsAddBtn, qcGlowCastsCP, quickCastTable["glowCasts"], ":") @@ -677,7 +677,7 @@ local function LoadSpellButton(b, value) b.tex:SetTexture("Interface\\AddOns\\Cell\\Media\\Icons\\create") b.tex:SetTexCoord(0, 1, 0, 1) else - local name, _, icon = GetSpellInfo(value) + local name, icon = F:GetSpellNameAndIcon(value) if name and icon then b:SetText(name) b.tex:SetTexture(icon) @@ -879,7 +879,7 @@ local function RegisterDrag(frame) return end - local f = GetMouseFocus() + local f = F:GetMouseFoci() if f and f.states and f.states.displayedUnit and F:UnitInGroup(f.states.displayedUnit) then quickCastTable["units"][frame.index] = f.states.displayedUnit frame:SetUnit(f.states.displayedUnit, outerBuff, innerBuff) @@ -1440,8 +1440,8 @@ local function UpdateQuickCast() -- prepare buffs glowBuffs = F:ConvertSpellTable(quickCastTable["glowBuffs"], true) glowCasts = F:ConvertSpellDurationTable(quickCastTable["glowCasts"]) - outerBuff = GetSpellInfo(quickCastTable["outerBuff"]) - innerBuff = GetSpellInfo(quickCastTable["innerBuff"]) + outerBuff = F:GetSpellNameAndIcon(quickCastTable["outerBuff"]) + innerBuff = F:GetSpellNameAndIcon(quickCastTable["innerBuff"]) -- create if not quickCastButtons then diff --git a/Utilities/Request_Dispel.lua b/Utilities/Request_Dispel.lua index 6646381e..0490f80c 100644 --- a/Utilities/Request_Dispel.lua +++ b/Utilities/Request_Dispel.lua @@ -171,7 +171,7 @@ local function CreateDRPane() return end - local name, _, tex = GetSpellInfo(spellId) + local name, tex = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -192,7 +192,7 @@ local function CreateDRPane() debuffItems[0]:SetScript("OnClick", function(self) local popup = Cell:CreatePopupEditBox(drDebuffsList, function(text) local spellId = tonumber(text) - local spellName = GetSpellInfo(spellId) + local spellName = F:GetSpellNameAndIcon(spellId) if spellId and spellName then -- update db tinsert(CellDB["dispelRequest"]["debuffs"], spellId) @@ -331,7 +331,7 @@ LoadList = function(scrollToBottom) -- tooltip debuffItems[i]:HookScript("OnEnter", function(self) if not drDebuffsList.popupEditBox:IsShown() then - local name, _, icon = GetSpellInfo(self.spellId) + local name, icon = F:GetSpellNameAndIcon(self.spellId) if not name then CellSpellTooltip:Hide() return @@ -350,7 +350,7 @@ LoadList = function(scrollToBottom) end) end - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) debuffItems[i].spellId = id debuffItems[i].spellIdText:SetText(id) diff --git a/Utilities/Request_Spell.lua b/Utilities/Request_Spell.lua index 2083ab42..fdabcb1a 100644 --- a/Utilities/Request_Spell.lua +++ b/Utilities/Request_Spell.lua @@ -98,7 +98,7 @@ end local function LoadSpellsDropdown() local items = {} for i, t in pairs(CellDB["spellRequest"]["spells"]) do - local name, _, icon = GetSpellInfo(t["spellId"]) + local name, icon = F:GetSpellNameAndIcon(t["spellId"]) tinsert(items, { ["text"] = "|T"..icon..":0::0:0:16:16:1:15:1:15|t "..name, ["value"] = t["spellId"], @@ -327,7 +327,7 @@ local function CreateSRPane() srDeleteBtn = Cell:CreateButton(srPane, L["Delete"], "red-hover", {65, 20}) srDeleteBtn:SetPoint("TOPLEFT", srAddBtn, "TOPRIGHT", 7, 0) srDeleteBtn:SetScript("OnClick", function() - local name, _, icon = GetSpellInfo(CellDB["spellRequest"]["spells"][srSelectedSpell]["spellId"]) + local name, icon = F:GetSpellNameAndIcon(CellDB["spellRequest"]["spells"][srSelectedSpell]["spellId"]) local spellEditFrame = Cell:CreateConfirmPopup(Cell.frames.utilitiesTab, 200, L["Delete spell?"].."\n".."|T"..icon..":0::0:0:16:16:1:15:1:15|t "..name, function(self) tremove(CellDB["spellRequest"]["spells"], srSelectedSpell) srSpellsDD:RemoveCurrentItem() @@ -476,7 +476,7 @@ local function CreateSpellEditFrame() return end - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) if not name then CellSpellTooltip:Hide() spellId = nil @@ -523,7 +523,7 @@ local function CreateSpellEditFrame() return end - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if not name then buffId = nil addBtn:SetEnabled(false) diff --git a/Utils.lua b/Utils.lua index cd5eedd9..c302199f 100644 --- a/Utils.lua +++ b/Utils.lua @@ -16,12 +16,11 @@ Cell.isVanilla = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC -- Cell.isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC and LE_EXPANSION_LEVEL_CURRENT == LE_EXPANSION_WRATH_OF_THE_LICH_KING Cell.isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC Cell.isCata = WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC - +Cell.isTWW = LE_EXPANSION_LEVEL_CURRENT == LE_EXPANSION_WAR_WITHIN ------------------------------------------------- -- class ------------------------------------------------- -local localizedClass = {} -FillLocalizedClassList(localizedClass) +local localizedClass = LocalizedClassList() local sortedClasses = {} local classFileToID = {} @@ -52,6 +51,32 @@ do sort(sortedClasses) end +if Cell.isRetail then + ---@param spellid number + ---@return string, number + function F:GetSpellNameAndIcon(spellid) + if C_Spell and C_Spell.GetSpellInfo then + local info = C_Spell.GetSpellInfo(spellid) + if not info.icon then + info.icon = C_Spell.GetSpellTexture(spellid) + end + + return info.name, info.icon + end + + -- todo: remove once 11.0 prepatch hits + local name, _, icon = GetSpellInfo(spellid) + return name, icon + end +else + ---@param spellid number + ---@return string, number + function F:GetSpellNameAndIcon(spellid) + local name, _, icon = GetSpellInfo(spellid) + return name, icon + end +end + function F:GetClassID(classFile) return classFileToID[classFile] end @@ -615,7 +640,6 @@ function F:ConvertTable(t, value) return temp end -local GetSpellInfo = GetSpellInfo function F:ConvertSpellTable(t, convertIdToName) if not convertIdToName then return F:ConvertTable(t) @@ -623,7 +647,7 @@ function F:ConvertSpellTable(t, convertIdToName) local temp = {} for k, v in ipairs(t) do - local name = GetSpellInfo(v) + local name = F:GetSpellNameAndIcon(v) if name then temp[name] = k end @@ -635,7 +659,7 @@ function F:ConvertSpellTable_WithClass(t) local temp = {} for class, ct in pairs(t) do for _, id in ipairs(ct) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then temp[id] = true end @@ -648,7 +672,7 @@ function F:ConvertSpellDurationTable(t, convertIdToName) local temp = {} for _, v in ipairs(t) do local id, duration = strsplit(":", v) - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then if convertIdToName then temp[name] = tonumber(duration) @@ -665,7 +689,7 @@ function F:ConvertSpellDurationTable_WithClass(t) for class, ct in pairs(t) do for k, v in ipairs(ct) do local id, duration = strsplit(":", v) - local name, _, icon = GetSpellInfo(id) + local name, icon = F:GetSpellNameAndIcon(id) if name then temp[tonumber(id)] = {tonumber(duration), icon} end @@ -698,7 +722,7 @@ function F:FilterInvalidSpells(t) else -- consumables spellId = t[i][1] end - if not GetSpellInfo(spellId) then + if not F:GetSpellNameAndIcon(spellId) then tremove(t, i) end end @@ -779,7 +803,22 @@ end local combinedHeader = "CellRaidFrameHeader0" local separatedHeaders = {"CellRaidFrameHeader1", "CellRaidFrameHeader2", "CellRaidFrameHeader3", "CellRaidFrameHeader4", "CellRaidFrameHeader5", "CellRaidFrameHeader6", "CellRaidFrameHeader7", "CellRaidFrameHeader8"} -function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist) +Cell.clickCastFrames = {} +Cell.clickCastFrameQueue = {} + +function F:RegisterFrame(frame) + Cell.clickCastFrames[frame] = true + Cell.clickCastFrameQueue[frame] = true -- put into queue + Cell:Fire("UpdateQueuedClickCastings") +end + +function F:UnregisterFrame(frame) + Cell.clickCastFrames[frame] = nil -- ignore + Cell.clickCastFrameQueue[frame] = false -- mark for only cleanup + Cell:Fire("UpdateQueuedClickCastings") +end + +function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist, updateBlizzardFrames) -- solo if not updateCurrentGroupOnly or (updateCurrentGroupOnly and Cell.vars.groupType == "solo") then for _, b in pairs(Cell.unitButtons.solo) do @@ -1411,8 +1450,6 @@ local UnitInRange = UnitInRange local UnitCanAssist = UnitCanAssist local UnitCanAttack = UnitCanAttack local UnitCanCooperate = UnitCanCooperate -local IsSpellInRange = IsSpellInRange -local IsItemInRange = IsItemInRange local CheckInteractDistance = CheckInteractDistance local UnitIsDead = UnitIsDead local GetSpellTabInfo = GetSpellTabInfo @@ -1486,51 +1523,77 @@ local harmItems = { ["WARRIOR"] = 28767, } -local function GetNumSpells() - local _, _, offset, numSpells = GetSpellTabInfo(GetNumSpellTabs()) - return offset + numSpells -end - local function FindSpellIndex(spellName) if not spellName or spellName == "" then return nil end - for i = 1, GetNumSpells() do - local spell = GetSpellBookItemName(i, BOOKTYPE_SPELL) - if spell == spellName then - return i + + if C_SpellBook and C_SpellBook.FindSpellBookSlotForSpell then + return select(1, C_SpellBook.FindSpellBookSlotForSpell(spellName)) + end + + local tabs = C_SpellBook and C_SpellBook.GetNumSpellBookSkillLines and C_SpellBook.GetNumSpellBookSkillLines() or GetNumSpellTabs() + local total = 0 + + if C_SpellBook and C_SpellBook.GetSpellBookSkillLineInfo then + local info = C_SpellBook.GetSpellBookSkillLineInfo(tabs) + total = info.itemIndexOffset+ info.numSpellBookItems + else + local _, _, offset, numSpells = GetSpellTabInfo(tabs) + total = offset + numSpells + end + + if C_SpellBook and C_SpellBook.GetSpellBookItemName then + for i = 1, total do + local spell = C_SpellBook.GetSpellBookItemName(i, Enum.SpellBookSpellBank.Player) + if spell == spellName then + return i + end + end + else + for i = 1, total do + local spell = GetSpellBookItemName(i, BOOKTYPE_SPELL) + if spell == spellName then + return i + end end end + return nil end -- do -- -- NOTE: convert ID to NAME then to INDEX -- for k, id in pairs(friendSpells) do --- friendSpells[k] = FindSpellIndex(GetSpellInfo(id)) +-- friendSpells[k] = FindSpellIndex(F:GetSpellNameAndIcon(id)) -- end -- for k, id in pairs(harmSpells) do --- harmSpells[k] = FindSpellIndex(GetSpellInfo(id)) +-- harmSpells[k] = FindSpellIndex(F:GetSpellNameAndIcon(id)) -- end -- end -local function UnitInSpellRange(spellIndex, unit) - if not spellIndex then return end - return IsSpellInRange(spellIndex, BOOKTYPE_SPELL, unit) == 1 +local function UnitInSpellRange(spellName, unit) + if C_Spell and C_Spell.IsSpellInRange then + return C_Spell.IsSpellInRange(spellName, unit) + end + if not IsSpellInRange or not spellName then return end + return IsSpellInRange(spellName, unit) end local rc = CreateFrame("Frame") rc:RegisterEvent("SPELLS_CHANGED") -if playerClass == "EVOKER" then - local spell_dead, spell_alive, spell_harm - rc:SetScript("OnEvent", function() - spell_dead = FindSpellIndex(GetSpellInfo(361227)) - spell_alive = FindSpellIndex(GetSpellInfo(361469)) - spell_harm = FindSpellIndex(GetSpellInfo(361469)) - end) +local spell_friend, spell_harm, spell_dead +rc:SetScript("OnEvent", function() + spell_friend = F:GetSpellNameAndIcon(friendSpells[playerClass]) + spell_harm = F:GetSpellNameAndIcon(harmSpells[playerClass]) + spell_dead = spell_friend + if playerClass == "EVOKER" then + spell_dead = F:GetSpellNameAndIcon(361227) + end +end) - -- NOTE: UnitInRange for evoker is around 50y +if Cell.isRetail then function F:IsInRange(unit, check) if not UnitIsVisible(unit) then return false @@ -1538,108 +1601,63 @@ if playerClass == "EVOKER" then if UnitIsUnit("player", unit) then return true - -- elseif not check and F:UnitInGroup(unit) then - -- -- NOTE: UnitInRange only works with group players/pets - -- local checked - -- inRange, checked = UnitInRange(unit) - -- if not checked then - -- return F:IsInRange(unit, true) - -- end - -- return inRange + elseif not check and F:UnitInGroup(unit) then + -- NOTE: UnitInRange only works with group players/pets --! but not available for PLAYER PET when SOLO + local inRange, checked = UnitInRange(unit) + if not checked then + return F:IsInRange(unit, true) + end + return inRange else - -- UnitCanCooperate works with cross-faction, UnitCanAssist does not if UnitCanAssist("player", unit) or UnitCanCooperate("player", unit) then - -- print("CanAssist", unit) if UnitIsDead(unit) then - return UnitInSpellRange(spell_dead, unit) -- 40y + return UnitInSpellRange(spell_dead, unit) -- resurrection range, need separately for evoker else - return UnitInSpellRange(spell_alive, unit) -- 25/30y + return UnitInSpellRange(spell_friend, unit) -- normal heal range end elseif UnitCanAttack("player", unit) then - -- print("CanAttack", unit) - return UnitInSpellRange(spell_harm, unit) + if spell_harm then + return UnitInSpellRange(spell_harm, unit) + end end - -- print("InRange", unit) return UnitInRange(unit) end end else - local spell_friend, spell_harm - rc:SetScript("OnEvent", function() - spell_friend = FindSpellIndex(GetSpellInfo(friendSpells[playerClass])) - spell_harm = FindSpellIndex(GetSpellInfo(harmSpells[playerClass])) - end) + function F:IsInRange(unit, check) + if not UnitIsVisible(unit) then + return false + end - if Cell.isRetail then - function F:IsInRange(unit, check) - if not UnitIsVisible(unit) then - return false + if UnitIsUnit("player", unit) then + return true + elseif not check and F:UnitInGroup(unit) then + -- NOTE: UnitInRange only works with group players/pets --! but not available for PLAYER PET when SOLO + local inRange, checked = UnitInRange(unit) + if not checked then + return F:IsInRange(unit, true) end - - if UnitIsUnit("player", unit) then - return true - elseif not check and F:UnitInGroup(unit) then - -- NOTE: UnitInRange only works with group players/pets --! but not available for PLAYER PET when SOLO - local checked - inRange, checked = UnitInRange(unit) - if not checked then - return F:IsInRange(unit, true) + return inRange + else + if UnitCanAssist("player", unit) then + -- print("CanAssist", unit) + if spell_friend then + return UnitInSpellRange(spell_friend, unit) + else + return C_Item.IsItemInRange(friendItems[playerClass], unit) end - return inRange - else - if UnitCanAssist("player", unit) or UnitCanCooperate("player", unit) then - -- print("CanAssist", unit) - if spell_friend then - return UnitInSpellRange(spell_friend, unit) - end - elseif UnitCanAttack("player", unit) then - -- print("CanAttack", unit) - if spell_harm then - return UnitInSpellRange(spell_harm, unit) - end + elseif UnitCanAttack("player", unit) then + -- print("CanAttack", unit) + if spell_harm then + return UnitInSpellRange(spell_harm, unit) + else + return C_Item.IsItemInRange(harmItems[playerClass], unit) end - - -- print("InRange", unit) - return UnitInRange(unit) - end - end - else - function F:IsInRange(unit, check) - if not UnitIsVisible(unit) then - return false end - if UnitIsUnit("player", unit) then - return true - elseif not check and F:UnitInGroup(unit) then - -- NOTE: UnitInRange only works with group players/pets --! but not available for PLAYER PET when SOLO - local checked - inRange, checked = UnitInRange(unit) - if not checked then - return F:IsInRange(unit, true) - end - return inRange - else - if UnitCanAssist("player", unit) then - -- print("CanAssist", unit) - if spell_friend then - return UnitInSpellRange(spell_friend, unit) - else - return IsItemInRange(friendItems[playerClass], unit) - end - elseif UnitCanAttack("player", unit) then - -- print("CanAttack", unit) - if spell_harm then - return UnitInSpellRange(spell_harm, unit) - else - return IsItemInRange(harmItems[playerClass], unit) - end - end - - -- print("CheckInteractDistance", unit) - return CheckInteractDistance(unit, 4) -- 28 yards - end + -- print("CheckInteractDistance", unit) + return CheckInteractDistance(unit, 4) -- 28 yards end end end @@ -1892,38 +1910,6 @@ function F:GetInstanceName() end end -------------------------------------------------- --- spell description -------------------------------------------------- --- https://wow.gamepedia.com/UIOBJECT_GameTooltip --- local function EnumerateTooltipLines_helper(...) --- for i = 1, select("#", ...) do --- local region = select(i, ...) --- if region and region:GetObjectType() == "FontString" then --- local text = region:GetText() -- string or nil --- print(region:GetName(), text) --- end --- end --- end - --- https://wowpedia.fandom.com/wiki/Patch_10.0.2/API_changes -local lines = {} -function F:GetSpellInfo(spellId) - wipe(lines) - - local name, _, icon = GetSpellInfo(spellId) - if not name then return end - - local data = C_TooltipInfo.GetSpellByID(spellId) - for i, line in ipairs(data.lines) do - TooltipUtil.SurfaceArgs(line) - -- line.leftText - -- line.rightText - end - - return name, icon, table.concat(lines, "\n") -end - ------------------------------------------------- -- auras ------------------------------------------------- @@ -2083,4 +2069,12 @@ function F:OverrideLGF(override) WA_GetUnitFrame = WeakAuras.GetUnitFrame WeakAuras.GetUnitFrame = Cell.GetUnitFrame end +end + +function F:GetMouseFoci() + if Cell.isTWW then + return GetMouseFoci() + else + return GetMouseFocus() + end end \ No newline at end of file diff --git a/Widgets/Widgets.lua b/Widgets/Widgets.lua index 102280b0..754787e2 100644 --- a/Widgets/Widgets.lua +++ b/Widgets/Widgets.lua @@ -3226,7 +3226,7 @@ local function CreateGrid(parent, text, width) parent:SetFrameStrata("LOW") -- self:Hide() --! Hide() will cause OnDragStop trigger TWICE!!! C_Timer.After(0.05, function() - local b = GetMouseFocus() + local b = F:GetMouseFoci() if b then b = b:GetParent() end F:MoveClickCastings(parent.clickCastingIndex, b and b.clickCastingIndex) end) @@ -3290,8 +3290,8 @@ function addon:CreateBindingListButton(parent, modifier, bindKey, bindType, bind spellIcon:SetTexCoord(0.08, 0.92, 0.08, 0.92) spellIcon:Hide() - function b:ShowSpellIcon(spell) - spellIcon:SetTexture(GetSpellTexture(spell) or 134400) + function b:ShowIcon(texture) + spellIcon:SetTexture(texture or 134400) spellIconBg:Show() spellIcon:Show() -- actionGrid.text:ClearAllPoints() @@ -3299,6 +3299,22 @@ function addon:CreateBindingListButton(parent, modifier, bindKey, bindType, bind -- actionGrid.text:SetPoint("RIGHT", P:Scale(-5), 0) end + function b:ShowSpellIcon(spell) + local icon = nil + if spell then + icon = select(2, F:GetSpellNameAndIcon(spell)) + end + b:ShowIcon(icon) + end + + function b:ShowItemIcon(itemslot) + b:ShowIcon(GetInventoryItemTexture("player", itemslot)) + end + + function b:ShowMacroIcon(macro) + b:ShowIcon(select(2, GetMacroInfo(macro))) + end + function b:HideSpellIcon() spellIconBg:Hide() spellIcon:Hide() diff --git a/Widgets/Widgets_IndicatorSettings.lua b/Widgets/Widgets_IndicatorSettings.lua index 89610d7b..acaca9e4 100644 --- a/Widgets/Widgets_IndicatorSettings.lua +++ b/Widgets/Widgets_IndicatorSettings.lua @@ -3376,7 +3376,6 @@ local function CreateSetting_Texture(parent) return widget end -local GetSpellInfo = GetSpellInfo local function CreateAuraButtons(parent, auraButtons, auraTable, noUpDownButtons, isZeroValid, updateHeightFunc) local n = #auraTable @@ -3392,7 +3391,7 @@ local function CreateAuraButtons(parent, auraButtons, auraTable, noUpDownButtons return end - local name, _, tex = GetSpellInfo(spellId) + local name, tex = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -3420,7 +3419,7 @@ local function CreateAuraButtons(parent, auraButtons, auraTable, noUpDownButtons auraButtons[0]:SetScript("OnClick", function(self) local popup = addon:CreatePopupEditBox(parent, function(text) local spellId = tonumber(text) - local spellName = GetSpellInfo(spellId) + local spellName = F:GetSpellNameAndIcon(spellId) if (spellId and spellName) or (spellId == 0 and isZeroValid) then -- update db tinsert(auraTable, spellId) @@ -3538,7 +3537,7 @@ local function CreateAuraButtons(parent, auraButtons, auraTable, noUpDownButtons auraButtons[i].spellIconBg:Hide() auraButtons[i].spellIcon:Hide() else - local name, _, icon = GetSpellInfo(spell) + local name, icon = F:GetSpellNameAndIcon(spell) auraButtons[i].spellIdText:SetText(spell) auraButtons[i].spellId = spell auraButtons[i].spellTex = icon @@ -3554,7 +3553,7 @@ local function CreateAuraButtons(parent, auraButtons, auraTable, noUpDownButtons -- spell tooltip auraButtons[i]:HookScript("OnEnter", function(self) if not parent.popupEditBox:IsShown() then - local name = GetSpellInfo(self.spellId) + local name = F:GetSpellNameAndIcon(self.spellId) if not name then CellSpellTooltip:Hide() return @@ -3632,7 +3631,7 @@ local function CreateAuraButtons(parent, auraButtons, auraTable, noUpDownButtons F:Print(L["Invalid spell id."]) end else - local spellName, _, spellIcon = GetSpellInfo(spellId) + local spellName, spellIcon = F:GetSpellNameAndIcon(spellId) if spellId and spellName then -- update text auraButtons[i].spellIdText:SetText(spellId) @@ -3702,7 +3701,7 @@ local function GetExportString(t) local s = "" local n = 0 for i, id in ipairs(t) do - local name = GetSpellInfo(id) + local name = F:GetSpellNameAndIcon(id) if name then s = s .. (i == 1 and "" or "\n") .. id .. ", -- " .. name n = n + 1 @@ -3919,7 +3918,7 @@ local function CreateCleuAuraButtons(parent, auraTable, updateHeightFunc) return end - local name = GetSpellInfo(spellId) + local name = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() Validate() @@ -4079,7 +4078,7 @@ local function CreateCleuAuraButtons(parent, auraTable, updateHeightFunc) end) end - local name, _, icon = GetSpellInfo(t[1]) + local name, icon = F:GetSpellNameAndIcon(t[1]) cleuAuraButtons[i].spellIdText:SetText(t[1]) cleuAuraButtons[i].spellNameText:SetText(name or L["Invalid"]) cleuAuraButtons[i].durationText:SetText(t[2]) @@ -4098,7 +4097,7 @@ local function CreateCleuAuraButtons(parent, auraTable, updateHeightFunc) cleuAuraButtons[i]:HookScript("OnEnter", function(self) if parent.inputs:IsShown() then return end - local name = GetSpellInfo(self.spellId) + local name = F:GetSpellNameAndIcon(self.spellId) if not name then CellSpellTooltip:Hide() return @@ -4135,7 +4134,7 @@ local function CreateCleuAuraButtons(parent, auraTable, updateHeightFunc) parent.inputs.okBtn:SetScript("OnClick", function() local spellId = tonumber(parent.inputs.spellEB:GetText()) local duration = tonumber(parent.inputs.durationEB:GetText()) - local spellName, _, spellIcon = GetSpellInfo(spellId) + local spellName, spellIcon = F:GetSpellNameAndIcon(spellId) -- update text cleuAuraButtons[i].spellIdText:SetText(spellId) cleuAuraButtons[i].spellNameText:SetText(spellName) @@ -4279,7 +4278,7 @@ local function CreateSpellButtons(parent, class, spells, disableds) -- 深寒凝冰 覆盖了 寒冰屏障 spellButtons[buttonIndex].icon:SetTexture(135841) else - local icon = select(3, GetSpellInfo(spellId)) + local icon = select(2, F:GetSpellNameAndIcon(spellId)) spellButtons[buttonIndex].icon:SetTexture(icon) end @@ -4518,7 +4517,7 @@ local function CreateConsumableButtons(parent, spellTable, updateHeightFunc) return end - local name = GetSpellInfo(spellId) + local name = F:GetSpellNameAndIcon(spellId) if not name then CellSpellTooltip:Hide() return @@ -4546,7 +4545,7 @@ local function CreateConsumableButtons(parent, spellTable, updateHeightFunc) consumableButtons[0]:SetScript("OnClick", function(self) local popup = addon:CreatePopupEditBox(parent, function(text) local spellId = tonumber(text) - local spellName = GetSpellInfo(spellId) + local spellName = F:GetSpellNameAndIcon(spellId) if spellId and spellName then -- update db tinsert(spellTable, { @@ -4677,7 +4676,7 @@ local function CreateConsumableButtons(parent, spellTable, updateHeightFunc) end -- fill data - local name, _, icon = GetSpellInfo(spell[1]) + local name, icon = F:GetSpellNameAndIcon(spell[1]) consumableButtons[i].spellIdText:SetText(spell[1]) consumableButtons[i].spellId = spell[1] consumableButtons[i].spellNameText:SetText(name or L["Invalid"]) @@ -4698,7 +4697,7 @@ local function CreateConsumableButtons(parent, spellTable, updateHeightFunc) -- spell tooltip consumableButtons[i]:HookScript("OnEnter", function(self) if not parent.popupEditBox:IsShown() then - local name = GetSpellInfo(self.spellId) + local name = F:GetSpellNameAndIcon(self.spellId) if not name then CellSpellTooltip:Hide() return @@ -4730,7 +4729,7 @@ local function CreateConsumableButtons(parent, spellTable, updateHeightFunc) consumableButtons[i].edit:SetScript("OnClick", function() local popup = addon:CreatePopupEditBox(parent, function(text) local spellId = tonumber(text) - local spellName, _, spellIcon = GetSpellInfo(spellId) + local spellName, spellIcon = F:GetSpellNameAndIcon(spellId) if spellId and spellName then -- update text consumableButtons[i].spellIdText:SetText(spellId)