diff --git a/mods/no-toggle.lua b/mods/no-toggle.lua index 0d15e25..ec35a5a 100644 --- a/mods/no-toggle.lua +++ b/mods/no-toggle.lua @@ -12,6 +12,10 @@ local module = ShaguTweaks:register({ }) module.enable = function(self) + -- This fork requires ClassicAPI. Do not retain the old tooltip/action-name + -- scanners when the engine can identify auto-attack actions directly. + if not API or not API.autoattack or not API.autoattackbook or not API.actioninfo then return end + local attacking, shooting local attackNames = { @@ -22,13 +26,13 @@ module.enable = function(self) } local function AddAttackName(spellID, attackType) - if not API or not API.GetSpellInfo then return end local name = API.GetSpellInfo(spellID) if name then attackNames[strlower(name)] = attackType end end - -- Add the current client's localized spell names while retaining the - -- original English aliases for the legacy fallback. + -- CastSpellByName still receives text rather than a spellbook/action ID. + -- Resolve the localized names once through ClassicAPI while retaining the + -- common English aliases used by macros and third-party addons. AddAttackName(6603, "melee") AddAttackName(75, "ranged") AddAttackName(5019, "ranged") @@ -55,18 +59,14 @@ module.enable = function(self) end local function activeSpell(spellID) - if not API or not API.autoattack or not spellID then return false end + if not spellID then return false end return (API.IsAutoAttackSpell(spellID) and attacking) or (API.IsRangedAutoAttackSpell(spellID) and shooting) end local function activeSpellBook(index, booktype) - if API and API.autoattackbook then - return (API.IsAutoAttackSpellBookItem(index, booktype) and attacking) or - (API.IsRangedAutoAttackSpellBookItem(index, booktype) and shooting) - end - - return activeName(GetSpellName(index, booktype)) + return (API.IsAutoAttackSpellBookItem(index, booktype) and attacking) or + (API.IsRangedAutoAttackSpellBookItem(index, booktype) and shooting) end local origCastSpell = CastSpell @@ -82,31 +82,10 @@ module.enable = function(self) return origCastSpellByName(text, onself) end - local tt - local function GetLegacyTooltip() - if tt then return tt end - tt = CreateFrame("GameTooltip", "ShaguTweaksNoToggleTT", nil, "GameTooltipTemplate") - tt:SetOwner(UIParent, "ANCHOR_NONE") - return tt - end - local origUseAction = UseAction function _G.UseAction(slot, clicked, onself) - if API and API.actioninfo and API.autoattack then - local actionType, spellID = API.GetActionInfo(slot) - if actionType == "spell" and activeSpell(spellID) then return end - if actionType then return origUseAction(slot, clicked, onself) end - end - - -- Legacy clients have no action descriptor API. Keep the tooltip scan as - -- a fallback only, instead of paying for it on every spell/item action. - if HasAction(slot) and not GetActionText(slot) then - local tt = GetLegacyTooltip() - tt:SetOwner(UIParent, "ANCHOR_NONE") - tt:SetAction(slot) - local label = _G["ShaguTweaksNoToggleTTTextLeft1"] - if label and activeName(label:GetText()) then return end - end + local actionType, spellID = API.GetActionInfo(slot) + if actionType == "spell" and activeSpell(spellID) then return end return origUseAction(slot, clicked, onself) end end