mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Fix action button glow and state checks to use tooltip fallback
Previously, action button state functions (IsCurrentAction, IsActionInRange, IsUsableAction, ActionHasRange, GetActionCount, IsConsumableAction) only checked the active action, not the tooltip action. This caused issues when using #showtooltip without conditionals, or when no conditionals matched: - No glow on buttons even when the ability was queued/active - Incorrect range/usability indicators - Missing item counts for consumables Now all these functions use the same priority as GetActionTexture and GetActionCooldown: check the active action first, then fall back to the tooltip action. This ensures button states match the displayed icon. Fixes issues with abilities like Cleave and Heroic Strike not showing glow when queued, and ensures all action button visuals are consistent.
This commit is contained in:
@@ -2367,8 +2367,10 @@ end
|
||||
CleveRoids.Hooks.ActionHasRange = ActionHasRange
|
||||
function ActionHasRange(slot)
|
||||
local actions = CleveRoids.GetAction(slot)
|
||||
if actions and actions.active then
|
||||
return (1 and actions.active.inRange ~= -1 or nil)
|
||||
-- Use the same priority as GetActionTexture: active first, then tooltip
|
||||
local actionToCheck = (actions and actions.active) or (actions and actions.tooltip)
|
||||
if actionToCheck then
|
||||
return (1 and actionToCheck.inRange ~= -1 or nil)
|
||||
else
|
||||
return CleveRoids.Hooks.ActionHasRange(slot)
|
||||
end
|
||||
@@ -2377,8 +2379,10 @@ end
|
||||
CleveRoids.Hooks.IsActionInRange = IsActionInRange
|
||||
function IsActionInRange(slot, unit)
|
||||
local actions = CleveRoids.GetAction(slot)
|
||||
if actions and actions.active and actions.active.type == "spell" then
|
||||
return actions.active.inRange
|
||||
-- Use the same priority as GetActionTexture: active first, then tooltip
|
||||
local actionToCheck = (actions and actions.active) or (actions and actions.tooltip)
|
||||
if actionToCheck and actionToCheck.type == "spell" then
|
||||
return actionToCheck.inRange
|
||||
else
|
||||
return CleveRoids.Hooks.IsActionInRange(slot, unit)
|
||||
end
|
||||
@@ -2388,8 +2392,10 @@ CleveRoids.Hooks.OriginalIsUsableAction = IsUsableAction
|
||||
CleveRoids.Hooks.IsUsableAction = IsUsableAction
|
||||
function IsUsableAction(slot, unit)
|
||||
local actions = CleveRoids.GetAction(slot)
|
||||
if actions and actions.active then
|
||||
return actions.active.usable, actions.active.oom
|
||||
-- Use the same priority as GetActionTexture: active first, then tooltip
|
||||
local actionToCheck = (actions and actions.active) or (actions and actions.tooltip)
|
||||
if actionToCheck then
|
||||
return actionToCheck.usable, actionToCheck.oom
|
||||
else
|
||||
return CleveRoids.Hooks.IsUsableAction(slot, unit)
|
||||
end
|
||||
@@ -2397,17 +2403,20 @@ end
|
||||
|
||||
CleveRoids.Hooks.IsCurrentAction = IsCurrentAction
|
||||
function IsCurrentAction(slot)
|
||||
local active = CleveRoids.GetActiveAction(slot)
|
||||
local actions = CleveRoids.GetAction(slot)
|
||||
|
||||
if not active then
|
||||
-- Use the same priority as GetActionTexture: active first, then tooltip
|
||||
local actionToCheck = (actions and actions.active) or (actions and actions.tooltip)
|
||||
|
||||
if not actionToCheck then
|
||||
return CleveRoids.Hooks.IsCurrentAction(slot)
|
||||
else
|
||||
local name
|
||||
if active.spell then
|
||||
local rank = active.spell.rank or active.spell.highest.rank
|
||||
name = active.spell.name..(rank and ("("..rank..")"))
|
||||
elseif active.item then
|
||||
name = active.item.name
|
||||
if actionToCheck.spell then
|
||||
local rank = actionToCheck.spell.rank or actionToCheck.spell.highest.rank
|
||||
name = actionToCheck.spell.name..(rank and ("("..rank..")"))
|
||||
elseif actionToCheck.item then
|
||||
name = actionToCheck.item.name
|
||||
end
|
||||
|
||||
return CleveRoids.Hooks.IsCurrentAction(CleveRoids.GetProxyActionSlot(name) or slot)
|
||||
@@ -2534,28 +2543,30 @@ CleveRoids.Hooks.GetActionCount = GetActionCount
|
||||
function GetActionCount(slot)
|
||||
local action = CleveRoids.GetAction(slot)
|
||||
local count
|
||||
if action and action.active then
|
||||
-- Use the same priority as GetActionTexture: active first, then tooltip
|
||||
local actionToCheck = (action and action.active) or (action and action.tooltip)
|
||||
if actionToCheck then
|
||||
|
||||
local slotId = tonumber(action.active.action)
|
||||
local slotId = tonumber(actionToCheck.action)
|
||||
if slotId and slotId >= 1 and slotId <= 19 then
|
||||
return GetInventoryItemCount("player", slotId)
|
||||
end
|
||||
|
||||
if action.active.item then
|
||||
count = action.active.item.count
|
||||
if actionToCheck.item then
|
||||
count = actionToCheck.item.count
|
||||
|
||||
elseif action.active.spell then
|
||||
local reagent = action.active.spell.reagent
|
||||
elseif actionToCheck.spell then
|
||||
local reagent = actionToCheck.spell.reagent
|
||||
if not reagent then
|
||||
local ss, bt = action.active.spell.spellSlot, action.active.spell.bookType
|
||||
local ss, bt = actionToCheck.spell.spellSlot, actionToCheck.spell.bookType
|
||||
if ss and bt then
|
||||
local _, r = CleveRoids.GetSpellCost(ss, bt)
|
||||
reagent = r
|
||||
end
|
||||
if (not reagent) and _ReagentBySpell and action.active.spell.name then
|
||||
reagent = _ReagentBySpell[action.active.spell.name] -- e.g., Vanish → Flash Powder
|
||||
if (not reagent) and _ReagentBySpell and actionToCheck.spell.name then
|
||||
reagent = _ReagentBySpell[actionToCheck.spell.name] -- e.g., Vanish → Flash Powder
|
||||
end
|
||||
action.active.spell.reagent = reagent -- cache it so we don’t re-scan every frame
|
||||
actionToCheck.spell.reagent = reagent -- cache it so we don't re-scan every frame
|
||||
end
|
||||
if reagent then
|
||||
count = CleveRoids.GetReagentCount(reagent) -- id-first bag scan, falls back to name/tooltip
|
||||
@@ -2569,23 +2580,25 @@ end
|
||||
CleveRoids.Hooks.IsConsumableAction = IsConsumableAction
|
||||
function IsConsumableAction(slot)
|
||||
local action = CleveRoids.GetAction(slot)
|
||||
if action and action.active then
|
||||
-- Use the same priority as GetActionTexture: active first, then tooltip
|
||||
local actionToCheck = (action and action.active) or (action and action.tooltip)
|
||||
if actionToCheck then
|
||||
|
||||
local slotId = tonumber(action.active.action)
|
||||
local slotId = tonumber(actionToCheck.action)
|
||||
if slotId and slotId >= 1 and slotId <= 19 then
|
||||
local _, count = GetInventoryItemCount("player", slotId)
|
||||
if count and count > 0 then return 1 end
|
||||
end
|
||||
|
||||
if action.active.item and
|
||||
(CleveRoids.countedItemTypes[action.active.item.type]
|
||||
or CleveRoids.countedItemTypes[action.active.item.name])
|
||||
if actionToCheck.item and
|
||||
(CleveRoids.countedItemTypes[actionToCheck.item.type]
|
||||
or CleveRoids.countedItemTypes[actionToCheck.item.name])
|
||||
then
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
if action.active.spell and action.active.spell.reagent then
|
||||
if actionToCheck.spell and actionToCheck.spell.reagent then
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user