vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- ****************
2 -- * AutoShoutOut *
3 -- ****************
4  
5 ASO_Version = "1.15.5";
6  
7 local ASO_Debug = false;
8 local ASO_Variables_Loaded = false;
9 local ASO_Initialized = false;
10 local ASO_RezStone_Warn_Done = false;
11 local ASO_BeenGivenRezStone = false;
12  
13 local ASO_CharacterName = nil;
14  
15 local ASO_InDuel = false;
16  
17 local ASO_Event_Type_Desc_Selected = nil;
18  
19 local ASO_LastShout = {
20 [ASO_LOCSTR_HEALTH] = 0,
21 [ASO_LOCSTR_LIFE] = 0,
22 [ASO_LOCSTR_MANA] = 0,
23 [ASO_LOCSTR_PETHEALTH] = 0,
24 [ASO_LOCSTR_REZSTONE] = 0
25 };
26  
27 local ASO_Events = {
28 [ASO_LOCSTR_HEALTH_LABEL] = ASO_LOCSTR_HEALTH,
29 [ASO_LOCSTR_LIFE_LABEL] = ASO_LOCSTR_LIFE,
30 [ASO_LOCSTR_MANA_LABEL] = ASO_LOCSTR_MANA,
31 [ASO_LOCSTR_PETHEALTH_LABEL] = ASO_LOCSTR_PETHEALTH,
32 [ASO_LOCSTR_REZSTONE_LABEL] = ASO_LOCSTR_REZSTONE
33 };
34  
35 local ASO_Settings = {
36 [ASO_LOCSTR_CONFIGS_PARTY_LABEL] = ASO_LOCSTR_CONFIGS_PARTY,
37 [ASO_LOCSTR_CONFIGS_RAID_LABEL] = ASO_LOCSTR_CONFIGS_RAID,
38 [ASO_LOCSTR_CONFIGS_SOLO_LABEL] = ASO_LOCSTR_CONFIGS_SOLO,
39 };
40  
41 ------------------------------------------------------------------------------------------
42  
43 function ASO_OnLoad()
44  
45 --Store default config values for later:
46 if (ASO_Debug) then
47 ASO_ChatMessage(ASO_LOCSTR_LOADING .. " AutoShoutOut v" .. ASO_Version);
48 message(ASO_LOCSTR_LOADING .. " AutoShoutOut v" .. ASO_Version .. "\n\nDebug Is ON!");
49 end
50  
51 -- add the slash commands
52 SlashCmdList["ASOCMD"] = function(msg)
53 ASO_Command(msg);
54 end
55 SLASH_ASOCMD1 = "/aso";
56 SLASH_ASOCMD2 = "/autoshoutout";
57  
58  
59 -- Register for events
60 ASO_Register_For_Events();
61  
62  
63 -- Hook our window up so that the ESCAPE key closes it...
64 tinsert(UISpecialFrames, "AutoShoutOutWindow")
65  
66 -- Let user know it was loaded, and how they can get help if they need it
67 ASO_ChatMessage("AutoShoutOut v" .. ASO_Version .. " " .. ASO_LOCSTR_GREETINGS);
68  
69 end
70  
71 ------------------------------------------------------------------------------------------
72  
73 function ASO_Register_For_Events()
74  
75 -- IF YOU ADD A NEW EVENT, ALSO ADD IT TO ASO_Unregister_For_Events() !!!
76  
77 --Register Events:
78 this:RegisterEvent("PLAYER_AURAS_CHANGED");
79 this:RegisterEvent("UNIT_AURA"); -- v1.15.0
80 this:RegisterEvent("UNIT_AURASTATE"); -- v1.15.0
81 this:RegisterEvent("UNIT_COMBAT"); -- v1.15.0
82 this:RegisterEvent("UNIT_HEALTH");
83 this:RegisterEvent("UNIT_MANA");
84  
85 -- Below for variables loading and UnitName("player") initializations...
86 this:RegisterEvent("VARIABLES_LOADED");
87 this:RegisterEvent("PLAYER_ENTERING_WORLD");
88 this:RegisterEvent("UNIT_NAME_UPDATE");
89  
90 -- Below for Druid changing form, so that UI 'Mana' event type can be enabled/disabled
91 -- this:RegisterEvent("UPDATE_SHAPESHIFT_FORMS"); -- This does not seem to work for some reason???
92 this:RegisterEvent("UNIT_MODEL_CHANGED"); -- Will use this instead of UPDATE_SHAPESHIFT_FORMS
93  
94 -- Below is for automatic switching of configurations
95 this:RegisterEvent("PARTY_MEMBERS_CHANGED");
96 this:RegisterEvent("RAID_ROSTER_UPDATE");
97 this:RegisterEvent("CHAT_MSG_SYSTEM"); -- Used for duel information
98  
99 -- "DUEL_REQUESTED" only works if player requests, not if player is requested, so
100 -- we'll parse the system chat messages instead for the countdown messages.
101 this:RegisterEvent("DUEL_FINISHED");
102  
103 end
104  
105 ------------------------------------------------------------------------------------------
106  
107 function ASO_Unregister_For_Events()
108  
109 -- IF YOU ADD A NEW EVENT, ALSO ADD IT TO ASO_Unregister_For_Events() !!!
110  
111 --Register Events:
112 this:UnregisterEvent("PLAYER_AURAS_CHANGED");
113 this:UnregisterEvent("UNIT_AURA"); -- v1.15.0
114 this:UnregisterEvent("UNIT_AURASTATE"); -- v1.15.0
115 this:UnregisterEvent("UNIT_COMBAT"); -- v1.15.0
116 this:UnregisterEvent("UNIT_HEALTH");
117 this:UnregisterEvent("UNIT_MANA");
118  
119 -- Below for variables loading and UnitName("player") initializations...
120 this:UnregisterEvent("VARIABLES_LOADED");
121 this:UnregisterEvent("PLAYER_ENTERING_WORLD");
122 this:UnregisterEvent("UNIT_NAME_UPDATE");
123  
124 -- Below for Druid changing form, so that UI 'Mana' event type can be enabled/disabled
125 -- this:UnregisterEvent("UPDATE_SHAPESHIFT_FORMS"); -- This does not seem to work for some reason???
126 this:UnregisterEvent("UNIT_MODEL_CHANGED"); -- Will use this instead of UPDATE_SHAPESHIFT_FORMS
127  
128 -- Below is for automatic switching of configurations
129 this:UnregisterEvent("PARTY_MEMBERS_CHANGED");
130 this:UnregisterEvent("RAID_ROSTER_UPDATE");
131 this:UnregisterEvent("CHAT_MSG_SYSTEM"); -- Used for duel information
132  
133 -- "DUEL_REQUESTED" only works if player requests, not if player is requested, so
134 -- we'll parse the system chat messages instead for the countdown messages.
135 this:UnregisterEvent("DUEL_FINISHED");
136  
137 end
138  
139 ------------------------------------------------------------------------------------------
140  
141 function ASO_Command(msg)
142  
143 if (ASO_Debug) then
144 ASO_ChatMessage(msg);
145 end
146  
147 -- If need to redo commands functionality in full,
148 -- use below code instead, cleaner/better...
149 --local ASO_Command_Words = {};
150 --for msg in string.gfind(msg, "(%S+)") do
151 -- table.insert(ASO_Command_Words, msg)
152 --end
153  
154 -- Break down msg (thank you ChatWatch dev!)
155 -- (%S+) are spaces, (%a+) is alphas but doesn't work with special foreign chars!
156 local firsti, lasti, command, arg1, arg2, arg3 = string.find(msg, "(%S+) (%S+) (%S+) (%S+)");
157  
158 -- command nill if only three arg (instead of four), so check again
159 if (command == nil) then
160 -- (%S+) are spaces, (%a+) is alphas but doesn't work with special foreign chars!
161 firsti, lasti, command, arg1, arg2 = string.find(msg, "(%S+) (%S+) (%S+)");
162 end
163  
164 -- command nill if only two arg (instead of three), so check again
165 if (command == nil) then
166 -- (%S+) are spaces, (%a+) is alphas but doesn't work with special foreign chars!
167 firsti, lasti, command, arg1 = string.find(msg, "(%S+) (%S+)");
168 end
169  
170 -- command nill if only one arg (instead of two), so check again
171 if (command == nil) then
172 -- (%S+) are spaces, (%a+) is alphas but doesn't work with special foreign chars!
173 firsti, lasti, command = string.find(msg, "(%S+)");
174 end
175  
176 if (ASO_Debug) then
177 ASO_ChatMessage("Command...");
178 ASO_ChatMessage(command);
179 ASO_ChatMessage("Args...");
180 ASO_ChatMessage(arg1);
181 ASO_ChatMessage(arg2);
182 ASO_ChatMessage(arg3);
183 ASO_ChatMessage(arg4);
184 ASO_ChatMessage(arg5);
185 ASO_ChatMessage(arg6);
186 ASO_ChatMessage(arg7);
187 ASO_ChatMessage(arg8);
188 ASO_ChatMessage(arg9);
189 ASO_ChatMessage("Original string...");
190 ASO_ChatMessage(msg);
191 end
192  
193 -- Now that we have user-supplied info, lets do something
194 if ( (command ~= nil) and (string.lower(command) == ASO_LOCSTR_DEBUG) ) then
195  
196 if (AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL]) then
197 AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL] = false;
198 ASO_Debug = AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL];
199 message("AutoShoutOut v" .. ASO_Version .. "\n\n"..ASO_LOCSTR_DEBUG_LABEL.." Is "..string.upper(ASO_LOCSTR_OFF)..".");
200 else
201 AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL] = true;
202 ASO_Debug = AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL];
203 message("AutoShoutOut v" .. ASO_Version .. "\n\n"..ASO_LOCSTR_DEBUG_LABEL.." Is "..string.upper(ASO_LOCSTR_ON).."!");
204 end
205  
206 elseif ( (command ~= nil) and (string.lower(command) == ASO_LOCSTR_ON) ) then
207  
208 AutoShoutOut.NotifyingEnabled = true;
209 ASO_ChatMessage(ASO_LOCSTR_OUTPUT_MSG2 .. " " .. ASO_LOCSTR_ON .. ".");
210 ASO_Register_For_Events();
211  
212 elseif ( (command ~= nil) and (string.lower(command) == ASO_LOCSTR_OFF) ) then
213  
214 if ( AutoShoutOutWindow:IsVisible() ) then
215 ASO_Window_Hide();
216 end
217  
218 AutoShoutOut.NotifyingEnabled = false;
219 ASO_ChatMessage(ASO_LOCSTR_OUTPUT_MSG2 .. " " .. ASO_LOCSTR_OFF .. ".");
220 ASO_Unregister_For_Events();
221  
222 elseif ( (command ~= nil) and (string.lower(command) == ASO_LOCSTR_STATUS) ) then
223  
224 if ( ASO_IsStatusOutput() ) then
225 AutoShoutOut.StatusOutput = false;
226 else
227 AutoShoutOut.StatusOutput = true;
228 end
229  
230 local text = ASO_LOCSTR_OUTPUT_MSG1 .. " ";
231 if (ASO_IsStatusOutput()) then
232 text = text .. ASO_LOCSTR_ON .. ".";
233 else
234 text = text .. ASO_LOCSTR_OFF .. ".";
235 end
236  
237 ASO_ChatMessage(text);
238  
239 elseif ( (command ~= nil) and (string.lower(command) == ASO_LOCSTR_WARNMSGS) ) then
240  
241 if ( ASO_IsWarnMsgs() ) then
242 AutoShoutOut.WarnMsgs = false;
243 else
244 AutoShoutOut.WarnMsgs = true;
245 end
246  
247 local text = ASO_LOCSTR_OUTPUT_MSG4 .. " ";
248 if (ASO_IsWarnMsgs()) then
249 text = text .. ASO_LOCSTR_ON .. ".";
250 else
251 text = text .. ASO_LOCSTR_OFF .. ".";
252 end
253  
254 ASO_ChatMessage(text);
255  
256 elseif ( (command ~= nil) and (string.lower(command) == ASO_LOCSTR_RESET) ) then
257  
258 ASO_Confirm_Reinitalize_AutoShoutOut_Table();
259  
260 elseif ( (command ~= nil) and (string.lower(command) == "buffs") ) then -- Debugging purposes only
261  
262 ASO_ShowAllUnitBuffs("player");
263 ASO_ChatMessage("Rez Stone? " .. ASO_BooleanToString( ASO_HasRezStone() ) );
264  
265 else
266  
267 if ( ASO_IsNotifyingEnabled() ) then
268  
269 if (ASO_Debug) then
270 if ( (ASO_LOCSTR_CHARACTER ~= nil) and (ASO_CharacterName ~= nil) ) then
271 ASO_ChatMessage(ASO_LOCSTR_CHARACTER .. ": " .. ASO_CharacterName);
272 end
273 end
274  
275 ASO_Window_Toggle();
276  
277 else
278  
279 message(ASO_LOCSTR_OUTPUT_MSG3);
280  
281 end
282  
283 end
284  
285 end
286  
287 ------------------------------------------------------------------------------------------
288  
289 function ASO_SetMessage(type, settings, target, msg)
290  
291 if (string.lower(target) == ASO_LOCSTR_ON) then
292 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].MessageEnabled = true;
293 elseif (string.lower(target) == ASO_LOCSTR_OFF) then
294 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].MessageEnabled = false;
295 else
296 if ( ASO_IsStringLOCAL(target) or ASO_IsStringSAY(target) or ASO_IsStringPARTY(target) or ASO_IsStringRAID(target) ) then
297 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].MessageTarget = string.upper(target);
298 else
299 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].MessageTarget = target;
300 end
301 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].MessageText = msg;
302 end
303  
304 end
305  
306 ------------------------------------------------------------------------------------------
307  
308 function ASO_SetNotifyCondition(type, settings, msg)
309  
310 if (string.lower(msg) == ASO_LOCSTR_COMBAT) then
311 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].NotifyCombatOnly = true;
312 else
313 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].NotifyCombatOnly = false;
314 end
315  
316 end
317  
318 ------------------------------------------------------------------------------------------
319  
320 function ASO_SetNotifyDuringDuel(type, settings, msg)
321  
322 if (string.lower(msg) == ASO_LOCSTR_ON) then
323 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].NotifyDuringDuel = true;
324 else
325 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].NotifyDuringDuel = false;
326 end
327  
328 end
329  
330 ------------------------------------------------------------------------------------------
331  
332 function ASO_SetShout(type, settings, msg)
333  
334 if (string.lower(msg) == ASO_LOCSTR_ON) then
335 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].ShoutEnabled = true;
336 else
337 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].ShoutEnabled = false;
338 end
339  
340 end
341  
342 ------------------------------------------------------------------------------------------
343  
344 function ASO_SetNotifyPercent(type, settings, msg)
345  
346 msg = tonumber(msg);
347 if (msg == nil) then
348 return;
349 end
350  
351 local lowValue = 0;
352 local highValue = 99;
353  
354 if (msg >= lowValue) and (msg <= highValue) then
355 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].NotifyPercent = msg;
356 else
357 local temp = "'"..type.."' "..ASO_LOCSTR_SET_NOTIFY_PERCENT2.." "..lowValue.." & "..highValue.."!";
358 message(ASO_LOCSTR_TITLE.."\n"..temp);
359 end
360  
361 end
362  
363 ------------------------------------------------------------------------------------------
364  
365 function ASO_SetNotifyFrequency(type, settings, seconds)
366  
367 local seconds = tonumber(seconds);
368 if (type == nil or seconds == nil) then
369 return;
370 end
371  
372 local lowValue = 1;
373 local highValue = 999;
374  
375 if (seconds >= lowValue) and (seconds <= highValue) then
376 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][settings][type].NotifyFrequency = seconds;
377 else
378 local temp = "'"..type.."' "..ASO_LOCSTR_SET_NOTIFY_FREQUENCY2.." "..lowValue.." & "..highValue.."!";
379 message(ASO_LOCSTR_TITLE.."\n"..temp);
380 end
381  
382 end
383  
384 ------------------------------------------------------------------------------------------
385  
386 function ASO_BooleanToString(bool)
387 if (bool == true) then
388 return ASO_LOCSTR_TRUE;
389 else
390 return ASO_LOCSTR_FALSE;
391 end
392 end
393  
394 ------------------------------------------------------------------------------------------=
395  
396 function ASO_Initialize()
397  
398 -- UnitName('player') init coding logic from Iriel - Thanks! :)
399 -- "http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=46282&tmp=1#post46282"
400  
401 if (ASO_Debug) then
402 DEFAULT_CHAT_FRAME:AddMessage("AutoShoutOut - ASO_Initialized: " .. ASO_BooleanToString(ASO_Initialized), 1.0,1.0,1.0 );
403 DEFAULT_CHAT_FRAME:AddMessage("AutoShoutOut - ASO_Variables_Loaded: " .. ASO_BooleanToString(ASO_Variables_Loaded), 1.0,1.0,1.0 );
404 DEFAULT_CHAT_FRAME:AddMessage("AutoShoutOut - UnitName(\"player\"): " .. UnitName("player"), 1.0,1.0,1.0 );
405 end
406  
407 -- Have all conditions been met so that initialization can be done?
408 if (ASO_Initialized or
409 (not ASO_Variables_Loaded) or
410 (not UnitName("player")) or
411 (UnitName("player") == UNKNOWNOBJECT) -- "Unknown Entity")
412 ) then
413  
414 if (ASO_Debug) then
415 DEFAULT_CHAT_FRAME:AddMessage("AutoShoutOut - " .. ASO_LOCSTR_DEBUG_MSG5, 1.0,1.0,1.0);
416 end
417  
418 return;
419  
420 end
421  
422 -- Do any post loading of SavedVariables.lua processing
423  
424 -- Assign the character name to be used throughout the run of the add-on...
425 ASO_CharacterName = UnitName("player");
426 ASO_ShowCharacterNameErrorIfError();
427  
428 if (ASO_Debug) then
429 DEFAULT_CHAT_FRAME:AddMessage(ASO_LOCSTR_DEBUG_MSG6 .. " [" .. ASO_GetCharacterName() .. "]", 1.0,1.0,1.0);
430 end
431  
432 -- New per-player table definition for first-time running new version that has it
433 ASO_Initalize_AutoShoutOut_Table();
434  
435  
436 -- Add AutoShoutOut to myAddOns addons list
437 if(myAddOnsFrame) then
438 if (ASO_Debug) then
439 DEFAULT_CHAT_FRAME:AddMessage("AutoShoutOut "..ASO_LOCSTR_DEBUG_MSG7.." myAddOns!", 1.0,1.0,1.0);
440 end
441 myAddOnsList.AutoShoutOut = {name = ASO_LOCSTR_TITLE, description = ASO_LOCSTR_MYADDONS_DESCRIPTION, version = ASO_Version, category = MYADDONS_CATEGORY_COMBAT, frame = "AutoShoutOut", optionsframe = "AutoShoutOutWindow"};
442 end
443  
444 ASO_Build_Event_Strings();
445  
446 -- We have been initialized!
447 ASO_Initialized = true;
448  
449 end
450  
451 ------------------------------------------------------------------------------------------
452  
453 function ASO_GetCharacterName()
454 ASO_ShowCharacterNameErrorIfError();
455 return ASO_CharacterName;
456 end
457  
458 ------------------------------------------------------------------------------------------
459  
460 function ASO_ShowCharacterNameErrorIfError()
461  
462 if ( (not ASO_CharacterName) or (ASO_CharacterName == UNKNOWNOBJECT) ) then
463 local tempMsg = "AutoShoutOut\n\n" .. ASO_LOCSTR_CHARNAME_ERROR;
464 ASO_ChatMessage(tempMsg);
465 ASO_CombatMessage(tempMsg);
466 ASO_BannerMessage(tempMsg);
467 message(tempMsg);
468 end
469  
470 end
471  
472 ------------------------------------------------------------------------------------------
473  
474 function ASO_Confirm_Reinitalize_AutoShoutOut_Table()
475  
476 -- table.insert(StaticPopupDialogs, "AUTOSHOUTOUT_DIALOG");
477  
478 StaticPopupDialogs["AUTOSHOUTOUT_DIALOG"] = {
479 text = ASO_LOCSTR_CONFIRM_TABLE_INIT,
480 button1 = TEXT(ACCEPT),
481 button2 = TEXT(CANCEL),
482 showAlert = 1,
483 timeout = 0,
484 OnAccept = function()
485 ASO_Reinitalize_AutoShoutOut_Table();
486 end,
487 };
488  
489 StaticPopup_Show("AUTOSHOUTOUT_DIALOG");
490  
491 end
492  
493 ------------------------------------------------------------------------------------------
494  
495 function ASO_Reinitalize_AutoShoutOut_Table()
496  
497 ASO_ChatMessage("AutoShoutOut " .. ASO_LOCSTR_TABLE_INIT, 1.0, 1.0, 1.0);
498  
499 if (ASO_Debug) then
500 ASO_ChatMessage("ASO_Reinitalize_AutoShoutOut_Table()", 0.5, 0.5, 0.5);
501 end
502  
503 -- Reset the current character's info, not ALL of the character's info!
504 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()] = {}
505 ASO_Initalize_AutoShoutOut_Table();
506  
507 ASO_Window_Initialize();
508  
509 end
510  
511 ------------------------------------------------------------------------------------------
512  
513 function ASO_GetCharactersRealmName()
514  
515 -- Idea of using GetCVar("RealmName") from HunterBar FeedButton add-on
516 local RealmName = GetCVar("RealmName");
517  
518 if (RealmName == nil) then
519 RealmName = "UNKNOWN";
520 end
521  
522 return RealmName;
523  
524 end
525  
526 ------------------------------------------------------------------------------------------
527  
528 function ASO_Initalize_AutoShoutOut_Table()
529  
530 if ( not AutoShoutOut ) then
531 AutoShoutOut = {};
532 end
533  
534 -- Don't need to test because we always want to overwrite this value!
535 AutoShoutOut.Version = ASO_Version;
536  
537 if ( AutoShoutOut.NotifyingEnabled == nil ) then
538 AutoShoutOut.NotifyingEnabled = true; -- v1.14.0
539 end
540  
541 if ( AutoShoutOut.StatusOutput == nil ) then
542 AutoShoutOut.StatusOutput = true; -- v1.10.2
543 end
544  
545 if ( AutoShoutOut.WarnMsgs == nil ) then
546 AutoShoutOut.WarnMsgs = true; -- v1.15.2
547 end
548  
549 if ( not AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL] ) then
550 AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL] = false; -- v1.13.3
551 end
552 ASO_Debug = AutoShoutOut[ASO_LOCSTR_DEBUG_LABEL];
553  
554 if ( not AutoShoutOut[ASO_LOCSTR_REALM] ) then
555 AutoShoutOut[ASO_LOCSTR_REALM] = {};
556 end
557  
558 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()] ) then
559 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()] = {};
560 end
561  
562 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER] ) then
563 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER] = {};
564 end
565  
566 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()] ) then
567 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()] = {};
568 end
569  
570 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS] ) then
571 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS] = {};
572 end
573  
574 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] ) then
575 ASO_Set_Active_Configuration(ASO_LOCSTR_CONFIGS_SOLO);
576 end
577  
578 -- v1.12.0
579 if ( not ASO_IsAutoSwitch() ) then
580 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_AUTOSWITCH] = false;
581 end
582  
583  
584 for key,value in pairs(ASO_Settings) do
585  
586 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value] ) then
587 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value] = {};
588 end
589  
590 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]] ) then
591  
592 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]] = {};
593  
594 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].NotifyPercent = 30;
595 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].NotifyFrequency = 10;
596 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].NotifyCombatOnly = true;
597 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].NotifyDuringDuel = false; -- v1.12.0
598  
599 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].ShoutEnabled = true;
600 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].ShoutEmote = ASO_LOCSTR_DOEMOTE_HEALME;
601  
602 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].MessageEnabled = false;
603  
604 if (value == ASO_LOCSTR_CONFIGS_PARTY) then
605 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].MessageTarget = ASO_LOCSTR_PARTY;
606 elseif (value == ASO_LOCSTR_CONFIGS_RAID) then
607 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].MessageTarget = ASO_LOCSTR_RAID;
608 else
609 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].MessageTarget = ASO_LOCSTR_LOCAL; -- ASO_GetCharacterName();
610 end
611  
612 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_HEALTH_LABEL]].MessageText = ASO_LOCSTR_DEFAULT_MESSAGE_HEALTH;
613  
614 end
615  
616 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]] ) then
617  
618 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]] = {};
619  
620 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].NotifyPercent = 25;
621 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].NotifyFrequency = 10;
622 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].NotifyCombatOnly = true;
623 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].NotifyDuringDuel = false; -- v1.12.0
624  
625 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].ShoutEnabled = false;
626 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].ShoutEmote = nil;
627  
628 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].MessageEnabled = true;
629  
630 if (value == ASO_LOCSTR_CONFIGS_PARTY) then
631 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].MessageTarget = ASO_LOCSTR_PARTY;
632 elseif (value == ASO_LOCSTR_CONFIGS_RAID) then
633 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].MessageTarget = ASO_LOCSTR_RAID;
634 else
635 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].MessageTarget = ASO_LOCSTR_LOCAL; -- ASO_GetCharacterName();
636 end
637  
638 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]].MessageText = ASO_LOCSTR_DEFAULT_MESSAGE_PETHEALTH;
639  
640 end
641  
642 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]] ) then
643  
644 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]] = {};
645  
646 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].NotifyPercent = 15;
647 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].NotifyFrequency = 10;
648 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].NotifyCombatOnly = true;
649 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].NotifyDuringDuel = false; -- v1.12.0
650  
651 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].ShoutEnabled = true;
652 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].ShoutEmote = ASO_LOCSTR_DOEMOTE_HELPME;
653  
654 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].MessageEnabled = false;
655  
656 if (value == ASO_LOCSTR_CONFIGS_PARTY) then
657 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].MessageTarget = ASO_LOCSTR_PARTY;
658 elseif (value == ASO_LOCSTR_CONFIGS_RAID) then
659 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].MessageTarget = ASO_LOCSTR_RAID;
660 else
661 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].MessageTarget = ASO_LOCSTR_LOCAL; -- ASO_GetCharacterName();
662 end
663  
664 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].MessageText = ASO_LOCSTR_DEFAULT_MESSAGE_LIFE;
665  
666 end
667  
668 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]] ) then
669  
670 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]] = {};
671  
672 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].NotifyPercent = 5;
673 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].NotifyFrequency = 15;
674 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].NotifyCombatOnly = true;
675 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].NotifyDuringDuel = false; -- v1.12.0
676  
677 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].ShoutEnabled = true;
678 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].ShoutEmote = ASO_LOCSTR_DOEMOTE_OOM;
679  
680 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].MessageEnabled = false;
681  
682 if (value == ASO_LOCSTR_CONFIGS_PARTY) then
683 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].MessageTarget = ASO_LOCSTR_PARTY;
684 elseif (value == ASO_LOCSTR_CONFIGS_RAID) then
685 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].MessageTarget = ASO_LOCSTR_RAID;
686 else
687 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].MessageTarget = ASO_LOCSTR_LOCAL; -- ASO_GetCharacterName();
688 end
689  
690 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_MANA_LABEL]].MessageText = ASO_LOCSTR_DEFAULT_MESSAGE_MANA;
691  
692 end
693  
694 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]] ) then -- v1.15.0
695  
696 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]] = {};
697  
698 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].NotifyPercent = 100;
699 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].NotifyFrequency = 60;
700 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].NotifyCombatOnly = false;
701 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].NotifyDuringDuel = false; -- v1.12.0
702  
703 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].ShoutEnabled = false;
704 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].ShoutEmote = nil;
705  
706 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].MessageEnabled = false;
707  
708 if (value == ASO_LOCSTR_CONFIGS_PARTY) then
709 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].MessageTarget = ASO_LOCSTR_PARTY;
710 elseif (value == ASO_LOCSTR_CONFIGS_RAID) then
711 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].MessageTarget = ASO_LOCSTR_RAID;
712 else
713 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].MessageTarget = ASO_LOCSTR_LOCAL; -- ASO_GetCharacterName();
714 end
715  
716 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][value][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].MessageText = ASO_LOCSTR_DEFAULT_MESSAGE_REZSTONE;
717  
718 end
719  
720 end
721  
722 end
723  
724 ------------------------------------------------------------------------------------------
725  
726 -- Used for pattern matching system messages to determine if user in/out of duel
727  
728 function ASO_Build_Event_Strings()
729  
730 -- Vars from "FrameXML\GlobalStrings.lua"
731  
732 if (ASO_Debug) then
733 ASO_ChatMessage(DUEL_COUNTDOWN, 0.5, 0.5, 0.5);
734 --ASO_ChatMessage(ERR_DUEL_CANCELLED, 0.5, 0.5, 0.5);
735 --ASO_ChatMessage(DUEL_WINNER_KNOCKOUT, 0.5, 0.5, 0.5);
736 --ASO_ChatMessage(DUEL_WINNER_RETREAT, 0.5, 0.5, 0.5);
737 ASO_ChatMessage("-----");
738 end
739  
740 -- We strip out any argument value markers in the default strings
741 -- like player names (%s / %1), or time left (%d), etc. These substrings
742 -- are then used later to parse though event mesages that come in, to see
743 -- if all of the words in these substrings exist in the received message.
744  
745 ASO_SYSMSG_DUEL_COUNTDOWN = string.gsub(DUEL_COUNTDOWN,"%%d","");
746 if (ASO_Debug) then
747 ASO_ChatMessage("[" .. ASO_SYSMSG_DUEL_COUNTDOWN .. "]", 0.5, 1.5, 0.5);
748 end
749  
750 -- Event DUEL_FINISHED should handle the ending of a duel for both parties.
751  
752 --ASO_SYSMSG_DUEL_WINNER_KNOCKOUT = string.gsub(DUEL_WINNER_KNOCKOUT,"%%1%$s","");
753 --ASO_SYSMSG_DUEL_WINNER_KNOCKOUT = string.gsub(ASO_SYSMSG_DUEL_WINNER_KNOCKOUT,"%%2%$s","");
754 --if (ASO_Debug) then
755 -- ASO_ChatMessage("[" .. ASO_SYSMSG_DUEL_WINNER_KNOCKOUT .. "]", 0.5, 1.5, 0.5);
756 --end
757  
758 --ASO_SYSMSG_DUEL_WINNER_RETREAT = string.gsub(DUEL_WINNER_RETREAT,"%%2%$s","");
759 --ASO_SYSMSG_DUEL_WINNER_RETREAT = string.gsub(ASO_SYSMSG_DUEL_WINNER_RETREAT,"%%1%$s","");
760 --if (ASO_Debug) then
761 -- ASO_ChatMessage("[" .. ASO_SYSMSG_DUEL_WINNER_RETREAT .. "]", 0.5, 1.5, 0.5);
762 --end
763  
764 end
765  
766 ------------------------------------------------------------------------------------------
767  
768 -- We intercept the ItemRef:SetItemRef(link, button) method call, to see if the user did a
769 -- ctrl-left-click, which means they want to target the source of the message.
770 local OLD_SetItemRef = SetItemRef;
771 function SetItemRef(link, text, button)
772 if ( strsub(link, 1, 6) == "player" ) then
773 local name = strsub(link, 8);
774 if ( name and (strlen(name) > 0) ) then
775 -- name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2");
776 if ( button == "LeftButton" and IsControlKeyDown() ) then
777  
778 local targetName = UnitName("target");
779 if (ASO_debug) then
780 if (targetName ~= nil) then
781 ASO_ChatMessage("targetName: " .. targetName);
782 else
783 ASO_ChatMessage("targetName: nil!");
784 end
785 end
786  
787 -- If already targeted, target pet if unit has one
788 if (name == targetName) then
789  
790 if (ASO_Debug) then
791 ASO_ChatMessage("AutoShoutOut: Targeting ["..name.."]'s pet!");
792 end
793  
794 -- TargetUnitsPet(Unit) was deprecated in WoW v1.6!
795 -- v1.15.3 (for WoW 1.6) (Thank you Silmalia (http://forums.worldofwarcraft.com/thread.aspx?ForumName=wow-interface-customization&ThreadID=179460))
796 if(not TargetUnitsPet) then
797 TargetUnitsPet = function(name)
798 -- THIS IS NOT WORKING!
799 TargetUnit(name.."pet"); -- Only works in party/raid
800 end
801 end
802 TargetUnitsPet("target");
803  
804 -- Not already targeted, so try and target
805 else
806  
807 if (ASO_Debug) then
808 ASO_ChatMessage("AutoShoutOut: Targeting ["..name.."]");
809 end
810  
811 TargetByName(name);
812  
813 -- Lets verify that unit was targeted successfully
814 targetName = UnitName("target");
815 if (name ~= targetName) then
816 -- Something went wrong!
817 message(ASO_LOCSTR_TITLE.."\n\n" .. ASO_LOCSTR_TARGET_ERROR .. " ["..name.."]!");
818 ClearTarget();
819 end
820  
821 end
822  
823 else
824 OLD_SetItemRef(link, text, button);
825 end
826 end
827 return;
828  
829 else
830 OLD_SetItemRef(link, text, button);
831 end
832  
833 end
834  
835 ------------------------------------------------------------------------------------------
836  
837 function ASO_OnEvent(event)
838  
839 if (ASO_Debug) then
840 local msg = "ASO_OnEvent: ";
841 if (event ~= nil) then
842 msg = msg .. event;
843 end
844 if (arg1 ~= nil) then
845 msg = msg .. " arg1: " .. arg1;
846 end
847 if (arg2 ~= nil) then
848 msg = msg .. " arg2: " .. arg2;
849 end
850 if (arg3 ~= nil) then
851 msg = msg .. " arg3: " .. arg3;
852 end
853 if (arg4 ~= nil) then
854 msg = msg .. " arg4: " .. arg4;
855 end
856 if (arg5 ~= nil) then
857 msg = msg .. " arg5: " .. arg5;
858 end
859 if (arg6 ~= nil) then
860 msg = msg .. " arg6: " .. arg6;
861 end
862 if (arg7 ~= nil) then
863 msg = msg .. " arg7: " .. arg7;
864 end
865 if (arg8 ~= nil) then
866 msg = msg .. " arg8: " .. arg8;
867 end
868 if (arg9 ~= nil) then
869 msg = msg .. " arg9: " .. arg9;
870 end
871 ASO_CombatMessage(msg);
872 end
873  
874  
875 -- Have the SavedVariables.lua variables been loaded in yet?
876 if (event == "VARIABLES_LOADED") then
877 ASO_Variables_Loaded = true;
878 ASO_Initialize();
879 end
880  
881  
882 -- Has the player been fully loaded into the world for the first time or after '/console reloadui'?
883 if ( (event == "PLAYER_ENTERING_WORLD") or (event == "UNIT_NAME_UPDATE") ) then
884 ASO_Initialize();
885 end
886  
887  
888 -- If all pre-processing has been done, then do normal operations...
889 if (ASO_Initialized == true) then
890  
891  
892 if (UnitIsDeadOrGhost("player")) then
893  
894 if (ASO_Debug) then
895 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG8);
896 end
897 return;
898  
899 end
900  
901  
902 -- Warn user that Soulstone Resurrection was applied to them
903 -- but AutoShoutOut is not watching for it to go away...
904 if ( (event == "PLAYER_AURAS_CHANGED") or (event == "UNIT_AURA") or (event == "UNIT_AURASTATE") ) then -- v1.15.0
905 if ( not ASO_HasBeenGivenRezStone() ) then
906 if ( ASO_HasRezStone() ) then
907 if ( not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] ][ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]].MessageEnabled ) then
908 if ( not ASO_RezStone_Warn_Done ) then
909 if ( ASO_IsWarnMsgs() ) then
910 message(ASO_LOCSTR_TITLE .. "\n"..ASO_LOCSTR_REZSTONE_WARNING);
911 end
912 ASO_RezStone_Warn_Done = true;
913 end
914 end
915 ASO_BeenGivenRezStone = true;
916 -- ASO_CombatMessage("ASO_BeenGivenRezStone = " .. ASO_BooleanToString(ASO_BeenGivenRezStone), 1.0,1.0,1.0);
917 else
918 -- Reset warning message tracker if Soulstone Resurrection buff goes away...
919 ASO_RezStone_Warn_Done = false;
920 end
921 -- elseif ( not ASO_HasRezStone() ) then
922 -- ASO_BeenGivenRezStone = false;
923 ---- ASO_CombatMessage("ASO_BeenGivenRezStone = " .. ASO_BooleanToString(ASO_BeenGivenRezStone), 1.0,1.0,1.0);
924 end
925 end
926  
927  
928 if (event == "UNIT_MODEL_CHANGED") then -- event == "UPDATE_SHAPESHIFT_FORMS"
929  
930 -- Want the Mana event type to be disabled if the Druid
931 -- shapeshifts into a form that doesn't have mana.
932 ASO_Window_Initialize();
933  
934 end
935  
936  
937 if (event == "DUEL_FINISHED") then
938 ASO_SetInDuel(false);
939 end
940  
941  
942 if (event == "CHAT_MSG_SYSTEM") then
943  
944 if (ASO_Debug) then
945 ASO_ChatMessage("*** CHAT_MSG_SYSTEM ***");
946 ASO_ChatMessage("1");
947 ASO_ChatMessage(arg1);
948 --ASO_ChatMessage("2");
949 --ASO_ChatMessage(arg2);
950 --ASO_ChatMessage("3");
951 --ASO_ChatMessage(arg3);
952 ASO_ChatMessage("---------------");
953  
954 end
955  
956 -- Dueling
957 -- Vars from "FrameXML\GlobalStrings.lua"
958 -- DUEL_REQUESTED = "%s has challenged you to a duel.";
959 -- ERR_DUEL_REQUESTED = "You have requested a duel.";
960 if ASO_IsWordsInString(arg1, ASO_SYSMSG_DUEL_COUNTDOWN) then -- DUEL_COUNTDOWN = "Duel starting: %d"; -- %d is the number of seconds until the beginning of the duel.
961 ASO_SetInDuel(true);
962 -- Don't need to parse system message for finish of dueling as there's an event for it (see above)!
963 --elseif (arg1 == ERR_DUEL_CANCELLED) then -- ERR_DUEL_CANCELLED = "Duel cancelled.";
964 -- ASO_SetInDuel(false);
965 --elseif ASO_IsWordsInString(arg1, ASO_SYSMSG_DUEL_WINNER_KNOCKOUT) then -- DUEL_WINNER_KNOCKOUT = "%1$s has defeated %2$s in a duel"; -- %1$s is the winner, %2$s is the loser
966 -- ASO_SetInDuel(false);
967 --elseif ASO_IsWordsInString(arg1, ASO_SYSMSG_DUEL_WINNER_RETREAT) then -- DUEL_WINNER_RETREAT = "%2$s has fled from %1$s in a duel"; -- %1$s is the winner, %2$s is the loser
968 -- ASO_SetInDuel(false);
969 end
970  
971 end
972  
973  
974 -- Auto switching to PARTY/RAID
975 if ( ASO_IsAutoSwitch() ) then
976  
977 if ( ASO_Debug ) then
978 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG19);
979 end
980  
981 if ( ASO_IsInRaid() ) then
982  
983 if ( ASO_Debug ) then
984 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG20);
985 end
986  
987 if ( not ASO_IsActiveConfigRaid() ) then
988  
989 if ( ASO_Debug ) then
990 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG21);
991 end
992  
993 ASO_Set_Active_Configuration( ASO_LOCSTR_CONFIGS_RAID );
994 ASO_Window_Initialize(true);
995  
996 end
997  
998 elseif ( ASO_IsInParty() ) then
999  
1000 if ( ASO_Debug ) then
1001 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG22);
1002 end
1003  
1004 if ( not ASO_IsActiveConfigParty() ) then
1005  
1006 if ( ASO_Debug ) then
1007 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG23);
1008 end
1009  
1010 ASO_Set_Active_Configuration( ASO_LOCSTR_CONFIGS_PARTY );
1011 ASO_Window_Initialize(true);
1012  
1013 end
1014  
1015 else -- default to 'Solo'
1016  
1017 if ( ASO_Debug ) then
1018 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG24);
1019 end
1020  
1021 if ( not ASO_IsActiveConfigSolo() ) then
1022  
1023 if ( ASO_Debug ) then
1024 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG25);
1025 end
1026  
1027 ASO_Set_Active_Configuration( ASO_LOCSTR_CONFIGS_SOLO );
1028 ASO_Window_Initialize(true);
1029  
1030 end
1031  
1032 end
1033  
1034 end
1035  
1036  
1037 -- Check Life before Health, as its more important, so
1038 -- it doesn't get lost because only one or the other is
1039 -- ever done (on seperate timers but Health will not be
1040 -- done if Life needs to be done!).
1041 if ( ASO_IsNotifyingEnabled() ) then
1042  
1043 ASO_CheckLife();
1044 ASO_CheckHealth();
1045 ASO_CheckMana();
1046 ASO_CheckPetHealth();
1047 ASO_CheckRezStone();
1048  
1049 end
1050  
1051 end
1052  
1053 end
1054  
1055 ------------------------------------------------------------------------------------------
1056  
1057 function ASO_IsWordsInString(sysmsg, aso_sysmsg)
1058  
1059 if (ASO_Debug) then
1060 ASO_ChatMessage("SysMsg: " .. sysmsg );
1061 ASO_ChatMessage("ASO SysMsg: " .. aso_sysmsg );
1062 end
1063  
1064 counterFound = 0;
1065 counterMissed = 0;
1066  
1067 if ( not (sysmsg == nil) ) then
1068  
1069 -- Can cause 'C Stack Overflow' errors for some reason!?!?
1070 for w in string.gfind(aso_sysmsg, "(%S+)") do -- (%S+) are spaces, (%a+) is alphas but doesn't work with special foreign chars!
1071  
1072 i, j = string.find(sysmsg, w);
1073 if (i == nil) then
1074 counterMissed = counterMissed + 1;
1075 else
1076 counterFound = counterFound + 1;
1077 end
1078  
1079 end
1080  
1081 if (ASO_Debug) then
1082 ASO_ChatMessage("Found: " .. tostring( counterFound ) );
1083 ASO_ChatMessage("Missed: " .. tostring( counterMissed ) );
1084 end
1085  
1086 -- If new system messages show up with more than two args,
1087 -- counterMissed counter value will need to be changed!
1088 if ( counterMissed == 0 ) then
1089 return true;
1090 else
1091 return false;
1092 end
1093  
1094 end
1095  
1096 end
1097  
1098 ------------------------------------------------------------------------------------------
1099  
1100 function ASO_CheckHealth()
1101  
1102 -- Don't do health notifications if life notifications need to be done!
1103 -- Otherwise do health notifications.
1104  
1105 -- A health notification needs to be done
1106 if ( ASO_IsHealthPointsLow( ASO_Events[ASO_LOCSTR_HEALTH_LABEL] ) ) then
1107  
1108 -- If not doing any kind of life notifications do low health notifications
1109 if ( (not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] ][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].ShoutEnabled) and
1110 (not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] ][ASO_Events[ASO_LOCSTR_LIFE_LABEL]].MessageEnabled) ) then
1111  
1112 if (ASO_Debug) then
1113 ASO_ChatMessage("'" .. ASO_LOCSTR_HEALTH_LABEL .. "' " .. ASO_LOCSTR_DEBUG_MSG18);
1114 end
1115  
1116 ASO_UseGeneric(ASO_Events[ASO_LOCSTR_HEALTH_LABEL]);
1117  
1118 -- Life notifications could have been done, so check if the life percentage
1119 -- threshold has not been met. If it has not, then do low health notifications
1120 elseif ( not ASO_IsHealthPointsLow( ASO_Events[ASO_LOCSTR_LIFE_LABEL] ) ) then
1121  
1122 if (ASO_Debug) then
1123 ASO_ChatMessage("'" .. ASO_LOCSTR_HEALTH_LABEL .. "' " .. ASO_LOCSTR_DEBUG_MSG18);
1124 end
1125  
1126 ASO_UseGeneric(ASO_Events[ASO_LOCSTR_HEALTH_LABEL]);
1127  
1128 end
1129  
1130 -- Otherwise a life notification should have already been done in function ASO_OnEvent(event)!
1131  
1132 end
1133  
1134 return;
1135  
1136 end
1137  
1138 ------------------------------------------------------------------------------------------
1139  
1140 function ASO_CheckPetHealth()
1141  
1142 if ( HasPetUI() and ASO_IsHealthPointsLow(ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]) ) then
1143 if (ASO_Debug) then
1144 ASO_ChatMessage("'"..ASO_LOCSTR_PETHEALTH_LABEL .. "' " .. ASO_LOCSTR_DEBUG_MSG18);
1145 end
1146 ASO_UseGeneric(ASO_Events[ASO_LOCSTR_PETHEALTH_LABEL]);
1147 end
1148  
1149 return;
1150  
1151 end
1152  
1153 ------------------------------------------------------------------------------------------
1154  
1155 function ASO_CheckLife()
1156  
1157 if ( ASO_IsHealthPointsLow(ASO_Events[ASO_LOCSTR_LIFE_LABEL]) ) then
1158 if (ASO_Debug) then
1159 ASO_ChatMessage("'"..ASO_LOCSTR_LIFE_LABEL .. "' " .. ASO_LOCSTR_DEBUG_MSG18);
1160 end
1161 ASO_UseGeneric(ASO_Events[ASO_LOCSTR_LIFE_LABEL]);
1162 end
1163  
1164 return;
1165  
1166 end
1167  
1168 ------------------------------------------------------------------------------------------
1169  
1170 function ASO_CheckMana()
1171  
1172 if ( ASO_IsPlayerManaClass() ) then
1173  
1174 if ( ASO_IsManaPointsLow(ASO_Events[ASO_LOCSTR_MANA_LABEL]) ) then
1175  
1176 if (ASO_Debug) then
1177 ASO_ChatMessage("'"..ASO_LOCSTR_MANA_LABEL .. "' " .. ASO_LOCSTR_DEBUG_MSG18);
1178 end
1179  
1180 ASO_UseGeneric(ASO_Events[ASO_LOCSTR_MANA_LABEL]);
1181  
1182 end
1183  
1184 end
1185  
1186 return;
1187  
1188 end
1189  
1190 ------------------------------------------------------------------------------------------
1191  
1192 function ASO_CheckRezStone()
1193  
1194 if (ASO_Debug) then
1195 ASO_CombatMessage("ASO_CheckRezStone() - ASO_HasBeenGivenRezStone(): " .. ASO_BooleanToString(ASO_HasBeenGivenRezStone()), 1.0,1.0,1.0);
1196 ASO_CombatMessage("ASO_CheckRezStone() - not ASO_HasRezStone(): " .. ASO_BooleanToString(not ASO_HasRezStone()), 1.0,1.0,1.0);
1197 end
1198  
1199 if ( ASO_HasBeenGivenRezStone() ) then
1200 if ( not ASO_HasRezStone() ) then
1201 if (ASO_Debug) then
1202 ASO_ChatMessage("'"..ASO_LOCSTR_REZSTONE_LABEL .. "' " .. ASO_LOCSTR_DEBUG_MSG18);
1203 end
1204 ASO_UseGeneric(ASO_Events[ASO_LOCSTR_REZSTONE_LABEL]);
1205 end
1206 end
1207  
1208 return;
1209  
1210 end
1211  
1212 ------------------------------------------------------------------------------------------
1213  
1214 function ASO_IsPlayerManaClass()
1215  
1216 local ManaClass = true;
1217  
1218 local localizedClass, englishClass = UnitClass("player");
1219  
1220 if (englishClass == "DRUID") then
1221  
1222 -- Check for Druid in shapeshifted form...
1223 local numberOfShapes = GetNumShapeshiftForms();
1224 for i=1,numberOfShapes do
1225  
1226 icon, name, active = GetShapeshiftFormInfo(i);
1227  
1228 if (active == 1) then
1229  
1230 ManaClass = false;
1231 if (ASO_Debug) then
1232 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG9 .. " ["..englishClass.."]");
1233 end
1234  
1235 break;
1236  
1237 end
1238  
1239 end
1240  
1241 elseif ( (englishClass == "WARRIOR") or (englishClass == "ROGUE") ) then
1242  
1243 ManaClass = false;
1244 if (ASO_Debug) then
1245 ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG9 .. " ["..englishClass.."]");
1246 end
1247  
1248 end
1249  
1250 return ManaClass;
1251  
1252 end
1253  
1254 ------------------------------------------------------------------------------------------
1255  
1256 function ASO_IsHealthPointsLow(type)
1257  
1258 -- Convert player health to a percentage and check if it's less than the
1259 -- defined AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][type].NotifyPercent value:
1260  
1261 --if (ASO_Debug) then
1262 -- ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG10 .. " '"..type.."'...",0.0,1.0,0.0);
1263 --end
1264  
1265 local unit = ASO_GetEventTypeUnit(type);
1266  
1267 if (((UnitHealth(unit)/UnitHealthMax(unit))*100)<AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] ][type].NotifyPercent) then
1268 if (ASO_Debug) then
1269 ASO_ChatMessage("'"..type.."' " .. ASO_LOCSTR_DEBUG_MSG11,1.0,0.0,0.0);
1270 end
1271 return true;
1272 else
1273 --if (ASO_Debug) then
1274 -- ASO_ChatMessage("'"..type.."' " .. ASO_LOCSTR_DEBUG_MSG12,1.0,0.0,0.0);
1275 --end
1276 return false;
1277 end
1278  
1279 end
1280  
1281 ------------------------------------------------------------------------------------------
1282  
1283 function ASO_IsManaPointsLow(type)
1284  
1285 -- Convert player mana to a percentage and check if it's less than the
1286 -- defined AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][type].NotifyPercent value:
1287  
1288 --if (ASO_Debug) then
1289 -- ASO_ChatMessage(ASO_LOCSTR_DEBUG_MSG10 .. " '"..type.."'...",0.0,1.0,0.0);
1290 --end
1291  
1292 local unit = ASO_GetEventTypeUnit(type);
1293  
1294 if (((UnitMana(unit)/UnitManaMax(unit))*100)<AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][type].NotifyPercent) then
1295 if (ASO_Debug) then
1296 ASO_ChatMessage("'"..type.."' " .. ASO_LOCSTR_DEBUG_MSG11,1.0,0.0,0.0);
1297 end
1298 return true;
1299 else
1300 --if (ASO_Debug) then
1301 -- ASO_ChatMessage("'"..type.."' " .. ASO_LOCSTR_DEBUG_MSG12,1.0,0.0,0.0);
1302 --end
1303 return false;
1304 end
1305  
1306 end
1307  
1308 ------------------------------------------------------------------------------------------
1309  
1310 function ASO_IsInCombat(type)
1311  
1312 if (ASO_Debug) then
1313 ASO_ChatMessage( ASO_LOCSTR_DEBUG_MSG13, 1.0, 0.5, 0.5);
1314 end
1315  
1316 local unit = ASO_GetEventTypeUnit(type);
1317  
1318 if ( UnitAffectingCombat(unit) == 1 ) then
1319  
1320 if (ASO_Debug) then
1321 ASO_ChatMessage( ASO_LOCSTR_DEBUG_MSG14, 1.0, 0.5, 0.5);
1322 end
1323  
1324 return true;
1325  
1326 else
1327  
1328 if (ASO_Debug) then
1329 ASO_ChatMessage( ASO_LOCSTR_DEBUG_MSG15, 1.0, 0.5, 0.5);
1330 end
1331  
1332 return false;
1333  
1334 end
1335  
1336 end
1337  
1338 ------------------------------------------------------------------------------------------
1339  
1340 function ASO_UseGeneric(Type)
1341  
1342 if (ASO_Debug) then
1343 ASO_ChatMessage(">>>>> ASO_UseGeneric(Type): " .. Type,1.0,1.0,1.0);
1344 end
1345  
1346 --Check to see if CoolDownTime has passed:
1347 if (GetTime() - ASO_LastShout[Type] > AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].NotifyFrequency) then
1348  
1349 if (ASO_Debug) then
1350 ASO_ChatMessage("'"..Type.."' "..ASO_LOCSTR_DEBUG_MSG16 .. ASO_BooleanToString(AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].NotifyCombatOnly),1.0,0.75,0.75);
1351 ASO_IsInCombat(Type); -- for debugging reasons
1352 end
1353  
1354 if ( (AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].NotifyCombatOnly and ASO_IsInCombat(Type)) or (not AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].NotifyCombatOnly) ) then
1355  
1356 if ( (not ASO_IsInDuel()) or (ASO_IsInDuel() and AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].NotifyDuringDuel) ) then
1357  
1358 -- v1.14.0
1359 local channelingSpell = false;
1360 if ( CastingBarFrame.channeling == 1 ) then -- :IsShown()
1361 channelingSpell = true;
1362 end
1363  
1364 if (ASO_IsStatusOutput()) then
1365 ASO_CombatMessage(ASO_LOCSTR_COMBAT_MSG1.. " " .. Type .. " (Channeling? [".. ASO_BooleanToString(channelingSpell) .. "]). " .. ASO_LOCSTR_COMBAT_MSG2 ,1.0, 0.75, 0.75);
1366 end
1367  
1368 if ( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].ShoutEnabled ) then
1369  
1370 -- Don't do OOM shout if spell channeling, as it 'may' cause interruption of spell channeling
1371 if ( (not channelingSpell) or (ASP_Spell_Channeling and (Type ~= ASO_Events[ASO_LOCSTR_MANA_LABEL])) ) then
1372 DoEmote( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].ShoutEmote );
1373 end
1374  
1375 end
1376  
1377 if ( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].MessageEnabled ) then
1378 ASO_SendMessage( Type );
1379 end
1380  
1381 ASO_LastShout[Type] = GetTime();
1382 return true;
1383  
1384 elseif (ASO_IsStatusOutput()) then
1385 ASO_CombatMessage(ASO_LOCSTR_NOTIFY_DURING_DUEL_OFF, 1.0, 0.75, 0.75);
1386 end
1387  
1388 end
1389  
1390 else
1391 if (ASO_Debug) then
1392 ASO_ChatMessage("'"..Type.."' " .. ASO_LOCSTR_DEBUG_MSG17,1.0,0.0,0.0);
1393 end
1394 end
1395  
1396 return false;
1397  
1398 end
1399  
1400 ------------------------------------------------------------------------------------------
1401  
1402 function ASO_SendMessage(Type)
1403  
1404 if (ASO_Debug) then
1405 ASO_ChatMessage("Method ASO_SendMessage(" .. Type .. ") called!",1.0,1.0,1.0);
1406 end
1407  
1408 local target = AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].MessageTarget;
1409 local text = ASO_ParseMessage( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]][Type].MessageText, Type );
1410  
1411 if (target ~= nil and text ~= nil) then
1412  
1413 if (ASO_Debug) then
1414 ASO_ChatMessage("'" .. target .. "' "..ASO_LOCSTR_DEBUG_MSG4..": " .. text,1.0,1.0,1.0);
1415 end
1416  
1417 if (ASO_IsStringLOCAL(target)) then
1418 ASO_ChatMessage(text, 1.0, 1.0, 1.0);
1419 elseif (ASO_IsStringBANNER(target)) then
1420 ASO_BannerMessage(text, 1.0, 1.0, 1.0);
1421 elseif (ASO_IsStringSAY(target)) then
1422 SendChatMessage(text);
1423 elseif (ASO_IsStringPARTY(target)) then
1424 -- To prevent "C stack overflow" errors we verify that the user
1425 -- is in a PARTY/RAID. If not, then we do a say instead.
1426 -- 1.14.1
1427 if (ASO_IsInRaid() or ASO_IsInParty()) then -- v1.15.4 added ASO_IsInRaid()
1428 SendChatMessage(text, 'PARTY');
1429 else
1430 ASO_ChatMessage("ASO: " .. ASO_LOCSTR_UI_IsMessagingEnabledCheckButtonLabel .. "-" .. ASO_LOCSTR_UI_MessageTargetEditBoxLabel .. ASO_LOCSTR_DEBUG_MSG24, 1.0, 1.0, 0.75);
1431 SendChatMessage(text);
1432 end
1433 elseif (ASO_IsStringRAID(target)) then
1434 -- To prevent "C stack overflow" errors we verify that the user
1435 -- is in a PARTY/RAID. If not, then we do a say instead.
1436 -- 1.14.1
1437 if (ASO_IsInRaid()) then
1438 SendChatMessage(text, 'RAID');
1439 else
1440 ASO_ChatMessage("ASO: " .. ASO_LOCSTR_UI_IsMessagingEnabledCheckButtonLabel .. "-" .. ASO_LOCSTR_UI_MessageTargetEditBoxLabel .. ASO_LOCSTR_DEBUG_MSG24, 1.0, 1.0, 0.75);
1441 SendChatMessage(text);
1442 end
1443 else
1444 SendChatMessage(text, 'WHISPER', nil, target);
1445 end
1446  
1447 end
1448  
1449 end
1450  
1451 ------------------------------------------------------------------------------------------
1452  
1453 function ASO_ParseMessage(text, type)
1454  
1455 local message = text;
1456  
1457 -- Must be processed in largest to smallest order, as gsub substitutes substrings too!
1458 message = string.gsub(message, "$HEALTHPERCENT", math.floor( UnitHealth( ASO_GetEventTypeUnit(type) ) / UnitHealthMax( ASO_GetEventTypeUnit(type) ) * 100 ) );
1459 message = string.gsub(message, "$HEALTHMAX", UnitHealthMax( ASO_GetEventTypeUnit(type) ) );
1460 message = string.gsub(message, "$HEALTH", UnitHealth( ASO_GetEventTypeUnit(type) ) );
1461  
1462 message = string.gsub(message, "$MANAPERCENT", math.floor( UnitMana( ASO_GetEventTypeUnit(type) ) / UnitManaMax( ASO_GetEventTypeUnit(type) ) * 100 ) );
1463 message = string.gsub(message, "$MANAMAX", UnitManaMax( ASO_GetEventTypeUnit(type) ) );
1464 message = string.gsub(message, "$MANA", UnitMana( ASO_GetEventTypeUnit(type) ) );
1465  
1466 message = string.gsub(message, "$NAME", UnitName( ASO_GetEventTypeUnit(type) ) );
1467  
1468 return message;
1469  
1470 end
1471  
1472 ------------------------------------------------------------------------------------------
1473  
1474 -- The below functions should not do a string.upper or string.lower when checking against
1475 -- the constant variable values! This is so that a player 'Banner' can get a whisper and
1476 -- the user can choose to send messages to the upper center 'BANNER' (channel) area!
1477  
1478 function ASO_IsStringLOCAL(text)
1479 if (text ~= nil and text == ASO_LOCSTR_LOCAL) then
1480 return true;
1481 end
1482 return false;
1483 end
1484  
1485 function ASO_IsStringBANNER(text)
1486 if (text ~= nil and text == ASO_LOCSTR_BANNER) then
1487 return true;
1488 end
1489 return false;
1490 end
1491  
1492 function ASO_IsStringSAY(text)
1493 if (text ~= nil and text == ASO_LOCSTR_SAY) then
1494 return true;
1495 end
1496 return false;
1497 end
1498  
1499 function ASO_IsStringPARTY(text)
1500 if (text ~= nil and text == ASO_LOCSTR_PARTY) then
1501 return true;
1502 end
1503 return false;
1504 end
1505  
1506 function ASO_IsStringRAID(text)
1507 if (text ~= nil and text == ASO_LOCSTR_RAID) then
1508 return true;
1509 end
1510 return false;
1511 end
1512  
1513 ------------------------------------------------------------------------------------------
1514  
1515 function ASO_GetEventTypeUnit(eventType)
1516  
1517 if ( string.lower(eventType) == string.lower(ASO_LOCSTR_PETHEALTH) ) then
1518 -- if (ASO_Debug) then
1519 -- ASO_ChatMessage("'"..eventType.."' "..ASO_LOCSTR_DEBUG_MSG2,1.0,1.0,1.0);
1520 -- end
1521 return "pet";
1522 else
1523 -- if (ASO_Debug) then
1524 -- ASO_ChatMessage("'"..eventType.."' "..ASO_LOCSTR_DEBUG_MSG3,1.0,1.0,1.0);
1525 -- end
1526 return "player";
1527 end
1528  
1529 end
1530  
1531  
1532 ------------------------------------------------------------------------------------------
1533  
1534 function ASO_IsStatusOutput()
1535 return AutoShoutOut.StatusOutput;
1536 end
1537  
1538 ------------------------------------------------------------------------------------------
1539  
1540 function ASO_IsWarnMsgs()
1541 return AutoShoutOut.WarnMsgs;
1542 end
1543  
1544 ------------------------------------------------------------------------------------------
1545 -- Global switch check for any kind of notifications
1546 function ASO_IsNotifyingEnabled()
1547 return AutoShoutOut.NotifyingEnabled;
1548 end
1549  
1550 ------------------------------------------------------------------------------------------
1551  
1552 function ASO_IsAutoSwitch()
1553 return AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_AUTOSWITCH];
1554 end
1555  
1556 ------------------------------------------------------------------------------------------
1557  
1558 function ASO_IsInParty()
1559 if ( ASO_Debug ) then
1560 ASO_ChatMessage("ASO_IsInParty(): " .. ASO_BooleanToString( ( (not ASO_IsInRaid()) and (GetNumPartyMembers() ~= 0) ) ) );
1561 end
1562 return ( (not ASO_IsInRaid()) and (GetNumPartyMembers() ~= 0) );
1563 end
1564  
1565 ------------------------------------------------------------------------------------------
1566  
1567 function ASO_IsInRaid()
1568 if ( ASO_Debug ) then
1569 ASO_ChatMessage("ASO_IsInRaid(): " .. ASO_BooleanToString( (GetNumRaidMembers() ~= 0) ) );
1570 end
1571 return (GetNumRaidMembers() ~= 0);
1572 end
1573  
1574 ------------------------------------------------------------------------------------------
1575  
1576 function ASO_IsInDuel()
1577 if ( ASO_Debug ) then
1578 ASO_ChatMessage("ASO_IsInDuel(): " .. ASO_BooleanToString( ASO_InDuel ) );
1579 end
1580 return ASO_InDuel;
1581 end
1582  
1583 ------------------------------------------------------------------------------------------
1584  
1585 function ASO_SetInDuel(bool)
1586 ASO_InDuel = bool;
1587 if ( ASO_Debug ) then
1588 ASO_ChatMessage("ASO_SetInDuel(): " .. ASO_BooleanToString( ASO_InDuel ) );
1589 end
1590 end
1591  
1592 ------------------------------------------------------------------------------------------
1593  
1594 function ASO_IsActiveConfigSolo()
1595 -- return AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] == ASO_LOCSTR_CONFIGS_SOLO;
1596 return ( (not ASO_IsActiveConfigParty()) and (not ASO_IsActiveConfigRaid()) );
1597 end
1598  
1599 ------------------------------------------------------------------------------------------
1600  
1601 function ASO_IsActiveConfigParty()
1602 return AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] == ASO_LOCSTR_CONFIGS_PARTY;
1603 end
1604  
1605 ------------------------------------------------------------------------------------------
1606  
1607 function ASO_IsActiveConfigRaid()
1608 return AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] == ASO_LOCSTR_CONFIGS_RAID;
1609 end
1610  
1611 ------------------------------------------------------------------------------------------
1612  
1613 function ASO_ChatMessage(msg,r,g,b)
1614  
1615 if (msg == nil) then
1616 msg = 'nil';
1617 end
1618  
1619 if( DEFAULT_CHAT_FRAME ) then
1620 DEFAULT_CHAT_FRAME:AddMessage(msg,r,g,b);
1621 else
1622 message("AutoShoutOut is unable to display a message in your general chat window (DEFAULT_CHAT_FRAME)!\n" .. msg);
1623 end
1624  
1625 end
1626  
1627 ------------------------------------------------------------------------------------------
1628  
1629 function ASO_CombatMessage(msg,r,g,b)
1630  
1631 if (msg == nil) then
1632 msg = 'nil';
1633 end
1634  
1635 if( ChatFrame2 ) then
1636 ChatFrame2:AddMessage(msg,r,g,b);
1637 -- else
1638 -- message("AutoShoutOut is unable to display a message in your combat chat window (ChatFrame2)!\n" .. msg);
1639 end
1640  
1641 end
1642  
1643 ------------------------------------------------------------------------------------------
1644  
1645 function ASO_BannerMessage(msg,r,g,b)
1646  
1647 if (msg == nil) then
1648 msg = 'nil';
1649 end
1650  
1651 if( UIErrorsFrame ) then
1652 UIErrorsFrame:AddMessage(msg,r,g,b,1.0,UIERRORS_HOLD_TIME);
1653 else
1654 message(ASO_LOCSTR_BANNER_DISPLAY_ERROR .. "\n" .. msg );
1655 end
1656  
1657 end
1658  
1659 -----------------------------------------------------------------------------------------------
1660  
1661 function ASO_HasRezStone()
1662  
1663 hasRezStone = ASO_IsPlayerBuffUp("Spell_Shadow_SoulGem"); -- Spell_Shadow_SoulGem
1664 -- ASO_CombatMessage("ASO_HasRezStone(): " .. ASO_BooleanToString(hasRezStone), 1.0,1.0,1.0);
1665 return hasRezStone;
1666  
1667 end
1668  
1669 -----------------------------------------------------------------------------------------------
1670  
1671 function ASO_HasBeenGivenRezStone()
1672 -- ASO_CombatMessage("ASO_HasBeenGivenRezStone(): " .. ASO_BooleanToString(ASO_BeenGivenRezStone), 1.0,1.0,1.0);
1673 return ASO_BeenGivenRezStone;
1674 end
1675  
1676 -----------------------------------------------------------------------------------------------
1677  
1678 function ASO_IsPlayerBuffUp(sBuffname)
1679 return ASO_IsUnitBuffUp("player", sBuffname)
1680 end;
1681  
1682 --Loops through active buffs looking for a string match
1683 --Origin Zorlen's hunter functions (via WowWiki)
1684 function ASO_IsUnitBuffUp(sUnitname, sBuffname)
1685 local iIterator = 1
1686 while (UnitBuff(sUnitname, iIterator)) do
1687 if (string.find(UnitBuff(sUnitname, iIterator), sBuffname)) then
1688 return true
1689 end
1690 iIterator = iIterator + 1
1691 end
1692 return false
1693 end
1694  
1695 function ASO_ShowAllUnitBuffs(sUnitname)
1696 local iIterator = 1;
1697 DEFAULT_CHAT_FRAME:AddMessage( format("[%s] Buffs", sUnitname) );
1698 while (UnitBuff(sUnitname, iIterator)) do
1699 DEFAULT_CHAT_FRAME:AddMessage( UnitBuff(sUnitname, iIterator), 1, 1, 0);
1700 iIterator = iIterator + 1;
1701 end
1702 DEFAULT_CHAT_FRAME:AddMessage("---", 1, 1, 0);
1703 end
1704  
1705 -----------------------------------------------------------------------------------------------
1706  
1707 -- ========================================================================================
1708 -- ========================================================================================
1709 -- ========================================================================================
1710  
1711 function ASO_Window_OnShow()
1712 ASO_Window_Initialize();
1713 end
1714  
1715 --------------------------------------------------------------------------------------------
1716  
1717 function ASO_Window_OnHide()
1718 PlaySound("igMainMenuClose");
1719 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] );
1720 end
1721  
1722 --------------------------------------------------------------------------------------------
1723  
1724 function ASO_Window_Toggle()
1725  
1726 if ( AutoShoutOutWindow:IsVisible() ) then
1727 ASO_Window_Hide();
1728 else
1729 PlaySound("igMainMenuOpen");
1730 AutoShoutOutWindow:Show();
1731 end
1732  
1733 end
1734  
1735 --------------------------------------------------------------------------------------------
1736  
1737 function ASO_Window_Hide()
1738 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] );
1739 PlaySound("igMainMenuClose");
1740 AutoShoutOutWindow:Hide();
1741 end
1742  
1743 --------------------------------------------------------------------------------------------
1744  
1745 function ASO_Window_Initialize(flagRepaint)
1746  
1747 if ( AutoShoutOutWindow:IsVisible() ) then
1748  
1749 -- Resize UI controls based on localization settings...
1750 getglobal("AutoShoutOutWindow"):SetWidth(ASO_LOCSTR_UI_MainWindowSize_Width, ASO_LOCSTR_UI_MainWindowSize_Height);
1751 getglobal("AutoShoutOutWindow_TitleBox"):SetWidth(ASO_LOCSTR_UI_TitleBoxSize_Width, 65);
1752 getglobal("MessageMessageEditBox"):SetWidth(ASO_LOCSTR_UI_MessageMessageEditBoxSize_Width, 16);
1753 --
1754  
1755 UIDropDownMenu_SetSelectedValue(ConfigurationsDropDown, AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]);
1756 ASO_Window_Update_Controls(ASO_LOCSTR_HEALTH_LABEL, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
1757  
1758 getglobal("EventList_GlobalButton1"):LockHighlight();
1759 getglobal("EventList_GlobalButton2"):UnlockHighlight();
1760 getglobal("EventList_GlobalButton3"):UnlockHighlight();
1761 getglobal("EventList_GlobalButton4"):UnlockHighlight();
1762 getglobal("EventList_GlobalButton5"):UnlockHighlight();
1763  
1764 -- Assign tooltips...
1765 getglobal("ConfigurationsDropDown").tooltip = ASO_LOCSTR_UI_TooltipText_ConfigurationsDropDown;
1766 getglobal("AutoSwitchCheckButton").tooltip = ASO_LOCSTR_UI_TooltipText_AutoSwitchCheckButton;
1767 getglobal("EventList_GlobalButton1").tooltip = ASO_LOCSTR_UI_TooltipText_EventList_GlobalButton1;
1768 getglobal("EventList_GlobalButton2").tooltip = ASO_LOCSTR_UI_TooltipText_EventList_GlobalButton2;
1769 getglobal("EventList_GlobalButton3").tooltip = ASO_LOCSTR_UI_TooltipText_EventList_GlobalButton3;
1770 getglobal("EventList_GlobalButton4").tooltip = ASO_LOCSTR_UI_TooltipText_EventList_GlobalButton4;
1771 getglobal("EventList_GlobalButton5").tooltip = ASO_LOCSTR_UI_TooltipText_EventList_GlobalButton5;
1772 getglobal("NotifyPercentEditBox").tooltip = ASO_LOCSTR_UI_TooltipText_NotifyPercentEditBox;
1773 getglobal("NotifyFrequencyEditBox").tooltip = ASO_LOCSTR_UI_TooltipText_NotifyFrequencyEditBox;
1774 getglobal("MessageMessageEditBox").tooltip = ASO_LOCSTR_UI_TooltipText_MessageMessageEditBox;
1775 getglobal("IsShoutEnabledCheckButton").tooltip = ASO_LOCSTR_UI_TooltipText_IsShoutEnabledCheckButton;
1776 getglobal("IsMessagingEnabledCheckButton").tooltip = ASO_LOCSTR_UI_TooltipText_IsMessagingEnabledCheckButton;
1777 getglobal("TargetChannelsButton").tooltip = ASO_LOCSTR_UI_TooltipText_TargetChannelsButton;
1778 getglobal("MessageTargetEditBox").tooltip = ASO_LOCSTR_UI_TooltipText_MessageTargetEditBox;
1779 getglobal("AutoShoutOutWindowCloseButton").tooltip = ASO_LOCSTR_UI_TooltipText_AutoShoutOutWindowCloseButton;
1780 getglobal("AutoShoutOutWindow_Close_Button").tooltip = ASO_LOCSTR_UI_TooltipText_AutoShoutOutWindow_Close_Button;
1781  
1782 -- v1.12.0 addition with autoswitching functionality...
1783 -- Below is to get around painting bug, where the Configuration dropdown has its value changed
1784 -- via a set call, and it changes internally, but the text that is displayed does not change. Hiding
1785 -- and reshowing the window seems to force a repaint of the dropdown, so that the label reflects
1786 -- the same value as what it is set to.
1787 if (flagRepaint) then
1788 AutoShoutOutWindow:Hide();
1789 AutoShoutOutWindow:Show();
1790 end
1791  
1792 end
1793  
1794 end
1795  
1796 --------------------------------------------------------------------------------------------
1797  
1798 function ASO_Window_EventList_OnClick(whichclick,buttonobject)
1799  
1800 PlaySound("igMainMenuOptionCheckBoxOn");
1801  
1802 getglobal("EventList_GlobalButton1"):UnlockHighlight();
1803 getglobal("EventList_GlobalButton2"):UnlockHighlight();
1804 getglobal("EventList_GlobalButton3"):UnlockHighlight();
1805 getglobal("EventList_GlobalButton4"):UnlockHighlight();
1806 getglobal("EventList_GlobalButton5"):UnlockHighlight();
1807  
1808 buttonobject:LockHighlight();
1809  
1810 local btnLabel = getglobal(buttonobject:GetName().."Label");
1811  
1812 -- Should only be saving settings that have changed,
1813 -- but table is small enough to get away with this.
1814 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
1815  
1816 ASO_Window_Update_Controls( btnLabel:GetText(), UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
1817  
1818 end
1819  
1820 --------------------------------------------------------------------------------------------
1821  
1822 function ASO_Set_Active_Configuration(config)
1823  
1824 if ( config ~= AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE]) then
1825 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] = config;
1826 if ( ASO_IsStatusOutput() ) then
1827 ASO_CombatMessage("AutoShoutOut " .. ASO_LOCSTR_UI_ConfigurationsDropDownLabel .. ": " .. string.upper( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_ACTIVE] ), 1.0, 0.75, 1.0);
1828 end
1829 end
1830  
1831 end
1832  
1833 --------------------------------------------------------------------------------------------
1834  
1835 function ASO_Window_Update_Controls( EventTypeDesc, SettingsTypeDesc )
1836  
1837 ASO_Event_Type_Desc_Selected = EventTypeDesc;
1838  
1839 ASO_Set_Active_Configuration(SettingsTypeDesc);
1840  
1841 if ( ASO_IsAutoSwitch() ) then
1842 getglobal("AutoSwitchCheckButton"):SetChecked( 1 );
1843 else
1844 getglobal("AutoSwitchCheckButton"):SetChecked( nil );
1845 end
1846  
1847 getglobal("NotifyPercentEditBox"):SetText( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].NotifyPercent );
1848  
1849 getglobal("NotifyFrequencyEditBox"):SetText( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].NotifyFrequency );
1850  
1851 if ( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].NotifyCombatOnly ) then
1852 getglobal("IsCombatOnlyCheckButton"):SetChecked( 1 );
1853 else
1854 getglobal("IsCombatOnlyCheckButton"):SetChecked( nil );
1855 end
1856  
1857 if ( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].NotifyDuringDuel ) then
1858 getglobal("IsNotifyDuringDuelCheckButton"):SetChecked( 1 );
1859 else
1860 getglobal("IsNotifyDuringDuelCheckButton"):SetChecked( nil );
1861 end
1862  
1863 if ( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].ShoutEnabled ) then
1864 getglobal("IsShoutEnabledCheckButton"):SetChecked( 1 );
1865 else
1866 getglobal("IsShoutEnabledCheckButton"):SetChecked( nil );
1867 end
1868  
1869 if ( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].MessageEnabled ) then
1870 getglobal("IsMessagingEnabledCheckButton"):SetChecked( 1 );
1871 else
1872 getglobal("IsMessagingEnabledCheckButton"):SetChecked( nil );
1873 end
1874  
1875 getglobal("MessageTargetEditBox"):SetText( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].MessageTarget );
1876  
1877 getglobal("MessageMessageEditBox"):SetText( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].MessageText );
1878  
1879 ------------------------------------------
1880 -- Show/Hide controls based on settings...
1881 ------------------------------------------
1882  
1883 ASO_Window_OnClick_IsMessagingEnabledCheckButton();
1884  
1885 -- If event type selected is 'Rez Stone' then don't let them modify the notify percentage...
1886 if ( EventTypeDesc == ASO_LOCSTR_REZSTONE_LABEL ) then
1887 getglobal("NotifyPercentEditBox"):Hide();
1888 else
1889 getglobal("NotifyPercentEditBox"):Show();
1890 end
1891  
1892 if ( AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][SettingsTypeDesc][ASO_Events[EventTypeDesc]].ShoutEmote == nil ) then
1893 getglobal("IsShoutEnabledCheckButtonLabel"):SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
1894 getglobal("IsShoutEnabledCheckButton"):Disable();
1895 else
1896 getglobal("IsShoutEnabledCheckButtonLabel"):SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
1897 getglobal("IsShoutEnabledCheckButton"):Enable();
1898 end
1899  
1900 -- If not a class that has a mana pool, disable selection of the mana event type...
1901 if ( ASO_IsPlayerManaClass() ) then
1902 getglobal("EventList_GlobalButton3Label"):SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
1903 getglobal("EventList_GlobalButton3"):Enable();
1904 else
1905 getglobal("EventList_GlobalButton3Label"):SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
1906 getglobal("EventList_GlobalButton3"):Disable();
1907 end
1908  
1909 -- If not a class that has a pet, disable selection of the pet health event type...
1910 if ( HasPetUI() ) then
1911 getglobal("EventList_GlobalButton4Label"):SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
1912 getglobal("EventList_GlobalButton4"):Enable();
1913 else
1914 getglobal("EventList_GlobalButton4Label"):SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
1915 getglobal("EventList_GlobalButton4"):Disable();
1916 end
1917  
1918 end
1919  
1920 ----------------------------------------------------------------------------------------------
1921  
1922 function ASO_Save_Settings( EventTypeDesc, SettingsTypeDesc )
1923  
1924 if (ASO_Debug) then
1925 ASO_ChatMessage("ASO_Save_Settings --> [" .. EventTypeDesc .. "][" .. SettingsTypeDesc .. "]" , 1.0, 1.0, 1.0 );
1926 end
1927  
1928 if ( getglobal("AutoSwitchCheckButton"):GetChecked() == 1 ) then
1929 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_AUTOSWITCH] = true;
1930 else
1931 AutoShoutOut[ASO_LOCSTR_REALM][ASO_GetCharactersRealmName()][ASO_LOCSTR_CHARACTER][ASO_GetCharacterName()][ASO_LOCSTR_CONFIGS][ASO_LOCSTR_CONFIGS_AUTOSWITCH] = false;
1932 end
1933  
1934 ASO_SetNotifyPercent( ASO_Events[EventTypeDesc], SettingsTypeDesc, getglobal("NotifyPercentEditBox"):GetText() );
1935  
1936 ASO_SetNotifyFrequency( ASO_Events[EventTypeDesc], SettingsTypeDesc, getglobal("NotifyFrequencyEditBox"):GetText() );
1937  
1938 if ( getglobal("IsCombatOnlyCheckButton"):GetChecked() == 1 ) then
1939 ASO_SetNotifyCondition( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_COMBAT);
1940 else
1941 ASO_SetNotifyCondition( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_ALWAYS);
1942 end
1943  
1944 if ( getglobal("IsNotifyDuringDuelCheckButton"):GetChecked() == 1 ) then
1945 ASO_SetNotifyDuringDuel( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_ON);
1946 else
1947 ASO_SetNotifyDuringDuel( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_OFF);
1948 end
1949  
1950 if ( getglobal("IsShoutEnabledCheckButton"):GetChecked() == 1 ) then
1951 ASO_SetShout( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_ON );
1952 else
1953 ASO_SetShout( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_OFF );
1954 end
1955  
1956 if ( getglobal("IsMessagingEnabledCheckButton"):GetChecked() == 1 ) then
1957 ASO_SetMessage( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_ON, nil);
1958 else
1959 ASO_SetMessage( ASO_Events[EventTypeDesc], SettingsTypeDesc, ASO_LOCSTR_OFF, nil);
1960 end
1961  
1962 ASO_SetMessage( ASO_Events[EventTypeDesc], SettingsTypeDesc, getglobal("MessageTargetEditBox"):GetText(), getglobal("MessageMessageEditBox"):GetText());
1963  
1964 end
1965  
1966 -----------------------------------------------------------------------------------------------
1967  
1968 function ASO_Window_OnClick_IsMessagingEnabledCheckButton()
1969  
1970 if ( getglobal("IsMessagingEnabledCheckButton"):GetChecked() == 1 ) then
1971  
1972 getglobal("MessageTargetEditBox"):Show();
1973 getglobal("MessageMessageEditBox"):Show();
1974 getglobal("TargetChannelsButton"):Show();
1975  
1976 -- For 'Soulstone' event (Soulstone Resurrection buff)...
1977 if ( ASO_HasRezStone() ) then
1978 ASO_BeenGivenRezStone = true;
1979 end
1980  
1981 else
1982  
1983 getglobal("MessageTargetEditBox"):Hide();
1984 getglobal("MessageMessageEditBox"):Hide();
1985 getglobal("TargetChannelsButton"):Hide();
1986  
1987 -- For 'Soulstone' event (Soulstone Resurrection buff)...
1988 if ( not ASO_HasRezStone() ) then
1989 ASO_BeenGivenRezStone = false;
1990 end
1991  
1992 end
1993  
1994 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
1995  
1996 end
1997  
1998 -----------------------------------------------------------------------------------------------
1999  
2000 function ASO_Window_OnClick_IsCombatOnlyCheckButton()
2001 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2002 end
2003  
2004 -----------------------------------------------------------------------------------------------
2005  
2006 function ASO_Window_OnClick_IsShoutEnabledCheckButton()
2007 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2008 end
2009  
2010 -----------------------------------------------------------------------------------------------
2011  
2012 function ASO_Window_OnClick_ChannelsButton(buttonobject)
2013  
2014 PlaySound("igMainMenuOptionCheckBoxOn");
2015  
2016 if ( getglobal("MessageTargetEditBox"):GetText() == ASO_LOCSTR_LOCAL ) then
2017 getglobal("MessageTargetEditBox"):SetText( string.upper( ASO_LOCSTR_BANNER ) );
2018 elseif ( getglobal("MessageTargetEditBox"):GetText() == ASO_LOCSTR_BANNER ) then
2019 getglobal("MessageTargetEditBox"):SetText( string.upper( ASO_LOCSTR_SAY ) );
2020 elseif ( getglobal("MessageTargetEditBox"):GetText() == ASO_LOCSTR_SAY ) then
2021 getglobal("MessageTargetEditBox"):SetText( string.upper( ASO_LOCSTR_PARTY ) );
2022 elseif ( getglobal("MessageTargetEditBox"):GetText() == ASO_LOCSTR_PARTY ) then
2023 getglobal("MessageTargetEditBox"):SetText( string.upper( ASO_LOCSTR_RAID ) );
2024 elseif ( getglobal("MessageTargetEditBox"):GetText() == ASO_LOCSTR_RAID ) then
2025 -- If player is targeted, enter their name...
2026 if ( UnitIsPlayer("target") ) then
2027 getglobal("MessageTargetEditBox"):SetText( UnitName("target") );
2028 else
2029 getglobal("MessageTargetEditBox"):SetText( string.upper( ASO_LOCSTR_LOCAL ) );
2030 end
2031 -- Redundant...
2032 --elseif ( getglobal("MessageTargetEditBox"):GetText() == UnitName("target") ) then
2033 -- getglobal("MessageTargetEditBox"):SetText( string.upper( ASO_LOCSTR_LOCAL ) );
2034 else
2035 getglobal("MessageTargetEditBox"):SetText( string.upper( ASO_LOCSTR_LOCAL ) );
2036 end
2037  
2038 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2039  
2040 end
2041  
2042 -----------------------------------------------------------------------------------------------
2043  
2044 function ASO_Window_ConfigurationsDropDown_OnLoad()
2045 UIDropDownMenu_Initialize(this, ASO_Window_ConfigurationsDropDown_Initialize);
2046 end
2047  
2048 -----------------------------------------------------------------------------------------------
2049  
2050 function ASO_Window_ConfigurationsDropDown_OnShow()
2051 UIDropDownMenu_Initialize(this, ASO_Window_ConfigurationsDropDown_Initialize);
2052 end
2053  
2054 -----------------------------------------------------------------------------------------------
2055  
2056 function ASO_Window_ConfigurationsDropDown_Initialize()
2057  
2058 for key,value in pairs(ASO_Settings) do
2059  
2060 info = {};
2061 info.text = key;
2062 info.value = value;
2063 -- info.tooltipText = ASO_LOCSTR_UI_TooltipText_ConfigurationsDropDown; -- Doesn't work!?
2064 info.func = ASO_Window_ConfigurationsDropDown_OnClick;
2065 UIDropDownMenu_AddButton(info);
2066  
2067 end
2068  
2069 end
2070  
2071 -----------------------------------------------------------------------------------------------
2072  
2073 function ASO_Window_ConfigurationsDropDown_OnClick()
2074  
2075 -- Should only be saving settings that have changed,
2076 -- but table is small enough to get away with this.
2077 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2078  
2079 UIDropDownMenu_SetSelectedValue(ConfigurationsDropDown, this.value);
2080  
2081 ASO_Window_Update_Controls( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2082  
2083 end
2084  
2085 -----------------------------------------------------------------------------------------------
2086  
2087 function ASO_Window_OnClick_AutoSwitchCheckButton()
2088 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2089 end
2090  
2091 -----------------------------------------------------------------------------------------------
2092  
2093 function ASO_Window_OnClick_IsNotifyDuringDuelCheckButton()
2094 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2095 end
2096  
2097 -----------------------------------------------------------------------------------------------
2098  
2099 function ASO_Window_OnTabPressed_NotifyPercentEditBox()
2100  
2101 -- Should only be saving settings that have changed,
2102 -- but table is small enough to get away with this.
2103 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2104  
2105 this:ClearFocus();
2106 getglobal("NotifyFrequencyEditBox"):SetFocus();
2107  
2108 end
2109  
2110 -----------------------------------------------------------------------------------------------
2111  
2112 function ASO_Window_OnEnterPressed_NotifyPercentEditBox()
2113  
2114 -- Should only be saving settings that have changed,
2115 -- but table is small enough to get away with this.
2116 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2117  
2118 this:ClearFocus();
2119 getglobal("NotifyFrequencyEditBox"):SetFocus();
2120  
2121 end
2122  
2123 -----------------------------------------------------------------------------------------------
2124  
2125 function ASO_Window_OnTabPressed_NotifyFrequencyEditBox()
2126  
2127 -- Should only be saving settings that have changed,
2128 -- but table is small enough to get away with this.
2129 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2130  
2131 this:ClearFocus();
2132 getglobal("MessageTargetEditBox"):SetFocus();
2133  
2134 end
2135  
2136 -----------------------------------------------------------------------------------------------
2137  
2138 function ASO_Window_OnEnterPressed_NotifyFrequencyEditBox()
2139  
2140 -- Should only be saving settings that have changed,
2141 -- but table is small enough to get away with this.
2142 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2143  
2144 this:ClearFocus();
2145 getglobal("MessageTargetEditBox"):SetFocus();
2146  
2147 end
2148  
2149 -----------------------------------------------------------------------------------------------
2150  
2151 function ASO_Window_OnTabPressed_MessageTargetEditBox()
2152  
2153 -- Should only be saving settings that have changed,
2154 -- but table is small enough to get away with this.
2155 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2156  
2157 this:ClearFocus();
2158 getglobal("MessageMessageEditBox"):SetFocus();
2159  
2160 end
2161  
2162 -----------------------------------------------------------------------------------------------
2163  
2164 function ASO_Window_OnEnterPressed_MessageTargetEditBox()
2165  
2166 -- Should only be saving settings that have changed,
2167 -- but table is small enough to get away with this.
2168 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2169  
2170 this:ClearFocus();
2171 getglobal("MessageMessageEditBox"):SetFocus();
2172  
2173 end
2174  
2175 -----------------------------------------------------------------------------------------------
2176  
2177 function ASO_Window_OnTabPressed_MessageMessageEditBox()
2178  
2179 -- Should only be saving settings that have changed,
2180 -- but table is small enough to get away with this.
2181 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2182  
2183 this:ClearFocus();
2184  
2185 if ( getglobal("NotifyPercentEditBox"):IsVisible() ) then
2186 getglobal("NotifyPercentEditBox"):SetFocus();
2187 else
2188 getglobal("NotifyFrequencyEditBox"):SetFocus();
2189 end
2190  
2191  
2192 end
2193  
2194 -----------------------------------------------------------------------------------------------
2195  
2196 function ASO_Window_OnEnterPressed_MessageMessageEditBox()
2197  
2198 -- Should only be saving settings that have changed,
2199 -- but table is small enough to get away with this.
2200 ASO_Save_Settings( ASO_Event_Type_Desc_Selected, UIDropDownMenu_GetSelectedValue(ConfigurationsDropDown) );
2201  
2202 this:ClearFocus();
2203  
2204 if ( getglobal("NotifyPercentEditBox"):IsVisible() ) then
2205 getglobal("NotifyPercentEditBox"):SetFocus();
2206 else
2207 getglobal("NotifyFrequencyEditBox"):SetFocus();
2208 end
2209  
2210 end
2211