vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 spot.lua
3 Scripts for Bagnon_Spot, which provides filtering functionality for Bagnon
4 --]]
5  
6 local nameFilter;
7  
8 --[[ Search Box Functions ]]--
9  
10 function BagnonSpot_OnHide()
11 nameFilter = nil;
12  
13 if(Bagnon and Bagnon:IsShown() ) then
14 BagnonFrame_Generate(Bagnon);
15 end
16 if(Banknon and Banknon:IsShown() ) then
17 BagnonFrame_Generate(Banknon);
18 end
19 end
20  
21 function BagnonSpotSearch_OnTextChanged()
22 if(this:GetText() and this:GetText() ~= "") then
23 nameFilter = string.lower(this:GetText());
24 else
25 nameFilter = nil;
26 end
27  
28 if(Bagnon and Bagnon:IsShown() ) then
29 BagnonFrame_Generate(Bagnon);
30 end
31 if(Banknon and Banknon:IsShown() ) then
32 BagnonFrame_Generate(Banknon);
33 end
34 end
35  
36 --[[ Function Overrides ]]--
37  
38 BagnonFrame_OnDoubleClick = function(frame)
39 if(arg1 == "LeftButton") then
40 BagnonSpot:Hide();
41 BagnonSpot.frame = frame;
42  
43 local x, y = GetCursorPosition();
44 x = x / UIParent:GetScale();
45 y = y / UIParent:GetScale();
46  
47 BagnonSpot:ClearAllPoints();
48 BagnonSpot:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x - 24, y + 24);
49 BagnonSpot:Show();
50 end
51 end
52  
53 local function ToItemID(hyperLink)
54 if(hyperLink) then
55 local _, _, w = string.find(hyperLink, "item:(%d+)") ;
56 return w;
57 end
58 return nil;
59 end
60  
61 -- Darkens items we're not searching for
62 local oBagnonItem_Update = BagnonItem_Update;
63 BagnonItem_Update = function(item)
64 oBagnonItem_Update(item);
65  
66 if( nameFilter ) then
67  
68 local link;
69  
70 if(item.isLink) then
71 if(BagnonDB) then
72 link = BagnonDB.GetItemData(item:GetParent():GetParent().player, item:GetParent():GetID() , item:GetID());
73 end
74 else
75 link = ToItemID( GetContainerItemLink(item:GetParent():GetID() , item:GetID()) );
76 end
77  
78 if(link) then
79 local name = (GetItemInfo(link));
80  
81 if(name) then
82 if( not string.find(string.lower(name), nameFilter) ) then
83 getglobal(item:GetName() .. "IconTexture"):SetVertexColor(0.5, 0.5, 0.5, 0.5);
84 else
85 getglobal(item:GetName() .. "IconTexture"):SetVertexColor(1, 1, 1, 1);
86 end
87 else
88 getglobal(item:GetName() .. "IconTexture"):SetVertexColor(1, 1, 1, 1);
89 end
90 end
91 else
92 getglobal(item:GetName() .. "IconTexture"):SetVertexColor(1, 1, 1, 1);
93 end
94 end
95  
96 local oBagnonFrame_OnHide = BagnonFrame_OnHide
97 BagnonFrame_OnHide = function()
98 oBagnonFrame_OnHide();
99  
100 if(BagnonSpot:IsVisible() and BagnonSpot.frame == this) then
101 BagnonSpot:Hide();
102 end
103 end
104  
105 local oBagnonFrame_OnEnter = BagnonFrame_OnEnter;
106 BagnonFrame_OnEnter = function()
107 oBagnonFrame_OnEnter();
108  
109 if(BagnonSets.showTooltips) then
110 GameTooltip:AddLine(BAGNON_SPOT_TOOLTIP);
111 GameTooltip:Show();
112 end
113 end