View Single Post
01-17-22, 07:49 PM   #8
Nagí
A Murloc Raider
 
Nagí's Avatar
Join Date: Oct 2020
Posts: 6
Hey! I'm updating this post to expose my advancement on the subject.

The previous answers have helped and learned me a lot. So I would therefore like to thank them once again.

At first, I obstinately continued in the way that has been suggested. I tried to fix the issue encountered with SetMask() while in combat. But I didn't found anything pertinent in the Blizzard interface.

So I decided to try as I thought with a folder containing my textures in order to avoid SetMask().
And I achieved to something working perfectly as expected. It's like this:
Lua Code:
  1. hooksecurefunc("UnitFramePortrait_Update", function(self)
  2.     if self.portrait then
  3.       if UnitIsPlayer(self.unit) then
  4.         local race = ((select(2,UnitRace(self.unit))):lower());
  5.         local gender = (UnitSex(self.unit) == 3);
  6.         if gender then
  7.           self.portrait:SetTexture(string.format("Interface\\AddOns\\RaceIconPortrait\\Textures\\%s-%s.tga", race, "female"))
  8.         else
  9.           self.portrait:SetTexture(string.format("Interface\\AddOns\\RaceIconPortrait\\Textures\\%s-%s.tga", race, "male"))          
  10.         end
  11.       end
  12.       if UnitIsPlayer("target") then
  13.         TargetFramePortrait:SetTexCoord(1,0,0,1)
  14.       else
  15.         TargetFramePortrait:SetTexCoord(0,1,0,1)
  16.       end
  17.       if UnitIsPlayer("focus") then
  18.         FocusFramePortrait:SetTexCoord(1,0,0,1)
  19.       else
  20.         FocusFramePortrait:SetTexCoord(0,1,0,1)
  21.       end
  22.     end
  23. end)
I'm conscious that it could be better, especially with the UnitSex() and the second %s (I have particularly struggled with this, for finally end up to this). Also I have add the functionality to reverse the portrait for the target and focus frame. If you have any suggestion I'll be glad to read them.
  Reply With Quote