WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   SecondsToTimeAbbrev fps drops (https://www.wowinterface.com/forums/showthread.php?t=59657)

glupikreten 08-30-23 02:24 AM

SecondsToTimeAbbrev fps drops
 
Hi,

Can someone please explain me why this causes fps drops and/or how to prevent it? :)

Lua Code:
  1. local origSecondsToTimeAbbrev = _G.SecondsToTimeAbbrev
  2. local function SecondsToTimeAbbrevHook(seconds)
  3.     origSecondsToTimeAbbrev(seconds)
  4.  
  5.     local tempTime
  6.     if (seconds >= 86400) then
  7.         tempTime = ceil(seconds / 86400)
  8.         return "|cffffffff%dd|r", tempTime
  9.     end
  10.  
  11.     if (seconds >= 3600) then
  12.         tempTime = ceil(seconds / 3600)
  13.         return "|cffffffff%dh|r", tempTime
  14.     end
  15.  
  16.     if (seconds >= 60) then
  17.         tempTime = ceil(seconds / 60)
  18.         return "|cffffffff%dm|r", tempTime
  19.     end
  20.  
  21.     return "|cffffffff%d|r", seconds
  22. end
  23. SecondsToTimeAbbrev = SecondsToTimeAbbrevHook

Fizzlemizz 08-30-23 03:02 AM

Is there some specific reason you:
Lua Code:
  1. local origSecondsToTimeAbbrev = _G.SecondsToTimeAbbrev
and then in your replacement function:
Lua Code:
  1. origSecondsToTimeAbbrev(seconds)

Seems like double handling for no reason other than wasting CPU cycles and creating load for something that's going to be called "lots".

glupikreten 08-30-23 03:58 AM

It is not my code... its nBuff addon...

So i commented what you pointed out.. and still if i uncomment line 38 i get regular fps drops...

I mean.. if you or someone can see it in a glimpse i would be really happy with a solution...

I really do not expect more than that... its not that important. :)

Lua Code:
  1. local _, nBuff = ...
  2. local cfg = nBuff.Config
  3.  
  4. local _G = _G
  5. local unpack = unpack
  6.  
  7. --[[
  8. _G.DAY_ONELETTER_ABBR = '|cffffffff%dd|r'
  9. _G.HOUR_ONELETTER_ABBR = '|cffffffff%dh|r'
  10. _G.MINUTE_ONELETTER_ABBR = '|cffffffff%dm|r'
  11. _G.SECOND_ONELETTER_ABBR = '|cffffffff%d|r'
  12.  
  13. -- _G.DEBUFF_MAX_DISPLAY = 32 -- show more debuffs
  14. -- _G.BUFF_MIN_ALPHA = 1
  15. --]]
  16. -- local origSecondsToTimeAbbrev = _G.SecondsToTimeAbbrev
  17. local function SecondsToTimeAbbrevHook(seconds)
  18.     -- origSecondsToTimeAbbrev(seconds)
  19.  
  20.     local tempTime
  21.     if (seconds >= 86400) then
  22.         tempTime = ceil(seconds / 86400)
  23.         return "|cffffffff%dd|r", tempTime
  24.     end
  25.  
  26.     if (seconds >= 3600) then
  27.         tempTime = ceil(seconds / 3600)
  28.         return "|cffffffff%dh|r", tempTime
  29.     end
  30.  
  31.     if (seconds >= 60) then
  32.         tempTime = ceil(seconds / 60)
  33.         return "|cffffffff%dm|r", tempTime
  34.     end
  35.  
  36.     return "|cffffffff%d|r", seconds
  37. end
  38. -- SecondsToTimeAbbrev = SecondsToTimeAbbrevHook
  39.  
  40. -- BuffFrame:SetScript("OnUpdate", nil)
  41.  
  42. -- TemporaryEnchantFrame ...
  43. TempEnchant1:ClearAllPoints()
  44. TempEnchant1:SetPoint("TOPRIGHT", Minimap, "TOPLEFT", -15, 0)
  45. -- TempEnchant1.SetPoint = function() end
  46.  
  47. TempEnchant2:ClearAllPoints()
  48. TempEnchant2:SetPoint("TOPRIGHT", TempEnchant1, "TOPLEFT", -cfg.paddingX, 0)
  49.  
  50. local function UpdateFirstButton(self)
  51.     if (self and self:IsShown()) then
  52.         self:ClearAllPoints()
  53.  
  54.         if (BuffFrame.numEnchants == 1) then
  55.             self:SetPoint("TOPRIGHT", TempEnchant1, "TOPLEFT", -cfg.paddingX, 0)
  56.             return
  57.         elseif (BuffFrame.numEnchants == 2) then
  58.             self:SetPoint("TOPRIGHT", TempEnchant2, "TOPLEFT", -cfg.paddingX, 0)
  59.             return
  60.         elseif (BuffFrame.numEnchants == 3) then
  61.             self:SetPoint("TOPRIGHT", TempEnchant3, "TOPLEFT", -cfg.paddingX, 0)
  62.             return
  63.         else
  64.             self:SetPoint("TOPRIGHT", TempEnchant1)
  65.             return
  66.         end
  67.     end
  68. end
  69.  
  70. local function CheckFirstButton()
  71.     if (BuffButton1) then
  72.         UpdateFirstButton(BuffButton1)
  73.     end
  74. end
  75.  
  76. hooksecurefunc(
  77.     "BuffFrame_UpdateAllBuffAnchors",
  78.     function()
  79.         local previousBuff, aboveBuff
  80.         local numBuffs = 0
  81.         local numTotal = BuffFrame.numEnchants
  82.  
  83.         for i = 1, BUFF_ACTUAL_DISPLAY do
  84.             local buff = _G["BuffButton" .. i]
  85.  
  86.             numBuffs = numBuffs + 1
  87.             numTotal = numTotal + 1
  88.  
  89.             buff:ClearAllPoints()
  90.             if (numBuffs == 1) then
  91.                 UpdateFirstButton(buff)
  92.             elseif (numBuffs > 1 and mod(numTotal, cfg.buffPerRow) == 1) then
  93.                 if (numTotal == cfg.buffPerRow + 1) then
  94.                     buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, -cfg.paddingY)
  95.                 else
  96.                     buff:SetPoint("TOP", aboveBuff, "BOTTOM", 0, -cfg.paddingY)
  97.                 end
  98.  
  99.                 aboveBuff = buff
  100.             else
  101.                 buff:SetPoint("TOPRIGHT", previousBuff, "TOPLEFT", -cfg.paddingX, 0)
  102.             end
  103.  
  104.             previousBuff = buff
  105.         end
  106.     end
  107. )
  108.  
  109. hooksecurefunc(
  110.     "DebuffButton_UpdateAnchors",
  111.     function(self, index)
  112.         local numBuffs = BUFF_ACTUAL_DISPLAY + BuffFrame.numEnchants
  113.  
  114.         local debuffSpace = cfg.buffSize + cfg.paddingY
  115.         local numRows = ceil(numBuffs / cfg.buffPerRow)
  116.  
  117.         local rowSpacing
  118.         if (numRows and numRows > 1) then
  119.             rowSpacing = -numRows * debuffSpace
  120.         else
  121.             rowSpacing = -debuffSpace
  122.         end
  123.  
  124.         local buff = _G[self .. index]
  125.         buff:ClearAllPoints()
  126.         if (index == 1) then
  127.             buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, rowSpacing)
  128.         elseif (index >= 2 and mod(index, cfg.buffPerRow) == 1) then
  129.             buff:SetPoint("TOP", _G[self .. (index - cfg.buffPerRow)], "BOTTOM", 0, -cfg.paddingY)
  130.         else
  131.             buff:SetPoint("TOPRIGHT", _G[self .. (index - 1)], "TOPLEFT", -cfg.paddingX, 0)
  132.         end
  133.     end
  134. )
  135.  
  136. for i = 1, NUM_TEMP_ENCHANT_FRAMES do
  137.     local button = _G["TempEnchant" .. i]
  138.     button:SetScale(cfg.buffScale)
  139.     button:SetSize(cfg.buffSize, cfg.buffSize)
  140.  
  141.     button:SetScript(
  142.         "OnShow",
  143.         function()
  144.             CheckFirstButton()
  145.         end
  146.     )
  147.  
  148.     button:SetScript(
  149.         "OnHide",
  150.         function()
  151.             CheckFirstButton()
  152.         end
  153.     )
  154.  
  155.     local icon = _G["TempEnchant" .. i .. "Icon"]
  156.     icon:SetTexCoord(0.04, 0.96, 0.04, 0.96)
  157.  
  158.     local duration = _G["TempEnchant" .. i .. "Duration"]
  159.     duration:ClearAllPoints()
  160.     duration:SetPoint("BOTTOM", button, "BOTTOM", 0, -2)
  161.     duration:SetFont(cfg.durationFont, cfg.buffFontSize, "THINOUTLINE")
  162.     duration:SetShadowOffset(0, 0)
  163.     duration:SetDrawLayer("OVERLAY")
  164.  
  165.     local border = _G["TempEnchant" .. i .. "Border"]
  166.     border:ClearAllPoints()
  167.     border:SetPoint("TOPRIGHT", button, 1, 1)
  168.     border:SetPoint("BOTTOMLEFT", button, -1, -1)
  169.     border:SetTexture(cfg.borderDebuff)
  170.     border:SetTexCoord(0, 1, 0, 1)
  171.     border:SetVertexColor(0.9, 0.25, 0.9)
  172.  
  173.     button.Shadow = button:CreateTexture("$parentBackground", "BACKGROUND")
  174.     button.Shadow:SetPoint("TOPRIGHT", border, 3.35, 3.35)
  175.     button.Shadow:SetPoint("BOTTOMLEFT", border, -3.35, -3.35)
  176.     button.Shadow:SetTexture("Interface\\AddOns\\nBuff\\media\\textureShadow")
  177.     button.Shadow:SetVertexColor(0, 0, 0, 1)
  178. end
  179.  
  180. hooksecurefunc(
  181.     "AuraButton_Update",
  182.     function(self, index)
  183.         local button = _G[self .. index]
  184.  
  185.         if (button and not button.Shadow) then
  186.             if (button) then
  187.                 if (self:match("Debuff")) then
  188.                     button:SetSize(cfg.debuffSize, cfg.debuffSize)
  189.                     button:SetScale(cfg.debuffScale)
  190.                 else
  191.                     button:SetSize(cfg.buffSize, cfg.buffSize)
  192.                     button:SetScale(cfg.buffScale)
  193.                 end
  194.             end
  195.  
  196.             local icon = _G[self .. index .. "Icon"]
  197.             if (icon) then
  198.                 icon:SetTexCoord(0.04, 0.96, 0.04, 0.96)
  199.             end
  200.  
  201.             local duration = _G[self .. index .. "Duration"]
  202.             if (duration) then
  203.                 duration:ClearAllPoints()
  204.                 duration:SetPoint("BOTTOM", button, "BOTTOM", 0, -2)
  205.                 if (self:match("Debuff")) then
  206.                     duration:SetFont(cfg.durationFont, cfg.debuffFontSize, "THINOUTLINE")
  207.                 else
  208.                     duration:SetFont(cfg.durationFont, cfg.buffFontSize, "THINOUTLINE")
  209.                 end
  210.                 duration:SetShadowOffset(0, 0)
  211.                 duration:SetDrawLayer("OVERLAY")
  212.             end
  213.  
  214.             local count = _G[self .. index .. "Count"]
  215.             if (count) then
  216.                 count:ClearAllPoints()
  217.                 count:SetPoint("TOPRIGHT", button)
  218.                 if (self:match("Debuff")) then
  219.                     count:SetFont(cfg.countFont, cfg.debuffCountSize, "THINOUTLINE")
  220.                 else
  221.                     count:SetFont(cfg.countFont, cfg.buffCountSize, "THINOUTLINE")
  222.                 end
  223.                 count:SetShadowOffset(0, 0)
  224.                 count:SetDrawLayer("OVERLAY")
  225.             end
  226.  
  227.             local border = _G[self .. index .. "Border"]
  228.             if (border) then
  229.                 border:SetTexture(cfg.borderDebuff)
  230.                 border:SetPoint("TOPRIGHT", button, 1, 1)
  231.                 border:SetPoint("BOTTOMLEFT", button, -1, -1)
  232.                 border:SetTexCoord(0, 1, 0, 1)
  233.             end
  234.  
  235.             if (button and not border) then
  236.                 if (not button.texture) then
  237.                     button.texture = button:CreateTexture("$parentOverlay", "ARTWORK")
  238.                     button.texture:SetParent(button)
  239.                     button.texture:SetTexture(cfg.borderBuff)
  240.                     button.texture:SetPoint("TOPRIGHT", button, 1, 1)
  241.                     button.texture:SetPoint("BOTTOMLEFT", button, -1, -1)
  242.                     button.texture:SetVertexColor(unpack(cfg.buffBorderColor))
  243.                 end
  244.             end
  245.  
  246.             if (button) then
  247.                 if (not button.Shadow) then
  248.                     button.Shadow = button:CreateTexture("$parentShadow", "BACKGROUND")
  249.                     button.Shadow:SetTexture("Interface\\AddOns\\nBuff\\media\\textureShadow")
  250.                     button.Shadow:SetPoint("TOPRIGHT", button.texture or border, 3.35, 3.35)
  251.                     button.Shadow:SetPoint("BOTTOMLEFT", button.texture or border, -3.35, -3.35)
  252.                     button.Shadow:SetVertexColor(0, 0, 0, 1)
  253.                 end
  254.             end
  255.         end
  256.     end
  257. )


All times are GMT -6. The time now is 02:26 AM.

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