View Single Post
11-30-20, 08:28 AM   #6
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Lybrial View Post
What is so special about the MainMenuMicroButton that it wont override the textures?
It is best to look at Blizzard's code to see what is going on. In this case you have this running OnUpdate:
Lua Code:
  1. function MainMenuMicroButtonMixin:OnUpdate(elapsed)
  2.     if ( self.updateInterval > 0 ) then
  3.         self.updateInterval = self.updateInterval - elapsed;
  4.     else
  5.         self.updateInterval = PERFORMANCEBAR_UPDATE_INTERVAL;
  6.         local status = GetFileStreamingStatus();
  7.         if ( status == 0 ) then
  8.             status = (GetBackgroundLoadingStatus()~=0) and 1 or 0;
  9.         end
  10.         if ( status == 0 ) then
  11.             MainMenuBarDownload:Hide();
  12.             self:SetNormalAtlas("hud-microbutton-MainMenu-Up", true);
  13.             self:SetPushedAtlas("hud-microbutton-MainMenu-Down", true);
  14.             self:SetDisabledAtlas("hud-microbutton-MainMenu-Disabled", true);
  15.         else
  16.             self:SetNormalTexture("Interface\\Buttons\\UI-MicroButtonStreamDL-Up");
  17.             self:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonStreamDL-Down");
  18.             self:SetDisabledTexture("Interface\\Buttons\\UI-MicroButtonStreamDL-Up");
  19.             if ( status == 1 ) then
  20.                 MainMenuBarDownload:SetTexture("Interface\\BUTTONS\\UI-MicroStream-Green");
  21.             elseif ( status == 2 ) then
  22.                 MainMenuBarDownload:SetTexture("Interface\\BUTTONS\\UI-MicroStream-Yellow");
  23.             elseif ( status == 3 ) then
  24.                 MainMenuBarDownload:SetTexture("Interface\\BUTTONS\\UI-MicroStream-Red");
  25.             end
  26.             MainMenuBarDownload:Show();
  27.         end
  28.         local bandwidthIn, bandwidthOut, latencyHome, latencyWorld = GetNetStats();
  29.         local latency = latencyHome > latencyWorld and latencyHome or latencyWorld;
  30.         if ( latency > PERFORMANCEBAR_MEDIUM_LATENCY ) then
  31.             MainMenuBarPerformanceBar:SetVertexColor(1, 0, 0);
  32.         elseif ( latency > PERFORMANCEBAR_LOW_LATENCY ) then
  33.             MainMenuBarPerformanceBar:SetVertexColor(1, 1, 0);
  34.         else
  35.             MainMenuBarPerformanceBar:SetVertexColor(0, 1, 0);
  36.         end
  37.         if ( self.hover and not KeybindFrames_InQuickKeybindMode() ) then
  38.             self.tooltipText = MicroButtonTooltipText(MAINMENU_BUTTON, "TOGGLEGAMEMENU");
  39.             MainMenuBarPerformanceBarFrame_OnEnter(self);
  40.         end
  41.     end
  42. end
The easy fix is to replace the OnUpdate script with something similar that does not undo your changes:
Lua Code:
  1. MainMenuMicroButton:SetScript('OnUpdate', function(self, elapsed)
  2.     if ( self.updateInterval > 0 ) then
  3.         self.updateInterval = self.updateInterval - elapsed;
  4.     else
  5.         self.updateInterval = PERFORMANCEBAR_UPDATE_INTERVAL;
  6.         local status = GetFileStreamingStatus();
  7.         if ( status == 0 ) then
  8.             status = (GetBackgroundLoadingStatus()~=0) and 1 or 0;
  9.         end
  10.         if ( status == 0 ) then
  11.             MainMenuBarDownload:Hide();
  12. --          self:SetNormalAtlas("hud-microbutton-MainMenu-Up", true);
  13. --          self:SetPushedAtlas("hud-microbutton-MainMenu-Down", true);
  14. --          self:SetDisabledAtlas("hud-microbutton-MainMenu-Disabled", true);
  15.         else
  16. --          self:SetNormalTexture("Interface\\Buttons\\UI-MicroButtonStreamDL-Up");
  17. --          self:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonStreamDL-Down");
  18. --          self:SetDisabledTexture("Interface\\Buttons\\UI-MicroButtonStreamDL-Up");
  19.             if ( status == 1 ) then
  20.                 MainMenuBarDownload:SetTexture("Interface\\BUTTONS\\UI-MicroStream-Green");
  21.             elseif ( status == 2 ) then
  22.                 MainMenuBarDownload:SetTexture("Interface\\BUTTONS\\UI-MicroStream-Yellow");
  23.             elseif ( status == 3 ) then
  24.                 MainMenuBarDownload:SetTexture("Interface\\BUTTONS\\UI-MicroStream-Red");
  25.             end
  26.             MainMenuBarDownload:Show();
  27.         end
  28.         local bandwidthIn, bandwidthOut, latencyHome, latencyWorld = GetNetStats();
  29.         local latency = latencyHome > latencyWorld and latencyHome or latencyWorld;
  30.         if ( latency > PERFORMANCEBAR_MEDIUM_LATENCY ) then
  31.             MainMenuBarPerformanceBar:SetVertexColor(1, 0, 0);
  32.         elseif ( latency > PERFORMANCEBAR_LOW_LATENCY ) then
  33.             MainMenuBarPerformanceBar:SetVertexColor(1, 1, 0);
  34.         else
  35.             MainMenuBarPerformanceBar:SetVertexColor(0, 1, 0);
  36.         end
  37.         if ( self.hover and not KeybindFrames_InQuickKeybindMode() ) then
  38.             self.tooltipText = MicroButtonTooltipText(MAINMENU_BUTTON, "TOGGLEGAMEMENU");
  39.             MainMenuBarPerformanceBarFrame_OnEnter(self);
  40.         end
  41.     end
  42. end)
  Reply With Quote