WoWInterface SVN TradeTabs

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 2 to Rev 3
    Reverse comparison

Rev 2 → Rev 3

TradeTabs.lua
4,8 → 4,10
28596, -- Alchemy
29844, -- Blacksmithing
33359, -- Cooking
28029, -- Enchanting
30350, -- Engineering
27028, -- First Aid
45357, -- Inscription
28897, -- Jewel Crafting
32549, -- Leatherworking
2842, -- Poisons
13,63 → 15,43
26790, -- Tailoring
}
 
local craftSpells = {
5149, -- Beast Training
28029, -- Enchanting
}
 
local MACRO_TEXT_FORMAT = [[
/script HideUIPanel(%s)
/cast %s
]]
 
 
function TradeTabs:OnEvent(event,...)
self:UnregisterEvent(event)
if not IsLoggedIn() then
self:RegisterEvent(event)
elseif InCombatLockdown() then
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self.queue = self.queue or {}
self.queue[event] = true
else
if self.queue then
for v in pairs(self.queue) do
self.queue[v] = nil
if v ~= event then
self:Initialize(v)
end
end
end
if event == "TRADE_SKILL_SHOW" or event == "CRAFT_SHOW" then
self:Initialize(event)
end
else
self:Initialize()
end
end
 
 
function TradeTabs:Initialize(event)
if not self.tradeSpells then
self:InitSpells()
function TradeTabs:Initialize()
if self.initialized then return end -- Shouldn't need this, but I'm paranoid
 
for i=1,#tradeSpells do
tradeSpells[GetSpellInfo(tradeSpells[i])] = true
end
 
local parent
local spells = {}
 
for i=1,MAX_SPELLS do
local n = GetSpellName(i,"spell")
if tradeSpells[n] then
spells[n] = i
end
end
 
local parent = TradeSkillFrame
if SkilletFrame then
parent = SkilletFrame
self:UnregisterAllEvents()
elseif event == "TRADE_SKILL_SHOW" then
parent = TradeSkillFrame
elseif event == "CRAFT_SHOW" then
parent = CraftFrame
end
 
local prev = self:BuildTabs(self.tradeSpells,nil,parent,"CraftFrame")
self:BuildTabs(self.craftSpells,prev,parent,"TradeSkillFrame")
end
 
function TradeTabs:BuildTabs(list,prev,parent,hideFrame)
for spell,spellid in pairs(list) do
local tab = self:CreateTab(spell,spellid,parent,hideFrame)
local prev
for spell,spellid in pairs(spells) do
local tab = self:CreateTab(spell,spellid,parent)
local point,relPoint,x,y = "TOPLEFT","BOTTOMLEFT",0,-17
if not prev then
prev,relPoint,x,y = parent,"TOPRIGHT",-32,-64
78,32 → 60,9
tab:SetPoint(point,prev,relPoint,x,y)
prev = tab
end
return prev
self.initialized = true
end
 
local function fillList(list)
for i = 1,#list do
list[GetSpellInfo(list[i])] = true
end
end
 
function TradeTabs:InitSpells()
fillList(tradeSpells)
fillList(craftSpells)
 
self.tradeSpells = {}
self.craftSpells = {}
 
for i=1,MAX_SPELLS do
local n = GetSpellName(i,"spell")
if tradeSpells[n] then
self.tradeSpells[n] = i
elseif craftSpells[n] then
self.craftSpells[n] = i
end
end
end
 
local function onEnter(self)
GameTooltip:SetOwner(self,"ANCHOR_RIGHT") GameTooltip:SetText(self.tooltip)
self:GetParent():LockHighlight()
136,21 → 95,18
end
 
 
function TradeTabs:CreateTab(spell,spellID,parent,hideFrame)
function TradeTabs:CreateTab(spell,spellID,parent)
local button = CreateFrame("CheckButton",nil,parent,"SpellBookSkillLineTabTemplate,SecureActionButtonTemplate")
button.tooltip = spell
button.hideFrame = hideFrame
button:Show()
button:SetAttribute("type","macro")
button:SetAttribute("macrotext",MACRO_TEXT_FORMAT:format(hideFrame,spell))
button:SetAttribute("type","spell")
button:SetAttribute("spell",spell)
button.spellID = spellID
button:SetNormalTexture(GetSpellTexture(spellID, "spell"))
 
button:SetScript("OnEvent",updateSelection)
button:RegisterEvent("TRADE_SKILL_SHOW")
button:RegisterEvent("TRADE_SKILL_CLOSE")
button:RegisterEvent("CRAFT_SHOW")
button:RegisterEvent("CRAFT_CLOSE")
button:RegisterEvent("CURRENT_SPELL_CAST_CHANGED")
 
createClickStopper(button)
159,6 → 115,5
end
 
TradeTabs:RegisterEvent("TRADE_SKILL_SHOW")
TradeTabs:RegisterEvent("CRAFT_SHOW")
TradeTabs:RegisterEvent("UNIT_SPELLCAST_SUECCEEDED")
TradeTabs:SetScript("OnEvent",TradeTabs.OnEvent)
TradeTabs.toc
1,9 → 1,10
## Interface: 20400
## Interface: 30000
## Title: TradeTabs
## Notes: Adds spellbook-style tabs to the TradeSkillFrame and CraftFrame for easy swapping between production skills
## Author: tard
## Version 1.4
## Notes: Adds spellbook-style tabs to the TradeSkillFrame for easy swapping between production skills
## Author: Tem
## Version 1.5
## X-Category: Tradeskill
## LoadOnDemand: 1
## LoadWith: Blizzard_TradeSkillUI, Blizzard_CraftUI
TradeTabs.lua
\ No newline at end of file +## LoadWith: Blizzard_TradeSkillUI + +TradeTabs.lua