Reply
Thread Tools Display Modes
Unread 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' />
Aerials is offline   Reply With Quote
Unread 05-26-13, 02:35 PM   #2
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
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.
Rainrider is offline   Reply With Quote
Unread 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...
Aerials is offline   Reply With Quote
Unread 05-27-13, 12:09 AM   #4
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,738
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, ShieldsUp, 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.
Phanx is offline   Reply With Quote
Unread 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.
Aerials is offline   Reply With Quote
Unread 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.
Aerials is offline   Reply With Quote
Unread 05-27-13, 12:23 PM   #7
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
Here's the parts I changed (I think they were changed at least 10%, allowing me to post this even if it's copyrighted, I can't find ANY copyright info for the plugin anywhere, so dono how legal this is...)

I added:
Lua Code:
  1. wsb.Visibility:RegisterEvent("PLAYER_ENTERING_WORLD")
to the visibility part.... he has a comment indicating that he's pissed that it doesn't show when logging in... this is a pretty easy fix, IMO...

and I changed something to:
Lua Code:
  1. local maxshards = 4 -- 3. They got rid of the glyph and made 4 baseline.
  2.             --[[
  3.             for i = 1, GetNumGlyphSockets() do
  4.                 local glyphID = select(4, GetGlyphSocketInfo(i))
  5.                 if glyphID == SPEC_WARLOCK_AFFLICTION_GLYPH_SHARDS then maxshards = 4 end
  6.             end        
  7.             --]]
I'm sure you can figure out how it was....

changed something else to:
Lua Code:
  1. local maxembers = 4 -- 3. They got rid of the glyph and made 4 baseline.
  2.             --[[
  3.             for i = 1, GetNumGlyphSockets() do
  4.                 local glyphID = select(4, GetGlyphSocketInfo(i))
  5.                 if glyphID == SPEC_WARLOCK_DESTRUCTION_GLYPH_EMBERS then maxembers = 4 end
  6.             end        
  7.             --]]

then changed / added:

Lua Code:
  1. local wasMax = false -- this was added to the main variables at the top...
  2. [...]
  3. [2] = {150/255, 50/255,  150/255, 1}, -- Fury -- changed this color
  4. [...]
  5. [4] = {225/255, 115/255,  225/255, 1}, -- Full Fury -- added this color to the table

Lua Code:
  1. local power = UnitPower("player", SPELL_POWER_DEMONIC_FURY)
  2.             local maxPower = UnitPowerMax("player", SPELL_POWER_DEMONIC_FURY)
  3.             if power >= (maxPower - 20) then wasMax = true end
  4.             if power <= 20 then wasMax = false end
  5.            
  6.             if wasMax == false then
  7.                 wsb[1]:SetStatusBarColor(unpack(Colors[SPEC_WARLOCK_DEMONOLOGY]))
  8.                 if wsb[1].bg then wsb[1].bg:SetAlpha(0.15) wsb[1].bg:SetTexture(unpack(Colors[SPEC_WARLOCK_DEMONOLOGY])) end
  9.             elseif wasMax == true then
  10.                 wsb[1]:SetStatusBarColor(unpack(Colors[SPEC_WARLOCK_DEMONOLOGY + 2]))
  11.                 if wsb[1].bg then wsb[1].bg:SetAlpha(0.15) wsb[1].bg:SetTexture(unpack(Colors[SPEC_WARLOCK_DEMONOLOGY + 2])) end
  12.             end
in two locations... they're in the visibility (when bar is spawned), and update. I was assuming people are sometimes going to log in and not enter combat at all (AH runs)... This seems redundant but I'm too lazy to think through the logic right now.

Do you see any possible issues with this all? do you know if there's a specific ammount in the default UI at which the bar will change color? It never seems to actually reach 0 and changes a bit before full...
Aerials is offline   Reply With Quote
Unread 05-27-13, 12:37 PM   #8
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
Upon looking further into it, I think Tukz or whoever it is has stopped putting anything on / updating anything on WoW Interface. His last bug response for that plugin was in 2009, and it's 2 patches behind... last comment he responded to was on August 17, 1012...

Thus the reason plugins are lame.
Aerials is offline   Reply With Quote
Unread 05-27-13, 02:54 PM   #9
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,738
Originally Posted by Aerials View Post
Thus the reason plugins are lame.
Better there's a slightly outdated plugin that needs 10 minutes of attention to update, than every layout author having to write their own warlock power elements from scratch. This seems like a strange complaint... "someone wrote 99% of the code for me, but not 100%, waaaaa, I'd rather they hadn't written anything!"

Originally Posted by Aerials View Post
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...).
If you don't like playing a lock, and aren't good at playing a lock, you can do that quest all you want and you'll never get your green fire. It's hard.

You can detect whether the player has green fire by checking if they have the spell The Codex of Xerrath -- 101508 and/or 137206 are the two spellIDs listed on Wowhead. I'm not sure if both are used in-game.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, 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!
Phanx is offline   Reply With Quote
Unread 05-27-13, 03:22 PM   #10
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
I just found the id's 137206, 101508 after SEARCHING link crazy, then saw that you had already found them lol. I'm not sure why there are two, trying to see which it is when you get the green fire, maybe horde / alli? maybe fire on / off? I dono...
Aerials is offline   Reply With Quote
Unread 05-27-13, 03:38 PM   #11
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
O.o copyrights....

Also, I'm sure I could eventually get it... Like in patch 16.2... But yeah, I suck at lock and know I'd have no chance at all currently, did some googling and saw that its hard. I don't care for the class other than to include support for the class, that's where my interest lies.

Back in 2010 I had two ouf layouts with support for something like 8 or 9 plugins... When you have to update that many and include them with your layout because the original versions won't work it becomes questionable as far as copyright goes. For example, this plugin does not say what the copyright terms are in any way. I don't know if I can distribute a modified version or not. Your ouf layout, which I love by the way, says what the terms of distributing a modified version are, but many people don't include that like you do.

In other words, fixing the bugs isn't the distressing part of plugins so much as needing to distribute something that you don't know if you're allowed to distribute.
Aerials is offline   Reply With Quote
Unread 05-27-13, 05:58 PM   #12
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,738
Originally Posted by Aerials View Post
I'm not sure why there are two, trying to see which it is when you get the green fire, maybe horde / alli? maybe fire on / off? I dono...
It could be Horde/Alliance, or it could be that one is the version you get when you complete the quest, and the other is the version you get if you un-learn it for 500g to revert to red fire, and then later go re-learn it to get your green fire back. My roommate is still trying to get it for the first time, so I can't actually check anything in-game right now.

Originally Posted by Aerials View Post
I don't care for the class other than to include support for the class, that's where my interest lies.
That's what the PTR is for.

Originally Posted by Aerials View Post
In other words, fixing the bugs isn't the distressing part of plugins so much as needing to distribute something that you don't know if you're allowed to distribute.
The description implies (to me at least) that the plugin author meant for layout authors to hack on it to meet their layout's needs, but if you're worrited about it, just write your own using the plugin as a usage example, or use mine, which already supports showing embers either as icons or as statusbars.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, 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!
Phanx is offline   Reply With Quote
Unread 05-27-13, 06:25 PM   #13
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
I found a lock willing to run /script print(IsPlayerSpell(137206)) print(IsPlayerSpell(101508)) with the spell and after unlearning it (I tip well). with the spell, both return true, after unlearning it, both return false... there seems to be absolutely no point in having both ID's, but maybe they needed one for the form change and one for the change to coloring... I dono, don't really care, all I needed to know is that they are both true while they have it and both false if they disable it.

I don't really see the purpose to knowing though, maybe I'll hit up YouTube and see if it changes the colors of the bars / etc... while it's learned.

EDIT:: Yup, they turn an ugly green.... meh.

Last edited by Aerials : 05-27-13 at 06:29 PM.
Aerials is offline   Reply With Quote
Unread 05-27-13, 08:39 PM   #14
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
Just use WARLOCK_GREEN_FIRE (as seen in the default ui). You don't need to register PLAYER_ENTERING_WORLD as oUF will update your units on that event. You could take a look at my implementation too if you wish (found here). If you find something useful there, use it as you wish.
Rainrider is offline   Reply With Quote
Unread 05-27-13, 09:07 PM   #15
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
I ended up using:
Code:
local lockHasGreen = IsPlayerSpell(137206)
[...]
if lockHasGreen then
[etc...]

This part of that would have saved me quite a while, lol... I didn't know you could check a spell like this:
Code:
if (IsSpellKnown(WARLOCK_GREEN_FIRE)) then
oh well. I may look over the way you have done it all later, but for now I like how I have it. I can't really test it, but it should work (lol...). They're the same power type I think (just a cosmetic difference), so it should be fine.

My colors currently:
Code:
local Colors = { 
	[1] = {148/255, 130/255, 201/255, 1}, -- Shards
	[2] = {150/255, 50/255,  150/255, 1}, -- Fury
	[3] = {222/255, 95/255,  95/255, 1}, -- Embers
	[4] = {225/255, 115/255,  225/255, 1}, -- Full Fury
	[5] = {95/255, 222/255,  95/255, 1}, -- Green Fire
}
Aerials is offline   Reply With Quote
Unread 05-28-13, 07:26 AM   #16
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
Normally it's a good idea to check the default implementation to see what events blizzard uses for setting up and updating. There are often some constants like WARLOCK_GREEN_FIRE, that you can use too and that are likely to remain usable if they change the spell id. It is also more descriptive when you read the code later. As for the green fire, yes, it is just a cosmetic change, not one regarding the power type or the way it works. It leads to a change though - you must keep SPELLS_CHANGED registered for the element for destro locks if you want to support it.
Rainrider is offline   Reply With Quote
Reply

Go BackWoWInterface » 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