From 20132c515137e0dd3a9c0c338f137bc9324ca194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Tue, 11 Jun 2024 00:29:56 +0200 Subject: [PATCH 01/14] testingg --- Core.lua | 8 +- Core_Cata.lua | 4 +- Core_Vanilla.lua | 8 +- Defaults/ClickCasting_DefaultSpells.lua | 12 +- Defaults/ClickCasting_DefaultSpells_Cata.lua | 12 +- .../ClickCasting_DefaultSpells_Vanilla.lua | 10 +- Defaults/Indicator_DefaultSpells.lua | 44 +++---- Indicators/Built-in.lua | 43 +++++-- Indicators/StatusIcon.lua | 2 +- Modules/ClickCastings.lua | 30 ++--- Modules/Indicators.lua | 2 +- Modules/Layouts.lua | 2 +- Modules/RaidDebuffs.lua | 25 ++-- Modules/RaidDebuffs_Classic.lua | 2 +- RaidFrames/Groups/SpotlightFrame.lua | 2 +- RaidFrames/MainFrame.lua | 4 +- Utilities/BuffTracker.lua | 2 +- Utilities/QuickAssist.lua | 4 +- Utilities/QuickAssist_Config.lua | 20 ++-- Utilities/QuickCast.lua | 20 ++-- Utilities/Request_Dispel.lua | 8 +- Utilities/Request_Spell.lua | 8 +- Utils.lua | 107 +++++++++++++----- Widgets/Widgets.lua | 2 +- Widgets/Widgets_IndicatorSettings.lua | 33 +++--- 25 files changed, 235 insertions(+), 179 deletions(-) diff --git a/Core.lua b/Core.lua index 86492f07..330fc45d 100644 --- a/Core.lua +++ b/Core.lua @@ -24,9 +24,9 @@ Cell.MIN_INDICATORS_VERSION = 228 Cell.MIN_DEBUFFS_VERSION = 228 Cell.MIN_QUICKASSIST_VERSION = 227 ---@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 @@ -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, 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..8903bfae 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 @@ -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/Indicators/Built-in.lua b/Indicators/Built-in.lua index 654dcae5..4a21bfbd 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 @@ -1644,7 +1644,6 @@ end ------------------------------------------------- -- role icon ------------------------------------------------- -local GetTexCoordsForRoleSmallCircle = GetTexCoordsForRoleSmallCircle local defaultRoleIcon = { TANK = "Interface\\AddOns\\Cell\\Media\\Roles\\TANK32", @@ -1652,23 +1651,53 @@ local defaultRoleIcon = { DAMAGER = "Interface\\AddOns\\Cell\\Media\\Roles\\DAMAGER32", } +-- 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:SetVertexColor(1, 1, 1) if role == "TANK" or role == "HEALER" or (not self.hideDamager and role == "DAMAGER") then if self.texture == "default" then -- self.tex:SetTexture("Interface\\AddOns\\Cell\\Media\\Roles\\UI-LFG-ICON-PORTRAITROLES.blp") - -- self.tex:SetTexCoord(GetTexCoordsForRoleSmallCircle(role)) + -- self.tex:SetTexCoord(getSmallTextCoordsForRole(role)) self.tex:SetTexture(defaultRoleIcon[role]) self.tex:SetTexCoord(0, 1, 0, 1) elseif self.texture == "default2" then self.tex:SetTexture("Interface\\AddOns\\Cell\\Media\\Roles\\UI-LFG-ICON-ROLES.blp") - self.tex:SetTexCoord(GetTexCoordsForRole(role)) + self.tex:SetTexCoord(getTextCoordsForRole(role)) elseif self.texture == "blizzard" then self.tex:SetTexture("Interface\\LFGFRAME\\UI-LFG-ICON-PORTRAITROLES.blp") - self.tex:SetTexCoord(GetTexCoordsForRoleSmallCircle(role)) + self.tex:SetTexCoord(getSmallTextCoordsForRole(role)) elseif self.texture == "blizzard2" then self.tex:SetTexture("Interface\\LFGFRAME\\UI-LFG-ICON-ROLES.blp") - self.tex:SetTexCoord(GetTexCoordsForRole(role)) + self.tex:SetTexCoord(getTextCoordsForRole(role)) elseif self.texture == "ffxiv" then self.tex:SetTexture("Interface\\AddOns\\Cell\\Media\\Roles\\FFXIV\\"..role) self.tex:SetTexCoord(0, 1, 0, 1) @@ -1677,7 +1706,7 @@ local function RoleIcon_SetRole(self, role) self.tex:SetTexCoord(0, 1, 0, 1) elseif self.texture == "mattui" then self.tex:SetTexture("Interface\\AddOns\\Cell\\Media\\Roles\\MattUI.blp") - self.tex:SetTexCoord(GetTexCoordsForRoleSmallCircle(role)) + self.tex:SetTexCoord(getSmallTextCoordsForRole(role)) elseif self.texture == "custom" then self.tex:SetTexture(self[role]) self.tex:SetTexCoord(0, 1, 0, 1) 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..a5f21d8c 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") @@ -447,7 +444,7 @@ local function ApplyClickCastings(b) end if t[2] == "spell" then - local spellName = GetSpellInfo(t[3]) or "" + local spellName = F:GetSpellNameAndIcon(t[3]) or "" -- NOTE: spell 在无效/过远的目标上会处于“等待选中目标”的状态,即鼠标指针有一圈灰色材质。用 macrotext 可以解决这个问题 -- NOTE: 但对于尸体状态(未释放)的目标,需要额外判断 @@ -481,20 +478,13 @@ local function ApplyClickCastings(b) end if (alwaysTargeting == "left" and bindKey == "type1") or alwaysTargeting == "any" then - b:SetAttribute(bindKey, "macro") - local attr = string.gsub(bindKey, "type", "macrotext") - b:SetAttribute(attr, "/tar ["..unit.."]\n/cast ["..unit..condition.."] "..spellName..sMaRt) + b:SetAttribute(bindKey, "spell") + local attr = string.gsub(bindKey, "type", "spell") + b:SetAttribute(attr, spellName) if not Cell.isRetail then UpdatePlaceholder(b, attr) end else - -- local attr = string.gsub(bindKey, "type", "spell") - -- b:SetAttribute(attr, spellName) - b:SetAttribute(bindKey, "macro") - local attr = string.gsub(bindKey, "type", "macrotext") - if F:IsSoulstone(spellName) then - b:SetAttribute(attr, "/tar ["..unit.."]\n/cast ["..unit.."] "..spellName.."\n/targetlasttarget") - else - b:SetAttribute(attr, "/cast ["..unit..condition.."] "..spellName..sMaRt) - end + local attr = string.gsub(bindKey, "type", "spell") + b:SetAttribute(attr, spellName) if not Cell.isRetail then UpdatePlaceholder(b, attr) end end elseif t[2] == "macro" then @@ -1022,7 +1012,7 @@ local function ShowActionsMenu(index, b) 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" @@ -1053,7 +1043,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 +1073,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 @@ -1304,7 +1294,7 @@ 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 diff --git a/Modules/Indicators.lua b/Modules/Indicators.lua index 3ca0d0d8..e25be0f7 100644 --- a/Modules/Indicators.lua +++ b/Modules/Indicators.lua @@ -224,7 +224,7 @@ local function InitIndicator(indicatorName) elseif indicatorName == "roleIcon" then indicator.tex:SetTexture("Interface\\AddOns\\Cell\\Media\\UI-LFG-ICON-PORTRAITROLES.blp") - indicator.tex:SetTexCoord(GetTexCoordsForRoleSmallCircle("DAMAGER")) + indicator.tex:SetTexCoord(20/64, 39/64, 22/64, 41/64) -- texture type cannot glow by LCG indicator.preview = indicator.preview or CreateFrame("Frame", nil, previewButton) indicator.preview:SetAllPoints(indicator) diff --git a/Modules/Layouts.lua b/Modules/Layouts.lua index eb15a760..8ee65058 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 = 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..09493a88 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 = 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: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..f73c09f3 100644 --- a/Modules/RaidDebuffs_Classic.lua +++ b/Modules/RaidDebuffs_Classic.lua @@ -815,7 +815,7 @@ local function RegisterForDrag(b) b:SetScript("OnDragStop", function(self) self:SetAlpha(1) dragged:Hide() - local newB = GetMouseFocus() + local newB = 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 diff --git a/RaidFrames/Groups/SpotlightFrame.lua b/RaidFrames/Groups/SpotlightFrame.lua index f6f28957..bc9b45ae 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 = 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/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/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..54b855f8 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 = 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 = 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 = 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..4ce5a0c7 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 = 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..321fc4f6 100644 --- a/Utils.lua +++ b/Utils.lua @@ -20,8 +20,7 @@ Cell.isCata = WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC ------------------------------------------------- -- 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 @@ -1412,7 +1436,6 @@ 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,36 +1509,60 @@ 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 + if Enum and Enum.SpellBookSpellBank then + return IsSpellInRange(spellIndex, unit) == 1 + end return IsSpellInRange(spellIndex, BOOKTYPE_SPELL, unit) == 1 end @@ -1525,9 +1572,9 @@ 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)) + spell_dead = FindSpellIndex(F:GetSpellNameAndIcon(361227)) + spell_alive = FindSpellIndex(F:GetSpellNameAndIcon(361469)) + spell_harm = FindSpellIndex(F:GetSpellNameAndIcon(361469)) end) -- NOTE: UnitInRange for evoker is around 50y @@ -1567,8 +1614,8 @@ if playerClass == "EVOKER" then else local spell_friend, spell_harm rc:SetScript("OnEvent", function() - spell_friend = FindSpellIndex(GetSpellInfo(friendSpells[playerClass])) - spell_harm = FindSpellIndex(GetSpellInfo(harmSpells[playerClass])) + spell_friend = FindSpellIndex(F:GetSpellNameAndIcon(friendSpells[playerClass])) + spell_harm = FindSpellIndex(F:GetSpellNameAndIcon(harmSpells[playerClass])) end) if Cell.isRetail then @@ -1581,8 +1628,7 @@ else 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) + local inRange, checked = UnitInRange(unit) if not checked then return F:IsInRange(unit, true) end @@ -1614,8 +1660,7 @@ else 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) + local inRange, checked = UnitInRange(unit) if not checked then return F:IsInRange(unit, true) end @@ -1626,14 +1671,14 @@ else if spell_friend then return UnitInSpellRange(spell_friend, unit) else - return IsItemInRange(friendItems[playerClass], unit) + return C_Item.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) + return C_Item.IsItemInRange(harmItems[playerClass], unit) end end diff --git a/Widgets/Widgets.lua b/Widgets/Widgets.lua index 102280b0..8418434c 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 = GetMouseFoci() if b then b = b:GetParent() end F:MoveClickCastings(parent.clickCastingIndex, b and b.clickCastingIndex) end) diff --git a/Widgets/Widgets_IndicatorSettings.lua b/Widgets/Widgets_IndicatorSettings.lua index 598512b4..33826281 100644 --- a/Widgets/Widgets_IndicatorSettings.lua +++ b/Widgets/Widgets_IndicatorSettings.lua @@ -3375,7 +3375,6 @@ local function CreateSetting_Texture(parent) return widget end -local GetSpellInfo = GetSpellInfo local function CreateAuraButtons(parent, auraButtons, auraTable, noUpDownButtons, isZeroValid, updateHeightFunc) local n = #auraTable @@ -3391,7 +3390,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 @@ -3419,7 +3418,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) @@ -3537,7 +3536,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 @@ -3553,7 +3552,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 @@ -3631,7 +3630,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) @@ -3701,7 +3700,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 @@ -3918,7 +3917,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() @@ -4078,7 +4077,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]) @@ -4097,7 +4096,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 @@ -4134,7 +4133,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) @@ -4278,7 +4277,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 @@ -4517,7 +4516,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 @@ -4545,7 +4544,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, { @@ -4676,7 +4675,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"]) @@ -4697,7 +4696,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 @@ -4729,7 +4728,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) From 5b332f2aac83d0c1f79b865fba4e0479ee461b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 00:34:29 +0200 Subject: [PATCH 02/14] Fix getspelltexture --- Widgets/Widgets.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Widgets/Widgets.lua b/Widgets/Widgets.lua index 8418434c..f657c3e8 100644 --- a/Widgets/Widgets.lua +++ b/Widgets/Widgets.lua @@ -3291,7 +3291,7 @@ function addon:CreateBindingListButton(parent, modifier, bindKey, bindType, bind spellIcon:Hide() function b:ShowSpellIcon(spell) - spellIcon:SetTexture(GetSpellTexture(spell) or 134400) + spellIcon:SetTexture(C_SPELL.GetSpellTexture(spell) or 134400) spellIconBg:Show() spellIcon:Show() -- actionGrid.text:ClearAllPoints() From f3202216b0cc370d1f97cf1682a5a3de551d4a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 00:35:06 +0200 Subject: [PATCH 03/14] no idea but this fails on hunter solo with pet --- Utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utils.lua b/Utils.lua index 321fc4f6..d327245c 100644 --- a/Utils.lua +++ b/Utils.lua @@ -1559,7 +1559,7 @@ end -- end local function UnitInSpellRange(spellIndex, unit) - if not spellIndex then return end + if not IsSpellInRange or not spellIndex then return end if Enum and Enum.SpellBookSpellBank then return IsSpellInRange(spellIndex, unit) == 1 end From 81f41f6c97ff3510654fb2ec7791905fb200f163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 19:43:45 +0200 Subject: [PATCH 04/14] Update remaining --- .snippets/ClickCastingTips.lua | 2 +- .snippets/GenericRaidDebuffs.lua | 4 +-- Defaults/ClickCasting_DefaultSpells.lua | 2 +- Defaults/Indicator_DefaultSpells_Cata.lua | 20 ++++++------ Defaults/Indicator_DefaultSpells_Vanilla.lua | 18 +++++------ Indicators/Consumables.lua | 2 +- Modules/ClickCastings.lua | 28 +++++++++++----- Modules/RaidDebuffs_Classic.lua | 13 ++++---- Revise.lua | 2 +- Utilities/BuffTracker_Cata.lua | 2 +- Utilities/BuffTracker_Vanilla.lua | 2 +- Utils.lua | 34 +------------------- Widgets/Widgets.lua | 2 +- 13 files changed, 55 insertions(+), 76 deletions(-) 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/Defaults/ClickCasting_DefaultSpells.lua b/Defaults/ClickCasting_DefaultSpells.lua index 8903bfae..5bcefa4a 100644 --- a/Defaults/ClickCasting_DefaultSpells.lua +++ b/Defaults/ClickCasting_DefaultSpells.lua @@ -410,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 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/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/Modules/ClickCastings.lua b/Modules/ClickCastings.lua index a5f21d8c..2dfceccb 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -399,6 +399,8 @@ 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) -- if t[2] == "spell" then @@ -443,7 +445,11 @@ local function ApplyClickCastings(b) b:SetAttribute(bindKey, t[2]) end - if t[2] == "spell" then + if Cell.isTWW 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 可以解决这个问题 @@ -476,16 +482,22 @@ local function ApplyClickCastings(b) end end end - + if (alwaysTargeting == "left" and bindKey == "type1") or alwaysTargeting == "any" then - b:SetAttribute(bindKey, "spell") - local attr = string.gsub(bindKey, "type", "spell") - b:SetAttribute(attr, spellName) + b:SetAttribute(bindKey, "macro") + local attr = string.gsub(bindKey, "type", "macrotext") + b:SetAttribute(attr, "/tar ["..unit.."]\n/cast ["..unit..condition.."] "..spellName..sMaRt) if not Cell.isRetail then UpdatePlaceholder(b, attr) end else - local attr = string.gsub(bindKey, "type", "spell") - b:SetAttribute(attr, spellName) - if not Cell.isRetail then UpdatePlaceholder(b, attr) end + -- local attr = string.gsub(bindKey, "type", "spell") + -- b:SetAttribute(attr, spellName) + b:SetAttribute(bindKey, "macro") + local attr = string.gsub(bindKey, "type", "macrotext") + if F:IsSoulstone(spellName) then + b:SetAttribute(attr, "/tar ["..unit.."]\n/cast ["..unit.."] "..spellName.."\n/targetlasttarget") + else + b:SetAttribute(attr, "/cast ["..unit..condition.."] "..spellName..sMaRt) + end end elseif t[2] == "macro" then local attr = string.gsub(bindKey, "type", "macrotext") diff --git a/Modules/RaidDebuffs_Classic.lua b/Modules/RaidDebuffs_Classic.lua index f73c09f3..15019255 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 @@ -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/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_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/Utils.lua b/Utils.lua index d327245c..582f0275 100644 --- a/Utils.lua +++ b/Utils.lua @@ -16,7 +16,7 @@ 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 ------------------------------------------------- @@ -1937,38 +1937,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 ------------------------------------------------- diff --git a/Widgets/Widgets.lua b/Widgets/Widgets.lua index f657c3e8..43bf8c24 100644 --- a/Widgets/Widgets.lua +++ b/Widgets/Widgets.lua @@ -3291,7 +3291,7 @@ function addon:CreateBindingListButton(parent, modifier, bindKey, bindType, bind spellIcon:Hide() function b:ShowSpellIcon(spell) - spellIcon:SetTexture(C_SPELL.GetSpellTexture(spell) or 134400) + spellIcon:SetTexture(C_Spell.GetSpellTexture(spell) or 134400) spellIconBg:Show() spellIcon:Show() -- actionGrid.text:ClearAllPoints() From 81da3377fc651fab73f1f55dcef654d88be92ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 19:58:25 +0200 Subject: [PATCH 05/14] compat --- Widgets/Widgets.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Widgets/Widgets.lua b/Widgets/Widgets.lua index 43bf8c24..02ea3baa 100644 --- a/Widgets/Widgets.lua +++ b/Widgets/Widgets.lua @@ -3291,7 +3291,7 @@ function addon:CreateBindingListButton(parent, modifier, bindKey, bindType, bind spellIcon:Hide() function b:ShowSpellIcon(spell) - spellIcon:SetTexture(C_Spell.GetSpellTexture(spell) or 134400) + spellIcon:SetTexture(select(2, F:GetSpellNameAndIcon(spell)) or 134400) spellIconBg:Show() spellIcon:Show() -- actionGrid.text:ClearAllPoints() From 97654b4932d3b96ee325371a7645941260960a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 20:17:18 +0200 Subject: [PATCH 06/14] Remove macrotext dependent options from settings --- Modules/ClickCastings.lua | 127 +++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 56 deletions(-) diff --git a/Modules/ClickCastings.lua b/Modules/ClickCastings.lua index 2dfceccb..11e99580 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -445,7 +445,7 @@ local function ApplyClickCastings(b) b:SetAttribute(bindKey, t[2]) end - if Cell.isTWW then + 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) @@ -482,7 +482,7 @@ local function ApplyClickCastings(b) end end end - + if (alwaysTargeting == "left" and bindKey == "type1") or alwaysTargeting == "any" then b:SetAttribute(bindKey, "macro") local attr = string.gsub(bindKey, "type", "macrotext") @@ -591,7 +591,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", @@ -601,8 +602,11 @@ local function CreateTargetingPane() alwaysTargeting = "disabled" Cell:Fire("UpdateClickCastings", true) end, - }, - { + } + } + + if not Cell.isTWW then + table.insert(items, { ["text"] = L["Left Spell"], ["value"] = "left", ["onClick"] = function() @@ -611,8 +615,8 @@ local function CreateTargetingPane() alwaysTargeting = "left" Cell:Fire("UpdateClickCastings", true) end, - }, - { + }) + table.insert(items, { ["text"] = L["Any Spells"], ["value"] = "any", ["onClick"] = function() @@ -621,8 +625,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 @@ -638,32 +643,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 + table.insert(items, + { + ["text"] = L["Normal"], + ["value"] = "normal", + ["onClick"] = function() + Cell.vars.clickCastings["smartResurrection"] = "normal" + Cell:Fire("UpdateClickCastings", true) + end, + } + ) + + table.insert(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 @@ -746,8 +759,10 @@ local function ShowTypesMenu(index, b) CheckChanges() b:HideSpellIcon() end, - }, - { + } + } + if not Cell.isTWW then + table.insert(items, { ["text"] = L["Macro"], ["onClick"] = function() b.typeGrid:SetText(L["Macro"]) @@ -768,31 +783,31 @@ local function ShowTypesMenu(index, b) CheckChanges() b:HideSpellIcon() end, - }, - { - ["text"] = L["Spell"], - ["onClick"] = function() - b.typeGrid:SetText(L["Spell"]) - if clickCastingsTab.popupEditBox then clickCastingsTab.popupEditBox:Hide() end - - changed[index] = changed[index] or {b} - -- check type - if b.bindType ~= "spell" then - changed[index]["bindType"] = "spell" - 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, - }, - } + }) + end + table.insert(items, { + ["text"] = L["Spell"], + ["onClick"] = function() + b.typeGrid:SetText(L["Spell"]) + if clickCastingsTab.popupEditBox then clickCastingsTab.popupEditBox:Hide() end + + changed[index] = changed[index] or {b} + -- check type + if b.bindType ~= "spell" then + changed[index]["bindType"] = "spell" + 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) P:ClearPoints(menu) From 82cc68f8259aa97d7f224bbf17176bcfeb6d7d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 20:33:37 +0200 Subject: [PATCH 07/14] Fix compatibility with GetMouseFoci --- Modules/Layouts.lua | 2 +- Modules/RaidDebuffs.lua | 2 +- Modules/RaidDebuffs_Classic.lua | 2 +- RaidFrames/Groups/SpotlightFrame.lua | 2 +- Utilities/QuickAssist_Config.lua | 6 +++--- Utilities/QuickCast.lua | 2 +- Utils.lua | 8 ++++++++ Widgets/Widgets.lua | 2 +- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Modules/Layouts.lua b/Modules/Layouts.lua index 8ee65058..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 = GetMouseFoci() + 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 09493a88..cd47349e 100644 --- a/Modules/RaidDebuffs.lua +++ b/Modules/RaidDebuffs.lua @@ -920,7 +920,7 @@ local function RegisterForDrag(b) b:SetScript("OnDragStop", function(self) self:SetAlpha(1) dragged:Hide() - local newB = GetMouseFoci() + 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 diff --git a/Modules/RaidDebuffs_Classic.lua b/Modules/RaidDebuffs_Classic.lua index 15019255..02e8d780 100644 --- a/Modules/RaidDebuffs_Classic.lua +++ b/Modules/RaidDebuffs_Classic.lua @@ -815,7 +815,7 @@ local function RegisterForDrag(b) b:SetScript("OnDragStop", function(self) self:SetAlpha(1) dragged:Hide() - local newB = GetMouseFoci() + 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 diff --git a/RaidFrames/Groups/SpotlightFrame.lua b/RaidFrames/Groups/SpotlightFrame.lua index bc9b45ae..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 = GetMouseFoci() + local f = F:GetMouseFoci() if f == WorldFrame then f = F:GetUnitButtonByGUID(UnitGUID("mouseover") or "") diff --git a/Utilities/QuickAssist_Config.lua b/Utilities/QuickAssist_Config.lua index 54b855f8..215c7554 100644 --- a/Utilities/QuickAssist_Config.lua +++ b/Utilities/QuickAssist_Config.lua @@ -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 = GetMouseFoci() + 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 = GetMouseFoci() + 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 = GetMouseFoci() + local b = F:GetMouseFoci() if b and b._class then local classToIndex = F:ConvertTable(layoutTable["order"]) -- print(self._class, "->", b._class) diff --git a/Utilities/QuickCast.lua b/Utilities/QuickCast.lua index 4ce5a0c7..923a378f 100644 --- a/Utilities/QuickCast.lua +++ b/Utilities/QuickCast.lua @@ -879,7 +879,7 @@ local function RegisterDrag(frame) return end - local f = GetMouseFoci() + 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) diff --git a/Utils.lua b/Utils.lua index 582f0275..21433ed7 100644 --- a/Utils.lua +++ b/Utils.lua @@ -2096,4 +2096,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 02ea3baa..fc55be32 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 = GetMouseFoci() + local b = F:GetMouseFoci() if b then b = b:GetParent() end F:MoveClickCastings(parent.clickCastingIndex, b and b.clickCastingIndex) end) From ffdc9c8a1514bf0ebf95f1a879b5ae9d6adcfebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 23:47:29 +0200 Subject: [PATCH 08/14] Fix range checks --- Utils.lua | 148 +++++++++++++++++++----------------------------------- 1 file changed, 53 insertions(+), 95 deletions(-) diff --git a/Utils.lua b/Utils.lua index 21433ed7..b20b936b 100644 --- a/Utils.lua +++ b/Utils.lua @@ -1435,7 +1435,6 @@ local UnitInRange = UnitInRange local UnitCanAssist = UnitCanAssist local UnitCanAttack = UnitCanAttack local UnitCanCooperate = UnitCanCooperate -local IsSpellInRange = IsSpellInRange local CheckInteractDistance = CheckInteractDistance local UnitIsDead = UnitIsDead local GetSpellTabInfo = GetSpellTabInfo @@ -1558,26 +1557,28 @@ end -- end -- end -local function UnitInSpellRange(spellIndex, unit) - if not IsSpellInRange or not spellIndex then return end - if Enum and Enum.SpellBookSpellBank then - return IsSpellInRange(spellIndex, unit) == 1 +local function UnitInSpellRange(spellName, unit) + if C_Spell and C_Spell.IsSpellInRange then + return C_Spell.IsSpellInRange(spellName, unit) end - return IsSpellInRange(spellIndex, BOOKTYPE_SPELL, unit) == 1 + 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(F:GetSpellNameAndIcon(361227)) - spell_alive = FindSpellIndex(F:GetSpellNameAndIcon(361469)) - spell_harm = FindSpellIndex(F:GetSpellNameAndIcon(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 @@ -1585,106 +1586,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 else - return UnitInSpellRange(spell_alive, unit) -- 25/30y + return UnitInSpellRange(spell_friend, unit) -- 25/30y 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(F:GetSpellNameAndIcon(friendSpells[playerClass])) - spell_harm = FindSpellIndex(F:GetSpellNameAndIcon(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 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 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 C_Item.IsItemInRange(friendItems[playerClass], 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 - end - - -- print("CheckInteractDistance", unit) - return CheckInteractDistance(unit, 4) -- 28 yards - end + -- print("CheckInteractDistance", unit) + return CheckInteractDistance(unit, 4) -- 28 yards end end end From e3f8f887dd7b6b83adcbf748c314e6b3508cd198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 23:54:01 +0200 Subject: [PATCH 09/14] comments --- Utils.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utils.lua b/Utils.lua index b20b936b..54b714c3 100644 --- a/Utils.lua +++ b/Utils.lua @@ -1596,9 +1596,9 @@ if Cell.isRetail then else if UnitCanAssist("player", unit) or UnitCanCooperate("player", unit) then 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_friend, unit) -- 25/30y + return UnitInSpellRange(spell_friend, unit) -- normal heal range end elseif UnitCanAttack("player", unit) then if spell_harm then From 8c5d923b03cec1abed61b3faf645f94900905ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Mon, 17 Jun 2024 22:31:53 +0200 Subject: [PATCH 10/14] update Toc --- Cell.toc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 55783365f5292a2d7452c82fa9a943c44158611f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Mon, 17 Jun 2024 23:08:32 +0200 Subject: [PATCH 11/14] Add click/item and macro --- Core.lua | 4 +- Modules/ClickCastings.lua | 239 ++++++++++++++++++++++++++++++-------- Widgets/Widgets.lua | 16 ++- 3 files changed, 204 insertions(+), 55 deletions(-) diff --git a/Core.lua b/Core.lua index 330fc45d..620badca 100644 --- a/Core.lua +++ b/Core.lua @@ -24,8 +24,8 @@ Cell.MIN_INDICATORS_VERSION = 228 Cell.MIN_DEBUFFS_VERSION = 228 Cell.MIN_QUICKASSIST_VERSION = 227 ---[==[@debug@ -local debugMode = true +--@debug@ +-- local debugMode = true --@end-debug@]==] function F:Debug(arg, ...) if debugMode then diff --git a/Modules/ClickCastings.lua b/Modules/ClickCastings.lua index 11e99580..e1710a5a 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -89,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 @@ -403,6 +409,10 @@ local function ClearClickCastings(b) 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) @@ -500,7 +510,15 @@ local function ApplyClickCastings(b) 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 @@ -540,7 +558,7 @@ local function UpdateClickCastings(noReload) -- load db and set attribute ApplyClickCastings(b) - end, false, true) + end, false, true, true) previousClickCastings = F:Copy(clickCastingTable) end Cell:RegisterCallback("UpdateClickCastings", "UpdateClickCastings", UpdateClickCastings) @@ -606,7 +624,7 @@ local function CreateTargetingPane() } if not Cell.isTWW then - table.insert(items, { + tinsert(items, { ["text"] = L["Left Spell"], ["value"] = "left", ["onClick"] = function() @@ -616,7 +634,7 @@ local function CreateTargetingPane() Cell:Fire("UpdateClickCastings", true) end, }) - table.insert(items, { + tinsert(items, { ["text"] = L["Any Spells"], ["value"] = "any", ["onClick"] = function() @@ -654,7 +672,7 @@ local function CreateSmartResPane() } } if not Cell.isTWW then - table.insert(items, + tinsert(items, { ["text"] = L["Normal"], ["value"] = "normal", @@ -665,7 +683,7 @@ local function CreateSmartResPane() } ) - table.insert(items, { + tinsert(items, { ["text"] = L["Normal + Combat Res"], ["value"] = "normal+combat", ["onClick"] = function() @@ -759,10 +777,7 @@ local function ShowTypesMenu(index, b) CheckChanges() b:HideSpellIcon() end, - } - } - if not Cell.isTWW then - table.insert(items, { + }, { ["text"] = L["Macro"], ["onClick"] = function() b.typeGrid:SetText(L["Macro"]) @@ -774,40 +789,84 @@ 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, - }) - end - table.insert(items, { - ["text"] = L["Spell"], - ["onClick"] = function() - b.typeGrid:SetText(L["Spell"]) - if clickCastingsTab.popupEditBox then clickCastingsTab.popupEditBox:Hide() end - - changed[index] = changed[index] or {b} - -- check type - if b.bindType ~= "spell" then - changed[index]["bindType"] = "spell" - 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, - }) + }, { + ["text"] = L["Spell"], + ["onClick"] = function() + b.typeGrid:SetText(L["Spell"]) + if clickCastingsTab.popupEditBox then clickCastingsTab.popupEditBox:Hide() end + + changed[index] = changed[index] or {b} + -- check type + if b.bindType ~= "spell" then + changed[index]["bindType"] = "spell" + 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, + }, { + ["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) P:ClearPoints(menu) @@ -916,8 +975,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) @@ -954,8 +1014,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} @@ -970,8 +1030,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} @@ -986,8 +1046,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} @@ -1002,8 +1062,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} @@ -1018,8 +1078,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} @@ -1034,8 +1094,8 @@ 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, { @@ -1055,6 +1115,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 = { @@ -1284,6 +1411,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 @@ -1328,6 +1459,12 @@ CreateBindingListButton = function(modifier, bindKey, bindType, bindAction, i) 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/Widgets/Widgets.lua b/Widgets/Widgets.lua index fc55be32..8feb63ac 100644 --- a/Widgets/Widgets.lua +++ b/Widgets/Widgets.lua @@ -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(select(2, F:GetSpellNameAndIcon(spell)) or 134400) + function b:ShowIcon(texture) + spellIcon:SetTexture(texture or 134400) spellIconBg:Show() spellIcon:Show() -- actionGrid.text:ClearAllPoints() @@ -3299,6 +3299,18 @@ function addon:CreateBindingListButton(parent, modifier, bindKey, bindType, bind -- actionGrid.text:SetPoint("RIGHT", P:Scale(-5), 0) end + function b:ShowSpellIcon(spell) + b:ShowIcon(select(2, F:GetSpellNameAndIcon(spell))) + 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() From 3e951bc27380c7c667f648f3f3d0721082106dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Tue, 18 Jun 2024 19:33:26 +0200 Subject: [PATCH 12/14] Fix nil in ShowSpellIcon --- Widgets/Widgets.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Widgets/Widgets.lua b/Widgets/Widgets.lua index 8feb63ac..754787e2 100644 --- a/Widgets/Widgets.lua +++ b/Widgets/Widgets.lua @@ -3300,7 +3300,11 @@ function addon:CreateBindingListButton(parent, modifier, bindKey, bindType, bind end function b:ShowSpellIcon(spell) - b:ShowIcon(select(2, F:GetSpellNameAndIcon(spell))) + local icon = nil + if spell then + icon = select(2, F:GetSpellNameAndIcon(spell)) + end + b:ShowIcon(icon) end function b:ShowItemIcon(itemslot) From 7254832a607227811cc9d9cffa8024178f11f398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Tue, 18 Jun 2024 19:33:41 +0200 Subject: [PATCH 13/14] typo --- Modules/RaidDebuffs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/RaidDebuffs.lua b/Modules/RaidDebuffs.lua index cd47349e..f67e7de7 100644 --- a/Modules/RaidDebuffs.lua +++ b/Modules/RaidDebuffs.lua @@ -2092,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:F:GetSpellNameAndIcon(spellId))) + -- SetSpellDesc(select(3, F:GetSpellNameAndIcon(spellId))) -- end) local isEnabled = selectedButtonIndex <= #currentBossTable["enabled"] From 815005ce53fcc494e5bec4063239dc2ecb90adb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Tue, 18 Jun 2024 21:53:20 +0200 Subject: [PATCH 14/14] Use ClickCastFrames global --- Core.lua | 24 ++++++++++++++++++++++++ Modules/ClickCastings.lua | 32 +++++++++++++++++++++----------- Utils.lua | 17 ++++++++++++++++- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/Core.lua b/Core.lua index 620badca..3ce50517 100644 --- a/Core.lua +++ b/Core.lua @@ -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/Modules/ClickCastings.lua b/Modules/ClickCastings.lua index e1710a5a..7cd5bcd8 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -524,7 +524,7 @@ local function ApplyClickCastings(b) 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] @@ -547,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, 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 ------------------------------------------------- diff --git a/Utils.lua b/Utils.lua index 54b714c3..c302199f 100644 --- a/Utils.lua +++ b/Utils.lua @@ -803,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