public
Description: WoW addon - Track down those needy and greedy party members
Homepage: http://www.tekkub.net
Clone URL: git://github.com/tekkub/greedbeacon.git
Click here to lend your support to: greedbeacon and make a donation at www.pledgie.com !
Redo GreedBeacon again, this time lets try chat links instead of 
OptionHouse
tekkub (author)
Sat Mar 29 02:23:48 -0700 2008
commit  59a80f4da740d4c18452ce7bed8d4eb0d98d96a2
tree    54970c840c4194657afa09e86d104857e1969d4c
parent  c8f0dcc1a9163f75de67d5e2d1c3efca859e172c
...
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
85
86
87
88
89
90
 
 
 
91
 
 
 
92
93
94
95
96
97
98
99
100
101
102
103
104
105
 
 
 
 
 
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 
 
 
 
 
 
 
 
 
138
139
140
141
142
143
144
145
146
147
 
 
 
 
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
 
 
 
 
177
178
179
180
 
181
182
183
184
185
186
187
188
189
190
191
 
 
 
 
192
193
194
195
196
197
198
 
 
 
 
199
200
 
201
202
203
204
205
206
207
208
209
210
 
 
 
 
 
 
211
212
213
 
 
 
 
 
 
 
 
214
215
216
217
218
219
220
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
 
 
 
 
 
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
0
@@ -1,221 +1,100 @@
0
-local dewdrop = AceLibrary("Dewdrop-2.0")
0
-local tablet = AceLibrary("Tablet-2.0")
0
-
0
-local colorneed, colorgreed, colorpass = "|cffff0000", "|cffffff00", "|cffdddddd"
0
-local tokens, rolls, openrolls = {}, {}, 0
0
-local tokensgreenme
0
-local tokensets = {
0
- greens = {"ahnqirajscarab", "zulgurubcoin"},
0
- blues = {"ahnqirajidol20", "ahnqirajidol40", "zulgurubbijou"},
0
-}
0
-local tokenzones = {
0
- ["Ahn'Qiraj"] = true,
0
- ["Ruins of Ahn'Qiraj"] = true,
0
- ["Zul'Gurub"] = true,
0
-}
0
-local _, _, _, qualgreen = GetItemQualityColor(2)
0
-local _, _, _, qualblue = GetItemQualityColor(3)
0
-local tokenformat1 = qualgreen.. "%s/%s ".. qualblue.. "%s/%s|r | "
0
-local tokenformat2 = string.format("%sGreen Tokens: %s|r", qualgreen, "%s/%s")
0
-local tokenformat3 = string.format("%sBlue Tokens: %s|r", qualblue, "%s/%s")
0
-local strings = {
0
- pass = "passed on: (.+)",
0
- greed = "has selected Greed for: (.+)",
0
- need = "has selected Need for: (.+)",
0
-
0
- selfpass = "You passed on: (.+)",
0
- selfgreed = "You have selected Greed for: (.+)",
0
- selfneed = "You have selected Need for: (.+)",
0
-
0
- allpass = "Everyone passed on: (.+)",
0
- won = "(.+) won: (.+)",
0
- receive = "(.+) receives? loot: (.+).",
0
-}
0
-local rollpairs = {
0
- [strings.pass] = "pass",
0
- [strings.greed] = "greed",
0
- [strings.need] = "need",
0
- [strings.selfpass] = "pass",
0
- [strings.selfgreed] = "greed",
0
- [strings.selfneed] = "need",
0
-}
0
-
0
-
0
-FuBar_GreedBeacon = AceLibrary("AceAddon-2.0"):new("AceHook-2.1", "AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "AceDebug-2.0", "FuBarPlugin-2.0")
0
-FuBar_GreedBeacon.tooltipHiddenWhenEmpty = true
0
-FuBar_GreedBeacon:RegisterDB("FuBar_GreedBeaconDB")
0
-FuBar_GreedBeacon:RegisterDefaults("profile", {chat = false})
0
-
0
-function FuBar_GreedBeacon:OnEnable()
0
- self:RegisterEvent("CHAT_MSG_LOOT")
0
- self:SecureHook("GroupLootFrame_OpenNewFrame")
0
- self:SecureHook("RollOnLoot")
0
-end
0
-
0
-
0
-function FuBar_GreedBeacon:RollOnLoot(rollid, roll)
0
- openrolls = openrolls - 1
0
-end
0
-
0
 
0
-function FuBar_GreedBeacon:GroupLootFrame_OpenNewFrame(rollid, rollTime)
0
- openrolls = openrolls + 1
0
- table.insert(rolls, 1, {id = rollid, link = GetLootRollItemLink(rollid), greed = 0, need = 0, pass = 0})
0
-end
0
-
0
-local gii = GetItemInfo
0
-local GetItemInfo = function(id)
0
- if type(id) == "number" then return gii(id)
0
- elseif type(id) == "string" then
0
- local i = tonumber(id)
0
- if i then return gii(i) end
0
 
0
- local _, _, itemid = string.find(id, "item:(%d+)")
0
- if itemid then return gii(itemid) end
0
- end
0
-end
0
+local colorneed, colorgreed = "|cffff0000", "|cffffff00"
0
+local coloredwords = {Greed = colorgreed.."Greed", Need = colorneed.."Need"}
0
+local rolls = {}
0
 
0
 
0
-function FuBar_GreedBeacon:FindRollIndex(itemlink, hasWinner, allpass)
0
- for i,val in ipairs(rolls) do
0
- if (val.link == itemlink) and ((hasWinner and val.winner) or (hasWinner == false and not val.winner) or (hasWinner == nil)) then
0
- return i
0
- end
0
- end
0
- if allpass then
0
- for i,val in ipairs(rolls) do
0
- if (val.link == itemlink) and val.winner and val.winner == "Pass" then
0
- return i
0
- end
0
- end
0
+local function FindRoll(link, player, hasselected, hasrolled)
0
+ for i,roll in ipairs(rolls) do
0
+ if roll._link == link and not roll._winner and (not roll[player] or hasselected) then return roll, i end
0
   end
0
+ local newroll = {_link = link}
0
+ table.insert(rolls, newroll)
0
+ return newroll, #rolls
0
 end
0
 
0
 
0
-function FuBar_GreedBeacon:CHAT_MSG_LOOT(msg)
0
- local itemname, winner = self:ParseLootPickup(msg)
0
- if itemname and winner then return self:StoreWinner(itemname, winner)
0
- else
0
- local itemname, rolltype = self:ParseRollChoice(msg)
0
- if itemname and rolltype then
0
- local i = self:FindRollIndex(itemname, false)
0
- if not i then return end
0
-
0
- rolls[i][rolltype] = rolls[i][rolltype] + 1
0
- return self:Update()
0
+local function FindUnprintedRoll(link, player)
0
+ for i,roll in ipairs(rolls) do
0
+ if roll._link == link and roll[player] and (roll._printed or 0) < 7 then
0
+ roll._printed = (roll._printed or 0) + 1
0
+ return roll, i
0
     end
0
   end
0
 end
0
 
0
 
0
-function FuBar_GreedBeacon:ParseRollChoice(msg)
0
- for i,v in pairs(rollpairs) do
0
- local _, _, itemname = string.find(msg, i)
0
- if itemname then return itemname, v end
0
- end
0
-end
0
-
0
-
0
-function FuBar_GreedBeacon:ParseLootPickup(msg)
0
- if GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then return end
0
- local _, _, itemname = string.find(msg, strings.allpass)
0
- if itemname then return itemname, "Pass" end
0
-
0
- _, _, playername, itemname = string.find(msg, strings.receive)
0
- if playername and itemname then
0
- playername = (playername == "You" and UnitName("player")) or playername
0
- local _, _, qual = GetItemInfo(itemname)
0
- if qual and qual >= GetLootThreshold() then return itemname, playername end
0
- end
0
-end
0
-
0
-
0
-function FuBar_GreedBeacon:StoreWinner(itemname, winner)
0
- local i = self:FindRollIndex(itemname, false, true)
0
- if not i then
0
- table.insert(rolls, 1, {winner = winner, need = 0, greed = 0, pass = 0, link = itemname})
0
- return self:Update()
0
+local f = CreateFrame("Frame")
0
+f:RegisterEvent("CHAT_MSG_LOOT")
0
+f:SetScript("OnEvent", function(self, event, msg)
0
+ local rolltype, rollval, link, player = msg:match("(.+) Roll %- (%d+) for (.+) by (.+)")
0
+ if player then
0
+ local roll, i = FindRoll(link, player, true)
0
+ roll[player] = (rolltype == "Need" and colorneed or colorgreed)..rollval
0
+ roll._type = rolltype
0
+ return
0
   end
0
 
0
- if PeriodicTable then
0
- if PeriodicTable:ItemInSet(itemname, tokensets.greens) then
0
- tokens.greentotal = (tokens.greentotal or 0) + 1
0
- if winner == UnitName("player") then tokensgreenme = (tokensgreenme or 0) + 1 end
0
- elseif PeriodicTable:ItemInSet(itemname, tokensets.blues) then
0
- tokens.bluetotal = (tokens.bluetotal or 0) + 1
0
- if winner == UnitName("player") then tokens.blueme = (tokens.blueme or 0) + 1 end
0
- end
0
+ local player, selection, link = msg:match("(.*) has selected (.+) for: (.+)")
0
+ if player then
0
+ FindRoll(link, player)[player] = coloredwords[selection]
0
+ return
0
   end
0
- rolls[i].winner = winner
0
-
0
- return self:Update()
0
-end
0
-
0
-
0
-function FuBar_GreedBeacon:UseTokenData()
0
- return self.db.profile.showtokentracker and rolls[1] and tokenzones[GetRealZoneText()]
0
-end
0
-
0
 
0
-function FuBar_GreedBeacon:OnTextUpdate()
0
- local idx, str
0
-
0
- for i,val in ipairs(rolls) do
0
- if not idx and not val.winner then idx = i end
0
- end
0
- if not idx and rolls[1] then idx = 1 end
0
-
0
- if idx then
0
- local toks = self:UseTokenData() and string.format(tokenformat1, (tokensgreenme or 0), (tokens.greentotal or 0), (tokens.blueme or 0), (tokens.bluetotal or 0)) or ""
0
- local val = rolls[idx]
0
- if val.winner then
0
- local color = ((val.need > 0) and colorneed or (val.greed > 0) and colorgreed or colorpass)
0
- str = string.format("%s%s %s%s", toks, self.db.profile.supressitem and "" or val.link, color, val.winner)
0
- else
0
- str = string.format("%s%s %s%d %s%d %s%d", toks, self.db.profile.supressitem and "" or val.link, colorneed, val.need, colorgreed, val.greed, colorpass, val.pass)
0
- end
0
+ local player, link = msg:match("(.*) won: (.+)")
0
+ if player then
0
+ local roll, i = FindRoll(link, player, true, true)
0
+ roll._winner = player
0
   end
0
- self:SetText(str or "No Item")
0
-end
0
-
0
+end)
0
 
0
-function FuBar_GreedBeacon:OnTooltipUpdate()
0
- local det = self:IsTooltipDetached()
0
- if openrolls < 1 and det then return end
0
 
0
- local cat = tablet:AddCategory("columns", 2)
0
- if self:UseTokenData() then
0
- local gtoks = string.format(tokenformat2, (tokensgreenme or 0), (tokens.greentotal or 0))
0
- local btoks = string.format(tokenformat3, (tokens.blueme or 0), (tokens.bluetotal or 0))
0
- cat:AddLine("text", gtoks, "text2", btoks)
0
- end
0
+local orig1 = ChatFrame_MessageEventHandler
0
+function ChatFrame_MessageEventHandler(event, ...)
0
+ if event == "CHAT_MSG_LOOT" then
0
+--~ if arg1:match(" has selected .+ for: ") or (arg1:match(" passed on: ") and not arg1:match("Everyone passed on: ")) then return end
0
 
0
- cat = tablet:AddCategory("columns", 4)
0
- for _,val in ipairs(rolls) do
0
- if not det or not val.winner then
0
- local color = val.winner and ((val.need > 0) and colorneed or (val.greed > 0) and colorgreed or colorpass) or ""
0
- cat:AddLine("text", val.id or "--", "text2", val.link, "text3", color..(val.winner or ""),
0
- "text4", string.format("%s%d %s%d %s%d", colorneed, val.need, colorgreed, val.greed, colorpass, val.pass))
0
+ local player, link = arg1:match("(.*) won: (.+)")
0
+ if player then
0
+ local roll, i = FindUnprintedRoll(link, player, true, true)
0
+ arg1 = string.format("%s|Hgreedbeacon:%d|h[%s roll]|h|r %s won %s ", roll._type == "Need" and colorneed or colorgreed, 1, roll._type, player, link)
0
     end
0
   end
0
+ return orig1(event, ...)
0
 end
0
 
0
 
0
-function FuBar_GreedBeacon:MenuSettings()
0
- dewdrop:AddLine("text", "Clear list","func", function()
0
- rolls, tokens = {}, {}
0
- self:Update()
0
- end)
0
-
0
- dewdrop:AddLine()
0
+local orig2 = SetItemRef
0
+function SetItemRef(link, text, button)
0
+ local id = link:match("greedbeacon:(%d+)")
0
+ if id then
0
+ ShowUIPanel(ItemRefTooltip)
0
+ if not ItemRefTooltip:IsShown() then ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE") end
0
 
0
- dewdrop:AddLine("text", "Use token tracker", "func", function() self:ToggleOption("showtokentracker") end, "checked", self.db.profile.showtokentracker)
0
- dewdrop:AddLine("text", "Show item on bar", "func", function() self:ToggleOption("supressitem") end, "checked", not self.db.profile.supressitem)
0
+ local i = tonumber(id)
0
+ local val = rolls[i]
0
+ ItemRefTooltip:ClearLines()
0
+ ItemRefTooltip:AddLine(coloredwords[val._type].." roll|r - "..val._link)
0
+ ItemRefTooltip:AddDoubleLine("Winner:", "|cffffffff"..val._winner)
0
+ for i,v in pairs(val) do if string.sub(i, 1, 1) ~= "_" then ItemRefTooltip:AddDoubleLine(i, v) end end
0
+ ItemRefTooltip:Show()
0
+ else return orig2(link, text, button) end
0
 end
0
 
0
 
0
-function FuBar_GreedBeacon:ToggleOption(var)
0
- self.db.profile[var] = not self.db.profile[var]
0
- return self:Update()
0
-end
0
-
0
+--~ local oe = f:GetScript("OnEvent")
0
+--~ local function e(event, a1)
0
+--~ oe(f, event, a1)
0
+--~ this, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ChatFrame1, event, a1, nil, nil, ""
0
+--~ ChatFrame_MessageEventHandler(event)
0
+--~ end
0
+
0
+--~ local name, link = GetItemInfo(6948)
0
+--~ e("CHAT_MSG_LOOT", "Bob has selected Greed for: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Joe has selected Need for: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Mary has selected Need for: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Jane passed on: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Need Roll - 56 for "..link.." by Joe")
0
+--~ e("CHAT_MSG_LOOT", "Need Roll - 5 for "..link.." by Mary")
0
+--~ e("CHAT_MSG_LOOT", "Joe won: "..link)
...
1
 
2
3
4
...
6
7
8
9
10
11
12
 
13
14
15
...
 
1
2
3
4
...
6
7
8
 
 
 
 
9
10
11
12
0
@@ -1,4 +1,4 @@
0
-## Interface: 20300
0
+## Interface: 20400
0
 
0
 ## Title: GreedBeacon
0
 ## Notes: Track down those needy and greedy party members.
0
@@ -6,10 +6,7 @@
0
 ## Version: Alpha
0
 ## X-Category: Inventory
0
 
0
-## SavedVariables: GreedBeaconDB
0
-
0
-## Dependencies: FuBar
0
-## OptionalDeps: Ace2, TabletLib, DewdropLib, FuBarPlugin-2.0
0
+## OptionalDeps: tekErr
0
 
0
 ## LoadManagers: AddonLoader
0
 ## X-LoadOn-Always: delayed

Comments

    No one has commented yet.