-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,34 @@ | ||
local F, C = unpack(select(2, ...)) | ||
local UNITFRAME = F:GetModule('UnitFrame') | ||
|
||
local function OnUpdate(self) | ||
local start, duration = GetSpellCooldown(61304) | ||
if start > 0 and duration > 0 then | ||
if self.duration ~= duration then | ||
self:SetMinMaxValues(0, duration) | ||
self.duration = duration | ||
end | ||
self:SetValue(GetTime() - start) | ||
self.spark:Show() | ||
else | ||
self.spark:Hide() | ||
end | ||
end | ||
|
||
function UNITFRAME:CreateGCDTicker(self) | ||
local bar = CreateFrame('StatusBar', nil, self) | ||
bar:SetFrameLevel(self.Health:GetFrameLevel() + 1) | ||
bar:SetStatusBarTexture(C.Assets.Texture.Backdrop) | ||
bar:GetStatusBarTexture():SetAlpha(0) | ||
bar:SetAllPoints() | ||
|
||
local spark = bar:CreateTexture(nil, 'OVERLAY') | ||
spark:SetTexture(C.Assets.Texture.Spark) | ||
spark:SetBlendMode('ADD') | ||
spark:SetPoint('TOPLEFT', bar:GetStatusBarTexture(), 'TOPRIGHT', -10, 10) | ||
spark:SetPoint('BOTTOMRIGHT', bar:GetStatusBarTexture(), 'BOTTOMRIGHT', 10, -10) | ||
bar.spark = spark | ||
bar.spark = bar:CreateTexture(nil, 'OVERLAY') | ||
bar.spark:SetTexture(C.Assets.Texture.Spark) | ||
bar.spark:SetBlendMode('ADD') | ||
bar.spark:SetPoint('TOPLEFT', bar:GetStatusBarTexture(), 'TOPRIGHT', -10, 10) | ||
bar.spark:SetPoint('BOTTOMRIGHT', bar:GetStatusBarTexture(), 'BOTTOMRIGHT', 10, -10) | ||
|
||
bar:SetScript('OnUpdate', OnUpdate) | ||
self.GCDTicker = bar | ||
self.GCD = bar | ||
end | ||
|
||
function UNITFRAME:UpdateGCDTicker() | ||
local player = _G.oUF_Player | ||
local bar = player and player.GCDTicker | ||
if not bar then | ||
return | ||
local frame = _G.oUF_Player | ||
if C.DB.Unitframe.GCDIndicator then | ||
if not frame:IsElementEnabled('GCD') then | ||
frame:EnableElement('GCD') | ||
if frame.GCD then | ||
frame.GCD:ForceUpdate() | ||
end | ||
end | ||
else | ||
if frame:IsElementEnabled('GCD') then | ||
frame:DisableElement('GCD') | ||
end | ||
end | ||
|
||
bar:SetShown(C.DB.Unitframe.GCDIndicator) | ||
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,62 @@ | ||
local F = unpack(select(2, ...)) | ||
local oUF = F.Libs.oUF | ||
|
||
local function Update(self, event, unit) | ||
local spark = self.spark | ||
local start, duration = GetSpellCooldown(61304) | ||
if start > 0 and duration > 0 then | ||
if self.duration ~= duration then | ||
self:SetMinMaxValues(0, duration) | ||
self.duration = duration | ||
end | ||
self:SetValue(GetTime() - start) | ||
|
||
if spark then | ||
self.spark:Show() | ||
end | ||
else | ||
if spark then | ||
self.spark:Hide() | ||
end | ||
end | ||
end | ||
|
||
local function Path(self, ...) | ||
return (self.GCD.Override or Update)(self, ...) | ||
end | ||
|
||
local function ForceUpdate(element) | ||
return Path(element.__owner, 'ForceUpdate', element.__owner.unit) | ||
end | ||
|
||
local function Enable(self, unit) | ||
local element = self.GCD | ||
if (element and UnitIsUnit(unit, 'player')) then | ||
element.__owner = self | ||
element.ForceUpdate = ForceUpdate | ||
|
||
element:SetScript('OnUpdate', Update) | ||
|
||
if (element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then | ||
element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) | ||
end | ||
|
||
local spark = element.spark | ||
if (spark and spark:IsObjectType('Texture') and not spark:GetTexture()) then | ||
spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]]) | ||
end | ||
|
||
element:Show() | ||
|
||
return true | ||
end | ||
end | ||
|
||
local function Disable(self) | ||
local element = self.GCD | ||
if (element) then | ||
element:Hide() | ||
end | ||
end | ||
|
||
oUF:AddElement('GCD', Path, Enable, Disable) |
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