Advertisement
Guest User

Ithilyn, RaidCooldowns add tooltips

a guest
Mar 4th, 2010
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. function mod:StartCooldown(sender, spellId, cooldown)
  2.     if self.db.profile.hideSelf and sender == playerName then return end
  3.     if not self.db.profile.spells[spellId] then return end -- Only show a bar for this spell if the user enabled it
  4.    
  5.     -- Because we now scan all spells whenever a Spell Cooldown event is fired,
  6.     -- a sync might be sent multiple times for the same spell. This block prevents
  7.     -- the bar from constantly updating its max time, making it look like the
  8.     -- cooldown is being used again.
  9.     local bar = barGroup:GetBar(sender .. "_" .. spellId)
  10.     if bar == nil then
  11.         bar = barGroup:NewTimerBar((sender .. "_" .. spellId), sender, cooldown, cooldown, spellId)
  12.         bar.caster  = sender
  13.         bar.spellId = spellId
  14.         -- begin ithilyn
  15.         bar.spellName = GetSpellInfo(spellId)
  16.         bar:SetScript("OnEnter", function(bar, ...)
  17.             GameTooltip:SetOwner(bar, "ANCHOR_TOPLEFT")
  18.             GameTooltip:SetText(bar.spellName)
  19.             GameTooltip:Show()
  20.         end)
  21.         bar:SetScript("OnLeave", function(frame, ...)
  22.             GameTooltip:Hide()
  23.         end)
  24.         bar:EnableMouse(true)
  25.         -- end ithilyn
  26.     else
  27.         bar:SetTimer(cooldown, bar.maxValue)
  28.     end
  29.  
  30.     local _, c = UnitClass(sender)
  31.     if not c then
  32.         -- Get the class name from our cooldown table; this is used exclusively for testing
  33.         for k, v in pairs(RaidCooldowns.cooldowns) do
  34.             for k2, v2 in pairs(v) do
  35.                 if v2.id == spellId then
  36.                     c = k
  37.                 end
  38.             end
  39.         end
  40.     end
  41.    
  42.     local color = RAID_CLASS_COLORS[c]
  43.     if type(color) == "table" then
  44.         bar:SetColorAt(1.00, color.r, color.g, color.b, 1)
  45.         bar:SetColorAt(0.00, color.r, color.g, color.b, 1)
  46.     end
  47. end
  48.  
  49. function mod:StopCooldown(sender, spellId)
  50.     local bar = barGroup:GetBar(sender .. "_" .. spellId)
  51.     if bar ~= nil then
  52.         barGroup:RemoveBar(bar)
  53.         self:UpdateDisplay() -- Removes a gap that appears in edge cases
  54.     end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement