vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- GrimoireKeeper.lua |
2 | |||
3 | GrimoireKeeperData = {}; |
||
4 | local GKOld_MerchantFrame_UpdateMerchantInfo; |
||
5 | |||
6 | function GrimoireKeeper_OnLoad() |
||
7 | this:RegisterEvent("VARIABLES_LOADED"); |
||
8 | GKOld_MerchantFrame_UpdateMerchantInfo = MerchantFrame_UpdateMerchantInfo; |
||
9 | MerchantFrame_UpdateMerchantInfo = GrimoireKeeper_ColorMerchantInfo; |
||
10 | end |
||
11 | |||
12 | function GrimoireKeeper_OnEvent(event) |
||
13 | if event == "VARIABLES_LOADED" then |
||
14 | this:RegisterEvent("PET_BAR_UPDATE"); |
||
15 | elseif event == "PET_BAR_UPDATE" then |
||
16 | GrimoireKeeper_ParsePetSkills(); |
||
17 | end |
||
18 | end |
||
19 | |||
20 | function GrimoireKeeper_ParsePetSkills() |
||
21 | local hasPetSpells, petToken = HasPetSpells(); |
||
22 | if hasPetSpells ~= nil and petToken == "DEMON" then |
||
23 | local i = 1; |
||
24 | local name, rank = GetSpellName(i, BOOKTYPE_PET) |
||
25 | while name ~= nil do |
||
26 | _,_,rank = string.find(rank, "(%d)") |
||
27 | if rank == nil then rank = "0" end; |
||
28 | GrimoireKeeperData[name] = tonumber(rank); |
||
29 | i = i + 1; |
||
30 | name, rank = GetSpellName(i, BOOKTYPE_PET); |
||
31 | end |
||
32 | else return; |
||
33 | end |
||
34 | end |
||
35 | |||
36 | function GrimoireKeeper_ColorMerchantInfo() |
||
37 | GKOld_MerchantFrame_UpdateMerchantInfo(); |
||
38 | local total = GetMerchantNumItems(); |
||
39 | local name, item; |
||
40 | for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do |
||
41 | local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i); |
||
42 | if (index <= total) then |
||
43 | item = GetMerchantItemInfo(index); |
||
44 | if item == nil then return end; |
||
45 | if string.find(item, "Grimoire") then |
||
46 | _,_,name, rank = string.find(item, "Grimoire of ([%w%s]+) %(Rank (%d+)%)"); |
||
47 | if name == nil then _,_,name = string.find(item, "Grimoire of ([%w%s]+)") end; |
||
48 | if name ~= nil and GrimoireKeeperData[name] ~= nil then |
||
49 | local itemButton = getglobal("MerchantItem"..i.."ItemButton"); |
||
50 | local merchantButton = getglobal("MerchantItem"..i); |
||
51 | if rank ~= nil then rank = tonumber(rank) end; |
||
52 | if (rank == nil) or (rank <= GrimoireKeeperData[name]) then |
||
53 | SetItemButtonNameFrameVertexColor(merchantButton, 0, 0.75, 0.75); |
||
54 | SetItemButtonSlotVertexColor(merchantButton, 0, 0.75, 0.75); |
||
55 | SetItemButtonTextureVertexColor(itemButton, 0, 0.65, 0.65); |
||
56 | SetItemButtonNormalTextureVertexColor(itemButton, 0, 0.65, 0.65); |
||
57 | end |
||
58 | end |
||
59 | end |
||
60 | end |
||
61 | end |
||
62 | end |