WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Adding a gcd spark to a castbar (https://www.wowinterface.com/forums/showthread.php?t=39006)

Pyrates 02-20-11 02:18 PM

Adding a gcd spark to a castbar
 
Hey there!

I'm trying to add a gcd spark to my castbar. Up to now, I've been using ouf_gcd by hungtar, but he discontinued support, and it stopped working (I guess because of the ouf update). Can anyone tell me how to do that now?

Dawn 02-20-11 03:33 PM

Have you tried to look at how he did it and tried to adept it right into your layout? :)

Pyrates 02-20-11 04:07 PM

There are two problem with that: First it adds a separate bar, which I'm trying to avoid now (I want that spark inside the usual cast bar). Second, I don't really understand how. oUF_gcd adds a new element, and I can use elements (well, some), but I don't know how to make an element work in my layout that does not work because it's not compatible with the new ouf (that's what I assume... there are actually no lua errors).

Doesn't mean I'd not try to, if that's the only way (I kinda assumed that ouf itself brings something to have a gcd spark). oUF_gcd is simple enough for me to basically understand what's going on, but I have no idea how to diagnose the problem, since there is no lua error...

Dawn 02-20-11 04:36 PM

Just did a quick search for "GCD" and it revealed 3 GCD plugins for oUF. Maybe take a look at this one.

Pyrates 02-21-11 02:50 AM

Yeah I know about that, but it's the base for hungar's gcd plugin, so I guess it suffers the same problem (it's much older, too). I'll give it a shot though :)

gagou 02-21-11 04:12 AM

I've made my own gcd element for my personal layout, it's not very complicated to understand, it may help you so here is the code for the element:
Code:

local parent, ns = ...
local oUF = ns.oUF

local GetTime, GetSpellCooldown = GetTime, _G.GetSpellCooldown

local _, class = UnitClass('player')
local spellName
if class == 'DEATHKNIGHT' then
        spellName = GetSpellInfo(45902)
elseif class == 'DRUID' then
        spellName = GetSpellInfo(5176)
elseif class == 'HUNTER' then
        spellName = GetSpellInfo(3044)
elseif class == 'MAGE' then
        spellName = GetSpellInfo(133)
elseif class == 'PALADIN' then
        spellName = GetSpellInfo(20271)
elseif class == 'PRIEST' then
        spellName = GetSpellInfo(2061)
elseif class == 'ROGUE' then
        spellName = GetSpellInfo(1752)
elseif class == 'SHAMAN' then
        spellName = GetSpellInfo(331)
elseif class == 'WARLOCK' then
        spellName = GetSpellInfo(348)
elseif class == 'WARRIOR' then
        spellName = GetSpellInfo(772)
end

local function OnUpdate(self, elapsed)
        self.currentTime = self.currentTime + elapsed
        if self.currentTime >= self.endTime then
                self:Hide()
        end
        self.Spark:SetPoint('CENTER', self, 'LEFT', (self.currentTime - self.startTime) * self:GetWidth() / self.duration, 0)
end

local function Update(self, event)
        local gcd = self.TomGCD
        local start, duration, enable = GetSpellCooldown(spellName)
        if enable == 1 and start and duration > 0 and duration <= 1.5 then
                gcd.startTime = start
                gcd.currentTime = GetTime()
                gcd.duration = duration
                gcd.endTime = start + duration
                gcd:Show()
        else
                gcd:Hide()
        end
end

local ForceUpdate = function(element)
        return Update(element.__owner, 'ForceUpdate')
end

local function Enable(self, unit)
        local gcd = self.TomGCD
        if gcd then
                gcd.__owner = self
                gcd.ForceUpdate = ForceUpdate
                self:RegisterEvent('SPELL_UPDATE_COOLDOWN', Update)
                gcd:SetScript('OnUpdate', OnUpdate)
                gcd:Hide()
        end
end

local function Disable(self, unit)
        local gcd = self.TomGCD
        if gcd then
                self:UnregisterEvent('SPELL_UPDATE_COOLDOWN', Update)
                gcd:SetScript('OnUpdate', nil)
                gcd:Hide()
        end
end

oUF:AddElement('TomGCD', Update, Enable, Disable)

here is how I spawn it in my layout :


Code:

local function spawnGCDBar(self, width, height, ...)
        local gcd = CreateFrame('Frame', nil, UIParent)
        gcd:SetSize(width, height)
        gcd:SetBackdrop(backdrop)
        gcd:SetBackdropColor(0.25, 0.25, 0.25)

        local spark = gcd:CreateTexture(nil, 'OVERLAY')
        spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]])
        spark:SetBlendMode('ADD')
        spark:SetSize(20, height*2.2)
        gcd.Spark = spark

        gcd:SetPoint(...)
        return gcd
end

it should not be very complicated to adapt it to your needs

Pyrates 02-24-11 05:52 PM

Thanks for all your help :) Turns out I'm simply stupid and ouf_gcd is still working. Sorry for that...


All times are GMT -6. The time now is 10:05 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI