View Single Post
04-30-18, 04:48 PM   #28
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Thanks. The missing link was GetAtlasInfo() which is not described anywhere.

It is working now.

Lua Code:
  1. local function OnVignetteAdded(self,event,id)
  2.   if not id then return end
  3.   self.vignettes = self.vignettes or {}
  4.   if self.vignettes[id] then return end
  5.   local vignetteInfo = C_VignetteInfo.GetVignetteInfo(id)
  6.   if not vignetteInfo then return end
  7.   local _, width, height, txLeft, txRight, txTop, txBottom = GetAtlasInfo(vignetteInfo.atlasName)
  8.   PlaySoundFile("Sound\\Interface\\RaidWarning.ogg")
  9.   local str = "|TInterface\\MINIMAP\\ObjectIconsAtlas:0:0:0:0:256:256:"..(txLeft*256)..":"..(txRight*256)..":"..(txTop*256)..":"..(txBottom*256).."|t"
  10.   RaidNotice_AddMessage(RaidWarningFrame, str.." "..vignetteInfo.name.." spotted!", ChatTypeInfo["RAID_WARNING"])
  11.   print(str.." "..vignetteInfo.name,"spotted!")
  12.   self.vignettes[id] = true
  13. end
  14.  
  15. -----------------------------
  16. -- Init
  17. -----------------------------
  18.  
  19. --eventHandler
  20. local eventHandler = CreateFrame("Frame")
  21. eventHandler:RegisterEvent("VIGNETTE_MINIMAP_UPDATED")
  22. eventHandler:SetScript("OnEvent", OnVignetteAdded)

Btw here is sth I found in the Blizzard_TutorialLogic.lua. It is a atlas to string texture converter if I see that right. It might be able to upgrade my current solution.

Lua Code:
  1. function TutorialHelper:FormatAtlasString(str)
  2.     return (string.gsub(str, "{Atlas|([%w_]+):?(%d*)}", function(atlasName, size)
  3.                 size = tonumber(size) or 0;
  4.  
  5.                 local filename, width, height, txLeft, txRight, txTop, txBottom = GetAtlasInfo(atlasName);
  6.  
  7.                 if (not filename) then return; end
  8.  
  9.                 local atlasWidth = width / (txRight - txLeft);
  10.                 local atlasHeight = height / (txBottom - txTop);
  11.  
  12.                 local pxLeft    = atlasWidth    * txLeft;
  13.                 local pxRight   = atlasWidth    * txRight;
  14.                 local pxTop     = atlasHeight   * txTop;
  15.                 local pxBottom  = atlasHeight   * txBottom;
  16.  
  17.                 return string.format("|T%s:%d:%d:0:0:%d:%d:%d:%d:%d:%d|t", filename, size, size, atlasWidth, atlasHeight, pxLeft, pxRight, pxTop, pxBottom);
  18.             end));
  19. end

Nice that actually was helpful. Instead of the texture path hard coded you can use the texture file id instead. Got it working now.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 04-30-18 at 05:01 PM.
  Reply With Quote