Skip to content

Commit

Permalink
Major refactor to use ACTION_RANGE_CHECK_UPDATE
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed May 21, 2023
1 parent 6879d03 commit 93cb568
Show file tree
Hide file tree
Showing 12 changed files with 975 additions and 556 deletions.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# tullaRange release notes

## 10.1.5

* Note: This version does not work on 10.1.0 realms (aka Retail)
* (WoW 10.1.5) Rebuilt using the new ACTION_RANGE_CHECK_UPDATE event
* (WoW 3.4.2) Fixed an error when loading the settings UI
* Hotkeys are now colored red when an action is out of range, and white otherwise.
* Pet actions now implement out of mana coloring

## 10.1.0

* Update TOCs for World of Warcraft 10.1.0
Expand Down
55 changes: 55 additions & 0 deletions tullaRange/actionState.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--------------------------------------------------------------------------------
-- shared functions between the different implementations
--------------------------------------------------------------------------------

local _, Addon = ...

local function isUsuableAction(slot)
local actionType, id = GetActionInfo(slot)

if actionType == "macro" then
-- for macros with names that start with a #, we prioritize the OOM
-- check using a spell cost strategy over other ones to better
-- clarify if the macro is actually usable or not
local name = GetMacroInfo(id)

if name and name:sub(1, 1) == "#" then
local spellID = GetMacroSpell(id)

-- only run the check for spell macros
if spellID then
local costs = GetSpellPowerCost(spellID)
for i = 1, #costs do
local cost = costs[i]

if UnitPower("player", cost.type) < cost.minCost then
return false, false
end
end
end
end
end

return IsUsableAction(slot)
end

function Addon.GetActionState(slot)
local usable, oom = isUsuableAction(slot)
local oor = IsActionInRange(slot) == false

return usable and not oor, oom, oor
end

function Addon.GetPetActionState(slot)
local _, _, _, _, _, _, spellID, checksRange, inRange = GetPetActionInfo(slot)
local oor = checksRange and not inRange

if spellID then
local _, oom = IsUsableSpell(spellID)
if oom then
return false, oom, oor
end
end

return (not oor) and GetPetActionSlotUsable(slot), false, oor
end
53 changes: 53 additions & 0 deletions tullaRange/attackFlash.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
--------------------------------------------------------------------------------
-- A reimplementation of the attack flash animation
--
-- The stock UI uses an OnUpdate handler for this. Ths version is implemented
-- using animations to be a bit more performant
--------------------------------------------------------------------------------

local _, Addon = ...

local flashAnimations = {}

local function startFlashing(button)
local animation = flashAnimations[button]

if not animation then
animation = button.Flash:CreateAnimationGroup()
animation:SetLooping("BOUNCE")

local alpha = animation:CreateAnimation("ALPHA")
alpha:SetDuration(Addon:GetFlashDuration())
alpha:SetFromAlpha(0)
alpha:SetToAlpha(0.7)
alpha.owner = button

flashAnimations[button] = animation
end

button.Flash:Show()
animation:Play()
end

local function stopFlashing(button)
local animation = flashAnimations[button]

if animation then
animation:Stop()
button.Flash:Hide()
end
end

function Addon.StartAttackAnimation(button)
if button:IsVisible() then
startFlashing(button)
end
end

function Addon.UpdateAttackAnimation(button)
if (button.flashing == 1 or button.flashing == true) and button:IsVisible() then
startFlashing(button)
else
stopFlashing(button)
end
end
Loading

0 comments on commit 93cb568

Please sign in to comment.