Thread Tools Display Modes
07-25-16, 08:02 PM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Creating UnitFrame with oUF

Hi all,

It's been a while since I posted my last thread here.

I was damn busy for last couple of months finishing my work and finally back here to solve this old problem + new minor problem with the pre-patch of Legion.

1. As I replied on thread below this post (http://www.wowinterface.com/forums/s...4&postcount=22), I am still having an issue with creating reverse fill of status bar and flipping status bar texture. I've tried with both haste's and monolit's approaches, but failed on making it work.

Lua Code:
  1. Health:SetReverseFill(true);
  2. Health.PostUpdate = function(Health, unit, min, max)
  3.    Health:SetValue(max - Health:GetValue());
  4. end

Lua Code:
  1. A.CreateHealthBar = function(f, unit)
  2.     local Health;
  3.  
  4.     if unit == "player" or unit == "targettarget" then
  5.         Health = CreateFrame("StatusBar", f:GetName() .. "HealthBar", f);
  6.     elseif unit == "target" then
  7.         Health = A.ReverseStatusBar(f);
  8.         Health.PostUpdate = A.PostUpdateHealth;
  9.     end
  10.  
  11.     Health:SetFrameLevel(Health:GetFrameLevel() + 1);
  12.     Health:SetStatusBarTexture(HEALTH_BAR);
  13.     Health:SetStatusBarColor(0.85, 0.86, 0.84, 1);
  14.  
  15.     if unit == "player" then
  16.         Health:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -1);
  17.         Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
  18.     elseif unit == "target" then
  19.         Health:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
  20.         Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
  21.     elseif unit == "targettarget" then
  22.         Health:SetPoint("TOP", f, "TOP", 0, -1);
  23.         Health:SetSize(f:GetWidth() - 22, f:GetHeight() - 12);
  24.     end
  25.  
  26.     Health.bg = Health:CreateTexture(nil, "BACKGROUND");
  27.     Health.bg:SetAllPoints(true);
  28.     Health.bg:SetTexture(BACKDROP);
  29.     Health.bg:SetVertexColor(0.08, 0.08, 0.08, 1);
  30.  
  31.     f.Health = Health;
  32.     f.Health.bg = Health.bg;
  33. end
  34.  
  35. -- Thanks to Monolit from WoWInterface for sharing this code!
  36. local StatusBarUpdaterOnUpdate;
  37. local StatusBarOnChanged;
  38. A.ReverseStatusBar = function(f, unit)
  39.     local statusbar = CreateFrame("Statusbar", f:GetName() .. "HealthBar", f);
  40.     statusbar.updater = CreateFrame("Frame", nil, statusbar);
  41.     statusbar.updater:Hide();
  42.     statusbar.updater:SetScript("OnUpdate", StatusBarUpdaterOnUpdate);
  43.  
  44.     statusbar:SetScript("OnSizeChanged", StatusBarOnChanged);
  45.     statusbar:SetScript("OnValueChanged", StatusBarOnChanged);
  46.     statusbar:SetScript("OnMinMaxChanged", StatusBarOnChanged);
  47.  
  48.     return statusbar;
  49. end
  50.  
  51. StatusBarUpdaterOnUpdate = function(updater)
  52.     updater:Hide();
  53.  
  54.     local b = updater:GetParent();
  55.  
  56.     local tex = b:GetStatusBarTexture();
  57.     tex:ClearAllPoints();
  58.     tex:SetPoint("BOTTOMRIGHT");
  59.     tex:SetPoint("TOPLEFT", b, "TOPRIGHT", (b:GetValue() / select(2, b:GetMinMaxValues()) - 1) * b:GetWidth(), 0);
  60.  
  61.     local d = select(2, b:GetMinMaxValues());
  62.  
  63.     local x;
  64.  
  65.     if d ~= 0 then
  66.         x = (b:GetValue() / (d - 1)) * b:GetWidth();
  67.     end
  68.  
  69.     tex:SetPoint("TOPLEFT", b, "TOPRIGHT", x, 0);
  70. end
  71.  
  72. StatusBarOnChanged = function(statusbar)
  73.     statusbar.updater:Show();
  74. end
  75.  
  76. A.PostUpdateHealth = function(statusbar, unit, min, max)
  77.     if UnitIsDeadOrGhost(unit) then
  78.         statusbar:SetValue(0);
  79.     end
  80. end

2. I was trying to create a combo points bar with using lightspark's version of oUF.

For rogue, selecting 'Deeper Stratagem' as Tier 3 talent will increase its maximum combo point from 5 to 6 and I am not sure how I could apply this on oUF. I've attempted with MAX_COMBO_POINTS, but since this value is a constant, it does not seem to be working.

Lua Code:
  1. A.CreateComboPoints = function(f, unit)
  2.     local CPoints = {};
  3.  
  4.     for i = 1, MAX_COMBO_POINTS do
  5.         local CPoint = CreateFrame("Frame", f:GetName() .. "ComboPoint" .. i, f);
  6.         CPoint:SetWidth((f:GetWidth() - ((MAX_COMBO_POINTS - 1) * 5) - (MAX_COMBO_POINTS * 2 * 1)) / MAX_COMBO_POINTS);
  7.         CPoint:SetHeight(8);
  8.  
  9.         if i == 1 then
  10.             CPoint:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 1, -5);
  11.         else
  12.             CPoint:SetPoint("LEFT", CPoints[i - 1], "RIGHT", 7, 0);
  13.         end
  14.  
  15.         local texture = CPoint:CreateTexture(nil, "OVERLAY");
  16.         texture:SetSize(CPoint:GetSize());
  17.         texture:SetPoint("CENTER");
  18.         texture:SetTexture(COMBO_POINT);
  19.         texture:SetVertexColor(0.95, 0.38, 0.65, 1);
  20.  
  21.         CPoint.texture = texture;
  22.  
  23.         CPoints[i] = CPoint;
  24.     end
  25.  
  26.     f.CPoints = CPoints;
  27. end

Could I get some help regarding those?

Thank you!

Last edited by Layback_ : 07-25-16 at 08:05 PM.
  Reply With Quote
07-25-16, 08:14 PM   #2
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Do not use CPoints widget, use ClassIcons instead.

BTW, you can have up to 8 combo points at once.

P.S. I proposed to remove CPoints from oUF, but I'll removed them from my version w/ next update.
__________________

Last edited by lightspark : 07-25-16 at 08:24 PM.
  Reply With Quote
07-25-16, 08:31 PM   #3
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
As for reversed status bars, what are you trying to achieve w/ that weird updater thingy? O_o

statusbar:SetReverseFill(true) works fine, I use it myself and never had issues w/ it.

Here is my target frame w/ reversed health bar.



I added 1 line of code.

Do something like this and you should be fine

Lua Code:
  1. local Health = CreateFrame("StatusBar", "$parentHealthBar", f);
  2.  
  3. if unit == "target" then
  4.     Health:SetReverseFill(true);
  5.     Health.PostUpdate = A.PostUpdateHealth;
  6. end
__________________

Last edited by lightspark : 07-25-16 at 08:49 PM.
  Reply With Quote
07-25-16, 08:58 PM   #4
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by lightspark View Post
As for reversed status bars, what are you trying to achieve w/ that weird updater thingy? O_o

statusbar:SetReverseFill(true) works fine, I use it myself and never had issues w/ it.

Here is my target frame w/ reversed health bar.



I added 1 line of code.
Hi lightspark!

I honestly don't know how that updater things works, but I brought it from monolit's old post

About statusbar:SetReverseFill(true), yeah it works fine with pure solid textures, but behaves bit weird when the texture has some sort of shape on it.

Please have a look at the .gif image that I captured



The frame on the left is a player's frame while the one on the right is a target's frame.

As you can see, the shape on player's frame stays on its position, but the shape on target's frame is moving as the value changes.

Lua Code:
  1. A.CreateHealthBar = function(f, unit)
  2.     local Health;
  3.     Health = CreateFrame("StatusBar", f:GetName() .. "HealthBar", f);
  4.  
  5.     if unit == "target" then
  6.         Health:SetReverseFill(true);
  7.     end
  8.  
  9.     Health:SetFrameLevel(Health:GetFrameLevel() + 1);
  10.     Health:SetStatusBarTexture(HEALTH_BAR);
  11.     Health:SetStatusBarColor(0.74, 0.81, 0.76, 1);
  12.  
  13.     if unit == "player" then
  14.         Health:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -1);
  15.         Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
  16.     elseif unit == "target" then
  17.         Health:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
  18.         Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
  19.     elseif unit == "targettarget" then
  20.         Health:SetPoint("TOP", f, "TOP", 0, -1);
  21.         Health:SetSize(f:GetWidth() - 22, f:GetHeight() - 12);
  22.     end
  23.  
  24.     Health.bg = Health:CreateTexture(nil, "BACKGROUND");
  25.     Health.bg:SetAllPoints(true);
  26.     Health.bg:SetTexture(BACKDROP);
  27.  
  28.     f.Health = Health;
  29.     f.Health.bg = Health.bg;
  30. end

I want that shape stays still instead of it moving as the value changes.

Also, if possible, I would like to flip the texture it horizontally as well for target frame!

Thank you.
  Reply With Quote
07-25-16, 09:14 PM   #5
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by Layback_ View Post
Hi lightspark!

I honestly don't know how that updater things works, but I brought it from monolit's old post

About statusbar:SetReverseFill(true), yeah it works fine with pure solid textures, but behaves bit weird when the texture has some sort of shape on it.

Please have a look at the .gif image that I captured



The frame on the left is a player's frame while the one on the right is a target's frame.

As you can see, the shape on player's frame stays on its position, but the shape on target's frame is moving as the value changes.

-- code here

I want that shape stays still instead of it moving as the value changes.

Also, if possible, I would like to flip the texture it horizontally as well for target frame!

Thank you.
Ak, makes sense then. That's why I never use status bar textures w/ some sort of artwork on them, I prefer to use overlay textures, otherwise too much hustle. Simplest workaround is to create a texture w/ those three stripes and place it on top of health bar whereever you need them T_T That's what I'd do.

-- update

Texture like this, so you can colour it, size it and place it whichever way you want.



Here's TGA.

P.S. You can flip it horizontally via texture:SetTexCoord(1, 0, 0, 1).
__________________

Last edited by lightspark : 07-25-16 at 09:47 PM.
  Reply With Quote
07-25-16, 09:46 PM   #6
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by lightspark View Post
Ak, makes sense then. That's why I never use status bar textures w/ some sort of artwork on them, I prefer to use overlay textures, otherwise too much hustle. Simplest workaround is to create a texture w/ those three stripes and place it on top of health bar whereever you need them T_T That's what I'd do.

-- update

Texture like this, so you can colour it, size it and place it whichever way you want.



Here's TGA.
Hm... that could be the easiest workaround for me to deal with!

How about this?

Few months ago, a guy called 'zork' explained me with his approach which I honestly failed to understand

Thankfully, he shared his code and result as well.

thread: http://www.wowinterface.com/forums/showthread.php?t=53203
oUF_Doom from zork's github: https://github.com/zorker/rothui/tree/master/wow6.0/oUF_Doom
oUF_Doom result: http://imgur.com/a/BHfcs

If you don't mind, could you please have a look and explain me how this works?!
  Reply With Quote
07-25-16, 10:01 PM   #7
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by Layback_ View Post
Hm... that could be the easiest workaround for me to deal with!

How about this?

Few months ago, a guy called 'zork' explained me with his approach which I honestly failed to understand

Thankfully, he shared his code and result as well.

thread: http://www.wowinterface.com/forums/showthread.php?t=53203
oUF_Doom from zork's github: https://github.com/zorker/rothui/tree/master/wow6.0/oUF_Doom
oUF_Doom result: http://imgur.com/a/BHfcs

If you don't mind, could you please have a look and explain me how this works?!
In his case status bar (health) works as a controller, it has no texture, it's there to calculate values, those values are used to crop a texture (doomHealth), which is used as a fake or substitute status bar texture, the one you see.
__________________
  Reply With Quote
07-25-16, 10:46 PM   #8
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by lightspark View Post
In his case status bar (health) works as a controller, it has no texture, it's there to calculate values, those values are used to crop a texture (doomHealth), which is used as a fake or substitute status bar texture, the one you see.
So, "Health" is sitting at the back to calculate the value while "DoomHealth" is sitting at the front to show the visual things...

Am I getting it right...?

mmmmmmmmmmmmmm......

This is so tricky

Maybe, I should take more time to consider this.

Thank you for your explanation!!!!!!


=============================================================================


So!!!!

About class icons, as you advised me, I have switched ComboPoints to ClassIcons

Lua Code:
  1. A.CreateClassIcons = function(f, unit)
  2.     local _, englishClass = UnitClass("player");
  3.  
  4.     local powerType;
  5.  
  6.     if englishClass == "MONK" then
  7.         powerType = SPELL_POWER_CHI;
  8.     elseif englishClass == "PALADIN" then
  9.         powerType = SPELL_POWER_HOLY_POWER;
  10.     elseif englishClass == "PRIEST" then
  11.         powerType = SPELL_POWER_SHADOW_ORBS;
  12.     elseif englishClass == "WARLOCK" then
  13.         powerType = SPELL_POWER_SOUL_SHARDS;
  14.     elseif englishClass == "ROGUE" or "DRUID" then
  15.         powerType = SPELL_POWER_COMBO_POINTS;
  16.     elseif englishClass == "MAGE" then
  17.         powerType = SPELL_POWER_ARCANE_CHARGES;
  18.     end
  19.  
  20.     local maxpower = UnitPowerMax("player", powerType);
  21.  
  22.     local ClassIcons = {};
  23.  
  24.     for i = 1, 6 do
  25.         local ClassIcon = CreateFrame("Frame", f:GetName() .. "ClassIcon" .. i, f);
  26.         ClassIcon:SetWidth((f:GetWidth() - ((maxpower - 1) * 5) - (maxpower * 2 * 1)) / maxpower);
  27.         ClassIcon:SetHeight(8);
  28.  
  29.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"BOTTOMRIGHT", ClassIcon, "TOPLEFT", 0, 0}, {0, 0, 0, 1});
  30.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"BOTTOMLEFT", ClassIcon, "TOPRIGHT", 0, 0}, {0, 0, 0, 1});
  31.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"TOPRIGHT", ClassIcon, "BOTTOMLEFT", 0, 0}, {0, 0, 0, 1});
  32.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"TOPLEFT", ClassIcon, "BOTTOMRIGHT", 0, 0}, {0, 0, 0, 1});
  33.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {ClassIcon:GetWidth(), 1}, {"BOTTOM", ClassIcon, "TOP", 0, 0}, {0, 0, 0, 1});
  34.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {ClassIcon:GetWidth(), 1}, {"TOP", ClassIcon, "BOTTOM", 0, 0}, {0, 0, 0, 1});
  35.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, ClassIcon:GetHeight()}, {"RIGHT", ClassIcon, "LEFT", 0, 0}, {0, 0, 0, 1});
  36.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, ClassIcon:GetHeight()}, {"LEFT", ClassIcon, "RIGHT", 0, 0}, {0, 0, 0, 1});
  37.  
  38.         if i == 1 then
  39.             ClassIcon:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 1, -6);
  40.         else
  41.             ClassIcon:SetPoint("LEFT", ClassIcons[i - 1], "RIGHT", 7, 0);
  42.         end
  43.  
  44.         local texture = ClassIcon:CreateTexture(nil, "OVERLAY");
  45.         texture:SetSize(ClassIcon:GetSize());
  46.         texture:SetPoint("CENTER");
  47.         texture:SetTexture(COMBO_POINT);
  48.         texture:SetVertexColor(0.95, 0.38, 0.65, 1);
  49.  
  50.         ClassIcon.texture = texture;
  51.  
  52.         ClassIcons[i] = ClassIcon;
  53.     end
  54.  
  55.     f.ClassIcons = ClassIcons;
  56. end

Unfortunately, since I am trying to use my own design(?) to display icons, I'm currently having some issue when I change spec or talent.

For example, when 'Deeper Stratagem' was initially deactivated on AddOn load and activate it later via talent or spec change, this results in...


Additionally, when 'Deeper Stratagem' was initially activated on AddOn load and deactivate it later via talent or spec change, this results in...


As you can see, the size of each icon does not change on PLAYER_TALENT_UPDATE.

I guess I'll have to manually edit it within ClassIcon element, but I ain't sure how I should start this ...

Could you please advise me regarding this?!
  Reply With Quote
07-26-16, 01:29 AM   #9
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by Layback_ View Post
So!!!!

About class icons, as you advised me, I have switched ComboPoints to ClassIcons

-- code

Unfortunately, since I am trying to use my own design(?) to display icons, I'm currently having some issue when I change spec or talent.

For example, when 'Deeper Stratagem' was initially deactivated on AddOn load and activate it later via talent or spec change, this results in...
-- pic

Additionally, when 'Deeper Stratagem' was initially activated on AddOn load and deactivate it later via talent or spec change, this results in...
-- pic

As you can see, the size of each icon does not change on PLAYER_TALENT_UPDATE.

I guess I'll have to manually edit it within ClassIcon element, but I ain't sure how I should start this ...

Could you please advise me regarding this?!
Y u do dis?

I use my own design w/ animations and other (unnecessary) things, and it works. There's no need for you to edit ClassIcons, cuz you fail to understand how ClassIcons widget works. It handles spec/talent/power switching well.

I'll come back later and post reworked version of your code.

-- update #1

The size wasn't changed on PLAYER_TALENT_UPDATE, because you didn't write code to resize it It doesn't happen on its own. All changes to class icons should be done in widget's PostUpdate.

-- upadte #2

Lua Code:
  1. local function ClassIconsPostUpdate(classicons, cur, max, maxChanged, powerType, event)
  2.     if maxChanged then
  3.         -- unit frame width
  4.         local width = classicons.__owner:GetWidth();
  5.  
  6.         for i = 1, max do
  7.             classicons[i]:SetWidth((width - ((max - 1) * 5) - (max * 2 * 1)) / max);
  8.         end
  9.     end
  10. end
  11.  
  12. A.CreateClassIcons = function(f, unit)
  13.     local ClassIcons = {};
  14.  
  15.     -- right now usable max is 8, but according to blizz code you may have up to 9
  16.     for i = 1, 9 do
  17.         local ClassIcon = CreateFrame("Frame", "$parentClassIcon" .. i, f);
  18.         ClassIcon:SetHeight(8);
  19.  
  20.         if i == 1 then
  21.             ClassIcon:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 1, -6);
  22.         else
  23.             ClassIcon:SetPoint("LEFT", ClassIcons[i - 1], "RIGHT", 7, 0);
  24.         end
  25.  
  26.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"BOTTOMRIGHT", ClassIcon, "TOPLEFT", 0, 0}, {0, 0, 0, 1});
  27.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"BOTTOMLEFT", ClassIcon, "TOPRIGHT", 0, 0}, {0, 0, 0, 1});
  28.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"TOPRIGHT", ClassIcon, "BOTTOMLEFT", 0, 0}, {0, 0, 0, 1});
  29.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"TOPLEFT", ClassIcon, "BOTTOMRIGHT", 0, 0}, {0, 0, 0, 1});
  30.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {ClassIcon:GetWidth(), 1}, {"BOTTOM", ClassIcon, "TOP", 0, 0}, {0, 0, 0, 1});
  31.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {ClassIcon:GetWidth(), 1}, {"TOP", ClassIcon, "BOTTOM", 0, 0}, {0, 0, 0, 1});
  32.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, ClassIcon:GetHeight()}, {"RIGHT", ClassIcon, "LEFT", 0, 0}, {0, 0, 0, 1});
  33.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, ClassIcon:GetHeight()}, {"LEFT", ClassIcon, "RIGHT", 0, 0}, {0, 0, 0, 1});
  34.  
  35.         local texture = ClassIcon:CreateTexture(nil, "OVERLAY");
  36.         texture:SetSize(ClassIcon:GetSize());
  37.         texture:SetPoint("CENTER");
  38.         texture:SetTexture(COMBO_POINT);
  39.         texture:SetVertexColor(0.95, 0.38, 0.65, 1);
  40.  
  41.         ClassIcon.texture = texture;
  42.  
  43.         ClassIcons[i] = ClassIcon;
  44.     end
  45.  
  46.     -- you should resize icons here!
  47.     ClassIcons.PostUpdate = ClassIconsPostUpdate
  48.  
  49.     f.ClassIcons = ClassIcons;
  50. end

That should do the trick.
__________________

Last edited by lightspark : 07-26-16 at 02:00 AM.
  Reply With Quote
07-26-16, 03:06 AM   #10
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by lightspark View Post
Y u do dis?

I use my own design w/ animations and other (unnecessary) things, and it works. There's no need for you to edit ClassIcons, cuz you fail to understand how ClassIcons widget works. It handles spec/talent/power switching well.

I'll come back later and post reworked version of your code.

-- update #1

The size wasn't changed on PLAYER_TALENT_UPDATE, because you didn't write code to resize it It doesn't happen on its own. All changes to class icons should be done in widget's PostUpdate.

-- upadte #2

Lua Code:
  1. local function ClassIconsPostUpdate(classicons, cur, max, maxChanged, powerType, event)
  2.     if maxChanged then
  3.         -- unit frame width
  4.         local width = classicons.__owner:GetWidth();
  5.  
  6.         for i = 1, max do
  7.             classicons[i]:SetWidth((width - ((max - 1) * 5) - (max * 2 * 1)) / max);
  8.         end
  9.     end
  10. end
  11.  
  12. A.CreateClassIcons = function(f, unit)
  13.     local ClassIcons = {};
  14.  
  15.     -- right now usable max is 8, but according to blizz code you may have up to 9
  16.     for i = 1, 9 do
  17.         local ClassIcon = CreateFrame("Frame", "$parentClassIcon" .. i, f);
  18.         ClassIcon:SetHeight(8);
  19.  
  20.         if i == 1 then
  21.             ClassIcon:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 1, -6);
  22.         else
  23.             ClassIcon:SetPoint("LEFT", ClassIcons[i - 1], "RIGHT", 7, 0);
  24.         end
  25.  
  26.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"BOTTOMRIGHT", ClassIcon, "TOPLEFT", 0, 0}, {0, 0, 0, 1});
  27.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"BOTTOMLEFT", ClassIcon, "TOPRIGHT", 0, 0}, {0, 0, 0, 1});
  28.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"TOPRIGHT", ClassIcon, "BOTTOMLEFT", 0, 0}, {0, 0, 0, 1});
  29.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, 1}, {"TOPLEFT", ClassIcon, "BOTTOMRIGHT", 0, 0}, {0, 0, 0, 1});
  30.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {ClassIcon:GetWidth(), 1}, {"BOTTOM", ClassIcon, "TOP", 0, 0}, {0, 0, 0, 1});
  31.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {ClassIcon:GetWidth(), 1}, {"TOP", ClassIcon, "BOTTOM", 0, 0}, {0, 0, 0, 1});
  32.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, ClassIcon:GetHeight()}, {"RIGHT", ClassIcon, "LEFT", 0, 0}, {0, 0, 0, 1});
  33.         A.CreateBorder(ClassIcon, "Border", BACKDROP, {1, ClassIcon:GetHeight()}, {"LEFT", ClassIcon, "RIGHT", 0, 0}, {0, 0, 0, 1});
  34.  
  35.         local texture = ClassIcon:CreateTexture(nil, "OVERLAY");
  36.         texture:SetSize(ClassIcon:GetSize());
  37.         texture:SetPoint("CENTER");
  38.         texture:SetTexture(COMBO_POINT);
  39.         texture:SetVertexColor(0.95, 0.38, 0.65, 1);
  40.  
  41.         ClassIcon.texture = texture;
  42.  
  43.         ClassIcons[i] = ClassIcon;
  44.     end
  45.  
  46.     -- you should resize icons here!
  47.     ClassIcons.PostUpdate = ClassIconsPostUpdate
  48.  
  49.     f.ClassIcons = ClassIcons;
  50. end

That should do the trick.
God.... You r just genius!!!!

Just to make things clear, I had to add this line of code:

Lua Code:
  1. classicons[i].texture:SetSize(classicons[i]:GetSize());

after

Lua Code:
  1. classicons[i]:SetWidth((width - ((max - 1) * 5) - (max * 2 * 1)) / max);

Otherwise, the texture itself gets massive.

Thank you so much for your help!!!
  Reply With Quote
07-26-16, 03:09 AM   #11
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
You dun need to, there's an easier way to handle it.

Lua Code:
  1. local texture = ClassIcon:CreateTexture(nil, "OVERLAY");
  2. texture:SetAllPoints();
  3. texture:SetTexture(COMBO_POINT);
  4. texture:SetVertexColor(0.95, 0.38, 0.65, 1);

Create textures like so.
__________________
  Reply With Quote
07-26-16, 04:36 AM   #12
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by lightspark View Post
You dun need to, there's an easier way to handle it.

Lua Code:
  1. local texture = ClassIcon:CreateTexture(nil, "OVERLAY");
  2. texture:SetAllPoints();
  3. texture:SetTexture(COMBO_POINT);
  4. texture:SetVertexColor(0.95, 0.38, 0.65, 1);

Create textures like so.
You are totally right!

I gotta study harder
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Creating UnitFrame with oUF


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