Quantcast The way I address the lack of Burning Embers support in classicons.lua - WoWInterface
 
Thread Tools Display Modes
05-25-13, 11:58 PM   #1
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
The way I address the lack of Burning Embers support in classicons.lua

I doubt this is anything close to perfect, but it works (step 1).
All I did was modify the code of classicons.lua slightly... It's as a separate file / element though, as it didn't seem to work otherwise.

Is there something that I missed in oUF that makes this unnecessary?

embers.lua

Lua Code:
  1. --[[ Element: Embers
  2.  Toggles the visibility of icons depending on the player's class and
  3.  specialization.
  4.  
  5.  Widget
  6.  
  7.  Embers - An array consisting of five UI Textures.
  8.  
  9.  Notes
  10.  Warlock - Embers
  11.  
  12.  Examples
  13.  
  14.    local Embers = {}
  15.    for index = 1, 5 do
  16.       local Icon = self:CreateTexture(nil, 'BACKGROUND')
  17.    
  18.       -- Position and size.
  19.       Icon:SetSize(16, 16)
  20.       Icon:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', index * Icon:GetWidth(), 0)
  21.    
  22.       Embers[index] = Icon
  23.    end
  24.    
  25.    -- Register with oUF
  26.    self.Embers = Embers
  27. ]]
  28.  
  29. local parent, ns = ...
  30. local oUF = ns.oUF
  31.  
  32. local PlayerClass = select(2, UnitClass'player')
  33.  
  34. -- Holds the class specific stuff.
  35. local ClassPowerType, ClassPowerTypes
  36. local ClassPowerEnable, ClassPowerDisable
  37. local RequireSpec, RequireSpell
  38.  
  39. local UpdateTexture = function(element)
  40.     local red, green, blue, desaturated
  41.     if(PlayerClass == 'WARLOCK') then
  42.         red, green, blue = 1, .49, .05
  43.         desaturated = false
  44.     end
  45.  
  46.     for i=1, 5 do
  47.         if(element[i].SetDesaturated) then
  48.             element[i]:SetDesaturated(desaturated)
  49.         end
  50.  
  51.         element[i]:SetVertexColor(red, green, blue)
  52.     end
  53. end
  54.  
  55. local ToggleVehicle = function(self, state)
  56.     local element = self.Embers
  57.     for i=1, 5 do
  58.         element[i]:Hide()
  59.     end
  60.  
  61.     (element.UpdateTexture or UpdateTexture) (element)
  62.  
  63.     if(state) then
  64.         ClassPowerDisable(self)
  65.     else
  66.         ClassPowerEnable(self)
  67.     end
  68. end
  69.  
  70. local Update = function(self, event, unit, powerType)
  71.     local element = self.Embers
  72.     local hasVehicle = UnitHasVehicleUI('player')
  73.     if(element.__inVehicle ~= hasVehicle) then
  74.         element.__inVehicle = hasVehicle
  75.         ToggleVehicle(self, hasVehicle)
  76.  
  77.         -- Continue the update if we left a vehicle.
  78.         if(hasVehicle) then return end
  79.     end
  80.  
  81.     if((unit and unit ~= 'player') or (powerType and not ClassPowerTypes[powerType])) then
  82.         return
  83.     end
  84.  
  85.     if(element.PreUpdate) then
  86.         element:PreUpdate()
  87.     end
  88.  
  89.     local cur = UnitPower('player', ClassPowerType)
  90.     local max = UnitPowerMax('player', ClassPowerType)
  91.  
  92.     for i=1, max do
  93.         if(i <= cur) then
  94.             element[i]:Show()
  95.         else
  96.             element[i]:Hide()
  97.         end
  98.     end
  99.  
  100.     local oldMax = element.__max
  101.     if(max ~= element.__max) then
  102.         if(max < element.__max) then
  103.             for i=max + 1, element.__max do
  104.                 element[i]:Hide()
  105.             end
  106.         end
  107.  
  108.         element.__max = max
  109.     end
  110.  
  111.     if(element.PostUpdate) then
  112.         return element:PostUpdate(cur, max, oldMax ~= max)
  113.     end
  114. end
  115.  
  116. local Path = function(self, ...)
  117.     return (self.Embers.Override or Update) (self, ...)
  118. end
  119.  
  120. local Visibility = function(self, event, unit)
  121.     local element = self.Embers
  122.     if((RequireSpell and not IsPlayerSpell(RequireSpell))) then
  123.         for i=1, 5 do
  124.             element[i]:Hide()
  125.         end
  126.         ClassPowerDisable(self)
  127.     else
  128.         ClassPowerEnable(self)
  129.         return Path(self, 'UpdateVisibility')
  130.     end
  131. end
  132.  
  133. local ForceUpdate = function(element)
  134.     return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
  135. end
  136.  
  137. do
  138.     if(PlayerClass == 'WARLOCK') then
  139.         ClassPowerType = SPELL_POWER_BURNING_EMBERS
  140.         ClassPowerTypes = {
  141.             BURNING_EMBERS = true,
  142.         }
  143.         RequireSpell = WARLOCK_BURNING_EMBERS
  144.         ClassPowerEnable = function(self)
  145.             local element = self.Embers
  146.  
  147.             self:RegisterEvent('UNIT_DISPLAYPOWER', Update)
  148.             self:RegisterEvent('UNIT_POWER_FREQUENT', Update)
  149.         end
  150.  
  151.         ClassPowerDisable = function(self)
  152.             self:UnregisterEvent('UNIT_DISPLAYPOWER', Update)
  153.             self:UnregisterEvent('UNIT_POWER_FREQUENT', Update)
  154.         end
  155.     end
  156. end
  157.  
  158. local Enable = function(self, unit)
  159.     local element = self.Embers
  160.     if(not element) then return end
  161.  
  162.     element.__owner = self
  163.     element.__max = 0
  164.     element.ForceUpdate = ForceUpdate
  165.  
  166.     if(ClassPowerEnable) then
  167.         if(PlayerClass == 'WARLOCK') then
  168.             self:RegisterEvent('SPELLS_CHANGED', Visibility, true)
  169.         end
  170.         ClassPowerEnable(self)
  171.  
  172.         for i=1, 5 do
  173.             local icon = element[i]
  174.             if(icon:IsObjectType'Texture' and not icon:GetTexture()) then
  175.                 icon:SetTexCoord(0.45703125, 0.60546875, 0.44531250, 0.73437500)
  176.                 icon:SetTexture([[Interface\PlayerFrame\Priest-ShadowUI]])
  177.             end
  178.         end
  179.  
  180.         (element.UpdateTexture or UpdateTexture) (element)
  181.  
  182.         return true
  183.     end
  184. end
  185.  
  186. local Disable = function(self)
  187.     local element = self.Embers
  188.     if(not element) then return end
  189.  
  190.     self:UnregisterEvent('SPELLS_CHANGED', Visibility)
  191.     self:UnregisterEvent('PLAYER_TALENT_UPDATE', Visibility)
  192.     ClassPowerDisable(self)
  193. end
  194.  
  195. oUF:AddElement('Embers', Update, Enable, Disable)

then in oUF.xml, add:
Code:
<Script file='elements\embers.lua' />
  Reply With Quote
05-26-13, 02:35 PM   #2
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 450
The classicons element is for stuff that's class power specific but does not work like a status bar. Burning Embers are status bars. Your implementation hides partially full embers, which the default ui doesn't do and that is actually relevant information. You also don't handle the green fire case.
  Reply With Quote
05-26-13, 11:05 PM   #3
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
Interesting.

Thanks for the feedback, without which I would never have heard of a green fire case... I had no idea what you were talking about, leading me to googling 'destruction green fire case,' I found stuff to read but probably won't get around to it until tomorrow.

I've never really stared at the ember 'bars' enough for it to really matter, and sometimes they can be misleading, looking full when they're not (especially in the case of addon bars... I have a hell of a time telling exactly when the runes are full in the DK rune bars). But I should probably at least have some sort of bar, and could theoretically turn this into an indicator system to show when the bars are indeed full...


Is there anything else in oUF designed to handle these by default? If it's that necessary for them to be status bars (then why would they just be completely missing in oUF in the first place), I'll look into a better implementation. I also have adapted the druid mana bar code to support demonic fury, I don't really play demonology though, so don't know anything about that other than it's a bar that fills as you're not a demon, and powers your demon spells... I don't know if there's anything out of the ordinary beyond it being a power bar, not that different than a mana bar (just a different method of filling it and a different power name).

TL;DR: Thanks for the input, I'll look into the idea of making them bars instead of indicators (I'll probably keep the indicators though with a diff texture...), and whatever this green fire stuff is...
  Reply With Quote
05-27-13, 12:09 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
There isn't anything in oUF (yet) to support burning embers or demonic fury. However, it's not because it's not "that necessary"; it's simply because the author of oUF has not had time to work on it.

Demonic fury is just a second mana bar, very similar to the druid mana bar. You should probably have it change color while in demon form, like the default UI, so it's one color while you're filling it and another color while you're using it.

It is important for burning embers to be statusbars, or at least have some indication of how close you are to filling the next ember. My solution for avoiding the "is this bar full?" issue is to make the bar semi-transparent while it's filling, and then switch to full opacity when it's full. This way you can still see its progress, but it's noticably dimmer when it's not full.

If you want to see how other people have implemented support for these powers in oUF layouts, check out oUF_Phanx, oUF_Diablo, or the oUF_WarlockSpecBars plugin.

If you like the default UI's appearance for burning embers, you could actually just pull the burning embers off the Blizzard player frame and put them on your oUF player frame.
__________________
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!

Last edited by Phanx : 05-27-13 at 12:13 AM.
  Reply With Quote
05-27-13, 10:35 AM   #5
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
Thanks, Phanx. I'll look into making the fury bar change colors, for now I'm using a combination of what I had to see when embers are full, and the plugin you pointed me to for bars.

That plugin also is a great example of why I hate to use those plugins... it's horribly out of date (not updated for 5.2), it's currently set up in a way that it'll always only show 3 shards, which was easy to fix, but they hadn't found it necessary to spend their time on changing a 3 to a 4 and commenting out a section searching for a glyph that no longer exists...

Anyway, it's great right now, because that plugin solves shards, embers, and the fury bar all at once (after modification), all it doesn't do is have a good color for the fury bar, or color changing for the fury bar, and I'm assuming it doesn't have a different color for the green thing I still haven't had time to look into (from what I read it's a purely cosmetic thing... is that acurate?)

Thanks again to both of you, it's WAY better now.

here's it so far:

Last edited by Aerials : 05-27-13 at 10:41 AM.
  Reply With Quote
05-27-13, 12:08 PM   #6
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
Fury and Ember color...

The fury bar will now change color when (full - 20) or (empty - 20) (the blizz ui seems to change the color a itty before full / empty, I was basing this number on the result of print(power) when the metamorph button lit up... eyeballing it probably isn't the most accurate of measurement but it seems good...)

What's this about green sruff? is there a spell to detect it (most likely)? or a completed quest? after you do the quest can you switch between normal and green? I really don't know about it and will eventually need a tester to see if it works, as I don't plan to do that quest (I actually hate warlock class, I'm just lvling it because I have all clases...).

Thanks for whatever info you can give.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » The way I address the lack of Burning Embers support in classicons.lua

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