-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactor to use ACTION_RANGE_CHECK_UPDATE
- Loading branch information
Showing
12 changed files
with
975 additions
and
556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.