Thanks. The missing link was GetAtlasInfo() which is not described anywhere.
It is working now.
Lua Code:
local function OnVignetteAdded(self,event,id)
if not id then return end
self.vignettes = self.vignettes or {}
if self.vignettes[id] then return end
local vignetteInfo = C_VignetteInfo.GetVignetteInfo(id)
if not vignetteInfo then return end
local _, width, height, txLeft, txRight, txTop, txBottom = GetAtlasInfo(vignetteInfo.atlasName)
PlaySoundFile("Sound\\Interface\\RaidWarning.ogg")
local str = "|TInterface\\MINIMAP\\ObjectIconsAtlas:0:0:0:0:256:256:"..(txLeft*256)..":"..(txRight*256)..":"..(txTop*256)..":"..(txBottom*256).."|t"
RaidNotice_AddMessage(RaidWarningFrame, str.." "..vignetteInfo.name.." spotted!", ChatTypeInfo["RAID_WARNING"])
print(str.." "..vignetteInfo.name,"spotted!")
self.vignettes[id] = true
end
-----------------------------
-- Init
-----------------------------
--eventHandler
local eventHandler = CreateFrame("Frame")
eventHandler:RegisterEvent("VIGNETTE_MINIMAP_UPDATED")
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:
function TutorialHelper:FormatAtlasString(str)
return (string.gsub(str, "{Atlas|([%w_]+):?(%d*)}", function(atlasName, size)
size = tonumber(size) or 0;
local filename, width, height, txLeft, txRight, txTop, txBottom = GetAtlasInfo(atlasName);
if (not filename) then return; end
local atlasWidth = width / (txRight - txLeft);
local atlasHeight = height / (txBottom - txTop);
local pxLeft = atlasWidth * txLeft;
local pxRight = atlasWidth * txRight;
local pxTop = atlasHeight * txTop;
local pxBottom = atlasHeight * txBottom;
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);
end));
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.