Thread Tools Display Modes
02-23-16, 10:55 PM   #1
jeAz_
A Deviate Faerie Dragon
Join Date: Feb 2016
Posts: 13
oUF - ClassIcons

Let me apologize that I'm writing multiple threads within a short term

So, here's my new questions.

I was trying to create "ClassIcon Bar" with "ClassIcon" element.

However, there was few problems with this.

Have a look at the code first:
Lua Code:
  1. A.CreateClassIcons = function(f, unit)
  2.     local _, Class = UnitClass(unit);
  3.     local MaxPower;
  4.     local ClassIcons = {};
  5.     local ClassIconName = {
  6.         Monk = "ChiOrb",
  7.         Paladin = "HolyPower",
  8.         Priest = "ShadowOrb",
  9.         Warlock = "SoulShard",
  10.     };
  11.     local ClassIconColor = {
  12.         Monk = {
  13.             r = 0.52,
  14.             g = 0.90,
  15.             b = 0.50,
  16.         },
  17.  
  18.         Paladin = {
  19.             r = 1.00,
  20.             g = 0.70,
  21.             b = 0.85,
  22.         },
  23.  
  24.         Priest = {
  25.             r = 1.00,
  26.             g = 1.00,
  27.             b = 1.00,
  28.         },
  29.         Warlock = {
  30.             r = 0.65,
  31.             g = 0.40,
  32.             b = 1.00,
  33.         },
  34.     };
  35.  
  36.     if (Class == "MONK") then
  37.         MaxPower = UnitPowerMax(unit, SPELL_POWER_CHI);
  38.     end
  39.  
  40.     local lowerClass = A.FirstToUpper(Class);
  41.  
  42.     for i = 1, 6 do
  43.         local ClassIcon = CreateFrame("Frame", ("YUI_" .. ClassIconName[lowerClass] .. i), f);
  44.    
  45.         ClassIcon:SetBackdrop({
  46.             bgFile = BACKDROP,
  47.             tile = true,
  48.             tileSize = 16,
  49.         });
  50.         ClassIcon:SetBackdropColor(0.1, 0.1, 0.1, 1);
  51.         ClassIcon:SetWidth((G[unit]["width"] - (MaxPower - 1)) / MaxPower);
  52.         ClassIcon:SetHeight(16);
  53.  
  54.         if i == 1 then
  55.             ClassIcon:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 0, -2);
  56.         else
  57.             ClassIcon:SetPoint("LEFT", ClassIcons[i - 1], "RIGHT", 1, 0);
  58.         end
  59.  
  60.         local texture = ClassIcon:CreateTexture(nil, "OVERLAY");
  61.         texture:SetTexture(COMBO_POINT);
  62.         texture:SetVertexColor(ClassIconColor[lowerClass]["r"], ClassIconColor[lowerClass]["g"], ClassIconColor[lowerClass]["b"], 1);
  63.         texture:SetWidth(ClassIcon:GetWidth() - 4);
  64.         texture:SetHeight(ClassIcon:GetHeight() - 4);
  65.         texture:SetPoint("CENTER");
  66.  
  67.         ClassIcon.texture = texture;
  68.         ClassIcons[i] = ClassIcon;
  69.     end
  70.  
  71.     f.ClassIcons = ClassIcons;
  72. end

The first issue with this code is that when I enter the game, "UnitPowerMax(unit, SPELL_POWER_CHI)" returns 0 and only returns the proper value when I reload the game.

The next issue is that since I'm using my own textures for Chi, I have to update the size and position of icon if I select "Ascension (Monk Talent: 3/2)" which increases max number of chi by 1. However, it seems not working as I expected ...

Lastly, instead of utilizing default "ClassIcons" element, I was trying to create my own element module for each classes, Monk, Warlock, Priest and Paladin. So, I've attempted to interpret the original "ClassIcons" module, but as a newbie, it was pretty complex to understand what each function performs.

Could anyone please help me with interpreting this module

Last edited by jeAz_ : 02-23-16 at 11:41 PM.
  Reply With Quote
02-24-16, 02:46 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I did my own classbars for oUF_Diablo. They can be found under modules.
https://github.com/zorker/rothui/tre...Diablo/modules

Example for Harmony:
https://github.com/zorker/rothui/blo...UF_Harmony.lua

On top of that make sure to check out the wow api changes for legion regarding that topic:
http://www.wowinterface.com/forums/s...ad.php?t=53140

Taking a look at rClassBars may help out aswell.
http://www.wowinterface.com/download...ClassBars.html
__________________
| 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
02-24-16, 03:42 AM   #3
jeAz_
A Deviate Faerie Dragon
Join Date: Feb 2016
Posts: 13
Originally Posted by zork View Post
I did my own classbars for oUF_Diablo. They can be found under modules.
https://github.com/zorker/rothui/tre...Diablo/modules

Example for Harmony:
https://github.com/zorker/rothui/blo...UF_Harmony.lua

On top of that make sure to check out the wow api changes for legion regarding that topic:
http://www.wowinterface.com/forums/s...ad.php?t=53140

Taking a look at rClassBars may help out aswell.
http://www.wowinterface.com/download...ClassBars.html
Hi zork,

Thank you for those nice references, and let me ask step by step.


About Default "classicon.lua":

1. On default oUF's default "classicon.lua" there is "PreUpdate" and "PostUpdate" functions. I understand when they are triggered, but ain't sure of what they actually process. Could you please explain me, if you know about them?


About your "oUF_Harmony.lua":

2. On your "oUF_Harmony.lua", it contains the following codes:
Lua Code:
  1. local w = 64*(max+2)
  2. bar:SetWidth(w)
  3. for i = 1, bar.maxOrbs do
  4.   local orb = self.Harmony[i]
  5.   if i > max then
  6.      if orb:IsShown() then orb:Hide() end
  7.   else
  8.     if not orb:IsShown() then orb:Show() end
  9.   end
  10. end
  11. for i = 1, max do
  12.   local orb = self.Harmony[i]
  13.   local full = num/max
  14.   if(i <= num) then
  15.     if full == 1 then
  16.       orb.fill:SetVertexColor(1,0,0)
  17.       orb.glow:SetVertexColor(1,0,0)
  18.     else
  19.       orb.fill:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  20.       orb.glow:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  21.     end
  22.     orb.fill:Show()
  23.     orb.glow:Show()
  24.     orb.highlight:Show()
  25.   else
  26.     orb.fill:Hide()
  27.     orb.glow:Hide()
  28.     orb.highlight:Hide()
  29.   end
  30. end

If I'm going set the appearance of "Chi Orbs" outside of this module, do I still have to have

local w = 64*(max+2)
bar:SetWidth(w)

and

second "for" loop?

3. Where does "bar.maxOrbs" come from?

4. How does "ForceUpdate" and "Path" functions work?

5. On "ForceUpdate" function and "Enable" function, there is "element.__owner". Does "__" mean something special in Lua when you are indexing an element from table?




Please excuse me if I'm asking too many questions.
  Reply With Quote
02-24-16, 04:18 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
1. Pre and Postupdate are hook functions. They let you manipulate values in case you need to do that to make the function process data correctly. Example you can change the color PostUpdate.
2. My chi bar has textures that are left and right of the orbs. Orbs number is dynamic depending on talents and what not. Thus I need to make sure that if the number of orbs changes the final bar still looks good. See 3.
3. My max orb value is hardcoded upon bar creation. That number could have been 10 or 100, but you know. The less frames you create the better.
https://github.com/zorker/rothui/blo.../bars.lua#L204
4. When the visibility changes a force update is needed to trigger the power update. You are right that I may have not needed the Path function but it gives you the ability to define a an Override function for a specific element. Like...you spawn 2 chi orb bars for example and want one to behave differently on update. That is where override is needed.
5. Nothing special. Just a prefix haste was using for the root element. (each bar is anchored to a root frame aka owner)
__________________
| 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
02-24-16, 07:10 PM   #5
jeAz_
A Deviate Faerie Dragon
Join Date: Feb 2016
Posts: 13
Originally Posted by zork View Post
1. Pre and Postupdate are hook functions. They let you manipulate values in case you need to do that to make the function process data correctly. Example you can change the color PostUpdate.
2. My chi bar has textures that are left and right of the orbs. Orbs number is dynamic depending on talents and what not. Thus I need to make sure that if the number of orbs changes the final bar still looks good. See 3.
3. My max orb value is hardcoded upon bar creation. That number could have been 10 or 100, but you know. The less frames you create the better.
https://github.com/zorker/rothui/blo.../bars.lua#L204
4. When the visibility changes a force update is needed to trigger the power update. You are right that I may have not needed the Path function but it gives you the ability to define a an Override function for a specific element. Like...you spawn 2 chi orb bars for example and want one to behave differently on update. That is where override is needed.
5. Nothing special. Just a prefix haste was using for the root element. (each bar is anchored to a root frame aka owner)
2. So, the purpose of following lines of code in "oUF_Harmony.lua":

Lua Code:
  1. local w = 64*(max+2)
  2. bar:SetWidth(w)

and

Lua Code:
  1. for i = 1, max do
  2.   local orb = self.Harmony[i]
  3.   local full = num/max
  4.   if(i <= num) then
  5.     if full == 1 then
  6.       orb.fill:SetVertexColor(1,0,0)
  7.       orb.glow:SetVertexColor(1,0,0)
  8.     else
  9.       orb.fill:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  10.       orb.glow:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  11.     end
  12.     orb.fill:Show()
  13.     orb.glow:Show()
  14.     orb.highlight:Show()
  15.   else
  16.     orb.fill:Hide()
  17.     orb.glow:Hide()
  18.     orb.highlight:Hide()
  19.   end
  20. end

is to re-size the bar's width when there is a update on talent or spec which affects the max number of chi.

Am I getting it right?


6. Also, I still don't get why I can't get a "UnitPowerMax("player", SPELL_POWER_CHI)" doesn't work on Player Login...

I have read through about Legion's API Change that you wrote, but since that is being applied from Legion, I don't think this issue is related to that yet.

7.(???) Did you make those textures by yourself?

They look so cool !!

Last edited by jeAz_ : 02-24-16 at 10:32 PM.
  Reply With Quote
02-25-16, 02:46 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
2. Yes
6. I had some issues with ouf element registration aswell. That is why I am doing nasty things like this
https://github.com/zorker/rothui/blo...armony.lua#L90
Not sure why the event is not firing properly for the element.
7. Yes, I made the textures myself in the process of creating Roth UI. Some of them are based on Blizzard art, some of them are made from scratch.
__________________
| 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

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF - ClassIcons


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