tekkub / panda

WoW Addon - Prospecting and Disenchanting Aide

This URL has Read+Write access

panda / Panda.lua
100644 84 lines (66 sloc) 2.829 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

-------------------------------
-- Addon Namespace --
-------------------------------
 
Panda = DongleStub("Dongle-1.0"):New("Panda")
if tekDebug then Panda:EnableDebug(1, tekDebug:GetFrame("Panda")) end
 
 
function Panda:Initialize()
self.BC_GREEN_GEMS, self.BC_BLUE_GEMS, self.CUTS = nil -- Don't hold on to the constants, we might want them to GC later
 
local _, title = GetAddOnInfo("Panda")
local author, version = GetAddOnMetadata("Panda", "Author"), GetAddOnMetadata("Panda", "Version")
local oh = LibStub("OptionHouse-1.1"):RegisterAddOn("Panda", title, author, version)
oh:RegisterCategory("Disenchanting", self, "CreateDisenchantingPanel")
oh:RegisterCategory("Prospecting", self, "CreateProspectingPanel")
oh:RegisterCategory("Prices", self, "CreateDisenchantingPricePanel")
oh:RegisterCategory("Gem Cutting", self, "CreateCutGreenBluePanel")
 
self:RegisterEvent("LOOT_OPENED")
end
 
 
function Panda:Enable()
local i, spellname = 1
repeat
spellname = GetSpellName(i, BOOKTYPE_SPELL)
if spellname == "Disenchant" then self.canDisenchant = true end
if spellname == "Prospecting" then self.canProspect = true end
if spellname == "Jewelcrafting" then self.canJC = true end
i = i + 1
until (self.canDisenchant and self.canProspect and self.canJC) or not spellname
 
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("TRADE_SKILL_SHOW")
end
 
 
------------------------------
-- Util functions --
------------------------------
 
function Panda:HideTooltip() GameTooltip:Hide() end
function Panda:ShowTooltip()
if not self.link then return end
 
GameTooltip:SetOwner(self, "ANCHOR_NONE")
GameTooltip:SetPoint("TOPLEFT", self, "TOPRIGHT")
GameTooltip:SetHyperlink(self.link)
end
 
 
function Panda.GS(cash)
if not cash then return end
cash = cash/100
local s = floor(cash%100)
local g = floor(cash/100)
if g > 0 then return string.format("|cffffd700%d.|cffc7c7cf%02d", g, s)
else return string.format("|cffc7c7cf%d", s) end
end
 
 
-------------------------
-- Constants --
-------------------------
 
Panda.BC_GREEN_GEMS = {23077, 21929, 23112, 23079, 23117, 23107}
Panda.BC_BLUE_GEMS = {23436, 23439, 23440, 23437, 23438, 23441}
Panda.CUTS = {
[23077] = {23094, 23095, 23097, 23096, 28595},
[21929] = {23098, 23099, 23100, 23101, 31866, 31869},
[23112] = {23113, 23114, 23115, 23116, 28290, 31860},
[23079] = {23103, 23104, 23105, 23106},
[23117] = {23118, 23119, 23120, 23121},
[23107] = {23108, 23109, 23110, 23111, 31862, 31864},
[23436] = {24027, 24028, 24029, 24030, 24031, 24032, 24036},
[23439] = {24058, 24059, 24060, 24061, 31867, 31868},
[23440] = {24047, 24048, 24050, 24051, 24052, 24053, 31861},
[23437] = {24062, 24065, 24066, 24067, 33782},
[23438] = {24033, 24035, 24037, 24039},
[23441] = {24054, 24055, 24056, 24057, 31863, 31865},
}