WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   Hook fires for every element except the first one (https://www.wowinterface.com/forums/showthread.php?t=53521)

Miiru 06-02-16 01:19 AM

Hook fires for every element except the first one
 
2 Attachment(s)
Hello. Currently i am working on redesigning the challengemode frame. I noticed something i cant quite get the grip on.

On the challengemodekeystoneframe, you can add a keystone which will trigger this function:

Lua Code:
  1. function ChallengesKeystoneFrameMixin:SetUp(affixInfo)
  2.     if (type(affixInfo) == "table") then
  3.         local info = affixInfo;
  4.  
  5.         SetPortraitToTexture(self.Portrait, CHALLENGE_MODE_EXTRA_AFFIX_INFO[info.key].texture);
  6.        
  7.         if (info.pct > 999) then
  8.             self.Percent:SetFontObject("SystemFont_Shadow_Med1_Outline");
  9.         else
  10.             self.Percent:SetFontObject("SystemFont_Shadow_Large_Outline");
  11.         end
  12.                
  13.         self.Percent:SetText(("+%d%%"):format(info.pct));
  14.         self.Percent:Show();
  15.  
  16.         self.info = info;
  17.     else
  18.         local affixID = affixInfo;
  19.  
  20.         local _, _, filedataid = C_ChallengeMode.GetAffixInfo(affixID);
  21.  
  22.         SetPortraitToTexture(self.Portrait, filedataid);
  23.  
  24.         self.Percent:Hide();
  25.  
  26.         self.affixID = affixID;
  27.     end
  28.  
  29.     self:Show();
  30. end

Now since i want to change the look of the icons, i tried to hook into that function like this:

Lua Code:
  1. hooksecurefunc(ChallengesKeystoneFrameAffixMixin,"SetUp",function(self,affixInfo)
  2.         print("shot fired")
  3.         self.Border:Hide()
  4.         self.Portrait:SetTexCoord(0.15, 0.85, 0.15, 0.85)
  5.         --m_fontify(self.Percent,"white",miirgui.medium)   
  6.     end)

THis worked out just fine, except for the very first element it should work for. It just seems to always ignore the first element, no matter how many elements there are :( I meanwhile found a workaround by hooking ChallengesKeystoneFrameMixin:OnKeystoneSlotted() by shouldnt hooking the setup function work too?

Blizzard ChallengesUI

Gethe 06-02-16 08:45 AM

That's because that first affix is defined in XML, thus your hook to the mixin function had not been applied yet. The other affixes are created as needed by the ChallengeKeystoneFrameMixin, which happens only when you slot in a keystone.


All times are GMT -6. The time now is 08:34 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI