Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | tardmrr-14927 | local TradeTabs = CreateFrame("Frame","TradeTabs") |
2 | tardmrr-14927 | ||
3 | 8 | tardmrr-14927 | local tradeSpells = { -- Spell order in this table determines the tab order |
4 | 2 | tardmrr-14927 | 28596, -- Alchemy |
5 | tardmrr-14927 | 29844, -- Blacksmithing |
|
6 | 3 | tardmrr-14927 | 28029, -- Enchanting |
7 | 2 | tardmrr-14927 | 30350, -- Engineering |
8 | 3 | tardmrr-14927 | 45357, -- Inscription |
9 | 2 | tardmrr-14927 | 28897, -- Jewel Crafting |
10 | tardmrr-14927 | 32549, -- Leatherworking |
|
11 | 7 | tardmrr-14927 | 53428, -- Runeforging |
12 | 2 | tardmrr-14927 | 2656, -- Smelting |
13 | tardmrr-14927 | 26790, -- Tailoring |
|
14 | 8 | tardmrr-14927 | |
15 | tardmrr-14927 | 33359, -- Cooking |
|
16 | tardmrr-14927 | 27028, -- First Aid |
|
17 | tardmrr-14927 | ||
18 | tardmrr-14927 | 13262, -- Disenchant |
|
19 | tardmrr-14927 | 51005, -- Milling |
|
20 | tardmrr-14927 | 31252, -- Prospecting |
|
21 | tardmrr-14927 | 818, -- Basic Campfire |
|
22 | 2 | tardmrr-14927 | } |
23 | tardmrr-14927 | ||
24 | tardmrr-14927 | function TradeTabs:OnEvent(event,...) |
|
25 | tardmrr-14927 | self:UnregisterEvent(event) |
|
26 | tardmrr-14927 | if not IsLoggedIn() then |
|
27 | tardmrr-14927 | self:RegisterEvent(event) |
|
28 | tardmrr-14927 | elseif InCombatLockdown() then |
|
29 | tardmrr-14927 | self:RegisterEvent("PLAYER_REGEN_ENABLED") |
|
30 | 3 | tardmrr-14927 | else |
31 | tardmrr-14927 | self:Initialize() |
|
32 | 2 | tardmrr-14927 | end |
33 | tardmrr-14927 | end |
|
34 | tardmrr-14927 | ||
35 | tardmrr-14927 | ||
36 | 3 | tardmrr-14927 | function TradeTabs:Initialize() |
37 | 8 | tardmrr-14927 | if self.initialized or not IsAddOnLoaded("Blizzard_TradeSkillUI") then return end -- Shouldn't need this, but I'm paranoid |
38 | 3 | tardmrr-14927 | |
39 | tardmrr-14927 | for i=1,#tradeSpells do |
|
40 | 8 | tardmrr-14927 | local n = GetSpellInfo(tradeSpells[i]) |
41 | tardmrr-14927 | tradeSpells[n] = -1 |
|
42 | tardmrr-14927 | tradeSpells[i] = n |
|
43 | 2 | tardmrr-14927 | end |
44 | 8 | tardmrr-14927 | |
45 | tardmrr-14927 | local parent = TradeSkillFrame |
|
46 | tardmrr-14927 | if SkilletFrame then |
|
47 | tardmrr-14927 | parent = SkilletFrame |
|
48 | tardmrr-14927 | self:UnregisterAllEvents() |
|
49 | tardmrr-14927 | end |
|
50 | 2 | tardmrr-14927 | |
51 | 3 | tardmrr-14927 | for i=1,MAX_SPELLS do |
52 | tardmrr-14927 | local n = GetSpellName(i,"spell") |
|
53 | tardmrr-14927 | if tradeSpells[n] then |
|
54 | 8 | tardmrr-14927 | tradeSpells[n] = i |
55 | 3 | tardmrr-14927 | end |
56 | tardmrr-14927 | end |
|
57 | tardmrr-14927 | ||
58 | tardmrr-14927 | local prev |
|
59 | 8 | tardmrr-14927 | for i,spell in ipairs(tradeSpells) do |
60 | tardmrr-14927 | local spellid = tradeSpells[spell] |
|
61 | tardmrr-14927 | if type(spellid) == "number" and spellid > 0 then |
|
62 | tardmrr-14927 | local tab = self:CreateTab(spell,spellid,parent) |
|
63 | tardmrr-14927 | local point,relPoint,x,y = "TOPLEFT","BOTTOMLEFT",0,-17 |
|
64 | tardmrr-14927 | if not prev then |
|
65 | tardmrr-14927 | prev,relPoint,x,y = parent,"TOPRIGHT",-33,-44 |
|
66 | tardmrr-14927 | if parent == SkilletFrame then x = 0 end -- Special case. ew |
|
67 | tardmrr-14927 | end |
|
68 | tardmrr-14927 | tab:SetPoint(point,prev,relPoint,x,y) |
|
69 | tardmrr-14927 | prev = tab |
|
70 | 2 | tardmrr-14927 | end |
71 | tardmrr-14927 | end |
|
72 | 8 | tardmrr-14927 | |
73 | 3 | tardmrr-14927 | self.initialized = true |
74 | 2 | tardmrr-14927 | end |
75 | tardmrr-14927 | ||
76 | tardmrr-14927 | local function onEnter(self) |
|
77 | tardmrr-14927 | GameTooltip:SetOwner(self,"ANCHOR_RIGHT") GameTooltip:SetText(self.tooltip) |
|
78 | tardmrr-14927 | self:GetParent():LockHighlight() |
|
79 | tardmrr-14927 | end |
|
80 | tardmrr-14927 | ||
81 | tardmrr-14927 | local function onLeave(self) |
|
82 | tardmrr-14927 | GameTooltip:Hide() |
|
83 | tardmrr-14927 | self:GetParent():UnlockHighlight() |
|
84 | tardmrr-14927 | end |
|
85 | tardmrr-14927 | ||
86 | tardmrr-14927 | local function updateSelection(self) |
|
87 | tardmrr-14927 | if IsCurrentSpell(self.spellID,"spell") then |
|
88 | tardmrr-14927 | self:SetChecked(true) |
|
89 | tardmrr-14927 | self.clickStopper:Show() |
|
90 | tardmrr-14927 | else |
|
91 | tardmrr-14927 | self:SetChecked(false) |
|
92 | tardmrr-14927 | self.clickStopper:Hide() |
|
93 | tardmrr-14927 | end |
|
94 | tardmrr-14927 | end |
|
95 | tardmrr-14927 | ||
96 | tardmrr-14927 | local function createClickStopper(button) |
|
97 | tardmrr-14927 | local f = CreateFrame("Frame",nil,button) |
|
98 | tardmrr-14927 | f:SetAllPoints(button) |
|
99 | tardmrr-14927 | f:EnableMouse(true) |
|
100 | tardmrr-14927 | f:SetScript("OnEnter",onEnter) |
|
101 | tardmrr-14927 | f:SetScript("OnLeave",onLeave) |
|
102 | tardmrr-14927 | button.clickStopper = f |
|
103 | tardmrr-14927 | f.tooltip = button.tooltip |
|
104 | tardmrr-14927 | f:Hide() |
|
105 | tardmrr-14927 | end |
|
106 | tardmrr-14927 | ||
107 | tardmrr-14927 | ||
108 | 3 | tardmrr-14927 | function TradeTabs:CreateTab(spell,spellID,parent) |
109 | 2 | tardmrr-14927 | local button = CreateFrame("CheckButton",nil,parent,"SpellBookSkillLineTabTemplate,SecureActionButtonTemplate") |
110 | tardmrr-14927 | button.tooltip = spell |
|
111 | tardmrr-14927 | button:Show() |
|
112 | 3 | tardmrr-14927 | button:SetAttribute("type","spell") |
113 | tardmrr-14927 | button:SetAttribute("spell",spell) |
|
114 | 2 | tardmrr-14927 | button.spellID = spellID |
115 | tardmrr-14927 | button:SetNormalTexture(GetSpellTexture(spellID, "spell")) |
|
116 | tardmrr-14927 | ||
117 | tardmrr-14927 | button:SetScript("OnEvent",updateSelection) |
|
118 | tardmrr-14927 | button:RegisterEvent("TRADE_SKILL_SHOW") |
|
119 | tardmrr-14927 | button:RegisterEvent("TRADE_SKILL_CLOSE") |
|
120 | tardmrr-14927 | button:RegisterEvent("CURRENT_SPELL_CAST_CHANGED") |
|
121 | tardmrr-14927 | ||
122 | tardmrr-14927 | createClickStopper(button) |
|
123 | tardmrr-14927 | updateSelection(button) |
|
124 | tardmrr-14927 | return button |
|
125 | tardmrr-14927 | end |
|
126 | tardmrr-14927 | ||
127 | 8 | tardmrr-14927 | TradeTabs:RegisterEvent("TRADE_SKILL_SHOW") |
128 | 2 | tardmrr-14927 | TradeTabs:SetScript("OnEvent",TradeTabs.OnEvent) |
129 | 8 | tardmrr-14927 | |
130 | tardmrr-14927 | TradeTabs:Initialize() |