Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-06-13, 07:39 AM   #1
laukond
A Black Drake
Join Date: Dec 2011
Posts: 87
2 Script Questions

Hello, I would appreciate if you could help me with 2 questions.
http://i.imgur.com/7Ehq2.jpg


1.
As you can see on the screenshot the rested expbar has a bigger height than the not-rested expbar.

I use this code to decrease the height of MainMenuExpBar and I would like it to reduce the width of the rested bar too, but I cannot locate its name:

Lua Code:
  1. MainMenuExpBar:SetHeight(5)

I have looked here, but there doesn't seem to be anything about the height:
http://wowprogramming.com/utils/xmlb...ainMenuBar.lua


2.


I searched google for NUM_ADDONS_TO_DISPLAY and stumpled upon the code below.
It attaches AddOn memory usage to the Tracking Button.
Is there a way to make it not generate as much memory usage?

Currently when I am hovering the Tracking Button it keeps updating the usage.
My thought would be to make it only update once, which would reduce the amount of info it passes therefore less usage by itself?

Lua Code:
  1. local Stats = CreateFrame('Button')
  2. Stats:SetScript('OnEvent', function(self) self:Load() end)
  3. Stats:RegisterEvent('PLAYER_LOGIN')
  4.  
  5.  
  6. --[[ Startup ]]--
  7.  
  8. function Stats:Load()
  9.     local f = _G['MiniMapTrackingButton']
  10.     f:SetScript('OnEnter', self.OnEnter)
  11.     f:SetScript('OnLeave', self.OnLeave)
  12.     setmetatable(f, {__index = self})
  13. end
  14.  
  15.  
  16. --[[ Stats Frame Widget ]]--
  17.  
  18. local NUM_ADDONS_TO_DISPLAY = GetNumAddOns()
  19. local UPDATE_DELAY = 1
  20. local topAddOns
  21.  
  22. function Stats:OnEnter()
  23.     GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMLEFT', 0, self:GetHeight())
  24.     self:UpdateTooltip()
  25. end
  26.  
  27. function Stats:OnLeave()
  28.     GameTooltip:Hide()
  29. end
  30.  
  31. function Stats:UpdateTooltip()
  32.     --clear topAddOns list
  33.     if topAddOns then
  34.         for i,addon in pairs(topAddOns) do
  35.             addon.value = 0
  36.         end
  37.     else
  38.         topAddOns = {}
  39.         for i=1, NUM_ADDONS_TO_DISPLAY do
  40.             topAddOns[i] = {name = '', value = 0}
  41.         end
  42.     end
  43.  
  44.     --add FPS and latency
  45.     local down, up, latency = GetNetStats()
  46.     local fps = format('FPS: %.1f', GetFramerate())
  47.     local net = format('Ping: %d ms', latency)
  48.  
  49.     GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMLEFT', 0, self:GetHeight())
  50.     GameTooltip:ClearLines()
  51.     GameTooltip:AddDoubleLine(fps, net, 1, 1, 1, 1, 1, 1)
  52.     GameTooltip:AddLine('--------------------------------------------------')
  53.  
  54.     self:UpdateAddonsList(GetCVar('scriptProfile') == '1' and not IsModifierKeyDown())
  55. end
  56.  
  57. function Stats:UpdateAddonsList(watchingCPU)
  58.     if watchingCPU then
  59.         UpdateAddOnCPUUsage()
  60.     else
  61.         UpdateAddOnMemoryUsage()
  62.     end
  63.  
  64.     local total = 0
  65.     for i=1, GetNumAddOns() do
  66.         local value = (watchingCPU and GetAddOnCPUUsage(i)/1000) or GetAddOnMemoryUsage(i)
  67.         local name = (GetAddOnInfo(i))
  68.         total = total + value
  69.  
  70.         for j,addon in ipairs(topAddOns) do
  71.             if value > addon.value then
  72.                 for k = NUM_ADDONS_TO_DISPLAY, 1, -1 do
  73.                     if k == j then
  74.                         topAddOns[k].value = value
  75.                         topAddOns[k].name = GetAddOnInfo(i)
  76.                         break
  77.                     elseif k ~= 1 then
  78.                         topAddOns[k].value = topAddOns[k-1].value
  79.                         topAddOns[k].name = topAddOns[k-1].name
  80.                     end
  81.                 end
  82.                 break
  83.             end
  84.         end
  85.     end
  86.  
  87.     if total > 0 then
  88.         if watchingCPU then
  89.             GameTooltip:AddLine('Addon CPU Usage')
  90.         else
  91.             GameTooltip:AddLine('Addon Memory Usage')
  92.         end
  93.         GameTooltip:AddLine('--------------------------------------------------')
  94.  
  95.         for _,addon in ipairs(topAddOns) do
  96.             if watchingCPU then
  97.                 self:AddCPULine(addon.name, addon.value)
  98.             else
  99.                 self:AddMemoryLine(addon.name, addon.value)
  100.             end
  101.         end
  102.  
  103.         GameTooltip:AddLine('--------------------------------------------------')
  104.         if watchingCPU then
  105.             self:AddCPULine('Total', total)
  106.         else
  107.             self:AddMemoryLine('Total', total)
  108.         end
  109.     end
  110.     GameTooltip:Show()
  111. end
  112.  
  113. function Stats:AddCPULine(name, secs)
  114.     if secs > 3600 then
  115.         GameTooltip:AddDoubleLine(name, format('%.2f h', secs/3600), 1, 1, 1, 1, 0.2, 0.2)
  116.     elseif secs > 60 then
  117.         GameTooltip:AddDoubleLine(name, format('%.2f m', secs/60), 1, 1, 1, 1, 1, 0.2)
  118.     elseif secs >= 1 then
  119.         GameTooltip:AddDoubleLine(name, format('%.1f s', secs), 1, 1, 1, 0.2, 1, 0.2)
  120.     elseif secs > 0 then
  121.         GameTooltip:AddDoubleLine(name, format('%.1f ms', secs * 1000), 1, 1, 1, 0.2, 1, 0.2)
  122.     end
  123. end
  124.  
  125. function Stats:AddMemoryLine(name, size)
  126.     if size > 1000 then
  127.         GameTooltip:AddDoubleLine(name, format('%.2f mb', size/1000), 1, 1, 1, 1, 1, 0.2)
  128.     elseif size > 0 then
  129.         GameTooltip:AddDoubleLine(name, format('%.2f kb', size), 1, 1, 1, 0.2, 1, 0.2)
  130.     end
  131. end

Taken from https://github.com/Tuller/tullaTweak...ster/stats.lua

Any help is appreciated. Have a good day.

Last edited by laukond : 01-06-13 at 08:00 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » 2 Script Questions

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