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