vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -------------------------------------------------------------------------- |
2 | -- ImprovedErrorFrame.lua |
||
3 | -------------------------------------------------------------------------- |
||
4 | --[[ |
||
5 | |||
6 | Original ImprovedErrorFrame - Vjeux |
||
7 | ImprovedErrorFrame without FrameXML - AnduinLothar |
||
8 | |||
9 | ImprovedErrorFrame v2 - Sinaloit |
||
10 | - Now adds a minimap button when errors are present, no more windows |
||
11 | popping up every time you get an error. Click the button to view |
||
12 | the errors. |
||
13 | Icons provided by Moonfire |
||
14 | |||
15 | v2.0 |
||
16 | - Restructured code |
||
17 | - Error messages now reveal an error button rather than a popup on occurance |
||
18 | clicking on button shows frame with error messages |
||
19 | - Error button flashes when shown, hidden if no bugs |
||
20 | - Error button is mobile, orbits the Minimap |
||
21 | Shift-Left Click to drag, Shift-Right Click to reset |
||
22 | |||
23 | v2.1 |
||
24 | - Added Report button back, only shows up if ImprovedErrorFrame.displayReportButton = true |
||
25 | Set this value if you want to be able to have people report errors |
||
26 | - Added ImprovedErrorFrame_Report_OnClick() to be hooked by any AddOn that wants to know |
||
27 | when the Report button was clicked, passes ImprovedErrorFrame.errorMessageList |
||
28 | - Added slash command (/ief) to allow user to choose frame or button appearing on error |
||
29 | |||
30 | |||
31 | v2.2 |
||
32 | - Added IMPROVEDERRORFRAME_REV variable |
||
33 | - AddOn names/files are now stored in the errorMessageList |
||
34 | - Added ability to turn off blinking on notification icon |
||
35 | - Changed blinking to simply turning off/on highlight |
||
36 | - Added localization strings |
||
37 | - Streamlined the code a little |
||
38 | - Uses Sky for slashCommand registration if present else default method |
||
39 | |||
40 | v2.3 |
||
41 | - Added Khoas/Cosmos Registration if present |
||
42 | - Added tooltip to ErrorButton |
||
43 | - Added option to display count of errors |
||
44 | - Added option to always have ErrorButton present (button is disabled if no messages) |
||
45 | - Added sound when 1st error notification occurs |
||
46 | - Added option to disable sound |
||
47 | |||
48 | v2.4 |
||
49 | - Fixed Cosmos Registration |
||
50 | - Added line and parsedErr to errorList |
||
51 | - Fixed some state errors with toggles |
||
52 | - Khaos Registration now working correctly |
||
53 | |||
54 | v2.5 |
||
55 | - Fixed Always show to always show, even after camping when not using Cosmos/Khaos |
||
56 | - Removed extraneous calls to ImprovedErrorFrame.change<blah> in Khaos commands |
||
57 | - changeBlink/Count functions now are aware of button being disabled |
||
58 | |||
59 | v2.6 |
||
60 | - Fixed file pattern match to work on files with more than 1 period |
||
61 | - Renamed ping.mp3 to ErrorSound.mp3 for more clarity |
||
62 | - Fixed string.find in IEFSetOptions to work with 1 word commands |
||
63 | |||
64 | v2.7 |
||
65 | - Changed Bug Count to Red |
||
66 | - Fixed error sound for each error if minimap was open. |
||
67 | - Instead of rescheduling IEFNotify every time checks if present 1st |
||
68 | - Always shown button now enables properly when error occurs |
||
69 | |||
70 | v2.8 |
||
71 | - Added depedencies to Khaos Registration |
||
72 | - Changed Report button to hide IEFF before calling OnClick, now hook order doesn't matter |
||
73 | - Added a header to the IEFF so that its more obvious what it is |
||
74 | - Resolved issue with multiple sounds from getting same error repeatedly as only error |
||
75 | - Rechecked code and made compliant with new errorButtonActive setting |
||
76 | |||
77 | v2.81 |
||
78 | - Fixed issue with error text overlapping header. |
||
79 | |||
80 | v2.82 |
||
81 | - German localization added Thanks to StarDust |
||
82 | |||
83 | v2.9 |
||
84 | - Added option for an empty button during flashing for easier count reading. |
||
85 | |||
86 | v2.95 |
||
87 | - French Localization added thanks to Sasmira |
||
88 | - Khaos registration changed slightly, no more queue choice, unchecking IEF does this now. |
||
89 | - convertRev now translates tables of revisions or passed strings. |
||
90 | |||
91 | v2.97 |
||
92 | - Fixed default value error for Cosmos Registration for Empty |
||
93 | - Added XMLDebug, allows you to enable verbose FrameXML.log |
||
94 | |||
95 | $Id: ImprovedErrorFrame.lua 2121 2005-07-12 14:20:21Z Sinaloit $ |
||
96 | $Rev: 2121 $ |
||
97 | $LastChangedBy: Sinaloit $ |
||
98 | $Date: 2005-07-13 00:20:21 +1000 (Wed, 13 Jul 2005) $ |
||
99 | ]]-- |
||
100 | |||
101 | -- Revision tag |
||
102 | IMPROVEDERRORFRAME_REV = "$Rev: 2121 $"; |
||
103 | |||
104 | IEF_TEST_FLAG = nil; |
||
105 | IEF_TEST_FLAG2 = nil; |
||
106 | -- ImprovedErrorFrame Defines |
||
107 | local IEF_ERROR_MESSAGE_PAGE_MAX = 10; |
||
108 | local IEF_ERROR_MESSAGE_MAX = 999; |
||
109 | local IEF_ERROR_MESSAGE_INFINITE = 20; |
||
110 | local IEF_BLINK_DELAY = 2; |
||
111 | IEF_MSG_NEW = 0; -- Message added, not scheduled to be shown yet |
||
112 | IEF_MSG_SHOWN = 1; -- Message scheduled to be seen by user |
||
113 | IEF_MSG_VIEWED = 2; -- Message was viewed by user |
||
114 | |||
115 | ImprovedErrorSettings = { |
||
116 | -- Show error when it occurs |
||
117 | displayOnError = false; |
||
118 | -- To Blink or not to Blink |
||
119 | blinkNotification = true; |
||
120 | -- Display count of errors |
||
121 | displayCount = true; |
||
122 | -- Display even when no errors pending |
||
123 | alwaysShow = false; |
||
124 | -- Prevent sound from playing when error occurs |
||
125 | gagNoise = false; |
||
126 | -- Empty out the icon when blinking (allows numbers to be seen easier) |
||
127 | emptyButton = false; |
||
128 | -- Verbose XML errror logging |
||
129 | XMLDebug = false; |
||
130 | }; |
||
131 | |||
132 | ImprovedErrorFrame = { |
||
133 | -- Current Error Message |
||
134 | messagePrint = ""; |
||
135 | |||
136 | --[[ |
||
137 | -- List of all current Errors, both viewed and unviewed |
||
138 | -- |
||
139 | -- Table Structure: |
||
140 | -- .err = error message |
||
141 | -- .count = number of occurances |
||
142 | -- .status = IEF_MSG_NEW or IEF_MSG_SHOWN or IEF_MSG_VIEWED |
||
143 | -- .AddOn = name of addon that generated the error |
||
144 | -- .fileName = file name error occured in |
||
145 | -- .line = line number error occured on |
||
146 | -- .parsedErr = Just the error message no file/line number |
||
147 | -- .errDate = date/time error occured |
||
148 | -- .reported = error has been reported |
||
149 | --]] |
||
150 | errorMessageList = { }; |
||
151 | -- Display the report button, set by some other AddOn |
||
152 | displayReportButton = false; |
||
153 | -- Indicates if errorButton is active |
||
154 | errorButtonActive = false; |
||
155 | |||
156 | -- Previous function handlers |
||
157 | oldFuncs = { |
||
158 | oldERRORMESSAGE = _ERRORMESSAGE; |
||
159 | oldMessage = message; |
||
160 | }; |
||
161 | |||
162 | -- Error reporting function, this loads before Sea so we have to have our own. |
||
163 | Print = function(msg, r, g, b, frame) |
||
164 | if (not r) then r = 1.0; end |
||
165 | if (not g) then g = 1.0; end |
||
166 | if (not b) then b = 1.0; end |
||
167 | if (frame) then |
||
168 | frame:AddMessage(msg, r, g, b); |
||
169 | else |
||
170 | if ( DEFAULT_CHAT_FRAME ) then |
||
171 | DEFAULT_CHAT_FRAME:AddMessage(msg, r, g, b); |
||
172 | end |
||
173 | end |
||
174 | end; |
||
175 | |||
176 | -- Replaces old error handling functions and adds the Frame to the UI Panel list |
||
177 | enable = function() |
||
178 | _ERRORMESSAGE = ImprovedErrorFrame.newErrorMessage; |
||
179 | message = ImprovedErrorFrame.newErrorMessage; |
||
180 | UIPanelWindows["ImprovedErrorFrameFrame"] = { area = "center", pushable = 0 }; -- Allows the frame to be closed by Escape |
||
181 | end; |
||
182 | |||
183 | -- Returns error handling functions to original and removes Frame from UI Panel List |
||
184 | disable = function() |
||
185 | _ERRORMESSAGE = ImprovedErrorFrame.oldFuncs.oldERRORMESSAGE; |
||
186 | message = ImprovedErrorFrame.oldFuncs.oldMessage; |
||
187 | UIPanelWindows["ImprovedErrorFrameFrame"] = nil; |
||
188 | end; |
||
189 | |||
190 | -- Slash command handler |
||
191 | IEFSetOptions = function(msg) |
||
192 | msg = string.lower(msg); |
||
193 | local change = false; |
||
194 | local _, _, option, setting = string.find(msg, "(%w+) *(%w*)"); |
||
195 | if (option == IEF_NOTIFY_OPT) then |
||
196 | if (setting == IEF_ON) then |
||
197 | ImprovedErrorSettings.displayOnError = false; |
||
198 | elseif (setting == IEF_OFF) then |
||
199 | ImprovedErrorSettings.displayOnError = true; |
||
200 | else |
||
201 | ImprovedErrorSettings.displayOnError = not ImprovedErrorSettings.displayOnError; |
||
202 | end |
||
203 | if (ImprovedErrorSettings.displayOnError) then |
||
204 | ImprovedErrorFrame.Print(IEF_NOTIFY_OFF); |
||
205 | else |
||
206 | ImprovedErrorFrame.Print(IEF_NOTIFY_ON); |
||
207 | end |
||
208 | change = true; |
||
209 | elseif (Chronos and (option == IEF_BLINK_OPT)) then |
||
210 | if (setting == IEF_ON) then |
||
211 | ImprovedErrorSettings.blinkNotification = true; |
||
212 | elseif (setting == IEF_OFF) then |
||
213 | ImprovedErrorSettings.blinkNotification = false; |
||
214 | else |
||
215 | ImprovedErrorSettings.blinkNotification = not ImprovedErrorSettings.blinkNotification; |
||
216 | end |
||
217 | if (ImprovedErrorSettings.blinkNotification) then |
||
218 | ImprovedErrorFrame.Print(IEF_BLINK_ON); |
||
219 | else |
||
220 | ImprovedErrorFrame.Print(IEF_BLINK_OFF); |
||
221 | end |
||
222 | ImprovedErrorFrame.changeBlink(); |
||
223 | change = true; |
||
224 | elseif (option == IEF_COUNT_OPT) then |
||
225 | if (setting == IEF_ON) then |
||
226 | ImprovedErrorSettings.displayCount = true; |
||
227 | elseif (setting == IEF_OFF) then |
||
228 | ImprovedErrorSettings.displayCount = false; |
||
229 | else |
||
230 | ImprovedErrorSettings.displayCount = not ImprovedErrorSettings.displayCount; |
||
231 | end |
||
232 | if (ImprovedErrorSettings.displayCount) then |
||
233 | ImprovedErrorFrame.Print(IEF_COUNT_ON); |
||
234 | else |
||
235 | ImprovedErrorFrame.Print(IEF_COUNT_OFF); |
||
236 | end |
||
237 | ImprovedErrorFrame.changeCount(); |
||
238 | change = true; |
||
239 | elseif (option == IEF_ALWAYS_OPT) then |
||
240 | if (setting == IEF_ON) then |
||
241 | ImprovedErrorSettings.alwaysShow = true; |
||
242 | elseif (setting == IEF_OFF) then |
||
243 | ImprovedErrorSettings.alwaysShow = false; |
||
244 | else |
||
245 | ImprovedErrorSettings.alwaysShow = not ImprovedErrorSettings.alwaysShow; |
||
246 | end |
||
247 | if (ImprovedErrorSettings.alwaysShow) then |
||
248 | ImprovedErrorFrame.Print(IEF_ALWAYS_ON); |
||
249 | else |
||
250 | ImprovedErrorFrame.Print(IEF_ALWAYS_OFF); |
||
251 | end |
||
252 | ImprovedErrorFrame.changeAlways(); |
||
253 | change = true; |
||
254 | elseif (option == IEF_SOUND_OPT) then |
||
255 | if (setting == IEF_ON) then |
||
256 | ImprovedErrorSettings.gagNoise = false; |
||
257 | elseif (setting == IEF_OFF) then |
||
258 | ImprovedErrorSettings.gagNoise = true; |
||
259 | else |
||
260 | ImprovedErrorSettings.gagNoise = not ImprovedErrorSettings.gagNoise; |
||
261 | end |
||
262 | if (ImprovedErrorSettings.gagNoise) then |
||
263 | ImprovedErrorFrame.Print(IEF_SOUND_OFF); |
||
264 | else |
||
265 | ImprovedErrorFrame.Print(IEF_SOUND_ON); |
||
266 | end |
||
267 | change = true; |
||
268 | elseif (Chronos and option == IEF_EMPTY_OPT) then |
||
269 | if (setting == IEF_ON) then |
||
270 | ImprovedErrorSettings.emptyButton = true; |
||
271 | elseif (setting == IEF_OFF) then |
||
272 | ImprovedErrorSettings.emptyButton = false; |
||
273 | else |
||
274 | ImprovedErrorSettings.emptyButton = not ImprovedErrorSettings.emptyButton; |
||
275 | end |
||
276 | if (ImprovedErrorSettings.emptyButton) then |
||
277 | ImprovedErrorFrame.Print(IEF_EMPTY_ON); |
||
278 | else |
||
279 | ImprovedErrorFrame.Print(IEF_EMPTY_OFF); |
||
280 | end |
||
281 | change = true; |
||
282 | elseif (option == IEF_DEBUG_OPT) then |
||
283 | if (setting == IEF_ON) then |
||
284 | ImprovedErrorSettings.XMLDebug = 1; |
||
285 | elseif (setting == IEF_OFF) then |
||
286 | ImprovedErrorSettings.XMLDebug = 0; |
||
287 | else |
||
288 | if (ImprovedErrorSettings.XMLDebug == 1) then |
||
289 | ImprovedErrorSettings.XMLDebug = 0; |
||
290 | else |
||
291 | ImprovedErrorSettings.XMLDebug = 1; |
||
292 | end |
||
293 | end |
||
294 | SetCVar("XMLDebug", ImprovedErrorSettings.XMLDebug); |
||
295 | if (ImprovedErrorSettings.XMLDebug == 1) then |
||
296 | ImprovedErrorFrame.Print(IEF_DEBUG_ON); |
||
297 | else |
||
298 | ImprovedErrorFrame.Print(IEF_DEBUG_OFF); |
||
299 | end |
||
300 | change = true; |
||
301 | end |
||
302 | if (change) then |
||
303 | ImprovedErrorFrame.syncCosmosToVars(); |
||
304 | return; |
||
305 | end |
||
306 | ImprovedErrorFrame.displayOptions(); |
||
307 | end; |
||
308 | |||
309 | -- Starts/stops blinking if needed based on blinkNotification value |
||
310 | changeBlink = function(msg) |
||
311 | if (ImprovedErrorSettings.blinkNotification and IEFMinimapButton:IsVisible()) then |
||
312 | if (ImprovedErrorFrame.errorButtonActive) then |
||
313 | if (not Chronos.isScheduledByName("IEFNotify")) then |
||
314 | Chronos.scheduleByName("IEFNotify", IEF_BLINK_DELAY, ImprovedErrorFrame.buttonFlash, true); |
||
315 | end |
||
316 | end |
||
317 | else |
||
318 | Chronos.unscheduleByName("IEFNotify"); |
||
319 | IEFMinimapButton:UnlockHighlight(); |
||
320 | if (ImprovedErrorSettings.emptyButton) then |
||
321 | IEFMinimapButton:SetNormalTexture("Interface\\AddOns\\ImprovedErrorFrame\\Skin\\ErrorButton-Up"); |
||
322 | end |
||
323 | end |
||
324 | end; |
||
325 | |||
326 | -- Shows number on the button if it should be based on displayCount value |
||
327 | changeCount = function(msg) |
||
328 | if (ImprovedErrorSettings.displayCount and IEFMinimapButton:IsVisible()) then |
||
329 | if (ImprovedErrorFrame.errorButtonActive) then |
||
330 | IEFMinimapButton:SetText(ImprovedErrorFrame.countErrors()); |
||
331 | end |
||
332 | else |
||
333 | IEFMinimapButton:SetText(""); |
||
334 | end |
||
335 | end; |
||
336 | |||
337 | -- Makes appropriate changes based on the alwaysShow value |
||
338 | changeAlways = function(msg) |
||
339 | if (ImprovedErrorSettings.alwaysShow) then |
||
340 | if (not IEFMinimapButton:IsVisible()) then |
||
341 | IEFMinimapButton:Show(); |
||
342 | IEFMinimapButton:Disable(); |
||
343 | end |
||
344 | else |
||
345 | if (IEFMinimapButton:IsVisible() and not ImprovedErrorFrame.errorButtonActive) then |
||
346 | IEFMinimapButton:Enable(); |
||
347 | IEFMinimapButton:Hide(); |
||
348 | end |
||
349 | end |
||
350 | end; |
||
351 | |||
352 | changeEmpty = function(msg) |
||
353 | if (not ImprovedErrorSettings.emptyButton) then |
||
354 | IEFMinimapButton:SetNormalTexture("Interface\\AddOns\\ImprovedErrorFrame\\Skin\\ErrorButton-Up"); |
||
355 | end |
||
356 | end; |
||
357 | |||
358 | -- Print Format String and current settings |
||
359 | displayOptions = function() |
||
360 | if (Chronos) then |
||
361 | ImprovedErrorFrame.Print(IEF_FORMAT_STR); |
||
362 | else |
||
363 | ImprovedErrorFrame.Print(IEF_FORMAT_STR_NOCHRON); |
||
364 | end |
||
365 | ImprovedErrorFrame.Print(IEF_CURRENT_SETTINGS); |
||
366 | if (ImprovedErrorSettings.displayOnError) then |
||
367 | ImprovedErrorFrame.Print(" "..IEF_NOTIFY_OFF); |
||
368 | else |
||
369 | ImprovedErrorFrame.Print(" "..IEF_NOTIFY_ON); |
||
370 | end |
||
371 | if (Chronos) then |
||
372 | if (ImprovedErrorSettings.blinkNotification) then |
||
373 | ImprovedErrorFrame.Print(" "..IEF_BLINK_ON); |
||
374 | else |
||
375 | ImprovedErrorFrame.Print(" "..IEF_BLINK_OFF); |
||
376 | end |
||
377 | if (ImprovedErrorSettings.emptyButton) then |
||
378 | ImprovedErrorFrame.Print(" "..IEF_EMPTY_ON); |
||
379 | else |
||
380 | ImprovedErrorFrame.Print(" "..IEF_EMPTY_OFF); |
||
381 | end |
||
382 | end |
||
383 | if (ImprovedErrorSettings.displayCount) then |
||
384 | ImprovedErrorFrame.Print(" "..IEF_COUNT_ON); |
||
385 | else |
||
386 | ImprovedErrorFrame.Print(" "..IEF_COUNT_OFF); |
||
387 | end |
||
388 | if (ImprovedErrorSettings.alwaysShow) then |
||
389 | ImprovedErrorFrame.Print(" "..IEF_ALWAYS_ON); |
||
390 | else |
||
391 | ImprovedErrorFrame.Print(" "..IEF_ALWAYS_OFF); |
||
392 | end |
||
393 | if (ImprovedErrorSettings.gagNoise) then |
||
394 | ImprovedErrorFrame.Print(" "..IEF_SOUND_OFF); |
||
395 | else |
||
396 | ImprovedErrorFrame.Print(" "..IEF_SOUND_ON); |
||
397 | end |
||
398 | if (ImprovedErrorSettings.XMLDebug) then |
||
399 | ImprovedErrorFrame.Print(" "..IEF_DEBUG_ON); |
||
400 | else |
||
401 | ImprovedErrorFrame.Print(" "..IEF_DEBUG_OFF); |
||
402 | end |
||
403 | end; |
||
404 | |||
405 | -- Ran when AddOn starts |
||
406 | onLoad = function() |
||
407 | -- Convert Revision into a number |
||
408 | convertRev("IMPROVEDERRORFRAME_REV"); |
||
409 | |||
410 | -- Load XMLDebug from CVar. |
||
411 | -- (Must use CVars as regular variables aren't available until too late) |
||
412 | RegisterCVar("XMLDebug", 0); |
||
413 | ImprovedErrorSettings.XMLDebug = tonumber(GetCVar("XMLDebug")); |
||
414 | |||
415 | IEF_TEST_FLAG = ImprovedErrorSettings.XMLDebug; |
||
416 | if (ImprovedErrorSettings.XMLDebug == 1) then |
||
417 | IEF_TEST_FLAG2 = true; |
||
418 | FrameXML_Debug(1); |
||
419 | else |
||
420 | IEF_TEST_FLAG2 = false; |
||
421 | FrameXML_Debug(0); |
||
422 | end |
||
423 | |||
424 | -- Perform onLoad tasks |
||
425 | ImprovedErrorFrame.enable(); |
||
426 | this:RegisterEvent("VARIABLES_LOADED"); |
||
427 | end; |
||
428 | |||
429 | -- Event handler function |
||
430 | onEvent = function(event) |
||
431 | if (event == "VARIABLES_LOADED") then |
||
432 | if (Khaos) then |
||
433 | ImprovedErrorFrame.KhaosRegister(); |
||
434 | else |
||
435 | if (Cosmos_RegisterConfiguration) then |
||
436 | ImprovedErrorFrame.CosmosRegister(); |
||
437 | end |
||
438 | if (Sky) then |
||
439 | Sky.registerSlashCommand( |
||
440 | { |
||
441 | id = "ImprovedErrorFrameCommand"; |
||
442 | commands = { "/ief" }; |
||
443 | onExecute = ImprovedErrorFrame.IEFSetOptions; |
||
444 | helpText = IEF_HELP_TEXT; |
||
445 | } |
||
446 | ); |
||
447 | else |
||
448 | SlashCmdList["IEFRAME"] = ImprovedErrorFrame.IEFSetOptions; |
||
449 | SLASH_IEFRAME1 = "/ief"; |
||
450 | end |
||
451 | end |
||
452 | if (ImprovedErrorSettings.alwaysShow) then |
||
453 | if (not IEFMinimapButton:IsVisible()) then |
||
454 | IEFMinimapButton:Show(); |
||
455 | IEFMinimapButton:Disable(); |
||
456 | end |
||
457 | end |
||
458 | end |
||
459 | end; |
||
460 | |||
461 | -- Register Option set w/ Khaos |
||
462 | KhaosRegister = function() |
||
463 | Khaos.registerOptionSet("debug", |
||
464 | { |
||
465 | id = "ImprovedErrorFrame"; |
||
466 | text = IEF_OPTION_TEXT; |
||
467 | helptext = IEF_OPTION_HELP; |
||
468 | difficulty = 1; |
||
469 | default = true; |
||
470 | callback = function(state) |
||
471 | ImprovedErrorSettings.displayOnError = not state; |
||
472 | end; |
||
473 | options = { |
||
474 | { |
||
475 | id = "IEFHeader"; |
||
476 | text = IEF_HEADER_TEXT; |
||
477 | helptext = IEF_HEADER_HELP; |
||
478 | type = K_HEADER; |
||
479 | difficulty = 1; |
||
480 | }; |
||
481 | { |
||
482 | id = "IEFBlink"; |
||
483 | text = IEF_BLINK_TEXT; |
||
484 | helptext = IEF_BLINK_HELP; |
||
485 | type = K_TEXT; |
||
486 | value = true; |
||
487 | check = true; |
||
488 | difficulty = 1; |
||
489 | callback = function(state) |
||
490 | ImprovedErrorSettings.blinkNotification = state.checked; |
||
491 | ImprovedErrorFrame.changeBlink(); |
||
492 | end; |
||
493 | feedback = function(state) |
||
494 | if (state.checked) then |
||
495 | return IEF_BLINK_ON; |
||
496 | else |
||
497 | return IEF_BLINK_OFF; |
||
498 | end |
||
499 | end; |
||
500 | default = { |
||
501 | checked = true; |
||
502 | }; |
||
503 | disabled = { |
||
504 | checked = false; |
||
505 | }; |
||
506 | }; |
||
507 | { |
||
508 | id = "IEFCount"; |
||
509 | text = IEF_COUNT_TEXT; |
||
510 | helptext = IEF_COUNT_HELP; |
||
511 | type = K_TEXT; |
||
512 | value = true; |
||
513 | check = true; |
||
514 | difficulty = 1; |
||
515 | callback = function(state) |
||
516 | ImprovedErrorSettings.displayCount = state.checked; |
||
517 | ImprovedErrorFrame.changeCount(); |
||
518 | end; |
||
519 | feedback = function(state) |
||
520 | if (state.checked) then |
||
521 | return IEF_COUNT_ON; |
||
522 | else |
||
523 | return IEF_COUNT_OFF; |
||
524 | end |
||
525 | end; |
||
526 | default = { |
||
527 | checked = true; |
||
528 | }; |
||
529 | disabled = { |
||
530 | checked = false; |
||
531 | }; |
||
532 | }; |
||
533 | { |
||
534 | id = "IEFAlways"; |
||
535 | text = IEF_ALWAYS_TEXT; |
||
536 | helptext = IEF_ALWAYS_HELP; |
||
537 | type = K_TEXT; |
||
538 | value = true; |
||
539 | check = true; |
||
540 | difficulty = 1; |
||
541 | callback = function(state) |
||
542 | ImprovedErrorSettings.alwaysShow = state.checked; |
||
543 | ImprovedErrorFrame.changeAlways(); |
||
544 | end; |
||
545 | feedback = function(state) |
||
546 | if (state.checked) then |
||
547 | return IEF_ALWAYS_ON; |
||
548 | else |
||
549 | return IEF_ALWAYS_OFF; |
||
550 | end |
||
551 | end; |
||
552 | default = { |
||
553 | checked = false; |
||
554 | }; |
||
555 | disabled = { |
||
556 | checked = false; |
||
557 | }; |
||
558 | }; |
||
559 | { |
||
560 | id = "IEFSound"; |
||
561 | text = IEF_SOUND_TEXT; |
||
562 | helptext = IEF_SOUND_HELP; |
||
563 | type = K_TEXT; |
||
564 | value = true; |
||
565 | check = true; |
||
566 | difficulty = 1; |
||
567 | callback = function(state) |
||
568 | ImprovedErrorSettings.gagNoise = not state.checked; |
||
569 | end; |
||
570 | feedback = function(state) |
||
571 | if (state.checked) then |
||
572 | return IEF_SOUND_ON; |
||
573 | else |
||
574 | return IEF_SOUND_OFF; |
||
575 | end |
||
576 | end; |
||
577 | default = { |
||
578 | checked = true; |
||
579 | }; |
||
580 | disabled = { |
||
581 | checked = false; |
||
582 | }; |
||
583 | }; |
||
584 | { |
||
585 | id = "IEFEmpty"; |
||
586 | text = IEF_EMPTY_TEXT; |
||
587 | helptext = IEF_EMPTY_HELP; |
||
588 | type = K_TEXT; |
||
589 | value = true; |
||
590 | check = true; |
||
591 | difficulty = 1; |
||
592 | callback = function(state) |
||
593 | ImprovedErrorSettings.emptyButton = state.checked; |
||
594 | ImprovedErrorFrame.changeEmpty(); |
||
595 | end; |
||
596 | feedback = function(state) |
||
597 | if (state.checked) then |
||
598 | return IEF_EMPTY_ON; |
||
599 | else |
||
600 | return IEF_EMPTY_OFF; |
||
601 | end |
||
602 | end; |
||
603 | default = { |
||
604 | checked = false; |
||
605 | }; |
||
606 | disabled = { |
||
607 | checked = false; |
||
608 | }; |
||
609 | }; |
||
610 | { |
||
611 | id = "IEFDebug"; |
||
612 | text = IEF_DEBUG_TEXT; |
||
613 | helptext = IEF_DEBUG_HELP; |
||
614 | type = K_TEXT; |
||
615 | value = true; |
||
616 | check = true; |
||
617 | difficulty = 4; |
||
618 | callback = function(state) |
||
619 | ImprovedErrorSettings.XMLDebug = ImprovedErrorFrame.convertVar(state.checked); |
||
620 | SetCVar("XMLDebug", ImprovedErrorSettings.XMLDebug); |
||
621 | end; |
||
622 | feedback = function(state) |
||
623 | if (state.checked) then |
||
624 | return IEF_DEBUG_ON; |
||
625 | else |
||
626 | return IEF_DEBUG_OFF; |
||
627 | end |
||
628 | end; |
||
629 | default = { |
||
630 | checked = false; |
||
631 | }; |
||
632 | disabled = { |
||
633 | checked = false; |
||
634 | }; |
||
635 | }; |
||
636 | }; |
||
637 | commands = { |
||
638 | { |
||
639 | id = "ImprovedErrorFrameCommand"; |
||
640 | commands = { "/ief" }; |
||
641 | helpText = IEF_HELP_TEXT; |
||
642 | parseTree = { |
||
643 | [IEF_NOTIFY_OPT] = { |
||
644 | [1] = { |
||
645 | callback = function(msg) |
||
646 | if (msg == IEF_ON) then |
||
647 | ImprovedErrorSettings.displayOnError = false; |
||
648 | elseif (msg == IEF_OFF) then |
||
649 | ImprovedErrorSettings.displayOnError = true; |
||
650 | else |
||
651 | ImprovedErrorSettings.displayOnError = not ImprovedErrorSettings.displayOnError; |
||
652 | end |
||
653 | Khaos.setSetKey("sets", "ImprovedErrorFrame", not ImprovedErrorSettings.displayOnError) |
||
654 | if (ImprovedErrorSettings.displayOnError) then |
||
655 | ImprovedErrorFrame.Print(IEF_NOTIFY_OFF); |
||
656 | else |
||
657 | ImprovedErrorFrame.Print(IEF_NOTIFY_ON); |
||
658 | end |
||
659 | end; |
||
660 | }; |
||
661 | }; |
||
662 | [IEF_BLINK_OPT] = { |
||
663 | [1] = { |
||
664 | key = "IEFBlink"; |
||
665 | stringMap = { |
||
666 | [IEF_ON] = { checked = true; }; |
||
667 | [IEF_OFF] = { checked = false; }; |
||
668 | ["default"] = { checked = "~IEFBlink.checked" }; |
||
669 | }; |
||
670 | }; |
||
671 | [2] = { |
||
672 | callback = function(msg) |
||
673 | if (ImprovedErrorSettings.blinkNotification) then |
||
674 | ImprovedErrorFrame.Print(IEF_BLINK_ON); |
||
675 | else |
||
676 | ImprovedErrorFrame.Print(IEF_BLINK_OFF); |
||
677 | end |
||
678 | end; |
||
679 | }; |
||
680 | }; |
||
681 | [IEF_COUNT_OPT] = { |
||
682 | [1] = { |
||
683 | key = "IEFCount"; |
||
684 | stringMap = { |
||
685 | [IEF_ON] = { checked = true; }; |
||
686 | [IEF_OFF] = { checked = false; }; |
||
687 | ["default"] = { checked = "~IEFCount.checked" }; |
||
688 | }; |
||
689 | }; |
||
690 | [2] = { |
||
691 | callback = function(msg) |
||
692 | if (ImprovedErrorSettings.displayCount) then |
||
693 | ImprovedErrorFrame.Print(IEF_COUNT_ON); |
||
694 | else |
||
695 | ImprovedErrorFrame.Print(IEF_COUNT_OFF); |
||
696 | end |
||
697 | end; |
||
698 | }; |
||
699 | }; |
||
700 | [IEF_ALWAYS_OPT] = { |
||
701 | [1] = { |
||
702 | key = "IEFAlways"; |
||
703 | stringMap = { |
||
704 | [IEF_ON] = { checked = true; }; |
||
705 | [IEF_OFF] = { checked = false; }; |
||
706 | ["default"] = { checked = "~IEFAlways.checked" }; |
||
707 | }; |
||
708 | }; |
||
709 | [2] = { |
||
710 | callback = function(msg) |
||
711 | if (ImprovedErrorSettings.alwaysShow) then |
||
712 | ImprovedErrorFrame.Print(IEF_ALWAYS_ON); |
||
713 | else |
||
714 | ImprovedErrorFrame.Print(IEF_ALWAYS_OFF); |
||
715 | end |
||
716 | end; |
||
717 | }; |
||
718 | |||
719 | }; |
||
720 | [IEF_SOUND_OPT] = { |
||
721 | [1] = { |
||
722 | key = "IEFSound"; |
||
723 | stringMap = { |
||
724 | [IEF_ON] = { checked = false; }; |
||
725 | [IEF_OFF] = { checked = true; }; |
||
726 | ["default"] = { checked = "~IEFSound.checked" }; |
||
727 | }; |
||
728 | }; |
||
729 | [2] = { |
||
730 | callback = function(msg) |
||
731 | if (ImprovedErrorSettings.gagNoise) then |
||
732 | ImprovedErrorFrame.Print(IEF_SOUND_OFF); |
||
733 | else |
||
734 | ImprovedErrorFrame.Print(IEF_SOUND_ON); |
||
735 | end |
||
736 | end; |
||
737 | }; |
||
738 | }; |
||
739 | [IEF_EMPTY_OPT] = { |
||
740 | [1] = { |
||
741 | key = "IEFEmpty"; |
||
742 | stringMap = { |
||
743 | [IEF_ON] = { checked = true; }; |
||
744 | [IEF_OFF] = { checked = false; }; |
||
745 | ["default"] = { checked = "~IEFEmpty.checked" }; |
||
746 | }; |
||
747 | }; |
||
748 | [2] = { |
||
749 | callback = function(msg) |
||
750 | if (ImprovedErrorSettings.emptyButton) then |
||
751 | ImprovedErrorFrame.Print(IEF_EMPTY_ON); |
||
752 | else |
||
753 | ImprovedErrorFrame.Print(IEF_EMPTY_OFF); |
||
754 | end |
||
755 | end; |
||
756 | }; |
||
757 | }; |
||
758 | [IEF_DEBUG_OPT] = { |
||
759 | [1] = { |
||
760 | key = "IEFDebug"; |
||
761 | stringMap = { |
||
762 | [IEF_ON] = { checked = true; }; |
||
763 | [IEF_OFF] = { checked = false; }; |
||
764 | ["default"] = { checked = "~IEFDebug.checked" }; |
||
765 | }; |
||
766 | }; |
||
767 | [2] = { |
||
768 | callback = function(msg) |
||
769 | if (ImprovedErrorSettings.XMLDebug == 1) then |
||
770 | ImprovedErrorFrame.Print(IEF_DEBUG_ON); |
||
771 | else |
||
772 | ImprovedErrorFrame.Print(IEF_DEBUG_OFF); |
||
773 | end |
||
774 | end; |
||
775 | }; |
||
776 | }; |
||
777 | ["default"] = { |
||
778 | callback = function(msg) |
||
779 | ImprovedErrorFrame.displayOptions(); |
||
780 | end; |
||
781 | }; |
||
782 | }; |
||
783 | }; |
||
784 | }; |
||
785 | } |
||
786 | ); |
||
787 | end; |
||
788 | |||
789 | -- Register everything with Cosmos |
||
790 | CosmosRegister = function() |
||
791 | Cosmos_RegisterConfiguration( |
||
792 | "COS_IEF", |
||
793 | "SECTION", |
||
794 | IEF_OPTION_TEXT, |
||
795 | IEF_OPTION_HELP |
||
796 | ); |
||
797 | Cosmos_RegisterConfiguration( |
||
798 | "COS_IEF_SEPARATOR", |
||
799 | "SEPARATOR", |
||
800 | IEF_HEADER_TEXT, |
||
801 | IEF_HEADER_HELP |
||
802 | ); |
||
803 | Cosmos_RegisterConfiguration( |
||
804 | "COS_IEF_NOTIFY_OPT", |
||
805 | "CHECKBOX", |
||
806 | IEF_NOTIFY_TEXT, |
||
807 | IEF_NOTIFY_HELP, |
||
808 | function(value, checked) |
||
809 | ImprovedErrorSettings.displayOnError = (value < 1); |
||
810 | end, |
||
811 | ImprovedErrorFrame.convertVar(not ImprovedErrorSettings.displayOnError) |
||
812 | ); |
||
813 | Cosmos_RegisterConfiguration( |
||
814 | "COS_IEF_BLINK_OPT", |
||
815 | "CHECKBOX", |
||
816 | IEF_BLINK_TEXT, |
||
817 | IEF_BLINK_HELP, |
||
818 | function(value, checked) |
||
819 | ImprovedErrorSettings.blinkNotification = (value > 0); |
||
820 | ImprovedErrorFrame.changeBlink(); |
||
821 | end, |
||
822 | ImprovedErrorFrame.convertVar(ImprovedErrorSettings.blinkNotification) |
||
823 | ); |
||
824 | Cosmos_RegisterConfiguration( |
||
825 | "COS_IEF_COUNT_OPT", |
||
826 | "CHECKBOX", |
||
827 | IEF_COUNT_TEXT, |
||
828 | IEF_COUNT_HELP, |
||
829 | function(value, checked) |
||
830 | ImprovedErrorSettings.displayCount = (value > 0); |
||
831 | ImprovedErrorFrame.changeCount(); |
||
832 | end, |
||
833 | ImprovedErrorFrame.convertVar(ImprovedErrorSettings.displayCount) |
||
834 | ); |
||
835 | Cosmos_RegisterConfiguration( |
||
836 | "COS_IEF_ALWAYS_OPT", |
||
837 | "CHECKBOX", |
||
838 | IEF_ALWAYS_TEXT, |
||
839 | IEF_ALWAYS_HELP, |
||
840 | function(value, checked) |
||
841 | ImprovedErrorSettings.alwaysShow = (value > 0); |
||
842 | ImprovedErrorFrame.changeAlways(); |
||
843 | end, |
||
844 | ImprovedErrorFrame.convertVar(ImprovedErrorSettings.alwaysShow) |
||
845 | ); |
||
846 | Cosmos_RegisterConfiguration( |
||
847 | "COS_IEF_SOUND_OPT", |
||
848 | "CHECKBOX", |
||
849 | IEF_SOUND_TEXT, |
||
850 | IEF_SOUND_HELP, |
||
851 | function(value, checked) |
||
852 | ImprovedErrorSettings.gagNoise = (value < 1); |
||
853 | end, |
||
854 | ImprovedErrorFrame.convertVar(not ImprovedErrorSettings.gagNoise) |
||
855 | ); |
||
856 | Cosmos_RegisterConfiguration( |
||
857 | "COS_IEF_EMPTY_OPT", |
||
858 | "CHECKBOX", |
||
859 | IEF_EMPTY_TEXT, |
||
860 | IEF_EMPTY_HELP, |
||
861 | function(value, checked) |
||
862 | ImprovedErrorSettings.emptyButton = (value > 0); |
||
863 | ImprovedErrorFrame.changeEmpty(); |
||
864 | end, |
||
865 | ImprovedErrorFrame.convertVar(ImprovedErrorSettings.emptyButton) |
||
866 | ); |
||
867 | Cosmos_RegisterConfiguration( |
||
868 | "COS_IEF_DEBUG_OPT", |
||
869 | "CHECKBOX", |
||
870 | IEF_DEBUG_TEXT, |
||
871 | IEF_DEBUG_HELP, |
||
872 | function(value, checked) |
||
873 | ImprovedErrorSettings.XMLDebug = value; |
||
874 | SetCVar("XMLDebug", ImprovedErrorSettings.XMLDebug); |
||
875 | end, |
||
876 | ImprovedErrorFrame.convertVar(ImprovedErrorSettings.XMLDebug) |
||
877 | ); |
||
878 | ImprovedErrorFrame.syncVarsToCosmos(); |
||
879 | end; |
||
880 | |||
881 | -- Cosmos uses 0 & 1 not false/true so we need to convert |
||
882 | convertVar = function(varVal) |
||
883 | if (varVal) then |
||
884 | return 1; |
||
885 | else |
||
886 | return 0; |
||
887 | end |
||
888 | end; |
||
889 | |||
890 | -- Sync changed variables to Cosmos Vars |
||
891 | syncCosmosToVars = function() |
||
892 | if (Cosmos_RegisterConfiguration) then |
||
893 | Cosmos_UpdateValue("COS_IEF_NOTIFY_OPT", CSM_CHECKONOFF, ImprovedErrorFrame.convertVar(not ImprovedErrorSettings.displayOnError)); |
||
894 | Cosmos_SetCVar("COS_IEF_NOTIFY_OPT_X", ImprovedErrorFrame.convertVar(not ImprovedErrorSettings.displayOnError)); |
||
895 | Cosmos_UpdateValue("COS_IEF_BLINK_OPT", CSM_CHECKONOFF, ImprovedErrorFrame.convertVar(ImprovedErrorSettings.blinkNotification)); |
||
896 | Cosmos_SetCVar("COS_IEF_BLINK_OPT_X", ImprovedErrorFrame.convertVar(ImprovedErrorSettings.blinkNotification)); |
||
897 | Cosmos_UpdateValue("COS_IEF_COUNT_OPT", CSM_CHECKONOFF, ImprovedErrorFrame.convertVar(ImprovedErrorSettings.displayCount)); |
||
898 | Cosmos_SetCVar("COS_IEF_COUNT_OPT_X", ImprovedErrorFrame.convertVar(ImprovedErrorSettings.displayCount)); |
||
899 | Cosmos_UpdateValue("COS_IEF_ALWAYS_OPT", CSM_CHECKONOFF, ImprovedErrorFrame.convertVar(ImprovedErrorSettings.alwaysShow)); |
||
900 | Cosmos_SetCVar("COS_IEF_ALWAYS_OPT_X", ImprovedErrorFrame.convertVar(ImprovedErrorSettings.alwaysShow)); |
||
901 | Cosmos_UpdateValue("COS_IEF_SOUND_OPT", CSM_CHECKONOFF, ImprovedErrorFrame.convertVar(not ImprovedErrorSettings.gagNoise)); |
||
902 | Cosmos_SetCVar("COS_IEF_SOUND_OPT_X", ImprovedErrorFrame.convertVar(not ImprovedErrorSettings.gagNoise)); |
||
903 | Cosmos_UpdateValue("COS_IEF_EMPTY_OPT", CSM_CHECKONOFF, ImprovedErrorFrame.convertVar(ImprovedErrorSettings.emptyButton)); |
||
904 | Cosmos_SetCVar("COS_IEF_EMPTY_OPT_X", ImprovedErrorFrame.convertVar(ImprovedErrorSettings.emptyButton)); |
||
905 | Cosmos_UpdateValue("COS_IEF_DEBUG_OPT", CSM_CHECKONOFF, ImprovedErrorSettings.XMLDebug); |
||
906 | Cosmos_SetCVar("COS_IEF_DEBUG_OPT_X", ImprovedErrorSettings.XMLDebug); |
||
907 | if (CosmosMasterFrame:IsVisible() and (not CosmosMasterFrame_IsLoading)) then |
||
908 | CosmosMaster_DrawData(); |
||
909 | end |
||
910 | end |
||
911 | end; |
||
912 | |||
913 | -- Sync variables to Cosmos Vars |
||
914 | syncVarsToCosmos = function() |
||
915 | if (not Cosmos_RegisterConfiguration) then |
||
916 | return; |
||
917 | end |
||
918 | local cosVar = getglobal("COS_IEF_NOTIFY_OPT_X"); |
||
919 | if (cosVar) then |
||
920 | ImprovedErrorSettings.displayOnError = (cosVar < 1); |
||
921 | end |
||
922 | cosVar = getglobal("COS_IEF_BLINK_OPT_X"); |
||
923 | if (cosVar) then |
||
924 | ImprovedErrorSettings.blinkNotification = (cosVar > 0); |
||
925 | end |
||
926 | cosVar = getglobal("COS_IEF_COUNT_OPT_X"); |
||
927 | if (cosVar) then |
||
928 | ImprovedErrorSettings.displayCount = (cosVar > 0); |
||
929 | end |
||
930 | cosVar = getglobal("COS_IEF_ALWAYS_OPT_X"); |
||
931 | if (cosVar) then |
||
932 | ImprovedErrorSettings.alwaysShow = (cosVar > 0); |
||
933 | end |
||
934 | cosVar = getglobal("COS_IEF_SOUND_OPT_X"); |
||
935 | if (cosVar) then |
||
936 | ImprovedErrorSettings.gagNoise = (cosVar < 1); |
||
937 | end |
||
938 | cosVar = getglobal("COS_IEF_EMPTY_OPT_X"); |
||
939 | if (cosVar) then |
||
940 | ImprovedErrorSettings.emptyButton = (cosVar > 0); |
||
941 | end |
||
942 | cosVar = getglobal("COS_IEF_DEBUG_OPT_X"); |
||
943 | if (cosVar) then |
||
944 | ImprovedErrorSettings.XMLDebug = cosVar; |
||
945 | end |
||
946 | end; |
||
947 | |||
948 | -- Flags messages as shown, also builds the ImprovedErrorFrame.messagePrint message |
||
949 | populateErrors = function() |
||
950 | local errorMessageList = ImprovedErrorFrame.errorMessageList; |
||
951 | local shown = 0; |
||
952 | ImprovedErrorFrame.messagePrint = "\n"; |
||
953 | for i = 1, table.getn(errorMessageList), 1 do |
||
954 | if (shown >= IEF_ERROR_MESSAGE_PAGE_MAX) then |
||
955 | break; |
||
956 | end |
||
957 | local curMes = errorMessageList[i]; |
||
958 | if (curMes.status < IEF_MSG_VIEWED) then |
||
959 | curMes.status = IEF_MSG_SHOWN; |
||
960 | shown = shown + 1; |
||
961 | |||
962 | local _, _, file, line, error = string.find(curMes.err, "^%[string \"(.+)\"%]:([^:]+):(.+)"); |
||
963 | local count = curMes.count; |
||
964 | if (file and not curMes.AddOn and not curMes.fileName) then |
||
965 | local patternStr; |
||
966 | if (string.sub(file, -3) == "...") then |
||
967 | patternStr = ".+\\(.+)\\(.+%.%.%.)$"; |
||
968 | else |
||
969 | patternStr = ".+\\(.+)\\(.+%....)$"; |
||
970 | end |
||
971 | local _, _, AddOnName, fileName = string.find(file, patternStr); |
||
972 | if (AddOnName and not curMes.AddOn) then |
||
973 | curMes.AddOn = AddOnName; |
||
974 | end |
||
975 | if (fileName and not curMes.fileName) then |
||
976 | curMes.fileName = fileName; |
||
977 | end |
||
978 | if (line and not curMes.line) then |
||
979 | curMes.line = line; |
||
980 | end |
||
981 | if (error and not curMes.parsedErr) then |
||
982 | curMes.parsedErr = error; |
||
983 | end |
||
984 | end |
||
985 | if (curMes.fileName) then |
||
986 | if (string.sub(curMes.fileName, -3) ~= "...") then |
||
987 | ImprovedErrorFrame.messagePrint = ImprovedErrorFrame.messagePrint..IEF_FILE..file.."\n"..IEF_LINE..line.."\n"..IEF_COUNT..count.."\n|cFFFF0000"..IEF_ERROR..error.."|r"; |
||
988 | else |
||
989 | ImprovedErrorFrame.messagePrint = ImprovedErrorFrame.messagePrint..IEF_STRING..file.."\n"..IEF_LINE..line.."\n"..IEF_COUNT..count.."\n|cFFFF0000"..IEF_ERROR..error.."|r"; |
||
990 | end |
||
991 | else |
||
992 | ImprovedErrorFrame.messagePrint = ImprovedErrorFrame.messagePrint..IEF_COUNT..count.."\n|cFFFF0000"..IEF_ERROR..curMes.err.."|r"; |
||
993 | end |
||
994 | if (i ~= table.getn(errorMessageList)) then |
||
995 | ImprovedErrorFrame.messagePrint = ImprovedErrorFrame.messagePrint.."\n--------------------------------------------------\n"; |
||
996 | end |
||
997 | end |
||
998 | end |
||
999 | end; |
||
1000 | |||
1001 | -- Called after IEFFrame is hidden, turns off button if no more errors to view. Updates count if more. |
||
1002 | updateStatus = function() |
||
1003 | local numErrors = ImprovedErrorFrame.countErrors(); |
||
1004 | if (numErrors > 0) then |
||
1005 | ImprovedErrorFrame.errorNotify(numErrors); |
||
1006 | else |
||
1007 | IEFMinimapButton:UnlockHighlight(); |
||
1008 | if (ImprovedErrorSettings.emptyButton) then |
||
1009 | IEFMinimapButton:SetNormalTexture("Interface\\AddOns\\ImprovedErrorFrame\\Skin\\ErrorButton-Up"); |
||
1010 | end |
||
1011 | IEFMinimapButton:SetText(""); |
||
1012 | ImprovedErrorFrame.errorButtonActive = false; |
||
1013 | if (ImprovedErrorSettings.alwaysShow) then |
||
1014 | IEFMinimapButton:Disable(); |
||
1015 | else |
||
1016 | IEFMinimapButton:Hide(); |
||
1017 | end |
||
1018 | if (Chronos) then |
||
1019 | Chronos.unscheduleByName("IEFNotify"); |
||
1020 | end |
||
1021 | end |
||
1022 | end; |
||
1023 | |||
1024 | -- Reoccuring function to toggle Textures on the IEFMinimapButton |
||
1025 | buttonFlash = function(toggle) |
||
1026 | if (toggle) then |
||
1027 | IEFMinimapButton:LockHighlight(); |
||
1028 | if (ImprovedErrorSettings.emptyButton) then |
||
1029 | IEFMinimapButton:SetNormalTexture("Interface\\AddOns\\ImprovedErrorFrame\\Skin\\ErrorButton-Blank"); |
||
1030 | end |
||
1031 | else |
||
1032 | IEFMinimapButton:UnlockHighlight(); |
||
1033 | if (ImprovedErrorSettings.emptyButton) then |
||
1034 | IEFMinimapButton:SetNormalTexture("Interface\\AddOns\\ImprovedErrorFrame\\Skin\\ErrorButton-Up"); |
||
1035 | end |
||
1036 | end |
||
1037 | if (ImprovedErrorFrame.errorButtonActive) then |
||
1038 | Chronos.scheduleByName("IEFNotify", IEF_BLINK_DELAY, ImprovedErrorFrame.buttonFlash, not toggle); |
||
1039 | end |
||
1040 | end; |
||
1041 | |||
1042 | -- Counts number of errors left to be viewed, returns that number |
||
1043 | countErrors = function() |
||
1044 | local errorMessageList = ImprovedErrorFrame.errorMessageList; |
||
1045 | local numErrors = 0; |
||
1046 | for k,v in errorMessageList do |
||
1047 | if (v.status < IEF_MSG_VIEWED) then |
||
1048 | numErrors = numErrors + 1; |
||
1049 | end |
||
1050 | end |
||
1051 | return numErrors; |
||
1052 | end; |
||
1053 | |||
1054 | -- Show the IEFMinimap button and start the texture toggling, passed the # of unviewed errors |
||
1055 | errorNotify = function(numErrors) |
||
1056 | if (not ImprovedErrorFrame.errorButtonActive) then |
||
1057 | ImprovedErrorFrame.errorButtonActive = true; |
||
1058 | if (not ImprovedErrorSettings.gagNoise) then |
||
1059 | PlaySoundFile("Interface\\AddOns\\ImprovedErrorFrame\\Sound\\ErrorSound.mp3"); |
||
1060 | end |
||
1061 | if (ImprovedErrorSettings.alwaysShow) then |
||
1062 | IEFMinimapButton:Enable(); |
||
1063 | else |
||
1064 | IEFMinimapButton:Show(); |
||
1065 | end |
||
1066 | if (ImprovedErrorSettings.blinkNotification and Chronos) then |
||
1067 | if (not Chronos.isScheduledByName("IEFNotify")) then |
||
1068 | Chronos.scheduleByName("IEFNotify", IEF_BLINK_DELAY, ImprovedErrorFrame.buttonFlash, true); |
||
1069 | end |
||
1070 | end |
||
1071 | end |
||
1072 | if (ImprovedErrorSettings.displayCount) then |
||
1073 | IEFMinimapButton:SetText(numErrors); |
||
1074 | end |
||
1075 | end; |
||
1076 | |||
1077 | --[[ |
||
1078 | -- Called after errors occur, builds error list and behaves according to invoked. |
||
1079 | -- |
||
1080 | -- Arguments: |
||
1081 | -- invoked - called by button click? |
||
1082 | -- if true show frame, otherwise just notify. |
||
1083 | --]] |
||
1084 | showErrors = function(invoked) |
||
1085 | local numErrors = ImprovedErrorFrame.countErrors() |
||
1086 | if (numErrors) then |
||
1087 | if (not ImprovedErrorFrameFrame:IsVisible() and not ImprovedErrorSettings.displayOnError and not invoked) then |
||
1088 | ImprovedErrorFrame.errorNotify(numErrors); |
||
1089 | return; |
||
1090 | end |
||
1091 | ImprovedErrorFrame.populateErrors(); |
||
1092 | if (not ImprovedErrorFrameFrame:IsVisible()) then |
||
1093 | if (ImprovedErrorFrame.displayReportButton) then |
||
1094 | ImprovedErrorFrameReportButton:Show(); |
||
1095 | else |
||
1096 | ImprovedErrorFrameReportButton:Hide(); |
||
1097 | end |
||
1098 | ImprovedErrorFrameCloseButton:Show(); |
||
1099 | ScriptErrorsScrollFrameOne:Show(); |
||
1100 | ImprovedErrorFrameFrameButton:Hide(); |
||
1101 | if (ImprovedErrorSettings.displayOnError) then |
||
1102 | ImprovedErrorFrameFrameHeaderText:SetText(IEF_ERROR_TEXT); |
||
1103 | else |
||
1104 | ImprovedErrorFrameFrameHeaderText:SetText(IEF_TITLE_TEXT); |
||
1105 | end |
||
1106 | ImprovedErrorFrameFrame:Show(); |
||
1107 | end |
||
1108 | |||
1109 | ScriptErrorsScrollFrameOneText:SetText(ImprovedErrorFrame.messagePrint); |
||
1110 | ScriptErrorsScrollFrameOneText:ClearFocus(); |
||
1111 | end |
||
1112 | end; |
||
1113 | |||
1114 | --[[ |
||
1115 | -- New _ERRORMESSAGE handler, increments count if error exists already. If the message is new then |
||
1116 | -- it is printed to the DEFAULT_CHAT_FRAME and added to the table of errors. the showErrors function |
||
1117 | -- is then called. |
||
1118 | --]] |
||
1119 | newErrorMessage = function(errorMessage) |
||
1120 | local errorMessageList = ImprovedErrorFrame.errorMessageList; |
||
1121 | debuginfo(); |
||
1122 | if (not errorMessage) then return; end |
||
1123 | --if (table.getn(errorMessageList) >= IEF_ERROR_MESSAGE_MAX) then return; end |
||
1124 | |||
1125 | local foundMes = false; |
||
1126 | for curNum, curMes in errorMessageList do |
||
1127 | if (curMes.err == errorMessage) then |
||
1128 | if (curMes.count.."" ~= IEF_INFINITE) then |
||
1129 | curMes.count = curMes.count + 1; |
||
1130 | if (curMes.count > IEF_ERROR_MESSAGE_INFINITE) then |
||
1131 | curMes.count = IEF_INFINITE; |
||
1132 | end |
||
1133 | curMes.status = IEF_MSG_NEW; |
||
1134 | else |
||
1135 | if (curMes.status >= IEF_MSG_VIEWED) then |
||
1136 | return; |
||
1137 | end |
||
1138 | end |
||
1139 | foundMes = true; |
||
1140 | break; |
||
1141 | end |
||
1142 | end |
||
1143 | |||
1144 | if (not foundMes) then |
||
1145 | ImprovedErrorFrame.Print(errorMessage); |
||
1146 | end |
||
1147 | |||
1148 | if ((not foundMes) and (table.getn(errorMessageList) < IEF_ERROR_MESSAGE_MAX)) then |
||
1149 | table.insert(errorMessageList, { err = errorMessage, count = 1, status = IEF_MSG_NEW, reported = false, errDate = date() }); |
||
1150 | end |
||
1151 | |||
1152 | --if (table.getn(errorMessageList) > 0 and ImprovedErrorFrameFrame:IsVisible()) then return; end |
||
1153 | ImprovedErrorFrame.showErrors(false); |
||
1154 | end; |
||
1155 | |||
1156 | -- Button related functions that wont be hooked. |
||
1157 | -- Shamelessly copied from AnduinLothar with his permission |
||
1158 | Button = { |
||
1159 | onLoad = function() |
||
1160 | this:RegisterEvent("VARIABLES_LOADED"); |
||
1161 | end; |
||
1162 | -- Set the IEFMinimap button to whatever position it was moved to on startup. |
||
1163 | onEvent = function(event) |
||
1164 | if (event == "VARIABLES_LOADED") then |
||
1165 | if ((IEFMinimapButton_OffsetX) and (IEFMinimapButton_OffsetY)) then |
||
1166 | this:SetPoint("CENTER", "Minimap", "CENTER", IEFMinimapButton_OffsetX, IEFMinimapButton_OffsetY); |
||
1167 | end |
||
1168 | end |
||
1169 | end; |
||
1170 | -- Reset IEFMinimapButton to the default position. |
||
1171 | reset = function() |
||
1172 | IEFMinimapButton:ClearAllPoints(); |
||
1173 | IEFMinimapButton_OffsetX = 12; |
||
1174 | IEFMinimapButton_OffsetY = -80; |
||
1175 | IEFMinimapButton:SetPoint("CENTER", "Minimap", "CENTER", IEFMinimapButton_OffsetX, IEFMinimapButton_OffsetY); |
||
1176 | end; |
||
1177 | -- Ensures the button travels around the minimap when dragged, not around your screen |
||
1178 | onUpdate = function() |
||
1179 | if (this.isMoving) then |
||
1180 | local mouseX, mouseY = GetCursorPosition(); |
||
1181 | local centerX, centerY = Minimap:GetCenter(); |
||
1182 | local scale = Minimap:GetScale(); |
||
1183 | mouseX = mouseX / scale; |
||
1184 | mouseY = mouseY / scale; |
||
1185 | local radius = (Minimap:GetWidth()/2) + (this:GetWidth()/3); |
||
1186 | local x = math.abs(mouseX - centerX); |
||
1187 | local y = math.abs(mouseY - centerY); |
||
1188 | local xSign = 1; |
||
1189 | local ySign = 1; |
||
1190 | if not (mouseX >= centerX) then |
||
1191 | xSign = -1; |
||
1192 | end |
||
1193 | if not (mouseY >= centerY) then |
||
1194 | ySign = -1; |
||
1195 | end |
||
1196 | local angle = math.atan(x/y); |
||
1197 | x = math.sin(angle)*radius; |
||
1198 | y = math.cos(angle)*radius; |
||
1199 | this.currentX = xSign*x; |
||
1200 | this.currentY = ySign*y; |
||
1201 | this:SetPoint("CENTER", "Minimap", "CENTER", this.currentX, this.currentY); |
||
1202 | end |
||
1203 | end; |
||
1204 | } |
||
1205 | } |
||
1206 | |||
1207 | ScriptErrors.Show = function() |
||
1208 | message(ScriptErrors_Message:GetText()); |
||
1209 | end |
||
1210 | |||
1211 | -- Converts SVN Rev tag to just a number, pass name of global variable with tag in quotes. |
||
1212 | function convertRev(revStr) |
||
1213 | if (type(revStr) == "table") then |
||
1214 | for k,v in revStr do |
||
1215 | local _, _, revNum = string.find(v, "^%$Rev: (%d+) %$"); |
||
1216 | if (revNum) then |
||
1217 | revStr[k] = revNum; |
||
1218 | end |
||
1219 | end |
||
1220 | elseif (type(revStr) == "string") then |
||
1221 | local _, _, revNum = string.find(getglobal(revStr), "^%$Rev: (%d+) %$"); |
||
1222 | if (revNum) then |
||
1223 | setglobal(revStr, revNum); |
||
1224 | end |
||
1225 | end |
||
1226 | end |
||
1227 | |||
1228 | -- ========================================================== |
||
1229 | -- == Hookable IEFMinimap functions |
||
1230 | -- ========================================================== |
||
1231 | function IEFMinimapButton_OnMouseDown() |
||
1232 | if (IsShiftKeyDown() and MouseIsOver(IEFMinimapButton)) then |
||
1233 | if ( arg1 == "RightButton" ) then |
||
1234 | --wait for reset |
||
1235 | else |
||
1236 | this.isMoving = true; |
||
1237 | end |
||
1238 | end |
||
1239 | end |
||
1240 | |||
1241 | function IEFMinimapButton_OnMouseUp() |
||
1242 | if (this.isMoving) then |
||
1243 | this.isMoving = false; |
||
1244 | IEFMinimapButton_OffsetX = this.currentX; |
||
1245 | IEFMinimapButton_OffsetY = this.currentY; |
||
1246 | elseif (MouseIsOver(IEFMinimapButton)) then |
||
1247 | if (IsShiftKeyDown() and (arg1 == "RightButton")) then |
||
1248 | ImprovedErrorFrame.Button.reset(); |
||
1249 | elseif (ImprovedErrorFrame.errorButtonActive) then |
||
1250 | ImprovedErrorFrame.showErrors(true); |
||
1251 | end |
||
1252 | end |
||
1253 | end |
||
1254 | |||
1255 | function IEFMinimapButton_OnHide() |
||
1256 | this.isMoving = false; |
||
1257 | end |
||
1258 | |||
1259 | -- Empty function to be hooked by error reporting AddOns |
||
1260 | function ImprovedErrorFrame_Report_OnClick(errorList) |
||
1261 | --[[ |
||
1262 | -- Hook this function if you care when the report button is clicked |
||
1263 | -- the table of errors is passed, see the notes at the top for the |
||
1264 | -- structure. |
||
1265 | --]] |
||
1266 | end |