Thread Tools Display Modes
08-25-12, 09:59 AM   #1
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Coming back for MoP, needing some advices

Hey guys,

I'll start updating my oUF layout for MoP. I haven't touched my addon since the last year so things are a little rusty.
I would love to get some help catching up. Can you guys point some important things that changed for MoP, ouf-wise, like resources, powers etc?

Also, I'd like to know what tools you guys use while developing addons... is there anything new to ease the pain?
Back in the days I didn't used anything but programmer's notepad to edit my .lua files and bugsack to help me debug stuff.

Thanks in advance!
  Reply With Quote
08-25-12, 06:15 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by drakull View Post
Can you guys point some important things that changed for MoP, ouf-wise, like resources, powers etc?
Lots of things have changed. Make sure you have the latest version of oUF from https://github.com/haste/oUF, and then look at the individual element files to see how elements have been renamed, what properties elements are expected to have, how they are updated, etc.

I'd also suggest looking at layouts that have already been updated.

Originally Posted by drakull View Post
Also, I'd like to know what tools you guys use while developing addons... is there anything new to ease the pain?
Back in the days I didn't used anything but programmer's notepad to edit my .lua files and bugsack to help me debug stuff.
Notepad2 for editing code, BugSack for in-game debugging, and a web browser for referring to wowpedia.org and wowprogramming.com. I've tried more "featureful" editors and IDEs, and they just feel like bloated messes that get in the way more than they help. If you're looking for a new editor, there are some links here:

http://www.wowinterface.com/forums/s...ad.php?t=43699
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-25-12, 07:03 PM   #3
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Thanks for the info, Phanx.

I already got oUF's latest version and have started updating my addon. Right now I have updated my tag definitions to the new tag system and have started updating classbars.

It seems that oUF does not currently supports monk's Chi points system as well as priest's shadow orbs, tho.

As for coding tools, it seems that nothing have changed then... will stick with pnotepad and bugsack for now.

Edit: just found tukz plugins for the new class bars.

Last edited by drakull : 08-25-12 at 07:07 PM.
  Reply With Quote
08-25-12, 07:23 PM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
oUF (current master on GitHub) has support for all the new class powers, except for the ones used by a warlock.
  Reply With Quote
08-25-12, 08:18 PM   #5
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Originally Posted by p3lim View Post
oUF (current master on GitHub) has support for all the new class powers, except for the ones used by a warlock.
Yeah, just noted that... I must be doing something wrong, chi points do appear but are just white textures that do not update when I build/expend them.

Edit: Nevermind, got it to work. Was still using tukz's element name. Now to make it update the number of chi points depending on Ascension talent.

Last edited by drakull : 08-25-12 at 08:31 PM.
  Reply With Quote
08-25-12, 09:40 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can also look at my oUF layout which implements its own support for the new warlock powers.

As for max chi, the talent isn't really important, as UnitPowerMax returns the appropriate value at any given time.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 08-25-12 at 09:43 PM.
  Reply With Quote
08-25-12, 10:50 PM   #7
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Originally Posted by Phanx View Post
You can also look at my oUF layout which implements its own support for the new warlock powers.

As for max chi, the talent isn't really important, as UnitPowerMax returns the appropriate value at any given time.
Yeah but we have to create 5 chi points even if the player does not have the talent, and then Hide() or Show() it accordingly with the talent. Otherwise Harmony.Update causes a crash if the player activates the talent after the classbar is loaded.

I'll take a look at your warlock powers classbar, thanks!

Last edited by drakull : 08-25-12 at 10:52 PM.
  Reply With Quote
08-26-12, 01:22 PM   #8
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
You could take a look at https://github.com/haste/oUF/pull/147. It takes care of showing/hiding the 5th chi depending on Ascension. Maybe there is a better way to do this, I'm not a good coder
  Reply With Quote
08-26-12, 04:35 PM   #9
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Originally Posted by Rainrider View Post
You could take a look at https://github.com/haste/oUF/pull/147. It takes care of showing/hiding the 5th chi depending on Ascension. Maybe there is a better way to do this, I'm not a good coder
Its quite simple actually, just had to override the update method.

I was having a hard time implementing warlock bars, tho. Tried both Phanx and Tukz implementations but ended coding my own version. It's not finished yet but it's promising.
  Reply With Quote
08-27-12, 01:51 AM   #10
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Could post your alternate power implementation for the different elements?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
08-27-12, 06:14 AM   #11
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Originally Posted by zork View Post
Could post your alternate power implementation for the different elements?
I can't post it right now because I'm at work, will do when I get home. It's kind of a hackish implementation right now. Visibility is called when talents change to hide or show the apropriate orbs and, in case of demonology, it changes the first orb's size, positioning and orientation (yeah, it is hard coded inside the element ), then it forces an Update.

I think a better approach was to create 3 different bars inside a frame (one for each spec) and then show only the one for the active spec. Gotta try it.

Last edited by drakull : 08-27-12 at 06:22 AM.
  Reply With Quote
08-27-12, 09:29 AM   #12
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I have to update oUF_Diablo before MoP comes out and I have not yet decided on the display of all those elements. I thought of using those small bubbles but I'm not sure if I would like that.

Just displaying the current number is no option but I might use that on the first release because I think it can be implemented more easily via tags. (But I might be wrong)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
08-27-12, 12:26 PM   #13
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
I'd just post mine. The idea is that the layout creates 4 status bars and the element updates their visibility, using the first bar for demonic fury if demo spec'd. The layout then can resize and reanchor the bars in PostUpdate if needed.

I still have to add support for the prerequested spells.

The element code:
lua Code:
  1. local _, ns = ...
  2. local oUF = ns.oUF or oUF
  3.  
  4. -- specs
  5. local SPEC_WARLOCK_AFFLICTION = SPEC_WARLOCK_AFFLICTION
  6. local SPEC_WARLOCK_DESTRUCTION = SPEC_WARLOCK_DESTRUCTION
  7. local SPEC_WARLOCK_DEMONOLOGY = SPEC_WARLOCK_DEMONOLOGY
  8.  
  9. -- prereq spell IDs
  10. local WARLOCK_SOULBURN = WARLOCK_SOULBURN -- IsPlayerSpell
  11. local WARLOCK_BURNING_EMBERS = WARLOCK_BURNING_EMBERS   -- IsPlayerSpell
  12.  
  13. -- powerType
  14. local SPELL_POWER_SOUL_SHARDS = SPELL_POWER_SOUL_SHARDS
  15. local SPELL_POWER_DEMONIC_FURY = SPELL_POWER_DEMONIC_FURY
  16. local SPELL_POWER_BURNING_EMBERS = SPELL_POWER_BURNING_EMBERS
  17.  
  18. --
  19. local MAX_POWER_PER_EMBER = MAX_POWER_PER_EMBER
  20. local spec = 0
  21. local pType
  22.  
  23. local warlockColors = {
  24.     ["SOUL_SHARDS"] = {1, 0, 1},
  25.     ["BURNING_EMBERS"] = {1, 0, 0},
  26.     ["DEMONIC_FURY"] = {0, 1, 1},
  27. }
  28.  
  29. -- TODO: prereq spells
  30. local Visibility = function(self)
  31.     local element = self.WarlockPowerBar
  32.  
  33.     spec = GetSpecialization()
  34.     local power
  35.     local maxPower
  36.     local r, g, b
  37.  
  38.     if (spec) then
  39.         if (spec == SPEC_WARLOCK_AFFLICTION) then
  40.             pType = "SOUL_SHARDS"
  41.             power = UnitPower("player", SPELL_POWER_SOUL_SHARDS)
  42.             maxPower = UnitPowerMax("player", SPELL_POWER_SOUL_SHARDS)
  43.  
  44.             r, g, b = unpack(warlockColors["SOUL_SHARDS"])
  45.  
  46.             for i = 1, 4 do
  47.                 element[i]:SetStatusBarColor(r, g, b)
  48.                 element[i]:SetMinMaxValues(0, 1)
  49.  
  50.                 if (element[i].bg) then
  51.                     local mult = element[i].bg.multiplier or 1
  52.                     element[i].bg:SetVertexColor(r * mult, g * mult, b * mult)
  53.                 end
  54.  
  55.                 if (i <= maxPower) then
  56.                     element[i]:Show()
  57.                 else
  58.                     element[i]:Hide()
  59.                 end
  60.             end
  61.         elseif (spec == SPEC_WARLOCK_DEMONOLOGY) then
  62.             pType = "DEMONIC_FURY"
  63.             power = UnitPower("player", SPELL_POWER_DEMONIC_FURY)
  64.             maxPower = UnitPowerMax("player", SPELL_POWER_DEMONIC_FURY)
  65.  
  66.             r, g, b = unpack(warlockColors["DEMONIC_FURY"])
  67.  
  68.             element[1]:SetStatusBarColor(r, g, b)
  69.             element[1]:SetMinMaxValues(0, maxPower)
  70.             element[1]:SetAlpha(1)
  71.  
  72.             if (element[1].bg) then
  73.                 local mult = element[1].bg.multiplier or 1
  74.                 element[1].bg:SetVertexColor(r * mult, g * mult, b * mult)
  75.             end
  76.  
  77.             for i = 2, 4 do
  78.                 element[i]:Hide()
  79.             end
  80.         elseif (spec == SPEC_WARLOCK_DESTRUCTION) then
  81.             pType = "BURNING_EMBERS"
  82.             power = UnitPower("player", SPELL_POWER_BURNING_EMBERS, true)
  83.             maxPower = math.floor(UnitPowerMax("player", SPELL_POWER_BURNING_EMBERS, true) / MAX_POWER_PER_EMBER)
  84.  
  85.             r, g, b = unpack(warlockColors["BURNING_EMBERS"])
  86.  
  87.             for i = 1, 4 do
  88.                 element[i]:SetStatusBarColor(r, g, b)
  89.                 element[i]:SetMinMaxValues(MAX_POWER_PER_EMBER * i - MAX_POWER_PER_EMBER, MAX_POWER_PER_EMBER * i)
  90.                 element[i]:SetAlpha(1)
  91.  
  92.                 if (element[i].bg) then
  93.                     local mult = element[i].bg.multiplier or 1
  94.                     element[i].bg:SetVertexColor(r * mult, g * mult, b * mult)
  95.                 end
  96.  
  97.                 if (i <= maxPower) then
  98.                     element[i]:Show()
  99.                 else
  100.                     element[i]:Hide()
  101.                 end
  102.             end
  103.         end
  104.        
  105.         --element:ForceUpdate()
  106.     else
  107.         for i = 1, 4 do
  108.             element[i]:Hide()
  109.         end
  110.     end
  111.  
  112.     if (element.PostUpdateVisibility) then
  113.         element:PostUpdateVisibility(spec, power, maxPower)
  114.     end
  115. end
  116.  
  117. local Update = function(self, event, unit, powerType)
  118.     if (unit ~= "player") then return end
  119.    
  120.     if not powerType then
  121.         powerType = pType
  122.     end
  123.    
  124.     if (powerType and powerType ~= "SOUL_SHARDS" and powerType ~= "DEMONIC_FURY" and powerType ~= "BURNING_EMBERS") then return end
  125.  
  126.     local element = self.WarlockPowerBar
  127.     local power
  128.     local maxPower
  129.  
  130.     if (powerType == "SOUL_SHARDS" and spec == 1) then
  131.         power = UnitPower("player", SPELL_POWER_SOUL_SHARDS)
  132.         maxPower = UnitPowerMax("player", SPELL_POWER_SOUL_SHARDS)
  133.  
  134.         if (maxPower == 4 and not element[4]:IsVisible() or maxPower == 3 and element[4]:IsVisible()) then
  135.             Visibility(self)
  136.         end
  137.  
  138.         for i = 1, maxPower do
  139.             element[i]:SetValue(1)
  140.             if (i <= power) then
  141.                 element[i]:SetAlpha(1)
  142.             else
  143.                 element[i]:SetAlpha(0.3)
  144.             end
  145.         end
  146.     elseif (powerType == "DEMONIC_FURY" and spec == 2) then
  147.         power = UnitPower("player", SPELL_POWER_DEMONIC_FURY)
  148.         maxPower = UnitPowerMax("player", SPELL_POWER_DEMONIC_FURY)
  149.  
  150.         element[1]:SetValue(power)
  151.     elseif (powerType == "BURNING_EMBERS" and spec == 3) then
  152.         power = UnitPower("player", SPELL_POWER_BURNING_EMBERS, true)
  153.         maxPower = math.floor(UnitPowerMax("player", SPELL_POWER_BURNING_EMBERS, true) / MAX_POWER_PER_EMBER)
  154.  
  155.         if (maxPower == 4 and not element[4]:IsVisible() or maxPower == 3 and element[4]:IsVisible()) then
  156.             Visibility(self)
  157.         end
  158.  
  159.         for i = 1, maxPower do
  160.             element[i]:SetValue(power)
  161.         end
  162.     end
  163.    
  164.     if (element.PostUpdate) then
  165.         element:PostUpdate(powerType, power, maxPower)
  166.     end
  167. end
  168.  
  169. local Path = function(self, ...)
  170.     return (self.WarlockPowerBar.Override or Update) (self, ...)
  171. end
  172.  
  173. local ForceUpdate = function(element, ...)
  174.     return Path(element.__owner, "ForceUpdate", element.__owner.unit)
  175. end
  176.  
  177. local Enable = function(self)
  178.     local element = self.WarlockPowerBar
  179.  
  180.     if (element) then
  181.         element.__owner = self
  182.         element.ForceUpdate = ForceUpdate
  183.  
  184.         self:RegisterEvent("UNIT_POWER", Path)
  185.         self:RegisterEvent("UNIT_DISPLAYPOWER", Path)
  186.         self:RegisterEvent("PLAYER_TALENT_UPDATE", Visibility, true)
  187.  
  188.         Visibility(self)
  189.  
  190.         return true
  191.     end
  192. end
  193.  
  194. local Disable = function(self)
  195.     local element = self.WarlockPowerBar
  196.  
  197.     if (element) then
  198.         self:UnregisterEvent("UNIT_POWER", Path)
  199.         self:UnregisterEvent("UNIT_DISPLAYPOWER", Path)
  200.         self:UnregisterEvent("PLAYER_TALENT_UPDATE", Visibility)
  201.     end
  202. end
  203.  
  204. oUF:AddElement("Rain_WarlockPowerBar", Path, Enable, Disable)

The layout code:
Create the status bars:
lua Code:
  1. local AddWarlockPowerBar = function(self, width, height, spacing)
  2.     self.WarlockPowerBar = {}
  3.     self.WarlockPowerBar.width = width
  4.     self.WarlockPowerBar.height = height
  5.     self.WarlockPowerBar.spacing = spacing
  6.  
  7.     for i = 1, 4 do
  8.         self.WarlockPowerBar[i] = CreateFrame("StatusBar", "oUF_Rain_WarlockPowerBar"..i, self.Overlay)
  9.         self.WarlockPowerBar[i]:SetSize((width - 4 * spacing - spacing) / 4, height)
  10.         self.WarlockPowerBar[i]:SetPoint("BOTTOMLEFT", self.Overlay, (i - 1) * self.WarlockPowerBar[i]:GetWidth() + i * spacing, 1)
  11.         self.WarlockPowerBar[i]:SetStatusBarTexture(ns.media.TEXTURE)
  12.         self.WarlockPowerBar[i]:SetBackdrop(ns.media.BACKDROP)
  13.         self.WarlockPowerBar[i]:SetBackdropColor(0, 0, 0)
  14.        
  15.         self.WarlockPowerBar[i].bg = self.WarlockPowerBar[i]:CreateTexture(nil, "BORDER")
  16.         self.WarlockPowerBar[i].bg:SetTexture(ns.media.TEXTURE)
  17.         self.WarlockPowerBar[i].bg:SetAllPoints()
  18.         self.WarlockPowerBar[i].bg.multiplier = 0.5
  19.     end
  20.    
  21.     self.WarlockPowerBar.PostUpdateVisibility = ns.WarlockPowerPostUpdateVisibility
  22. end
  23. ns.AddWarlockPowerBar = AddWarlockPowerBar

PostUpdateVisibilty:
lua Code:
  1. local WarlockPowerPostUpdateVisibility = function(element, spec, power, maxPower)
  2.     local self = element.__owner
  3.     local width = element.width
  4.     local height = element.height
  5.     local spacing = element.spacing
  6.    
  7.     if spec then
  8.         if spec == 1 or spec == 3 then -- Affliction or Destruction
  9.             for i = 1, maxPower do
  10.                 element[i]:SetSize((width - maxPower * spacing - spacing) / maxPower, height)
  11.                 element[i]:SetPoint("BOTTOMLEFT", self.Overlay, (i - 1) * element[i]:GetWidth() + i * spacing, 1)
  12.             end
  13.         else -- Demonology
  14.             element[1]:SetSize(width - 2 * spacing, height)
  15.             element[1]:SetPoint("BOTTOMLEFT", self.Overlay, spacing, 1)
  16.             --element[1]:SetPoint("BOTTOMRIGHT", self.Overlay, -spacing, 1) -- we have to use SetSize lol?
  17.         end
  18.     end
  19. end
  20. ns.WarlockPowerPostUpdateVisibility = WarlockPowerPostUpdateVisibility
  Reply With Quote
08-27-12, 01:52 PM   #14
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Btw, would be thankful for ideas on how to do the prereq spells, as it seems that Phanx method issues:
oUF: Error: Style [Phanx] attempted to register event [SPELLS_CHANGED] on unit [player] with a handler that doesn't exist.
  Reply With Quote
08-27-12, 06:27 PM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not seeing any such error... what version of oUF are you using? Are you on live or beta servers? (Not that it will matter after today )
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-27-12, 06:47 PM   #16
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
On beta, latest oUF from github (only change I made was to temporary comment out line 551 in ouf.lua - selfisableBlizzard(unit)).

To reproduce:
Lvl 85 premade warlock travel from SW to Darnassus with the ship. Error message pops in chat after loading screen.
or
Level a warlock to lvl 10 and spec Destro or Affli. Error comes on spec and after every reloadui, entering world and so on. And the corresponding power bar appears after reloadui/entering world too, although it shouldn't.
  Reply With Quote
08-27-12, 07:43 PM   #17
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Here is my version. It's still not optimized but it does the job.

First, here is a picture of all three bars in action. Demonology bar, Destro bar (glyphed) and Affliction bar:

(It's also a first look at my new layout)

Layout:
Lua Code:
  1. self.WarlockSpecBars = classBarFactory(self, 4, true)
  2. self.WarlockSpecBars.PreUpdateVisibility = preUpdate
  3.  
  4. local classBarFactory = function(frame, count, reverse, fakeBg, color)
  5.     local bars
  6.     if playerClass == "WARLOCK" then
  7.         bars = CreateFrame("Frame", nil, frame)
  8.     else
  9.         bars = {}
  10.     end
  11.     for n = count, 1, -1 do
  12.         local i
  13.         local prev
  14.         local first
  15.         if reverse then
  16.             first = 1
  17.             i = count - n + 1
  18.             prev = i - 1
  19.         else
  20.             first = count
  21.             i = n
  22.             prev = i + 1
  23.         end
  24.         local bar
  25.         if fakeBg then
  26.             bar = CreateFrame("Frame", nil, frame)
  27.             bar.fg = bar:CreateTexture(nil, "ARTWORK")
  28.             bar.fg:SetTexture(cfg.statusBarTexture)
  29.             bar.fg:SetAllPoints(bar)
  30.             if color then bar.fg:SetVertexColor(color.r, color.g, color.b) end
  31.         else
  32.             bar = CreateFrame("StatusBar", nil, frame)
  33.             bar:SetStatusBarTexture(cfg.statusBarTexture)
  34.             bar:SetOrientation("VERTICAL")
  35.         end
  36.         bar:SetSize(5, 14)
  37.         bar:SetFrameLevel(4)
  38.        
  39.         createBGFrame(bar, 3)
  40.        
  41.         if i == first then
  42.             bar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -6, 3)
  43.         else
  44.             bar:SetPoint("TOPRIGHT", bars[prev], "TOPLEFT", -6, 0)
  45.         end
  46.        
  47.         local barBG = bar:CreateTexture(nil, "BACKGROUND")
  48.         barBG:SetAllPoints(bar)
  49.         barBG:SetTexture(cfg.statusBarTexture)
  50.         bar.bg = barBG
  51.         bar.bg.multiplier = 0.3
  52.         if color then bar.bg:SetVertexColor(color.r * 0.3, color.g * 0.3, color.b * 0.3) end
  53.         bars[i] = bar
  54.     end
  55.    
  56.     return bars
  57. end

Element:
Lua Code:
  1. local _, ns = ...
  2. local oUF = ns.oUF or oUF
  3. assert(oUF, "oUF_WarlockSpecBars was unable to locate oUF install")
  4.  
  5. if select(2, UnitClass("player")) ~= "WARLOCK" then return end
  6.  
  7. local MAX_POWER_PER_EMBER = 10
  8. local SPELL_POWER_DEMONIC_FURY = SPELL_POWER_DEMONIC_FURY
  9. local SPELL_POWER_BURNING_EMBERS = SPELL_POWER_BURNING_EMBERS
  10. local SPELL_POWER_SOUL_SHARDS = SPELL_POWER_SOUL_SHARDS
  11. local SPEC_WARLOCK_DESTRUCTION = SPEC_WARLOCK_DESTRUCTION
  12. local SPEC_WARLOCK_DESTRUCTION_GLYPH_EMBERS = 63304
  13. local SPEC_WARLOCK_AFFLICTION = SPEC_WARLOCK_AFFLICTION
  14. local SPEC_WARLOCK_AFFLICTION_GLYPH_SHARDS = 63302
  15. local SPEC_WARLOCK_DEMONOLOGY = SPEC_WARLOCK_DEMONOLOGY
  16. local LATEST_SPEC = 0
  17.  
  18. local Colors = {
  19.     [1] = {.61, .30, 1},
  20.     [2] = {.61, .30, 1},
  21.     [3] = {1, .76, .30}
  22. }
  23.  
  24. local Update = function(self, event, unit, powerType)
  25.     if(self.unit ~= unit or (powerType and powerType ~= "BURNING_EMBERS" and powerType ~= "SOUL_SHARDS" and powerType ~= "DEMONIC_FURY")) then return end
  26.     local wsb = self.WarlockSpecBars
  27.  
  28.     if(wsb.PreUpdate) then wsb:PreUpdate(self) end
  29.    
  30.     local spec = GetSpecialization()
  31.    
  32.     if spec then
  33.         if (spec == SPEC_WARLOCK_DESTRUCTION) then 
  34.             local maxPower = UnitPowerMax("player", SPELL_POWER_BURNING_EMBERS, true)
  35.             local power = UnitPower("player", SPELL_POWER_BURNING_EMBERS, true)
  36.             local numEmbers = power / MAX_POWER_PER_EMBER
  37.             local numBars = floor(maxPower / MAX_POWER_PER_EMBER)
  38.            
  39.             for i = 1, numBars do
  40.                 wsb[i]:SetMinMaxValues((MAX_POWER_PER_EMBER * i) - MAX_POWER_PER_EMBER, MAX_POWER_PER_EMBER * i)
  41.                 wsb[i]:SetValue(power)
  42.             end
  43.         elseif ( spec == SPEC_WARLOCK_AFFLICTION ) then
  44.             local numShards = UnitPower("player", SPELL_POWER_SOUL_SHARDS)
  45.             local maxShards = UnitPowerMax("player", SPELL_POWER_SOUL_SHARDS)
  46.            
  47.             for i = 1, maxShards do
  48.                 wsb[i]:SetMinMaxValues(0, 1)
  49.                 if i <= numShards then
  50.                     wsb[i]:SetValue(1)
  51.                 else
  52.                     wsb[i]:SetValue(0)
  53.                 end
  54.             end
  55.         elseif spec == SPEC_WARLOCK_DEMONOLOGY then
  56.             local power = UnitPower("player", SPELL_POWER_DEMONIC_FURY)
  57.             local maxPower = UnitPowerMax("player", SPELL_POWER_DEMONIC_FURY)
  58.                        
  59.             wsb[1]:SetMinMaxValues(0, maxPower)
  60.             wsb[1]:SetValue(power)
  61.         end
  62.     end
  63.  
  64.     if(wsb.PostUpdate) then
  65.         return wsb:PostUpdate(spec)
  66.     end
  67. end
  68.  
  69. local function Visibility(self, event, unit)
  70.     local wsb = self.WarlockSpecBars
  71.     local spec = GetSpecialization()
  72.  
  73.     if spec then
  74.         if not wsb:IsShown() then
  75.             wsb:Show()
  76.         end
  77.        
  78.         if LATEST_SPEC ~= spec then
  79.        
  80.             if(wsb.PreUpdateVisibility) then wsb:PreUpdateVisibility(self) end
  81.  
  82.             for i = 1, 4 do
  83.                 local max = select(2, wsb[i]:GetMinMaxValues())
  84.                 if spec == SPEC_WARLOCK_AFFLICTION then
  85.                     wsb[i]:SetValue(max)
  86.                 else
  87.                     wsb[i]:SetValue(0)
  88.                 end
  89.             end
  90.  
  91.             if LATEST_SPEC == SPEC_WARLOCK_DEMONOLOGY then
  92.                 wsb[1]:SetOrientation("VERTICAL")
  93.             end
  94.         end
  95.        
  96.         if spec == SPEC_WARLOCK_DESTRUCTION then
  97.             local maxembers = 3
  98.             for i = 1, GetNumGlyphSockets() do
  99.                 local glyphID = select(4, GetGlyphSocketInfo(i))
  100.                 if glyphID == SPEC_WARLOCK_DESTRUCTION_GLYPH_EMBERS then maxembers = 4 end
  101.             end    
  102.            
  103.             if maxembers == 3 then wsb[4]:Hide() else wsb[4]:Show() end
  104.             for n = 1, maxembers do
  105.                 wsb[n]:SetStatusBarColor(unpack(Colors[spec]))
  106.                 wsb[n].bg:SetVertexColor(Colors[spec][1] * .3,Colors[spec][2] * .3,Colors[spec][3] * .3)
  107.                 wsb[n]:Show()
  108.             end
  109.         elseif spec == SPEC_WARLOCK_AFFLICTION then
  110.             local maxshards = 3
  111.             for i = 1, GetNumGlyphSockets() do
  112.                 local glyphID = select(4, GetGlyphSocketInfo(i))
  113.                 if glyphID == SPEC_WARLOCK_AFFLICTION_GLYPH_SHARDS then maxshards = 4 end
  114.             end        
  115.            
  116.             for n = 1, maxshards do
  117.                 wsb[n]:SetStatusBarColor(unpack(Colors[spec]))
  118.                 wsb[n].bg:SetVertexColor(Colors[spec][1] * .3,Colors[spec][2] * .3,Colors[spec][3] * .3)
  119.                 wsb[n]:Show()
  120.             end
  121.            
  122.             if maxshards == 3 then wsb[4]:Hide() else wsb[4]:Show() end
  123.         elseif spec == SPEC_WARLOCK_DEMONOLOGY then
  124.             wsb[2]:Hide()
  125.             wsb[3]:Hide()
  126.             wsb[4]:Hide()
  127.             wsb[1]:SetOrientation("HORIZONTAL")
  128.             wsb[1]:SetStatusBarColor(unpack(Colors[spec]))
  129.             wsb[1].bg:SetVertexColor(Colors[spec][1] * .3,Colors[spec][2] * .3,Colors[spec][3] * .3)
  130.         end
  131.     else
  132.         if wsb:IsShown() then
  133.             wsb:Hide()
  134.         end
  135.     end
  136.    
  137.     wsb.ForceUpdate(wsb)
  138.     LATEST_SPEC = spec
  139. end
  140.  
  141. local Path = function(self, ...)
  142.     return (self.WarlockSpecBars.Override or Update) (self, ...)
  143. end
  144.  
  145. local ForceUpdate = function(element)
  146.     return Path(element.__owner, "ForceUpdate", element.__owner.unit, "SOUL_SHARDS")
  147. end
  148.  
  149. local function Enable(self)
  150.     local wsb = self.WarlockSpecBars
  151.     if(wsb) then
  152.         wsb.__owner = self
  153.         wsb.ForceUpdate = ForceUpdate
  154.  
  155.         self:RegisterEvent("UNIT_POWER", Path)
  156.         self:RegisterEvent("UNIT_DISPLAYPOWER", Path)
  157.         self:RegisterEvent("PLAYER_TALENT_UPDATE", Visibility, true)
  158.         self:RegisterEvent("SPELLS_CHANGED", Visibility, true)
  159.  
  160.         for i = 1, 4 do
  161.             local Point = wsb[i]
  162.             if not Point:GetStatusBarTexture() then
  163.                 Point:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=])
  164.             end
  165.         end
  166.        
  167.         wsb:Hide()
  168.  
  169.         return true
  170.     end
  171. end
  172.  
  173. local function Disable(self)
  174.     local wsb = self.WarlockSpecBars
  175.     if(wsb) then
  176.         self:UnregisterEvent("UNIT_POWER", Path)
  177.         self:UnregisterEvent("UNIT_DISPLAYPOWER", Path)
  178.         self:UnregisterEvent("PLAYER_TALENT_UPDATE", Visibility)
  179.     end
  180. end
  181.  
  182. oUF:AddElement("WarlockSpecBars", Path, Enable, Disable)

PreUpdateVisibility:
Lua Code:
  1. local preUpdate = function(wsb, self)
  2.     local spec = GetSpecialization()
  3.     if spec == SPEC_WARLOCK_DEMONOLOGY then
  4.         wsb[1]:SetSize(70, 5)
  5.         wsb[1]:SetPoint("TOPRIGHT", self, "TOPRIGHT", 2, -4)
  6.     else
  7.         wsb[1]:SetSize(5, 14)
  8.         wsb[1]:SetPoint("TOPRIGHT", self, "TOPRIGHT", -6, 3)
  9.     end
  10. end

The element is based on tukz implementation with many modifications of mine. And I stole Phanx's idea for a classbar factory, although my version is not based on his code.

Last edited by drakull : 08-27-12 at 08:52 PM. Reason: Creditz
  Reply With Quote
08-30-12, 12:15 PM   #18
Kekskrümel
An Aku'mai Servant
Join Date: Oct 2010
Posts: 39
Maybe you can take a look at ouf_alekk @ https://github.com/moonwitch/oUF_alekk

I would love to see an updated version for MoP, was working fine with cataclysm. Moonwitch is currently very busy :/

I would pay the person for updating it with some months wow, like I did with moonwitch.

Greetings

Last edited by Kekskrümel : 08-30-12 at 12:18 PM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Coming back for MoP, needing some advices

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