Thread Tools Display Modes
11-29-20, 09:38 AM   #1
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
MainMenuMicroButton: Override Textures

Hi,

im using the following code to override the micro menu button textures:

Lua Code:
  1. local buttonIndex = {
  2.     [1] = "MainMenuMicroButton",
  3.     [2] = "CharacterMicroButton",
  4.     [3] = "SpellbookMicroButton",
  5.     [4] = "TalentMicroButton",
  6.     [5] = "AchievementMicroButton",
  7.     [6] = "QuestLogMicroButton",
  8.     [7] = "GuildMicroButton",
  9.     [8] = "LFDMicroButton",
  10.     [9] = "EJMicroButton",
  11.     [10] = "CollectionsMicroButton",
  12.     [11] = ((not C_StorePublic.IsEnabled()) and (GetCurrentRegionName() == "CN")) and "HelpMicroButton" or "StoreMicroButton",
  13.     [12] = (C_StorePublic.IsEnabled() and (GetCurrentRegionName() ~= "CN")) and "HelpMicroButton"
  14. }
  15.  
  16. function MicroBlizzard:UpdateButtons()
  17.     TABLES:ForEach(_G.MICRO_BUTTONS, function(i, _)
  18.         local button = _G[buttonIndex[i]]
  19.         local db = self.db.profile.buttons.entries[buttonIndex[i]].texture
  20.  
  21.         button:GetNormalTexture():SetTextureFromDb(db, CORE.VALUES.Button.States.Normal)
  22.         button:GetPushedTexture():SetTextureFromDb(db, CORE.VALUES.Button.States.Pushed)
  23.  
  24.         if (button:GetDisabledTexture()) then
  25.             button:GetDisabledTexture():SetTextureFromDb(db, CORE.VALUES.Button.States.Disabled)
  26.         end
  27.     end)
  28. end
  29.  
  30. local function SetTextureFromDb(frame, texture, type, relative)
  31.     if (frame and texture) then
  32.         if (type == CORE.VALUES.Button.States.Normal) then
  33.             frame:SetInside(relative, texture.normal.offset.x, texture.normal.offset.y);
  34.             frame:SetTexture(texture.normal.texture)
  35.             frame:SetVertexColor(COLORS:Unpack(texture.color.default))
  36.         elseif (type == CORE.VALUES.Button.States.Pushed) then
  37.             frame:SetInside(relative, texture.pushed.offset.x, texture.pushed.offset.y);
  38.             frame:SetTexture(texture.pushed.texture)
  39.             frame:SetVertexColor(COLORS:Unpack(texture.color.accent))
  40.         elseif (type == CORE.VALUES.Button.States.Highlight) then
  41.             frame:SetInside(relative, texture.highlight.offset.x, texture.highlight.offset.y);
  42.             frame:SetTexture(texture.highlight.texture)
  43.             frame:SetVertexColor(COLORS:Unpack(texture.color.accent))
  44.         elseif (type == CORE.VALUES.Button.States.Disabled) then
  45.             frame:SetInside(relative, texture.disabled.offset.x, texture.disabled.offset.y);
  46.             frame:SetTexture(texture.disabled.texture)
  47.             frame:SetVertexColor(COLORS:Unpack(texture.color.disabled))
  48.         end
  49.     end
  50. end

This works for all buttons except the MainMenuMicroButton, See screenshot:

https://ibb.co/pWKHn1N

What is so special about the MainMenuMicroButton that it wont override the textures?

Last edited by Lybrial : 11-29-20 at 09:53 AM.
  Reply With Quote
11-29-20, 07:55 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Have you tried simply doing a manual override of these textures? Uses no extra resources and is much more reliable.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-29-20, 08:55 PM   #3
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
Hi,

thx for the reply. I do not know what a "manual override" of textures is

Do you mean replacing the textures on the hard drive?
  Reply With Quote
11-29-20, 09:30 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Yes, "replacing" the textures. WoW's client has a process that looks for any texture files in the install folder before loading the ones in the data, allowing you to load your own textures. Don't worry, this is legitimate, you are not editing any data files. This only works for the UI, such as icons and other 2D elements. It used to work for sounds, which was changed back in Legion BfA patch 8.2, and you can't replace anything in the 3D world.

For example, I am including two files I personally use which turns the edges of speech bubbles transparent while making the background fully opaque. You place these files in the following file path:
World of Warcraft\Interface\Tooltips
If your game was running, /reload to see the change. You may have to fully exit the game, but the recent change for recognizing new and changed addons on a reload may allow the game to load these new files as well.

To figure out which files you want to customize and where to place them, you can follow this wiki article, as well as this one, on how to extract all UI art assets from the game as well as browsing this github repository to see each asset as a .png file. You can convert between .blp (the Blizzard proprietary image format) and .png using BLPNG Converter hosted right on this site. Just edit the file as a .png then convert your edit to .blp. The converter saves the file output in the same folder you had the first file.
Attached Files
File Type: blp ChatBubble.blp (43.8 KB, 131 views)
File Type: blp ChatBubbleVertical.blp (6.5 KB, 120 views)

Last edited by Kanegasi : 11-30-20 at 08:56 AM. Reason: wrong patch
  Reply With Quote
11-30-20, 12:00 AM   #5
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
Thank you very much!

For me this is way too unflexible. I want the user to be able to exchange textures from the configuratio menu.

I guess what im going to do is to try to rebuild the micro menu with my own implementation.
I guess this will be challenging since all those strange restrictions blizzard puts up on buttons
when you are in fight.
  Reply With Quote
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
11-30-20, 09:44 PM   #7
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
Works perfectly! That is the best option so far! Thanks!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » MainMenuMicroButton: Override Textures

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