vanilla-wow-addons – Blame information for rev 1
?pathlinks?
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 Functions ]]-- |
||
9 | |||
10 | function BagnonSpot_Search(text) |
||
11 | if text and text ~= "" then |
||
12 | nameFilter = string.lower(text) |
||
13 | else |
||
14 | nameFilter = nil |
||
15 | end |
||
16 | |||
17 | if Bagnon and Bagnon:IsShown() then |
||
18 | BagnonFrame_Generate(Bagnon) |
||
19 | end |
||
20 | if Banknon and Banknon:IsShown() then |
||
21 | BagnonFrame_Generate(Banknon) |
||
22 | end |
||
23 | end |
||
24 | |||
25 | function BagnonSpot_ClearSearch() |
||
26 | nameFilter = nil |
||
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 | BagnonSpot:ClearAllPoints() |
||
44 | BagnonSpot:SetPoint("TOPLEFT", frame:GetName() .. "Title", "TOPLEFT", -2, 1) |
||
45 | BagnonSpot:SetPoint("BOTTOMRIGHT", frame:GetName() .. "Title", "BOTTOMRIGHT", 4, -1) |
||
46 | BagnonSpot:Show() |
||
47 | end |
||
48 | end |
||
49 | |||
50 | local function ToItemID(hyperLink) |
||
51 | if hyperLink then |
||
52 | local _, _, w = string.find(hyperLink, "item:(%d+)") |
||
53 | return w |
||
54 | end |
||
55 | end |
||
56 | |||
57 | -- Darkens items we're not searching for |
||
58 | local oBagnonItem_Update = BagnonItem_Update; |
||
59 | BagnonItem_Update = function(item) |
||
60 | oBagnonItem_Update(item) |
||
61 | |||
62 | if nameFilter then |
||
63 | local link; |
||
64 | if item.isLink then |
||
65 | if BagnonDB then |
||
66 | link = BagnonDB.GetItemData(item:GetParent():GetParent().player, item:GetParent():GetID() , item:GetID()) |
||
67 | end |
||
68 | else |
||
69 | link = ToItemID(GetContainerItemLink(item:GetParent():GetID() , item:GetID())) |
||
70 | end |
||
71 | |||
72 | if link then |
||
73 | local name = (GetItemInfo(link)) |
||
74 | if name and not string.find(string.lower(name), nameFilter) then |
||
75 | item:SetAlpha(item:GetParent():GetParent():GetAlpha()/3) |
||
76 | else |
||
77 | item:SetAlpha(item:GetParent():GetParent():GetAlpha()) |
||
78 | end |
||
79 | end |
||
80 | else |
||
81 | item:SetAlpha(item:GetParent():GetParent():GetAlpha()) |
||
82 | end |
||
83 | end |
||
84 | |||
85 | local oBagnonFrame_OnHide = BagnonFrame_OnHide |
||
86 | BagnonFrame_OnHide = function() |
||
87 | oBagnonFrame_OnHide() |
||
88 | |||
89 | if BagnonSpot:IsVisible() and BagnonSpot.frame == this then |
||
90 | BagnonSpot:Hide() |
||
91 | end |
||
92 | end |
||
93 | |||
94 | local oBagnonFrame_OnEnter = BagnonFrame_OnEnter; |
||
95 | BagnonFrame_OnEnter = function() |
||
96 | oBagnonFrame_OnEnter() |
||
97 | |||
98 | if BagnonSets.showTooltips then |
||
99 | GameTooltip:AddLine(BAGNON_SPOT_TOOLTIP) |
||
100 | GameTooltip:Show() |
||
101 | end |
||
102 | end |