WoWInterface SVN NeedyGreedy

[/] [trunk/] [NeedyGreedy.lua] - Blame information for rev 142

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 lokyst-32688
NeedyGreedy = LibStub("AceAddon-3.0"):NewAddon("NeedyGreedy", "AceEvent-3.0", "AceTimer-3.0", "AceConsole-3.0")
2 2 lokyst-32688
 
3 18 lokyst-32688
local L = LibStub("AceLocale-3.0"):GetLocale("NeedyGreedy", true)
4 141 lokyst-32688
local LSM = LibStub("LibSharedMedia-3.0")
5 18 lokyst-32688
 
6 51 lokyst-32688
local report = {}
7 lokyst-32688
local items = {}
8 lokyst-32688
local nameList = {}
9 lokyst-32688
 
10 22 lokyst-32688
-- Set up DataBroker object
11 20 lokyst-32688
local NeedyGreedyLDB = LibStub("LibDataBroker-1.1"):NewDataObject("NeedyGreedy", {
12 123 lokyst-32688
    type = "data source",
13 lokyst-32688
    text = "",
14 14 lokyst-32688
    label = "Needy Greedy",
15 lokyst-32688
    icon = "Interface\\Buttons\\UI-GroupLoot-Dice-Up",
16 lokyst-32688
    OnClick = function(frame, button)
17 lokyst-32688
        if button == "RightButton" then
18 lokyst-32688
            InterfaceOptionsFrame_OpenToCategory("NeedyGreedy")
19 21 lokyst-32688
        elseif IsShiftKeyDown() then
20 lokyst-32688
            NeedyGreedy.db.profile.detachedTooltip = not NeedyGreedy.db.profile.detachedTooltip
21 lokyst-32688
            LibStub("AceConfigRegistry-3.0"):NotifyChange("NeedyGreedy")
22 lokyst-32688
            NeedyGreedy:HideDBTooltip()
23 lokyst-32688
            NeedyGreedy:ShowDBTooltip(frame)
24 lokyst-32688
            NeedyGreedy:HideDetachedTooltip()
25 61 lokyst-32688
            if NeedyGreedy.db.profile.detachedTooltip then
26 94 lokyst-32688
                NeedyGreedy.db.profile.displayStatus = true
27 lokyst-32688
                NeedyGreedy:RefreshTooltip()
28 21 lokyst-32688
            end
29 28 lokyst-32688
        elseif IsAltKeyDown() then
30 lokyst-32688
            NeedyGreedy:ClearItems()
31 21 lokyst-32688
        elseif NeedyGreedy.db.profile.detachedTooltip then
32 14 lokyst-32688
            NeedyGreedy:ToggleDisplay()
33 lokyst-32688
        end
34 lokyst-32688
    end,
35 lokyst-32688
    OnEnter = function(frame)
36 21 lokyst-32688
        NeedyGreedy:ShowDBTooltip(frame)
37 14 lokyst-32688
    end,
38 lokyst-32688
    OnLeave = function()
39 71 lokyst-32688
        if NeedyGreedy.db.profile.detachedTooltip then
40 lokyst-32688
            NeedyGreedy:HideDBTooltip()
41 lokyst-32688
        end
42 14 lokyst-32688
    end,
43 2 lokyst-32688
})
44 20 lokyst-32688
local ngDBIcon = LibStub("LibDBIcon-1.0")
45 lokyst-32688
 
46 22 lokyst-32688
-- Set up configuration window
47 2 lokyst-32688
local options = {
48 18 lokyst-32688
    name = L["NeedyGreedy"],
49 lokyst-32688
    desc = L["Displays a table of items and the roll choices players have made on them"],
50 12 lokyst-32688
    handler = NeedyGreedy,
51 6 lokyst-32688
    type = "group",
52 lokyst-32688
    args = {
53 33 lokyst-32688
        general = {
54 lokyst-32688
            name = L['General'],
55 lokyst-32688
            type = 'group',
56 121 lokyst-32688
            childGroups = "tab",
57 33 lokyst-32688
            args = {
58 lokyst-32688
                nItems = {
59 lokyst-32688
                    name = L["Display Items"],
60 lokyst-32688
                    desc = L["Number of item columns in the display window"],
61 lokyst-32688
                    type = "range",
62 68 lokyst-32688
                    order = 105,
63 33 lokyst-32688
                    min = 1,
64 lokyst-32688
                    max = 10,
65 lokyst-32688
                    step = 1,
66 lokyst-32688
                    get = "GetNItems",
67 lokyst-32688
                    set = "SetNItems"
68 lokyst-32688
                },
69 lokyst-32688
                expiry = {
70 lokyst-32688
                    name = L["Expiry Time"],
71 lokyst-32688
                    desc = L["Minutes after item is received before it is removed from display (0 = forever)"],
72 lokyst-32688
                    type = "range",
73 36 lokyst-32688
                    order = 120,
74 33 lokyst-32688
                    min = 0,
75 34 lokyst-32688
                    max = 110,
76 33 lokyst-32688
                    step = 1,
77 lokyst-32688
                    get = "GetExpiry",
78 lokyst-32688
                    set = "SetExpiry"
79 lokyst-32688
                },
80 lokyst-32688
                quality = {
81 lokyst-32688
                    name = L["Minimum Quality"],
82 lokyst-32688
                    desc = L["Minimum quality of item to be displayed"],
83 lokyst-32688
                    type = "select",
84 36 lokyst-32688
                    order = 130,
85 33 lokyst-32688
                    values = {
86 lokyst-32688
                        [ITEM_QUALITY_UNCOMMON] = ITEM_QUALITY2_DESC,
87 lokyst-32688
                        [ITEM_QUALITY_RARE] = ITEM_QUALITY3_DESC,
88 lokyst-32688
                        [ITEM_QUALITY_EPIC] = ITEM_QUALITY4_DESC
89 lokyst-32688
                    },
90 lokyst-32688
                    style = "dropdown",
91 lokyst-32688
                    get = "GetQuality",
92 lokyst-32688
                    set = "SetQuality"
93 lokyst-32688
                },
94 68 lokyst-32688
                resetInNewParty = {
95 lokyst-32688
                    name = L["Reset on Join Party"],
96 lokyst-32688
                    desc = L["Clear the item list when joining a new group"],
97 lokyst-32688
                    type = "select",
98 lokyst-32688
                    values = {
99 lokyst-32688
                        always = "Always",
100 lokyst-32688
                        ask = "Ask",
101 lokyst-32688
                        never = "Never",
102 lokyst-32688
                    },
103 lokyst-32688
                    style = "dropdown",
104 lokyst-32688
                    order = 100,
105 lokyst-32688
                    get = "GetResetInNewParty",
106 lokyst-32688
                    set = "SetResetInNewParty",
107 lokyst-32688
                },
108 79 lokyst-32688
                resetInNewInstance = {
109 lokyst-32688
                    name = L["Reset in Instance"],
110 lokyst-32688
                    desc = L["Clear the item list when entering an instance"],
111 lokyst-32688
                    type = "select",
112 lokyst-32688
                    values = {
113 lokyst-32688
                        always = "Always",
114 lokyst-32688
                        ask = "Ask",
115 lokyst-32688
                        never = "Never",
116 lokyst-32688
                    },
117 lokyst-32688
                    style = "dropdown",
118 lokyst-32688
                    order = 101,
119 lokyst-32688
                    get = "GetResetInNewInstance",
120 lokyst-32688
                    set = "SetResetInNewInstance",
121 lokyst-32688
                },
122 68 lokyst-32688
 
123 33 lokyst-32688
                displayIcons = {
124 lokyst-32688
                    name = L["Graphical Display"],
125 lokyst-32688
                    desc = L["Display icons for rolls types instead of text"],
126 lokyst-32688
                    type = "toggle",
127 lokyst-32688
                    order = 20,
128 lokyst-32688
                    get = "GetDisplayIcons",
129 lokyst-32688
                    set = "SetDisplayIcons",
130 lokyst-32688
                },
131 lokyst-32688
                displayTextLink = {
132 lokyst-32688
                    name = L["Item Names"],
133 lokyst-32688
                    desc = L["Toggle the display of the item name in the header"],
134 lokyst-32688
                    order = 30,
135 lokyst-32688
                    type = "toggle",
136 lokyst-32688
                    get = "GetDisplayTextLink",
137 lokyst-32688
                    set = "SetDisplayTextLink",
138 lokyst-32688
                },
139 lokyst-32688
                hideMinimapIcon = {
140 lokyst-32688
                    name = L["Minimap Icon"],
141 lokyst-32688
                    desc = L["Toggle the display of the minimap icon"],
142 lokyst-32688
                    type = "toggle",
143 36 lokyst-32688
                    order = 99,
144 33 lokyst-32688
                    get = "GetHideMinimapIcon",
145 lokyst-32688
                    set = "SetHideMinimapIcon",
146 60 lokyst-32688
                    width = "full"
147 33 lokyst-32688
                },
148 37 lokyst-32688
                showGroupOnly = {
149 lokyst-32688
                    name = L["Hide Non-Members"],
150 lokyst-32688
                    desc = L["Only display the names of members currently in your party"],
151 lokyst-32688
                    type = "toggle",
152 113 lokyst-32688
                    order = 50,
153 37 lokyst-32688
                    get = "GetShowGroupOnly",
154 lokyst-32688
                    set = "SetShowGroupOnly",
155 lokyst-32688
                },
156 123 lokyst-32688
                showLootMethod = {
157 lokyst-32688
                    name = L["Show Loot Method"],
158 lokyst-32688
                    desc = L["Display the loot method as a databroker feed"],
159 lokyst-32688
                    type = "toggle",
160 lokyst-32688
                    order = 50,
161 lokyst-32688
                    get = "GetShowLootMethod",
162 lokyst-32688
                    set = "SetShowLootMethod",
163 lokyst-32688
                },
164 121 lokyst-32688
 
165 123 lokyst-32688
 
166 121 lokyst-32688
                chatOptions = {
167 lokyst-32688
                    name = L["Chat options"],
168 lokyst-32688
                    type = "group",
169 lokyst-32688
                    args = {
170 lokyst-32688
                        filterLootMsgs = {
171 lokyst-32688
                            name = L["Filter Loot Messages"],
172 lokyst-32688
                            desc = L["Enable filtering of loot roll messages"],
173 lokyst-32688
                            type = "toggle",
174 lokyst-32688
                            order = 70,
175 lokyst-32688
                            get = "GetFilterLootMsgs",
176 lokyst-32688
                            set = "SetFilterLootMsgs",
177 lokyst-32688
                        },
178 lokyst-32688
                        noSpamMode = {
179 lokyst-32688
                            name = L["Loot Summary"],
180 lokyst-32688
                            desc = L["Print loot roll summary message to chat frame"],
181 lokyst-32688
                            type = "toggle",
182 lokyst-32688
                            order =71,
183 lokyst-32688
                            get = "GetNoSpamMode",
184 lokyst-32688
                            set = "SetNoSpamMode",
185 lokyst-32688
                        },
186 lokyst-32688
                        highlightSelfChat = {
187 lokyst-32688
                            name = L["Highlight Self"],
188 lokyst-32688
                            desc = L["Color loot you have won differently. Only works with loot summary enabled"],
189 lokyst-32688
                            type = "toggle",
190 lokyst-32688
                            order = 75,
191 lokyst-32688
                            get = "GetHighlightSelfChat",
192 lokyst-32688
                            set = "SetHighlightSelfChat",
193 lokyst-32688
                        },
194 lokyst-32688
                        highlightSelfColorChat = {
195 lokyst-32688
                            name = L["Self Color"],
196 lokyst-32688
                            type = "color",
197 lokyst-32688
                            order = 76,
198 lokyst-32688
                            get = "GetHighlightSelfChatColor",
199 lokyst-32688
                            set = "SetHighlightSelfChatColor",
200 lokyst-32688
                            hasAlpha = false,
201 lokyst-32688
                        },
202 lokyst-32688
                        highlightWinnerChat = {
203 lokyst-32688
                            name = L["Highlight Winner"],
204 lokyst-32688
                            desc = L["Color winning loot rolls differently. Only works with loot summary enabled"],
205 lokyst-32688
                            type = "toggle",
206 lokyst-32688
                            order = 77,
207 lokyst-32688
                            get = "GetHighlightWinnerChat",
208 lokyst-32688
                            set = "SetHighlightWinnerChat",
209 lokyst-32688
                        },
210 lokyst-32688
                        highlightWinnerChatColor = {
211 lokyst-32688
                            name = L["Winner Color"],
212 lokyst-32688
                            type = "color",
213 lokyst-32688
                            order = 78,
214 lokyst-32688
                            get = "GetHighlightWinnerChatColor",
215 lokyst-32688
                            set = "SetHighlightWinnerChatColor",
216 lokyst-32688
                            hasAlpha = false,
217 lokyst-32688
                        },
218 lokyst-32688
                    },
219 lokyst-32688
                },
220 lokyst-32688
 
221 lokyst-32688
                UIOptions = {
222 lokyst-32688
                    name = L["UI options"],
223 lokyst-32688
                    type = "group",
224 lokyst-32688
                    args = {
225 lokyst-32688
                        highlightSelf = {
226 lokyst-32688
                            name = L["Highlight Self"],
227 lokyst-32688
                            desc = L["Color loot you have won differently"],
228 lokyst-32688
                            type = "toggle",
229 lokyst-32688
                            order = 80,
230 lokyst-32688
                            get = "GetHighlightSelf",
231 lokyst-32688
                            set = "SetHighlightSelf",
232 lokyst-32688
                        },
233 lokyst-32688
                        highlightSelfColor = {
234 lokyst-32688
                            name = L["Self Color"],
235 lokyst-32688
                            type = "color",
236 lokyst-32688
                            order = 81,
237 lokyst-32688
                            get = "GetHighlightSelfColor",
238 lokyst-32688
                            set = "SetHighlightSelfColor",
239 lokyst-32688
                            hasAlpha = false,
240 lokyst-32688
                        },
241 lokyst-32688
                        highlightWinner = {
242 lokyst-32688
                            name = L["Highlight Winner"],
243 lokyst-32688
                            desc = L["Color winning loot rolls differently"],
244 lokyst-32688
                            type = "toggle",
245 lokyst-32688
                            order = 82,
246 lokyst-32688
                            get = "GetHighlightWinner",
247 lokyst-32688
                            set = "SetHighlightWinner",
248 lokyst-32688
                        },
249 lokyst-32688
                        highlightWinnerColor = {
250 lokyst-32688
                            name = L["Winner Color"],
251 lokyst-32688
                            type = "color",
252 lokyst-32688
                            order = 83,
253 lokyst-32688
                            get = "GetHighlightWinnerColor",
254 lokyst-32688
                            set = "SetHighlightWinnerColor",
255 lokyst-32688
                            hasAlpha = false,
256 lokyst-32688
                        },
257 141 lokyst-32688
 
258 lokyst-32688
                        playSoundOnAward = {
259 lokyst-32688
                            name = L["Play Sound"],
260 lokyst-32688
                            desc = L["Play sound when rolling is complete"],
261 lokyst-32688
                            type = "toggle",
262 lokyst-32688
                            order = 100,
263 lokyst-32688
                            get = "GetPlaySoundOnAward",
264 lokyst-32688
                            set = "SetPlaySoundOnAward",
265 lokyst-32688
                        },
266 lokyst-32688
 
267 lokyst-32688
                        soundFile = {
268 lokyst-32688
                            name = 'Sound File',
269 lokyst-32688
                            desc = 'Sound to play when rolling is complete',
270 lokyst-32688
                            type = 'select',
271 lokyst-32688
                            dialogControl = 'LSM30_Sound',
272 lokyst-32688
                            style = "dropdown",
273 lokyst-32688
                            values = LSM:HashTable("sound"),
274 lokyst-32688
                            get = "GetSoundFile",
275 lokyst-32688
                            set = "SetSoundFile",
276 lokyst-32688
                        },
277 lokyst-32688
 
278 121 lokyst-32688
                    },
279 lokyst-32688
                },
280 92 lokyst-32688
            },
281 lokyst-32688
        },
282 60 lokyst-32688
 
283 92 lokyst-32688
        detachedTooltipOptions = {
284 lokyst-32688
            name = L["Detached Tooltip"],
285 lokyst-32688
            type = "group",
286 131 lokyst-32688
            childGroups = "tab",
287 92 lokyst-32688
            args = {
288 lokyst-32688
                detachedTooltip = {
289 lokyst-32688
                    name = L["Detach Tooltip"],
290 lokyst-32688
                    desc = L["Display the roll information in a standalone window"],
291 lokyst-32688
                    type = "toggle",
292 lokyst-32688
                    order = 10,
293 lokyst-32688
                    get = "GetDetachedTooltip",
294 lokyst-32688
                    set = "SetDetachedTooltip",
295 60 lokyst-32688
                },
296 92 lokyst-32688
                autoPopUp = {
297 lokyst-32688
                    name = L["Popup when rolling"],
298 lokyst-32688
                    desc = L["Automatically show the detached tooltip when an item is being rolled on"],
299 lokyst-32688
                    type = "toggle",
300 lokyst-32688
                    order = 11,
301 lokyst-32688
                    get = "GetAutoPopUp",
302 lokyst-32688
                    set = "SetAutoPopUp",
303 lokyst-32688
                },
304 lokyst-32688
                showOnParty = {
305 lokyst-32688
                    name = L["Show in party"],
306 lokyst-32688
                    desc = L["Display the detached window when joining a party and hide the tooltip when leaving a party"],
307 lokyst-32688
                    type = "toggle",
308 lokyst-32688
                    order = 12,
309 lokyst-32688
                    get = "GetShowOnParty",
310 lokyst-32688
                    set = "SetShowOnParty",
311 lokyst-32688
                },
312 103 lokyst-32688
                tooltipAutoHideDelay = {
313 lokyst-32688
                    name = L["Autohide delay"],
314 lokyst-32688
                    desc = L["Time to remain visible after the last item has been received (Popup mode only)"],
315 lokyst-32688
                    type = "range",
316 lokyst-32688
                    order = 13,
317 lokyst-32688
                    min = 0,
318 lokyst-32688
                    max = 60,
319 lokyst-32688
                    step = 1,
320 lokyst-32688
                    get = "GetAutoHideDelay",
321 lokyst-32688
                    set = "SetAutoHideDelay",
322 lokyst-32688
                },
323 92 lokyst-32688
                hideInCombat = {
324 lokyst-32688
                    name = L["Hide in combat"],
325 lokyst-32688
                    desc = L["Only display the detached window when not in combat"],
326 lokyst-32688
                    type = "toggle",
327 lokyst-32688
                    order = 14,
328 lokyst-32688
                    get = "GetHideInCombat",
329 lokyst-32688
                    set = "SetHideInCombat",
330 lokyst-32688
                },
331 lokyst-32688
                tooltipScale = {
332 lokyst-32688
                    name = L["Scale"],
333 lokyst-32688
                    desc = L["Adjust the scale of the detached tooltip"],
334 lokyst-32688
                    type = "range",
335 lokyst-32688
                    order = 16,
336 lokyst-32688
                    min = 0.5,
337 lokyst-32688
                    max= 2.0,
338 lokyst-32688
                    step = 0.01,
339 lokyst-32688
                    get = "GetTooltipScale",
340 lokyst-32688
                    set = "SetTooltipScale",
341 lokyst-32688
                },
342 93 lokyst-32688
                lockTooltip = {
343 lokyst-32688
                    name = L["Lock Tooltip"],
344 lokyst-32688
                    desc = L["Adjust the position of the detached tooltip"],
345 lokyst-32688
                    type = "toggle",
346 lokyst-32688
                    order = 100,
347 lokyst-32688
                    get = "GetLockTooltip",
348 lokyst-32688
                    set = "SetLockTooltip",
349 lokyst-32688
                    width = "full",
350 lokyst-32688
                },
351 60 lokyst-32688
 
352 131 lokyst-32688
                detachedTooltipUIOptions = {
353 lokyst-32688
                    name = L["UI options"],
354 lokyst-32688
                    type = "group",
355 lokyst-32688
                    args = {
356 lokyst-32688
                        useTooltipDefaults = {
357 lokyst-32688
                            name = L["Default Style"],
358 lokyst-32688
                            desc = L["Use the default tooltip background and border style for detached tooltip"],
359 lokyst-32688
                            type = "toggle",
360 lokyst-32688
                            order = 200,
361 lokyst-32688
                            get = "GetUseTooltipDefault",
362 lokyst-32688
                            set = "SetUseTooltipDefault",
363 lokyst-32688
                            width = "full",
364 lokyst-32688
                        },
365 lokyst-32688
                        bgColor = {
366 lokyst-32688
                            name = L["Background Color"],
367 lokyst-32688
                            desc = L["Change the background color of the detached tooltip"],
368 lokyst-32688
                            type = "color",
369 lokyst-32688
                            order = 210,
370 lokyst-32688
                            get = "GetBackgroundColor",
371 lokyst-32688
                            set = "SetBackgroundColor",
372 lokyst-32688
                            hasAlpha = true,
373 lokyst-32688
                            disabled = function() return NeedyGreedy.db.profile.useTooltipDefaults end,
374 lokyst-32688
                        },
375 lokyst-32688
                        borderColor = {
376 lokyst-32688
                            name = L["Border Color"],
377 lokyst-32688
                            desc = L["Change the border color of the detached tooltip"],
378 lokyst-32688
                            type = "color",
379 lokyst-32688
                            order = 220,
380 lokyst-32688
                            get = "GetBorderColor",
381 lokyst-32688
                            set = "SetBorderColor",
382 lokyst-32688
                            hasAlpha = true,
383 lokyst-32688
                            disabled = function() return NeedyGreedy.db.profile.useTooltipDefaults end,
384 lokyst-32688
                        },
385 lokyst-32688
                    }
386 lokyst-32688
                }
387 lokyst-32688
 
388 6 lokyst-32688
            },
389 lokyst-32688
        },
390 92 lokyst-32688
 
391 96 lokyst-32688
        dataBrokerOptions = {
392 lokyst-32688
            name = L["DataBroker Tooltip"],
393 lokyst-32688
            type = "group",
394 lokyst-32688
            args = {
395 lokyst-32688
                suppressInRaid = {
396 lokyst-32688
                    name = L["Hide In Raid"],
397 lokyst-32688
                    desc = L["Suppress the display of the LibDataBroker tooltip when in a raid"],
398 lokyst-32688
                    type = "toggle",
399 lokyst-32688
                    order = 10,
400 lokyst-32688
                    get = "GetSuppressInRaid",
401 lokyst-32688
                    set = "SetSuppressInRaid",
402 lokyst-32688
                },
403 lokyst-32688
            },
404 lokyst-32688
        },
405 lokyst-32688
 
406 6 lokyst-32688
    }
407 2 lokyst-32688
}
408 lokyst-32688
 
409 22 lokyst-32688
-- Set profile defaults
410 2 lokyst-32688
local defaults = {
411 6 lokyst-32688
    profile = {
412 14 lokyst-32688
        nItems = 2,
413 6 lokyst-32688
        expiry = 5,
414 30 lokyst-32688
        quality = ITEM_QUALITY_RARE,
415 14 lokyst-32688
        displayIcons = true,
416 lokyst-32688
        detachedTooltip = false,
417 16 lokyst-32688
        displayTextLink = false,
418 94 lokyst-32688
        displayStatus = false,
419 20 lokyst-32688
        minimap = { hide = false },
420 22 lokyst-32688
        filterLootMsgs = false,
421 90 lokyst-32688
        showOnParty = false,
422 36 lokyst-32688
        hideInCombat = false,
423 37 lokyst-32688
        showGroupOnly = true,
424 66 lokyst-32688
        autoPopUp = true,
425 68 lokyst-32688
        resetInNewParty = "ask",
426 79 lokyst-32688
        resetInNewInstance = "ask",
427 91 lokyst-32688
        tooltipScale = 1,
428 93 lokyst-32688
        lockTooltip = false,
429 96 lokyst-32688
        suppressInRaid = false,
430 103 lokyst-32688
        autoHideDelay = 0,
431 111 lokyst-32688
        noSpamMode = false,
432 112 lokyst-32688
        highlightSelf = false,
433 lokyst-32688
        highlightSelfColor = {1, 0.8, 0, 1},
434 113 lokyst-32688
        highlightWinner = false,
435 lokyst-32688
        highlightWinnerColor = {0, 1, 0, 1},
436 121 lokyst-32688
        highlightSelfChat = false,
437 lokyst-32688
        highlightSelfChatColor = {1, 0.8, 0, 1},
438 lokyst-32688
        highlightWinnerChat = false,
439 lokyst-32688
        highlightWinnerChatColor = {0, 1, 0, 1},
440 123 lokyst-32688
        showLootMethod = false,
441 131 lokyst-32688
        useTooltipDefaults = true,
442 lokyst-32688
        bgColor = GameTooltip:GetBackdrop(),
443 lokyst-32688
        borderColor = {GameTooltip:GetBackdropBorderColor()},
444 141 lokyst-32688
        playSoundOnAward = false,
445 142 lokyst-32688
        soundFile = LSM:Fetch("sound", value),
446 lokyst-32688
        soundName = "None",
447 6 lokyst-32688
    }
448 2 lokyst-32688
}
449 lokyst-32688
 
450 84 lokyst-32688
-- Console commands
451 lokyst-32688
local slashTable = {
452 lokyst-32688
    handler = NeedyGreedy,
453 lokyst-32688
    type = "group",
454 lokyst-32688
    args = {
455 lokyst-32688
        config = {
456 lokyst-32688
            name = L["Open the configuration menu"],
457 lokyst-32688
            type = "execute",
458 lokyst-32688
            func = function() InterfaceOptionsFrame_OpenToCategory("NeedyGreedy") end,
459 lokyst-32688
        },
460 lokyst-32688
        hide = {
461 lokyst-32688
            name = L["Hide the detached tooltip"],
462 lokyst-32688
            type = "execute",
463 lokyst-32688
            func = "SlashHide",
464 lokyst-32688
        },
465 lokyst-32688
        report = {
466 lokyst-32688
            name = L["Generate a text summary"],
467 lokyst-32688
            type = "execute",
468 lokyst-32688
            func = "PrintReport",
469 lokyst-32688
        },
470 lokyst-32688
        reset = {
471 lokyst-32688
            name = L["Reset the item list"],
472 lokyst-32688
            type = "execute",
473 lokyst-32688
            func = "ClearItems",
474 lokyst-32688
        },
475 lokyst-32688
        show = {
476 lokyst-32688
            name = L["Show the detached tooltip"],
477 lokyst-32688
            type = "execute",
478 lokyst-32688
            func = "SlashShow",
479 lokyst-32688
        },
480 lokyst-32688
    },
481 lokyst-32688
}
482 lokyst-32688
 
483 53 lokyst-32688
-- Icon textures
484 5 lokyst-32688
local iconSize = 27
485 13 lokyst-32688
local NEEDYGREEDY_CHOICE = {
486 6 lokyst-32688
    ["need"] = {
487 lokyst-32688
        ["string"] = "|c00FF0000" .. NEED .. "|r",
488 lokyst-32688
        ["icon"] = "|TInterface\\Buttons\\UI-GroupLoot-Dice-Up:" .. iconSize .. "|t",
489 lokyst-32688
    },
490 lokyst-32688
    ["greed"] = {
491 lokyst-32688
        ["string"] = "|c0000FF00" .. GREED .. "|r",
492 lokyst-32688
        ["icon"] = "|TInterface\\Buttons\\UI-GroupLoot-Coin-Up:" .. iconSize .. "|t",
493 lokyst-32688
    },
494 lokyst-32688
    ["pass"] = {
495 lokyst-32688
        ["string"] = "|c00CCCCCC" .. PASS .. "|r",
496 41 lokyst-32688
        ["icon"] = "|TInterface\\Buttons\\UI-GroupLoot-Pass-Up:" .. iconSize .. "|t",
497 6 lokyst-32688
    },
498 lokyst-32688
    ["disenchant"] = {
499 lokyst-32688
        ["string"] = "|c00FF00FF" .. ROLL_DISENCHANT .. "|r",
500 lokyst-32688
        ["icon"] = "|TInterface\\Buttons\\UI-GroupLoot-DE-Up:" .. iconSize .. "|t",
501 lokyst-32688
    }
502 3 lokyst-32688
}
503 41 lokyst-32688
local BLANK_ICON = "|T:27|t"
504 53 lokyst-32688
local CLOSE_ICON = "|TInterface\\Buttons\\UI-Panel-MinimizeButton-Up:" .. iconSize .. "|t"
505 lokyst-32688
local PAGER_ICONS = {
506 lokyst-32688
    leftUp = "|TInterface\\Buttons\\UI-SpellbookIcon-PrevPage-Up:" .. iconSize .. "|t",
507 lokyst-32688
    leftDisabled = "|TInterface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled:" .. iconSize .. "|t",
508 lokyst-32688
    rightUp = "|TInterface\\Buttons\\UI-SpellbookIcon-NextPage-Up:" .. iconSize .. "|t",
509 lokyst-32688
    rightDisabled = "|TInterface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled:" .. iconSize .. "|t",
510 lokyst-32688
}
511 3 lokyst-32688
 
512 14 lokyst-32688
-- Funky colors for text strings
513 lokyst-32688
local yC = "|cffFFCC00" -- Golden
514 lokyst-32688
local eC = "|cffEDA55F" -- Orange
515 lokyst-32688
local gC = "|cff00FF00" -- Green
516 lokyst-32688
 
517 25 lokyst-32688
-- For tracking original state of detailed loot information
518 lokyst-32688
local originalSpamFilterSetting = nil
519 22 lokyst-32688
 
520 35 lokyst-32688
-- For tracking combat status
521 lokyst-32688
local IS_IN_COMBAT = nil
522 lokyst-32688
 
523 61 lokyst-32688
-- We track rolling on items like this to avoid the scenario where you're in
524 lokyst-32688
-- combat the window pops up, you leave combat briefly before another add
525 lokyst-32688
-- attacks and the window disappears as you're deciding
526 88 lokyst-32688
local WATCH_ITEM_BEING_ROLLED_ON = nil
527 61 lokyst-32688
 
528 103 lokyst-32688
-- To track if there is a scheduled script
529 lokyst-32688
local ROLL_TIMER = nil
530 lokyst-32688
 
531 66 lokyst-32688
-- For tracking grouped status
532 lokyst-32688
local IS_IN_PARTY = nil
533 96 lokyst-32688
local IS_IN_RAID = nil
534 66 lokyst-32688
 
535 79 lokyst-32688
-- For tracking ghost status
536 lokyst-32688
local WAS_GHOST = nil
537 lokyst-32688
 
538 98 lokyst-32688
-- For tracking instance changes
539 lokyst-32688
local INSTANCE_NAME = nil
540 lokyst-32688
 
541 115 lokyst-32688
-- Needed for chat filter
542 lokyst-32688
local FILTER_CHAT_LOOT_MSGS = {}
543 lokyst-32688
 
544 lokyst-32688
local ORIG_FILTER_CHAT_LOOT_MSGS = {
545 lokyst-32688
    LOOT_ROLL_DISENCHANT,
546 lokyst-32688
    LOOT_ROLL_DISENCHANT_SELF,
547 lokyst-32688
    LOOT_ROLL_GREED,
548 lokyst-32688
    LOOT_ROLL_GREED_SELF,
549 lokyst-32688
    LOOT_ROLL_NEED,
550 lokyst-32688
    LOOT_ROLL_NEED_SELF,
551 lokyst-32688
    LOOT_ROLL_PASSED,
552 lokyst-32688
    LOOT_ROLL_PASSED_AUTO,
553 lokyst-32688
    LOOT_ROLL_PASSED_AUTO_FEMALE,
554 lokyst-32688
    LOOT_ROLL_PASSED_SELF,
555 lokyst-32688
    LOOT_ROLL_PASSED_SELF_AUTO,
556 lokyst-32688
    LOOT_ROLL_ROLLED_DE,
557 lokyst-32688
    LOOT_ROLL_ROLLED_GREED,
558 lokyst-32688
    LOOT_ROLL_ROLLED_NEED,
559 lokyst-32688
}
560 lokyst-32688
 
561 lokyst-32688
local NO_SPAM_FILTER_CHAT_LOOT_MSGS = {
562 lokyst-32688
    --LOOT_ROLL_ALL_PASSED,
563 lokyst-32688
    LOOT_ROLL_DISENCHANT,
564 lokyst-32688
    LOOT_ROLL_DISENCHANT_SELF,
565 lokyst-32688
    LOOT_ROLL_GREED,
566 lokyst-32688
    LOOT_ROLL_GREED_SELF,
567 lokyst-32688
    LOOT_ROLL_NEED,
568 lokyst-32688
    LOOT_ROLL_NEED_SELF,
569 lokyst-32688
    LOOT_ROLL_PASSED,
570 lokyst-32688
    LOOT_ROLL_PASSED_AUTO,
571 lokyst-32688
    LOOT_ROLL_PASSED_AUTO_FEMALE,
572 lokyst-32688
    LOOT_ROLL_PASSED_SELF,
573 lokyst-32688
    LOOT_ROLL_PASSED_SELF_AUTO,
574 lokyst-32688
    LOOT_ROLL_ROLLED_DE,
575 lokyst-32688
    LOOT_ROLL_ROLLED_GREED,
576 lokyst-32688
    LOOT_ROLL_ROLLED_NEED,
577 lokyst-32688
    LOOT_ROLL_WON,
578 lokyst-32688
    LOOT_ROLL_YOU_WON,
579 lokyst-32688
    --LOOT_ITEM,
580 lokyst-32688
    --LOOT_ITEM_MULTIPLE,
581 lokyst-32688
    --LOOT_ITEM_PUSHED_SELF,
582 lokyst-32688
    --LOOT_ITEM_PUSHED_SELF_MULTIPLE,
583 lokyst-32688
    --LOOT_ITEM_SELF,
584 lokyst-32688
    --LOOT_ITEM_SELF_MULTIPLE,
585 lokyst-32688
}
586 lokyst-32688
 
587 24 lokyst-32688
-- Utility functions
588 lokyst-32688
local function sanitizePattern(pattern)
589 lokyst-32688
    pattern = string.gsub(pattern, "%(", "%%(")
590 lokyst-32688
    pattern = string.gsub(pattern, "%)", "%%)")
591 lokyst-32688
    pattern = string.gsub(pattern, "%%s", "(.+)")
592 lokyst-32688
    pattern = string.gsub(pattern, "%%d", "(%%d+)")
593 lokyst-32688
    pattern = string.gsub(pattern, "%-", "%%-")
594 lokyst-32688
    return pattern
595 lokyst-32688
end
596 lokyst-32688
 
597 lokyst-32688
-- Converts a format string into a pattern and list of capture group indices
598 lokyst-32688
-- e.g. %2$s won the %1$s
599 lokyst-32688
local function patternFromFormat(format)
600 lokyst-32688
    local pattern = ""
601 lokyst-32688
    local captureIndices = {}
602 25 lokyst-32688
 
603 24 lokyst-32688
    local start = 1
604 lokyst-32688
    local captureIndex = 0
605 lokyst-32688
    repeat
606 lokyst-32688
        -- find the next group
607 lokyst-32688
        local s, e, group, position = format:find("(%%([%d$]*)[ds])", start)
608 lokyst-32688
        if s then
609 lokyst-32688
            -- add the text between the last group and this group
610 lokyst-32688
            pattern = pattern..sanitizePattern(format:sub(start, s-1))
611 lokyst-32688
            -- update the current capture index, using the position bit in the
612 lokyst-32688
            -- group if it exists, otherwise just increment
613 lokyst-32688
            if #position > 0 then
614 lokyst-32688
                -- chop off the $ and convert to a number
615 lokyst-32688
                captureIndex = tonumber(position:sub(1, #position-1))
616 lokyst-32688
            else
617 lokyst-32688
                captureIndex = captureIndex + 1
618 lokyst-32688
            end
619 lokyst-32688
            -- add the current capture index to our list
620 lokyst-32688
            tinsert(captureIndices, captureIndex)
621 lokyst-32688
            -- remove the position bit from the group, sanitize the remainder
622 lokyst-32688
            -- and add it to the pattern
623 lokyst-32688
            pattern = pattern..sanitizePattern(group:gsub("%d%$", "", 1))
624 lokyst-32688
            -- start searching again from past the end of the group
625 lokyst-32688
            start = e + 1
626 lokyst-32688
        else
627 lokyst-32688
            -- if no more groups can be found, but there's still more text
628 lokyst-32688
            -- remaining in the format string, sanitize the remainder, add it
629 lokyst-32688
            -- to the pattern and finish the loop
630 lokyst-32688
            if start <= #format then
631 lokyst-32688
                pattern = pattern..sanitizePattern(format:sub(start))
632 lokyst-32688
            end
633 lokyst-32688
            break
634 lokyst-32688
        end
635 lokyst-32688
    until start > #format
636 25 lokyst-32688
 
637 24 lokyst-32688
    return pattern, captureIndices
638 lokyst-32688
end
639 lokyst-32688
 
640 lokyst-32688
-- Like string:find but uses a list of capture indices to re-order the capture
641 lokyst-32688
-- groups. For use with converted format strings that use positional args.
642 lokyst-32688
-- e.g. %2$s won the %1$s.
643 lokyst-32688
local function superFind(text, pattern, captureIndices)
644 lokyst-32688
    local results = { text:find(pattern) }
645 lokyst-32688
    if #results == 0 then
646 lokyst-32688
        return
647 lokyst-32688
    end
648 25 lokyst-32688
 
649 24 lokyst-32688
    local s, e = tremove(results, 1), tremove(results, 1)
650 25 lokyst-32688
 
651 24 lokyst-32688
    local captures = {}
652 lokyst-32688
    for _, index in ipairs(captureIndices) do
653 lokyst-32688
        tinsert(captures, results[index])
654 lokyst-32688
    end
655 25 lokyst-32688
 
656 24 lokyst-32688
    return s, e, unpack(captures)
657 lokyst-32688
end
658 lokyst-32688
 
659 31 lokyst-32688
-- Strips the item ID out of the item link
660 lokyst-32688
-- Needed for items that change their unique identifier
661 lokyst-32688
local function itemIdFromLink(itemLink)
662 lokyst-32688
    local found, _, itemString = string.find(itemLink, "|H(.+)|h")
663 lokyst-32688
    if found then
664 lokyst-32688
        local _, itemId = strsplit(":", itemString)
665 lokyst-32688
        return tonumber(itemId)
666 lokyst-32688
    end
667 lokyst-32688
    return nil
668 lokyst-32688
end
669 24 lokyst-32688
 
670 66 lokyst-32688
-- Ye olde pop up box
671 lokyst-32688
local function confirmResetDialog()
672 lokyst-32688
        StaticPopupDialogs["NeedyGreedyResetDialog"] = {
673 lokyst-32688
                                                text = L["Do you wish to reset NeedyGreedy?"],
674 lokyst-32688
                                                button1 = ACCEPT,
675 lokyst-32688
                                                button2 = CANCEL,
676 lokyst-32688
                                                timeout = 30,
677 lokyst-32688
                                                whileDead = 0,
678 lokyst-32688
                                                hideOnEscape = 1,
679 lokyst-32688
                                                OnAccept = function() NeedyGreedy:ClearItems() end,
680 lokyst-32688
                                        }
681 lokyst-32688
        StaticPopup_Show("NeedyGreedyResetDialog")
682 lokyst-32688
end
683 24 lokyst-32688
 
684 31 lokyst-32688
 
685 66 lokyst-32688
 
686 22 lokyst-32688
-- Event handling functions
687 12 lokyst-32688
function NeedyGreedy:OnInitialize()
688 84 lokyst-32688
 
689 lokyst-32688
    -- Profile handling
690 12 lokyst-32688
    self.db = LibStub("AceDB-3.0"):New("NeedyGreedyDB", defaults, true)
691 83 lokyst-32688
    self.db.RegisterCallback(self, "OnProfileChanged", "RefreshProfile")
692 lokyst-32688
    self.db.RegisterCallback(self, "OnProfileCopied", "RefreshProfile")
693 lokyst-32688
    self.db.RegisterCallback(self, "OnProfileReset", "RefreshProfile")
694 33 lokyst-32688
    options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
695 84 lokyst-32688
 
696 lokyst-32688
    -- Register config options
697 12 lokyst-32688
    LibStub("AceConfig-3.0"):RegisterOptionsTable("NeedyGreedy", options)
698 84 lokyst-32688
 
699 lokyst-32688
    -- Set up GUI configuration
700 33 lokyst-32688
    local ACD = LibStub("AceConfigDialog-3.0")
701 lokyst-32688
    ACD:AddToBlizOptions("NeedyGreedy", "NeedyGreedy", nil, "general")
702 92 lokyst-32688
    ACD:AddToBlizOptions("NeedyGreedy", L["Detached Tooltip"], "NeedyGreedy", "detachedTooltipOptions")
703 96 lokyst-32688
    ACD:AddToBlizOptions("NeedyGreedy", L["DataBroker Tooltip"], "NeedyGreedy", "dataBrokerOptions")
704 33 lokyst-32688
    ACD:AddToBlizOptions("NeedyGreedy", L["Profile"], "NeedyGreedy", "profile")
705 20 lokyst-32688
 
706 84 lokyst-32688
    -- Register slash options table
707 lokyst-32688
    LibStub("AceConfig-3.0"):RegisterOptionsTable("NeedyGreedyCmds", slashTable, {"ng", "needygreedy"})
708 lokyst-32688
 
709 20 lokyst-32688
    -- Register the minimap icon
710 lokyst-32688
    ngDBIcon:Register("NeedyGreedy", NeedyGreedyLDB, self.db.profile.minimap)
711 142 lokyst-32688
 
712 lokyst-32688
    -- Register some sounds
713 lokyst-32688
    LSM:Register("sound", "Bells", [[Sound\Spells\ShaysBell.wav]])
714 lokyst-32688
    LSM:Register("sound", "Cheer", [[Sound\Event Sounds\OgreEventCheerUnique.wav]])
715 lokyst-32688
 
716 2 lokyst-32688
end
717 lokyst-32688
 
718 12 lokyst-32688
function NeedyGreedy:OnEnable()
719 6 lokyst-32688
    self:RegisterEvent("PARTY_MEMBERS_CHANGED")
720 lokyst-32688
    self:RegisterEvent("START_LOOT_ROLL")
721 lokyst-32688
    self:RegisterEvent("CHAT_MSG_LOOT")
722 35 lokyst-32688
    self:RegisterEvent("PLAYER_REGEN_DISABLED")
723 lokyst-32688
    self:RegisterEvent("PLAYER_REGEN_ENABLED")
724 79 lokyst-32688
    self:RegisterEvent("PLAYER_ALIVE")
725 96 lokyst-32688
    self:RegisterEvent("RAID_ROSTER_UPDATE")
726 123 lokyst-32688
    self:RegisterEvent("PARTY_LOOT_METHOD_CHANGED")
727 35 lokyst-32688
 
728 39 lokyst-32688
    self:ScheduleRepeatingTimer("ExpireItems", 10)
729 2 lokyst-32688
 
730 40 lokyst-32688
    -- Refresh display when class can be determined
731 22 lokyst-32688
    self:RegisterEvent("PLAYER_ENTERING_WORLD")
732 40 lokyst-32688
    self:RegisterEvent("UNIT_CLASSIFICATION_CHANGED", "PLAYER_ENTERING_WORLD")
733 22 lokyst-32688
 
734 25 lokyst-32688
    self:RegisterEvent("PLAYER_LEAVING_WORLD")
735 lokyst-32688
 
736 22 lokyst-32688
    -- Set up chat filters
737 lokyst-32688
    if self.db.profile.filterLootMsgs then
738 lokyst-32688
        self:EnableChatFilter()
739 20 lokyst-32688
    end
740 25 lokyst-32688
 
741 111 lokyst-32688
    if self.db.profile.noSpamMode then
742 lokyst-32688
        self:EnableNoSpamMode()
743 lokyst-32688
    end
744 lokyst-32688
 
745 25 lokyst-32688
    self:SetShowLootSpam()
746 20 lokyst-32688
end
747 lokyst-32688
 
748 12 lokyst-32688
function NeedyGreedy:OnDisable()
749 21 lokyst-32688
    self:HideDetachedTooltip()
750 22 lokyst-32688
 
751 lokyst-32688
    -- Turn off chat filters
752 lokyst-32688
    if self.db.profile.filterLootMsgs then
753 lokyst-32688
        self:DisableChatFilter()
754 lokyst-32688
    end
755 25 lokyst-32688
 
756 lokyst-32688
    self:ResetShowLootSpam()
757 2 lokyst-32688
end
758 lokyst-32688
 
759 22 lokyst-32688
function NeedyGreedy:PLAYER_ENTERING_WORLD()
760 98 lokyst-32688
    local inInstance, instanceType = IsInInstance()
761 lokyst-32688
    local newInstanceName = GetInstanceInfo()
762 86 lokyst-32688
 
763 98 lokyst-32688
    -- PLAYER_ENTERING_WORLD events can trigger without any
764 lokyst-32688
    -- discernable change to the instance e.g. during
765 lokyst-32688
    -- Prophet Tharonja, CoT:CoS when the dragonkin reveal themselves
766 lokyst-32688
    -- Swamp Lord Musalek fight in Underbog
767 lokyst-32688
    if newInstanceName == INSTANCE_NAME then
768 lokyst-32688
        return
769 lokyst-32688
    else
770 lokyst-32688
        INSTANCE_NAME = newInstanceName
771 lokyst-32688
    end
772 lokyst-32688
 
773 61 lokyst-32688
    wipe(nameList)
774 lokyst-32688
    if self.db.profile.detachedTooltip then
775 lokyst-32688
        if self:DisplayDetachedTTCheck() then
776 lokyst-32688
            self:RefreshTooltip()
777 lokyst-32688
        end
778 6 lokyst-32688
    end
779 25 lokyst-32688
 
780 79 lokyst-32688
    if inInstance and (instanceType == "party" or instanceType == "raid") then
781 lokyst-32688
        -- Don't ask when making a graveyard run
782 lokyst-32688
        if not WAS_GHOST then
783 lokyst-32688
            if self.db.profile.resetInNewInstance == "always" and (#items ~= 0) then
784 lokyst-32688
                self:ClearItems()
785 lokyst-32688
            elseif self.db.profile.resetInNewInstance == "ask" and (#items ~= 0) then
786 lokyst-32688
                confirmResetDialog()
787 lokyst-32688
            end
788 lokyst-32688
        else
789 lokyst-32688
            WAS_GHOST = false
790 lokyst-32688
        end
791 lokyst-32688
    end
792 lokyst-32688
 
793 123 lokyst-32688
    self:UpdatePartyLootMethodText()
794 lokyst-32688
 
795 25 lokyst-32688
    self:SetShowLootSpam()
796 2 lokyst-32688
end
797 lokyst-32688
 
798 25 lokyst-32688
function NeedyGreedy:PLAYER_LEAVING_WORLD()
799 lokyst-32688
    self:ResetShowLootSpam()
800 lokyst-32688
end
801 lokyst-32688
 
802 12 lokyst-32688
function NeedyGreedy:PARTY_MEMBERS_CHANGED()
803 78 lokyst-32688
    if (GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0) and not IS_IN_PARTY then
804 66 lokyst-32688
        IS_IN_PARTY = true
805 90 lokyst-32688
 
806 69 lokyst-32688
        if self.db.profile.resetInNewParty == "always" and (#items ~= 0) then
807 68 lokyst-32688
            self:ClearItems()
808 69 lokyst-32688
        elseif self.db.profile.resetInNewParty == "ask" and (#items ~= 0) then
809 66 lokyst-32688
            confirmResetDialog()
810 lokyst-32688
        end
811 90 lokyst-32688
 
812 94 lokyst-32688
        if self.db.profile.showOnParty and self.db.profile.detachedTooltip and not self.db.profile.displayStatus then
813 lokyst-32688
            self.db.profile.displayStatus = true
814 90 lokyst-32688
            self:ShowDetachedTooltip()
815 lokyst-32688
        end
816 lokyst-32688
 
817 78 lokyst-32688
    elseif (GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0) then
818 66 lokyst-32688
        IS_IN_PARTY = false
819 96 lokyst-32688
        IS_IN_RAID = false
820 90 lokyst-32688
 
821 94 lokyst-32688
        if self.db.profile.showOnParty and self.db.profile.detachedTooltip and self.db.profile.displayStatus then
822 lokyst-32688
            self.db.profile.displayStatus = false
823 90 lokyst-32688
            self:HideDetachedTooltip()
824 lokyst-32688
        end
825 lokyst-32688
 
826 66 lokyst-32688
    end
827 lokyst-32688
 
828 123 lokyst-32688
    self:UpdatePartyLootMethodText()
829 lokyst-32688
 
830 38 lokyst-32688
    wipe(nameList)
831 21 lokyst-32688
    self:RefreshTooltip()
832 2 lokyst-32688
end
833 lokyst-32688
 
834 35 lokyst-32688
function NeedyGreedy:PLAYER_REGEN_DISABLED()
835 lokyst-32688
    IS_IN_COMBAT = true
836 lokyst-32688
    self:RefreshTooltip()
837 lokyst-32688
end
838 11 lokyst-32688
 
839 35 lokyst-32688
function NeedyGreedy:PLAYER_REGEN_ENABLED()
840 lokyst-32688
    IS_IN_COMBAT = false
841 lokyst-32688
    self:RefreshTooltip()
842 lokyst-32688
end
843 11 lokyst-32688
 
844 79 lokyst-32688
function NeedyGreedy:PLAYER_ALIVE()
845 80 lokyst-32688
    if UnitIsDeadOrGhost("player") then
846 79 lokyst-32688
        WAS_GHOST = true
847 lokyst-32688
    elseif WAS_GHOST then
848 lokyst-32688
        WAS_GHOST = false
849 lokyst-32688
    end
850 lokyst-32688
end
851 35 lokyst-32688
 
852 96 lokyst-32688
function NeedyGreedy:RAID_ROSTER_UPDATE()
853 lokyst-32688
    if GetNumRaidMembers() > 0 then
854 lokyst-32688
        IS_IN_RAID = true
855 lokyst-32688
    else
856 lokyst-32688
        IS_IN_RAID = false
857 lokyst-32688
    end
858 lokyst-32688
end
859 35 lokyst-32688
 
860 123 lokyst-32688
function NeedyGreedy:PARTY_LOOT_METHOD_CHANGED()
861 lokyst-32688
    self:UpdatePartyLootMethodText()
862 lokyst-32688
end
863 79 lokyst-32688
 
864 123 lokyst-32688
local LOOT_METHOD_STRINGS = {
865 lokyst-32688
    ["freeforall"] = LOOT_FREE_FOR_ALL,
866 lokyst-32688
    ["roundrobin"] = LOOT_ROUND_ROBIN,
867 lokyst-32688
    ["group"] = LOOT_GROUP_LOOT,
868 lokyst-32688
    ["master"] = LOOT_MASTER_LOOTER,
869 lokyst-32688
    ["needbeforegreed"] = LOOT_NEED_BEFORE_GREED,
870 lokyst-32688
}
871 96 lokyst-32688
 
872 123 lokyst-32688
function NeedyGreedy:UpdatePartyLootMethodText()
873 lokyst-32688
    if not self.db.profile.showLootMethod then
874 lokyst-32688
        NeedyGreedyLDB.text = ""
875 lokyst-32688
        return
876 lokyst-32688
    end
877 lokyst-32688
 
878 lokyst-32688
    local lootmethod, masterlooterPartyID, masterlooterRaidID = GetLootMethod()
879 lokyst-32688
    local name = ""
880 lokyst-32688
 
881 lokyst-32688
    if (GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0) then
882 lokyst-32688
        if lootmethod == "master" then
883 lokyst-32688
            if masterlooterRaidID ~= nil then
884 lokyst-32688
                name = GetRaidRosterInfo(masterlooterRaidID)
885 lokyst-32688
            elseif masterlooterPartyID ~= nil then
886 lokyst-32688
                name = UnitName("party" .. masterlooterPartyID)
887 lokyst-32688
            end
888 lokyst-32688
 
889 lokyst-32688
            if name == nil then
890 lokyst-32688
                name = UnitName("player")
891 lokyst-32688
            end
892 lokyst-32688
            NeedyGreedyLDB.text = LOOT_METHOD_STRINGS[lootmethod] .. " (" .. name .. ")"
893 lokyst-32688
        else
894 lokyst-32688
 
895 lokyst-32688
            NeedyGreedyLDB.text = LOOT_METHOD_STRINGS[lootmethod]
896 lokyst-32688
        end
897 lokyst-32688
 
898 lokyst-32688
    else
899 lokyst-32688
        NeedyGreedyLDB.text = ""
900 lokyst-32688
    end
901 lokyst-32688
end
902 lokyst-32688
 
903 lokyst-32688
 
904 11 lokyst-32688
-- Chat scanning and loot recording
905 88 lokyst-32688
function NeedyGreedy:START_LOOT_ROLL(event, rollid, rollTime)
906 6 lokyst-32688
    local texture, name, count, quality = GetLootRollItemInfo(rollid)
907 lokyst-32688
    local link = GetLootRollItemLink(rollid)
908 lokyst-32688
    if quality >= self.db.profile.quality then
909 69 lokyst-32688
        table.insert(items, {
910 6 lokyst-32688
            texture = texture,
911 lokyst-32688
            link = link,
912 31 lokyst-32688
            itemID = itemIdFromLink(link),
913 6 lokyst-32688
            assigned = "",
914 lokyst-32688
            received = 0,
915 lokyst-32688
            choices = {},
916 88 lokyst-32688
            rolls = {},
917 lokyst-32688
            rollTimeOut = GetTime() + rollTime/1000,
918 69 lokyst-32688
        })
919 61 lokyst-32688
 
920 lokyst-32688
        if self.db.profile.detachedTooltip and self.db.profile.autoPopUp then
921 88 lokyst-32688
            WATCH_ITEM_BEING_ROLLED_ON = true
922 61 lokyst-32688
            self:ShowDetachedTooltip()
923 103 lokyst-32688
            -- Check if a new roll was started before the delayed script was called
924 lokyst-32688
            if self.db.profile.autoHideDelay > 0 and ROLL_TIMER then
925 105 lokyst-32688
                self:CancelTimer(ROLL_TIMER, true)
926 106 lokyst-32688
                ROLL_TIMER = nil
927 103 lokyst-32688
            end
928 61 lokyst-32688
        end
929 lokyst-32688
 
930 6 lokyst-32688
        self:UpdateReport()
931 lokyst-32688
    end
932 2 lokyst-32688
end
933 lokyst-32688
 
934 99 lokyst-32688
local CHAT_MSG_TABLE = {
935 lokyst-32688
    {LOOT_ROLL_YOU_WON, "RecordAwarded", {1, "me", nil, nil}},
936 lokyst-32688
    {LOOT_ROLL_WON, "RecordAwarded", {2, 1, nil, nil}},
937 lokyst-32688
    {LOOT_ROLL_ALL_PASSED, "RecordAwarded", {1, "---", nil, nil}},
938 lokyst-32688
    {LOOT_ROLL_PASSED_AUTO, "RecordChoice", {2, 1, nil, "pass"}},
939 lokyst-32688
    {LOOT_ROLL_PASSED_AUTO_FEMALE, "RecordChoice", {2, 1, nil, "pass"}},
940 lokyst-32688
    {LOOT_ROLL_NEED_SELF, "RecordChoice", {1, "me", nil, "need"}},
941 lokyst-32688
    {LOOT_ROLL_GREED_SELF, "RecordChoice", {1, "me", nil, "greed"}},
942 lokyst-32688
    {LOOT_ROLL_PASSED_SELF, "RecordChoice", {1, "me", nil, "pass"}},
943 lokyst-32688
    {LOOT_ROLL_PASSED_SELF_AUTO, "RecordChoice", {1, "me", nil, "pass"}},
944 lokyst-32688
    {LOOT_ROLL_NEED, "RecordChoice", {2, 1, nil, "need"}},
945 lokyst-32688
    {LOOT_ROLL_GREED, "RecordChoice", {2, 1, nil, "greed"}},
946 lokyst-32688
    {LOOT_ROLL_PASSED, "RecordChoice", {2, 1, nil, "pass"}},
947 lokyst-32688
    {LOOT_ROLL_DISENCHANT_SELF, "RecordChoice", {1, "me", nil, "disenchant"}},
948 lokyst-32688
    {LOOT_ROLL_DISENCHANT, "RecordChoice", {2, 1, nil, "disenchant"}},
949 lokyst-32688
    {LOOT_ROLL_ROLLED_NEED, "RecordRoll", {2, 3, 1, nil}},
950 lokyst-32688
    {LOOT_ROLL_ROLLED_GREED, "RecordRoll", {2, 3, 1, nil}},
951 lokyst-32688
    {LOOT_ROLL_ROLLED_DE, "RecordRoll", {2, 3, 1, nil}},
952 lokyst-32688
    {LOOT_ITEM_PUSHED_SELF, "RecordReceived", {1, "me", nil, nil}},
953 lokyst-32688
    {LOOT_ITEM_PUSHED_SELF_MULTIPLE, "RecordReceived", {1, "me", nil, nil}},
954 lokyst-32688
    {LOOT_ITEM_SELF, "RecordReceived", {1, "me", nil, nil}},
955 lokyst-32688
    {LOOT_ITEM_SELF_MULTIPLE, "RecordReceived", {1, "me", nil, nil}},
956 lokyst-32688
    {LOOT_ITEM, "RecordReceived", {2, 1, nil, nil}},
957 lokyst-32688
    {LOOT_ITEM_MULTIPLE, "RecordReceived", {2, 1, nil, nil}},
958 lokyst-32688
}
959 2 lokyst-32688
 
960 111 lokyst-32688
local CHAT_MSG_NO_SPAM_TABLE = {
961 lokyst-32688
    LOOT_ROLL_WON_NO_SPAM_DE, -- = "%1$s won: %3$s |cff818181(Disenchant - %2$d)|r";
962 lokyst-32688
    LOOT_ROLL_WON_NO_SPAM_GREED, --  = "%1$s won: %3$s |cff818181(Greed - %2$d)|r";
963 lokyst-32688
    LOOT_ROLL_WON_NO_SPAM_NEED, -- = "%1$s won: %3$s |cff818181(Need - %2$d)|r";
964 lokyst-32688
    LOOT_ROLL_YOU_WON_NO_SPAM_DE, -- = "You won: %2$s |cff818181(Disenchant - %1$d)|r";
965 lokyst-32688
    LOOT_ROLL_YOU_WON_NO_SPAM_GREED, -- = "You won: %2$s |cff818181(Greed - %1$d)|r";
966 lokyst-32688
    LOOT_ROLL_YOU_WON_NO_SPAM_NEED, -- = "You won: %2$s |cff818181(Need - %1$d)|r";
967 lokyst-32688
}
968 lokyst-32688
 
969 lokyst-32688
function NeedyGreedy:NoSpamMessage(link, player)
970 lokyst-32688
    local printString
971 lokyst-32688
    local me = UnitName("player")
972 lokyst-32688
    local item
973 lokyst-32688
 
974 lokyst-32688
    for _, record in ipairs(items) do
975 lokyst-32688
        if record.assigned == player and record.link == link then
976 lokyst-32688
            item = record
977 lokyst-32688
            break
978 lokyst-32688
        end
979 lokyst-32688
    end
980 lokyst-32688
 
981 lokyst-32688
    if not item then
982 lokyst-32688
        return
983 lokyst-32688
    end
984 lokyst-32688
 
985 lokyst-32688
    local rollType = item.choices[player]
986 lokyst-32688
    local roll = item.rolls[player]
987 lokyst-32688
 
988 lokyst-32688
    if player == me then
989 lokyst-32688
        if rollType == "disenchant" then
990 lokyst-32688
            printString = LOOT_ROLL_YOU_WON_NO_SPAM_DE:format(roll, link)
991 lokyst-32688
        elseif rollType == "greed" then
992 lokyst-32688
            printString = LOOT_ROLL_YOU_WON_NO_SPAM_GREED:format(roll, link)
993 lokyst-32688
        elseif rollType == "need" then
994 lokyst-32688
            printString = LOOT_ROLL_YOU_WON_NO_SPAM_NEED:format(roll, link)
995 lokyst-32688
        end
996 lokyst-32688
    else
997 lokyst-32688
        if rollType == "disenchant" then
998 lokyst-32688
            printString = LOOT_ROLL_WON_NO_SPAM_DE:format(player, roll, link)
999 lokyst-32688
        elseif rollType == "greed" then
1000 lokyst-32688
            printString = LOOT_ROLL_WON_NO_SPAM_GREED:format(player, roll, link)
1001 lokyst-32688
        elseif rollType == "need" then
1002 lokyst-32688
            printString = LOOT_ROLL_WON_NO_SPAM_NEED:format(player, roll, link)
1003 lokyst-32688
        end
1004 lokyst-32688
    end
1005 118 lokyst-32688
 
1006 121 lokyst-32688
    -- Default to Blizzard color
1007 lokyst-32688
    local r, g, b, a = GetMessageTypeColor("CHAT_MSG_LOOT")
1008 lokyst-32688
 
1009 lokyst-32688
    -- Color winner
1010 lokyst-32688
    if self.db.profile.highlightWinnerChat then
1011 lokyst-32688
        r, g, b, a = unpack(self.db.profile.highlightWinnerChatColor)
1012 112 lokyst-32688
    end
1013 118 lokyst-32688
 
1014 121 lokyst-32688
    -- Color self
1015 lokyst-32688
    if self.db.profile.highlightSelfChat and player == me then
1016 lokyst-32688
        r, g, b, a = unpack(self.db.profile.highlightSelfChatColor)
1017 lokyst-32688
    end
1018 lokyst-32688
 
1019 111 lokyst-32688
    DEFAULT_CHAT_FRAME:AddMessage(printString, r, g, b)
1020 lokyst-32688
end
1021 lokyst-32688
 
1022 99 lokyst-32688
function NeedyGreedy:CHAT_MSG_LOOT(event,msg)
1023 lokyst-32688
    local functionName, link, player, roll, type
1024 lokyst-32688
    local stringValues, inputs
1025 2 lokyst-32688
 
1026 99 lokyst-32688
    for _, message in ipairs(CHAT_MSG_TABLE) do
1027 lokyst-32688
        stringValues = {self:unformat(message[1], msg)}
1028 lokyst-32688
        if #stringValues > 0 then
1029 lokyst-32688
            functionName = message[2]
1030 lokyst-32688
            inputs = message[3]
1031 lokyst-32688
            link = stringValues[inputs[1]]
1032 lokyst-32688
            if inputs[2] == "me" then
1033 lokyst-32688
                player = UnitName("player")
1034 lokyst-32688
            elseif inputs[2] == "---" then
1035 lokyst-32688
                player = "---"
1036 lokyst-32688
            else
1037 lokyst-32688
                player = stringValues[inputs[2]]
1038 lokyst-32688
            end
1039 lokyst-32688
            if inputs[3] then roll = stringValues[inputs[3]] end
1040 lokyst-32688
            type = inputs[4]
1041 lokyst-32688
            self:RecordParser(functionName, link, player, roll, type)
1042 lokyst-32688
            break
1043 lokyst-32688
        end
1044 6 lokyst-32688
    end
1045 99 lokyst-32688
end
1046 2 lokyst-32688
 
1047 99 lokyst-32688
function NeedyGreedy:RecordParser(functionName, link, player, roll, type)
1048 lokyst-32688
    if functionName == "RecordAwarded" then
1049 lokyst-32688
        self:RecordAwarded(link, player)
1050 111 lokyst-32688
 
1051 lokyst-32688
        -- if no spam filter option turned on
1052 lokyst-32688
        if self.db.profile.noSpamMode then
1053 lokyst-32688
            self:NoSpamMessage(link, player)
1054 lokyst-32688
        end
1055 lokyst-32688
 
1056 99 lokyst-32688
    elseif functionName == "RecordChoice" then
1057 lokyst-32688
        self:RecordChoice(link, player, type)
1058 lokyst-32688
    elseif functionName == "RecordRoll" then
1059 lokyst-32688
        self:RecordRoll(link, player, roll)
1060 lokyst-32688
    elseif functionName == "RecordReceived" then
1061 15 lokyst-32688
        self:RecordReceived(link, player)
1062 99 lokyst-32688
    else
1063 lokyst-32688
        self:Print("Unrecognised function name: " .. tostring(functionName))
1064 6 lokyst-32688
    end
1065 2 lokyst-32688
end
1066 lokyst-32688
 
1067 12 lokyst-32688
function NeedyGreedy:RecordChoice(link, player, choice)
1068 31 lokyst-32688
    local _, _, quality = GetItemInfo(link)
1069 lokyst-32688
    if quality < self.db.profile.quality then return end
1070 lokyst-32688
 
1071 69 lokyst-32688
    for _, record in ipairs(items) do
1072 6 lokyst-32688
        if record.assigned == "" and record.link == link then
1073 lokyst-32688
            record.choices[player] = choice
1074 lokyst-32688
            break
1075 lokyst-32688
        end
1076 lokyst-32688
    end
1077 lokyst-32688
    self:UpdateReport()
1078 2 lokyst-32688
end
1079 lokyst-32688
 
1080 12 lokyst-32688
function NeedyGreedy:RecordRoll(link, player, number)
1081 31 lokyst-32688
    local _, _, quality = GetItemInfo(link)
1082 lokyst-32688
    if quality < self.db.profile.quality then return end
1083 lokyst-32688
 
1084 69 lokyst-32688
    for _, record in ipairs(items) do
1085 6 lokyst-32688
        if record.assigned == "" and record.link == link then
1086 lokyst-32688
            record.rolls[player] = number
1087 lokyst-32688
            break
1088 lokyst-32688
        end
1089 lokyst-32688
    end
1090 lokyst-32688
    self:UpdateReport()
1091 2 lokyst-32688
end
1092 lokyst-32688
 
1093 12 lokyst-32688
function NeedyGreedy:RecordAwarded(link, player)
1094 31 lokyst-32688
    local _, _, quality = GetItemInfo(link)
1095 lokyst-32688
    if quality < self.db.profile.quality then return end
1096 lokyst-32688
 
1097 69 lokyst-32688
    for _, record in ipairs(items) do
1098 6 lokyst-32688
        if record.assigned == "" and record.link == link then
1099 lokyst-32688
            record.assigned = player
1100 lokyst-32688
            break
1101 lokyst-32688
        end
1102 lokyst-32688
    end
1103 lokyst-32688
    self:UpdateReport()
1104 2 lokyst-32688
end
1105 lokyst-32688
 
1106 15 lokyst-32688
function NeedyGreedy:RecordReceived(link, player)
1107 31 lokyst-32688
    local _, _, quality = GetItemInfo(link)
1108 39 lokyst-32688
    -- Because disenchanted items can be white >_<9
1109 lokyst-32688
    if quality < ITEM_QUALITY_COMMON then return end
1110 31 lokyst-32688
 
1111 lokyst-32688
    local match = false
1112 69 lokyst-32688
    for _, record in ipairs(items) do
1113 6 lokyst-32688
        if record.received == 0 and record.link == link then
1114 lokyst-32688
            record.received = GetTime()
1115 31 lokyst-32688
            match = true
1116 6 lokyst-32688
            break
1117 lokyst-32688
        end
1118 lokyst-32688
    end
1119 31 lokyst-32688
 
1120 lokyst-32688
    if not match then
1121 lokyst-32688
        -- For items with weird unique identifiers
1122 69 lokyst-32688
        for _, record in ipairs(items) do
1123 31 lokyst-32688
            if record.received == 0 and record.itemID == itemIdFromLink(link) then
1124 lokyst-32688
                record.received = GetTime()
1125 lokyst-32688
                match = true
1126 lokyst-32688
                break
1127 lokyst-32688
            end
1128 lokyst-32688
        end
1129 lokyst-32688
    end
1130 lokyst-32688
 
1131 39 lokyst-32688
    if not match then
1132 69 lokyst-32688
        for _, record in ipairs(items) do
1133 39 lokyst-32688
            -- Since players receive the results of the disenchant, we will never be
1134 lokyst-32688
            -- able to match the link that triggered the received message against
1135 lokyst-32688
            -- our list. However, we should cross disenchanted items that have been
1136 lokyst-32688
            -- assigned off the list as we find them on the assumption that they
1137 lokyst-32688
            -- would have automatically received the item anyway.
1138 lokyst-32688
            if record.choices[player] == "disenchant" and record.assigned == player and record.received == 0 then
1139 lokyst-32688
                record.received = GetTime()
1140 61 lokyst-32688
                -- It's ok to put in the break since each disenchanted
1141 lokyst-32688
                -- result will trigger a received message
1142 lokyst-32688
                break
1143 39 lokyst-32688
            end
1144 lokyst-32688
        end
1145 lokyst-32688
    end
1146 lokyst-32688
 
1147 61 lokyst-32688
    -- This could be done in one of the other loops, but since I live with
1148 lokyst-32688
    -- pedantic man, we will do this as a separate scan
1149 88 lokyst-32688
    if WATCH_ITEM_BEING_ROLLED_ON then
1150 61 lokyst-32688
        local itemsStillBeingRolledOn = 0
1151 69 lokyst-32688
        for _, record in ipairs(items) do
1152 61 lokyst-32688
            if record.received == 0 then
1153 lokyst-32688
                itemsStillBeingRolledOn = itemsStillBeingRolledOn + 1
1154 lokyst-32688
            end
1155 lokyst-32688
        end
1156 lokyst-32688
 
1157 lokyst-32688
        if itemsStillBeingRolledOn == 0 then
1158 103 lokyst-32688
            local autoHideDelay = self.db.profile.autoHideDelay
1159 lokyst-32688
 
1160 lokyst-32688
            if autoHideDelay == 0 then
1161 lokyst-32688
                self:RollPostProcessing()
1162 lokyst-32688
            else
1163 lokyst-32688
                ROLL_TIMER = self:ScheduleTimer("RollPostProcessing", autoHideDelay)
1164 lokyst-32688
            end
1165 141 lokyst-32688
 
1166 lokyst-32688
            if self.db.profile.playSoundOnAward then
1167 lokyst-32688
                local soundFile = self.db.profile.soundFile
1168 lokyst-32688
                if soundFile then
1169 lokyst-32688
                    PlaySoundFile(soundFile, "SFX")
1170 lokyst-32688
                end
1171 lokyst-32688
            end
1172 lokyst-32688
 
1173 61 lokyst-32688
        end
1174 lokyst-32688
    end
1175 lokyst-32688
 
1176 6 lokyst-32688
    self:UpdateReport()
1177 2 lokyst-32688
end
1178 lokyst-32688
 
1179 103 lokyst-32688
function NeedyGreedy:RollPostProcessing()
1180 lokyst-32688
    WATCH_ITEM_BEING_ROLLED_ON = false
1181 lokyst-32688
    ROLL_TIMER = nil
1182 lokyst-32688
    self:RefreshTooltip()
1183 lokyst-32688
end
1184 lokyst-32688
 
1185 28 lokyst-32688
function NeedyGreedy:ClearItems()
1186 38 lokyst-32688
    wipe(items)
1187 lokyst-32688
    wipe(nameList)
1188 44 lokyst-32688
    self:RefreshTooltip()
1189 66 lokyst-32688
    self:Print(L["All items have been cleared."])
1190 28 lokyst-32688
end
1191 2 lokyst-32688
 
1192 4 lokyst-32688
 
1193 28 lokyst-32688
 
1194 11 lokyst-32688
-- Tooltip Information Formatting
1195 12 lokyst-32688
function NeedyGreedy:PageLeft()
1196 14 lokyst-32688
    report.firstItem = report.firstItem - self.db.profile.nItems
1197 12 lokyst-32688
    if report.firstItem < 1 then
1198 lokyst-32688
        report.firstItem = 1
1199 6 lokyst-32688
    end
1200 lokyst-32688
    self:UpdateReport()
1201 2 lokyst-32688
end
1202 lokyst-32688
 
1203 12 lokyst-32688
function NeedyGreedy:PageRight()
1204 69 lokyst-32688
    local count = #items
1205 14 lokyst-32688
    report.firstItem = report.firstItem + self.db.profile.nItems
1206 6 lokyst-32688
    if count == 0 then
1207 12 lokyst-32688
        report.firstItem = 1
1208 lokyst-32688
    elseif report.firstItem > count then
1209 lokyst-32688
        report.firstItem = count
1210 6 lokyst-32688
    end
1211 lokyst-32688
    self:UpdateReport()
1212 2 lokyst-32688
end
1213 lokyst-32688
 
1214 12 lokyst-32688
function NeedyGreedy:GetSortedPlayers()
1215 6 lokyst-32688
    local list = {}
1216 2 lokyst-32688
 
1217 6 lokyst-32688
    if GetNumRaidMembers() > 0 then
1218 lokyst-32688
        for i = 1,MAX_RAID_MEMBERS do
1219 lokyst-32688
            name = GetRaidRosterInfo(i)
1220 lokyst-32688
            if name then
1221 38 lokyst-32688
                if not (nameList[name]) and (name ~= UNKNKOWN) then nameList[name] = name end
1222 6 lokyst-32688
            end
1223 lokyst-32688
        end
1224 lokyst-32688
    else
1225 lokyst-32688
        for _, unit in ipairs({"player", "party1", "party2", "party3", "party4"}) do
1226 lokyst-32688
            local name = UnitName(unit)
1227 lokyst-32688
            if name then
1228 38 lokyst-32688
                if not (nameList[name]) and (name ~= UNKNKOWN) then nameList[name] = name end
1229 6 lokyst-32688
            end
1230 lokyst-32688
        end
1231 lokyst-32688
    end
1232 37 lokyst-32688
 
1233 lokyst-32688
    if not self.db.profile.showGroupOnly then
1234 69 lokyst-32688
        for _, item in ipairs(items) do
1235 37 lokyst-32688
            for name, _ in pairs(item.choices) do
1236 lokyst-32688
                if not nameList[name] then nameList[name] = name end
1237 lokyst-32688
            end
1238 lokyst-32688
        end
1239 lokyst-32688
    end
1240 lokyst-32688
 
1241 lokyst-32688
    for name, _ in pairs(nameList) do
1242 lokyst-32688
        table.insert(list, name)
1243 lokyst-32688
    end
1244 lokyst-32688
 
1245 6 lokyst-32688
    table.sort(list)
1246 lokyst-32688
    return list
1247 2 lokyst-32688
end
1248 lokyst-32688
 
1249 12 lokyst-32688
function NeedyGreedy:GetNumPlayers()
1250 6 lokyst-32688
    local nraid = GetNumRaidMembers()
1251 lokyst-32688
    if nraid > 0 then
1252 lokyst-32688
        return nraid
1253 lokyst-32688
    else
1254 lokyst-32688
        return GetNumPartyMembers() + 1
1255 lokyst-32688
    end
1256 2 lokyst-32688
end
1257 lokyst-32688
 
1258 12 lokyst-32688
function NeedyGreedy:ColorizeName(name)
1259 6 lokyst-32688
    local _, class = UnitClass(name)
1260 lokyst-32688
    local color
1261 2 lokyst-32688
 
1262 6 lokyst-32688
    if class then
1263 65 lokyst-32688
        color = RAID_CLASS_COLORS[class]
1264 lokyst-32688
        color = string.format("\124cff%.2x%.2x%.2x", color.r*255, color.g*255, color.b*255)
1265 6 lokyst-32688
    end
1266 lokyst-32688
    if not color then
1267 lokyst-32688
        color = GRAY_FONT_COLOR_CODE
1268 lokyst-32688
    end
1269 lokyst-32688
    return color .. name .. "|r"
1270 2 lokyst-32688
end
1271 lokyst-32688
 
1272 12 lokyst-32688
function NeedyGreedy:ChoiceText(choice)
1273 6 lokyst-32688
    local style = "string"
1274 lokyst-32688
    if self.db.profile.displayIcons == true then style = "icon" end
1275 3 lokyst-32688
 
1276 6 lokyst-32688
    if choice then
1277 13 lokyst-32688
          if NEEDYGREEDY_CHOICE[choice][style] then
1278 lokyst-32688
              return NEEDYGREEDY_CHOICE[choice][style]
1279 6 lokyst-32688
          end
1280 lokyst-32688
    end
1281 lokyst-32688
    return ""
1282 2 lokyst-32688
end
1283 lokyst-32688
 
1284 112 lokyst-32688
function NeedyGreedy:RollText(number, winner, winnerIsSelf)
1285 lokyst-32688
    local hexColor = ""
1286 113 lokyst-32688
    local r, g, b, a = unpack({1, 1, 1, 1})
1287 112 lokyst-32688
 
1288 6 lokyst-32688
    if number then
1289 110 lokyst-32688
        number = " - " .. number
1290 113 lokyst-32688
        if self.db.profile.highlightWinner and winner then
1291 lokyst-32688
            r, g, b, a = unpack(self.db.profile.highlightWinnerColor)
1292 lokyst-32688
            hexColor = string.format("|cff%2X%2X%2X", 255*r, 255*g, 255*b)
1293 110 lokyst-32688
        end
1294 113 lokyst-32688
 
1295 118 lokyst-32688
        if self.db.profile.highlightSelf and winner and winnerIsSelf then
1296 113 lokyst-32688
            r, g, b, a = unpack(self.db.profile.highlightSelfColor)
1297 lokyst-32688
            hexColor = string.format("|cff%2X%2X%2X", 255*r, 255*g, 255*b)
1298 lokyst-32688
        end
1299 lokyst-32688
 
1300 lokyst-32688
        number = hexColor .. number .. "|r"
1301 lokyst-32688
 
1302 110 lokyst-32688
        return number
1303 6 lokyst-32688
    else
1304 lokyst-32688
        return ""
1305 lokyst-32688
    end
1306 2 lokyst-32688
end
1307 lokyst-32688
 
1308 12 lokyst-32688
function NeedyGreedy:AssignedText(item)
1309 6 lokyst-32688
    if item.received == 0 then
1310 lokyst-32688
        return "|c00FF0000" .. item.assigned .. "|r"
1311 lokyst-32688
    else
1312 lokyst-32688
        return "|c0000FF00" .. item.assigned .. "|r"
1313 lokyst-32688
    end
1314 2 lokyst-32688
end
1315 lokyst-32688
 
1316 12 lokyst-32688
function NeedyGreedy:ExpireItems()
1317 6 lokyst-32688
    local now = GetTime()
1318 lokyst-32688
    local update = false
1319 88 lokyst-32688
    local displayTimeOut = true
1320 lokyst-32688
    local padding = 60
1321 2 lokyst-32688
 
1322 69 lokyst-32688
    for rollid, record in ipairs(items) do
1323 103 lokyst-32688
        -- Are there any unresolved rolls past expiry time
1324 88 lokyst-32688
        if record.rollTimeOut and record.rollTimeOut > 0 and now < record.rollTimeOut + padding and WATCH_ITEM_BEING_ROLLED_ON then
1325 lokyst-32688
            displayTimeOut = false
1326 6 lokyst-32688
        end
1327 88 lokyst-32688
 
1328 103 lokyst-32688
        -- Are there items that need to be expired
1329 88 lokyst-32688
        if self.db.profile.expiry ~= 0 then
1330 lokyst-32688
            if record.received > 0 and now - record.received >= self.db.profile.expiry * 60 then
1331 lokyst-32688
                table.remove(items, rollid)
1332 lokyst-32688
                wipe(nameList)
1333 lokyst-32688
                update = true
1334 lokyst-32688
            end
1335 lokyst-32688
        end
1336 6 lokyst-32688
    end
1337 88 lokyst-32688
 
1338 lokyst-32688
    if displayTimeOut and WATCH_ITEM_BEING_ROLLED_ON then
1339 103 lokyst-32688
        self:RollPostProcessing()
1340 88 lokyst-32688
    end
1341 lokyst-32688
 
1342 6 lokyst-32688
    if update then
1343 lokyst-32688
        self:UpdateReport()
1344 lokyst-32688
    end
1345 2 lokyst-32688
end
1346 lokyst-32688
 
1347 26 lokyst-32688
local CONVERTED_FORMATS = {}
1348 12 lokyst-32688
function NeedyGreedy:unformat(fmt, msg)
1349 26 lokyst-32688
    local pattern, captureIndices
1350 lokyst-32688
    if CONVERTED_FORMATS[fmt] then
1351 lokyst-32688
        pattern, captureIndices = unpack(CONVERTED_FORMATS[fmt])
1352 lokyst-32688
    else
1353 lokyst-32688
        pattern, captureIndices = patternFromFormat(fmt)
1354 lokyst-32688
        CONVERTED_FORMATS[fmt] = {pattern, captureIndices}
1355 lokyst-32688
    end
1356 lokyst-32688
 
1357 lokyst-32688
    local _, _, a1, a2, a3, a4 = superFind(msg, pattern, captureIndices)
1358 6 lokyst-32688
    return a1, a2, a3, a4
1359 2 lokyst-32688
end
1360 lokyst-32688
 
1361 lokyst-32688
 
1362 11 lokyst-32688
 
1363 lokyst-32688
-- Config option getters and setters
1364 12 lokyst-32688
function NeedyGreedy:GetNItems(info)
1365 14 lokyst-32688
    return self.db.profile.nItems
1366 2 lokyst-32688
end
1367 lokyst-32688
 
1368 14 lokyst-32688
function NeedyGreedy:SetNItems(info, nItems)
1369 lokyst-32688
    self.db.profile.nItems = nItems
1370 11 lokyst-32688
    self:RefreshTooltip()
1371 2 lokyst-32688
end
1372 lokyst-32688
 
1373 12 lokyst-32688
function NeedyGreedy:GetExpiry(info)
1374 6 lokyst-32688
    return self.db.profile.expiry
1375 2 lokyst-32688
end
1376 lokyst-32688
 
1377 12 lokyst-32688
function NeedyGreedy:SetExpiry(info, expiry)
1378 6 lokyst-32688
    self.db.profile.expiry = expiry
1379 lokyst-32688
    self:ExpireItems()
1380 2 lokyst-32688
end
1381 lokyst-32688
 
1382 12 lokyst-32688
function NeedyGreedy:GetQuality(info)
1383 6 lokyst-32688
    return self.db.profile.quality
1384 2 lokyst-32688
end
1385 lokyst-32688
 
1386 12 lokyst-32688
function NeedyGreedy:SetQuality(info, quality)
1387 6 lokyst-32688
    self.db.profile.quality = quality
1388 2 lokyst-32688
end
1389 3 lokyst-32688
 
1390 12 lokyst-32688
function NeedyGreedy:GetDisplayIcons(info)
1391 6 lokyst-32688
    return self.db.profile.displayIcons
1392 3 lokyst-32688
end
1393 lokyst-32688
 
1394 12 lokyst-32688
function NeedyGreedy:SetDisplayIcons(info, displayIcons)
1395 6 lokyst-32688
    self.db.profile.displayIcons = displayIcons
1396 lokyst-32688
    self:UpdateReport()
1397 3 lokyst-32688
end
1398 4 lokyst-32688
 
1399 14 lokyst-32688
function NeedyGreedy:GetDetachedTooltip(info)
1400 lokyst-32688
    return self.db.profile.detachedTooltip
1401 lokyst-32688
end
1402 4 lokyst-32688
 
1403 14 lokyst-32688
function NeedyGreedy:SetDetachedTooltip(info, detachedTooltip)
1404 lokyst-32688
    self.db.profile.detachedTooltip = detachedTooltip
1405 74 lokyst-32688
    self:HideDBTooltip()
1406 61 lokyst-32688
    if self.db.profile.detachedTooltip then
1407 94 lokyst-32688
        self.db.profile.displayStatus = true
1408 61 lokyst-32688
        if self:CheckDisplayOptions() then
1409 lokyst-32688
            self:ShowDetachedTooltip()
1410 lokyst-32688
        end
1411 14 lokyst-32688
    else
1412 94 lokyst-32688
        self.db.profile.displayStatus = false
1413 21 lokyst-32688
        self:HideDetachedTooltip()
1414 14 lokyst-32688
        -- Return to page one
1415 lokyst-32688
        report.firstItem = 1
1416 lokyst-32688
    end
1417 lokyst-32688
end
1418 lokyst-32688
 
1419 16 lokyst-32688
function NeedyGreedy:GetDisplayTextLink(info)
1420 lokyst-32688
    return self.db.profile.displayTextLink
1421 lokyst-32688
end
1422 14 lokyst-32688
 
1423 16 lokyst-32688
function NeedyGreedy:SetDisplayTextLink(info, displayTextLink)
1424 lokyst-32688
    self.db.profile.displayTextLink = displayTextLink
1425 lokyst-32688
    self:UpdateReport()
1426 lokyst-32688
end
1427 14 lokyst-32688
 
1428 20 lokyst-32688
function NeedyGreedy:GetHideMinimapIcon(info)
1429 lokyst-32688
    return not self.db.profile.minimap.hide
1430 lokyst-32688
end
1431 16 lokyst-32688
 
1432 20 lokyst-32688
function NeedyGreedy:SetHideMinimapIcon(info, hideMinimapIcon)
1433 lokyst-32688
    self.db.profile.minimap.hide = not hideMinimapIcon
1434 lokyst-32688
    if self.db.profile.minimap.hide then
1435 lokyst-32688
        ngDBIcon:Hide("NeedyGreedy")
1436 lokyst-32688
    else
1437 lokyst-32688
        ngDBIcon:Show("NeedyGreedy")
1438 lokyst-32688
    end
1439 lokyst-32688
end
1440 16 lokyst-32688
 
1441 22 lokyst-32688
function NeedyGreedy:GetFilterLootMsgs(info)
1442 lokyst-32688
    return self.db.profile.filterLootMsgs
1443 lokyst-32688
end
1444 20 lokyst-32688
 
1445 22 lokyst-32688
function NeedyGreedy:SetFilterLootMsgs(info, filterLootMsgs)
1446 lokyst-32688
    self.db.profile.filterLootMsgs = filterLootMsgs
1447 lokyst-32688
    if self.db.profile.filterLootMsgs then
1448 lokyst-32688
        self:EnableChatFilter()
1449 lokyst-32688
    else
1450 lokyst-32688
        self:DisableChatFilter()
1451 lokyst-32688
    end
1452 lokyst-32688
end
1453 20 lokyst-32688
 
1454 90 lokyst-32688
function NeedyGreedy:GetShowOnParty(info)
1455 lokyst-32688
    return self.db.profile.showOnParty
1456 34 lokyst-32688
end
1457 22 lokyst-32688
 
1458 90 lokyst-32688
function NeedyGreedy:SetShowOnParty(info, showOnParty)
1459 lokyst-32688
    self.db.profile.showOnParty = showOnParty
1460 34 lokyst-32688
end
1461 22 lokyst-32688
 
1462 35 lokyst-32688
function NeedyGreedy:GetHideInCombat(info)
1463 lokyst-32688
    return self.db.profile.hideInCombat
1464 lokyst-32688
end
1465 34 lokyst-32688
 
1466 35 lokyst-32688
function NeedyGreedy:SetHideInCombat(info, hideInCombat)
1467 lokyst-32688
    self.db.profile.hideInCombat = hideInCombat
1468 lokyst-32688
    self:RefreshTooltip()
1469 lokyst-32688
end
1470 34 lokyst-32688
 
1471 37 lokyst-32688
function NeedyGreedy:GetShowGroupOnly(info)
1472 lokyst-32688
    return self.db.profile.showGroupOnly
1473 lokyst-32688
end
1474 35 lokyst-32688
 
1475 37 lokyst-32688
function NeedyGreedy:SetShowGroupOnly(info, showGroupOnly)
1476 lokyst-32688
    self.db.profile.showGroupOnly = showGroupOnly
1477 44 lokyst-32688
    wipe(nameList)
1478 37 lokyst-32688
    self:RefreshTooltip()
1479 lokyst-32688
end
1480 35 lokyst-32688
 
1481 61 lokyst-32688
function NeedyGreedy:GetAutoPopUp(info)
1482 lokyst-32688
    return self.db.profile.autoPopUp
1483 lokyst-32688
end
1484 37 lokyst-32688
 
1485 61 lokyst-32688
function NeedyGreedy:SetAutoPopUp(info, autoPopUp)
1486 lokyst-32688
    self.db.profile.autoPopUp = autoPopUp
1487 lokyst-32688
    self:RefreshTooltip()
1488 lokyst-32688
end
1489 37 lokyst-32688
 
1490 66 lokyst-32688
function NeedyGreedy:GetResetInNewParty(info)
1491 lokyst-32688
    return self.db.profile.resetInNewParty
1492 lokyst-32688
end
1493 61 lokyst-32688
 
1494 66 lokyst-32688
function NeedyGreedy:SetResetInNewParty(info, resetInNewParty)
1495 lokyst-32688
    self.db.profile.resetInNewParty = resetInNewParty
1496 lokyst-32688
end
1497 61 lokyst-32688
 
1498 79 lokyst-32688
function NeedyGreedy:GetResetInNewInstance(info)
1499 lokyst-32688
    return self.db.profile.resetInNewInstance
1500 lokyst-32688
end
1501 66 lokyst-32688
 
1502 79 lokyst-32688
function NeedyGreedy:SetResetInNewInstance(info, resetInNewInstance)
1503 lokyst-32688
    self.db.profile.resetInNewInstance = resetInNewInstance
1504 lokyst-32688
end
1505 66 lokyst-32688
 
1506 91 lokyst-32688
function NeedyGreedy:GetTooltipScale(info)
1507 lokyst-32688
    return self.db.profile.tooltipScale
1508 lokyst-32688
end
1509 79 lokyst-32688
 
1510 91 lokyst-32688
function NeedyGreedy:SetTooltipScale(info, tooltipScale)
1511 lokyst-32688
    self.db.profile.tooltipScale = tooltipScale
1512 lokyst-32688
    self:RefreshTooltip()
1513 lokyst-32688
end
1514 79 lokyst-32688
 
1515 93 lokyst-32688
function NeedyGreedy:GetLockTooltip(info)
1516 lokyst-32688
    return self.db.profile.lockTooltip
1517 lokyst-32688
end
1518 91 lokyst-32688
 
1519 93 lokyst-32688
function NeedyGreedy:SetLockTooltip(info, lockTooltip)
1520 lokyst-32688
    self.db.profile.lockTooltip = lockTooltip
1521 lokyst-32688
    self:RefreshTooltip()
1522 lokyst-32688
end
1523 91 lokyst-32688
 
1524 96 lokyst-32688
function NeedyGreedy:GetSuppressInRaid(info)
1525 lokyst-32688
    return self.db.profile.suppressInRaid
1526 lokyst-32688
end
1527 93 lokyst-32688
 
1528 96 lokyst-32688
function NeedyGreedy:SetSuppressInRaid(info, suppressInRaid)
1529 lokyst-32688
    self.db.profile.suppressInRaid = suppressInRaid
1530 lokyst-32688
    self:RefreshTooltip()
1531 lokyst-32688
end
1532 112 lokyst-32688
 
1533 103 lokyst-32688
function NeedyGreedy:GetAutoHideDelay(info)
1534 lokyst-32688
    return self.db.profile.autoHideDelay
1535 lokyst-32688
end
1536 93 lokyst-32688
 
1537 103 lokyst-32688
function NeedyGreedy:SetAutoHideDelay(info, autoHideDelay)
1538 lokyst-32688
    self.db.profile.autoHideDelay = autoHideDelay
1539 lokyst-32688
    self:RefreshTooltip()
1540 lokyst-32688
end
1541 96 lokyst-32688
 
1542 123 lokyst-32688
function NeedyGreedy:GetShowLootMethod(info)
1543 lokyst-32688
    return self.db.profile.showLootMethod
1544 lokyst-32688
end
1545 lokyst-32688
 
1546 lokyst-32688
function NeedyGreedy:SetShowLootMethod(info, showLootMethod)
1547 lokyst-32688
    self.db.profile.showLootMethod = showLootMethod
1548 lokyst-32688
    self:UpdatePartyLootMethodText()
1549 lokyst-32688
end
1550 lokyst-32688
 
1551 111 lokyst-32688
function NeedyGreedy:GetNoSpamMode(info)
1552 lokyst-32688
    return self.db.profile.noSpamMode
1553 lokyst-32688
end
1554 96 lokyst-32688
 
1555 121 lokyst-32688
-- Chat config
1556 111 lokyst-32688
function NeedyGreedy:SetNoSpamMode(info, noSpamMode)
1557 lokyst-32688
    self.db.profile.noSpamMode = noSpamMode
1558 lokyst-32688
    if noSpamMode then
1559 lokyst-32688
        self:EnableNoSpamMode()
1560 lokyst-32688
    else
1561 lokyst-32688
        self:DisableNoSpamMode()
1562 lokyst-32688
    end
1563 lokyst-32688
end
1564 103 lokyst-32688
 
1565 121 lokyst-32688
function NeedyGreedy:GetHighlightSelfChat(info)
1566 lokyst-32688
    return self.db.profile.highlightSelfChat
1567 lokyst-32688
end
1568 lokyst-32688
 
1569 lokyst-32688
function NeedyGreedy:SetHighlightSelfChat(info, highlightSelfChat)
1570 lokyst-32688
    self.db.profile.highlightSelfChat = highlightSelfChat
1571 lokyst-32688
    self:RefreshTooltip()
1572 lokyst-32688
end
1573 lokyst-32688
 
1574 lokyst-32688
function NeedyGreedy:GetHighlightSelfChatColor(info)
1575 lokyst-32688
    return unpack(self.db.profile.highlightSelfChatColor)
1576 lokyst-32688
end
1577 lokyst-32688
 
1578 lokyst-32688
function NeedyGreedy:SetHighlightSelfChatColor(info, r, g, b, a)
1579 lokyst-32688
    self.db.profile.highlightSelfChatColor = {r, g, b, a}
1580 lokyst-32688
    self:RefreshTooltip()
1581 lokyst-32688
end
1582 lokyst-32688
 
1583 lokyst-32688
function NeedyGreedy:GetHighlightWinnerChat(info)
1584 lokyst-32688
    return self.db.profile.highlightWinnerChat
1585 lokyst-32688
end
1586 lokyst-32688
 
1587 lokyst-32688
function NeedyGreedy:SetHighlightWinnerChat(info, highlightWinnerChat)
1588 lokyst-32688
    self.db.profile.highlightWinnerChat = highlightWinnerChat
1589 lokyst-32688
    self:RefreshTooltip()
1590 lokyst-32688
end
1591 lokyst-32688
 
1592 lokyst-32688
function NeedyGreedy:GetHighlightWinnerChatColor(info)
1593 lokyst-32688
    return unpack(self.db.profile.highlightWinnerChatColor)
1594 lokyst-32688
end
1595 lokyst-32688
 
1596 lokyst-32688
function NeedyGreedy:SetHighlightWinnerChatColor(info, r, g, b, a)
1597 lokyst-32688
    self.db.profile.highlightWinnerChatColor = {r, g, b, a}
1598 lokyst-32688
    self:RefreshTooltip()
1599 lokyst-32688
end
1600 lokyst-32688
 
1601 lokyst-32688
-- UI config
1602 112 lokyst-32688
function NeedyGreedy:GetHighlightSelf(info)
1603 lokyst-32688
    return self.db.profile.highlightSelf
1604 lokyst-32688
end
1605 lokyst-32688
 
1606 lokyst-32688
function NeedyGreedy:SetHighlightSelf(info, highlightSelf)
1607 lokyst-32688
    self.db.profile.highlightSelf = highlightSelf
1608 lokyst-32688
    self:RefreshTooltip()
1609 lokyst-32688
end
1610 lokyst-32688
 
1611 lokyst-32688
function NeedyGreedy:GetHighlightSelfColor(info)
1612 lokyst-32688
    return unpack(self.db.profile.highlightSelfColor)
1613 lokyst-32688
end
1614 lokyst-32688
 
1615 lokyst-32688
function NeedyGreedy:SetHighlightSelfColor(info, r, g, b, a)
1616 lokyst-32688
    self.db.profile.highlightSelfColor = {r, g, b, a}
1617 lokyst-32688
    self:RefreshTooltip()
1618 lokyst-32688
end
1619 lokyst-32688
 
1620 113 lokyst-32688
function NeedyGreedy:GetHighlightWinner(info)
1621 lokyst-32688
    return self.db.profile.highlightWinner
1622 lokyst-32688
end
1623 112 lokyst-32688
 
1624 113 lokyst-32688
function NeedyGreedy:SetHighlightWinner(info, highlightWinner)
1625 lokyst-32688
    self.db.profile.highlightWinner = highlightWinner
1626 lokyst-32688
    self:RefreshTooltip()
1627 lokyst-32688
end
1628 112 lokyst-32688
 
1629 113 lokyst-32688
function NeedyGreedy:GetHighlightWinnerColor(info)
1630 lokyst-32688
    return unpack(self.db.profile.highlightWinnerColor)
1631 lokyst-32688
end
1632 lokyst-32688
 
1633 lokyst-32688
function NeedyGreedy:SetHighlightWinnerColor(info, r, g, b, a)
1634 lokyst-32688
    self.db.profile.highlightWinnerColor = {r, g, b, a}
1635 lokyst-32688
    self:RefreshTooltip()
1636 lokyst-32688
end
1637 lokyst-32688
 
1638 131 lokyst-32688
function NeedyGreedy:GetUseTooltipDefault(info)
1639 lokyst-32688
    return self.db.profile.useTooltipDefaults
1640 lokyst-32688
end
1641 113 lokyst-32688
 
1642 131 lokyst-32688
function NeedyGreedy:SetUseTooltipDefault(info, useTooltipDefaults)
1643 lokyst-32688
    self.db.profile.useTooltipDefaults = useTooltipDefaults
1644 lokyst-32688
    self:RefreshTooltip()
1645 lokyst-32688
end
1646 113 lokyst-32688
 
1647 131 lokyst-32688
function NeedyGreedy:GetBackgroundColor(info)
1648 lokyst-32688
    return unpack(self.db.profile.bgColor)
1649 lokyst-32688
end
1650 lokyst-32688
 
1651 lokyst-32688
function NeedyGreedy:SetBackgroundColor(info, r, g, b, a)
1652 lokyst-32688
    self.db.profile.bgColor = {r, g, b, a}
1653 lokyst-32688
    self:RefreshTooltip()
1654 lokyst-32688
end
1655 lokyst-32688
 
1656 lokyst-32688
function NeedyGreedy:GetBorderColor(info)
1657 lokyst-32688
    return unpack(self.db.profile.borderColor)
1658 lokyst-32688
end
1659 lokyst-32688
 
1660 lokyst-32688
function NeedyGreedy:SetBorderColor(info, r, g, b, a)
1661 lokyst-32688
    self.db.profile.borderColor = {r, g, b, a}
1662 lokyst-32688
    self:RefreshTooltip()
1663 lokyst-32688
end
1664 lokyst-32688
 
1665 141 lokyst-32688
function NeedyGreedy:GetPlaySoundOnAward(info)
1666 lokyst-32688
    return self.db.profile.playSoundOnAward
1667 lokyst-32688
end
1668 131 lokyst-32688
 
1669 141 lokyst-32688
function NeedyGreedy:SetPlaySoundOnAward(info, value)
1670 lokyst-32688
    self.db.profile.playSoundOnAward = value
1671 lokyst-32688
end
1672 lokyst-32688
 
1673 lokyst-32688
function NeedyGreedy:GetSoundFile(info)
1674 lokyst-32688
    return self.db.profile.soundName
1675 lokyst-32688
end
1676 lokyst-32688
 
1677 lokyst-32688
function NeedyGreedy:SetSoundFile(info, value)
1678 lokyst-32688
    self.db.profile.soundName = value
1679 lokyst-32688
    self.db.profile.soundFile = LSM:Fetch("sound", value)
1680 lokyst-32688
end
1681 lokyst-32688
 
1682 lokyst-32688
 
1683 64 lokyst-32688
-- QTip Frames
1684 4 lokyst-32688
local LibQTip = LibStub('LibQTip-1.0')
1685 65 lokyst-32688
local COL_MIN_WIDTH = 60
1686 4 lokyst-32688
 
1687 64 lokyst-32688
-- Special cell provider for displaying item icons
1688 lokyst-32688
local ItemCell, ItemCell_Prototype = LibQTip:CreateCellProvider()
1689 lokyst-32688
function ItemCell_Prototype:InitializeCell()
1690 65 lokyst-32688
    local ItemCellHeight = 30
1691 lokyst-32688
    local IconHeight = 25
1692 64 lokyst-32688
 
1693 65 lokyst-32688
    self:SetHeight(ItemCellHeight)
1694 lokyst-32688
    self:SetWidth(COL_MIN_WIDTH)
1695 64 lokyst-32688
 
1696 65 lokyst-32688
    if not self.ItemDetailsBorder then
1697 lokyst-32688
        self.ItemDetailsBorder = self:CreateTexture(nil, 'ARTWORK')
1698 lokyst-32688
    end
1699 64 lokyst-32688
 
1700 65 lokyst-32688
    self.ItemDetailsBorder:SetTexture(nil)
1701 lokyst-32688
    self.ItemDetailsBorder:SetAlpha(1)
1702 lokyst-32688
    self.ItemDetailsBorder:SetHeight(ItemCellHeight)
1703 lokyst-32688
    self.ItemDetailsBorder:SetWidth(ItemCellHeight)
1704 lokyst-32688
    self.ItemDetailsBorder:SetPoint("CENTER", self, "CENTER")
1705 64 lokyst-32688
 
1706 65 lokyst-32688
    if not self.ItemDetails then
1707 lokyst-32688
        self.ItemDetails = self:CreateTexture(nil,"OVERLAY")
1708 lokyst-32688
    end
1709 64 lokyst-32688
 
1710 65 lokyst-32688
    self.ItemDetails:SetTexture(nil)
1711 lokyst-32688
    self.ItemDetails:SetHeight(IconHeight)
1712 lokyst-32688
    self.ItemDetails:SetWidth(IconHeight)
1713 lokyst-32688
    self.ItemDetails:SetPoint("CENTER", self.ItemDetailsBorder, "CENTER")
1714 lokyst-32688
 
1715 64 lokyst-32688
end
1716 lokyst-32688
 
1717 lokyst-32688
function ItemCell_Prototype:SetupCell(tooltip, value, justification, font, args)
1718 lokyst-32688
    local icon, quality = unpack(value)
1719 65 lokyst-32688
    self.ItemDetails:SetTexture(icon)
1720 64 lokyst-32688
 
1721 lokyst-32688
    if quality then
1722 lokyst-32688
        local color = {r, g, b, hex}
1723 lokyst-32688
        color.r, color.g, color.b, color.hex = GetItemQualityColor(quality)
1724 65 lokyst-32688
        self.ItemDetailsBorder:SetTexture(color.r, color.g, color.b)
1725 64 lokyst-32688
    else
1726 65 lokyst-32688
        self.ItemDetailsBorder:SetTexture(nil)
1727 64 lokyst-32688
    end
1728 lokyst-32688
 
1729 65 lokyst-32688
    self.ItemDetailsBorder:Show()
1730 64 lokyst-32688
 
1731 65 lokyst-32688
    return self:GetWidth(), self:GetHeight()
1732 64 lokyst-32688
end
1733 lokyst-32688
 
1734 124 lokyst-32688
function ItemCell_Prototype:getContentHeight()
1735 lokyst-32688
    return 30
1736 lokyst-32688
end
1737 lokyst-32688
 
1738 82 lokyst-32688
-- Create functions locally to reduce garbage collection
1739 lokyst-32688
local function Detached_OnMouseDown()
1740 lokyst-32688
    NeedyGreedy.detachedTooltip:StartMoving()
1741 lokyst-32688
end
1742 lokyst-32688
 
1743 lokyst-32688
local function Detached_OnMouseUp()
1744 lokyst-32688
    -- Make it remember
1745 lokyst-32688
    local tooltip = NeedyGreedy.detachedTooltip
1746 lokyst-32688
    local pos = NeedyGreedy.db.profile.reportFramePos
1747 lokyst-32688
 
1748 lokyst-32688
    tooltip:StopMovingOrSizing()
1749 lokyst-32688
 
1750 lokyst-32688
    local anchor1, _, anchor2, x, y = tooltip:GetPoint()
1751 lokyst-32688
 
1752 lokyst-32688
    pos.anchor1 = anchor1
1753 lokyst-32688
    pos.anchor2 = anchor2
1754 lokyst-32688
    pos.x = x
1755 lokyst-32688
    pos.y = y
1756 lokyst-32688
end
1757 lokyst-32688
 
1758 64 lokyst-32688
-- Detachable tooltip
1759 21 lokyst-32688
function NeedyGreedy:ShowDetachedTooltip()
1760 34 lokyst-32688
 
1761 6 lokyst-32688
    -- Acquire a tooltip
1762 55 lokyst-32688
    if not LibQTip:IsAcquired("NeedyGreedyReport") then
1763 lokyst-32688
        self.detachedTooltip = LibQTip:Acquire("NeedyGreedyReport", 1, "LEFT")
1764 91 lokyst-32688
        self.detachedTooltip:SetScale(self.db.profile.tooltipScale)
1765 14 lokyst-32688
 
1766 131 lokyst-32688
        local r, g, b, a
1767 lokyst-32688
        if self.db.profile.useTooltipDefaults then
1768 lokyst-32688
            r, g, b, a  = unpack(GameTooltip:GetBackdrop())
1769 lokyst-32688
            self.detachedTooltip:SetBackdropColor(r, g, b, a)
1770 lokyst-32688
            r, g, b, a = GameTooltip:GetBackdropBorderColor()
1771 lokyst-32688
            self.detachedTooltip:SetBackdropBorderColor(r, g, b, a)
1772 lokyst-32688
        else
1773 lokyst-32688
            r, g, b, a = unpack(self.db.profile.bgColor)
1774 lokyst-32688
            self.detachedTooltip:SetBackdropColor(r, g, b, a)
1775 lokyst-32688
            r, g, b, a = unpack(self.db.profile.borderColor)
1776 lokyst-32688
            self.detachedTooltip:SetBackdropBorderColor(r, g, b, a)
1777 lokyst-32688
        end
1778 lokyst-32688
 
1779 55 lokyst-32688
        -- Add columns here because tooltip:Clear() preserves columns
1780 lokyst-32688
        for i = 1, self.db.profile.nItems do
1781 lokyst-32688
            self.detachedTooltip:AddColumn("LEFT")
1782 lokyst-32688
        end
1783 4 lokyst-32688
 
1784 55 lokyst-32688
        -- Add two columns for left and right buttons if detached
1785 lokyst-32688
        if self.db.profile.detachedTooltip then
1786 lokyst-32688
            self.detachedTooltip:AddColumn("LEFT")
1787 lokyst-32688
        end
1788 14 lokyst-32688
 
1789 55 lokyst-32688
        -- Fill in the info
1790 lokyst-32688
        self:BuildDetachedTooltip(self.detachedTooltip)
1791 4 lokyst-32688
 
1792 55 lokyst-32688
        if self.db.profile.detachedTooltip then
1793 lokyst-32688
            -- To make tooltip detached
1794 lokyst-32688
            self.detachedTooltip:ClearAllPoints()
1795 lokyst-32688
            self.detachedTooltip:SetFrameStrata("FULLSCREEN")
1796 lokyst-32688
            self.detachedTooltip:EnableMouse(true)
1797 lokyst-32688
            self.detachedTooltip:SetResizable(true)
1798 lokyst-32688
            self.detachedTooltip:SetFrameLevel(1)
1799 lokyst-32688
            self.detachedTooltip:SetMovable(true)
1800 lokyst-32688
            self.detachedTooltip:SetClampedToScreen(true)
1801 4 lokyst-32688
 
1802 55 lokyst-32688
            if not self.db.profile.reportFramePos then
1803 lokyst-32688
                self.db.profile.reportFramePos = {
1804 lokyst-32688
                    anchor1 = "CENTER",
1805 lokyst-32688
                    anchor2 = "CENTER",
1806 lokyst-32688
                    x = 0,
1807 lokyst-32688
                    y = 0
1808 lokyst-32688
                }
1809 lokyst-32688
            end
1810 lokyst-32688
            self.detachedTooltip:SetPoint(self.db.profile.reportFramePos.anchor1, nil, self.db.profile.reportFramePos.anchor2,
1811 lokyst-32688
                self.db.profile.reportFramePos.x, self.db.profile.reportFramePos.y)
1812 lokyst-32688
 
1813 lokyst-32688
            -- Make it move !
1814 93 lokyst-32688
            if not self.db.profile.lockTooltip then
1815 lokyst-32688
                self.detachedTooltip:SetScript("OnMouseDown", Detached_OnMouseDown)
1816 lokyst-32688
                self.detachedTooltip:SetScript("OnMouseUp", Detached_OnMouseUp)
1817 lokyst-32688
            end
1818 14 lokyst-32688
        end
1819 21 lokyst-32688
    end
1820 14 lokyst-32688
 
1821 21 lokyst-32688
    -- Show it, et voilà !
1822 lokyst-32688
    self.detachedTooltip:Show()
1823 lokyst-32688
end
1824 lokyst-32688
 
1825 lokyst-32688
function NeedyGreedy:HideDetachedTooltip()
1826 lokyst-32688
    if self.detachedTooltip then
1827 lokyst-32688
        self.detachedTooltip:Hide()
1828 82 lokyst-32688
        self.detachedTooltip:SetScript("OnMouseDown", nil)
1829 lokyst-32688
        self.detachedTooltip:SetScript("OnMouseUp", nil)
1830 91 lokyst-32688
        self.detachedTooltip:SetScale(1)
1831 21 lokyst-32688
        LibQTip:Release(self.detachedTooltip)
1832 lokyst-32688
        self.detachedTooltip = nil
1833 lokyst-32688
    end
1834 lokyst-32688
end
1835 lokyst-32688
 
1836 lokyst-32688
function NeedyGreedy:ShowDBTooltip(frame)
1837 lokyst-32688
    -- Acquire a tooltip
1838 55 lokyst-32688
    if not LibQTip:IsAcquired("NeedyGreedyDBReport") then
1839 lokyst-32688
        self.dbTooltip = LibQTip:Acquire("NeedyGreedyDBReport", 1, "LEFT")
1840 21 lokyst-32688
 
1841 55 lokyst-32688
        if not self.db.profile.detachedTooltip then
1842 71 lokyst-32688
            self.dbTooltip:SetAutoHideDelay(0.25, frame)
1843 58 lokyst-32688
            -- Add columns here because tooltip:Clear() preserves columns
1844 lokyst-32688
            for i = 1, self.db.profile.nItems do
1845 lokyst-32688
                self.dbTooltip:AddColumn("LEFT")
1846 lokyst-32688
            end
1847 55 lokyst-32688
 
1848 71 lokyst-32688
            -- Extra column for the pager arrow
1849 lokyst-32688
            self.dbTooltip:AddColumn("LEFT")
1850 lokyst-32688
 
1851 58 lokyst-32688
            -- Fill in the info
1852 lokyst-32688
            self:BuildDBReportTooltip(self.dbTooltip)
1853 55 lokyst-32688
        else
1854 34 lokyst-32688
 
1855 55 lokyst-32688
            self:AddHeaderText(self.dbTooltip)
1856 lokyst-32688
            self:AddInfoText(self.dbTooltip)
1857 21 lokyst-32688
        end
1858 50 lokyst-32688
 
1859 55 lokyst-32688
        if frame then self.dbTooltip:SmartAnchorTo(frame) end
1860 102 lokyst-32688
 
1861 lokyst-32688
        self.dbTooltip:SetScript("OnHide", function()
1862 lokyst-32688
            if self.dbTooltip then
1863 lokyst-32688
                LibQTip:Release(self.dbTooltip)
1864 lokyst-32688
                self.dbTooltip = nil
1865 lokyst-32688
            end
1866 lokyst-32688
        end)
1867 6 lokyst-32688
    end
1868 4 lokyst-32688
 
1869 6 lokyst-32688
    -- Show it, et voilà !
1870 21 lokyst-32688
    self.dbTooltip:Show()
1871 4 lokyst-32688
end
1872 lokyst-32688
 
1873 21 lokyst-32688
function NeedyGreedy:HideDBTooltip()
1874 lokyst-32688
    if self.dbTooltip then
1875 lokyst-32688
        self.dbTooltip:Hide()
1876 lokyst-32688
        LibQTip:Release(self.dbTooltip)
1877 lokyst-32688
        self.dbTooltip = nil
1878 14 lokyst-32688
    end
1879 5 lokyst-32688
end
1880 lokyst-32688
 
1881 21 lokyst-32688
function NeedyGreedy:PopulateReportTooltip(tooltip)
1882 14 lokyst-32688
    local nItems = self.db.profile.nItems
1883 7 lokyst-32688
    local players = self:GetSortedPlayers()
1884 5 lokyst-32688
 
1885 72 lokyst-32688
    -- For sizing the columns
1886 lokyst-32688
    local fontString = tooltip:CreateFontString()
1887 lokyst-32688
    fontString:SetFontObject(tooltip:GetFont())
1888 lokyst-32688
    local minWidth = 0
1889 lokyst-32688
    for _, name in ipairs(players) do
1890 lokyst-32688
        fontString:SetText(name)
1891 lokyst-32688
        local fontWidth = fontString:GetStringWidth()
1892 lokyst-32688
        minWidth = max(fontWidth, minWidth)
1893 lokyst-32688
    end
1894 lokyst-32688
 
1895 12 lokyst-32688
    -- Verify that report.firstItem is set reasonably
1896 69 lokyst-32688
    local count = #items
1897 11 lokyst-32688
 
1898 12 lokyst-32688
    if not(report.firstItem) then report.firstItem = 1 end
1899 7 lokyst-32688
    if count == 0 then
1900 12 lokyst-32688
        report.firstItem = 1
1901 lokyst-32688
    elseif report.firstItem > count then
1902 lokyst-32688
        report.firstItem = count
1903 6 lokyst-32688
    end
1904 5 lokyst-32688
 
1905 14 lokyst-32688
    -- Create icon headers
1906 21 lokyst-32688
    local headerline, _ = tooltip:AddLine("")
1907 7 lokyst-32688
    for i = 1, nItems do
1908 69 lokyst-32688
        local index = #items - (report.firstItem + i - 2)
1909 7 lokyst-32688
        local texture = ""
1910 lokyst-32688
        local item = nil
1911 69 lokyst-32688
        if index >= 1 then
1912 lokyst-32688
            item = items[index]
1913 6 lokyst-32688
        end
1914 64 lokyst-32688
 
1915 lokyst-32688
        -- Placeholder icons
1916 72 lokyst-32688
        tooltip:SetCell(headerline, i + 1, "", nil, nil, nil, nil , nil, nil, nil, minWidth)
1917 64 lokyst-32688
 
1918 9 lokyst-32688
        if item then
1919 65 lokyst-32688
            -- Color surrounding cell according to item rarity
1920 lokyst-32688
            local _, _, quality = GetItemInfo(item.itemID)
1921 72 lokyst-32688
            tooltip:SetCell(headerline, i + 1, {item.texture, quality}, nil, nil, nil, ItemCell , nil, nil, nil, minWidth)
1922 65 lokyst-32688
 
1923 21 lokyst-32688
            tooltip:SetCellScript(headerline, i + 1, "OnEnter", function()
1924 lokyst-32688
                GameTooltip:SetOwner(tooltip, "ANCHOR_RIGHT")
1925 9 lokyst-32688
                GameTooltip:SetHyperlink(item.link)
1926 lokyst-32688
            end )
1927 21 lokyst-32688
                tooltip:SetCellScript(headerline, i + 1, "OnMouseUp", function()
1928 17 lokyst-32688
                    if IsShiftKeyDown() then
1929 lokyst-32688
                        ChatEdit_InsertLink(item.link)
1930 lokyst-32688
                    end
1931 lokyst-32688
                end )
1932 21 lokyst-32688
            tooltip:SetCellScript(headerline, i + 1, "OnLeave", function()
1933 9 lokyst-32688
                GameTooltip:Hide()
1934 lokyst-32688
            end )
1935 lokyst-32688
        end
1936 6 lokyst-32688
    end
1937 5 lokyst-32688
 
1938 14 lokyst-32688
    -- Now add item link names
1939 16 lokyst-32688
    if self.db.profile.displayTextLink then
1940 21 lokyst-32688
        headerline, _ = tooltip:AddLine("")
1941 16 lokyst-32688
        for i = 1, nItems do
1942 69 lokyst-32688
            local index = #items - (report.firstItem + i - 2)
1943 16 lokyst-32688
            local text = ""
1944 lokyst-32688
            local item = nil
1945 69 lokyst-32688
            if index >= 1 then
1946 lokyst-32688
                item = items[index]
1947 lokyst-32688
                text = item.link
1948 16 lokyst-32688
            end
1949 21 lokyst-32688
            tooltip:SetCell(headerline, i + 1, text, nil, nil, nil, nil, nil, nil, nil, 60)
1950 16 lokyst-32688
            if item then
1951 21 lokyst-32688
                tooltip:SetCellScript(headerline, i + 1, "OnEnter", function()
1952 lokyst-32688
                    GameTooltip:SetOwner(tooltip, "ANCHOR_RIGHT")
1953 16 lokyst-32688
                    GameTooltip:SetHyperlink(item.link)
1954 lokyst-32688
                end )
1955 21 lokyst-32688
                tooltip:SetCellScript(headerline, i + 1, "OnMouseUp", function()
1956 17 lokyst-32688
                    if IsShiftKeyDown() then
1957 lokyst-32688
                        ChatEdit_InsertLink(item.link)
1958 lokyst-32688
                    end
1959 lokyst-32688
                end )
1960 21 lokyst-32688
                tooltip:SetCellScript(headerline, i + 1, "OnLeave", function()
1961 16 lokyst-32688
                    GameTooltip:Hide()
1962 lokyst-32688
                end )
1963 lokyst-32688
            end
1964 14 lokyst-32688
        end
1965 lokyst-32688
    end
1966 5 lokyst-32688
 
1967 32 lokyst-32688
    tooltip:AddLine("")
1968 lokyst-32688
 
1969 6 lokyst-32688
    -- Create table with party names and their rolls
1970 112 lokyst-32688
    local me = UnitName("player")
1971 6 lokyst-32688
    for i, name in ipairs(players) do
1972 41 lokyst-32688
        local partyLine = tooltip:AddLine("")
1973 72 lokyst-32688
        tooltip:SetCell(partyLine, 1, self:ColorizeName(name) .. " " .. (self.db.profile.displayIcons and BLANK_ICON or ""), nil, "LEFT", nil, nil, nil, nil, nil, minWidth)
1974 5 lokyst-32688
 
1975 7 lokyst-32688
        for i = 1, nItems do
1976 69 lokyst-32688
            local index = #items - (report.firstItem + i - 2)
1977 lokyst-32688
            if index >= 1 then
1978 lokyst-32688
                local item = items[index]
1979 112 lokyst-32688
                tooltip:SetCell(partyLine, i + 1, self:ChoiceText(item.choices[name]) .. self:RollText(item.rolls[name], item.assigned == name, item.assigned == me), nil, "LEFT", nil, nil, nil, nil, nil, minWidth)
1980 6 lokyst-32688
            end
1981 lokyst-32688
        end
1982 lokyst-32688
    end
1983 5 lokyst-32688
 
1984 21 lokyst-32688
    tooltip:AddSeparator()
1985 7 lokyst-32688
 
1986 lokyst-32688
    -- Display winner
1987 14 lokyst-32688
    local winnerTable = {yC .. "Winner|r"}
1988 7 lokyst-32688
    for i = 1, nItems do
1989 69 lokyst-32688
        local index = #items - (report.firstItem + i - 2)
1990 lokyst-32688
        if index >= 1 then
1991 lokyst-32688
            local item = items[index]
1992 6 lokyst-32688
            table.insert(winnerTable, self:AssignedText(item))
1993 lokyst-32688
        end
1994 lokyst-32688
    end
1995 21 lokyst-32688
    tooltip:AddLine(unpack(winnerTable))
1996 14 lokyst-32688
end
1997 lokyst-32688
 
1998 lokyst-32688
function NeedyGreedy:AddHeaderText(tooltip)
1999 32 lokyst-32688
    local headerText = yC .. "NeedyGreedy|r"
2000 lokyst-32688
    local lineNum = tooltip:AddLine("")
2001 53 lokyst-32688
    tooltip:SetCell(lineNum, 1, headerText, tooltip:GetHeaderFont(), tooltip:GetColumnCount() - 1)
2002 32 lokyst-32688
 
2003 53 lokyst-32688
    if self.detachedTooltip and tooltip == self.detachedTooltip then
2004 lokyst-32688
        tooltip:SetCell(lineNum, tooltip:GetColumnCount(), CLOSE_ICON)
2005 lokyst-32688
        tooltip:SetCellScript(lineNum, tooltip:GetColumnCount(),"OnMouseUp", function() self:ToggleDisplay() end)
2006 lokyst-32688
    end
2007 lokyst-32688
 
2008 14 lokyst-32688
    tooltip:AddLine("")
2009 lokyst-32688
end
2010 lokyst-32688
 
2011 lokyst-32688
function NeedyGreedy:AddPagerArrows(tooltip)
2012 lokyst-32688
    local nItems = self.db.profile.nItems
2013 69 lokyst-32688
    local count = #items
2014 14 lokyst-32688
 
2015 lokyst-32688
    local lineNum, _ = tooltip:AddLine("")
2016 56 lokyst-32688
    local colNum = nItems + 1
2017 14 lokyst-32688
 
2018 12 lokyst-32688
    if report.firstItem > 1 then
2019 56 lokyst-32688
        tooltip:SetCell(lineNum, colNum, PAGER_ICONS.leftUp, nil, "RIGHT")
2020 14 lokyst-32688
        tooltip:SetCellScript(lineNum, colNum, "OnMouseUp", function() self:PageLeft() end)
2021 8 lokyst-32688
    else
2022 56 lokyst-32688
        tooltip:SetCell(lineNum, colNum, PAGER_ICONS.leftDisabled, nil, "RIGHT")
2023 8 lokyst-32688
    end
2024 14 lokyst-32688
 
2025 12 lokyst-32688
    if report.firstItem + nItems - 1 < count then
2026 53 lokyst-32688
        tooltip:SetCell(lineNum, colNum + 1, PAGER_ICONS.rightUp)
2027 14 lokyst-32688
        tooltip:SetCellScript(lineNum, colNum + 1, "OnMouseUp", function() self:PageRight() end)
2028 8 lokyst-32688
    else
2029 53 lokyst-32688
        tooltip:SetCell(lineNum, colNum + 1, PAGER_ICONS.rightDisabled)
2030 8 lokyst-32688
    end
2031 14 lokyst-32688
 
2032 lokyst-32688
    -- Set the page # text
2033 lokyst-32688
    local pageText = ""
2034 56 lokyst-32688
    if nItems == 1 and count > 0 then
2035 14 lokyst-32688
        pageText = tostring(report.firstItem)
2036 lokyst-32688
    elseif count == 0 then
2037 56 lokyst-32688
        pageText = ""
2038 14 lokyst-32688
    elseif count == 1 or report.firstItem == count then
2039 18 lokyst-32688
        pageText = string.format(L["%d of %d"], report.firstItem, count)
2040 14 lokyst-32688
    else
2041 lokyst-32688
        local lastitem = report.firstItem + nItems - 1
2042 lokyst-32688
        if (lastitem > count) then
2043 lokyst-32688
            lastitem = count
2044 lokyst-32688
        end
2045 18 lokyst-32688
        pageText = string.format(L["%d-%d of %d"], report.firstItem, lastitem, count)
2046 14 lokyst-32688
    end
2047 lokyst-32688
 
2048 56 lokyst-32688
    tooltip:SetCell(lineNum, colNum - 1, yC .. pageText, nil, "RIGHT")
2049 5 lokyst-32688
end
2050 lokyst-32688
 
2051 14 lokyst-32688
function NeedyGreedy:AddInfoText(tooltip)
2052 34 lokyst-32688
    local lineNum
2053 lokyst-32688
    local helpText
2054 lokyst-32688
 
2055 lokyst-32688
    tooltip:AddLine("")
2056 lokyst-32688
 
2057 lokyst-32688
    helpText = ""
2058 14 lokyst-32688
    if self.db.profile.detachedTooltip then
2059 34 lokyst-32688
        helpText = helpText .. eC .. L["Click"] .. "|r " .. gC .. L["to hide/show detached tooltip"] .. "|r\n"
2060 14 lokyst-32688
    end
2061 34 lokyst-32688
    helpText = helpText .. eC .. L["Shift-Click"] .. "|r " .. gC .. L["to attach/detach tooltip"] .. "|r\n"
2062 lokyst-32688
    helpText = helpText .. eC .. L["Alt-Click"] .. "|r " .. gC .. L["to clear item list"] .. "|r"
2063 lokyst-32688
    lineNum = tooltip:AddLine()
2064 14 lokyst-32688
    tooltip:SetCell(lineNum, 1, helpText, nil, tooltip:GetColumnCount())
2065 lokyst-32688
end
2066 lokyst-32688
 
2067 50 lokyst-32688
function NeedyGreedy:BuildDetachedTooltip(tooltip)
2068 lokyst-32688
    tooltip:Clear()
2069 lokyst-32688
    self:AddHeaderText(tooltip)
2070 lokyst-32688
    self:PopulateReportTooltip(tooltip)
2071 lokyst-32688
    self:AddPagerArrows(tooltip)
2072 lokyst-32688
end
2073 lokyst-32688
 
2074 lokyst-32688
function NeedyGreedy:BuildDBReportTooltip(tooltip)
2075 lokyst-32688
    tooltip:Clear()
2076 lokyst-32688
    self:AddHeaderText(tooltip)
2077 96 lokyst-32688
    if self:DisplayLDBTTCheck() then
2078 lokyst-32688
        self:PopulateReportTooltip(tooltip)
2079 lokyst-32688
        self:AddPagerArrows(tooltip)
2080 lokyst-32688
    end
2081 50 lokyst-32688
    self:AddInfoText(tooltip)
2082 lokyst-32688
end
2083 lokyst-32688
 
2084 12 lokyst-32688
function NeedyGreedy:UpdateReport()
2085 21 lokyst-32688
    local tooltip = nil
2086 lokyst-32688
    if self.detachedTooltip and self.detachedTooltip:IsShown() then
2087 50 lokyst-32688
        self:BuildDetachedTooltip(self.detachedTooltip)
2088 46 lokyst-32688
    elseif self.dbTooltip and self.dbTooltip:IsShown() and (not self.db.profile.detachedTooltip) then
2089 50 lokyst-32688
        self:BuildDBReportTooltip(self.dbTooltip)
2090 21 lokyst-32688
    else
2091 lokyst-32688
        return
2092 11 lokyst-32688
    end
2093 lokyst-32688
end
2094 lokyst-32688
 
2095 12 lokyst-32688
function NeedyGreedy:RefreshTooltip()
2096 58 lokyst-32688
    if self.db.profile.detachedTooltip and self:DisplayDetachedTTCheck() then
2097 21 lokyst-32688
        self:HideDetachedTooltip()
2098 lokyst-32688
        self:ShowDetachedTooltip()
2099 58 lokyst-32688
    else
2100 lokyst-32688
        self:HideDetachedTooltip()
2101 11 lokyst-32688
    end
2102 21 lokyst-32688
    self:HideDBTooltip()
2103 11 lokyst-32688
end
2104 lokyst-32688
 
2105 22 lokyst-32688
function NeedyGreedy:ToggleDisplay()
2106 lokyst-32688
    if not self.db.profile.detachedTooltip then return end
2107 11 lokyst-32688
 
2108 61 lokyst-32688
    -- Don't toggle display status if we can't see anything to toggle
2109 58 lokyst-32688
    if self.detachedTooltip and self.detachedTooltip:IsShown() then
2110 88 lokyst-32688
        if WATCH_ITEM_BEING_ROLLED_ON then
2111 lokyst-32688
            WATCH_ITEM_BEING_ROLLED_ON = false
2112 lokyst-32688
        end
2113 22 lokyst-32688
        self:HideDetachedTooltip()
2114 94 lokyst-32688
        self.db.profile.displayStatus = false
2115 61 lokyst-32688
    elseif self:CheckDisplayOptions() then
2116 22 lokyst-32688
        self:ShowDetachedTooltip()
2117 94 lokyst-32688
        self.db.profile.displayStatus = true
2118 22 lokyst-32688
    end
2119 11 lokyst-32688
 
2120 22 lokyst-32688
end
2121 lokyst-32688
 
2122 61 lokyst-32688
-- Only use this when not forcing display e.g. RefreshTooltip
2123 58 lokyst-32688
function NeedyGreedy:DisplayDetachedTTCheck()
2124 88 lokyst-32688
    if self.db.profile.autoPopUp and WATCH_ITEM_BEING_ROLLED_ON then
2125 61 lokyst-32688
        return true
2126 lokyst-32688
    end
2127 lokyst-32688
 
2128 94 lokyst-32688
    if not self.db.profile.displayStatus then
2129 61 lokyst-32688
        return false
2130 lokyst-32688
    end
2131 lokyst-32688
 
2132 lokyst-32688
    return self:CheckDisplayOptions()
2133 lokyst-32688
end
2134 lokyst-32688
 
2135 lokyst-32688
-- Use this when forcing display of detached tooltip
2136 lokyst-32688
function NeedyGreedy:CheckDisplayOptions()
2137 90 lokyst-32688
    if self:CheckShowInCombat() then
2138 34 lokyst-32688
        return true
2139 lokyst-32688
    end
2140 22 lokyst-32688
 
2141 34 lokyst-32688
    return false
2142 lokyst-32688
end
2143 22 lokyst-32688
 
2144 35 lokyst-32688
function NeedyGreedy:CheckShowInCombat()
2145 lokyst-32688
    if self.db.profile.hideInCombat and IS_IN_COMBAT then
2146 lokyst-32688
        return false
2147 lokyst-32688
    end
2148 34 lokyst-32688
 
2149 35 lokyst-32688
    return true
2150 lokyst-32688
end
2151 34 lokyst-32688
 
2152 96 lokyst-32688
function NeedyGreedy:DisplayLDBTTCheck()
2153 lokyst-32688
    if self:CheckSuppressInRaid() then
2154 lokyst-32688
        return false
2155 lokyst-32688
    end
2156 35 lokyst-32688
 
2157 96 lokyst-32688
    return true
2158 lokyst-32688
end
2159 35 lokyst-32688
 
2160 96 lokyst-32688
function NeedyGreedy:CheckSuppressInRaid()
2161 lokyst-32688
    if IS_IN_RAID and self.db.profile.suppressInRaid then
2162 lokyst-32688
        return true
2163 lokyst-32688
    end
2164 lokyst-32688
 
2165 lokyst-32688
    return false
2166 lokyst-32688
end
2167 lokyst-32688
 
2168 lokyst-32688
 
2169 lokyst-32688
 
2170 22 lokyst-32688
-- Chat filter functions
2171 23 lokyst-32688
local function FilterLootMsg(ChatFrameSelf, event, ...)
2172 129 lokyst-32688
    local msg = select(1, ...)
2173 23 lokyst-32688
    for _, string in ipairs(FILTER_CHAT_LOOT_MSGS) do
2174 lokyst-32688
        local match = NeedyGreedy:unformat(string, msg)
2175 lokyst-32688
        if match then
2176 lokyst-32688
            return true
2177 lokyst-32688
        end
2178 22 lokyst-32688
    end
2179 23 lokyst-32688
 
2180 108 lokyst-32688
    return false, ...
2181 22 lokyst-32688
end
2182 lokyst-32688
 
2183 111 lokyst-32688
function NeedyGreedy:EnableNoSpamMode()
2184 lokyst-32688
    FILTER_CHAT_LOOT_MSGS = NO_SPAM_FILTER_CHAT_LOOT_MSGS
2185 lokyst-32688
end
2186 lokyst-32688
 
2187 lokyst-32688
function NeedyGreedy:DisableNoSpamMode()
2188 lokyst-32688
    FILTER_CHAT_LOOT_MSGS = ORIG_FILTER_CHAT_LOOT_MSGS
2189 lokyst-32688
end
2190 lokyst-32688
 
2191 23 lokyst-32688
function NeedyGreedy:EnableChatFilter()
2192 115 lokyst-32688
    FILTER_CHAT_LOOT_MSGS = ORIG_FILTER_CHAT_LOOT_MSGS
2193 lokyst-32688
    if self.db.profile.noSpamMode then
2194 lokyst-32688
        FILTER_CHAT_LOOT_MSGS = NO_SPAM_FILTER_CHAT_LOOT_MSGS
2195 lokyst-32688
    end
2196 23 lokyst-32688
    ChatFrame_AddMessageEventFilter("CHAT_MSG_LOOT", FilterLootMsg)
2197 lokyst-32688
end
2198 lokyst-32688
 
2199 22 lokyst-32688
function NeedyGreedy:DisableChatFilter()
2200 23 lokyst-32688
    ChatFrame_RemoveMessageEventFilter("CHAT_MSG_LOOT", FilterLootMsg)
2201 22 lokyst-32688
end
2202 lokyst-32688
 
2203 lokyst-32688
 
2204 25 lokyst-32688
 
2205 lokyst-32688
-- Automatic enabling of detailed loot information
2206 lokyst-32688
function NeedyGreedy:SetShowLootSpam()
2207 lokyst-32688
    local showLootSpam = GetCVar("showLootSpam") -- 0 for filtered, 1 for details
2208 lokyst-32688
    if showLootSpam == "0" then
2209 lokyst-32688
        originalSpamFilterSetting = showLootSpam
2210 lokyst-32688
        SetCVar("showLootSpam", "1")
2211 24 lokyst-32688
    end
2212 25 lokyst-32688
end
2213 lokyst-32688
 
2214 lokyst-32688
function NeedyGreedy:ResetShowLootSpam()
2215 lokyst-32688
    if originalSpamFilterSetting then
2216 lokyst-32688
        SetCVar("showLootSpam", originalSpamFilterSetting)
2217 lokyst-32688
        originalSpamFilterSetting = nil
2218 24 lokyst-32688
    end
2219 lokyst-32688
end
2220 22 lokyst-32688
 
2221 25 lokyst-32688
 
2222 lokyst-32688
 
2223 84 lokyst-32688
-- Slash Commands
2224 lokyst-32688
function NeedyGreedy:SlashHide()
2225 lokyst-32688
    self.db.profile.detachedTooltip = true
2226 94 lokyst-32688
    self.db.profile.displayStatus = false
2227 88 lokyst-32688
    if WATCH_ITEM_BEING_ROLLED_ON then
2228 lokyst-32688
        WATCH_ITEM_BEING_ROLLED_ON = false
2229 lokyst-32688
    end
2230 84 lokyst-32688
    self:RefreshTooltip()
2231 lokyst-32688
    LibStub("AceConfigRegistry-3.0"):NotifyChange("NeedyGreedy")
2232 52 lokyst-32688
end
2233 lokyst-32688
 
2234 84 lokyst-32688
function NeedyGreedy:SlashShow()
2235 lokyst-32688
    self.db.profile.detachedTooltip = true
2236 94 lokyst-32688
    self.db.profile.displayStatus = true
2237 84 lokyst-32688
    self:RefreshTooltip()
2238 lokyst-32688
    LibStub("AceConfigRegistry-3.0"):NotifyChange("NeedyGreedy")
2239 lokyst-32688
end
2240 lokyst-32688
 
2241 52 lokyst-32688
function NeedyGreedy:PrintReport()
2242 lokyst-32688
    if #items == 0 then self:Print(L["Nothing to report"]) return end
2243 lokyst-32688
    local output = {}
2244 lokyst-32688
 
2245 69 lokyst-32688
    for _, item in ipairs(items) do
2246 52 lokyst-32688
        for name, choice in pairs(item.choices) do
2247 lokyst-32688
            if not output[name] then
2248 lokyst-32688
                output[name] = {
2249 lokyst-32688
                    ["name"] = name,
2250 lokyst-32688
                    ["need"] = 0,
2251 lokyst-32688
                    ["greed"] = 0,
2252 lokyst-32688
                    ["disenchant"] = 0,
2253 lokyst-32688
                    ["pass"] = 0,
2254 lokyst-32688
                    ["assigned"] = 0,
2255 lokyst-32688
                }
2256 lokyst-32688
            end
2257 lokyst-32688
 
2258 lokyst-32688
            for k, v in pairs(output[name]) do
2259 lokyst-32688
                if choice == k then
2260 lokyst-32688
                    output[name][k] = v + 1
2261 lokyst-32688
                end
2262 lokyst-32688
            end
2263 lokyst-32688
 
2264 lokyst-32688
            if item.assigned == name then
2265 lokyst-32688
                output[name]["assigned"] = output[name]["assigned"] + 1
2266 lokyst-32688
            end
2267 lokyst-32688
        end
2268 lokyst-32688
    end
2269 lokyst-32688
 
2270 lokyst-32688
    local sorted = {}
2271 lokyst-32688
    for _, record in pairs(output) do
2272 lokyst-32688
        table.insert(sorted, record)
2273 lokyst-32688
    end
2274 lokyst-32688
    table.sort(sorted, function(a,b) return b.assigned < a.assigned end)
2275 lokyst-32688
 
2276 lokyst-32688
    for _, info in ipairs(sorted) do
2277 lokyst-32688
        self:Printf("%s N:%d G:%d DE:%d P:%d Wins:%d", info.name, info.need, info.greed, info.disenchant, info.pass, info.assigned)
2278 lokyst-32688
    end
2279 lokyst-32688
end
2280 lokyst-32688
 
2281 lokyst-32688
 
2282 lokyst-32688
 
2283 83 lokyst-32688
-- Profile Handling
2284 lokyst-32688
function NeedyGreedy:RefreshProfile()
2285 lokyst-32688
    if self.db.profile.minimap.hide then
2286 lokyst-32688
        ngDBIcon:Hide("NeedyGreedy")
2287 lokyst-32688
    else
2288 lokyst-32688
        ngDBIcon:Show("NeedyGreedy")
2289 lokyst-32688
    end
2290 lokyst-32688
 
2291 lokyst-32688
    self:RefreshTooltip()
2292 lokyst-32688
end
2293 lokyst-32688
 
2294 lokyst-32688
 
2295 lokyst-32688
 
2296 11 lokyst-32688
-- Unit tests
2297 141 lokyst-32688
--[[
2298 38 lokyst-32688
function NeedyGreedy:SetItems(itemList)
2299 lokyst-32688
    items = itemList
2300 39 lokyst-32688
    self:UpdateReport()
2301 38 lokyst-32688
end
2302 lokyst-32688
 
2303 63 lokyst-32688
function NeedyGreedy:GetItems()
2304 lokyst-32688
    return items
2305 lokyst-32688
end
2306 lokyst-32688
 
2307 12 lokyst-32688
function NeedyGreedy:TestItemList()
2308 42 lokyst-32688
    items = {
2309 lokyst-32688
        {
2310 lokyst-32688
            ["received"] = 108626.818,
2311 lokyst-32688
            ["assigned"] = "Evilplaque",
2312 lokyst-32688
            ["itemID"] = 36040,
2313 lokyst-32688
            ["link"] = "|cff1eff00|Hitem:36040:0:0:0:0:0:-36:-2033450911:80|h[Condor Pants of the Sorcerer]|h|r",
2314 lokyst-32688
            ["choices"] = {
2315 lokyst-32688
                ["Aneeka"] = "greed",
2316 lokyst-32688
                ["Lubov"] = "greed",
2317 lokyst-32688
                ["Evilplaque"] = "greed",
2318 lokyst-32688
                ["Blizzy"] = "disenchant",
2319 lokyst-32688
                ["Dkmonkey"] = "disenchant",
2320 lokyst-32688
            },
2321 lokyst-32688
            ["rolls"] = {
2322 lokyst-32688
                ["Aneeka"] = "24",
2323 lokyst-32688
                ["Lubov"] = "66",
2324 lokyst-32688
                ["Evilplaque"] = "98",
2325 lokyst-32688
                ["Blizzy"] = "52",
2326 lokyst-32688
                ["Dkmonkey"] = "3",
2327 lokyst-32688
            },
2328 lokyst-32688
            ["texture"] = "Interface\\Icons\\INV_Pants_Cloth_10",
2329 lokyst-32688
        }, -- [6]
2330 lokyst-32688
        {
2331 lokyst-32688
            ["received"] = 109046.237,
2332 lokyst-32688
            ["assigned"] = "Lubov",
2333 lokyst-32688
            ["itemID"] = 50228,
2334 lokyst-32688
            ["link"] = "|cffa335ee|Hitem:50228:0:0:0:0:0:0:1749772928:80|h[Barbed Ymirheim Choker]|h|r",
2335 lokyst-32688
            ["choices"] = {
2336 lokyst-32688
                ["Aneeka"] = "greed",
2337 lokyst-32688
                ["Blizzy"] = "disenchant",
2338 lokyst-32688
                ["Evilplaque"] = "disenchant",
2339 lokyst-32688
                ["Lubov"] = "need",
2340 lokyst-32688
                ["Dkmonkey"] = "disenchant",
2341 lokyst-32688
            },
2342 lokyst-32688
            ["rolls"] = {
2343 lokyst-32688
                ["Lubov"] = "17",
2344 lokyst-32688
            },
2345 lokyst-32688
            ["texture"] = "Interface\\Icons\\INV_Jewelry_Necklace_22",
2346 lokyst-32688
        }, -- [7]
2347 lokyst-32688
        {
2348 lokyst-32688
            ["received"] = 109223.287,
2349 lokyst-32688
            ["assigned"] = "Lubov",
2350 lokyst-32688
            ["itemID"] = 36260,
2351 lokyst-32688
            ["link"] = "|cff1eff00|Hitem:36260:0:0:0:0:0:-40:-1617756088:80|h[Cormorant Footwraps of the Bandit]|h|r",
2352 lokyst-32688
            ["choices"] = {
2353 lokyst-32688
                ["Aneeka"] = "greed",
2354 lokyst-32688
                ["Blizzy"] = "disenchant",
2355 lokyst-32688
                ["Evilplaque"] = "greed",
2356 lokyst-32688
                ["Lubov"] = "greed",
2357 lokyst-32688
                ["Dkmonkey"] = "disenchant",
2358 lokyst-32688
            },
2359 lokyst-32688
            ["rolls"] = {
2360 lokyst-32688
                ["Aneeka"] = "61",
2361 lokyst-32688
                ["Blizzy"] = "54",
2362 lokyst-32688
                ["Evilplaque"] = "50",
2363 lokyst-32688
                ["Lubov"] = "87",
2364 lokyst-32688
                ["Dkmonkey"] = "1",
2365 lokyst-32688
            },
2366 lokyst-32688
            ["texture"] = "Interface\\Icons\\INV_Boots_Chain_07",
2367 lokyst-32688
        }, -- [8]
2368 lokyst-32688
        {
2369 lokyst-32688
            ["received"] = 109267.102,
2370 lokyst-32688
            ["assigned"] = "Dkmonkey",
2371 lokyst-32688
            ["itemID"] = 50319,
2372 lokyst-32688
            ["link"] = "|cffa335ee|Hitem:50319:0:0:0:0:0:0:459549600:80|h[Unsharpened Ice Razor]|h|r",
2373 lokyst-32688
            ["choices"] = {
2374 lokyst-32688
                ["Aneeka"] = "disenchant",
2375 lokyst-32688
                ["Lubov"] = "disenchant",
2376 lokyst-32688
                ["Evilplaque"] = "disenchant",
2377 lokyst-32688
                ["Blizzy"] = "disenchant",
2378 lokyst-32688
                ["Dkmonkey"] = "disenchant",
2379 lokyst-32688
            },
2380 lokyst-32688
            ["rolls"] = {
2381 lokyst-32688
                ["Aneeka"] = "69",
2382 lokyst-32688
                ["Lubov"] = "28",
2383 lokyst-32688
                ["Evilplaque"] = "30",
2384 lokyst-32688
                ["Blizzy"] = "21",
2385 lokyst-32688
                ["Dkmonkey"] = "80",
2386 lokyst-32688
            },
2387 lokyst-32688
            ["texture"] = "Interface\\Icons\\inv_weapon_shortblade_61",
2388 lokyst-32688
        }, -- [9]
2389 lokyst-32688
        {
2390 lokyst-32688
            ["received"] = 109483.031,
2391 lokyst-32688
            ["assigned"] = "Dkmonkey",
2392 lokyst-32688
            ["itemID"] = 50262,
2393 lokyst-32688
            ["link"] = "|cffa335ee|Hitem:50262:0:0:0:0:0:0:305102456:80|h[Felglacier Bolter]|h|r",
2394 lokyst-32688
            ["choices"] = {
2395 lokyst-32688
                ["Aneeka"] = "disenchant",
2396 lokyst-32688
                ["Blizzy"] = "disenchant",
2397 lokyst-32688
                ["Evilplaque"] = "disenchant",
2398 lokyst-32688
                ["Lubov"] = "disenchant",
2399 lokyst-32688
                ["Dkmonkey"] = "disenchant",
2400 lokyst-32688
            },
2401 lokyst-32688
            ["rolls"] = {
2402 lokyst-32688
                ["Aneeka"] = "9",
2403 lokyst-32688
                ["Lubov"] = "40",
2404 lokyst-32688
                ["Evilplaque"] = "69",
2405 lokyst-32688
                ["Blizzy"] = "45",
2406 lokyst-32688
                ["Dkmonkey"] = "77",
2407 lokyst-32688
            },
2408 lokyst-32688
            ["texture"] = "Interface\\Icons\\inv_weapon_crossbow_30",
2409 lokyst-32688
        }, -- [10]
2410 lokyst-32688
        {
2411 lokyst-32688
            ["received"] = 109746.236,
2412 lokyst-32688
            ["assigned"] = "Blizzy",
2413 lokyst-32688
            ["itemID"] = 37780,
2414 lokyst-32688
            ["link"] = "|cff0070dd|Hitem:37780:0:0:0:0:0:0:1986751616:80|h[Condor-Bone Chestguard]|h|r",
2415 lokyst-32688
            ["choices"] = {
2416 lokyst-32688
                ["Aneeka"] = "greed",
2417 lokyst-32688
                ["Blizzy"] = "disenchant",
2418 lokyst-32688
                ["Evilplaque"] = "greed",
2419 lokyst-32688
                ["Lubov"] = "greed",
2420 lokyst-32688
                ["Dkmonkey"] = "greed",
2421 lokyst-32688
            },
2422 lokyst-32688
            ["rolls"] = {
2423 lokyst-32688
                ["Aneeka"] = "14",
2424 lokyst-32688
                ["Lubov"] = "22",
2425 lokyst-32688
                ["Evilplaque"] = "72",
2426 lokyst-32688
                ["Blizzy"] = "77",
2427 lokyst-32688
                ["Dkmonkey"] = "62",
2428 lokyst-32688
            },
2429 lokyst-32688
            ["texture"] = "Interface\\Icons\\INV_Chest_Chain_14",
2430 lokyst-32688
        }, -- [11]
2431 lokyst-32688
        {
2432 lokyst-32688
            ["received"] = 110173.528,
2433 lokyst-32688
            ["assigned"] = "Lubov",
2434 lokyst-32688
            ["itemID"] = 50272,
2435 lokyst-32688
            ["link"] = "|cffa335ee|Hitem:50272:0:0:0:0:0:0:349262944:80|h[Frost Wyrm Ribcage]|h|r",
2436 lokyst-32688
            ["choices"] = {
2437 lokyst-32688
                ["Aneeka"] = "greed",
2438 lokyst-32688
                ["Blizzy"] = "disenchant",
2439 lokyst-32688
                ["Evilplaque"] = "disenchant",
2440 lokyst-32688
                ["Lubov"] = "need",
2441 lokyst-32688
                ["Dkmonkey"] = "disenchant",
2442 lokyst-32688
            },
2443 lokyst-32688
            ["rolls"] = {
2444 lokyst-32688
                ["Lubov"] = "2",
2445 lokyst-32688
            },
2446 lokyst-32688
            ["texture"] = "Interface\\Icons\\inv_chest_plate23",
2447 lokyst-32688
        }, -- [12]
2448 lokyst-32688
        {
2449 lokyst-32688
            ["received"] = 110155.978,
2450 lokyst-32688
            ["assigned"] = "Lubov",
2451 lokyst-32688
            ["itemID"] = 50285,
2452 lokyst-32688
            ["link"] = "|cffa335ee|Hitem:50285:0:0:0:0:0:0:617698400:80|h[Icebound Bronze Cuirass]|h|r",
2453 lokyst-32688
            ["choices"] = {
2454 lokyst-32688
                ["Aneeka"] = "greed",
2455 lokyst-32688
                ["Blizzy"] = "disenchant",
2456 lokyst-32688
                ["Evilplaque"] = "disenchant",
2457 lokyst-32688
                ["Lubov"] = "need",
2458 lokyst-32688
                ["Dkmonkey"] = "disenchant",
2459 lokyst-32688
            },
2460 lokyst-32688
            ["rolls"] = {
2461 lokyst-32688
                ["Lubov"] = "25",
2462 lokyst-32688
            },
2463 lokyst-32688
            ["texture"] = "Interface\\Icons\\inv_chest_plate23",
2464 lokyst-32688
        }, -- [13]
2465 lokyst-32688
        {
2466 lokyst-32688
            ["received"] = 110154.673,
2467 lokyst-32688
            ["assigned"] = "Evilplaque",
2468 lokyst-32688
            ["itemID"] = 43102,
2469 lokyst-32688
            ["link"] = "|cff0070dd|Hitem:43102:0:0:0:0:0:0:1423004768:80|h[Frozen Orb]|h|r",
2470 lokyst-32688
            ["choices"] = {
2471 lokyst-32688
                ["Aneeka"] = "greed",
2472 lokyst-32688
                ["Lubov"] = "greed",
2473 lokyst-32688
                ["Evilplaque"] = "greed",
2474 lokyst-32688
                ["Blizzy"] = "greed",
2475 lokyst-32688
                ["Dkmonkey"] = "greed",
2476 lokyst-32688
            },
2477 lokyst-32688
            ["rolls"] = {
2478 lokyst-32688
                ["Aneeka"] = "83",
2479 lokyst-32688
                ["Blizzy"] = "96",
2480 lokyst-32688
                ["Evilplaque"] = "96",
2481 lokyst-32688
                ["Lubov"] = "60",
2482 lokyst-32688
                ["Dkmonkey"] = "15",
2483 lokyst-32688
            },
2484 lokyst-32688
            ["texture"] = "Interface\\Icons\\Spell_Frost_FrozenCore",
2485 lokyst-32688
        }, -- [14]
2486 6 lokyst-32688
    }
2487 73 lokyst-32688
    self:RefreshTooltip()
2488 14 lokyst-32688
end
2489 141 lokyst-32688
 
2490 lokyst-32688
function NeedyGreedy:TestCleanup()
2491 lokyst-32688
    WATCH_ITEM_BEING_ROLLED_ON = true
2492 lokyst-32688
    local link = "|cff0070dd|Hitem:43102:0:0:0:0:0:0:1423004768:80|h[Frozen Orb]|h|r"
2493 lokyst-32688
    local player = "Lubov"
2494 lokyst-32688
    self:RecordReceived(link, player)
2495 lokyst-32688
end
2496 43 lokyst-32688
--]]
2497 25 lokyst-32688
 
2498 lokyst-32688
-- /dump NeedyGreedy:TestSuperFind()
2499 lokyst-32688
--[[
2500 lokyst-32688
function NeedyGreedy:TestSuperFind()
2501 lokyst-32688
    do
2502 lokyst-32688
        local pattern, captureIndices = patternFromFormat("%s automatically passed on: %s because he cannot loot that item.")
2503 lokyst-32688
        DevTools_Dump({pattern, captureIndices})
2504 lokyst-32688
        DevTools_Dump({superFind("bob automatically passed on: [Tuxedo Jacket] because he cannot loot that item.", pattern, captureIndices)})
2505 lokyst-32688
    end
2506 lokyst-32688
 
2507 lokyst-32688
    do
2508 lokyst-32688
        local pattern, captureIndices = patternFromFormat("%1$s gewinnt: %3$s |cff818181(Gier - %2$d)|r")
2509 lokyst-32688
        DevTools_Dump({pattern, captureIndices})
2510 lokyst-32688
        DevTools_Dump({superFind("bob gewinnt: [Tuxedo Jacket] |cff818181(Gier - 123)|r", pattern, captureIndices)})
2511 lokyst-32688
    end
2512 lokyst-32688
 
2513 lokyst-32688
    --DevTools_Dump()
2514 lokyst-32688
 
2515 lokyst-32688
end
2516 lokyst-32688
]]