Quantcast oUF_AuraBars - Page 2 - WoWInterface
Thread Tools Display Modes
01-19-15, 05:44 PM   #21
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by sirann View Post
So you're telling me there's a chance
Yes, your "else" was spot on!
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
07-29-18, 08:21 AM   #22
Terenna
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 90
I came across this thread, and was interested in your rewrite, Phanx. I was curious if you still had the pastecode you uploaded on curseforge some years back. The links now lead to dead ends, and it looks like no one uploaded the addon officially.

If not, no worries, thank you!
  Reply With Quote
07-29-18, 06:08 PM   #23
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Nope, sorry.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
07-29-18, 08:30 PM   #24
Terenna
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 90
Thank you so very much
  Reply With Quote
07-30-18, 12:54 AM   #25
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 264
You can pretty much copy my module from oUF_Lumen.



https://github.com/greven/oUF_Lumen/.../bartimers.lua

Check here on how to call them: https://github.com/greven/oUF_Lumen/...its/player.lua

You'll still need a PostUpdate function and a list of buffs / debuffs to track.

Hope it helps you.
__________________
My oUF Layout: oUF Lumen

Last edited by neverg : 07-30-18 at 01:37 AM.
  Reply With Quote
07-30-18, 05:33 AM   #26
Terenna
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 90
Thanks Neverg, I'll have to try that out, it looks very similar.
  Reply With Quote
08-28-18, 02:12 PM   #27
Azgaurd
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 4
Originally Posted by Terenna View Post
Thanks Neverg, I'll have to try that out, it looks very similar.
If you wanted to just get oUF AuraBars functioning again i have been keeping my own copy of it working. https://github.com/Wutname1/oUF_AuraBars
__________________
Libidos (Area 52)
  Reply With Quote
02-03-19, 12:37 AM   #28
Terenna
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 90
So I was able to recover the file. It required a few fixes to make it up to date. But if anyone wants a Phanx's oUF_Aurabars module, here it is:
Lua Code:
  1. --[[--------------------------------------------------------------------
  2. oUF_AuraBars
  3. Provides BuffBars and DebuffBars elements.
  4. Rewritten by Phanx.
  5.  
  6. Example:
  7.  
  8.     local BuffBars = CreateFrame("Frame", nil, frame)
  9.     BuffBars:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 10)
  10.     BuffBars:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 0, 10)
  11.     frame.BuffBars = BuffBars
  12.  
  13. Options:
  14.  
  15.     BuffBars.barHeight
  16.         - height of each bar
  17.         - defaults to 16
  18.         - width is controlled by the element's width
  19.  
  20.     BuffBars.fontFile
  21.         - font file for bar text
  22.         - defaults to health bar value's font or GameFontNormal
  23.     BuffBars.fontOutline
  24.         - outline style for bar text
  25.     BuffBars.nameSize
  26.         - font size for spell names
  27.         - defaults to 10
  28.     BuffBars.timeSize
  29.         - font size for spell durations
  30.         - defaults to 10
  31.     BuffBars.customColor
  32.         - table with r/g/b key values for the element's bars
  33.         - defaults to green buffs and red debuffs
  34.     BuffBars.customFilter
  35.         - function that returns whether or not to show an aura
  36.         - defaults to showing boss debuffs, anything cast by the player or pet, or anything self-applied on an enemy
  37.     BuffBars.customSort
  38.         - function that sorts the auras
  39.         - defaults to showing timeless first, then the rest in descending order by duration
  40.  
  41.     BuffBars.dispelTypeColors
  42.         - use debuff type colors for auras with types (magic, disease, etc)
  43.         - for auras with no type, see the .customColor option above
  44. ----------------------------------------------------------------------]]
  45.  
  46. local _, ns = ...
  47. local oUF = ns.oUF or oUF
  48. assert(oUF, "oUF_AuraBars was unable to locate oUF install.")
  49.  
  50. -- Upvalues for faster access:
  51. local format, min, next, pairs, sort, type = format, min, next, pairs, sort, type
  52. local UnitAura, UnitCanAttack, UnitIsUnit = UnitAura, UnitCanAttack, UnitIsUnit
  53.  
  54. ------------------------------------------------------------------------
  55. --  DEFAULTS
  56.  
  57. --  Override with element.customColor
  58. local defaultColors = {
  59.     HELPFUL = { r = 0, g = 0.6, b = 0 },
  60.     HARMFUL = { r = 0.8, g = 0, b = 0 },
  61. }
  62.  
  63. --  Override with element.customFilter
  64. local function defaultAuraFilter(frame, unit, name, icon, count, dispelType, duration, expirationTime, casterUnit, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3)
  65.     if isBossDebuff then
  66.         return true
  67.     elseif not casterUnit then
  68.         return UnitCanAttack("player", unit)
  69.     else
  70.         return UnitIsUnit(casterUnit, "player") or UnitIsUnit(casterUnit, "pet") or UnitIsUnit(casterUnit, "vehicle")
  71.     end
  72. end
  73.  
  74. --  Override with element.customSort
  75. local function defaultAuraSort(a, b)
  76.     if a.duration == 0 then
  77.         if b.duration == 0 then
  78.             return a.name < b.name
  79.         else
  80.             return true
  81.         end
  82.     else
  83.         if b.duration == 0 then
  84.             return false
  85.         else
  86.             return a.expirationTime > b.expirationTime
  87.         end
  88.     end
  89. end
  90.  
  91. ------------------------------------------------------------------------
  92. --  CREATE BARS
  93.  
  94. local function UpdateLayout(element)
  95.     local bars = element.bars
  96.  
  97.     local a, b, c, d = "BOTTOMLEFT", "TOPLEFT", "BOTTOMRIGHT", "TOPRIGHT"
  98.     if element.growDown then
  99.         a, b, c, d = b, a, d, c
  100.     end
  101.  
  102.     for i = 1, #bars do
  103.         local bar = bars[i]
  104.         bar:ClearAllPoints()
  105.         if i > 1 then
  106.             bar:SetPoint(a, bars[i-1], b, 0, 0)
  107.             bar:SetPoint(c, bars[i-1], d, 0, 0)
  108.         else
  109.             bar:SetPoint(a, element, a, bar:GetHeight(), 0) -- leave room for the icon
  110.             bar:SetPoint(c, element, c, 0, 0)
  111.         end
  112.     end
  113. end
  114.  
  115. local function bar_OnEnter(bar)
  116.     local element = bar:GetParent()
  117.     local aura = element.auras[bar.i]
  118.     GameTooltip:SetOwner(bar, "ANCHOR_TOPLEFT")
  119.     GameTooltip:SetUnitAura(element.__owner.unit, aura.index, element.__filter)
  120.     GameTooltip:Show()
  121. end
  122.  
  123. local function bar_OnLeave(bar)
  124.     GameTooltip:Hide()
  125. end
  126.  
  127. local function CreateBar(element, i)
  128.     local bars = element.bars
  129.     assert(#element.bars + 1 ~= bars, "Bad index passed to CreateBar")
  130.  
  131.     local parent = element.__owner
  132.  
  133.     local bar = CreateFrame("StatusBar", nil, element)
  134.     bar:SetHeight(element.barHeight or 16)
  135.     bar:SetStatusBarTexture([[Interface\AddOns\oUF_Terenna\Texture]] or [[Interface\ChatFrame\ChatFrameBackground]])
  136.  
  137.     bar:EnableMouse(true)
  138.     bar:SetScript("OnEnter", bar_OnEnter)
  139.     bar:SetScript("OnLeave", bar_OnLeave)
  140.  
  141.     bar:SetStatusBarColor(.25, .25, .25, 1)
  142.  
  143.     bars[i] = bar
  144.     bar.i = i
  145.  
  146.     -- Add a background:
  147.     local bg = bar:CreateTexture(nil, "BACKGROUND")
  148.     bg:SetAllPoints(true)
  149.     bg:SetTexture([[Interface\AddOns\oUF_Terenna\Texture]] or [[Interface\ChatFrame\ChatFrameBackground]])
  150.     bg:SetVertexColor(1, 1, 1)
  151.     bg:SetAlpha(.35)
  152.     bar.bg = bg
  153.  
  154.     -- Add the icon:
  155.     local icon = bar:CreateTexture(nil, "ARTWORK")
  156.     icon:SetPoint("RIGHT", bar, "LEFT")
  157.     icon:SetHeight(element.barHeight or 16)
  158.     icon:SetWidth(element.barHeight or 16)
  159.     icon:SetTexCoord(0.06, 0.94, 0.06, 0.94)
  160.     bar.icon = icon
  161.  
  162.     -- Add the time text:
  163.     local time = bar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  164.     time:SetPoint("RIGHT", -2, 1)
  165.     time:SetJustifyH("RIGHT")
  166.     time:SetTextColor(1, 1, 1)
  167.     bar.time = time
  168.  
  169.     -- Add the name text:
  170.     local name = bar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  171.     name:SetPoint("LEFT", 2, 1)
  172.     name:SetPoint("RIGHT", time, "LEFT", -2, 0)
  173.     name:SetJustifyH("LEFT")
  174.     name:SetTextColor(1, 1, 1)
  175.     bar.name = name
  176.  
  177.     -- Override the default font:
  178.     local font = element.fontFile or parent.Health.value and parent.Health.value:GetFont()
  179.     if font then
  180.         local size = select(2, GameFontNormal:GetFont())
  181.         local outline = element.fontOutline or parent.Health.value and select(3,parent.Health.value:GetFont())
  182.         time:SetFont(font, element.timeSize or 10)
  183.         name:SetFont(font, element.nameSize or 10)
  184.     end
  185.  
  186.     -- Update the layout:
  187.     UpdateLayout(element)
  188.  
  189.     -- Return the new bar:
  190.     return bar
  191. end
  192.  
  193. ------------------------------------------------------------------------
  194. --  UPDATE TIMES FOR ACTIVE (DE)BUFFS
  195.  
  196. local function UpdateBars(element, elapsed)
  197.     local bars = element.bars
  198.     local now = GetTime()
  199.     for i = 1, #bars do
  200.         local bar = bars[i]
  201.         if bar.duration then
  202.             local remaining = bar.expirationTime - now
  203.             bar:SetValue(remaining)
  204.             bar.time:SetFormattedText(SecondsToTimeAbbrev(remaining))
  205.         end
  206.     end
  207. end
  208.  
  209. ------------------------------------------------------------------------
  210. --  UTILITY FUNCTIONS
  211.  
  212. local table_create, table_delete
  213. do
  214.     local pool = {}
  215.  
  216.     function table_create()
  217.         local t = next(pool)
  218.         if t then
  219.             pool[t] = nil
  220.         end
  221.         return t or {}
  222.     end
  223.  
  224.     function table_delete(t)
  225.         if type(t) == "table" then
  226.             for k, v in pairs(t) do
  227.                 t[k] = table_delete(v)
  228.             end
  229.             t[true] = true
  230.             t[true] = nil
  231.             pool[t] = true
  232.         end
  233.         return nil
  234.     end
  235. end
  236.  
  237. ------------------------------------------------------------------------
  238. --  UPDATE BARS BASED ON CURRENT (DE)BUFFS
  239.  
  240. local function Update(frame, event, unit, elementName)
  241.     if unit ~= frame.unit then return end
  242.     local element = frame[elementName]
  243.  
  244.     local filterFunc = element.customFilter or defaultAuraFilter
  245.     local filter = element.__filter
  246.     local auras = element.auras
  247.     local numAuras = 0
  248.  
  249.     -- Scan all (de)buffs on the unit:
  250.     for i = 1, 40 do
  251.         local name, icon, count, dispelType, duration, expirationTime, casterUnit, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura(unit, i, filter)
  252.         if not name then break end
  253.  
  254.         if filterFunc(frame, unit, name, icon, count, dispelType, duration, expirationTime, casterUnit, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3) then
  255.             numAuras = numAuras + 1
  256.  
  257.             -- Store information about this (de)buff:
  258.             local t = auras[numAuras]
  259.             if not t then
  260.                 t = table_create()
  261.                 auras[numAuras] = t
  262.             end
  263.             t.index, t.name, t.icon, t.count, t.dispelType, t.duration, t.expirationTime, t.casterUnit, t.isStealable, t.shouldConsolidate, t.spellID, t.canApplyAura, t.isBossDebuff, t.value1, t.value2, t.value3 = i, name, icon, count or 1, dispelType, duration or 0, expirationTime, casterUnit, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3
  264.         end
  265.     end
  266.  
  267.     -- Clear old stored information:
  268.     for i = numAuras + 1, #auras do
  269.         auras[i] = table_delete(auras[i])
  270.     end
  271.  
  272.     -- Sort the active (de)buffs:
  273.     sort(auras, element.sort or defaultAuraSort)
  274.  
  275.     local bars = element.bars
  276.     local numAurasWithDuration = 0
  277.  
  278.     -- Update the bars:
  279.     for i = 1, numAuras do
  280.         local aura = auras[i]
  281.  
  282.         local bar = bars[i] or CreateBar(element, i)
  283.  
  284.         bar.icon:SetTexture(aura.icon)
  285.         bar.name:SetText(aura.count > 1 and format("%s [%d]", aura.name, aura.count) or aura.name)
  286.  
  287.         if aura.duration == 0 then
  288.             bar.duration, bar.expirationTime = nil, nil
  289.             bar:SetMinMaxValues(0, 1)
  290.             bar:SetValue(1)
  291.             bar.time:SetText(nil)
  292.         else
  293.             bar.duration, bar.expirationTime, bar.spellID = aura.duration, aura.expirationTime, aura.spellID
  294.             bar:SetMinMaxValues(0, aura.duration)
  295.             -- No need to set the value or time text here; the OnUpdate will do it.
  296.             numAurasWithDuration = numAurasWithDuration + 1
  297.         end
  298.        
  299.         if aura.duration == 0 then
  300.             bar:SetStatusBarColor(1, 1, 1, 0.0001)
  301.         elseif element.dispelTypeColors then
  302.             if aura.dispelType then
  303.                 if aura.dispelType == 'Magic' then
  304.                     bar:SetStatusBarColor(0.2, 0.6, 1)
  305.                 elseif aura.dispelType == 'Curse' then
  306.                     bar:SetStatusBarColor(0.6, 0, 1)
  307.                 elseif aura.dispelType ==  'Disease' then
  308.                     bar:SetStatusBarColor(0.6, 0.4, 0)
  309.                 elseif aura.dispelType == 'Poison' then
  310.                     bar:SetStatusBarColor(0, 0.6, 0)
  311.                 end
  312.             else
  313.                 bar:SetStatusBarColor(0.65, 0.1, 0.1)
  314.             end
  315.             bar:SetStatusBarColor(.25, .25, .25)
  316.         end
  317.        
  318.         bar:Show()
  319.     end
  320.  
  321.     -- Hide unused bars:
  322.     for i = numAuras + 1, #bars do
  323.         local bar = bars[i]
  324.         bar.duration, bar.expirationTime = nil, nil
  325.         bar:SetMinMaxValues(0, 1)
  326.         bar:SetValue(0)
  327.         bar.icon:SetTexture(nil)
  328.         bar.name:SetText(nil)
  329.         bar.time:SetText(nil)
  330.         bar:Hide()
  331.     end
  332.  
  333.     -- Start or stop the OnUpdate as needed:
  334.     if numAurasWithDuration > 0 then
  335.         element:SetScript("OnUpdate", UpdateBars)
  336.     else
  337.         element:SetScript("OnUpdate", nil)
  338.     end
  339.  
  340.     -- Adjust the total height in case there's a backdrop:
  341.     element:SetHeight(numAuras * (element.barHeight or 16))
  342. end
  343.  
  344. ------------------------------------------------------------------------
  345. --  CREATE ELEMENTS
  346.  
  347. local function Enable(self, elementName, updateFunc, auraFilter)
  348.     local element = self[elementName]
  349.     element.__filter = auraFilter
  350.     element.__owner = self
  351.  
  352.     self:RegisterEvent("UNIT_AURA", updateFunc)
  353.  
  354.     element.auras = element.auras or {}
  355.     element.bars = element.bars or {}
  356.  
  357.     return true
  358. end
  359.  
  360. local function Disable(self, elementName, updateFunc)
  361.     local element = self[elementName]
  362.  
  363.     self:UnregisterEvent("UNIT_AURA", updateFunc)
  364.  
  365.     element:SetScript("OnUpdate", nil)
  366.     element:Hide()
  367.  
  368.     for _, bar in pairs(element.bars) do
  369.         bar.duration, bar.expirationTime = nil, nil
  370.         bar:SetMinMaxValues(0, 1)
  371.         bar:SetValue(0)
  372.         bar.icon:SetTexture(nil)
  373.         bar.name:SetText(nil)
  374.         bar.time:SetText(nil)
  375.         bar:Hide()
  376.     end
  377.  
  378.     return true
  379. end
  380.  
  381. ------------------------------------------------------------------------
  382.  
  383. local function UpdateBuffBars(self, event, unit)
  384.     return self.BuffBars and Update(self, event, unit, "BuffBars")
  385. end
  386.  
  387. local function EnableBuffBars(self)
  388.     return self.BuffBars and Enable(self, "BuffBars", UpdateBuffBars, "HELPFUL")
  389. end
  390.  
  391. local function DisableBuffBars(self)
  392.     return self.BuffBars and Disable(self, "BuffBars", UpdateBuffBars)
  393. end
  394.  
  395. oUF:AddElement("BuffBars", UpdateBuffBars, EnableBuffBars, DisableBuffBars)
  396.  
  397. ------------------------------------------------------------------------
  398.  
  399. local function UpdateDebuffBars(self, event, unit)
  400.     return self.DebuffBars and Update(self, event, unit, "DebuffBars")
  401. end
  402.  
  403. local function EnableDebuffBars(self)
  404.     return self.DebuffBars and Enable(self, "DebuffBars", UpdateDebuffBars, "HARMFUL")
  405. end
  406.  
  407. local function DisableDebuffBars(self)
  408.     return self.DebuffBars and Disable(self, "DebuffBars", UpdateDebuffBars)
  409. end
  410.  
  411. oUF:AddElement("DebuffBars", UpdateDebuffBars, EnableDebuffBars, DisableDebuffBars)

Last edited by Terenna : 02-03-19 at 03:15 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF_AuraBars

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off