Thread Tools Display Modes
03-10-24, 06:05 PM   #1
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Setting Class Icon via SetAtlas and GetClassAtlas doesn't seem to work for me

As the title says.

I've been trying to create a custom unit frame piece by piece ( for reasons - have you seen nUI's archaic code? rofl ) and have stumbled on the portrait part.

Based on Blizzards code here : https://github.com/Gethe/wow-ui-sour...Frame.lua#L166

I have a simple frame with a texture which accepts the SetPortraitTexture image quite fine.
However, when I toggle on 'ReplaceMyFramePortrait' interface option and use the following code to use a different image it doesn't work.

My first attempt was this, which correctly retrieved the value from the GetCVar function and the classIconAtlas is set to classicon-WARLOCK which I can assume is correct as that is Blizzards function.
Now, the Blizzard PlayerFrame correctly makes the change, however, mine does not.
Lua Code:
  1. if useClassIcon == "1" then
  2.         local _, class = UnitClass(unitFrame.unit)        
  3.         if class then
  4.             local classIconAtlas = GetClassAtlas(class)
  5.             if classIconAtlas then
  6.                 unitFrame.Portrait.Icon:SetAtlas(classIconAtlas)
  7.             end
  8.         end
  9. end
  10. SetPortraitTexture(unitFrame.Portrait.Icon, "player",false)

So, I thought I would try a different route, as I can see from https://github.com/Gethe/wow-ui-text...ree/live/ICONS that the class icons individual files still exist.
Now my test character was a warlock and the file for her comes up as ICONS\ClassIcon_Warlock.png so I tried the following code. And it worked.

Lua Code:
  1. if useClassIcon == "1" then
  2.         local _, class = UnitClass(unitFrame.unit)        
  3.         if class then
  4.             unitFrame.Portrait.Icon:SetTexture("Interface\\ICONS\\ClassIcon_" .. class)
  5.         end
  6.     else
  7.         SetPortraitTexture(unitFrame.Portrait.Icon, "player",false)
  8.     end

So, the question is, does anyone know if there is some special setup for a texture to have to make atlas functions work ? Blizzard seems to be using them more nowadays so thought I better get to figuring them out rofl.

Thanks in advance.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
03-10-24, 07:41 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Maybe I'm missing something but this always ends up at SetPortraitTexture
Lua Code:
  1. if useClassIcon == "1" then
  2.         local _, class = UnitClass(unitFrame.unit)        
  3.         if class then
  4.             local classIconAtlas = GetClassAtlas(class)
  5.             if classIconAtlas then
  6.                 unitFrame.Portrait.Icon:SetAtlas(classIconAtlas)
  7.             end
  8.         end
  9. end
  10. SetPortraitTexture(unitFrame.Portrait.Icon, "player",false)

Possibly something like:
Lua Code:
  1. if useClassIcon == "1" then
  2.         local _, class = UnitClass(unitFrame.unit)
  3.         if class then
  4.             local classIconAtlas = GetClassAtlas(class)
  5.             if classIconAtlas then
  6.                 unitFrame.Portrait.Icon:SetAtlas(classIconAtlas)
  7.             else
  8.                 unitFrame.Portrait.Icon:SetTexture("Interface\\ICONS\\ClassIcon_" .. class) -- no atlas fallback if needed? (probably not)
  9.             end
  10.         else
  11.             SetPortraitTexture(unitFrame.Portrait.Icon, unitFrame.unit, false) -- no class fallback if needed?
  12.         end
  13. else
  14.     SetPortraitTexture(unitFrame.Portrait.Icon, unitFrame.unit, false)
  15. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-10-24 at 07:48 PM.
  Reply With Quote
03-10-24, 09:21 PM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
oh my .. I totally forgot the return statement. I thought it was supposed to lead back to that line with the atlas doing its stuff behind the scenes ..
Thanks, made me check their code again as I thought I had done the exact same thing they did rofl.

Lua Code:
  1. if ( UnitFrame_ShouldReplacePortrait(self) ) then
  2.             local _, class = UnitClass(self.unit);
  3.             if ( class ) then
  4.                 local classIconAtlas = GetClassAtlas(class);
  5.                 if ( classIconAtlas ) then
  6.                     self.portrait:SetAtlas(classIconAtlas);
  7.                     return;          <<<< I missed this line
  8.                 end
  9.             end
  10.         end
  11.  
  12.         SetPortraitTexture(self.portrait, self.unit, self.disablePortraitMask);


Ended up doing this in my code. It shouldn't get to the useClassIcon else statements but if they do they're covered with the old fashioned class icon files ( until they disappear ) unless the class part fails for some strange reason. With the "player" part replaced with unitFrame.unit for completeness ( not that I have the other units working yet rofl.)
Lua Code:
  1. if useClassIcon == "1" then
  2.         local _, class = UnitClass(unitFrame.unit)        
  3.  
  4.         if class then
  5.             local classIconAtlas = GetClassAtlas(class)
  6.             if classIconAtlas then
  7.                 unitFrame.Portrait.Icon:SetAtlas(classIconAtlas)
  8.             else
  9.                 unitFrame.Portrait.Icon:SetTexture("Interface\\ICONS\\ClassIcon_" .. class)
  10.             end  
  11.         else
  12.             SetPortraitTexture(unitFrame.Portrait.Icon, "player",false)
  13.         end
  14.     else
  15.         SetPortraitTexture(unitFrame.Portrait.Icon, "player",false)
  16.     end
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 03-10-24 at 09:35 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Setting Class Icon via SetAtlas and GetClassAtlas doesn't seem to work for me


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