Whew .. finally .. I suspect I messed up a validation step somewhere as I can't see anything specific being different from before rofl.
This is generated when a map button is clicked
Lua Code:
--[[ Generate list of spells available for the requested map ]]
function addonData:GenerateMapSpellList(mapID, mapButton)
local portalOffsetIdx = 1
local teleportOffsetIdx = 1
local factionGroup, factionName = UnitFactionGroup("player")
mapButton.Spells = {}
for spellID,spellData in pairs(addonData.Spells) do
local rightMap = spellData.map == addonData.activePage
local rightFaction = spellData.faction == factionName
local neutralFaction = spellData.faction == "Neutral"
local isPortal = spellData.isPortal
if rightMap and (rightFaction or neutralFaction) then
local index = teleportOffsetIdx
if isPortal then
index = portalOffsetIdx
end
mapButton.Spells = mapButton.Spells or {}
mapButton.Spells[spellID] = index
if isPortal then
portalOffsetIdx = portalOffsetIdx + 1
else
teleportOffsetIdx = teleportOffsetIdx + 1
end
end
end
end
This is called when the selected button frame is being displayed ( it is actually one frame with the button attribute values changing and the unused buttons being hidden as required)
Lua Code:
--[[ Set the Buttons up with what is available for the maps ]]
local function XMP_SetMapSpells()
local teleportIdx = 0
local portalIdx = 5
local usedButtons = {}
for spellID, buttonOffset in pairs(addonData.activeButton.Spells) do
local isPortal = addonData.Spells[spellID].isPortal
local index = teleportIdx + buttonOffset
if isPortal then index = portalIdx + buttonOffset end
local spellName,textureID = addonData:GetSpellInfo(spellID)
local button = XMP_Main.ButtonFrame.Buttons[index]
button:SetAttribute("type","spell")
button:SetAttribute("spell",spellID)
button.Icon:SetTexture(textureID)
button.NormalTexture:SetTexture("")
table.insert(usedButtons,index)
currentIdx = currentIdx + 1
end
for i = 1,#XMP_Main.ButtonFrame.Buttons do
if ( tContains(usedButtons,i) ) then
XMP_Main.ButtonFrame.Buttons[i]:Show()
else
XMP_Main.ButtonFrame.Buttons[i]:Hide()
end
end
end
And this is what I did to get the spell data loaded in memory
Lua Code:
--[[ Get the required information for the spellID ]]
function addonData:GetSpellInfo(spellID)
local spell = Spell:CreateFromSpellID(spellID)
local spellName = nil
local textureID = nil
spell:ContinueOnSpellLoad(function()
spellName = GetSpellInfo(spellID)
local id,fileID = GetSpellTexture(spellID)
textureID = fileID
end)
return spellName,textureID
end
Definitely looking better than my current version of the addon. A few more additions and it should be ready
Hopefully some of this will help other's trying to do something similar and hitting problems