Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated Queue #3092

Draft
wants to merge 1 commit into
base: dragonflight
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions AnimatedQueue/ActionButton.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
local _, addon = ...

local OutQuart = addon.Easing.OutQuart;

local GetSpellInfo = GetSpellInfo;
local GetSpellTexture = GetSpellTexture;
local UnitCastingInfo = UnitCastingInfo;
local UnitChannelInfo = UnitChannelInfo;
local GetSpellLossOfControlCooldown = GetSpellLossOfControlCooldown;
local GetSpellCooldown = GetSpellCooldown;
local GetSpellCharges = GetSpellCharges;
local GetTime = GetTime;
local GetCooldownAuraBySpellID = C_UnitAuras.GetCooldownAuraBySpellID;
local GetPlayerAuraBySpellID = C_UnitAuras.GetPlayerAuraBySpellID;

local ANIM_DURATION_PUSH_DOWN = 0.25;
local PUSH_DOWN_OFFSET = -8;


AnimatedQueueActionMixin = {};

function AnimatedQueueActionMixin:OnLoad()

end

local function AnimOnUpdate_FadeInIcon(self, elapsed)
self.iconAlpha = self.iconAlpha + 5*elapsed;
if self.iconAlpha >= 1 then
self.iconAlpha = 1;
self:SetScript("OnUpdate", nil);
end
self.Icon:SetAlpha(self.iconAlpha);
end

local function AnimOnUpdate_FadeOutIcon(self, elapsed)
self.iconAlpha = self.iconAlpha - 10*elapsed;
if self.iconAlpha <= 0 then
self.iconAlpha = 0;
self.Icon:SetTexture(self.icon);
self:SetScript("OnUpdate", AnimOnUpdate_FadeInIcon);
end
self.Icon:SetAlpha(self.iconAlpha);
end

function AnimatedQueueActionMixin:SetIcon(icon, fade)
if fade then
if icon ~= self.icon then
self.icon = icon;
self.iconAlpha = self.Icon:GetAlpha();
self:SetScript("OnUpdate", AnimOnUpdate_FadeOutIcon);
end
else
self.Icon:SetTexture(icon);
self:SetScript("OnUpdate", nil);
end
end

function AnimatedQueueActionMixin:UpdateCooldown()
if self.order == 1 then
self.Cooldown:Clear();
return
end

local passiveCooldownSpellID, auraData;

if self.spellID then
passiveCooldownSpellID = GetCooldownAuraBySpellID(self.spellID);
end

if passiveCooldownSpellID and passiveCooldownSpellID ~= 0 then
auraData = GetPlayerAuraBySpellID(passiveCooldownSpellID);
end

local start, duration, enable, modRate, locStart, locDuration, charges, maxCharges, chargeStart, chargeDuration, chargeModRate, forceShowDrawEdge, endTime;

if auraData then
local currentTime = GetTime();
endTime = auraData.expirationTime;
local timeUntilExpire = endTime - currentTime;
local howMuchTimeHasPassed = auraData.duration - timeUntilExpire;
locStart = currentTime - howMuchTimeHasPassed;
locDuration = endTime - currentTime;
start = currentTime - howMuchTimeHasPassed;
duration = auraData.duration
modRate = auraData.timeMod;
charges = auraData.charges;
maxCharges = auraData.maxCharges;
chargeStart = currentTime * 0.001;
chargeDuration = duration * 0.001;
chargeModRate = modRate;
enable = 1;
elseif self.spellID then
locStart, locDuration = GetSpellLossOfControlCooldown(self.spellID);
start, duration, enable, modRate = GetSpellCooldown(self.spellID);
charges, maxCharges, chargeStart, chargeDuration, chargeModRate = GetSpellCharges(self.spellID);
endTime = start + duration;
end

if (locStart + locDuration) > (start + duration) then
start, duration = locStart, locDuration;
forceShowDrawEdge = true;
else
if ( charges and maxCharges and maxCharges > 1 and charges == 0 ) then
start, duration, modRate = chargeStart, chargeDuration, chargeModRate;
else
--ClearChargeCooldown(self);
end
forceShowDrawEdge = false;
end

if self.isPrimary then
local startTimeMS, endTimeMS = select(4, UnitCastingInfo( "player" ));
if not startTimeMS then
startTimeMS, endTimeMS = select(4, UnitChannelInfo( "player" ));
end
if startTimeMS and endTimeMS then
local currentCastStartTime = startTimeMS * 0.001;
local currentCastEndTime = endTimeMS * 0.001;
if currentCastEndTime > endTime then
start = currentCastStartTime;
duration = currentCastEndTime - currentCastStartTime;
end
end
end

if enable and enable ~= 0 and start > 0 and duration > 0 then
self.Cooldown:SetDrawEdge(forceShowDrawEdge);
self.Cooldown:SetCooldown(start, duration, modRate);
else
self.Cooldown:Clear();
end
end

function AnimatedQueueActionMixin:SetSpell(spellID)
if spellID ~= self.spellID then
self.spellID = spellID;
local icon = GetSpellTexture(spellID);
self:SetIcon(icon, true);
end

self:UpdateCooldown();
end

function AnimatedQueueActionMixin:SetAbility(ability)
--Hekili ability ("local ability = class.abilities[ action ]" in Hekili\Core.lua)
if ability then
--if ability.gcd == "spell" then
-- self:SetSpell(ability.id);
--end
self:SetSpell(ability.id);
self.HotKey:SetText(ability.keybind);
else
self:ClearAction();
end
end

function AnimatedQueueActionMixin:ClearAction()
self.spellID = nil;
self.itemID = nil;
self.HotKey:SetText(nil);
end

function AnimatedQueueActionMixin:SetIconSize(side)
self.Icon:SetSize(side, side);
self.Cooldown:SetSize(side, side);
end
109 changes: 109 additions & 0 deletions AnimatedQueue/AnimatedQueue.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
<Script file="Easing.lua"/>
<Script file="ActionButton.lua"/>
<Script file="Core.lua"/>

<Frame name="AnimatedQueueActionTemplate" mixin="AnimatedQueueActionMixin" virtual="true">
<Size x="45" y="45"/>
<Frames>
<Frame parentKey="Reference">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
</Frame>
<Cooldown parentKey="Cooldown" hidden="true">
<SwipeTexture>
<Color r="0" g="0" b="0" a="0.85"/>
</SwipeTexture>
<EdgeTexture file="Interface\Cooldown\edge"/>
<BlingTexture file="Interface\Cooldown\star4">
<Color r="0.3" g="0.6" b="1" a="0.8"/>
</BlingTexture>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
<Size x="45" y="45"/>
</Cooldown>
</Frames>
<Layers>
<Layer level="BACKGROUND" textureSubLevel="1">
<Texture parentKey="Icon">
<TexCoords left="0.075" right="0.925" top="0.075" bottom="0.925"/>
<Size x="45" y="45"/>
<Anchors>
<Anchor point="CENTER" relativeKey="$parent.Reference" relativePoint="CENTER" x="0" y="0"/>
</Anchors>
</Texture>
</Layer>
<Layer level="BORDER">
<Texture parentKey="Border" snapToPixelGrid="true" texelSnappingBias="0" file="Interface\AddOns\Hekili\AnimatedQueue\Art\Border-Square-GradientStroke">
<TextureSliceMargins left="4" right="4" top="4" bottom="4"/>
<TextureSliceMode mode="Stretched"/>
<Anchors>
<Anchor point="TOPLEFT" relativeKey="$parent.Icon" relativePoint="TOPLEFT" x="0" y="0"/>
<Anchor point="BOTTOMRIGHT" relativeKey="$parent.Icon" relativePoint="BOTTOMRIGHT" x="0" y="0"/>
</Anchors>
</Texture>
</Layer>
<Layer level="OVERLAY">
<FontString parentKey="HotKey" inherits="NumberFontNormalSmallGray" justifyH="RIGHT">
<Color r="0.9" g="0.9" b="0.9"/>
<Anchors>
<Anchor point="TOPRIGHT" x="-2" y="-4"/>
</Anchors>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnLoad method="OnLoad"/>
</Scripts>
</Frame>

<Frame name="AnimatedQueueFrame" mixin="AnimatedQueueFrameMixin" parent="UIParent" frameStrata="LOW">
<Size x="45" y="45"/>
<Anchors>
<Anchor point="CENTER" relativeKey="$parent" relativePoint="CENTER" x="0" y="-196"/>
</Anchors>
<Frames>
<Frame parentKey="ActionContainer">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="CENTER" relativeKey="$parent" relativePoint="CENTER" x="0" y="0"/>
</Anchors>
</Frame>
<Frame parentKey="HighlightFrame">
<Size x="45" y="45"/>
<Anchors>
<Anchor point="CENTER" relativeKey="$parent" relativePoint="CENTER" x="0" y="0"/>
</Anchors>
<Layers>
<Layer level="ARTWORK" textureSubLevel="1">
<Texture parentKey="Icon" setAllPoints="true">
<TexCoords left="0.075" right="0.925" top="0.075" bottom="0.925"/>
</Texture>
</Layer>
<Layer level="OVERLAY">
<Texture parentKey="GlowBorder" setAllPoints="true" snapToPixelGrid="true" texelSnappingBias="0" file="Interface\AddOns\Hekili\AnimatedQueue\Art\Border-Square-Highlight-Blue" alpha="0">
<TextureSliceMargins left="16" right="16" top="16" bottom="16"/>
<TextureSliceMode mode="Stretched"/>
</Texture>
</Layer>
</Layers>
<Animations>
<AnimationGroup parentKey="AnimGlow" setToFinalAlpha="true">
<Alpha startDelay="0" fromAlpha="0" toAlpha="1" duration="0.05" childKey="GlowBorder" order="1"/>
<Alpha fromAlpha="1" toAlpha="0" duration="0.2" childKey="GlowBorder" order="2"/>

<Alpha startDelay="0" fromAlpha="1" toAlpha="1" duration="0.05" childKey="Icon" order="1"/>
<Scale startDelay="0" scaleX="0.9" scaleY="0.9" duration="0.05" childKey="Icon" order="1"/>
<Alpha fromAlpha="1" toAlpha="0" duration="0.2" childKey="Icon" order="2"/>
</AnimationGroup>
</Animations>
</Frame>
</Frames>
<Scripts>
<OnLoad method="OnLoad"/>
</Scripts>
</Frame>
</Ui>
Binary file not shown.
Binary file not shown.
Loading