Quantcast
Cooldown text is invisible for some objects while it does properly display swipe - WoWInterface
Thread Tools Display Modes
06-24-17, 03:18 AM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Cooldown text is invisible for some objects while it does properly display swipe

Hi all,

So, I have been creating my own aura tracker addon with a skeleton designed by MunkDev here.

Lua Code:
  1. ------------------------------
  2. -- Upvalue variable
  3. ------------------------------
  4.  
  5. local StringLower = string.lower;
  6. local CreateFrame = CreateFrame;
  7. local UIParent = UIParent;
  8. local unpack = unpack;
  9. local Mixin = Mixin;
  10. local ObjectPoolMixin = ObjectPoolMixin;
  11. local NumberFontNormal = NumberFontNormal;
  12. local GetSpecialization = GetSpecialization;
  13. local pairs = pairs;
  14. local UnitBuff = UnitBuff;
  15. local UnitDebuff = UnitDebuff;
  16.  
  17. ------------------------------
  18. -- Get addon
  19. ------------------------------
  20.  
  21. local CAA = LibStub("AceAddon-3.0"):GetAddon("CombatAssist");
  22.  
  23. ------------------------------
  24. -- Module initialization
  25. ------------------------------
  26.  
  27. local AM = CAA:NewModule("Aura");
  28.  
  29. ------------------------------
  30. -- Function definition
  31. ------------------------------
  32.  
  33. function string.ends(String, End)
  34.    return End == "" or string.sub(String, -string.len(End)) == End;
  35. end
  36.  
  37. function AM:OnInitialize()
  38.     HolderInitialize();
  39. end
  40.  
  41. function AM:OnEnable()
  42.     local holder = self.holder;
  43.     holder:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED");
  44.     holder:RegisterEvent("PLAYER_TARGET_CHANGED");
  45.     holder:RegisterUnitEvent("UNIT_AURA", "player", "target");
  46.     holder:SetScript("OnEvent", function(self, event, ...)
  47.         AM[event](AM, ...);
  48.     end)
  49.  
  50.     self:ACTIVE_TALENT_GROUP_CHANGED();
  51.     self:UNIT_AURA();
  52. end
  53.  
  54. function AM:UNIT_AURA()
  55.     local db = CAA.db.global.module.aura;
  56.  
  57.     local holder = self.holder;
  58.  
  59.     if db.buff.enable then
  60.         BuffUpdate();
  61.     end
  62. end
  63.  
  64. function AM:ACTIVE_TALENT_GROUP_CHANGED()
  65.     local holder = self.holder;
  66.  
  67.     local spec = GetSpecialization();
  68.     holder.auraIDList = CAA.db.char.aura.auraIDList[spec];
  69. end
  70.  
  71. function AM:PLAYER_TARGET_CHANGED()
  72.    
  73. end
  74.  
  75. function AM:OnDisable()
  76.     local holder = self.holder;
  77.     holder:UnregisterAllEvents();
  78. end
  79.  
  80. function HolderInitialize()
  81.     local db = CAA.db.global.module.aura;
  82.  
  83.     local holder = CreateFrame("Frame");
  84.  
  85.     if db.buff.enable then
  86.         local buff = CreateFrame("Frame", AM:GetName() .. "Buff", UIParent);
  87.         buff:SetPoint(unpack(db.buff.position));
  88.         buff.numObjects = 0;
  89.  
  90.         Mixin(buff, ObjectPoolMixin);
  91.         buff:OnLoad(ButtonCreate, ButtonReset);
  92.  
  93.         holder.buff = buff;
  94.     end
  95.  
  96.     AM.holder = holder;
  97. end
  98.  
  99. function BuffUpdate()
  100.     local db = CAA.db.global.module.aura.buff;
  101.  
  102.     local buff = AM.holder.buff;
  103.     local auraIDList = AM.holder.auraIDList;
  104.  
  105.     buff:ReleaseAll();
  106.  
  107.     local prevButton;
  108.     for buffID, info in pairs(auraIDList.buff) do
  109.         local icon, count, duration, expires, spellID;
  110.  
  111.         local index;
  112.         for j = 1, index or 40 do
  113.             local unit = info.unit or "player";
  114.             local filter = info.filter and "PLAYER|" .. info.filter or "PLAYER";
  115.  
  116.             _, _, icon, count, _, duration, expires, _, _, _, spellID = UnitBuff(unit, j, filter);
  117.  
  118.             if spellID and spellID == buffID then
  119.                 local button = buff:Acquire();
  120.  
  121.                 local cd = button.cd;
  122.                 if duration and duration > 0 then
  123.                     print(spellID);
  124.  
  125.                     cd:SetCooldown(expires - duration, duration);
  126.                    
  127.                     cd:Show();
  128.                 else
  129.                     cd:Hide();
  130.                 end
  131.  
  132.                 button.icon:SetTexture(icon);
  133.                 button.count:SetText((count and count > 1) and count or "");
  134.                 button:Show();
  135.  
  136.                 if prevButton then
  137.                     button:SetPoint("LEFT", prevButton, "RIGHT", db.gap, 0);
  138.                 else
  139.                     button:SetPoint("LEFT");
  140.                 end
  141.  
  142.                 prevButton = button;
  143.  
  144.                 break;
  145.             elseif not spellID then
  146.                 index = j;
  147.            
  148.                 break;
  149.             end
  150.         end
  151.     end
  152.  
  153.     buff:SetSize(buff.numActiveObjects > 0 and ((db.size + db.gap) * buff.numActiveObjects) - db.gap or 0, db.size);
  154. end
  155.  
  156. function ButtonCreate(self)
  157.     local size = CAA.db.global.module.aura.buff.size;
  158.  
  159.     self.numObjects = self.numObjects + 1;
  160.  
  161.     local id = self.numObjects;
  162.  
  163.     local button = CreateFrame("Frame", "$parentButton" .. id, self);
  164.     button:SetSize(size, size);
  165.     button:SetTemplate(1);
  166.     button:Hide();
  167.  
  168.     local cd = CreateFrame("Cooldown", "$parentCooldown", button, "CooldownFrameTemplate");
  169.     cd:SetAllPoints(button);
  170.  
  171.     local icon = button:CreateTexture(nil, "BORDER");
  172.     icon:SetAllPoints(button);
  173.     icon:CutOffEdges();
  174.  
  175.     local count = button:CreateFontString(nil, "OVERLAY");
  176.     count:SetFontObject(NumberFontNormal);
  177.     count:SetPoint("TOP", button, "BOTTOM", 0, -2);
  178.  
  179.     button.cd = cd;
  180.     button.icon = icon;
  181.     button.count = count;
  182.  
  183.     return button;
  184. end
  185.  
  186. function ButtonReset(self, button)
  187.     button:ClearAllPoints();
  188.     button:Hide();
  189. end

I've made some modifications so that it matches my need.

However, it suddenly started to not show cooldown text for some buttons as it is shown on the image below.



As you can see, the third button does not display its cooldown text even if its swipe is working correctly.

Unfortunately, I don't get why this is happening and even unsure of how I could reproduce this issue

Any helps, please?

Thank you!

Last edited by Layback_ : 06-24-17 at 03:25 AM.
  Reply With Quote
07-13-17, 10:12 PM   #2
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Bump!

I've been testing it over and over again, but could've not figured out.

Here's an another example.



As you can see, the duration (cd:GetRegion()) is hidden for 3rd button.
(It's not always a 3rd button, but is random)

And here is a code snippet of button creation.

Lua Code:
  1. function AurasCreateIcon(element, index)
  2.     local button = CreateFrame("Button", "$parentButton" .. index, element);
  3.     button:RegisterForClicks("RightButtonUp");
  4.     button:SetSize(ICON_SIZE, ICON_SIZE);
  5.     button:SetTemplate(1);
  6.  
  7.     local cd = CreateFrame("Cooldown", "$parentCooldown", button, "CooldownFrameTemplate");
  8.     cd:SetFrameLevel(button:GetFrameLevel());
  9.     cd:SetAllPoints(button);
  10.  
  11.     local cdTime = cd:GetRegions();
  12.     cdTime:SetDrawLayer("OVERLAY", 7);
  13.     cdTime:SetFont(Jung9, 12, "OUTLINE");
  14.     cdTime:ClearAllPoints(true);
  15.     cdTime:SetPoint("BOTTOMRIGHT", cd, "BOTTOMRIGHT");
  16.  
  17.     local icon = button:CreateTexture(nil, "BORDER");
  18.     icon:SetAllPoints(button);
  19.     icon:CutOffEdges();
  20.  
  21.     local count = button:CreateFontString();
  22.     count:SetDrawLayer("OVERLAY", 7);
  23.     count:SetFont(Jung9, 12, "OUTLINE");
  24.     count:SetPoint("TOPLEFT", cd, "TOPLEFT", 2, -2);
  25.  
  26.     button.cd = cd;
  27.     button.icon = icon;
  28.     button.count = count;
  29.  
  30.     return button;
  31. end

It's driving me crazy

Last edited by Layback_ : 07-13-17 at 10:34 PM.
  Reply With Quote
07-14-17, 07:32 AM   #3
JDoubleU00
A Scalebane Royal Guard
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 448
Is it always Swipe that does not get updated?
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
07-14-17, 07:40 AM   #4
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Originally Posted by JDoubleU00 View Post
Is it always Swipe that does not get updated?
Hi JDoubleU00,

Swipes update well, but it's an cooldown text (duration in this case) created via "CooldownFrameTemplate" that is not being displayed properly.

If you see my second example, you will see that the bottom right text is not shown for 3rd button.

It's not even shown on frame stacks, '/fstack'
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Cooldown text is invisible for some objects while it does properly display swipe

Thread Tools
Display Modes

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