vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1  
2  
3  
4 -- Saved Data
5  
6 NuNData = {};
7 NuNSettings = {};
8  
9  
10  
11  
12 -- Arrays
13  
14 local dfltHeadings = NUN_DFLTHEADINGS;
15 local HRaces = NUN_HRACES;
16 local ARaces = NUN_ARACES;
17 local AllClasses = NUN_ALLCLASSES;
18 local HClasses = NUN_HCLASSES;
19 local AClasses = NUN_ACLASSES;
20 local HRanks = NUN_HRANKS;
21 local ARanks = NUN_ARANKS;
22 local Professions = NUN_PROFESSIONS;
23 local Sexes = NUN_SEXES;
24 local searchFor = NUN_SEARCHFOR;
25 local transmitTo = NUN_TRANSMITTO;
26 local invSlotList = NUN_INVENTORY_SLOT_LIST;
27 local noteTypes = NUN_NOTETYPES;
28  
29 local Races = {};
30 local Ranks = {};
31 local Classes = {};
32  
33 local foundNuN = {};
34 local c_continents = {};
35 local foundHNuN = {};
36 local foundANuN = {};
37 local foundNNuN = {};
38 local NuNQuestLog = {};
39  
40 local NuN_Filtered = {};
41  
42 local NuN_MapNotesValidVersions = {
43 "1800.7",
44 };
45 local NuN_MapNotesPlayedVersions = {};
46  
47 local NuN_LastOpen = {};
48  
49  
50  
51 -- Local Variables
52  
53 local bttnChanges = {};
54 local uBttns = getn(dfltHeadings);
55 local detlOffset = uBttns;
56 local hdngOffset = (uBttns * 2);
57 local pHead = "~Hdng";
58 local pDetl = "~Detl";
59 local discard;
60 local c_name;
61 local prevName;
62 local c_class;
63 local c_race;
64 local c_guild;
65 local c_route;
66 local c_text;
67 local c_text_len;
68 local g_text;
69 local g_text_len;
70 local txtTxt = "txt";
71 local pName;
72 local pKey;
73 local pFaction;
74 local hdNbr;
75 local nameHdNbr;
76 local nameDtNbr;
77 local oriTxt;
78 local isTitle;
79 local bttnNumb;
80 local lastDD;
81 local switch;
82 local parm1;
83 local Notes = "notes~";
84 local itmIndex = "ItmIndex~";
85 local mrgIndex = "merged~";
86 local c_note;
87 local c_type;
88 local prevNote;
89 local tryI;
90 local lastBttn;
91 local lastBttnIndex;
92 local deletedE;
93 local visibles;
94 local lastVisible;
95 local lastBttnDetl;
96 local NuN_importing;
97 local updateInterval = 10;
98 local popUpUpdateInterval = 1;
99 local timeSinceLastUpdate = 0;
100 local popUpTimeSinceLastUpdate = 0;
101 local NuNRaceDropDown;
102 local NuNClassDropDown;
103 local NuNCRankDropDown;
104 local NuNHRankDropDown;
105 local unitTest;
106 local NuN_rType;
107 local ttName;
108 local gtName;
109 local NuN_Fade = "False";
110 local NuN_TT_Y_Offset = 0;
111 local NUN_TT_LEN = 80;
112 local NuN_GNote_OriTitle = nil;
113 local prevLink;
114 local NuN_PinUpHeader = false;
115 local lastPinned;
116 local pinnedTTMoved = true;
117 local typeIndex;
118 local NuN_Fingers;
119 local NuN_Trinkets;
120 local NuN_Hand;
121 local sendTo;
122 local msgSeq = 0;
123 local NuNSearchTitle = NUN_SEARCH;
124 local NuN_Parties = "parties~";
125 local NuN_MouseOver = false;
126 local NuN_QuestsUpdating = "False";
127 local oneDone = false;
128 local NuN_AtStartup = "True";
129 local popUpHide = true;
130 local NuN_IgnoreNextQUpdate = nil;
131 local qTriggs = 0;
132 local noTipAnchor = nil;
133 local inBG = false;
134 local NuN_FirstTime = true;
135 local NuN_QuestAccepted = nil;
136  
137  
138  
139  
140 -- Local Function Hooks
141  
142 local NuNOri_FriendsFrameFriendButton_OnClick;
143 local NuNOri_FriendsFrameIgnoreButton_OnClick;
144 local NuNOri_FriendsFrameGuildPlayerStatusButton_OnClick;
145 local NuNOri_FriendsFrameGuildStatusButton_OnClick;
146 local NuNOri_FriendsFrameWhoButton_OnClick;
147  
148 local NuNOri_FriendsList_Update;
149 local NuNOri_IgnoreList_Update;
150 local NuNOri_GuildStatus_Update;
151 local NuNOri_WhoList_Update;
152 local NuNOri_ContainerFrameItemButton_OnClick;
153 local NuNOri_SetItemRef;
154 local NuNOri_PaperDollItemSlotButton_OnClick;
155 local NuNOri_QuestLog_Update;
156 local NuNOri_QuestLogRewardItem_OnClick;
157 local NuNOri_QuestItem_OnClick;
158 local NuNOri_QuestRewardItem_OnClick;
159 local NuNOri_AbandonQuest;
160 local NuNOri_QuestDetailAcceptButton_OnClick;
161 local NuNOri_QuestRewardCompleteButton_OnClick;
162  
163 -- Hook the MapNotes Function
164 local NuNOri_MapNotes_OnEnter;
165 local NuNOri_MapNotes_OnLeave;
166 local NuNOri_MapNotes_DeleteNote;
167 local NuNOri_MetaMapNotes_OnEnter;
168 local NuNOri_MetaMapNotes_OnLeave;
169 local NuNOri_MetaMapNotes_DeleteNote;
170 local NuN_GetZoneTableSize;
171  
172  
173  
174 -- Constants
175  
176 NUN_VERSION = "3.21";
177 NUN_MAX_PARTY_MEMBERS = 4;
178 NUN_AUTO_C = "A";
179 NUN_SELF_C = "S";
180 NUN_MANU_C = "M";
181 NUN_HORD_C = "H";
182 NUN_ALLI_C = "A";
183 NUN_NOTE_C = "N";
184 NUN_QUEST_C = "Q";
185 NUN_PARTY_C = "P";
186 NUN_MAX_ADD_TXT = 4;
187 NUN_MAX_TXT_CHR = 1012;
188 NUN_MAX_TXT_LIM = (NUN_MAX_ADD_TXT + 1) * NUN_MAX_TXT_CHR;
189 NUN_MAX_TXT_C = tostring(NUN_MAX_TXT_LIM);
190 NUN_MAX_TXT_BUF = NUN_MAX_TXT_LIM - 225;
191 NUN_SEP = " ";
192 NUN_OFF = "Offline";
193 NUN_TT_HDNG = "tooltip";
194 NUN_TT_MAX = 1012;
195 NUN_TT_KEYPHRASE = "TT::";
196 NUN_TT_END = "::";
197 NUN_TT_LINES_TRIGGER = 6;
198 NUN_TT_Y_SHIFT = 12;
199 NUN_TT_KEYPHRASE_LEN = string.len(NUN_TT_KEYPHRASE);
200 NUN_TT_ETC = " .....";
201 NUN_TXT_LABEL = "0 / "..NUN_MAX_TXT_LIM;
202 NUN_SPEED = "Speed";
203 NUN_GOLD = "|cffffB300|h";
204 NUN_GREEN = "|cff00ee00|h";
205 NUN_WHITE = "|cffffffff|h";
206 NUN_C_END = "|h|r";
207 NUN_PINNED_TT_PADDING = " ";
208 NUN_PLACE_HOLDER = "<Place Holder>";
209 NUN_CHAT_LIMIT = 180;
210 NUN_FRAMESCALE_MIN = 0.75;
211 NUN_FRAMESCALE_MAX = 1.75;
212 NUN_FRAMESCALE_STEP = 0.01;
213 NUN_TT_FONTSCALE_MIN = 0.90;
214 NUN_TT_FONTSCALE_MAX = 2.00;
215 NUN_FONTSCALE_STEP = 0.01;
216 NUN_TT_MAPFONTSCALE_MIN = 0.25;
217 NUN_TT_MAPFONTSCALE_MAX = 1.75;
218 NUN_MAPFONTSCALE_STEP = 0.01;
219 NUN_FRAMESCALE_MIN_TXT = tostring( NUN_FRAMESCALE_MIN * 100 ) .. "%";
220 NUN_FRAMESCALE_MAX_TXT = tostring( NUN_FRAMESCALE_MAX * 100 ) .. "%";
221 NUN_TT_FONTSCALE_MIN_TXT = tostring ( NUN_TT_FONTSCALE_MIN * 100 ) .. "%";
222 NUN_TT_FONTSCALE_MAX_TXT = tostring ( NUN_TT_FONTSCALE_MAX * 100 ) .. "%";
223 NUN_TT_MAPFONTSCALE_MIN_TXT = tostring ( NUN_TT_MAPFONTSCALE_MIN * 100 ) .. "%";
224 NUN_TT_MAPFONTSCALE_MAX_TXT = tostring ( NUN_TT_MAPFONTSCALE_MAX * 100 ) .. "%";
225 NUN_REPLACEQNAME_TXT = "$N";
226 NUN_REPLACEQCLASS_TXT = "$C";
227  
228  
229  
230  
231  
232 -- MapNotes Version Warning
233  
234 StaticPopupDialogs["NUN_MAPNOTES_VERSION_ALERT"] = {
235 text = TEXT(NUN_MAPNOTESVERSION_WARNING),
236 button1 = TEXT(OKAY),
237 showAlert = 1,
238 timeout = 0,
239 };
240  
241 -- NotesUNeed Note Limit Exceeded
242  
243 StaticPopupDialogs["NUN_NOTELIMIT_EXCEEDED"] = {
244 text = TEXT(NUN_TEXTLIM1..NUN_MAX_TXT_LIM..NUN_TEXTLIM2),
245 button1 = TEXT(OKAY),
246 showAlert = 1,
247 timeout = 0,
248 };
249  
250  
251  
252  
253  
254  
255  
256  
257 -- Mod Functions
258  
259  
260 function NuN_OnLoad()
261 local continentID, zoneID, continent, zone;
262 local c_zones = {};
263  
264 NuNOri_FriendsFrameFriendButton_OnClick = FriendsFrameFriendButton_OnClick;
265 FriendsFrameFriendButton_OnClick = NuNNew_FriendsFrameFriendButton_OnClick;
266 NuNOri_FriendsFrameIgnoreButton_OnClick = FriendsFrameIgnoreButton_OnClick;
267 FriendsFrameIgnoreButton_OnClick = NuNNew_FriendsFrameIgnoreButton_OnClick;
268 NuNOri_FriendsFrameGuildPlayerStatusButton_OnClick = FriendsFrameGuildPlayerStatusButton_OnClick;
269 FriendsFrameGuildPlayerStatusButton_OnClick = NuNNew_FriendsFrameGuildPlayerStatusButton_OnClick;
270 NuNOri_FriendsFrameGuildStatusButton_OnClick = FriendsFrameGuildStatusButton_OnClick;
271 FriendsFrameGuildStatusButton_OnClick = NuNNew_FriendsFrameGuildStatusButton_OnClick;
272 NuNOri_FriendsFrameWhoButton_OnClick = FriendsFrameWhoButton_OnClick;
273 FriendsFrameWhoButton_OnClick = NuNNew_FriendsFrameWhoButton_OnClick;
274  
275 NuNOri_FriendsList_Update = FriendsList_Update;
276 FriendsList_Update = NuNNew_FriendsList_Update;
277 NuNOri_IgnoreList_Update = IgnoreList_Update;
278 IgnoreList_Update = NuNNew_IgnoreList_Update;
279 NuNOri_GuildStatus_Update = GuildStatus_Update;
280 GuildStatus_Update = NuNNew_GuildStatus_Update;
281 NuNOri_WhoList_Update = WhoList_Update;
282 WhoList_Update = NuNNew_WhoList_Update;
283 NuNOri_ContainerFrameItemButton_OnClick = ContainerFrameItemButton_OnClick;
284 ContainerFrameItemButton_OnClick = NuNNew_ContainerFrameItemButton_OnClick;
285 NuNOri_SetItemRef = SetItemRef;
286 SetItemRef = NuNNew_SetItemRef;
287 NuNOri_PaperDollItemSlotButton_OnClick = PaperDollItemSlotButton_OnClick;
288 PaperDollItemSlotButton_OnClick = NuNNew_PaperDollItemSlotButton_OnClick;
289 NuNOri_QuestLog_Update = QuestLog_Update;
290 QuestLog_Update = NuNNew_QuestLog_Update;
291 NuNOri_QuestLogRewardItem_OnClick = QuestLogRewardItem_OnClick;
292 QuestLogRewardItem_OnClick = NuNNew_QuestLogRewardItem_OnClick;
293 NuNOri_QuestItem_OnClick = QuestItem_OnClick;
294 QuestItem_OnClick = NuNNew_QuestItem_OnClick;
295 NuNOri_QuestRewardItem_OnClick = QuestRewardItem_OnClick;
296 QuestRewardItem_OnClick = NuNNew_QuestRewardItem_OnClick;
297 NuNOri_AbandonQuest = AbandonQuest;
298 AbandonQuest = NuNNew_AbandonQuest;
299 NuNOri_QuestDetailAcceptButton_OnClick = QuestDetailAcceptButton_OnClick;
300 QuestDetailAcceptButton_OnClick = NuNNew_QuestDetailAcceptButton_OnClick;
301 NuNOri_QuestRewardCompleteButton_OnClick = QuestRewardCompleteButton_OnClick;
302 QuestRewardCompleteButton_OnClick = NuNNew_QuestRewardCompleteButton_OnClick;
303  
304 this:RegisterEvent("IGNORELIST_UPDATE");
305 this:RegisterEvent("FRIENDLIST_UPDATE");
306 this:RegisterEvent("PLAYER_ENTERING_WORLD");
307 this:RegisterEvent("PLAYER_LEVEL_UP");
308 this:RegisterEvent("QUEST_LOG_UPDATE");
309 this:RegisterEvent("UPDATE_FACTION");
310 this:RegisterEvent("UNIT_QUEST_LOG_CHANGED");
311 this:RegisterEvent("QUEST_PROGRESS");
312 this:RegisterEvent("QUEST_COMPLETE");
313 this:RegisterEvent("QUEST_FINISHED");
314 this:RegisterEvent("QUEST_ITEM_UPDATE");
315 this:RegisterEvent("CHAT_MSG_SYSTEM");
316 this:RegisterEvent("PARTY_MEMBERS_CHANGED");
317 this:RegisterEvent("RAID_ROSTER_UPDATE");
318 this:RegisterEvent("VARIABLES_LOADED");
319  
320 SlashCmdList["NOTEUN"] = function(pList)
321 local gap = string.find(pList, NUN_SEP);
322 if ( gap ) then
323 switch = string.sub(pList, 1, (gap - 1));
324 parm1 = string.sub(pList, (gap + 1));
325 else
326 switch = pList;
327 parm1 = nil;
328 end
329 NuN_CmdLine(switch, parm1, pList);
330 end
331 SLASH_NOTEUN1 = "/nun";
332  
333 tryI = true;
334 pName = UnitName("player");
335  
336 NuN_InitialiseSavedVariables();
337  
338 ClearButtonChanges();
339  
340 c_continents[1] = {};
341 c_continents[2] = {};
342 for continentID, continent in ipairs{GetMapContinents()} do
343 c_zones = {};
344 c_continents[continentID].name = continent;
345 for zoneID, zone in ipairs{GetMapZones(continentID)} do
346 c_zones[zoneID] = zone;
347 end
348 c_continents[continentID].zones = c_zones;
349 end
350 end
351  
352  
353  
354 function NuN_CmdLine(option, parm1, pList)
355 local index;
356 local value;
357 local initial;
358 local remainder;
359 local contactName;
360 local switch;
361 local theUnitID = "target";
362  
363 if ( ( option == "" ) or ( option == nil ) ) then
364 NuN_Options();
365 else
366 switch = string.lower(option);
367 if ( switch == "-h" ) then
368 DEFAULT_CHAT_FRAME:AddMessage(NUN_HELP_TEXT);
369 index = 0;
370 value = getglobal("NUN_HELP_TEXT"..index);
371 while( value ) do
372 DEFAULT_CHAT_FRAME:AddMessage(value);
373 index = index + 1;
374 value = getglobal("NUN_HELP_TEXT"..index);
375 end
376 DEFAULT_CHAT_FRAME:AddMessage(NUN_HELP_TEXT);
377 elseif ( switch == NUN_HTT ) then
378 NuN_ToggleToolTips();
379 elseif ( ( switch == "-ca" ) or ( switch == "-ch" ) ) then
380 initial = string.upper( string.sub(parm1, 1, 1) );
381 remainder = string.lower( string.sub(parm1,2) );
382 contactName = initial..remainder;
383 if ( NuNData[pKey][contactName] ) then
384 if ( NuNFrame:IsVisible() ) then
385 NuN_HideFrame();
386 end
387 NuN_ShowSavedNote(contactName);
388 else
389 NuN_CreateContact(contactName, switch);
390 end
391 elseif ( switch == "-a" ) then
392 NuN_DisplayAll();
393 elseif ( switch == "-micro" ) then
394 NuN_ToggleMicroButtons();
395 elseif ( switch == "-g" ) then
396 if ( ( parm1 ~= nil ) and ( parm1 ~= "") ) then
397 NuN_GNoteExists(parm1);
398 NuNGNoteFrame.fromQuest = nil;
399 if ( c_note ) then
400 NuN_ShowSavedGNote();
401 else
402 c_note = parm1;
403 c_type = NuNGet_CommandID(noteTypes, " ");
404 NuN_ShowTitledGNote("");
405 end
406 else
407 NuN_ShowNewGNote();
408 end
409 elseif ( switch == "-t" ) then
410 NuN_FromTarget(false);
411 elseif ( ( switch == "->de" ) or ( switch == "->en" ) ) then
412 NuN_LangPatch(switch);
413 else
414 initial = string.upper( string.sub(switch, 1, 1) );
415 remainder = string.lower( string.sub(switch,2) );
416 contactName = initial..remainder;
417 if ( NuNData[pKey][contactName] ) then
418 if ( NuNFrame:IsVisible() ) then
419 NuN_HideFrame();
420 end
421 NuN_ShowSavedNote(contactName);
422 elseif ( NuN_GNoteExists(pList) ) then
423 NuNGNoteFrame.fromQuest = nil;
424 NuN_ShowSavedGNote();
425 else
426 c_name = contactName;
427 unitTest = true;
428 theUnitID = NuN_Target();
429 if ( theUnitID ~= nil ) then
430 NuN_NewContact(theUnitID);
431 else
432 NuN_Options();
433 end
434 end
435 end
436 end
437 end
438  
439  
440 function NuN_FromTarget(autoHide)
441 local tstValue = NuN_CheckTarget();
442 local theUnitID = "target";
443 local npcText;
444  
445 if ( IsAltKeyDown() ) then
446 NuN_LastOpen.type = "Contact";
447 NuN_ReOpen();
448 return;
449 end
450  
451 if ( IsShiftKeyDown() ) then
452 autoHide = true;
453 end
454  
455 if ( tstValue == "N" ) then
456 NuNGNoteFrame.fromQuest = nil;
457 if ( ( NuNData[pKey][Notes][c_note] ) or ( NuNData[Notes][c_note] ) ) then
458 if ( autoHide ~= true ) then
459 NuN_ShowSavedGNote();
460 end
461 else
462 npcText = NuN_NPCInfo();
463 c_type = NuNGet_CommandID(noteTypes, "NPC");
464 NuN_ShowTitledGNote(npcText);
465 if ( autoHide == true ) then
466 NuNGNote_WriteNote();
467 if ( not NuN_ConfirmFrame:IsVisible() ) then
468 HideUIPanel(NuNGNoteFrame);
469 NuN_Message(c_note..NUN_AUTONOTED);
470 end
471 end
472 end
473 else
474 if ( NuNData[pKey][c_name] ) then
475 if ( autoHide ~= true ) then
476 NuN_ShowSavedNote(c_name);
477 end
478 else
479 NuN_NewContact(theUnitID);
480 if ( autoHide == true ) then
481 NuN_WriteNote();
482 HideUIPanel(NuNFrame);
483 NuN_Message(c_name..NUN_AUTONOTED);
484 end
485 end
486 end
487 end
488  
489  
490 function NuN_CheckTarget()
491 local chkName = UnitName("target");
492  
493 if ( ( ( UnitPlayerControlled("target") ) and (not UnitIsUnit("player", "target") ) ) or ( UnitInParty("target") ) or ( UnitInRaid("target") ) )then
494 c_name = chkName;
495 return "F";
496 elseif ( ( not UnitPlayerControlled("target") ) and ( chkName ) ) then
497 c_note = chkName;
498 return "N";
499 else
500 c_name = pName;
501 return "S";
502 end
503 end
504  
505  
506  
507 function NuN_DisplayAll()
508 if ( NuNSearchFrame:IsVisible() ) then
509 NuNSearchFrame:Hide();
510 else
511 NuNSearchFrameBackButton:Disable();
512 NuNSearchFrame.backEnabled = nil;
513 ddSearch = NuNGet_CommandID(searchFor, "All");
514 searchType = searchFor[ddSearch].Command;
515 NuNOptions_Search();
516 end
517 end
518  
519  
520  
521 function NuN_Options()
522 if ( NuNOptionsFrame:IsVisible() ) then
523 HideUIPanel(NuNOptionsFrame);
524 else
525 if ( ( MapNotes_OnLoad ) or ( MetaMapNotes_OnLoad ) ) then
526 NuN_AutoMapCheckBox:Enable();
527 if ( NuNSettings[pKey].autoMapNotes ) then
528 NuN_AutoMapCheckBox:SetChecked(1);
529 else
530 NuN_AutoMapCheckBox:SetChecked(0);
531 end
532 else
533 NuN_AutoMapCheckBox:SetChecked(0);
534 NuN_AutoMapCheckBoxLabel:SetText(NUN_NOMAPNOTES);
535 NuN_AutoMapCheckBox:Disable();
536 end
537 if ( NuNFrame:IsVisible() ) then
538 NuN_HideFrame();
539 end
540 if ( NuNSearchFrame:IsVisible() ) then
541 HideUIPanel(NuNSearchFrame);
542 end
543 if ( NuNGNoteFrame:IsVisible() ) then
544 HideUIPanel(NuNGNoteFrame);
545 end
546 UIDropDownMenu_SetSelectedID(NuNOptionsSearchDropDown, 1);
547 UIDropDownMenu_SetText(searchFor[1].Display, NuNOptionsSearchDropDown);
548 ddSearch = NuNGet_CommandID(searchFor, "All");
549 if ( NuNSettings[pKey].autoG ) then
550 NuNOptionsGuildCheckButton:SetChecked(1);
551 else
552 NuNOptionsGuildCheckButton:SetChecked(0);
553 end
554 if ( NuNSettings[pKey].autoA ) then
555 NuNOptionsAddCheckButton:SetChecked(1);
556 else
557 NuNOptionsAddCheckButton:SetChecked(0);
558 end
559 if ( NuNSettings[pKey].autoD ) then
560 NuNOptionsDeleteCheckButton:SetChecked(1);
561 else
562 NuNOptionsDeleteCheckButton:SetChecked(0);
563 end
564 if ( NuNSettings[pKey].autoQ ) then
565 NuN_AutoQuestCheckBox:SetChecked(1);
566 else
567 NuN_AutoQuestCheckBox:SetChecked(0);
568 end
569 if ( NuNSettings[pKey].autoN ) then
570 NuN_AutoNoteCheckBox:SetChecked(1);
571 else
572 NuN_AutoNoteCheckBox:SetChecked(0);
573 end
574 if ( NuNSettings[pKey].dLevel ) then
575 NuN_DefaultLevelCheckBox:SetChecked(1);
576 else
577 NuN_DefaultLevelCheckBox:SetChecked(0);
578 end
579 if ( NuNSettings[pKey].toolTips ) then
580 NuN_HelpTTCheckBox:SetChecked(1);
581 else
582 NuN_HelpTTCheckBox:SetChecked(0);
583 end
584 if ( NuNSettings[pKey].autoP ) then
585 NuN_AutoPartyCheckBox:SetChecked(1);
586 else
587 NuN_AutoPartyCheckBox:SetChecked(0);
588 end
589 if ( NuNSettings[pKey].minOver ) then
590 NuN_OverTTCheckBox:SetChecked(1);
591 else
592 NuN_OverTTCheckBox:SetChecked(0);
593 end
594 if ( NuNSettings[pKey].bHave ) then
595 NuN_BehaveCheckBox:SetChecked(1);
596 else
597 NuN_BehaveCheckBox:SetChecked(0);
598 end
599 NuNOptionsTTLengthTextBox:SetText( NuNSettings[pKey].ttLen );
600 NuNOptionsTTLineLengthTextBox:SetText( NuNSettings[pKey].ttLLen );
601 NuNSearchFrameBackButton:Enable();
602 NuNSearchFrame.backEnabled = true;
603 NuNOptionsFrame:SetScale(NuNSettings[pKey].pScale);
604 ShowUIPanel(NuNOptionsFrame);
605 end
606 end
607  
608  
609  
610 function ClearButtonChanges()
611 for i = 1, (uBttns * 2), 1 do
612 bttnChanges[i] = "";
613 end
614 end
615  
616  
617 function NuN_ShowSavedNote(cName)
618 c_name = cName;
619 c_class = nil;
620 c_race = nil;
621 c_guild = nil;
622 gRank = nil;
623 gRankIndex = nil;
624 gNote = nil;
625 gOfficerNote = nil;
626 c_route = "Saved";
627 if ( NuNData[pKey][c_name].faction == "Horde" ) then
628 NuN_HordeSetup();
629 else
630 NuN_AllianceSetup();
631 end
632 NuN_ShowNote();
633 end
634  
635  
636  
637 function NuN_ShowWhoNote(cName)
638 c_name = cName;
639 c_class = nil;
640 c_race = nil;
641 c_guild = nil;
642 gRank = nil;
643 gRankIndex = nil;
644 gNote = nil;
645 gOfficerNote = nil;
646 c_route = "Who";
647 if ( horde ) then
648 NuN_HordeSetup();
649 else
650 NuN_AllianceSetup();
651 end
652 NuN_ShowNote();
653 end
654  
655  
656  
657 function NuN_ShowNote()
658 local hText;
659 local theText;
660  
661 if ( ( NuNFrame:IsVisible() ) and ( prevName == c_name ) ) then
662 NuNFrame:Hide();
663 else
664 prevName = c_name;
665  
666 if ( NuNOptionsFrame:IsVisible() ) then
667 HideUIPanel(NuNOptionsFrame);
668 end
669  
670 lastDD = nil;
671 NuNButtonClrDD:Disable();
672  
673 ClearButtonChanges();
674  
675 NuNHeader:SetText(c_name);
676  
677 if ( NuNData[pKey][c_name] ) then
678 c_text = NuN_GetCText(c_name);
679 if ( ( c_text == nil ) or ( c_text == "" ) ) then
680 c_text = "\n";
681 end
682 NuNText:SetText( c_text );
683 NuNButtonDelete:Enable();
684 NuNCOpenChatButton:Enable();
685 NuNCTTCheckBoxLabel:Show();
686 NuN_CTTCheckBox:Show();
687 NuN_CTTCheckBox:SetChecked(0);
688 if ( NuN_PinnedTooltip.type == "Contact" ) then
689 NuN_CTTCheckBox:SetChecked( NuN_CheckPinnedBox(c_name) );
690 end
691 if ( c_name == pName ) then
692 NuNHeader:SetText(NUN_PLAYER.." : "..c_name);
693 elseif ( NuNData[pKey][c_name].type == NUN_AUTO_C ) then
694 NuNHeader:SetText(NUN_AUTO.." : "..c_name);
695 elseif ( NuNData[pKey][c_name].type == NUN_MANU_C ) then
696 NuNHeader:SetText(NUN_MANU.." : "..c_name);
697 elseif ( NuNData[pKey][c_name].type == NUN_PARTY_C ) then
698 NuNHeader:SetText(NUN_PARTY.." : "..c_name );
699 elseif ( NuNData[pKey][c_name].type == NUN_SELF_C ) then
700 NuNHeader:SetText(NUN_SELF.." : "..c_name);
701 else
702 NuNHeader:SetText(c_name);
703 end
704 else
705 theText = "";
706 NuNHeader:SetText(NUN_NEW.." : "..c_name);
707 if ( gNote ~= nil ) then
708 theText = "\n"..gNote;
709 end
710 if ( gOfficerNote ~= nil ) then
711 theText = theText.."\n"..gOfficerNote;
712 end
713 if ( theText == "" ) then
714 theText = "\n";
715 end
716 NuNText:SetText(theText);
717 NuNButtonDelete:Disable();
718 NuNCOpenChatButton:Disable();
719 NuNCTTCheckBoxLabel:Hide();
720 NuN_CTTCheckBox:Hide();
721 end
722  
723 UserButtons_Initialise();
724 DropDowns_Initialise();
725  
726 ddRace = nil;
727 ddClass = nil;
728 ddSex = nil;
729 ddProf1 = nil;
730 ddProf2 = nil;
731 ddCRank = nil;
732 ddHRank = nil;
733  
734 if ( NuNEditDetailsFrame:IsVisible() ) then
735 HideUIPanel(NuNEditDetailsFrame);
736 end
737 if ( NuNcDeleteFrame:IsVisible() ) then
738 HideUIPanel(NuNcDeleteFrame);
739 end
740  
741 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name][pName] ) and ( NuNData[pKey][c_name][pName].partied ) ) then
742 NuNPartiedLabel:Show();
743 NuNPartiedNumberLabel:SetText("(x"..tostring(NuNData[pKey][c_name][pName].partied)..")");
744 NuNPartiedNumberLabel:Show();
745 NuNFramePartyDownButton:Show();
746 else
747 NuNPartiedLabel:Hide();
748 NuNPartiedNumberLabel:SetText("(0)");
749 NuNPartiedNumberLabel:Hide();
750 NuNFramePartyDownButton:Hide();
751 end
752  
753 NuNFrame:SetScale(NuNSettings[pKey].pScale);
754 ShowUIPanel(NuNFrame);
755 if ( not NuNSettings[pKey].bHave ) then
756 NuNText:SetFocus();
757 else
758 NuNText:ClearFocus();
759 end
760 end
761 end
762  
763  
764  
765  
766 function NuN_Update_Ignored()
767 local index;
768 local value;
769 local x;
770 local iName;
771  
772 if ( pFaction ~= nil ) then
773 -- Check every Ignored player to make sure we have a Saved note
774  
775 if ( NuNSettings[pKey].autoA ) then
776 for i = 1, GetNumIgnores(), 1 do
777 iName = GetIgnoreName(i);
778 if ( ( iName ~= nil ) and ( not NuNData[pKey][iName] ) ) then
779 NuNData[pKey][iName] = {};
780 NuNData[pKey][iName].type = NUN_AUTO_C;
781 NuNData[pKey][iName].faction = pFaction;
782 NuNData[pKey][iName][txtTxt] = NUN_AUTO_IGNORE..NuN_GetDateStamp();
783 NuNData[pKey][iName].ignoreLst = {};
784 NuNData[pKey][iName].ignoreLst[1] = pName;
785 end
786 end
787 end
788  
789  
790  
791 -- Check every Saved entry to see if it is ignored, and upated Saved inofrmation on that basis
792  
793 for index, value in NuNData[pKey] do
794 if ( ( NuNData[pKey][index].faction) and ( NuNData[pKey][index].faction == pFaction ) and ( index ~= pName ) ) then
795 if ( NuN_Is_Ignored(index) ) then
796 if ( not NuNData[pKey][index].ignoreLst ) then -- Ignored but no ignore list currently
797 x = 1;
798 NuNData[pKey][index].ignoreLst = {};
799 NuNData[pKey][index].ignoreLst[x] = pName;
800 else -- Ignored but not on ignore list yet
801 if (not NuNGet_TableID(NuNData[pKey][index].ignoreLst, pName) ) then
802 x = getn( NuNData[pKey][index].ignoreLst ) + 1;
803 NuNData[pKey][index].ignoreLst[x] = pName;
804 end
805 end
806 else
807 if ( NuNData[pKey][index].ignoreLst ) then
808 x = NuNGet_TableID(NuNData[pKey][index].ignoreLst, pName);
809 if ( x ~= nil ) then -- Not ignored, but on ignore list > come off list
810 local tmpTable = Remove_Entry(NuNData[pKey][index].ignoreLst, x);
811 NuNData[pKey][index].ignoreLst = tmpTable;
812 if ( getn(NuNData[pKey][index].ignoreLst) == 0 ) then
813 -- If no more ignore list, and auto-deleting, and Auto-note, then delete note entirely
814 if ((NuNData[pKey][index].type == NUN_AUTO_C) and (NuNSettings[pKey].autoD) and (not NuNData[pKey][index].friendLst)) then
815 NuNData[pKey][index] = nil;
816 else
817 NuNData[pKey][index].ignoreLst = nil;
818 end
819 end
820 elseif ( getn(NuNData[pKey][index].ignoreLst) > 0 ) then
821  
822 -- If (Not Ignored) & (There is an Ignore List we are NOT On) & (Settings say we should try to Ignore)
823 -- & (Only 1 attempt per 'log on' OR Manual refresh ) then....
824  
825 if ( ( tryI == true ) and ( NuN_NotInfiniteIgored(index) ) ) then
826 if ( AddIgnore(index) ) then
827 x = getn(NuNData[pKey][index].ignoreLst) + 1;
828 NuNData[pKey][index].ignoreLst[x] = pName;
829 end
830 end
831 end
832 end
833 end
834 end
835 end
836 tryI = false;
837 end
838 end
839  
840  
841  
842 function NuN_Update_Friends()
843 local index;
844 local value;
845 local x;
846 local iName;
847  
848 if ( pFaction ~= nil ) then
849 if ( NuNSettings[pKey].autoA ) then
850 for i = 1, GetNumFriends(), 1 do
851 iName = GetFriendInfo(i);
852 if ( ( iName ~= nil ) and ( not NuNData[pKey][iName] ) ) then
853 NuNData[pKey][iName] = {};
854 NuNData[pKey][iName].type = NUN_AUTO_C;
855 NuNData[pKey][iName].faction = pFaction;
856 NuNData[pKey][iName][txtTxt] = NUN_AUTO_FRIEND..NuN_GetDateStamp();
857 NuNData[pKey][iName].friendLst = {};
858 NuNData[pKey][iName].friendLst[1] = pName;
859 end
860 end
861 end
862  
863 -- Check every Saved entry to see if it is friendly, and upated Saved information on that basis
864  
865 for index, value in NuNData[pKey] do
866 if ( index == pName ) then
867 NuNData[pKey][index].type = NUN_SELF_C;
868 elseif ( ( NuNData[pKey][index].faction ) and ( NuNData[pKey][index].faction == pFaction ) ) then
869 if ( NuN_Is_Friendly(index) ) then
870 if ( not NuNData[pKey][index].friendLst ) then
871 x = 1;
872 NuNData[pKey][index].friendLst = {};
873 NuNData[pKey][index].friendLst[x] = pName;
874 else
875 if (not NuNGet_TableID(NuNData[pKey][index].friendLst, pName) ) then
876 x = getn( NuNData[pKey][index].friendLst ) + 1;
877 NuNData[pKey][index].friendLst[x] = pName;
878 end
879 end
880 else
881 if ( NuNData[pKey][index].friendLst ) then
882 x = NuNGet_TableID(NuNData[pKey][index].friendLst, pName);
883 if ( x ~= nil ) then
884 local tmpTable = Remove_Entry(NuNData[pKey][index].friendLst, x);
885 NuNData[pKey][index].friendLst = tmpTable;
886 if ( getn(NuNData[pKey][index].friendLst) == 0 ) then
887 if ((NuNData[pKey][index].type == NUN_AUTO_C) and (NuNSettings[pKey].autoD) and (not NuNData[pKey][index].ignoreLst)) then
888 NuNData[pKey][index] = nil;
889 else
890 NuNData[pKey][index].friendLst = nil;
891 end
892 end
893 end
894 end
895 end
896 end
897 end
898  
899 end
900 end
901  
902  
903  
904 function Remove_Entry(table, entry)
905 local sorted = {};
906 local innerI = 0;
907 for i = 1, getn(table), 1 do
908 if ( i ~= entry ) then
909 innerI = innerI + 1;
910 sorted[innerI] = table[i];
911 end
912 end
913 return sorted;
914 end
915  
916 function NuN_Is_Ignored(aName)
917 for i = 1, GetNumIgnores(), 1 do
918 iName = GetIgnoreName(i);
919 if ( aName == GetIgnoreName(i) ) then
920 return true;
921 end
922 end
923 return false;
924 end
925  
926 function NuN_Is_Friendly(aName)
927 local iName;
928 for i = 1, GetNumFriends(), 1 do
929 iName = GetFriendInfo(i);
930 if ( iName == aName ) then
931 return true;
932 end
933 end
934 return false;
935 end
936  
937  
938  
939 function UserButtons_Initialise()
940 for n = 1, uBttns, 1 do
941 bttnHeadingText = getglobal("NuNTitleButton"..n.."ButtonTextHeading");
942 bttnDetailText = getglobal("NuNInforButton"..n.."ButtonTextDetail");
943 bttnDetail = getglobal("NuNInforButton"..n);
944 hdNbr = pHead..n;
945 nameHdNbr = c_name..hdNbr;
946 nameDtNbr = c_name..pDetl..n;
947 if ( NuNData[pKey][nameHdNbr] ) then
948 bttnHeadingText:SetText(NuNData[pKey][nameHdNbr].txt);
949 elseif (NuNSettings[pKey][hdNbr]) then
950 bttnHeadingText:SetText(NuNSettings[pKey][hdNbr].txt);
951 else
952 bttnHeadingText:SetText(dfltHeadings[n]);
953 end
954 if ( bttnHeadingText:GetText() == nil ) then
955 bttnDetailText:SetText("");
956 bttnDetail:Disable();
957 else
958 bttnDetail:Enable();
959 if ( NuNData[pKey][nameDtNbr] ) then
960 bttnDetailText:SetText(NuNData[pKey][nameDtNbr].txt);
961 else
962 bttnDetailText:SetText("");
963 end
964 end
965  
966 if ( n == 1 ) and ( c_guild ~= nil ) then
967 if ( bttnHeadingText:GetText() == dfltHeadings[n] ) and ( (bttnDetailText:GetText() == "") or (bttnDetailText:GetText() == nil) ) then
968 bttnDetailText:SetText(c_guild);
969 bttnChanges[n+detlOffset] = c_guild;
970 end
971 end
972 if ( n == 2 ) and ( gRank ~= nil ) then
973 if ( bttnHeadingText:GetText() == dfltHeadings[n] ) and ( (bttnDetailText:GetText() == "") or (bttnDetailText:GetText() == nil) ) then
974 if ( gRankIndex == 0 ) then
975 GuildRank = ("GM : "..gRank);
976 else
977 GuildRank = (gRankIndex.." : "..gRank);
978 end
979 bttnDetailText:SetText(GuildRank);
980 bttnChanges[n+detlOffset] = GuildRank;
981 end
982 end
983 end
984 end
985  
986  
987  
988 function DropDowns_Initialise()
989 if ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].race ~= nil ) then
990 UIDropDownMenu_SetSelectedID(NuNRaceDropDown, NuNData[pKey][c_name].race);
991 UIDropDownMenu_SetText(Races[ (NuNData[pKey][c_name].race) ], NuNRaceDropDown);
992 elseif ( c_race ~= nil ) then
993 ddRace = NuNGet_TableID(Races, c_race);
994 UIDropDownMenu_SetSelectedID(NuNRaceDropDown, ddRace);
995 UIDropDownMenu_SetText(c_race, NuNRaceDropDown);
996 else
997 UIDropDownMenu_ClearAll(NuNRaceDropDown);
998 end
999  
1000 if ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].cls ~= nil ) then
1001 UIDropDownMenu_SetSelectedID(NuNClassDropDown, NuNData[pKey][c_name].cls);
1002 UIDropDownMenu_SetText(Classes[ (NuNData[pKey][c_name].cls) ], NuNClassDropDown);
1003 elseif ( c_class ~= nil ) then
1004 ddClass = NuNGet_TableID(Classes, c_class);
1005 UIDropDownMenu_SetSelectedID(NuNClassDropDown, ddClass);
1006 UIDropDownMenu_SetText(c_class, NuNClassDropDown);
1007 else
1008 UIDropDownMenu_ClearAll(NuNClassDropDown);
1009 end
1010  
1011 if ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].sex ~= nil ) then
1012 UIDropDownMenu_SetSelectedID(NuNSexDropDown, NuNData[pKey][c_name].sex);
1013 UIDropDownMenu_SetText(Sexes[ (NuNData[pKey][c_name].sex) ], NuNSexDropDown);
1014 else
1015 UIDropDownMenu_ClearAll(NuNSexDropDown);
1016 end
1017  
1018 if ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].prof1 ~= nil ) then
1019 UIDropDownMenu_SetSelectedID(NuNProf1DropDown, NuNData[pKey][c_name].prof1);
1020 UIDropDownMenu_SetText(Professions[ (NuNData[pKey][c_name].prof1) ], NuNProf1DropDown);
1021 else
1022 UIDropDownMenu_ClearAll(NuNProf1DropDown);
1023 end
1024  
1025 if ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].prof2 ~= nil ) then
1026 UIDropDownMenu_SetSelectedID(NuNProf2DropDown, NuNData[pKey][c_name].prof2);
1027 UIDropDownMenu_SetText(Professions[ (NuNData[pKey][c_name].prof2) ], NuNProf2DropDown);
1028 else
1029 UIDropDownMenu_ClearAll(NuNProf2DropDown);
1030 end
1031  
1032 if ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].crank ~= nil ) then
1033 UIDropDownMenu_SetSelectedID(NuNCRankDropDown, NuNData[pKey][c_name].crank);
1034 UIDropDownMenu_SetText(Ranks[ (NuNData[pKey][c_name].crank) ], NuNCRankDropDown);
1035 else
1036 UIDropDownMenu_ClearAll(NuNCRankDropDown);
1037 end
1038  
1039 if ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].hrank ~= nil ) then
1040 UIDropDownMenu_SetSelectedID(NuNHRankDropDown, NuNData[pKey][c_name].hrank);
1041 UIDropDownMenu_SetText(Ranks[ (NuNData[pKey][c_name].hrank) ], NuNHRankDropDown);
1042 else
1043 UIDropDownMenu_ClearAll(NuNHRankDropDown);
1044 end
1045 end
1046  
1047  
1048  
1049 function NuNGet_TableID(tab, txt)
1050 for i = 1, getn(tab), 1 do
1051 if ( tab[i] == txt ) then return i; end
1052 end
1053 return nil;
1054 end
1055  
1056  
1057 function NuNGet_CommandID(tab, txt)
1058 for i = 1, getn(tab), 1 do
1059 if ( tab[i].Command == txt ) then return i; end
1060 end
1061 return nil;
1062 end
1063  
1064  
1065 function NuN_WriteNote()
1066 if (not NuNData[pKey][c_name]) then
1067 NuNData[pKey][c_name] = {};
1068 end
1069  
1070 if ( c_name == pName ) then
1071 NuNData[pKey][c_name].type = NUN_SELF_C;
1072 NuNHeader:SetText(NUN_PLAYER.." : "..c_name);
1073 elseif ( ( not NuNData[pKey][c_name].type ) or ( NuNData[pKey][c_name].type == NUN_AUTO_C ) ) then
1074 NuNData[pKey][c_name].type = NUN_MANU_C;
1075 NuNHeader:SetText(NUN_MANU.." : "..c_name);
1076 end
1077  
1078 if ( not NuNData[pKey][c_name].faction ) then
1079 if ( ( c_route == "Target" ) or ( c_route == "Create" ) ) then
1080 NuNData[pKey][c_name].faction = c_faction;
1081 else
1082 NuNData[pKey][c_name].faction = pFaction;
1083 end
1084 end
1085  
1086 if ( FriendsListFrame:IsVisible() ) then
1087 NuNNew_FriendsList_Update();
1088 elseif ( IgnoreListFrame:IsVisible() ) then
1089 NuNNew_IgnoreList_Update();
1090 elseif ( GuildPlayerStatusFrame:IsVisible() ) then
1091 NuNNew_GuildStatus_Update();
1092 elseif ( GuildStatusFrame:IsVisible() ) then
1093 NuNNew_GuildStatus_Update();
1094 elseif ( WhoFrame:IsVisible() ) then
1095 NuNNew_WhoList_Update();
1096 end
1097  
1098 if ( c_guild ~= nil ) then
1099 NuNData[pKey][c_name].guild = c_guild;
1100 end
1101 if ( not NuNData[pKey][c_name].guild ) then
1102 NuNData[pKey][c_name].guild = "";
1103 end
1104  
1105 if ( NuN_Is_Ignored(c_name) ) then
1106 if ( not NuNData[pKey][c_name].ignoreLst ) then
1107 NuNData[pKey][c_name].ignoreLst = {};
1108 end
1109 if (not NuNGet_TableID(NuNData[pKey][c_name].ignoreLst, pName) ) then
1110 local x = getn(NuNData[pKey][c_name].ignoreLst) + 1;
1111 NuNData[pKey][c_name].ignoreLst[x] = pName;
1112 end
1113 end
1114  
1115 if ( NuN_Is_Friendly(c_name) ) then
1116 if ( not NuNData[pKey][c_name].friendLst ) then
1117 NuNData[pKey][c_name].friendLst = {};
1118 end
1119 if ( not NuNGet_TableID(NuNData[pKey][c_name].friendLst, pName) ) then
1120 local x = getn(NuNData[pKey][c_name].friendLst) + 1;
1121 NuNData[pKey][c_name].friendLst[x] = pName;
1122 end
1123 end
1124  
1125 if (ddRace) then
1126 if ( ddRace == -1 ) then
1127 NuNData[pKey][c_name].race = nil;
1128 else
1129 NuNData[pKey][c_name].race = ddRace;
1130 end
1131 ddRace = nil;
1132 elseif ( c_race ~= nil ) then
1133 NuNData[pKey][c_name].race = NuNGet_TableID(Races, c_race);
1134 end
1135 if (ddClass) then
1136 if ( ddClass == -1 ) then
1137 NuNData[pKey][c_name].cls = nil;
1138 else
1139 NuNData[pKey][c_name].cls = ddClass;
1140 end
1141 ddClass = nil;
1142 elseif ( c_class ~= nil ) then
1143 NuNData[pKey][c_name].cls = NuNGet_TableID(Classes, c_class);
1144 end
1145 if (ddSex) then
1146 if ( ddSex == -1 ) then
1147 NuNData[pKey][c_name].sex = nil;
1148 else
1149 NuNData[pKey][c_name].sex = ddSex;
1150 end
1151 ddSex = nil;
1152 end
1153 if (ddProf1) then
1154 if ( ddProf1 == -1 ) then
1155 NuNData[pKey][c_name].prof1 = nil;
1156 else
1157 NuNData[pKey][c_name].prof1 = ddProf1;
1158 end
1159 ddProf1 = nil;
1160 end
1161 if (ddProf2) then
1162 if ( ddProf2 == -1 ) then
1163 NuNData[pKey][c_name].prof2 = nil;
1164 else
1165 NuNData[pKey][c_name].prof2 = ddProf2;
1166 end
1167 ddProf2 = nil;
1168 end
1169 if (ddCRank) then
1170 if ( ddCRank == -1 ) then
1171 NuNData[pKey][c_name].crank = nil;
1172 else
1173 NuNData[pKey][c_name].crank = ddCRank;
1174 end
1175 ddCRank = nil;
1176 end
1177 if (ddHRank) then
1178 if ( ddHRank == -1 ) then
1179 NuNData[pKey][c_name].hrank = nil;
1180 else
1181 NuNData[pKey][c_name].hrank = ddHRank;
1182 end
1183 ddHRank = nil;
1184 end
1185  
1186 c_text = NuNText:GetText();
1187 NuN_SetCText(c_name);
1188  
1189 for n = 1, uBttns, 1 do
1190 if (bttnChanges[n] ~= "") and (bttnChanges[n] ~= nil) then
1191 hdNbr = pHead..n;
1192 nameHdNbr = c_name..hdNbr;
1193 if (not NuNData[pKey][nameHdNbr]) then
1194 NuNData[pKey][nameHdNbr] = {};
1195 end
1196 if (bttnChanges[n] == 1) then
1197 NuNData[pKey][nameHdNbr].txt = "";
1198 else
1199 NuNData[pKey][nameHdNbr].txt = bttnChanges[n];
1200 end
1201 end
1202 end
1203  
1204 for n = 1, uBttns, 1 do
1205 b = n + detlOffset;
1206 if (bttnChanges[b] ~= "") and (bttnChanges[b] ~= nil) then
1207 nameDtNbr = c_name..pDetl..n;
1208 if (not NuNData[pKey][nameDtNbr]) then
1209 NuNData[pKey][nameDtNbr] = {};
1210 end
1211 if (bttnChanges[b] == 1) then
1212 NuNData[pKey][nameDtNbr].txt = nil;
1213 else
1214 NuNData[pKey][nameDtNbr].txt = bttnChanges[b];
1215 end
1216 end
1217 end
1218  
1219 if ( ( NuNSearchFrame:IsVisible() ) and ( not string.find(NuNSearchTitleText:GetText(), NUN_QUESTS_TEXT) ) ) then
1220 NuNSearch_Search();
1221 end
1222  
1223 ClearButtonChanges();
1224 NuNButtonDelete:Enable();
1225 NuNCOpenChatButton:Enable();
1226 NuNCTTCheckBoxLabel:Show();
1227 NuN_CTTCheckBox:Show();
1228 end
1229  
1230  
1231  
1232 function NuNGNote_WriteNote()
1233 local conflict = false;
1234 local value, index, pad;
1235 local conflicts = 0;
1236 local saveLvl;
1237 local NuN_Creating = nil;
1238  
1239 if ( NuNGNoteTitleButton:IsVisible() ) then
1240 c_note = NuNGNoteTitleButtonText:GetText();
1241 else
1242 c_note = NuNGNoteTextBox:GetText();
1243 end
1244  
1245 NuNConflictedRealmsLabel:SetText(" ");
1246 if ( ( NuN_GLevel_CheckBox:GetChecked() ) and ( not NuNGNoteFrame.confirmed ) ) then
1247 for index, value in NuNData do
1248 if ( ( index ~= pKey ) and ( NuNData[index][Notes] ) ) then
1249 if ( NuNData[index][Notes][c_note] ) then
1250 conflicts = conflicts + 1;
1251 if ( conflicts == 1 ) then
1252 pad = "";
1253 else
1254 pad = ", ";
1255 end
1256 if ( conflicts < 5 ) then
1257 NuNConflictedRealmsLabel:SetText( NuNConflictedRealmsLabel:GetText()..pad..index );
1258 end
1259 conflict = true;
1260 end
1261 end
1262 end
1263 end
1264  
1265 if ( ( conflict ) and ( not NuNGNoteFrame.confirmed ) ) then
1266 if ( conflicts > 4 ) then
1267 NuNConflictedRealmsLabel:SetText( NuNConflictedRealmsLabel:GetText().."..." );
1268 end
1269 ShowUIPanel(NuN_ConfirmFrame);
1270 else
1271 if ( NuN_ConfirmFrame:IsVisible() ) then
1272 HideUIPanel(NuN_ConfirmFrame);
1273 end
1274 if ( not NuN_GNote_OriTitle ) then
1275 NuN_Creating = true;
1276 end
1277 if ( ( ( NuN_GNote_OriTitle ) and ( NuN_GNote_OriTitle ~= c_note ) ) or ( not NuN_GNote_OriTitle ) ) then
1278 if ( ( NuNData[pKey][Notes][c_note] ) or ( NuNData[Notes][c_note] ) ) then
1279 message(NUN_DUPLICATE);
1280 return;
1281 else
1282 if ( NuNData[pKey][Notes][NuN_GNote_OriTitle] ) then
1283 NuNData[pKey][Notes][NuN_GNote_OriTitle] = nil;
1284 elseif ( NuNData[Notes][NuN_GNote_OriTitle] ) then
1285 NuNData[Notes][NuN_GNote_OriTitle] = nil;
1286 end
1287 end
1288 end
1289  
1290 NuN_GNote_OriTitle = c_note;
1291 g_text = NuNGNoteTextScroll:GetText();
1292 if ( g_text == nil ) then
1293 g_text = "";
1294 end
1295  
1296 if ( NuN_GLevel_CheckBox:GetChecked() ) then
1297 saveLvl = "Account";
1298 NuNData[Notes][c_note] = {};
1299 for index, value in NuNData do
1300 if ( NuNData[index][Notes] ) then
1301 if ( NuNData[index][Notes][c_note] ) then
1302 NuNData[index][Notes][c_note] = nil;
1303 end
1304 end
1305 end
1306 else
1307 saveLvl = "Realm";
1308 NuNData[pKey][Notes][c_note] = {};
1309 if ( NuNData[Notes][c_note] ) then
1310 NuNData[Notes][c_note] = nil;
1311 end
1312 end
1313 NuN_SetGText(saveLvl);
1314  
1315 if ( string.find(c_note, "|Hitem:") ) then
1316 simpleName = NuN_GetSimpleName(c_note);
1317 if ( simpleName ~= nil ) then
1318 NuNData[itmIndex][simpleName] = c_note;
1319 end
1320 end
1321 if ( NuNGNoteFrame.type ) then
1322 if ( NuN_GLevel_CheckBox:GetChecked() ) then
1323 NuNData[Notes][c_note].type = NuNGNoteFrame.type;
1324 else
1325 NuNData[pKey][Notes][c_note].type = NuNGNoteFrame.type;
1326 end
1327 if ( noteTypes[NuNGNoteFrame.type].Command == "QST" ) then
1328 if ( not NuNData[pKey].QuestHistory[pName][c_note] ) then
1329 NuNData[pKey].QuestHistory[pName][c_note] = {};
1330 NuNData[pKey].QuestHistory[pName][c_note].sortDate = tostring(date("%Y%m%d%H%M%S"));
1331 NuNData[pKey].QuestHistory[pName][c_note].pLevel = UnitLevel("player");
1332 NuNData[pKey].QuestHistory[pName][c_note].txt = NUN_CREATED.."\n "..NuN_GetDateStamp().."\n "..NuN_GetLoc().."\n";
1333 NuN_UpdateQuestNotes("Write");
1334 end
1335 elseif ( ( noteTypes[NuNGNoteFrame.type].Command == "NPC" ) and ( NuN_Creating ) and ( NuNSettings[pKey].autoMapNotes ) ) then
1336 NuN_MapNote("Target", "", "", nil);
1337 end
1338 end
1339  
1340 if ( QuestLogFrame:IsVisible() ) then
1341 NuNNew_QuestLog_Update();
1342 end
1343  
1344 if ( ( NuNSearchFrame:IsVisible() ) and ( NuNGNoteFrame.fromQuest ) ) then
1345 NuN_FetchQuestHistory();
1346 elseif ( ( NuNSearchFrame:IsVisible() ) and ( not string.find(NuNSearchTitleText:GetText(), NUN_QUESTS_TEXT) ) ) then
1347 NuNSearch_Search();
1348 end
1349  
1350 NuNGNoteButtonDelete:Enable();
1351 if ( ( MapNotes_OnLoad ) or ( MetaMapNotes_OnLoad ) ) then
1352 NuNMapNoteButton:Enable();
1353 end
1354 NuNGOpenChatButton:Enable();
1355 NuN_GTTCheckBox:Show();
1356 NuN_GTTCheckBox:SetChecked(0);
1357 if ( NuN_PinnedTooltip.type == "General" ) then
1358 NuN_GTTCheckBox:SetChecked( NuN_CheckPinnedBox(c_note) );
1359 end
1360 NuNGTTCheckBoxLabel:Show();
1361 NuNGNoteTitleButtonText:SetText(c_note);
1362 NuNGNoteTextBox:Hide();
1363 NuNGNoteTitleButton:Show();
1364 NuNGNoteHeader:SetText(NUN_SAVED_NOTE);
1365 end
1366 end
1367  
1368  
1369  
1370 function NuN_HideFrame()
1371 HideUIPanel(NuNEditDetailsFrame);
1372 HideUIPanel(NuNFrame);
1373 end
1374  
1375 function NuNGNote_HideFrame()
1376 HideUIPanel(NuNGNoteFrame);
1377 end
1378  
1379  
1380  
1381 function NuN_OnEvent()
1382 if ( event == "VARIABLES_LOADED" ) then
1383 --NuN_Message("NotesUNeed "..NUN_VERSION.." "..NUN_LOADED);
1384  
1385 elseif ( ( event == "IGNORELIST_UPDATE" ) and ( not NuN_importing ) )then
1386 NuN_Update_Ignored();
1387  
1388 elseif ( event == "PLAYER_ENTERING_WORLD" ) then
1389 pFaction = UnitFactionGroup("player");
1390 if ( pFaction == "Horde" ) then
1391 horde = true;
1392 else
1393 horde = false;
1394 end
1395  
1396 tryI = true;
1397 pName = UnitName("player");
1398  
1399 NuN_InitialiseSavedVariables();
1400  
1401 if ( not NuNData[pKey][pName] ) then
1402 NuN_AutoNote();
1403 end
1404 NuN_Update_Friends();
1405 NuN_Update_Ignored();
1406 if ( not NuNSettings[pKey].hideMicro ) then
1407 ShowUIPanel(NuNMicroFrame);
1408 else
1409 HideUIPanel(NuNMicroFrame);
1410 end
1411 NuN_PinnedTooltip:SetScale(NuNSettings[pKey].tScale);
1412 NuN_Tooltip:SetScale(NuNSettings[pKey].tScale);
1413 WorldMapTooltip:SetScale(NuNSettings[pKey].mScale);
1414 NuN_MapTooltip:SetScale(NuNSettings[pKey].mScale);
1415 NuNPopup:SetScale(NuNSettings[pKey].mScale);
1416 if ( ( MapNotes_OnLoad ) or ( MetaMapNotes_OnLoad ) ) then
1417 NuN_MapIndexHouseKeeping();
1418 end
1419 NuN_AtStartup = "True";
1420  
1421 if ( NuN_FirstTime ) then
1422 NuN_FirstTime = nil;
1423 if ( MetaMapNotes_OnLoad ) then
1424 NuNOri_MetaMapNotes_OnEnter = MetaMapNotes_OnEnter;
1425 MetaMapNotes_OnEnter = NuNNew_MetaMapNotes_OnEnter;
1426 NuNOri_MetaMapNotes_OnLeave = MetaMapNotes_OnLeave;
1427 MetaMapNotes_OnLeave = NuNNew_MetaMapNotes_OnLeave;
1428 NuNOri_MetaMapNotes_DeleteNote = MetaMapNotes_DeleteNote;
1429 MetaMapNotes_DeleteNote = NuNNew_MetaMapNotes_DeleteNote;
1430 NuN_GetZoneTableSize = MetaMapNotes_GetZoneTableSize;
1431 elseif ( MapNotes_OnLoad ) then
1432 NuNOri_MapNotes_OnEnter = MapNotes_OnEnter;
1433 MapNotes_OnEnter = NuNNew_MapNotes_OnEnter;
1434 NuNOri_MapNotes_OnLeave = MapNotes_OnLeave;
1435 MapNotes_OnLeave = NuNNew_MapNotes_OnLeave;
1436 NuNOri_MapNotes_DeleteNote = MapNotes_DeleteNote;
1437 MapNotes_DeleteNote = NuNNew_MapNotes_DeleteNote;
1438 NuN_GetZoneTableSize = MapNotes_GetZoneTableSize;
1439 end
1440 end
1441  
1442 elseif ( ( event == "FRIENDLIST_UPDATE" ) and ( not NuN_importing ) ) then
1443 NuN_Update_Friends();
1444  
1445 elseif( event == "PLAYER_LEVEL_UP" ) then
1446 if ( NuNData[pKey][pName] ) then
1447 local lvl = UnitLevel("player");
1448 local cxp = UnitXP("player");
1449 local nxp = UnitXPMax("player");
1450 if ( cxp ) and ( nxp ) then
1451 local diff = nxp - cxp;
1452 if ( cxp > diff ) then
1453 lvl = lvl + 1;
1454 end
1455 end
1456 c_text = NuN_GetCText(pName);
1457 local len = string.len(c_text);
1458 if ( len < NUN_MAX_TXT_BUF ) then
1459 c_text = c_text..NUN_LVL_REACHED..lvl.." : ";
1460 c_text = c_text.."\n "..NuN_GetDateStamp();
1461 c_text = c_text.."\n "..NuN_GetLoc();
1462 NuN_SetCText(pName);
1463 end
1464 end
1465  
1466 -- elseif ( event == "CHAT_MSG_SYSTEM" ) then
1467 -- if ( arg1 ) then
1468 -- local p = string.find(arg1, NUN_COMPLETED);
1469 -- if ( p ) then
1470 -- local q = string.sub(arg1, 1, (p-1));
1471 -- NuN_QuestHandIn(q);
1472 -- timeSinceLastUpdate = 0;
1473 -- NuN_IgnoreNextQUpdate = true;
1474 -- end
1475 -- end
1476  
1477 elseif ( ( event == "PARTY_MEMBERS_CHANGED" ) or ( event == "RAID_ROSTER_UPDATE" ) ) then
1478 if ( NuNSettings[pKey].autoP ) then
1479 NuN_ProcessParty();
1480 end
1481  
1482 elseif ( ( NuN_QuestsUpdating == "False" ) and ( NuN_AtStartup == "False" ) and ( event == "QUEST_LOG_UPDATE" ) ) then
1483 if ( ( NuNGNoteFrame:IsVisible() ) and ( noteTypes[NuNGNoteFrame.type].Command == "QST" ) ) then
1484 HideUIPanel(NuNGNoteFrame);
1485 end
1486 if ( NuN_QuestAccepted ) then
1487 local qHeader = nil;
1488 local qCollapsed = nil;
1489 local qIndex, qLevel, qTag, qComplete = NuN_CheckQuestList(NuN_QuestAccepted);
1490 if ( qIndex > 0 ) then
1491 NuN_ProcessQuest(NuN_QuestAccepted, qLevel, qTag, qHeader, qCollapsed, qComplete, qIndex);
1492 end
1493 NuN_QuestAccepted = nil;
1494 return;
1495 end
1496 if ( NuN_IgnoreNextQUpdate ) then
1497 NuN_IgnoreNextQUpdate = nil;
1498 else
1499 NuN_UpdateQuestNotes(event);
1500 end
1501 end
1502 end
1503  
1504  
1505  
1506 function NuNHRaceDropDown_OnLoad()
1507 UIDropDownMenu_Initialize(NuNHRaceDropDown, NuNHRaceDropDown_Initialise);
1508 UIDropDownMenu_SetWidth(75);
1509 end
1510  
1511 function NuNHRaceDropDown_Initialise()
1512 local info;
1513 for i=1, getn(HRaces), 1 do
1514 info = {};
1515 info.text = HRaces[i];
1516 info.func = NuNHRaceButton_OnClick;
1517 UIDropDownMenu_AddButton(info);
1518 end
1519 end
1520  
1521 function NuNHRaceButton_OnClick()
1522 UIDropDownMenu_SetSelectedID(NuNHRaceDropDown, this:GetID());
1523 ddRace = this:GetID();
1524 lastDD = "Race";
1525 NuNButtonClrDD:Enable();
1526 end
1527  
1528 function NuNARaceDropDown_OnLoad()
1529 UIDropDownMenu_Initialize(NuNARaceDropDown, NuNARaceDropDown_Initialise);
1530 UIDropDownMenu_SetWidth(75);
1531 end
1532  
1533 function NuNARaceDropDown_Initialise()
1534 local info;
1535 for i=1, getn(ARaces), 1 do
1536 info = {};
1537 info.text = ARaces[i];
1538 info.func = NuNARaceButton_OnClick;
1539 UIDropDownMenu_AddButton(info);
1540 end
1541 end
1542  
1543 function NuNARaceButton_OnClick()
1544 UIDropDownMenu_SetSelectedID(NuNARaceDropDown, this:GetID());
1545 ddRace = this:GetID();
1546 lastDD = "Race";
1547 NuNButtonClrDD:Enable();
1548 end
1549  
1550  
1551  
1552 function NuNHClassDropDown_OnLoad()
1553 UIDropDownMenu_Initialize(NuNHClassDropDown, NuNHClassDropDown_Initialise);
1554 UIDropDownMenu_SetWidth(75);
1555 end
1556  
1557 function NuNHClassDropDown_Initialise()
1558 local info;
1559 for i=1, getn(HClasses), 1 do
1560 info = {};
1561 info.text = HClasses[i];
1562 info.func = NuNHClassButton_OnClick;
1563 UIDropDownMenu_AddButton(info);
1564 end
1565 end
1566  
1567 function NuNHClassButton_OnClick()
1568 UIDropDownMenu_SetSelectedID(NuNHClassDropDown, this:GetID());
1569 ddClass = this:GetID();
1570 lastDD = "Class";
1571 NuNButtonClrDD:Enable();
1572 end
1573  
1574 function NuNAClassDropDown_OnLoad()
1575 UIDropDownMenu_Initialize(NuNAClassDropDown, NuNAClassDropDown_Initialise);
1576 UIDropDownMenu_SetWidth(75);
1577 end
1578  
1579 function NuNAClassDropDown_Initialise()
1580 local info;
1581 for i=1, getn(AClasses), 1 do
1582 info = {};
1583 info.text = AClasses[i];
1584 info.func = NuNAClassButton_OnClick;
1585 UIDropDownMenu_AddButton(info);
1586 end
1587 end
1588  
1589 function NuNAClassButton_OnClick()
1590 UIDropDownMenu_SetSelectedID(NuNAClassDropDown, this:GetID());
1591 ddClass = this:GetID();
1592 lastDD = "Class";
1593 NuNButtonClrDD:Enable();
1594 end
1595  
1596  
1597  
1598 function NuNSexDropDown_OnLoad()
1599 UIDropDownMenu_Initialize(NuNSexDropDown, NuNSexDropDown_Initialise);
1600 UIDropDownMenu_SetWidth(75);
1601 end
1602  
1603 function NuNSexDropDown_Initialise()
1604 local info;
1605 for i=1, getn(Sexes), 1 do
1606 info = {};
1607 info.text = Sexes[i];
1608 info.func = NuNSexButton_OnClick;
1609 UIDropDownMenu_AddButton(info);
1610 end
1611 end
1612  
1613 function NuNSexButton_OnClick()
1614 UIDropDownMenu_SetSelectedID(NuNSexDropDown, this:GetID());
1615 ddSex = this:GetID();
1616 lastDD = "Sex";
1617 NuNButtonClrDD:Enable();
1618 end
1619  
1620  
1621  
1622 function NuNProf1DropDown_OnLoad()
1623 UIDropDownMenu_Initialize(NuNProf1DropDown, NuNProf1DropDown_Initialise);
1624 UIDropDownMenu_SetWidth(210);
1625 end
1626  
1627 function NuNProf1DropDown_Initialise()
1628 local info;
1629 for i=1, getn(Professions), 1 do
1630 info = {};
1631 info.text = Professions[i];
1632 info.func = NuNProf1Button_OnClick;
1633 UIDropDownMenu_AddButton(info);
1634 end
1635 end
1636  
1637 function NuNProf1Button_OnClick()
1638 UIDropDownMenu_SetSelectedID(NuNProf1DropDown, this:GetID());
1639 ddProf1 = this:GetID();
1640 lastDD = "Prof1";
1641 NuNButtonClrDD:Enable();
1642 end
1643  
1644  
1645  
1646 function NuNProf2DropDown_OnLoad()
1647 UIDropDownMenu_Initialize(NuNProf2DropDown, NuNProf2DropDown_Initialise);
1648 UIDropDownMenu_SetWidth(210);
1649 end
1650  
1651 function NuNProf2DropDown_Initialise()
1652 local info;
1653 for i=1, getn(Professions), 1 do
1654 info = {};
1655 info.text = Professions[i];
1656 info.func = NuNProf2Button_OnClick;
1657 UIDropDownMenu_AddButton(info);
1658 end
1659 end
1660  
1661 function NuNProf2Button_OnClick()
1662 UIDropDownMenu_SetSelectedID(NuNProf2DropDown, this:GetID());
1663 ddProf2 = this:GetID();
1664 lastDD = "Prof2";
1665 NuNButtonClrDD:Enable();
1666 end
1667  
1668  
1669  
1670 function NuNHCRankDropDown_OnLoad()
1671 UIDropDownMenu_Initialize(NuNHCRankDropDown, NuNHCRankDropDown_Initialise);
1672 UIDropDownMenu_SetWidth(125);
1673 end
1674  
1675 function NuNHCRankDropDown_Initialise()
1676 local info;
1677 for i=1, getn(HRanks), 1 do
1678 info = {};
1679 info.text = HRanks[i];
1680 info.func = NuNHCRankButton_OnClick;
1681 UIDropDownMenu_AddButton(info);
1682 end
1683 end
1684  
1685 function NuNHCRankButton_OnClick()
1686 UIDropDownMenu_SetSelectedID(NuNHCRankDropDown, this:GetID());
1687 ddCRank = this:GetID();
1688 lastDD = "CRank";
1689 NuNButtonClrDD:Enable();
1690 end
1691  
1692 function NuNACRankDropDown_OnLoad()
1693 UIDropDownMenu_Initialize(NuNACRankDropDown, NuNACRankDropDown_Initialise);
1694 UIDropDownMenu_SetWidth(125);
1695 end
1696  
1697 function NuNACRankDropDown_Initialise()
1698 local info;
1699 for i=1, getn(ARanks), 1 do
1700 info = {};
1701 info.text = ARanks[i];
1702 info.func = NuNACRankButton_OnClick;
1703 UIDropDownMenu_AddButton(info);
1704 end
1705 end
1706  
1707 function NuNACRankButton_OnClick()
1708 UIDropDownMenu_SetSelectedID(NuNACRankDropDown, this:GetID());
1709 ddCRank = this:GetID();
1710 lastDD = "CRank";
1711 NuNButtonClrDD:Enable();
1712 end
1713  
1714  
1715  
1716 function NuNHHRankDropDown_OnLoad()
1717 UIDropDownMenu_Initialize(NuNHHRankDropDown, NuNHHRankDropDown_Initialise);
1718 UIDropDownMenu_SetWidth(125);
1719 end
1720  
1721 function NuNHHRankDropDown_Initialise()
1722 local info;
1723 for i=1, getn(HRanks), 1 do
1724 info = {};
1725 info.text = HRanks[i];
1726 info.func = NuNHHRankButton_OnClick;
1727 UIDropDownMenu_AddButton(info);
1728 end
1729 end
1730  
1731 function NuNHHRankButton_OnClick()
1732 UIDropDownMenu_SetSelectedID(NuNHHRankDropDown, this:GetID());
1733 ddHRank = this:GetID();
1734 lastDD = "HRank";
1735 NuNButtonClrDD:Enable();
1736 end
1737  
1738 function NuNAHRankDropDown_OnLoad()
1739 UIDropDownMenu_Initialize(NuNAHRankDropDown, NuNAHRankDropDown_Initialise);
1740 UIDropDownMenu_SetWidth(125);
1741 end
1742  
1743 function NuNAHRankDropDown_Initialise()
1744 local info;
1745 for i=1, getn(ARanks), 1 do
1746 info = {};
1747 info.text = ARanks[i];
1748 info.func = NuNAHRankButton_OnClick;
1749 UIDropDownMenu_AddButton(info);
1750 end
1751 end
1752  
1753 function NuNAHRankButton_OnClick()
1754 UIDropDownMenu_SetSelectedID(NuNAHRankDropDown, this:GetID());
1755 ddHRank = this:GetID();
1756 lastDD = "HRank";
1757 NuNButtonClrDD:Enable();
1758 end
1759  
1760  
1761 function NuNOptionsSearchDropDown_OnLoad()
1762 UIDropDownMenu_Initialize(NuNOptionsSearchDropDown, NuNOptionsSearchDropDown_Initialise);
1763 UIDropDownMenu_SetWidth(165);
1764 end
1765  
1766 function NuNOptionsSearchDropDown_Initialise()
1767 local info;
1768 for i=1, getn(searchFor), 1 do
1769 info = {};
1770 info.text = searchFor[i].Display;
1771 info.func = NuNOptionsSearchDropDown_OnClick;
1772 UIDropDownMenu_AddButton(info);
1773 end
1774 end
1775  
1776 function NuNOptionsSearchDropDown_OnClick()
1777 UIDropDownMenu_SetSelectedID(NuNOptionsSearchDropDown, this:GetID());
1778 ddSearch = this:GetID();
1779 end
1780  
1781  
1782  
1783 function NuNSearchClassDropDown_OnLoad()
1784 UIDropDownMenu_Initialize(NuNSearchClassDropDown, NuNSearchClassDropDown_Initialise);
1785 UIDropDownMenu_SetWidth(204);
1786 end
1787  
1788 function NuNSearchClassDropDown_Initialise()
1789 local info;
1790 for i=1, getn(AllClasses), 1 do
1791 info = {};
1792 info.text = AllClasses[i];
1793 info.func = NuNSearchClassButton_OnClick;
1794 UIDropDownMenu_AddButton(info);
1795 end
1796 end
1797  
1798 function NuNSearchClassButton_OnClick()
1799 UIDropDownMenu_SetSelectedID(NuNSearchClassDropDown, this:GetID());
1800 ddClassSearch = this:GetID();
1801 end
1802  
1803  
1804  
1805 function NuNSearchProfDropDown_OnLoad()
1806 UIDropDownMenu_Initialize(NuNSearchProfDropDown, NuNSearchProfDropDown_Initialise);
1807 UIDropDownMenu_SetWidth(204);
1808 end
1809  
1810 function NuNSearchProfDropDown_Initialise()
1811 local info;
1812 for i=1, getn(Professions), 1 do
1813 info = {};
1814 info.text = Professions[i];
1815 info.func = NuNSearchProfButton_OnClick;
1816 UIDropDownMenu_AddButton(info);
1817 end
1818 end
1819  
1820 function NuNSearchProfButton_OnClick()
1821 UIDropDownMenu_SetSelectedID(NuNSearchProfDropDown, this:GetID());
1822 ddProfSearch = this:GetID();
1823 end
1824  
1825 function NuNChatDropDown_OnLoad()
1826 UIDropDownMenu_Initialize(NuNChatDropDown, NuNChatDropDown_Initialise);
1827 UIDropDownMenu_SetWidth(110);
1828 end
1829  
1830 function NuNChatDropDown_Initialise()
1831 local info;
1832 for i=1, getn(transmitTo), 1 do
1833 info = {};
1834 info.text = transmitTo[i].Display;
1835 info.func = NuNChatButton_OnClick;
1836 UIDropDownMenu_AddButton(info);
1837 end
1838 end
1839  
1840 function NuNChatButton_OnClick()
1841 UIDropDownMenu_SetSelectedID(NuNChatDropDown, this:GetID());
1842 sendTo = transmitTo[this:GetID()].Command;
1843 if ( sendTo == "WHISPER" ) or ( sendTo == "NuN" ) then
1844 NuNChatTextBox:SetText("");
1845 NuNChatTextBox:Show();
1846 NuNTransmit:Disable();
1847 else
1848 if ( NuNChatTextBox:IsVisible() ) then
1849 NuNChatTextBox:Hide();
1850 end
1851 NuNTransmit:Enable();
1852 end
1853 end
1854  
1855 function NuNGTypeDropDown_OnLoad()
1856 UIDropDownMenu_Initialize(NuNGTypeDropDown, NuNGTypeDropDown_Initialise);
1857 UIDropDownMenu_SetWidth(70);
1858 end
1859  
1860 function NuNGTypeDropDown_Initialise()
1861 local info;
1862 for i=1, getn(noteTypes), 1 do
1863 info = {};
1864 info.text = noteTypes[i].Display;
1865 info.func = NuNGTypeButton_OnClick;
1866 UIDropDownMenu_AddButton(info);
1867 end
1868 end
1869  
1870 function NuNGTypeButton_OnClick()
1871 UIDropDownMenu_SetSelectedID(NuNGTypeDropDown, this:GetID());
1872 NuNGNoteFrame.type = this:GetID();
1873 if ( noteTypes[NuNGNoteFrame.type].Command == "NPC" ) then
1874 NuNNPCTargetButton:Show();
1875 else
1876 NuNNPCTargetButton:Hide();
1877 end
1878 end
1879  
1880  
1881  
1882 function NuNEditDetails()
1883 local prntObj;
1884 local prntTxtObj;
1885  
1886 newTxt = (NuNEditDetailsBox:GetText());
1887  
1888 if (newTxt ~= oriTxt) then
1889 chldObj = getglobal("NuNInforButton"..bttnNumb);
1890 if ((newTxt == "") and (isTitle)) or ((newTxt == nil) and (isTitle)) then
1891 chldTxtObj = getglobal("NuNInforButton"..bttnNumb.."ButtonTextDetail");
1892 chldTxt = chldTxtObj:SetText("");
1893 chldObj:Disable();
1894 else
1895 chldObj:Enable();
1896 end
1897 bttnTxtObj:SetText(newTxt);
1898  
1899 if (isTitle) then
1900 if ( NuNEditDetail_CheckButton:GetChecked() ) then
1901 hdNbr = pHead..bttnNumb;
1902 nameHdNbr = c_name..hdNbr;
1903 if (not NuNSettings[pKey][hdNbr]) then
1904 NuNSettings[pKey][hdNbr] = {};
1905 end
1906 NuNSettings[pKey][hdNbr].txt = newTxt;
1907 if ( NuNData[pKey][nameHdNbr] ) then
1908 NuNData[pKey][nameHdNbr] = nil;
1909 end
1910 else
1911 index = tonumber(bttnNumb);
1912 if ( ( newTxt == "" ) or ( newTxt == nil ) )then
1913 bttnChanges[index] = 1;
1914 else
1915 bttnChanges[index] = newTxt;
1916 end
1917 end
1918 else
1919 index = bttnNumb + detlOffset;
1920 if ( newTxt == "" ) then
1921 bttnChanges[index] = 1;
1922 else
1923 bttnChanges[index] = newTxt;
1924 end
1925 if ( index == (detlOffset + 1) ) then
1926 prntTxtObj = getglobal("NuNTitleButton"..bttnNumb.."ButtonTextHeading");
1927 if ( prntTxtObj:GetText() == dfltHeadings[1] ) then
1928 c_guild = newTxt;
1929 end
1930 end
1931 end
1932 NuNEditDetails_HideFrame();
1933 else
1934 NuNEditDetails_HideFrame();
1935 end
1936 end
1937  
1938  
1939  
1940 function NuNEditDetails_HideFrame()
1941 NuNButtonSaveNote:Enable();
1942 HideUIPanel(NuNEditDetailsFrame);
1943 end
1944  
1945  
1946  
1947 function NuNUserButton_OnClick(bttn)
1948 local bttnName = bttn:GetName();
1949 local prfx = (string.sub(bttnName, 1, 8));
1950  
1951 bttnNumb = (string.sub(bttnName, 15, 15));
1952  
1953 if (prfx == "NuNTitle") then
1954 isTitle = true;
1955 bttnTxtObj = getglobal(bttnName.."ButtonTextHeading");
1956 else
1957 isTitle = false;
1958 bttnTxtObj = getglobal(bttnName.."ButtonTextDetail");
1959 end
1960 oriTxt = bttnTxtObj:GetText();
1961  
1962 NuNEditDetails_ShowFrame(isTitle);
1963 end
1964  
1965  
1966  
1967 function NuNEditDetails_ShowFrame(isTitle)
1968 NuNButtonSaveNote:Disable();
1969  
1970 NuNText:ClearFocus();
1971 if (oriTxt == nil) then
1972 NuNEditDetailsBox:SetText("");
1973 else
1974 NuNEditDetailsBox:SetText(oriTxt);
1975 end
1976 if (isTitle) then
1977 NuNCheckBoxLabel:SetText("Save as Default");
1978 NuNEditDetail_CheckButton:SetChecked(0);
1979 NuNEditDetailsRestoreButton:Enable();
1980 NuNEditDetail_CheckButton:Show();
1981 NuNEditDetailsRestoreButton:Show();
1982 else
1983 NuNCheckBoxLabel:SetText("");
1984 NuNEditDetail_CheckButton:Hide();
1985 NuNEditDetailsRestoreButton:Hide();
1986 end
1987 ShowUIPanel(NuNEditDetailsFrame);
1988 NuNEditDetailsBox:SetFocus();
1989 end
1990  
1991  
1992  
1993 function NuN_EditDetailCheckButtonOnClick()
1994 if ( NuNEditDetail_CheckButton:GetChecked() ) then
1995 NuNEditDetailsRestoreButton:Disable();
1996 else
1997 NuNEditDetailsRestoreButton:Enable();
1998 end
1999 end
2000  
2001  
2002  
2003 function NuNEditDetailsRestore()
2004 nameHdNbr = c_name..pHead..bttnNumb;
2005 if ( NuNData[pKey][nameHdNbr] ) then
2006 NuNData[pKey][nameHdNbr] = nil;
2007 end
2008 NuNEditDetails_HideFrame();
2009 NuN_HideFrame();
2010 NuN_ShowNote();
2011 end
2012  
2013  
2014  
2015  
2016  
2017 -------------------------------------------------------------------------------------------
2018 -- Succesful Function Hooks
2019  
2020  
2021  
2022 function NuNNew_FriendsFrameFriendButton_OnClick(button)
2023 NuNOri_FriendsFrameFriendButton_OnClick(button);
2024 if ( ( button == "LeftButton" ) and ( NuNFrame:IsVisible() ) ) then
2025 NuN_HideFrame();
2026 NuN_ShowFriendNote();
2027 end
2028 end
2029  
2030 function NuNNew_FriendsFrameIgnoreButton_OnClick()
2031 NuNOri_FriendsFrameIgnoreButton_OnClick();
2032 if ( ( button == "LeftButton" ) and ( NuNFrame:IsVisible() ) ) then
2033 NuN_HideFrame();
2034 NuN_ShowIgnoreNote();
2035 end
2036 end
2037  
2038 function NuNNew_FriendsFrameGuildPlayerStatusButton_OnClick(button)
2039 NuNOri_FriendsFrameGuildPlayerStatusButton_OnClick(button);
2040 if ( ( button == "LeftButton" ) and ( NuNFrame:IsVisible() ) ) then
2041 NuN_HideFrame();
2042 NuN_ShowGuildNote();
2043 end
2044 end
2045  
2046 function NuNNew_FriendsFrameGuildStatusButton_OnClick(button)
2047 NuNOri_FriendsFrameGuildStatusButton_OnClick(button);
2048 if ( ( button == "LeftButton" ) and ( NuNFrame:IsVisible() ) ) then
2049 NuN_HideFrame();
2050 NuN_ShowGuildNote();
2051 end
2052 end
2053  
2054 function NuNNew_FriendsFrameWhoButton_OnClick(button)
2055 NuNOri_FriendsFrameWhoButton_OnClick(button);
2056 if ( ( button == "LeftButton" ) and ( NuNFrame:IsVisible() ) ) then
2057 NuN_HideFrame();
2058 NuN_ShowWhoNote(WhoFrame.selectedName);
2059 end
2060 end
2061  
2062 function NuNNew_FriendsList_Update()
2063 local bttnIndx;
2064  
2065 NuNOri_FriendsList_Update();
2066  
2067 for i = 1, 10, 1 do
2068 bttnIndx = getglobal("NuN_FriendNotesButton"..i);
2069 NuN_UpdateNoteButton(bttnIndx, i, "F");
2070 end
2071 end
2072  
2073 function NuNNew_IgnoreList_Update()
2074 local bttnIndx;
2075  
2076 NuNOri_IgnoreList_Update();
2077  
2078 for i = 1, 20, 1 do
2079 bttnIndx = getglobal("NuN_IgnoreNotesButton"..i);
2080 NuN_UpdateNoteButton(bttnIndx, i, "I");
2081 end
2082 end
2083  
2084 function NuNNew_GuildStatus_Update()
2085 local bttnIndx;
2086  
2087 NuNOri_GuildStatus_Update();
2088  
2089 for i = 1, 13, 1 do
2090 bttnIndx = getglobal("NuN_GuildSNotesButton"..i);
2091 NuN_UpdateNoteButton(bttnIndx, i, "GS");
2092 bttnIndx = getglobal("NuN_GuildNotesButton"..i);
2093 NuN_UpdateNoteButton(bttnIndx, i, "G");
2094 end
2095 end
2096  
2097 function NuNNew_WhoList_Update()
2098 local bttnIndx;
2099  
2100 NuNOri_WhoList_Update();
2101  
2102 for i = 1, 17, 1 do
2103 bttnIndx = getglobal("NuN_WhoNotesButton"..i);
2104 NuN_UpdateNoteButton(bttnIndx, i, "W");
2105 end
2106 end
2107  
2108 function NuNNew_QuestLog_Update()
2109 local bttnIndx;
2110  
2111 NuNOri_QuestLog_Update();
2112  
2113 for i = 1, 6, 1 do
2114 bttnIndx = getglobal("NuN_QuestNotesButton"..i);
2115 NuN_UpdateNoteButton(bttnIndx, i, NUN_QUEST_C);
2116 end
2117 end
2118  
2119 function NuNNew_ContainerFrameItemButton_OnClick(button, ignoreShift)
2120 if ( ( IsAltKeyDown() ) and ( IsShiftKeyDown() ) ) then
2121 local itmLink = GetContainerItemLink( this:GetParent():GetID(), this:GetID() );
2122 if ( ( itmLink ~= nil ) and ( itmLink ~= "" ) ) then
2123 if ( button == "LeftButton" ) then
2124 if ( ( NuNGNoteFrame:IsVisible() ) or ( NuNFrame:IsVisible() ) ) then
2125 if ( NuNGNoteFrame:IsVisible() ) then
2126 local cText = NuNGNoteTextScroll:GetText().."\n"..itmLink;
2127 NuNGNoteTextScroll:SetText(cText);
2128 return;
2129 elseif ( NuNFrame:IsVisible() ) then
2130 local cText = NuNText:GetText().."\n"..itmLink;
2131 NuNText:SetText(cText);
2132 return;
2133 end
2134 else
2135 NuNGNoteFrame.fromQuest = nil;
2136 if ( ( NuNData[pKey][Notes][itmLink] ) or ( NuNData[Notes][itmLink] ) ) then
2137 c_note = itmLink;
2138 NuN_ShowSavedGNote();
2139 else
2140 NuN_GNoteFromItem(itmLink, "GameTooltip");
2141 end
2142 return;
2143 end
2144 end
2145 end
2146 end
2147  
2148 NuNOri_ContainerFrameItemButton_OnClick(button, ignoreShift);
2149 end
2150  
2151 function NuNNew_SetItemRef(link, text, button)
2152 if ( strsub(link, 1, 6) == "player" ) then
2153 local name = string.sub(link, 8);
2154 if ( name and (string.len(name) > 0) ) then
2155 name = string.gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3");
2156 name = string.gsub(name, "([^%s]*)%s+([^%s]*)", "%2");
2157 if ( IsShiftKeyDown() ) then
2158 local NuN_staticPopup = StaticPopup_Visible("ADD_IGNORE");
2159 if ( not NuN_staticPopup ) then
2160 if ( IsAltKeyDown() ) then
2161 if ( NuNData[pKey][name] ) then
2162 NuN_ShowSavedNote(name);
2163 else
2164 NuN_CreateContact(name, pFaction);
2165 end
2166 else
2167 ttName = name;
2168 NuN_ClearPinnedTT();
2169 NuN_PinnedTooltip:SetOwner(this, "ANCHOR_RIGHT");
2170 NuN_PinUpHeader = true;
2171 NuN_PinnedTooltip.type = "Contact";
2172 NuN_BuildTT(NuN_PinnedTooltip);
2173 NuN_PinUpHeader = false;
2174 NuN_PinnedTooltip:Show();
2175 end
2176 end
2177 end
2178 end
2179 elseif ( IsShiftKeyDown() ) and ( IsAltKeyDown() ) then
2180 if ( button == "LeftButton" ) then
2181 if ( ( NuNGNoteFrame:IsVisible() ) or ( NuNFrame:IsVisible() ) ) then
2182 if ( NuNGNoteFrame:IsVisible() ) then
2183 local cText = NuNGNoteTextScroll:GetText().."\n"..text;
2184 NuNGNoteTextScroll:SetText(cText);
2185 return;
2186 elseif ( NuNFrame:IsVisible() ) then
2187 local cText = NuNText:GetText().."\n"..text;
2188 NuNText:SetText(cText);
2189 return;
2190 end
2191 else
2192 NuNGNoteFrame.fromQuest = nil;
2193 if ( ( NuNData[pKey][Notes][text] ) or ( NuNData[Notes][text] ) ) then
2194 c_note = text;
2195 NuN_ShowSavedGNote();
2196 else
2197 ItemRefTooltip:SetHyperlink(link);
2198 NuN_GNoteFromItem(text, "ItemRefTooltip");
2199 end
2200 return;
2201 end
2202 end
2203 end
2204  
2205 NuNOri_SetItemRef(link, text, button);
2206  
2207 if ( ItemRefTooltip:IsVisible() ) then
2208 NuN_ItemRefTooltip_OnShow();
2209 end
2210 end
2211  
2212 function NuNNew_PaperDollItemSlotButton_OnClick(button)
2213 local itmLink;
2214 if ( ( IsShiftKeyDown() ) and ( IsAltKeyDown() ) ) then
2215 if ( ( InspectFrame ) and ( InspectFrame:IsVisible() ) ) then
2216 itmLink = GetInventoryItemLink("target", this:GetID());
2217 else
2218 itmLink = GetInventoryItemLink("player", this:GetID());
2219 end
2220 if ( ( itmLink ~= nil ) and ( itmLink ~= "" ) ) then
2221 if ( button == "LeftButton" ) then
2222 if ( ( NuNGNoteFrame:IsVisible() ) or ( NuNFrame:IsVisible() ) ) then
2223 if ( NuNGNoteFrame:IsVisible() ) then
2224 local cText = NuNGNoteTextScroll:GetText().."\n"..itmLink;
2225 NuNGNoteTextScroll:SetText(cText);
2226 return;
2227 elseif ( NuNFrame:IsVisible() ) then
2228 local cText = NuNText:GetText().."\n"..itmLink;
2229 NuNText:SetText(cText);
2230 return;
2231 end
2232 else
2233 NuNGNoteFrame.fromQuest = nil;
2234 if ( ( NuNData[pKey][Notes][itmLink] ) or ( NuNData[Notes][itmLink] ) ) then
2235 c_note = itmLink;
2236 NuN_ShowSavedGNote();
2237 else
2238 NuN_GNoteFromItem(itmLink, "GameTooltip");
2239 end
2240 return;
2241 end
2242 end
2243 end
2244 end
2245  
2246 NuNOri_PaperDollItemSlotButton_OnClick(button);
2247 end
2248  
2249 function NuNNew_QuestLogRewardItem_OnClick()
2250 if ( ( IsShiftKeyDown() ) and ( IsAltKeyDown() ) and ( this.rewardType ~= "spell" ) ) then
2251 local itmLink = GetQuestLogItemLink(this.type, this:GetID());
2252 if ( ( itmLink ~= nil ) and ( itmLink ~= "" ) ) then
2253 local sLink = NuN_GetSimpleName(itmLink);
2254 if ( ( NuNGNoteFrame:IsVisible() ) and ( sLink == prevLink ) ) then
2255 HideUIPanel(NuNGNoteFrame);
2256 else
2257 prevLink = sLink;
2258 NuNGNoteFrame.fromQuest = nil;
2259 if ( ( NuNData[pKey][Notes][itmLink] ) or ( NuNData[Notes][itmLink] ) ) then
2260 c_note = itmLink;
2261 NuN_ShowSavedGNote();
2262 else
2263 NuN_GNoteFromItem(itmLink, "GameTooltip");
2264 local q = GetQuestLogSelection();
2265 if ( q ) then
2266 q = GetQuestLogTitle(q);
2267 if ( q ) then
2268 if ( NuNGNoteFrame:IsVisible() ) then
2269 NuNGNoteTextScroll:SetText( NuNGNoteTextScroll:GetText().."\n"..NUN_QUEST..q );
2270 end
2271 end
2272 end
2273 end
2274 end
2275 return;
2276 end
2277 end
2278  
2279 NuNOri_QuestLogRewardItem_OnClick();
2280 end
2281  
2282 function NuNNew_QuestItem_OnClick()
2283 if ( ( IsShiftKeyDown() ) and ( IsAltKeyDown() ) and ( this.rewardType ~= "spell" ) ) then
2284 local itmLink = GetQuestItemLink(this.type, this:GetID());
2285 if ( ( itmLink ~= nil ) and ( itmLink ~= "" ) ) then
2286 local sLink = NuN_GetSimpleName(itmLink);
2287 if ( ( NuNGNoteFrame:IsVisible() ) and ( sLink == prevLink ) ) then
2288 HideUIPanel(NuNGNoteFrame);
2289 else
2290 prevLink = sLink;
2291 NuNGNoteFrame.fromQuest = nil;
2292 if ( ( NuNData[pKey][Notes][itmLink] ) or ( NuNData[Notes][itmLink] ) ) then
2293 c_note = itmLink;
2294 NuN_ShowSavedGNote();
2295 else
2296 NuN_GNoteFromItem(itmLink, "GameTooltip");
2297 local giver = QuestFrameNpcNameText:GetText();
2298 local quest = QuestTitleText:GetText();
2299 if ( giver ) then
2300 giver = "\n"..giver.."\n"..NuN_GetLoc();
2301 end
2302 if ( quest ) then
2303 giver = giver.."\n"..NUN_QUEST..quest;
2304 end
2305 if ( giver ) then
2306 NuNGNoteTextScroll:SetText( NuNGNoteTextScroll:GetText()..giver );
2307 end
2308 end
2309 end
2310 return;
2311 end
2312 end
2313  
2314 NuNOri_QuestItem_OnClick();
2315 end
2316  
2317 function NuNNew_QuestRewardItem_OnClick()
2318 if ( ( IsShiftKeyDown() ) and ( IsAltKeyDown() ) and ( this.rewardType ~= "spell" ) ) then
2319 local itmLink = GetQuestItemLink(this.type, this:GetID());
2320 if ( ( itmLink ~= nil ) and ( itmLink ~= "" ) ) then
2321 local sLink = NuN_GetSimpleName(itmLink);
2322 if ( ( NuNGNoteFrame:IsVisible() ) and ( sLink == prevLink ) ) then
2323 HideUIPanel(NuNGNoteFrame);
2324 else
2325 prevLink = sLink;
2326 NuNGNoteFrame.fromQuest = nil;
2327 if ( ( NuNData[pKey][Notes][itmLink] ) or ( NuNData[Notes][itmLink] ) ) then
2328 c_note = itmLink;
2329 NuN_ShowSavedGNote();
2330 else
2331 NuN_GNoteFromItem(itmLink, "GameTooltip");
2332 end
2333 end
2334 return;
2335 end
2336 end
2337  
2338 NuNOri_QuestRewardItem_OnClick();
2339 end
2340  
2341 function NuNNew_AbandonQuest()
2342 local qN = GetAbandonQuestName();
2343 timeSinceLastUpdate = 0;
2344 NuN_IgnoreNextQUpdate = true;
2345 NuN_AbandonQuest(qN);
2346 NuNOri_AbandonQuest();
2347 end
2348  
2349 function NuNNew_QuestDetailAcceptButton_OnClick()
2350 NuNOri_QuestDetailAcceptButton_OnClick();
2351 NuN_QuestAccepted = GetTitleText();
2352 end
2353  
2354 function NuNNew_QuestRewardCompleteButton_OnClick()
2355 local qN = GetTitleText();
2356 NuN_QuestHandIn(qN);
2357 NuNOri_QuestRewardCompleteButton_OnClick();
2358 end
2359  
2360 -------------------------------------------------------------------------------------------
2361 -- Attempt to Hook MapNotes functions
2362  
2363 function NuNNew_MapNotes_OnEnter(id)
2364 if ( NuNPopup:IsVisible() ) then
2365 return;
2366 end
2367 NuNOri_MapNotes_OnEnter(id);
2368 NuN_WorldMapTooltip_OnShow(id);
2369 end
2370  
2371 function NuNNew_MapNotes_OnLeave(id)
2372 if ( NuNPopup:IsVisible() ) then
2373 popUpHide = true;
2374 return;
2375 end
2376 NuNOri_MapNotes_OnLeave(id);
2377 end
2378  
2379 function NuNNew_MapNotes_DeleteNote(id, cont, zone)
2380 local lId = id;
2381 local lCont, lZone, lLst;
2382 if ( id > 0 ) then
2383 lCont, lZone, lLst = NuN_PreDeleteMapIndex(id, cont, zone);
2384 end
2385 NuNOri_MapNotes_DeleteNote(id, cont, zone);
2386 if ( ( lId > 0 ) and ( cont ~= 0 ) ) then
2387 NuN_DeleteMapIndex(lId, lCont, lZone, lLst);
2388 end
2389 end
2390  
2391 -------------------------------------------------------------------------------------------
2392 -- Attempt to Hook MetaMapNotes functions
2393  
2394 function NuNNew_MetaMapNotes_OnEnter(id)
2395 if ( NuNPopup:IsVisible() ) then
2396 return;
2397 end
2398 NuNOri_MetaMapNotes_OnEnter(id);
2399 WorldMapTooltip:SetScale(NuNSettings[pKey].mScale);
2400 WorldMapTooltip:Show();
2401 NuN_WorldMapTooltip_OnShow(id);
2402 end
2403  
2404 function NuNNew_MetaMapNotes_OnLeave(id)
2405 if ( NuNPopup:IsVisible() ) then
2406 popUpHide = true;
2407 return;
2408 end
2409 NuNOri_MetaMapNotes_OnLeave(id);
2410 end
2411  
2412 function NuNNew_MetaMapNotes_DeleteNote(id, cont, zone)
2413 local lId = id;
2414 local lCont, lZone, lLst;
2415 if ( id > 0 ) then
2416 lCont, lZone, lLst = NuN_PreDeleteMapIndex(id, cont, zone);
2417 end
2418 NuNOri_MetaMapNotes_DeleteNote(id, cont, zone);
2419 if ( ( lId > 0 ) and ( cont ~= 0 ) ) then
2420 NuN_DeleteMapIndex(lId, lCont, lZone, lLst);
2421 end
2422 end
2423  
2424 -------------------------------------------------------------------------------------------
2425  
2426  
2427 function NuN_GNoteFromItem(link, theTT)
2428 local catTxt = "";
2429  
2430 catTxt = NuN_ExtractTooltipInfo(catTxt, theTT);
2431 c_note = link;
2432 c_type = NuNGet_CommandID(noteTypes, "ITM");
2433 NuN_ShowTitledGNote(catTxt);
2434 end
2435  
2436  
2437 function NuN_ExtractTooltipInfo(xTTText, theTT)
2438 local lftTxt, rgtTxt, needRight;
2439 local endLine = "\n";
2440 local tmpTxt;
2441 local foundTTInfo = false;
2442 local ttLLen = NUN_TT_LEN;
2443  
2444 if ( NuNSettings[pKey].ttLLen ) then
2445 if ( NuNSettings[pKey].ttLLen == "" ) then
2446 ttLLen = 0;
2447 else
2448 ttLLen = tonumber( NuNSettings[pKey].ttLLen );
2449 end
2450 end
2451  
2452 for i=2, 23, 1 do
2453 lftTxt = getglobal(theTT.."TextLeft"..i):GetText();
2454 rgtTxt = getglobal(theTT.."TextRight"..i):GetText();
2455 needRight = false;
2456 tmpTxt = "";
2457 if ( lftTxt ~= nil ) then
2458 if ( ( string.find(lftTxt, "\"" ) ) or ( ( string.find(lftTxt, "/") ) and ( string.find(lftTxt, "\)") ) ) ) then
2459 tmpTxt = NUN_GOLD..lftTxt;
2460 elseif ( string.find(lftTxt, ":") ) then
2461 tmpTxt = NUN_GREEN..lftTxt;
2462 else
2463 tmpTxt = NUN_WHITE..lftTxt;
2464 end
2465 if ( rgtTxt ~= nil ) then
2466 needRight = NuN_TestLeftTT(lftTxt);
2467 if ( needRight ) then
2468 local lLen = string.len(lftTxt);
2469 local rLen = string.len(rgtTxt);
2470 local spaces = ttLLen - (lLen + rLen) - 10;
2471 local pad = string.rep(" ", spaces);
2472 tmpTxt = tmpTxt..pad..rgtTxt;
2473 end
2474 end
2475 xTTText = xTTText..tmpTxt..NUN_C_END..endLine;
2476 foundTTInfo = true;
2477 end
2478 end
2479  
2480 return xTTText;
2481 end
2482  
2483  
2484  
2485 function NuN_TestLeftTT(lftTxt)
2486 if ( string.find(lftTxt, NUN_HAND ) ) or ( string.find(lftTxt, NUN_HAND2) ) or ( string.find(lftTxt, NUN_FEET ) ) or ( string.find(lftTxt, NUN_LEGS ) ) or ( string.find(lftTxt, NUN_HEAD ) ) or ( string.find(lftTxt, NUN_WAIST ) ) or ( string.find(lftTxt, NUN_SHOULDER ) ) or ( string.find(lftTxt, NUN_CHEST ) ) or ( string.find(lftTxt, NUN_WRIST ) ) or ( string.find(lftTxt, NUN_DAMAGE ) ) then
2487 return true;
2488 else
2489 return false;
2490 end
2491 end
2492  
2493  
2494  
2495 function NuN_Who()
2496 local wName = nil;
2497 local wGuildName = nil;
2498 local wRace = nil;
2499 local wClass = nil;
2500 local bttnHeadingText1;
2501 local bttnDetailText1;
2502  
2503 SendWho(c_name);
2504  
2505 local n = GetNumWhoResults();
2506 for i = 1, n, 1 do
2507 wName = GetWhoInfo(i);
2508 if ( wName == c_name ) then
2509 wName, wGuildName, wLvl, wRace, wClass, wZone = GetWhoInfo(i);
2510 if ( wGuildName ~= nil ) then
2511 c_guild = wGuildName;
2512 end
2513 bttnHeadingText1 = getglobal("NuNTitleButton1ButtonTextHeading");
2514 bttnDetailText1 = getglobal("NuNInforButton1ButtonTextDetail");
2515 if ( bttnHeadingText1:GetText() == dfltHeadings[1] ) and ( wGuildName ~= nil) then
2516 bttnDetailText1:SetText(wGuildName);
2517 c_guild = wGuildName;
2518 if ( wGuildName == "" ) then
2519 bttnChanges[6] = 1;
2520 else
2521 bttnChanges[6] = wGuildName;
2522 end
2523 end
2524 if ( wClass ~= nil ) then
2525 c_class = wClass;
2526 ddClass = NuNGet_TableID(Classes, c_class);
2527 UIDropDownMenu_SetSelectedID(NuNClassDropDown, ddClass);
2528 UIDropDownMenu_SetText(c_class, NuNClassDropDown);
2529 end
2530 if ( wRace ~= nil ) then
2531 c_race = wRace;
2532 ddRace = NuNGet_TableID(Races, c_race);
2533 UIDropDownMenu_SetSelectedID(NuNRaceDropDown, ddRace);
2534 UIDropDownMenu_SetText(c_race, NuNRaceDropDown);
2535 end
2536 end
2537 end
2538 end
2539  
2540  
2541  
2542 function NuN_Target()
2543 local lName;
2544 local lRace;
2545 local lClass;
2546 local lSex;
2547 local lPvPRank;
2548 local lPvPRankID;
2549 local lgName;
2550 local lgRank;
2551 local lgRankIndex;
2552 local theUnitID = nil;
2553  
2554 if ( ( UnitInParty("target") ) or ( UnitInRaid("target") ) ) then
2555 theUnitID = "target";
2556 end
2557  
2558 if ( theUnitID == nil ) then
2559 theUnitID = NuN_CheckPartyByName(c_name);
2560 end
2561  
2562 if ( theUnitID == nil ) then
2563 theUnitID = NuN_CheckRaidByName(c_name);
2564 end
2565  
2566 if ( theUnitID == nil ) then
2567 TargetByName(c_name);
2568 lName = UnitName("target");
2569 if ( lName == c_name ) then
2570 theUnitID = "target";
2571 else
2572 ClearTarget();
2573 end
2574 end
2575  
2576 if ( unitTest == true ) then
2577 unitTest = false;
2578 else
2579 if ( theUnitID ~= nil ) then
2580 lRace = UnitRace(theUnitID);
2581 if ( lRace ~= nil ) then
2582 c_race = lRace;
2583 ddRace = NuNGet_TableID(Races, c_race);
2584 UIDropDownMenu_SetSelectedID(NuNRaceDropDown, ddRace);
2585 UIDropDownMenu_SetText(c_race, NuNRaceDropDown);
2586 end
2587  
2588 lClass = UnitClass(theUnitID);
2589 if ( lClass ~= nil ) then
2590 c_class = lClass;
2591 ddClass = NuNGet_TableID(Classes, c_class);
2592 UIDropDownMenu_SetSelectedID(NuNClassDropDown, ddClass);
2593 UIDropDownMenu_SetText(c_class, NuNClassDropDown);
2594 end
2595  
2596 lSex = UnitSex(theUnitID);
2597 if ( lSex ~= nil ) then
2598 if ( lSex == 0 ) then
2599 lsex = NUN_MALE;
2600 else
2601 lsex = NUN_FEMALE;
2602 end
2603 ddSex = NuNGet_TableID(Sexes, lsex);
2604 UIDropDownMenu_SetSelectedID(NuNSexDropDown, ddSex);
2605 UIDropDownMenu_SetText(lsex, NuNSexDropDown);
2606 end
2607  
2608 lPvPRankID = UnitPVPRank(theUnitID);
2609 if ( lPvPRankID ~= nil ) and ( lPvPRankID > 0 ) then
2610 lPvPRank = GetPVPRankInfo(lPvPRankID);
2611 ddCRank = NuNGet_TableID(Ranks, lPvPRank);
2612 UIDropDownMenu_SetSelectedID(NuNCRankDropDown, ddCRank);
2613 UIDropDownMenu_SetText(lPvPRank, NuNCRankDropDown);
2614 end
2615  
2616 lgName, lgRank, lgRankIndex = GetGuildInfo(theUnitID);
2617 if ( lgName ~= nil ) then
2618 c_guild = lgName;
2619 end
2620 bttnHeadingText1 = getglobal("NuNTitleButton1ButtonTextHeading");
2621 bttnDetailText1 = getglobal("NuNInforButton1ButtonTextDetail");
2622 bttnHeadingText2 = getglobal("NuNTitleButton2ButtonTextHeading");
2623 bttnDetailText2 = getglobal("NuNInforButton2ButtonTextDetail");
2624 if ( lgName ~= "" ) and ( lgName ~= nil ) then
2625 if ( bttnHeadingText1:GetText() == dfltHeadings[1] ) then
2626 bttnDetailText1:SetText(lgName);
2627 bttnChanges[6] = lgName;
2628 end
2629 if ( bttnHeadingText2:GetText() == dfltHeadings[2] ) then
2630 if ( lgRankIndex == 0 ) then
2631 lgRankTxt = ( "GM : "..lgRank );
2632 else
2633 lgRankTxt = ( lgRankIndex.." : "..lgRank );
2634 end
2635 bttnDetailText2:SetText(lgRankTxt);
2636 bttnChanges[7] = lgRankTxt;
2637 end
2638 end
2639  
2640 if ( theUnitID == "target" ) then
2641 for index = 1, getn(invSlotList), 1 do
2642 local text = GetInventoryItemLink(theUnitID, index);
2643 if ( text ) then
2644 local link = NuN_GetLink(text);
2645 if ( link ) then
2646 ItemRefTooltip:SetHyperlink(link);
2647 NuN_CheckSlot();
2648 if ( typeIndex ) then
2649 NuNText:SetText( NuNText:GetText() .. "\n" .. invSlotList[typeIndex].name .. text );
2650 else
2651 NuNText:SetText( NuNText:GetText() .. "\n" .. text );
2652 end
2653 end
2654 end
2655 end
2656 end
2657  
2658 end
2659 end
2660 return theUnitID;
2661 end
2662  
2663  
2664  
2665 function NuN_CheckSlot()
2666 local lftTxt;
2667  
2668 typeIndex = nil;
2669 NuN_Fingers = 0;
2670 NuN_Trinkets = 0;
2671 NuN_Hand = 0;
2672 for i=2, 5, 1 do
2673 lftTxt = getglobal("ItemRefTooltipTextLeft"..i):GetText();
2674 if ( lftTxt ) then
2675 typeIndex = NuN_Wearable(lftTxt);
2676 if ( typeIndex ~= nil ) then
2677 break;
2678 end
2679 end
2680 end
2681 end
2682  
2683  
2684  
2685 function NuN_Wearable(txt)
2686 if ( string.find(txt, NUN_HEAD) ) then
2687 return 1;
2688 elseif ( string.find(txt, NUN_NECK) ) then
2689 return 2;
2690 elseif ( string.find(txt, NUN_SHOULDER) ) then
2691 return 3;
2692 elseif ( string.find(txt, NUN_SHIRT) ) then
2693 return 4;
2694 elseif ( string.find(txt, NUN_CHEST) ) then
2695 return 5;
2696 elseif ( string.find(txt, NUN_WAIST) ) then
2697 return 6;
2698 elseif ( string.find(txt, NUN_LEGS) ) then
2699 return 7;
2700 elseif ( string.find(txt, NUN_FEET) ) then
2701 return 8;
2702 elseif ( string.find(txt, NUN_WRIST) ) then
2703 return 9;
2704 elseif ( string.find(txt, NUN_HANDS) ) then
2705 return 10;
2706 elseif ( string.find(txt, NUN_FINGER) ) then
2707 NuN_Fingers = NuN_Fingers + 1;
2708 return 11 + NuN_Fingers;
2709 elseif ( string.find(txt, NUN_TRINKET) ) then
2710 NuN_Trinkets = NuN_Trinkets + 1;
2711 return 13 + NuN_Trinkets;
2712 elseif ( string.find(txt, NUN_BACK) ) then
2713 return 15;
2714 elseif ( string.find(txt, NUN_HAND) ) then
2715 NuN_Hand = NuN_Hand + 1;
2716 return 16 + NuN_Hand;
2717 elseif ( string.find(txt, NUN_HAND2) ) then
2718 return 16;
2719 elseif ( string.find(txt, NUN_GUN) ) or ( string.find(txt, NUN_RANGED) ) or ( string.find(txt, NUN_BOW_U) ) or ( string.find(txt, NUN_BOW_L) ) or ( string.find(txt, NUN_WAND) or ( string.find(txt, NUN_THROWN) ) ) then
2720 return 18;
2721 elseif ( string.find(txt, NUN_TABARD) ) then
2722 return 19;
2723 else
2724 return nil;
2725 end
2726 end
2727  
2728  
2729  
2730 function NuN_Delete()
2731 if ( NuNData[pKey][c_name] ) then
2732 NuNData[pKey][c_name] = nil;
2733 end
2734  
2735 for n = 1, uBttns, 1 do
2736 nameHdNbr = c_name..pHead..n;
2737 nameDtNbr = c_name..pDetl..n;
2738 if ( NuNData[pKey][nameHdNbr] ) then
2739 NuNData[pKey][nameHdNbr] = nil;
2740 end
2741 if ( NuNData[pKey][nameDtNbr] ) then
2742 NuNData[pKey][nameDtNbr] = nil;
2743 end
2744 end
2745 if ( NuN_CTTCheckBox:GetChecked() ) then
2746 NuN_ClearPinnedTT();
2747 end
2748 NuN_HideFrame();
2749 if ( ( NuNSearchFrame:IsVisible() ) and ( not string.find(NuNSearchTitleText:GetText(), NUN_QUESTS_TEXT) ) ) then
2750 deletedE = true;
2751 NuNSearch_Search();
2752 end
2753 if ( FriendsListFrame:IsVisible() ) then
2754 NuNNew_FriendsList_Update();
2755 elseif ( IgnoreListFrame:IsVisible() ) then
2756 NuNNew_IgnoreList_Update();
2757 elseif ( GuildPlayerStatusFrame:IsVisible() ) then
2758 NuNNew_GuildStatus_Update();
2759 elseif ( GuildStatusFrame:IsVisible() ) then
2760 NuNNew_GuildStatus_Update();
2761 elseif ( WhoFrame:IsVisible() ) then
2762 NuNNew_WhoList_Update();
2763 end
2764 end
2765  
2766 function NuNGNote_Delete()
2767 local c_note = NuNGNoteTitleButtonText:GetText();
2768 if ( NuNGNoteFrame.fromQuest ) then
2769 NuNData[pKey].QuestHistory[pName][c_note] = nil;
2770 HideUIPanel(NuNGNoteFrame);
2771 if ( NuNSearchFrame:IsVisible() ) then
2772 deletedE = true;
2773 NuN_FetchQuestHistory();
2774 end
2775 else
2776 if ( string.find(c_note, "|Hitem:") ) then
2777 NuN_DeleteItem(c_note);
2778 end
2779 if ( NuNData[pKey][Notes][c_note] ) then
2780 NuNData[pKey][Notes][c_note] = nil;
2781 elseif ( NuNData[Notes][c_note] ) then
2782 NuNData[Notes][c_note] = nil;
2783 end
2784 if ( NuN_GTTCheckBox:GetChecked() ) then
2785 NuN_ClearPinnedTT();
2786 end
2787 HideUIPanel(NuNGNoteFrame);
2788 if ( NuNSearchFrame:IsVisible() ) then
2789 deletedE = true;
2790 NuNSearch_Search();
2791 end
2792 if ( ( QuestLogFrame:IsVisible() ) and ( not NuNGNoteFrame.fromQuest ) ) then
2793 NuNNew_QuestLog_Update();
2794 end
2795 NuN_UpdateMapNotesIndex(c_note);
2796 end
2797 end
2798  
2799  
2800  
2801 function NuNOptions_ResetDefaults()
2802 NuNSettings[pKey] = {};
2803 NuNSettings[pKey].autoG = nil;
2804 NuNSettings[pKey].autoA = nil;
2805 NuNSettings[pKey].autoD = nil;
2806 NuNSettings[pKey].toolTips = "1";
2807 NuNSettings[pKey].pScale = 1.00;
2808 NuNSettings[pKey].tScale = 1.00;
2809 NuNSettings[pKey].mScale = 1.00;
2810 NuN_PinnedTooltip:SetScale(1);
2811 NuN_Tooltip:SetScale(1);
2812 WorldMapTooltip:SetScale(1);
2813 NuN_MapTooltip:SetScale(1);
2814 NuNPopup:SetScale(1);
2815 NuNSettings[pKey].dLevel = "1";
2816 NuNSettings[pKey].autoQ = nil;
2817 NuNSettings[pKey].autoN = nil;
2818 NuNSettings[pKey].autoP = nil;
2819 NuNSettings[pKey].minOver = "1";
2820 NuNSettings[pKey].ttLen = NUN_TT_MAX;
2821 NuNSettings[pKey].ttLLen = NUN_TT_LEN;
2822 NuNSettings[pKey].hideMicro = nil;
2823 HideUIPanel(NuNOptionsFrame);
2824 NuNFrame:SetUserPlaced(0);
2825 NuNFrame:ClearAllPoints();
2826 NuNFrame:SetPoint("CENTER", UIParent, "CENTER", 220, 15);
2827 NuNGNoteFrame:SetUserPlaced(0);
2828 NuNGNoteFrame:ClearAllPoints();
2829 NuNGNoteFrame:SetPoint("CENTER", UIParent, "CENTER", 250, -15);
2830 NuNSearchFrame:SetUserPlaced(0);
2831 NuNSearchFrame:ClearAllPoints();
2832 NuNSearchFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 60, -144);
2833 if ( NuNMicroFrame:IsVisible() ) then
2834 HideUIPanel(NuNMicroFrame);
2835 end
2836 NuNMicroFrame:SetUserPlaced(0);
2837 NuNMicroFrame:ClearAllPoints();
2838 NuNMicroFrame:SetPoint("TOP", UIParent, "TOP", 0, -30);
2839 ShowUIPanel(NuNMicroFrame);
2840 NuN_Options();
2841 end
2842  
2843  
2844  
2845 function NuNOptions_Import()
2846 local x;
2847 local index;
2848 local value;
2849 local isInGuild = false;
2850 local lGuild = GetGuildInfo("player");
2851 if ( lGuild ~= nil ) then
2852 isInGuild = true;
2853 end
2854  
2855 NuN_importing = true;
2856 for index, value in NuNData[pKey] do
2857 if ( ( NuNData[pKey][index].faction ) and ( index == pName ) ) then
2858 NuNData[pKey][index].type = NUN_SELF_C;
2859 elseif ( ( NuNData[pKey][index].faction == pFaction ) and ( index ~= pName ) ) then
2860 if ( NuNData[pKey][index].ignoreLst ) then
2861 if ( not NuN_Is_Ignored(index) ) then
2862 if ( NuN_NotInfiniteIgored(index) ) then
2863 if ( AddIgnore(index) ) then
2864 x = getn(NuNData[pKey][index].ignoreLst) + 1;
2865 NuNData[pKey][index].ignoreLst[x] = pName;
2866 end
2867 end
2868 end
2869 elseif ( ( isInGuild ) and ( NuNData[pKey][index].guild == lGuild ) and ( not NuNSettings[pKey].autoG ) ) then
2870 -- Forget this entry as they are guild mates with current player and settings say not to add as friend
2871 elseif ( NuNData[pKey][index].friendLst ) then
2872 if ( not NuN_Is_Friendly(index) ) then
2873 AddFriend(index);
2874 if ( not NuNData[pKey][index].friendLst ) then
2875 NuNData[pKey][index].friendLst = {};
2876 end
2877 if ( not NuNGet_TableID(NuNData[pKey][index].friendLst, pName) ) then
2878 x = getn( NuNData[pKey][index].friendLst) + 1;
2879 NuNData[pKey][index].friendLst[x] = pName;
2880 end
2881 end
2882 end
2883 end
2884 end
2885 NuN_importing = false;
2886 end
2887  
2888 function NuNOptions_Export()
2889 local iName;
2890 for i = 1, GetNumFriends(), 1 do
2891 iName = GetFriendInfo(i);
2892 if ( not NuNData[pKey][iName] ) then
2893 NuNData[pKey][iName] = {};
2894 NuNData[pKey][iName].type = NUN_AUTO_C;
2895 NuNData[pKey][iName].faction = pFaction;
2896 NuNData[pKey][iName][txtTxt] = NUN_AUTO_FRIEND..NuN_GetDateStamp();
2897 NuNData[pKey][iName].friendLst = {};
2898 NuNData[pKey][iName].friendLst[1] = pName;
2899 end
2900 end
2901 for i = 1, GetNumIgnores(), 1 do
2902 iName = GetIgnoreName(i);
2903 if ( not NuNData[pKey][iName] ) then
2904 NuNData[pKey][iName] = {};
2905 NuNData[pKey][iName].type = NUN_AUTO_C;
2906 NuNData[pKey][iName].faction = pFaction;
2907 NuNData[pKey][iName][txtTxt] = NUN_AUTO_IGNORE..NuN_GetDateStamp();
2908 NuNData[pKey][iName].ignoreLst = {};
2909 NuNData[pKey][iName].ignoreLst[1] = pName;
2910 end
2911 end
2912 end
2913  
2914  
2915  
2916 function NuNOptions_Search()
2917 local lDisplay = searchFor[ddSearch].Display;
2918 local lCommand = searchFor[ddSearch].Command;
2919  
2920 ddClassSearch = nil;
2921 ddProfSearch = nil;
2922 ddText = nil;
2923 lastBttnIndex = 0;
2924 lastBttn = nil;
2925 lastBttnDetl = nil;
2926 NuN_Filtered = nil;
2927 foundNuN = {};
2928 NuNSearchFrame:SetScale(NuNSettings[pKey].pScale);
2929 ShowUIPanel(NuNSearchFrame);
2930 HideUIPanel(NuNOptionsFrame);
2931 NuNSearchFrame.searchType = lDisplay;
2932 NuNSearchTitleText:SetText(lDisplay);
2933 NuNSearchFrameSearchButton:Enable();
2934  
2935 if ( ( lCommand == "All" ) or ( string.find(lCommand, "Notes") ) ) then
2936 NuNSearchClassDropDown:Hide();
2937 NuNSearchProfDropDown:Hide();
2938 NuNSearchTextBox:Hide();
2939 NuNSearch_Search();
2940 elseif ( lCommand == "Class" ) then
2941 UIDropDownMenu_ClearAll(NuNSearchClassDropDown);
2942 NuNSearchClassDropDown:Show();
2943 NuNSearchProfDropDown:Hide();
2944 NuNSearchTextBox:Hide();
2945 NuNSearch_Update();
2946 elseif ( lCommand == "Profession" ) then
2947 NuNSearchClassDropDown:Hide();
2948 UIDropDownMenu_ClearAll(NuNSearchProfDropDown);
2949 NuNSearchProfDropDown:Show();
2950 NuNSearchTextBox:Hide();
2951 NuNSearch_Update();
2952 elseif ( lCommand == "Quest History" ) then
2953 NuNSearchFrameSearchButton:Disable();
2954 NuNSearchClassDropDown:Hide();
2955 NuNSearchProfDropDown:Hide();
2956 NuNSearchTextBox:Hide();
2957 NuNSearchTitleText:SetText(NUN_QUESTS_TEXT.." : "..pName);
2958 NuN_FetchQuestHistory();
2959 else
2960 NuNSearchClassDropDown:Hide();
2961 NuNSearchProfDropDown:Hide();
2962 -- NuNSearchTextBox:SetText("");
2963 NuNSearchTextBox:Show();
2964 NuNSearchTextBox:SetFocus();
2965 -- NuNSearch_Update();
2966 NuNSearch_Search();
2967 end
2968 end
2969  
2970  
2971  
2972 function NuNSearch_Search()
2973 local index;
2974 local value;
2975 local tstTxt;
2976 local srchText;
2977 local countH = 0;
2978 local countA = 0;
2979 local countN = 0;
2980 local classType;
2981 local searchType = searchFor[ddSearch].Command;
2982 local subType = "";
2983 local noteType = 0;
2984 local results = 0;
2985 if ( searchType == "Class" ) then
2986 classType = AllClasses[ddClassSearch];
2987 end
2988 if ( string.find(searchType, "Notes:") ) then
2989 subType = string.sub(searchType, 7);
2990 searchType = string.sub(searchType, 1, 5);
2991 end
2992  
2993 foundNuN = {};
2994 foundHNuN = {};
2995 foundANuN = {};
2996 foundNNuN = {};
2997  
2998 for index, value in NuNData[pKey] do
2999 if ( searchType == "All" ) then
3000 if ( NuNData[pKey][index].faction == "Horde" ) then
3001 countH = countH + 1;
3002 foundHNuN[countH] = index;
3003 elseif ( NuNData[pKey][index].faction == "Alliance" ) then
3004 countA = countA + 1;
3005 foundANuN[countA] = index;
3006 end
3007 elseif ( searchType == "Class" ) then
3008 if ( NuNData[pKey][index].faction == "Horde" ) then
3009 if ( HClasses[NuNData[pKey][index].cls] == classType ) then
3010 countH = countH + 1;
3011 foundHNuN[countH] = index;
3012 end
3013 elseif ( NuNData[pKey][index].faction == "Alliance" ) then
3014 if ( AClasses[NuNData[pKey][index].cls] == classType ) then
3015 countA = countA + 1;
3016 foundANuN[countA] = index;
3017 end
3018 end
3019 elseif ( searchType == "Profession" ) then
3020 if ( NuNData[pKey][index].faction == "Horde" ) then
3021 if ( ( NuNData[pKey][index].prof1 == ddProfSearch ) or ( NuNData[pKey][index].prof2 == ddProfSearch ) ) then
3022 countH = countH + 1;
3023 foundHNuN[countH] = index;
3024 end
3025 elseif ( NuNData[pKey][index].faction == "Alliance" ) then
3026 if ( ( NuNData[pKey][index].prof1 == ddProfSearch ) or ( NuNData[pKey][index].prof2 == ddProfSearch ) ) then
3027 countA = countA + 1;
3028 foundANuN[countA] = index;
3029 end
3030 end
3031 elseif ( searchType == "Text" ) then
3032 tstTxt = NuNSearchTextBox:GetText();
3033 if ( NuNData[pKey][index].txt ) then
3034 srchText = NuN_GetCText(index);
3035 if ( srchText == nil ) then
3036 srchText = "";
3037 end
3038 if ( ( string.find(srchText, tstTxt) ) or ( string.find(NuNData[pKey][index].txt, tstTxt) ) or ( string.find(index, tstTxt) ) ) then
3039 local tName = index;
3040 if ( not NuNData[pKey][index].faction ) then
3041 tName = nil;
3042 local pos = string.find(index, pDetl);
3043 if ( pos == nil ) then
3044 pos = string.find(index, pHead);
3045 if ( pos ~= nil ) then
3046 tName = string.sub(index, 1, (pos - 1));
3047 end
3048 else
3049 tName = string.sub(index, 1, (pos - 1));
3050 end
3051 end
3052 if ( tName ~= nil ) then
3053 if ( NuNData[pKey][tName].faction == "Horde" ) then
3054 if ( NuNGet_TableID(foundHNuN, tName) == nil ) then
3055 countH = countH + 1;
3056 foundHNuN[countH] = tName;
3057 end
3058 else
3059 if ( NuNGet_TableID(foundANuN, tName) == nil ) then
3060 countA = countA + 1;
3061 foundANuN[countA] = tName;
3062 end
3063 end
3064 end
3065 end
3066 end
3067 end
3068 end
3069  
3070 for index, value in NuNData[pKey][Notes] do
3071 if ( ( NuNData[pKey][Notes][index] ) and ( NuNData[pKey][Notes][index].type ) ) then
3072 noteType = NuNData[pKey][Notes][index].type;
3073 else
3074 noteType = 1;
3075 end
3076 if ( ( searchType == "All" ) or ( searchType == "Notes" ) ) then
3077 if ( ( subType == "" ) or ( ( subType == "Generic" ) and ( noteType == 1 ) ) or ( ( subType == "Items" ) and ( noteType == 2 ) ) or ( ( subType == "Logs" ) and ( noteType == 3 ) ) or ( ( subType == "NPCs" ) and ( noteType == 4 ) ) or ( ( subType == "Quests" ) and ( noteType == 5 ) ) ) then
3078 countN = countN + 1;
3079 foundNNuN[countN] = index;
3080 end
3081 elseif ( searchType == "Text" ) then
3082 tstTxt = NuNSearchTextBox:GetText();
3083 srchText = NuN_GetGText(index);
3084 if ( srchText == nil ) then
3085 srchText = "";
3086 end
3087 if ( ( string.find(srchText, tstTxt)) or ( string.find(index, tstTxt ) ) ) then
3088 countN = countN + 1;
3089 foundNNuN[countN] = index;
3090 end
3091 end
3092 end
3093  
3094 for index, value in NuNData[Notes] do
3095 if ( ( NuNData[Notes][index] ) and ( NuNData[Notes][index].type ) ) then
3096 noteType = NuNData[Notes][index].type;
3097 else
3098 noteType = 1;
3099 end
3100 if ( ( searchType == "All" ) or ( searchType == "Notes" ) ) then
3101 if ( ( subType == "" ) or ( ( subType == "Generic" ) and ( noteType == 1 ) ) or ( ( subType == "Items" ) and ( noteType == 2 ) ) or ( ( subType == "Logs" ) and ( noteType == 3 ) ) or ( ( subType == "NPCs" ) and ( noteType == 4 ) ) or ( ( subType == "Quests" ) and ( noteType == 5 ) ) ) then
3102 countN = countN + 1;
3103 foundNNuN[countN] = index;
3104 end
3105 elseif ( searchType == "Text" ) then
3106 tstTxt = NuNSearchTextBox:GetText();
3107 srchText = NuN_GetGText(index);
3108 if ( srchText == nil ) then
3109 srchText = "";
3110 end
3111 if ( ( string.find(srchText, tstTxt)) or ( string.find(index, tstTxt ) ) ) then
3112 countN = countN + 1;
3113 foundNNuN[countN] = index;
3114 end
3115 end
3116 end
3117  
3118 table.sort(foundANuN);
3119 table.sort(foundHNuN);
3120 table.sort(foundNNuN);
3121 NuN_DefaultSort();
3122  
3123 if ( ( searchType ~= "Class" ) and ( searchType ~= "Profession" ) ) then
3124 NuNSearchTextBox:Show();
3125 ddSearch = NuNGet_CommandID(searchFor, "Text");
3126 if ( NuN_Filtered ) then
3127 local tmpNuN = {};
3128 local c = 0;
3129  
3130 for i=1, getn(foundNuN), 1 do
3131 if ( NuNGet_TableID(NuN_Filtered, foundNuN[i]) ) then
3132 c = c + 1;
3133 tmpNuN[c] = foundNuN[i];
3134 end
3135 end
3136 foundNuN = tmpNuN;
3137 else
3138 NuN_Filtered = foundNuN;
3139 end
3140 end
3141  
3142 results = getn(foundNuN);
3143 NuNSearchTitleText:SetText(NuNSearchFrame.searchType.." ("..results..")");
3144  
3145 NuNSearch_Update();
3146 if ( ( deletedE ) and ( visibles > 0 ) and ( lastBttn ~= nil ) ) then
3147 deletedE = false;
3148 if ( lastBttnIndex > visibles ) then
3149 NuNSearch_HighlightRefresh(lastVisible);
3150 NuNSearchNote_OnClick(lastVisible);
3151 else
3152 NuNSearch_HighlightRefresh(lastBttn);
3153 NuNSearchNote_OnClick(lastBttn);
3154 end
3155 else
3156 NuNSearch_HighlightRefresh(nil);
3157 end
3158 end
3159  
3160  
3161  
3162 function NuN_DefaultSort()
3163 if ( horde ) then
3164 NuN_copyT(foundNuN, foundHNuN, NUN_HORD_C);
3165 NuN_copyT(foundNuN, foundANuN, NUN_ALLI_C);
3166 NuN_copyT(foundNuN, foundNNuN, NUN_NOTE_C);
3167 else
3168 NuN_copyT(foundNuN, foundANuN, NUN_ALLI_C);
3169 NuN_copyT(foundNuN, foundHNuN, NUN_HORD_C);
3170 NuN_copyT(foundNuN, foundNNuN, NUN_NOTE_C);
3171 end
3172 end
3173  
3174  
3175  
3176 function NuN_copyT(t1, t2, c_prefix)
3177 local i1 = getn(t1);
3178 for i2=1, getn(t2), 1 do
3179 i1 = i1 + 1;
3180 t1[i1] = c_prefix..t2[i2];
3181 end
3182 end
3183  
3184  
3185  
3186 function NuNSearch_Back()
3187 if ( NuNFrame:IsVisible() ) then
3188 NuN_HideFrame();
3189 end
3190 if ( NuNGNoteFrame:IsVisible() ) then
3191 HideUIPanel(NuNGNoteFrame);
3192 end
3193 HideUIPanel(NuNSearchFrame);
3194 NuNOptionsFrame:SetScale(NuNSettings[pKey].pScale);
3195 NuN_Options();
3196 end
3197  
3198  
3199  
3200 function NuNSearch_Update()
3201 local theNoteIndex;
3202 local theOffsetNoteIndex;
3203 local theNote;
3204 local theNoteHFlag;
3205 local theNoteAFlag;
3206 local theNoteNFlag;
3207 local numNuNFound = getn(foundNuN);
3208  
3209 NuN_CheckQuestList();
3210  
3211 visibles = 0;
3212 FauxScrollFrame_Update(NuNSearchListScrollFrame, numNuNFound, NUN_SHOWN, NUN_NOTE_HEIGHT);
3213 for theNoteIndex=1, NUN_SHOWN, 1 do
3214 theOffsetNoteIndex = theNoteIndex + FauxScrollFrame_GetOffset(NuNSearchListScrollFrame);
3215 theNote = getglobal( "NuNSearchNote"..theNoteIndex );
3216 if ( theOffsetNoteIndex > numNuNFound ) then
3217 theNote:Hide();
3218 else
3219 theNote:SetTextColor(1, 0.82, 0, 1);
3220 theNoteHFlag = getglobal( "NuNSearchNote"..theNoteIndex.."FrameHFlag" );
3221 theNoteAFlag = getglobal( "NuNSearchNote"..theNoteIndex.."FrameAFlag" );
3222 theNoteNFlag = getglobal( "NuNSearchNote"..theNoteIndex.."FrameNFlag" );
3223 theNoteLFlag = getglobal( "NuNSearchNote"..theNoteIndex.."FrameLFlag" );
3224 theNoteType = getglobal( "NuNSearchNote"..theNoteIndex.."FrameType" );
3225 theNoteLFlag:Hide();
3226 local typ = string.sub(foundNuN[theOffsetNoteIndex], 1, 1);
3227 local noteName = string.sub(foundNuN[theOffsetNoteIndex], 2);
3228 theNote:SetText( noteName );
3229 if ( typ == NUN_HORD_C ) then
3230 theNoteAFlag:Hide();
3231 theNoteNFlag:Hide();
3232 theNoteHFlag:Show();
3233 elseif ( typ == NUN_ALLI_C ) then
3234 theNoteHFlag:Hide();
3235 theNoteNFlag:Hide();
3236 theNoteAFlag:Show();
3237 elseif ( typ == NUN_QUEST_C ) then
3238 theNoteHFlag:Hide();
3239 theNoteAFlag:Hide();
3240 if ( ( NuNData[Notes][noteName] ) or ( NuNData[pKey][Notes][noteName] ) ) then
3241 theNoteNFlag:Show();
3242 else
3243 theNoteNFlag:Hide();
3244 end
3245 else
3246 theNoteHFlag:Hide();
3247 theNoteAFlag:Hide();
3248 theNoteNFlag:Show();
3249 end
3250 theNote.type = typ;
3251 if ( typ == NUN_HORD_C ) or ( typ == NUN_ALLI_C ) then
3252 if ( NuNData[pKey][noteName].type ) then
3253 typ = NuNData[pKey][noteName].type;
3254 if ( typ == NUN_AUTO_C ) then
3255 theNoteType:SetText(NUN_AUTO);
3256 elseif ( noteName == pName ) then
3257 theNoteType:SetText(NUN_PLAYER);
3258 elseif ( typ == NUN_SELF_C ) then
3259 theNoteType:SetText(NUN_SELF);
3260 elseif ( typ == NUN_MANU_C ) then
3261 theNoteType:SetText(NUN_MANU);
3262 elseif ( typ == NUN_PARTY_C ) then
3263 theNoteType:SetText(NUN_PARTY);
3264 else
3265 theNoteType:SetText(" ");
3266 end
3267 else
3268 theNoteType:SetText(" ");
3269 end
3270 elseif ( typ == NUN_QUEST_C ) then
3271 theNoteLFlag:Hide();
3272 if ( ( not NuNQuestLog[noteName] ) and ( ( NuNData[pKey].QuestHistory[pName][noteName].handedIn ) or ( NuNData[pKey].QuestHistory[pName][noteName].complete ) ) ) then
3273 theNoteLFlag:Show();
3274 elseif ( ( NuNData[pKey].QuestHistory[pName][noteName] ) and ( NuNData[pKey].QuestHistory[pName][noteName].abandoned ) ) then
3275 theNote:SetTextColor(0.9, 0, 0, 0.9);
3276 elseif ( NuNQuestLog[noteName] ) then
3277 theNote:SetTextColor(0, 0.9, 0, 0.9);
3278 end
3279 theNoteType:SetText(NuNData[pKey].QuestHistory[pName][noteName].pLevel);
3280 else
3281 if ( ( NuNData[pKey][Notes][noteName] ) and ( NuNData[pKey][Notes][noteName].type ) ) then
3282 typ = NuNData[pKey][Notes][noteName].type;
3283 elseif ( NuNData[Notes][noteName] ) then
3284 theNoteLFlag:Show();
3285 if ( NuNData[Notes][noteName].type ) then
3286 typ = NuNData[Notes][noteName].type;
3287 end
3288 else
3289 typ = 1;
3290 end
3291 theNoteType:SetText(noteTypes[typ].Display);
3292 if ( noteTypes[typ].Command == "QST" ) then
3293 if ( NuNQuestLog[noteName] ) then
3294 theNote:SetTextColor(0, 0.9, 0, 0.9);
3295 elseif ( ( NuNData[pKey].QuestHistory[pName][noteName] ) and ( NuNData[pKey].QuestHistory[pName][noteName].abandoned ) ) then
3296 theNote:SetTextColor(0.9, 0, 0, 0.9);
3297 end
3298 end
3299 end
3300 theNote:Show();
3301 visibles = visibles + 1;
3302 lastVisible = theNote;
3303 if ( theOffsetNoteIndex == lastBttnDetl ) then
3304 theNote:LockHighlight();
3305 else
3306 theNote:UnlockHighlight();
3307 end
3308 end
3309 end
3310 end
3311  
3312  
3313  
3314 function NuNSearchNote_OnEnter(bttnNote)
3315 local bttnName = bttnNote:GetName();
3316 local storePinned = NuN_PinnedTooltip.type;
3317  
3318 local x, y = GetCursorPosition();
3319 if ( x > 500 ) then
3320 NuN_Tooltip:SetOwner(this, "ANCHOR_LEFT");
3321 else
3322 NuN_Tooltip:SetOwner(this, "ANCHOR_RIGHT");
3323 end
3324 ttName = bttnNote:GetText();
3325 NuN_Tooltip:ClearLines();
3326 if ( bttnNote.type == "N" ) then
3327 NuN_PinnedTooltip.type = "General";
3328 elseif ( bttnNote.type == "A" ) or ( bttnNote.type == "H" ) then
3329 NuN_PinnedTooltip.type = "Contact";
3330 elseif ( bttnNote.type == NUN_QUEST_C ) then
3331 NuN_PinnedTooltip.type = "QuestHistory";
3332 end
3333 NuN_BuildTT(NuN_Tooltip);
3334 NuN_PinnedTooltip.type = storePinned;
3335 NuN_Fade = "False";
3336 NuN_Tooltip:Show();
3337 end
3338  
3339  
3340  
3341 function NuNSearchNote_OnClick(bttnNote)
3342 local noteName = bttnNote:GetText();
3343 local lclNote;
3344 local lclNoteHFlag;
3345 local lclNoteAFlag;
3346 local lclNoteNFlag;
3347 local lastBttnDetlN;
3348 local nType;
3349  
3350 if ( IsShiftKeyDown() ) then
3351 if ( ChatFrameEditBox:IsVisible() ) then
3352 ChatFrameEditBox:Insert(noteName);
3353 elseif ( NuNGNoteFrame:IsVisible() ) then
3354 local cText = NuNGNoteTextScroll:GetText().."\n"..noteName;
3355 NuNGNoteTextScroll:SetText(cText);
3356 elseif ( NuNFrame:IsVisible() ) then
3357 local cText = NuNText:GetText().."\n"..noteName;
3358 NuNText:SetText(cText);
3359 end
3360 else
3361 lastBttn = bttnNote;
3362 lastBttnIndex = bttnNote:GetID();
3363 lastBttnDetlN = bttnNote.type..noteName;
3364 lastBttnDetl = NuNGet_TableID(foundNuN, lastBttnDetlN);
3365  
3366 NuNSearch_HighlightRefresh(bttnNote);
3367  
3368 if ( ( bttnNote.type == NUN_HORD_C ) or ( bttnNote.type == NUN_ALLI_C ) ) then
3369 c_name = noteName;
3370 NuN_ShowSavedNote( c_name );
3371 else
3372 if ( bttnNote.type == NUN_QUEST_C ) then
3373 NuNGNoteFrame.fromQuest = "1";
3374 c_type = NuNGet_CommandID(noteTypes, "QST");
3375 else
3376 NuNGNoteFrame.fromQuest = nil;
3377 end
3378 c_note = noteName;
3379 if ( ( NuNData[Notes][c_note] ) or ( NuNData[pKey][Notes][c_note] ) ) then
3380 NuN_ShowSavedGNote();
3381 else
3382 NuN_ShowTitledGNote("");
3383 end
3384 end
3385 end
3386 end
3387  
3388  
3389  
3390 function NuNSearch_HighlightRefresh(tstNote)
3391 local theNote;
3392 for i=1, NUN_SHOWN, 1 do
3393 theNote = getglobal("NuNSearchNote"..i);
3394 if ( ( theNote == tstNote ) and ( theNote:IsVisible() ) ) then
3395 theNote:LockHighlight();
3396 else
3397 theNote:UnlockHighlight();
3398 end
3399 end
3400 end
3401  
3402  
3403  
3404 function NuN_DateStamp()
3405 NuNText:SetText(NuNText:GetText().."\n"..NuN_GetDateStamp());
3406 end
3407  
3408 function NuNGNote_DateStamp()
3409 NuNGNoteTextScroll:SetText(NuNGNoteTextScroll:GetText().."\n"..NuN_GetDateStamp());
3410 end
3411  
3412 function NuN_GetDateStamp()
3413 local dateStamp = date("%A, %d %B %Y %H:%M:%S");
3414 dateStamp = NuN_LocaliseDateStamp(dateStamp);
3415 return dateStamp;
3416 end
3417  
3418  
3419  
3420 function NuN_Loc()
3421 NuNText:SetText(NuNText:GetText().."\n"..NuN_GetLoc());
3422 end
3423  
3424 function NuNGNote_Loc()
3425 NuNGNoteTextScroll:SetText(NuNGNoteTextScroll:GetText().."\n"..NuN_GetLoc());
3426 end
3427  
3428 function NuN_GetLoc()
3429 local locData = pName.."'s "..NUN_LOC.." : ";
3430 local myCID, myC, mySubZ, myZID, myZ, px, py, coords;
3431 local loc = false;
3432  
3433 myCID = GetCurrentMapContinent();
3434 if ( ( myCID ~= nil) and ( myCID > 0 ) ) then
3435 myC = c_continents[myCID].name;
3436 end
3437 if ( myC ~= nil ) then
3438 locData = locData..myC..", ";
3439 loc = true;
3440 end
3441  
3442 myZ = GetZoneText();
3443 if ( ( myZ == nil ) or ( myZ == "" ) ) then
3444 myZID = GetCurrentMapZone();
3445 if ( ( myZID ~= nil ) and ( myCID ~= nil ) and ( myCID > 0 ) ) then
3446 myZ = c_continents[myCID].zones[myZID];
3447 end
3448 end
3449 if ( ( myZ ~= nil ) and ( myZ ~= "" ) ) then
3450 locData = locData..myZ..", ";
3451 end
3452  
3453  
3454 mySubZ = GetSubZoneText();
3455 if ( ( mySubZ == nil ) or ( mySubZ == "" ) ) then
3456 mySubZ = GetMinimapZoneText();
3457 end
3458 if ( mySubZ ~= nil ) then
3459 locData = locData..mySubZ..", ";
3460 loc = true;
3461 end
3462  
3463 px, py = GetPlayerMapPosition("player");
3464 if ( ( px ~= nil ) and ( py ~= nil ) ) then
3465 coords = format("(%d, %d)", px * 100.0, py * 100.0);
3466 locData = locData..coords;
3467 loc = true;
3468 end
3469 if ( loc == true ) then
3470 return locData;
3471 else
3472 return "";
3473 end
3474 end
3475  
3476  
3477  
3478 function NuN_AutoNote()
3479 if ( NuNSettings[pKey].autoN ) then
3480 local lName;
3481 local lRace;
3482 local lClass;
3483 local lSex;
3484 local lPvPRank;
3485 local lPvPRankID;
3486 local lgName;
3487 local lgRank;
3488 local lgRankIndex;
3489 local bttnKey;
3490  
3491 if ( pFaction ~= nil ) then
3492 NuNData[pKey][pName] = {};
3493 NuNData[pKey][pName].type = NUN_SELF_C;
3494 NuNData[pKey][pName].faction = pFaction;
3495 NuNData[pKey][pName][txtTxt] = "";
3496 lRace = UnitRace("player");
3497 if ( lRace ~= nil ) then
3498 ddRace = NuNGet_TableID(Races, lRace);
3499 NuNData[pKey][pName].race = ddRace;
3500 end
3501 lClass = UnitClass("player");
3502 if ( lClass ~= nil ) then
3503 ddClass = NuNGet_TableID(Classes, lClass);
3504 NuNData[pKey][pName].cls = ddClass;
3505 end
3506 lSex = UnitSex("player");
3507 if ( lSex ~= nil ) then
3508 NuNData[pKey][pName].sex = lSex + 1;
3509 end
3510 lPvPRankID = UnitPVPRank("player");
3511 if ( lPvPRankID ~= nil ) and ( lPvPRankID > 0 ) then
3512 lPvPRank = GetPVPRankInfo(lPvPRankID);
3513 ddCRank = NuNGet_TableID(Ranks, lPvPRank);
3514 NuNData[pKey][pName].crank = ddCRank;
3515 end
3516 lgName, lgRank, lgRankIndex = GetGuildInfo("player");
3517 if ( lgName ~= "" ) and ( lgName ~= nil ) then
3518 bttnKey = pName..pDetl.."1";
3519 NuNData[pKey][bttnKey] = {};
3520 NuNData[pKey][bttnKey].txt = lgName;
3521 bttnKey = pName..pDetl.."2";
3522 NuNData[pKey][bttnKey] = {};
3523 if ( lgRankIndex == 0 ) then
3524 NuNData[pKey][bttnKey].txt = ( "GM : "..lgRank );
3525 else
3526 NuNData[pKey][bttnKey].txt = ( lgRankIndex.." : "..lgRank );
3527 end
3528 end
3529 end
3530 end
3531 end
3532  
3533  
3534  
3535 function NuN_ClrDD()
3536 if ( lastDD == "Race" ) then
3537 UIDropDownMenu_ClearAll(NuNRaceDropDown);
3538 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].race ) ) then
3539 ddRace = -1;
3540 else
3541 ddRace = nil;
3542 end
3543 elseif ( lastDD == "Class" ) then
3544 UIDropDownMenu_ClearAll(NuNClassDropDown);
3545 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].cls ) ) then
3546 ddClass = -1;
3547 else
3548 ddClass = nil;
3549 end
3550 elseif ( lastDD == "Sex" ) then
3551 UIDropDownMenu_ClearAll(NuNSexDropDown);
3552 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].sex ) ) then
3553 ddSex = -1;
3554 else
3555 ddSex = nil;
3556 end
3557 elseif ( lastDD == "Prof1" ) then
3558 UIDropDownMenu_ClearAll(NuNProf1DropDown);
3559 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].prof1 ) ) then
3560 ddProf1 = -1;
3561 else
3562 ddProf1 = nil;
3563 end
3564 elseif ( lastDD == "Prof2" ) then
3565 UIDropDownMenu_ClearAll(NuNProf2DropDown);
3566 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].prof2 ) ) then
3567 ddProf2 = -1;
3568 else
3569 ddProf2 = nil;
3570 end
3571 elseif ( lastDD == "CRank" ) then
3572 UIDropDownMenu_ClearAll(NuNCRankDropDown);
3573 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].crank ) ) then
3574 ddCRank = -1;
3575 else
3576 ddCRank = nil;
3577 end
3578 elseif ( lastDD == "HRank" ) then
3579 UIDropDownMenu_ClearAll(NuNHRankDropDown);
3580 if ( ( NuNData[pKey][c_name] ) and ( NuNData[pKey][c_name].hrank ) ) then
3581 ddHRank = -1;
3582 else
3583 ddHRank = nil;
3584 end
3585 end
3586 lastDD = nil;
3587 NuNButtonClrDD:Disable();
3588 end
3589  
3590  
3591 function NuN_GTypeDependant_Setup()
3592 UIDropDownMenu_SetSelectedID(NuNGTypeDropDown, c_type);
3593 UIDropDownMenu_SetText(noteTypes[c_type].Display, NuNGTypeDropDown);
3594 if ( noteTypes[c_type].Command == "NPC" ) then
3595 NuNNPCTargetButton:Show();
3596 else
3597 NuNNPCTargetButton:Hide();
3598 end
3599 end
3600  
3601  
3602 function NuN_ShowSavedGNote()
3603 if ( ( NuNGNoteFrame:IsVisible() ) and ( prevNote == c_note ) ) then
3604 NuNGNoteFrame:Hide();
3605 else
3606 if ( ( NuNData[pKey][Notes][c_note] ) and ( NuNData[pKey][Notes][c_note].type ) ) then
3607 c_type = NuNData[pKey][Notes][c_note].type;
3608 NuNGNoteFrame.type = c_type;
3609 NuN_GTypeDependant_Setup();
3610 elseif ( ( NuNData[Notes][c_note] ) and ( NuNData[Notes][c_note].type ) ) then
3611 c_type = NuNData[Notes][c_note].type;
3612 NuNGNoteFrame.type = c_type;
3613 NuN_GTypeDependant_Setup();
3614 else
3615 c_type = NuNGet_CommandID(noteTypes, " ");
3616 NuNGNoteFrame.type = c_type;
3617 NuN_GTypeDependant_Setup();
3618 end
3619 if ( NuNData[pKey][Notes][c_note] ) then
3620 NuN_GLevel_CheckBox:SetChecked(0);
3621 elseif ( NuNData[Notes][c_note] ) then
3622 NuN_GLevel_CheckBox:SetChecked(1);
3623 end
3624 NuN_GNote_OriTitle = c_note;
3625 prevNote = c_note;
3626 if ( NuNOptionsFrame:IsVisible() ) then
3627 HideUIPanel(NuNOptionsFrame);
3628 end
3629 if ( NuNcDeleteFrame:IsVisible() ) then
3630 HideUIPanel(NuNcDeleteFrame);
3631 end
3632 NuNGNoteFrame:SetScale(NuNSettings[pKey].pScale);
3633 ShowUIPanel(NuNGNoteFrame);
3634 NuNGNoteTextBox:Hide();
3635 g_text = NuN_GetGText(c_note);
3636 if ( g_text == "" ) then
3637 g_text = "\n";
3638 end
3639 NuNGNoteTextScroll:SetText(g_text);
3640 NuNGNoteTitleButtonText:SetText(c_note);
3641 NuNGNoteTitleButton:Show();
3642 if ( not NuNSettings[pKey].bHave ) then
3643 NuNGNoteTextScroll:SetFocus();
3644 end
3645 if ( NuNGNoteFrame.fromQuest ) then
3646 NuNGNoteHeader:SetText(NUN_QUEST_NOTE);
3647 NuNGNoteButtonDelete:Enable();
3648 NuNGNoteTitleButton:Disable();
3649 NuNGNoteButtonSaveNote:Disable();
3650 else
3651 NuNGNoteHeader:SetText(NUN_SAVED_NOTE);
3652 NuNGNoteButtonDelete:Disable();
3653 NuNGNoteTitleButton:Enable();
3654 NuNGNoteButtonSaveNote:Enable();
3655 end
3656 NuNGNoteButtonDateStamp:Enable();
3657 NuNGNoteButtonLoc:Enable();
3658 NuNGNoteButtonDelete:Enable();
3659 if ( ( MapNotes_OnLoad ) or ( MetaMapNotes_OnLoad ) ) then
3660 NuNMapNoteButton:Enable();
3661 end
3662 NuNGOpenChatButton:Enable();
3663 NuNGTTCheckBoxLabel:Show();
3664 NuN_GTTCheckBox:Show();
3665 NuN_GTTCheckBox:SetChecked(0);
3666 if ( NuN_PinnedTooltip.type == "General" ) then
3667 NuN_GTTCheckBox:SetChecked( NuN_CheckPinnedBox(c_note) );
3668 end
3669 end
3670 end
3671  
3672 function NuN_ShowTitledGNote(GNoteText)
3673 if ( ( NuNGNoteFrame:IsVisible() ) and ( prevNote == c_note ) ) then
3674 NuNGNoteFrame:Hide();
3675 else
3676 if ( NuNSettings[pKey].dLevel ) then
3677 NuN_GLevel_CheckBox:SetChecked(1);
3678 else
3679 NuN_GLevel_CheckBox:SetChecked(0);
3680 end
3681 prevNote = c_note;
3682 NuNGNoteFrame.type = c_type;
3683 NuN_GTypeDependant_Setup();
3684 NuN_GNote_OriTitle = nil;
3685 if ( NuNOptionsFrame:IsVisible() ) then
3686 HideUIPanel(NuNOptionsFrame);
3687 end
3688 if ( NuNcDeleteFrame:IsVisible() ) then
3689 HideUIPanel(NuNcDeleteFrame);
3690 end
3691 NuNGNoteFrame:SetScale(NuNSettings[pKey].pScale);
3692 ShowUIPanel(NuNGNoteFrame);
3693 NuNGNoteTextScroll:SetText(GNoteText);
3694 NuNGNoteTextBox:Hide();
3695 NuNGNoteTitleButtonText:SetText(c_note);
3696 NuNGNoteTitleButton:Show();
3697 if ( not NuNSettings[pKey].bHave ) then
3698 NuNGNoteTextScroll:SetFocus();
3699 end
3700 NuNGNoteButtonDateStamp:Enable();
3701 NuNGNoteButtonLoc:Enable();
3702 if ( NuNGNoteFrame.fromQuest ) then
3703 NuNGNoteHeader:SetText(NUN_QUEST_NOTE);
3704 NuNGNoteButtonDelete:Enable();
3705 if ( ( MapNotes_OnLoad ) or ( MetaMapNotes_OnLoad ) ) then
3706 NuNMapNoteButton:Enable();
3707 end
3708 NuNGNoteTitleButton:Disable();
3709 NuNGNoteButtonSaveNote:Disable();
3710 else
3711 NuNGNoteHeader:SetText(NUN_NEW_NOTE);
3712 NuNGNoteButtonDelete:Disable();
3713 NuNMapNoteButton:Disable();
3714 NuNGNoteTitleButton:Enable();
3715 NuNGNoteButtonSaveNote:Enable();
3716 end
3717 NuNGOpenChatButton:Disable();
3718 NuNGTTCheckBoxLabel:Hide();
3719 NuN_GTTCheckBox:Hide();
3720 end
3721 end
3722  
3723 function NuN_ShowNewGNote()
3724 local tstTxt = NuNGNoteTextBox:GetText();
3725 if ( ( NuNGNoteFrame:IsVisible() ) and ( NuNGNoteTextBox:IsVisible() ) and ( tstTxt == "" ) ) then
3726 NuNGNoteFrame:Hide();
3727 else
3728 if ( IsAltKeyDown() ) then
3729 NuN_LastOpen.type = "General";
3730 NuN_ReOpen();
3731 return;
3732 end
3733  
3734 if ( NuNSettings[pKey].dLevel ) then
3735 NuN_GLevel_CheckBox:SetChecked(1);
3736 else
3737 NuN_GLevel_CheckBox:SetChecked(0);
3738 end
3739 c_type = NuNGet_CommandID(noteTypes, " ");
3740 NuNGNoteFrame.type = c_type;
3741 NuNGNoteFrame.fromQuest = nil;
3742 NuN_GTypeDependant_Setup();
3743 NuN_GNote_OriTitle = nil;
3744 if ( NuNOptionsFrame:IsVisible() ) then
3745 HideUIPanel(NuNOptionsFrame);
3746 end
3747 if ( NuNcDeleteFrame:IsVisible() ) then
3748 HideUIPanel(NuNcDeleteFrame);
3749 end
3750 if ( NuNGNoteFrame.fromQuest ) then
3751 NuNGNoteHeader:SetText(NUN_QUEST_NOTE);
3752 else
3753 NuNGNoteHeader:SetText(NUN_NEW_NOTE);
3754 end
3755 NuNGNoteButtonSaveNote:Disable();
3756 NuNGNoteFrame:SetScale(NuNSettings[pKey].pScale);
3757 ShowUIPanel(NuNGNoteFrame);
3758 NuNGNoteTextScroll:SetText("");
3759 NuNGNoteTitleButton:Hide();
3760 NuNGNoteTextBox:SetText("");
3761 NuNGNoteTextBox:Show();
3762 NuNGNoteTextBox:SetFocus();
3763 NuNGNoteButtonDelete:Disable();
3764 NuNMapNoteButton:Disable();
3765 NuNGOpenChatButton:Disable();
3766 NuNGTTCheckBoxLabel:Hide();
3767 NuN_GTTCheckBox:Hide();
3768 end
3769 end
3770  
3771  
3772  
3773 function NuN_OptionsGuildCheckBox_OnClick()
3774 if ( NuNOptionsGuildCheckButton:GetChecked() ) then
3775 NuNSettings[pKey].autoG = "1";
3776 else
3777 NuNSettings[pKey].autoG = nil;
3778 end
3779 end
3780  
3781 function NuN_OptionsAddCheckBox_OnClick()
3782 if ( NuNOptionsAddCheckButton:GetChecked() ) then
3783 NuNSettings[pKey].autoA = "1";
3784 NuN_Update_Friends();
3785 NuN_Update_Ignored();
3786 else
3787 NuNSettings[pKey].autoA = nil;
3788 end
3789 end
3790  
3791 function NuN_OptionsDeleteCheckBox_OnClick()
3792 if ( NuNOptionsDeleteCheckButton:GetChecked() ) then
3793 NuNSettings[pKey].autoD = "1";
3794 NuN_Update_Friends();
3795 NuN_Update_Ignored();
3796 else
3797 NuNSettings[pKey].autoD = nil;
3798 end
3799 end
3800  
3801 function NuN_DefaultLevelCheckBox_OnClick()
3802 if ( NuN_DefaultLevelCheckBox:GetChecked() ) then
3803 NuNSettings[pKey].dLevel = "1";
3804 else
3805 NuNSettings[pKey].dLevel = nil;
3806 end
3807 end
3808  
3809 function NuN_HelpTTCheckBox_OnClick()
3810 if ( NuN_HelpTTCheckBox:GetChecked() ) then
3811 NuNSettings[pKey].toolTips = "1";
3812 else
3813 NuNSettings[pKey].toolTips = nil;
3814 end
3815 end
3816  
3817 function NuN_AutoQuestCheckBox_OnClick()
3818 if ( NuN_AutoQuestCheckBox:GetChecked() ) then
3819 NuNSettings[pKey].autoQ = "1";
3820 NuN_UpdateQuestNotes("SwitchedOn");
3821 else
3822 NuNSettings[pKey].autoQ = nil;
3823 end
3824 end
3825  
3826 function NuN_AutoNoteCheckBox_OnClick()
3827 if ( NuN_AutoNoteCheckBox:GetChecked() ) then
3828 NuNSettings[pKey].autoN = "1";
3829 if ( not NuNData[pKey][pName] ) then
3830 NuN_AutoNote();
3831 end
3832 else
3833 NuNSettings[pKey].autoN = nil;
3834 end
3835 end
3836  
3837  
3838 function NuN_OnUpdate(arg1)
3839 if ( ( NuNMicroFrame:IsVisible() ) and ( MouseIsOver(NuNMicroFrame) ) ) then
3840 NuNMicroBorder:Show();
3841 else
3842 NuNMicroBorder:Hide();
3843 end
3844  
3845 if ( noTipAnchor ) then
3846 NuN_GameTooltip_OnShow();
3847 end
3848  
3849 timeSinceLastUpdate = timeSinceLastUpdate + arg1;
3850 if ( ( timeSinceLastUpdate > updateInterval ) and ( not UnitAffectingCombat("player") ) ) then
3851 if ( not NuNData[pKey][pName] ) then
3852 NuN_AutoNote();
3853 end
3854 if ( oneDone == true ) then
3855 oneDone = false;
3856 NuN_AtStartup = "False";
3857 NuN_QuestsUpdating = "False";
3858 if ( InfinateIgnore_Config ) then
3859 NuN_Update_Ignored();
3860 end
3861 else
3862 oneDone = true;
3863 if ( not QuestLogFrame:IsVisible() ) then
3864 NuN_CheckQuestList();
3865 if ( not NuN_IgnoreNextQUpdate ) then
3866 NuN_UpdateQuestNotes("Timed");
3867 end
3868 end
3869 end
3870 timeSinceLastUpdate = 0;
3871 end
3872 end
3873  
3874  
3875  
3876 function NuN_NewContact(unitType)
3877 local Friendly;
3878  
3879 if ( ( unitType == "target" ) and ( c_name ~= pName ) ) then
3880 if ( UnitIsFriend("player", "target") ) then
3881 Friendly = true;
3882 else
3883 Friendly = false;
3884 end
3885 else
3886 Friendly = true;
3887 end
3888 if ( ((horde) and (Friendly)) or ((not horde) and (not Friendly)) ) then
3889 c_faction = "Horde";
3890 NuN_HordeSetup();
3891 else
3892 c_faction = "Alliance";
3893 NuN_AllianceSetup();
3894 end
3895 c_route = "Target";
3896 c_race = nil;
3897 c_class = nil;
3898 c_guild = nil;
3899 gRank = nil;
3900 gRankIndex = nil;
3901 gNote = nil;
3902 gOfficerNote = nil;
3903 NuN_ShowNote();
3904 NuN_Target();
3905 if ( c_name == pName ) then
3906 ClearTarget();
3907 end
3908 end
3909  
3910  
3911 function NuN_CreateContact(contactName, tFaction)
3912 c_name = contactName;
3913 c_route = "Create";
3914 if ( ( tFaction == "-ch" ) or ( tFaction == "Horde" ) ) then
3915 c_faction = "Horde";
3916 NuN_HordeSetup();
3917 else
3918 c_faction = "Alliance";
3919 NuN_AllianceSetup();
3920 end
3921 c_race = nil;
3922 c_class = nil;
3923 c_guild = nil;
3924 gRank = nil;
3925 gRankIndex = nil;
3926 gNote = nil;
3927 gOfficerNote = nil;
3928 NuN_ShowNote();
3929 end
3930  
3931  
3932 function NuN_HordeSetup()
3933 NuNRaceDropDown = NuNHRaceDropDown;
3934 NuNClassDropDown = NuNHClassDropDown;
3935 NuNCRankDropDown = NuNHCRankDropDown;
3936 NuNHRankDropDown = NuNHHRankDropDown;
3937 NuNARaceDropDown:Hide();
3938 NuNHRaceDropDown:Show();
3939 NuNAClassDropDown:Hide();
3940 NuNHClassDropDown:Show();
3941 NuNACRankDropDown:Hide();
3942 NuNHCRankDropDown:Show();
3943 NuNAHRankDropDown:Hide();
3944 NuNHHRankDropDown:Show();
3945 Classes = HClasses;
3946 Races = HRaces;
3947 Ranks = HRanks;
3948 NuNAFlag:Hide();
3949 NuNHFlag:Show();
3950 end
3951  
3952 function NuN_AllianceSetup()
3953 NuNRaceDropDown = NuNARaceDropDown;
3954 NuNClassDropDown = NuNAClassDropDown;
3955 NuNCRankDropDown = NuNACRankDropDown;
3956 NuNHRankDropDown = NuNAHRankDropDown;
3957 NuNHRaceDropDown:Hide();
3958 NuNARaceDropDown:Show();
3959 NuNHClassDropDown:Hide();
3960 NuNAClassDropDown:Show();
3961 NuNHCRankDropDown:Hide();
3962 NuNACRankDropDown:Show();
3963 NuNHHRankDropDown:Hide();
3964 NuNAHRankDropDown:Show();
3965 Classes = AClasses;
3966 Races = ARaces;
3967 Ranks = ARanks;
3968 NuNHFlag:Hide();
3969 NuNAFlag:Show();
3970 end
3971  
3972  
3973 function NuN_CheckPartyByName(parmN)
3974 local partym;
3975  
3976 for groupIndex = 1, NUN_MAX_PARTY_MEMBERS, 1 do
3977 if (GetPartyMember(groupIndex)) then
3978 partym = "party"..groupIndex;
3979 lName = UnitName(partym);
3980 if ( lName == parmN) then
3981 return partym;
3982 end
3983 end
3984 end
3985 return nil;
3986 end
3987  
3988 function NuN_CheckRaidByName(parmN)
3989 local raidm;
3990 local lclName;
3991 local numRaid = GetNumRaidMembers();
3992  
3993 for raidIndex = 1, numRaid, 1 do
3994 lclName = GetRaidRosterInfo(raidIndex);
3995 if ( lclName == parmN ) then
3996 raidm = "raid"..raidIndex;
3997 return raidm;
3998 end
3999 end
4000 return nil;
4001 end
4002  
4003  
4004  
4005 function NuN_GetCText(gLclName)
4006 local txtIndex;
4007 local catText;
4008  
4009 catText = "";
4010 if ( NuNData[pKey][gLclName][txtTxt] ) then
4011 catText = NuNData[pKey][gLclName][txtTxt];
4012 end
4013 for i = 1, NUN_MAX_ADD_TXT, 1 do
4014 txtIndex = txtTxt..i;
4015 if ( NuNData[pKey][gLclName][txtIndex] ) then
4016 catText = catText..NuNData[pKey][gLclName][txtIndex];
4017 end
4018 end
4019 return catText;
4020 end
4021  
4022  
4023  
4024 function NuN_GetGText(gLclNote)
4025 local txtIndex;
4026 local catText;
4027  
4028 catText = "";
4029 if ( ( NuNData[pKey][Notes][gLclNote] ) and ( NuNData[pKey][Notes][gLclNote][txtTxt] ) ) then
4030 catText = NuNData[pKey][Notes][gLclNote][txtTxt];
4031 elseif ( ( NuNData[Notes][gLclNote] ) and ( NuNData[Notes][gLclNote][txtTxt] ) ) then
4032 catText = NuNData[Notes][gLclNote][txtTxt];
4033 end
4034 for i = 1, NUN_MAX_ADD_TXT, 1 do
4035 txtIndex = txtTxt..i;
4036 if ( ( NuNData[pKey][Notes][gLclNote] ) and ( NuNData[pKey][Notes][gLclNote][txtIndex] ) ) then
4037 catText = catText..NuNData[pKey][Notes][gLclNote][txtIndex];
4038 elseif ( ( NuNData[Notes][gLclNote] ) and ( NuNData[Notes][gLclNote][txtIndex] ) ) then
4039 catText = catText..NuNData[Notes][gLclNote][txtIndex];
4040 end
4041 end
4042 return catText;
4043 end
4044  
4045  
4046  
4047 function NuN_SetCText(sLclName)
4048 local cLower;
4049 local cUpper;
4050 local txtIndex;
4051  
4052 c_text_len = string.len(c_text);
4053 if ( c_text_len < NUN_MAX_TXT_CHR ) then
4054 cUpper = c_text_len;
4055 else
4056 cUpper = NUN_MAX_TXT_CHR;
4057 end
4058 NuNData[pKey][sLclName][txtTxt] = string.sub(c_text, 1, cUpper);
4059 for i = 1, NUN_MAX_ADD_TXT, 1 do
4060 cLower = NUN_MAX_TXT_CHR * i;
4061 txtIndex = txtTxt..i;
4062 if ( c_text_len > cLower ) then
4063 cLower = cLower + 1;
4064 cUpper = NUN_MAX_TXT_CHR * ( i + 1 );
4065 if ( c_text_len < cUpper ) then
4066 cUpper = c_text_len;
4067 end
4068 NuNData[pKey][sLclName][txtIndex] = string.sub(c_text, cLower, cUpper);
4069 else
4070 NuNData[pKey][sLclName][txtIndex] = "";
4071 end
4072 end
4073 end
4074  
4075  
4076  
4077 function NuN_SetGText(saveLvl)
4078 local cLower;
4079 local cUpper;
4080 local txtIndex;
4081  
4082 g_text_len = string.len(g_text);
4083 if ( g_text_len < NUN_MAX_TXT_CHR ) then
4084 cUpper = g_text_len;
4085 else
4086 cUpper = NUN_MAX_TXT_CHR;
4087 end
4088  
4089 if ( saveLvl == "Realm" ) then
4090 NuNData[pKey][Notes][c_note][txtTxt] = string.sub(g_text, 1, NUN_MAX_TXT_CHR);
4091 for i = 1, NUN_MAX_ADD_TXT, 1 do
4092 cLower = NUN_MAX_TXT_CHR * i;
4093 txtIndex = txtTxt..i;
4094 if ( g_text_len > cLower ) then
4095 cLower = cLower + 1;
4096 cUpper = NUN_MAX_TXT_CHR * ( i + 1 );
4097 if ( g_text_len < cUpper ) then
4098 cUpper = g_text_len;
4099 end
4100 NuNData[pKey][Notes][c_note][txtIndex] = string.sub(g_text, cLower, cUpper);
4101 else
4102 NuNData[pKey][Notes][c_note][txtIndex] = "";
4103 end
4104 end
4105 else
4106 NuNData[Notes][c_note][txtTxt] = string.sub(g_text, 1, NUN_MAX_TXT_CHR);
4107 for i = 1, NUN_MAX_ADD_TXT, 1 do
4108 cLower = NUN_MAX_TXT_CHR * i;
4109 txtIndex = txtTxt..i;
4110 if ( g_text_len > cLower ) then
4111 cLower = cLower + 1;
4112 cUpper = NUN_MAX_TXT_CHR * ( i + 1 );
4113 if ( g_text_len < cUpper ) then
4114 cUpper = g_text_len;
4115 end
4116 NuNData[Notes][c_note][txtIndex] = string.sub(g_text, cLower, cUpper);
4117 else
4118 NuNData[Notes][c_note][txtIndex] = "";
4119 end
4120 end
4121 end
4122 end
4123  
4124  
4125  
4126 function NuN_TextWarning(box, tLabel)
4127 local lenTxt, lenTxtL, oLabel;
4128  
4129 lenTxt = box:GetText();
4130 lenTxtL = string.len(lenTxt);
4131 oLabel = getglobal(tLabel);
4132 if ( ( lenTxtL == nil ) or ( lenTxtL == 0 ) ) then
4133 oLabel:SetText("0 / "..NUN_MAX_TXT_LIM);
4134 else
4135 oLabel:SetText(lenTxtL.." / "..NUN_MAX_TXT_LIM);
4136 end
4137 if ( lenTxtL > NUN_MAX_TXT_LIM ) then
4138 StaticPopup_Show("NUN_NOTELIMIT_EXCEEDED");
4139 end
4140 end
4141  
4142  
4143  
4144 function NuN_OptionsButton_OnEnter()
4145 if ( NuNSettings[pKey].toolTips ) then
4146 NuN_Fade = "False";
4147 local x, y = GetCursorPosition();
4148 if ( x > 500 ) then
4149 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4150 else
4151 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4152 end
4153 NuN_Tooltip:ClearLines();
4154 NuN_Tooltip:AddLine(NUN_MICROOPTIONS_TOOLTIP_TXT1, 1, 0.7, 0);
4155 NuN_Tooltip:AddLine(NUN_MICROOPTIONS_TOOLTIP_TXT2, 0, 1, 0);
4156 NuN_Tooltip:Show();
4157 end
4158 end
4159  
4160 function NuN_BrowseButton_OnEnter()
4161 if ( NuNSettings[pKey].toolTips ) then
4162 NuN_Fade = "False";
4163 local x, y = GetCursorPosition();
4164 if ( x > 500 ) then
4165 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4166 else
4167 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4168 end
4169 NuN_Tooltip:ClearLines();
4170 NuN_Tooltip:AddLine(NUN_MICROBROWSEA_TOOLTIP_TXT1, 1, 0.7, 0);
4171 NuN_Tooltip:AddLine(NUN_MICROBROWSEA_TOOLTIP_TXT2, 0, 1, 0);
4172 NuN_Tooltip:Show();
4173 end
4174 end
4175  
4176 function NuN_ContactButton_OnEnter()
4177 if ( NuNSettings[pKey].toolTips ) then
4178 NuN_Fade = "False";
4179 local x, y = GetCursorPosition();
4180 if ( x > 500 ) then
4181 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4182 else
4183 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4184 end
4185 NuN_Tooltip:ClearLines();
4186 NuN_Tooltip:AddLine(NUN_MICROCONTACT_TOOLTIP_TXT1, 1, 0.7, 0);
4187 NuN_Tooltip:AddLine(NUN_MICROCONTACT_TOOLTIP_TXT2, 0, 1, 0);
4188 NuN_Tooltip:AddLine(NUN_MICROCONTACT_TOOLTIP_TXT3, 0, 1, 0);
4189 NuN_Tooltip:Show();
4190 end
4191 end
4192  
4193 function NuN_GNoteButton_OnEnter()
4194 if ( NuNSettings[pKey].toolTips ) then
4195 NuN_Fade = "False";
4196 local x, y = GetCursorPosition();
4197 if ( x > 500 ) then
4198 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4199 else
4200 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4201 end
4202 NuN_Tooltip:ClearLines();
4203 NuN_Tooltip:AddLine(NUN_MICROGENNOTE_TOOLTIP_TXT1, 1, 0.7, 0);
4204 NuN_Tooltip:AddLine(NUN_MICROGENNOTE_TOOLTIP_TXT2, 0, 1, 0);
4205 NuN_Tooltip:Show();
4206 end
4207 end
4208  
4209 function NuN_ResetButton_OnEnter()
4210 if ( NuNSettings[pKey].toolTips ) then
4211 NuN_Fade = "False";
4212 local x, y = GetCursorPosition();
4213 if ( x > 500 ) then
4214 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4215 else
4216 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4217 end
4218 NuN_Tooltip:ClearLines();
4219 NuN_Tooltip:AddLine(NUN_RESETBUTTON_TOOLTIP_TXT1, 1, 0.7, 0);
4220 NuN_Tooltip:AddLine(NUN_RESETBUTTON_TOOLTIP_TXT2, 0, 1, 0);
4221 NuN_Tooltip:Show();
4222 end
4223 end
4224  
4225 function NuN_LocButton_OnEnter()
4226 if ( NuNSettings[pKey].toolTips ) then
4227 NuN_Fade = "False";
4228 local x, y = GetCursorPosition();
4229 if ( x > 500 ) then
4230 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4231 else
4232 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4233 end
4234 NuN_Tooltip:ClearLines();
4235 NuN_Tooltip:AddLine(NUN_LOCBUTTON_TOOLTIP_TXT1, 1, 0.7, 0);
4236 NuN_Tooltip:AddLine(NUN_LOCBUTTON_TOOLTIP_TXT2, 0, 1, 0);
4237 NuN_Tooltip:Show();
4238 end
4239 end
4240  
4241 function NuN_GNoteTitle_OnEnter()
4242 if ( NuNSettings[pKey].toolTips ) then
4243 NuN_Fade = "False";
4244 local x, y = GetCursorPosition();
4245 if ( x > 500 ) then
4246 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4247 else
4248 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4249 end
4250 NuN_Tooltip:ClearLines();
4251 NuN_Tooltip:AddLine(NUN_GNOTETITLE_TOOLTIP_TXT1, 1, 0.7, 0);
4252 NuN_Tooltip:AddLine(NUN_GNOTETITLE_TOOLTIP_TXT2, 0, 1, 0);
4253 NuN_Tooltip:Show();
4254 end
4255 end
4256  
4257 function NuN_SaveDefCheck_OnEnter()
4258 if ( NuNSettings[pKey].toolTips ) then
4259 NuN_Fade = "False";
4260 local x, y = GetCursorPosition();
4261 if ( x > 500 ) then
4262 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4263 else
4264 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4265 end
4266 NuN_Tooltip:ClearLines();
4267 NuN_Tooltip:AddLine(NUN_SAVEDEF_TOOLTIP_TXT1, 1, 0.7, 0);
4268 NuN_Tooltip:AddLine(NUN_SAVEDEF_TOOLTIP_TXT2, 0, 1, 0);
4269 NuN_Tooltip:Show();
4270 end
4271 end
4272  
4273 function NuN_RestoreDefButton_OnEnter()
4274 if ( NuNSettings[pKey].toolTips ) then
4275 NuN_Fade = "False";
4276 local x, y = GetCursorPosition();
4277 if ( x > 500 ) then
4278 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4279 else
4280 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4281 end
4282 NuN_Tooltip:ClearLines();
4283 NuN_Tooltip:AddLine(NUN_RESTOREDEF_TOOLTIP_TXT1, 1, 0.7, 0);
4284 NuN_Tooltip:AddLine(NUN_RESTOREDEF_TOOLTIP_TXT2, 0, 1, 0);
4285 NuN_Tooltip:AddLine(NUN_RESTOREDEF_TOOLTIP_TXT3, 0, 1, 0);
4286 NuN_Tooltip:AddLine(NUN_RESTOREDEF_TOOLTIP_TXT4, 0, 1, 0);
4287 NuN_Tooltip:Show();
4288 end
4289 end
4290  
4291 function NuN_TargetButton_OnEnter()
4292 if ( NuNSettings[pKey].toolTips ) then
4293 NuN_Fade = "False";
4294 local x, y = GetCursorPosition();
4295 if ( x > 500 ) then
4296 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4297 else
4298 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4299 end
4300 NuN_Tooltip:ClearLines();
4301 NuN_Tooltip:AddLine(NUN_TARGETBUTTON_TOOLTIP_TXT1, 1, 0.7, 0);
4302 NuN_Tooltip:AddLine(NUN_TARGETBUTTON_TOOLTIP_TXT2, 0, 1, 0);
4303 NuN_Tooltip:AddLine(NUN_TARGETBUTTON_TOOLTIP_TXT3, 0, 1, 0);
4304 NuN_Tooltip:AddLine(NUN_TARGETBUTTON_TOOLTIP_TXT4, 0, 1, 0);
4305 NuN_Tooltip:Show();
4306 end
4307 end
4308  
4309 function NuN_NPCTargetButton_OnEnter()
4310 if ( NuNSettings[pKey].toolTips ) then
4311 NuN_Fade = "False";
4312 local x, y = GetCursorPosition();
4313 if ( x > 500 ) then
4314 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4315 else
4316 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4317 end
4318 NuN_Tooltip:ClearLines();
4319 NuN_Tooltip:AddLine(NUN_NPCTARGETBUTTON_TOOLTIP_TXT1, 1, 0.7, 0);
4320 NuN_Tooltip:AddLine(NUN_NPCTARGETBUTTON_TOOLTIP_TXT2, 0, 1, 0);
4321 NuN_Tooltip:Show();
4322 end
4323 end
4324  
4325 function NuN_WhoButton_OnEnter()
4326 if ( NuNSettings[pKey].toolTips ) then
4327 NuN_Fade = "False";
4328 local x, y = GetCursorPosition();
4329 if ( x > 500 ) then
4330 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4331 else
4332 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4333 end
4334 NuN_Tooltip:ClearLines();
4335 NuN_Tooltip:AddLine(NUN_WHOBUTTON_TOOLTIP_TXT1, 1, 0.7, 0);
4336 NuN_Tooltip:AddLine(NUN_WHOBUTTON_TOOLTIP_TXT2, 0, 1, 0);
4337 NuN_Tooltip:AddLine(NUN_WHOBUTTON_TOOLTIP_TXT3, 0, 1, 0);
4338 NuN_Tooltip:Show();
4339 end
4340 end
4341  
4342 function NuN_UserButtons_OnEnter(owner)
4343 if ( NuNSettings[pKey].toolTips ) then
4344 NuN_Fade = "False";
4345 local x, y = GetCursorPosition();
4346 if ( x > 500 ) then
4347 NuN_Tooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT");
4348 else
4349 NuN_Tooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT");
4350 end
4351 NuN_Tooltip:ClearLines();
4352 NuN_Tooltip:AddLine(NUN_USERBUTTON_TOOLTIP_TXT1, 1, 0.7, 0);
4353 NuN_Tooltip:AddLine(NUN_USERBUTTON_TOOLTIP_TXT2, 0, 1, 0);
4354 NuN_Tooltip:AddLine(NUN_USERBUTTON_TOOLTIP_TXT3, 0, 1, 0);
4355 NuN_Tooltip:Show();
4356 end
4357 end
4358  
4359 function NuN_ClearDD_OnEnter()
4360 if ( NuNSettings[pKey].toolTips ) then
4361 NuN_Fade = "False";
4362 local x, y = GetCursorPosition();
4363 if ( x > 500 ) then
4364 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4365 else
4366 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4367 end
4368 NuN_Tooltip:ClearLines();
4369 NuN_Tooltip:AddLine(NUN_CLEARDD_TOOLTIP_TXT1, 1, 0.7, 0);
4370 NuN_Tooltip:AddLine(NUN_CLEARDD_TOOLTIP_TXT2, 0, 1, 0);
4371 NuN_Tooltip:Show();
4372 end
4373 end
4374  
4375  
4376 function NuN_FFButton_OnEnter()
4377 NuN_FFButton_StateLit:Show();
4378 if ( NuNSettings[pKey].toolTips ) then
4379 NuN_Fade = "False";
4380 NuN_Tooltip:SetOwner(this, "ANCHOR_RIGHT");
4381 NuN_Tooltip:ClearLines();
4382 NuN_Tooltip:AddLine(NUN_FFBUTTON_TOOLTIP_TXT1, 1, 0.7, 0);
4383 NuN_Tooltip:AddLine(NUN_FFBUTTON_TOOLTIP_TXT2, 0, 1, 0);
4384 NuN_Tooltip:Show();
4385 end
4386 end
4387  
4388  
4389 function NuNMapNoteButton_OnEnter()
4390 if ( NuNSettings[pKey].toolTips ) then
4391 NuN_Fade = "False";
4392 local x, y = GetCursorPosition();
4393 if ( x > 500 ) then
4394 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4395 else
4396 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4397 end
4398 NuN_Tooltip:ClearLines();
4399 NuN_Tooltip:AddLine(NUN_TT_MAPNOTES_TXT1, 1, 0.7, 0);
4400 NuN_Tooltip:AddLine(NUN_TT_MAPNOTES_TXT2, 0, 1, 0);
4401 NuN_Tooltip:AddLine(NUN_TT_MAPNOTES_TXT3, 0, 1, 0);
4402 NuN_Tooltip:Show();
4403 end
4404 end
4405  
4406 function NuN_PinnedTT_OnEnter()
4407 if ( NuNSettings[pKey].toolTips ) then
4408 NuN_Fade = "False";
4409 local x, y = GetCursorPosition();
4410 if ( x > 500 ) then
4411 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4412 else
4413 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4414 end
4415 NuN_Tooltip:ClearLines();
4416 NuN_Tooltip:AddLine(NUN_TT_PIN_EDIT_TXT1, 1, 0.7, 0);
4417 NuN_Tooltip:AddLine(NUN_TT_PIN_EDIT_TXT2, 0, 1, 0);
4418 NuN_Tooltip:AddLine(NUN_TT_PIN_EDIT_TXT3, 0, 1, 0);
4419 NuN_Tooltip:Show();
4420 end
4421 end
4422  
4423 function NuN_OpenChat_OnEnter()
4424 if ( NuNSettings[pKey].toolTips ) then
4425 NuN_Fade = "False";
4426 local x, y = GetCursorPosition();
4427 if ( x > 500 ) then
4428 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4429 else
4430 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4431 end
4432 NuN_Tooltip:ClearLines();
4433 NuN_Tooltip:AddLine(NUN_TT_OPENCHAT_TXT1, 1, 0.7, 0);
4434 NuN_Tooltip:AddLine(NUN_TT_OPENCHAT_TXT2, 0, 1, 0);
4435 NuN_Tooltip:AddLine(NUN_TT_OPENCHAT_TXT3, 0, 1, 0);
4436 NuN_Tooltip:Show();
4437 end
4438 end
4439  
4440  
4441 function NuN_GNoteButtonDelete_OnEnter()
4442 if ( ( NuNSettings[pKey].toolTips ) and ( NuNGNoteFrame.fromQuest ) ) then
4443 NuN_Fade = "False";
4444 local x, y = GetCursorPosition();
4445 if ( x > 500 ) then
4446 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
4447 else
4448 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
4449 end
4450 NuN_Tooltip:ClearLines();
4451 NuN_Tooltip:AddLine(NUN_TT_GDELETE_TXT1, 1, 0.7, 0);
4452 NuN_Tooltip:AddLine(NUN_TT_GDELETE_TXT2, 0, 1, 0);
4453 NuN_Tooltip:AddLine(NUN_TT_GDELETE_TXT3, 0, 1, 0);
4454 NuN_Tooltip:AddLine(NUN_TT_GDELETE_TXT4, 0, 1, 0);
4455 NuN_Tooltip:Show();
4456 end
4457 end
4458  
4459  
4460  
4461 function NuN_FFButton_OnLeave()
4462 NuN_FFButton_StateLit:Hide();
4463 NuN_Tooltip:Hide();
4464 end
4465  
4466 function NuN_TTButton_OnLeave()
4467 NuN_Tooltip:Hide();
4468 end
4469  
4470 function NuN_ToggleToolTips()
4471 if ( NuNSettings[pKey].toolTips ) then
4472 NuNSettings[pKey].toolTips = nil;
4473 else
4474 NuNSettings[pKey].toolTips = "1";
4475 end
4476 end
4477  
4478  
4479  
4480 function NuN_NPCInfo()
4481 local NPCInfo = "";
4482 local NPCloc;
4483 local NPCtimed;
4484 local someInfo = false;
4485 local listText = nil;
4486  
4487 NPClvl = UnitLevel("target");
4488 NPCcls = UnitClass("target");
4489 NPCclsXtra = UnitClassification("target");
4490 NPCtype = UnitCreatureType("target");
4491 NPCsex = UnitSex("target");
4492 if ( NPClvl ~= nil ) then
4493 if ( NPClvl == -1 ) then
4494 NPCInfo = NUN_LEVEL.." : ?? ";
4495 else
4496 NPCInfo = NUN_LEVEL.." : "..NPClvl.." ";
4497 end
4498 end
4499 if ( NPCcls ~= nil ) then
4500 NPCInfo = NPCInfo..NUN_CLASS.." : "..NPCcls..", ";
4501 end
4502 if ( NPCsex ~= nil ) then
4503 local sex = Sexes[NPCsex + 1];
4504 if ( sex ) then
4505 NPCInfo = NPCInfo..sex..", ";
4506 end
4507 end
4508 if ( NPCtype ~= nil ) then
4509 NPCInfo = NPCInfo..NPCtype.." ";
4510 end
4511 if ( NPCclsXtra ~= "normal" ) then
4512 NPCInfo = NPCInfo..( string.upper(NPCclsXtra) );
4513 end
4514  
4515 GameTooltip:SetUnit("target");
4516 NPCprof = GameTooltipTextLeft2:GetText();
4517 if ( ( string.find(NPCprof, NUN_LEVEL) or ( NPCprof == nil ) ) ) then
4518 -- skip
4519 else
4520 NPCInfo = NPCInfo.."\n"..NUN_PROF.." : "..NPCprof.." ";
4521 end
4522  
4523 NPCtimed = NuN_GetDateStamp();
4524 NPCloc = NuN_GetLoc();
4525  
4526 NPCInfo = NPCInfo.."\n\n"..NPCtimed.."\n"..NPCloc;
4527  
4528 if ( MerchantFrame:IsVisible() ) then
4529 listText = NuN_BuildShoppingList();
4530 end
4531  
4532 if ( listText ) then
4533 NPCInfo = NPCInfo.."\n\n"..listText;
4534 end
4535  
4536 return NPCInfo;
4537 end
4538  
4539  
4540  
4541  
4542  
4543 function NuN_ShowFriendNote()
4544 local numFriends = GetNumFriends();
4545 if (numFriends ~= nil) and (numFriends > 0) then
4546 if ( FriendsFrame.selectedFriend ) then
4547 FriendsFrame.selectedFriend = GetSelectedFriend();
4548 c_name, discard, c_class, discard, connected = GetFriendInfo(FriendsFrame.selectedFriend);
4549 if ( c_class == "Unknown" ) then
4550 c_class = nil;
4551 end;
4552 c_race = nil;
4553 c_guild = nil;
4554 gRank = nil;
4555 gRankIndex = nil;
4556 gNote = nil;
4557 gOfficerNote = nil;
4558 c_route = "Friend";
4559 if ( horde ) then
4560 NuN_HordeSetup();
4561 else
4562 NuN_AllianceSetup();
4563 end
4564 NuN_ShowNote();
4565 end
4566 end
4567 end
4568  
4569  
4570  
4571 function NuN_ShowIgnoreNote()
4572 local numIgnores = GetNumIgnores();
4573 if (numIgnores ~= nil) and (numIgnores > 0) then
4574 if ( FriendsFrame.selectedIgnore ) then
4575 FriendsFrame.selectedIgnore = GetSelectedIgnore();
4576 c_name = GetIgnoreName(FriendsFrame.selectedIgnore);
4577 c_class = nil;
4578 c_race = nil;
4579 c_guild = nil;
4580 gRank = nil;
4581 gRankIndex = nil;
4582 gNote = nil;
4583 gOfficerNote = nil;
4584 c_route = "Ignore";
4585 if ( horde ) then
4586 NuN_HordeSetup();
4587 else
4588 NuN_AllianceSetup();
4589 end
4590 NuN_ShowNote();
4591 end
4592 end
4593 end
4594  
4595  
4596  
4597 function NuN_ShowGuildNote()
4598 local numGuildMembers = GetNumGuildMembers();
4599 if (numGuildMembers ~= nil) and (numGuildMembers > 0) then
4600 c_class = nil;
4601 c_race = nil;
4602 c_name, gRank, gRankIndex, discard, c_class, discard, discard, gNote, gOfficerNote, discard = GetGuildRosterInfo( GetGuildRosterSelection() );
4603 if ( c_name ~= nil ) then
4604 c_guild = GetGuildInfo("player");
4605 c_route = "Guild";
4606 if ( horde ) then
4607 NuN_HordeSetup();
4608 else
4609 NuN_AllianceSetup();
4610 end
4611 NuN_ShowNote();
4612 end
4613 end
4614 end
4615  
4616  
4617 function NuN_UpdateNoteButton(nBttn, nBttnID, NuN_rType)
4618 local bName = nBttn:GetName();
4619 local pBttnTxt, discard, qHeader;
4620 local bttnNoteHFlag = getglobal(bName.."FrameHFlag");
4621 local bttnNoteAFlag = getglobal(bName.."FrameAFlag");
4622 local bttnNoteNFlag = getglobal(bName.."FrameNFlag");
4623 local bttnNoteQFlag = getglobal(bName.."FrameQFlag");
4624  
4625 if ( NuN_rType == "A" ) then
4626 if ( FriendsListFrame:IsVisible() ) then
4627 NuN_rType = "F";
4628 elseif ( IgnoreListFrame:IsVisible() ) then
4629 NuN_rType = "I";
4630 elseif ( GuildPlayerStatusFrame:IsVisible() ) then
4631 NuN_rType = "G";
4632 elseif ( GuildStatusFrame:IsVisible() ) then
4633 NuN_rType = "GS";
4634 elseif ( WhoFrame:IsVisible() ) then
4635 NuN_rType = "W";
4636 elseif ( QuestFrame:IsVisible() ) then
4637 NuN_rType = NUN_QUEST_C;
4638 end
4639 end
4640  
4641 if ( ( FriendsFrame:IsVisible() ) and ( bttnNoteAFlag ) and ( bttnNoteHFlag ) and ( bttnNoteNFlag ) ) then
4642 pBttnTxt = NuN_GetName_FrameButton(nBttnID, NuN_rType);
4643 if ( NuNData[pKey][pBttnTxt] ) then
4644 if ( NuNData[pKey][pBttnTxt].faction == "Horde" ) then
4645 bttnNoteAFlag:Hide();
4646 bttnNoteNFlag:Hide();
4647 bttnNoteHFlag:Show();
4648 else
4649 bttnNoteHFlag:Hide();
4650 bttnNoteNFlag:Hide();
4651 bttnNoteAFlag:Show();
4652 end
4653 else
4654 bttnNoteAFlag:Hide();
4655 bttnNoteHFlag:Hide();
4656 bttnNoteNFlag:Show();
4657 end
4658 elseif ( ( QuestLogFrame:IsVisible() ) and ( bttnNoteQFlag ) and ( bttnNoteNFlag ) ) then
4659 local lOffset = nBttnID + FauxScrollFrame_GetOffset(QuestLogListScrollFrame);
4660 pBttnTxt, discard, discard, qHeader = GetQuestLogTitle(lOffset);
4661 if ( qHeader ) then
4662 nBttn:Hide();
4663 elseif ( pBttnTxt ) then
4664 nBttn:Show();
4665 if ( ( NuNData[pKey][Notes][pBttnTxt] ) or ( NuNData[Notes][pBttnTxt] ) ) then
4666 bttnNoteNFlag:Hide();
4667 bttnNoteQFlag:Show();
4668 else
4669 bttnNoteQFlag:Hide();
4670 bttnNoteNFlag:Show();
4671 end
4672 end
4673 end
4674 end
4675  
4676  
4677  
4678 function NuN_NoteButton_OnInteract(nBttnID, uAction)
4679 local pBttnTxt;
4680 local lOffset;
4681 local qLevel, qTag, qHeader, qCollapsed, qComplete;
4682 local qText = "";
4683  
4684 if ( FriendsListFrame:IsVisible() ) then
4685 pBttnTxt = NuN_GetName_FrameButton(nBttnID, "F");
4686 if ( uAction == "Click" ) then
4687 lOffset = FauxScrollFrame_GetOffset(FriendsFrameFriendsScrollFrame);
4688 SetSelectedFriend( (tonumber(nBttnID)+lOffset) );
4689 NuNOri_FriendsList_Update();
4690 if ( NuNData[pKey][pBttnTxt] ) then
4691 NuN_ShowSavedNote(pBttnTxt);
4692 else
4693 NuN_ShowFriendNote();
4694 end
4695 elseif ( uAction == "MouseOver" ) then
4696 ttName = pBttnTxt;
4697 NuN_StaticTT();
4698 end
4699 elseif ( IgnoreListFrame:IsVisible() ) then
4700 pBttnTxt = NuN_GetName_FrameButton(nBttnID, "I");
4701 if ( uAction == "Click" ) then
4702 lOffset = FauxScrollFrame_GetOffset(FriendsFrameIgnoreScrollFrame);
4703 SetSelectedIgnore( (tonumber(nBttnID)+lOffset) );
4704 NuNOri_IgnoreList_Update();
4705 if ( NuNData[pKey][pBttnTxt] ) then
4706 NuN_ShowSavedNote(pBttnTxt);
4707 else
4708 NuN_ShowIgnoreNote();
4709 end
4710 elseif ( uAction == "MouseOver" ) then
4711 ttName = pBttnTxt;
4712 NuN_StaticTT();
4713 end
4714 elseif ( GuildPlayerStatusFrame:IsVisible() ) then
4715 pBttnTxt = NuN_GetName_FrameButton(nBttnID, "G");
4716 if ( uAction == "Click" ) then
4717 GuildFrame.selectedGuildMember = getglobal("GuildFrameButton"..nBttnID).guildIndex;
4718 GuildFrame.selectedName = getglobal("GuildFrameButton"..nBttnID.."Name"):GetText();
4719 SetGuildRosterSelection(GuildFrame.selectedGuildMember);
4720 NuNNew_GuildStatus_Update();
4721 if ( NuNData[pKey][pBttnTxt] ) then
4722 NuN_ShowSavedNote(pBttnTxt);
4723 else
4724 NuN_ShowGuildNote();
4725 end
4726 elseif ( uAction == "MouseOver" ) then
4727 ttName = pBttnTxt;
4728 NuN_StaticTT();
4729 end
4730 elseif ( GuildStatusFrame:IsVisible() ) then
4731 pBttnTxt = NuN_GetName_FrameButton(nBttnID, "GS");
4732 if ( uAction == "Click" ) then
4733 GuildFrame.selectedGuildMember = getglobal("GuildFrameGuildStatusButton"..nBttnID).guildIndex;
4734 GuildFrame.selectedName = getglobal("GuildFrameGuildStatusButton"..nBttnID.."Name"):GetText();
4735 SetGuildRosterSelection(GuildFrame.selectedGuildMember);
4736 NuNOri_GuildStatus_Update();
4737 if ( NuNData[pKey][pBttnTxt] ) then
4738 NuN_ShowSavedNote(pBttnTxt);
4739 else
4740 NuN_ShowGuildNote();
4741 end
4742 elseif ( uAction == "MouseOver" ) then
4743 ttName = pBttnTxt;
4744 NuN_StaticTT();
4745 end
4746 elseif ( WhoFrame:IsVisible() ) then
4747 pBttnTxt = NuN_GetName_FrameButton(nBttnID, "W");
4748 if ( uAction == "Click" ) then
4749 WhoFrame.selectedWho = getglobal("WhoFrameButton"..nBttnID).whoIndex;
4750 WhoFrame.selectedName = getglobal("WhoFrameButton"..nBttnID.."Name"):GetText();
4751 NuNOri_WhoList_Update();
4752 if ( NuNData[pKey][pBttnTxt] ) then
4753 NuN_ShowSavedNote(pBttnTxt);
4754 else
4755 NuN_ShowWhoNote(pBttnTxt);
4756 end
4757 elseif ( uAction == "MouseOver" ) then
4758 ttName = pBttnTxt;
4759 NuN_StaticTT();
4760 end
4761 elseif ( QuestLogFrame:IsVisible() ) then
4762 lOffset = nBttnID + FauxScrollFrame_GetOffset(QuestLogListScrollFrame);
4763 pBttnTxt, qLevel, qTag, qHeader, qCollapsed, qComplete = GetQuestLogTitle(lOffset);
4764 c_note = pBttnTxt;
4765 if ( uAction == "Click" ) then
4766 QuestLog_SetSelection(lOffset);
4767 NuNOri_QuestLog_Update();
4768 if ( qHeader ) then
4769 qText = "";
4770 else
4771 NuNGNoteFrame.fromQuest = nil;
4772 if ( ( NuNData[pKey][Notes][c_note] ) or ( NuNData[Notes][c_note] ) ) then
4773 NuN_ShowSavedGNote();
4774 else
4775 if ( qLevel == nil ) then
4776 qLevel = "--";
4777 end
4778 if ( qTag == nil ) then
4779 qTag = "";
4780 end
4781 qText = "\n"..c_note.." "..NUN_QLVL..qLevel.." "..qTag.." ".."\n\n"..NuN_BuildQuestText().."\n";
4782 if ( qHeader ) then
4783 c_type = NuNGet_CommandID(noteTypes, " ");
4784 else
4785 c_type = NuNGet_CommandID(noteTypes, "QST");
4786 end
4787 NuN_ShowTitledGNote( qText );
4788 end
4789 end
4790 elseif ( uAction == "MouseOver" ) then
4791 ttName = c_note;
4792 NuN_StaticTT();
4793 end
4794 end
4795 end
4796  
4797  
4798  
4799 function NuN_GetName_FrameButton(lBttnID, NuN_rType)
4800 local lBttn, lBttnTxt;
4801  
4802 if ( NuN_rType == "F" ) then
4803 lBttn = getglobal("FriendsFrameFriendButton"..lBttnID.."ButtonTextNameLocation");
4804 lBttnTxt = lBttn:GetText();
4805 local pos = string.find(lBttnTxt, NUN_SEP);
4806 if ( string.find(lBttnTxt, NUN_OFF) ) then
4807 lBttnTxt = string.sub(lBttnTxt, 11, (pos - 1));
4808 else
4809 lBttnTxt = string.sub(lBttnTxt, 1, (pos - 1));
4810 end
4811 elseif ( NuN_rType == "I" ) then
4812 lBttn = getglobal("FriendsFrameIgnoreButton"..lBttnID.."ButtonTextName");
4813 lBttnTxt = lBttn:GetText();
4814 elseif ( NuN_rType == "G" ) then
4815 lBttn = getglobal("GuildFrameButton"..lBttnID.."Name");
4816 lBttnTxt = lBttn:GetText();
4817 elseif ( NuN_rType == "GS" ) then
4818 lBttn = getglobal("GuildFrameGuildStatusButton"..lBttnID.."Name");
4819 lBttnTxt = lBttn:GetText();
4820 elseif ( NuN_rType == "W" ) then
4821 lBttn = getglobal("WhoFrameButton"..lBttnID.."Name");
4822 lBttnTxt = lBttn:GetText();
4823 elseif ( NuN_rType == NUN_QUEST_C ) then
4824 lBttn = getglobal("QuestLogTitle"..lBttnID.."NormalText");
4825 lBttnTxt = lBttn:GetText();
4826 end
4827  
4828 return lBttnTxt;
4829 end
4830  
4831  
4832 function NuN_StaticTT()
4833 local storePinned = NuN_PinnedTooltip.type;
4834  
4835 NuN_Tooltip:ClearLines();
4836 NuN_PinnedTooltip.type = "Nil";
4837 NuN_BuildTT(NuN_Tooltip);
4838 NuN_PinnedTooltip.type = storePinned;
4839 NuN_Fade = "False";
4840 NuN_Tooltip:Show();
4841 end
4842  
4843  
4844 function NuN_BuildTT(nunTT)
4845 local lGuild = nil;
4846 local lGuildR = nil;
4847 local lprof = "";
4848 local tt = {};
4849 local tti = 0;
4850 local srchText, sStart, sStop, tipText;
4851 local lineCount = 0;
4852 local finalTipText;
4853 local txtLines;
4854 local NuN_trunc = false;
4855 local gttLines = 0;
4856 local ttLinesDiff = 0;
4857 local ttLen = NUN_TT_MAX;
4858 local ttLLen = NUN_TT_LEN;
4859  
4860 if ( ( NuNSettings[pKey].toolTips ) or ( nunTT == NuN_PinnedTooltip ) ) then
4861 if ( NuN_PinnedTooltip.type ~= "General" ) and ( NuN_PinnedTooltip.type ~= "QuestHistory" ) and ( NuNData[pKey][ttName] ) then
4862 nunTT:AddLine(NUN_NOTESUNEED_INFO..NUN_PINNED_TT_PADDING, 1, 0.7, 0);
4863 lineCount = lineCount + 1;
4864  
4865 if ( NuN_PinUpHeader == true ) then
4866 nunTT:AddLine(ttName);
4867 lastPinned = ttName;
4868 lineCount = lineCount + 1;
4869 end
4870  
4871 for n = 1, uBttns, 1 do
4872 hdNbr = pHead..n
4873 nameHdNbr = ttName..hdNbr;
4874 nameDtNbr = ttName..pDetl..n;
4875 if ( ( (n == 1) and (not NuNData[pKey][nameHdNbr]) ) or ( (n==1) and ( NuNData[pKey][nameHdNbr].txt == dfltHeadings[n] ) ) ) then
4876 if ( NuNData[pKey][nameDtNbr] ) then
4877 lGuild = NuNData[pKey][nameDtNbr].txt;
4878 end
4879 elseif ( ( (n == 2) and (not NuNData[pKey][nameHdNbr]) ) or ( (n==2) and ( NuNData[pKey][nameHdNbr].txt == dfltHeadings[n] ) ) ) then
4880 if ( NuNData[pKey][nameDtNbr] ) then
4881 lGuildR = NuNData[pKey][nameDtNbr].txt;
4882 end
4883 elseif ( NuNData[pKey][nameHdNbr] ) then
4884 local ttDetl = (string.lower(NuNData[pKey][nameHdNbr].txt));
4885 if ( string.find(ttDetl, NUN_TT_HDNG) ) then
4886 if ( NuNData[pKey][nameDtNbr] ) then
4887 tti = tti + 1;
4888 tt[tti] = NuNData[pKey][nameDtNbr].txt;
4889 end
4890 end
4891 elseif ( NuNSettings[pKey][hdNbr] ) then
4892 local ttDetl = (string.lower(NuNSettings[pKey][hdNbr].txt));
4893 if ( string.find(ttDetl, NUN_TT_HDNG) ) then
4894 if ( NuNData[pKey][nameDtNbr] ) then
4895 tti = tti + 1;
4896 tt[tti] = NuNData[pKey][nameDtNbr].txt;
4897 end
4898 end
4899 end
4900 end
4901  
4902 for i = 1, getn(tt), 1 do
4903 nunTT:AddLine(tt[i], 0.9, 0.2, 0.2);
4904 lineCount = lineCount + 1;
4905 end
4906  
4907 if ( ( lGuild ~= nil) and ( lGuild ~= "" ) ) then
4908 if ( ( lGuildR ~= nil ) and ( lGuildR ~= "" ) ) then
4909 lGuild = lGuild.." : "..lGuildR;
4910 end
4911 nunTT:AddLine(lGuild, 0.9, 0.9, 0);
4912 lineCount = lineCount + 1;
4913 end
4914  
4915 if ( NuNData[pKey][ttName].prof1 ) then
4916 lprof = Professions[NuNData[pKey][ttName].prof1];
4917 end
4918 if ( NuNData[pKey][ttName].prof2 ) then
4919 if (lprof == "") then
4920 lprof = Professions[NuNData[pKey][ttName].prof2];
4921 else
4922 lprof = lprof.." - "..Professions[NuNData[pKey][ttName].prof2];
4923 end
4924 end
4925 if ( lprof ~= "" ) then
4926 nunTT:AddLine(lprof, 0.8, 0.2, 0.8);
4927 lineCount = lineCount + 1;
4928 end
4929  
4930 srchText = NuN_GetCText(ttName);
4931 elseif ( ( NuN_PinnedTooltip.type ~= "Contact" ) and ( NuN_PinnedTooltip.type ~= "QuestHistory" ) and ( ( NuNData[pKey][Notes][ttName] ) or ( NuNData[Notes][ttName] ) ) ) then
4932 nunTT:AddLine(NUN_NOTESUNEED_INFO..NUN_PINNED_TT_PADDING, 1, 0.7, 0);
4933 lineCount = lineCount + 1;
4934  
4935 if ( NuN_PinUpHeader == true ) then
4936 nunTT:AddLine(ttName);
4937 lastPinned = ttName;
4938 lineCount = lineCount + 1;
4939 end
4940  
4941 srchText = NuN_GetGText(ttName);
4942 elseif ( ( NuN_PinnedTooltip.type == "QuestHistory" ) and ( NuNData[pKey].QuestHistory[pName][ttName] ) ) then
4943 nunTT:AddLine(NUN_NOTESUNEED_INFO..NUN_PINNED_TT_PADDING, 1, 0.7, 0);
4944 lineCount = lineCount + 1;
4945  
4946 if ( NuN_PinUpHeader == true ) then
4947 nunTT:AddLine(ttName);
4948 lastPinned = ttName;
4949 lineCount = lineCount + 1;
4950 end
4951  
4952 srchText = NuNData[pKey].QuestHistory[pName][ttName].txt;
4953 end
4954  
4955 if ( NuN_PinnedTooltip.type ~= "QuestHistory" ) then
4956 if ( NuNSettings[pKey].ttLen ) then
4957 if ( NuNSettings[pKey].ttLen == "" ) then
4958 ttLen = 0;
4959 else
4960 ttLen = tonumber( NuNSettings[pKey].ttLen );
4961 end
4962 end
4963 if ( NuNSettings[pKey].ttLLen ) then
4964 if ( NuNSettings[pKey].ttLLen == "" ) then
4965 ttLLen = 0;
4966 else
4967 ttLLen = tonumber( NuNSettings[pKey].ttLLen );
4968 end
4969 end
4970 end
4971  
4972 if ( ( NuN_MouseOver == true ) and ( NuNSettings[pKey].minOver ) ) then
4973 srchText = "";
4974 end
4975  
4976 if ( ( srchText ~= nil ) and ( srchText ~= "" ) ) then
4977 sStart = string.find(srchText, NUN_TT_KEYPHRASE);
4978 if ( sStart ~= nil ) then
4979 sStart = sStart + NUN_TT_KEYPHRASE_LEN;
4980 sStop = string.find(srchText, NUN_TT_END, sStart);
4981 if ( sStop == nil ) then
4982 sStop = sStart + ttLen - 1;
4983 else
4984 sStop = sStop - 1;
4985 local sDiff = sStop - sStart;
4986 if ( ( sDiff > ttLen ) or ( sDiff < 0 ) ) then
4987 sStop = sStart + ttLen - 1;
4988 NuN_trunc = true;
4989 end
4990 end
4991 tipText = string.sub(srchText, sStart, sStop);
4992 else
4993 if ( string.len(srchText) > ttLen ) then
4994 NuN_trunc = true;
4995 end
4996 tipText = string.sub(srchText, 1, ttLen);
4997 end
4998 if ( string.len(tipText) > ttLLen ) then
4999 finalTipText, txtLines = NuN_ParseTT(tipText, ttLLen);
5000 else
5001 finalTipText = tipText;
5002 txtLines = 1;
5003 end
5004 if ( NuN_trunc == true ) then
5005 finalTipText = finalTipText..NUN_TT_ETC;
5006 end
5007 nunTT:AddLine(finalTipText, 0, 1, 0);
5008 lineCount = lineCount + txtLines;
5009 end
5010  
5011 local gttLines = GameTooltip:NumLines();
5012 local ttLinesDiff = lineCount - gttLines;
5013 if ( ttLinesDiff > NUN_TT_LINES_TRIGGER ) then
5014 local scaleUp = math.floor( 4 * (NuNSettings[pKey].tScale - 1) );
5015 NuN_TT_Y_Offset = ( ( ttLinesDiff - NUN_TT_LINES_TRIGGER ) * ( NUN_TT_Y_SHIFT + scaleUp ) );
5016 NuN_TT_Y_Offset = math.floor( NuN_TT_Y_Offset );
5017 end
5018 end
5019 end
5020  
5021  
5022 function NuN_ParseTT(txtIn, fragLen)
5023 local p1 = 0;
5024 local p2 = 0;
5025 local txtOut = "";
5026 local txtTmp = "";
5027 local xtraLines = "";
5028 local parsedLines = 1;
5029  
5030 while ( true ) do
5031 p2 = string.find(txtIn, "\n", ( p1 + 1 ) );
5032 if ( p2 == nil ) then
5033 break;
5034 end
5035 txtTmp = string.sub(txtIn, ( p1 + 1 ), p2);
5036 txtTmpL = string.len(txtTmp);
5037 if ( txtTmpL > ( fragLen + 10 ) ) then
5038 txtTmp, xtraLines = NuN_Fragment(txtTmp, fragLen);
5039 else
5040 xtraLines = 1;
5041 end
5042 p1 = p2;
5043 parsedLines = parsedLines + xtraLines;
5044 txtOut = txtOut..txtTmp;
5045 end
5046 txtTmp = string.sub(txtIn, ( p1 + 1 ) );
5047 txtTmpL = string.len(txtTmp);
5048 if ( txtTmpL > fragLen ) then
5049 txtTmp, xtraLines = NuN_Fragment(txtTmp, fragLen);
5050 else
5051 xtraLines = 1;
5052 end
5053 parsedLines = parsedLines + xtraLines;
5054 txtOut = txtOut..txtTmp;
5055  
5056 return txtOut, parsedLines;
5057 end
5058  
5059  
5060 function NuN_Fragment(txtWhole, fragLen)
5061 local p1 = 0;
5062 local p2 = 0;
5063 local lst = 0;
5064 local txtFrags = "";
5065 local count = 1;
5066  
5067 while ( true ) do
5068 p2 = string.find(txtWhole, " ", ( p1 + 1 ) )
5069 if ( p2 == nil ) then
5070 break
5071 end
5072 if ( p2 > ( lst + fragLen ) ) then
5073 lst = p1;
5074 txtFrags = txtFrags.."\n";
5075 count = count + 1;
5076 end
5077 txtFrags = txtFrags..string.sub(txtWhole, ( p1 + 1 ), p2);
5078 p1 = p2;
5079 end
5080 txtFrags = txtFrags..string.sub(txtWhole, ( p1 + 1 ) );
5081  
5082 return txtFrags, count;
5083 end
5084  
5085  
5086 function NuN_Tooltip_OnUpdate()
5087 if ( ( NuN_Fade == "True" ) and ( not UnitExists("mouseover") ) ) then
5088 local gt = GameTooltipTextLeft1:GetText();
5089 if ( gt ~= gtName ) then
5090 this:Hide();
5091 return;
5092 end
5093 if ( this.fadeStartTime == 0 ) then
5094 this.fadeStartTime = GetTime();
5095 end
5096 local elapsed = GetTime() - this.fadeStartTime;
5097 local fadeHoldTime = this.fadeHoldTime;
5098 local fadeOutTime = this.fadeOutTime;
5099 if ( elapsed >= ( fadeHoldTime + fadeOutTime ) ) then
5100 this:ClearLines();
5101 this:Hide();
5102 elseif ( elapsed > fadeHoldTime ) then
5103 local alpha = 1 - ( ( elapsed - fadeHoldTime ) / fadeOutTime );
5104 this:SetAlpha(alpha);
5105 end
5106 end
5107 end
5108  
5109  
5110 function NuN_FFButton_OnShow()
5111 NuN_FFButton_Up();
5112 end
5113  
5114  
5115 function NuN_FFButton_Down()
5116 if ( pFaction == "Horde" ) then
5117 NuN_FFButton_StateADown:Hide();
5118 NuN_FFButton_StateAUp:Hide();
5119 NuN_FFButton_StateHUp:Hide();
5120 NuN_FFButton_StateHDown:Show();
5121 else
5122 NuN_FFButton_StateHDown:Hide();
5123 NuN_FFButton_StateHUp:Hide();
5124 NuN_FFButton_StateAUp:Hide();
5125 NuN_FFButton_StateADown:Show();
5126 end
5127  
5128 if ( FriendsListFrame:IsVisible() ) then
5129 NuN_ShowFriendNote();
5130 elseif ( IgnoreListFrame:IsVisible() ) then
5131 NuN_ShowIgnoreNote();
5132 elseif ( GuildPlayerStatusFrame:IsVisible() ) then
5133 NuN_ShowGuildNote();
5134 elseif ( GuildStatusFrame:IsVisible() ) then
5135 NuN_ShowGuildNote();
5136 elseif ( WhoFrame:IsVisible() ) then
5137 if ( WhoFrame.selectedName ) then
5138 NuN_ShowWhoNote(WhoFrame.selectedName);
5139 end
5140 elseif ( RaidFrame:IsVisible() ) then
5141 local tstValue = NuN_CheckTarget();
5142 if ( UnitInRaid("target") ) then
5143 c_name = UnitName("target");
5144 if ( NuNData[pKey][c_name] ) then
5145 NuN_ShowSavedNote(c_name);
5146 else
5147 NuN_NewContact("target");
5148 end
5149 end
5150 end
5151 end
5152  
5153 function NuN_FFButton_Up()
5154 if ( pFaction == "Horde" ) then
5155 NuN_FFButton_StateADown:Hide();
5156 NuN_FFButton_StateAUp:Hide();
5157 NuN_FFButton_StateHDown:Hide();
5158 NuN_FFButton_StateHUp:Show();
5159 else
5160 NuN_FFButton_StateHDown:Hide();
5161 NuN_FFButton_StateHUp:Hide();
5162 NuN_FFButton_StateADown:Hide();
5163 NuN_FFButton_StateAUp:Show();
5164 end
5165 end
5166  
5167  
5168  
5169 function NuN_GNoteTitle_OnClick()
5170 NuN_ClearPinnedTT();
5171 NuNGTTCheckBoxLabel:Hide();
5172 NuN_GTTCheckBox:Hide();
5173 NuNGNoteTextBox:SetText( NuNGNoteTitleButtonText:GetText() );
5174 NuNGNoteTitleButton:Hide();
5175 NuNGNoteTextBox:Show();
5176 NuNGNoteTextBox:SetFocus();
5177 end
5178  
5179 function NuN_GNoteTitleSet()
5180 NuNGNoteTitleButtonText:SetText( NuNGNoteTextBox:GetText() );
5181 NuNGNoteTextBox:Hide();
5182 NuNGNoteTitleButton:Show();
5183 end
5184  
5185  
5186 function NuN_GetSimpleName(cmplxName)
5187 local smplName, posB, posE;
5188  
5189 posB = string.find(cmplxName, "|h");
5190 posE = string.find(cmplxName, "]|h");
5191 if ( posB ~= nil ) and ( posE ~= nil ) and ( posB < posE ) then
5192 smplName = string.sub(cmplxName, (posB + 3), (posE - 1));
5193 return smplName
5194 else
5195 return nil;
5196 end
5197 end
5198  
5199  
5200 function NuN_GetLink(cmplxName)
5201 local link, posB, posE;
5202  
5203 posB = string.find(cmplxName, "|Hitem:");
5204 posE = string.find(cmplxName, "|h");
5205 if ( posB ~= nil ) and ( posE ~= nil ) and ( posB < posE ) then
5206 link = string.sub(cmplxName, (posB + 2), (posE - 1));
5207 return link;
5208 else
5209 return nil;
5210 end
5211 end
5212  
5213  
5214 function NuN_GNoteExists(tstNote)
5215 local cmplxName;
5216  
5217 if ( ( NuNData[pKey][Notes][tstNote] ) or ( NuNData[Notes][tstNote] ) ) then
5218 c_note = tstNote;
5219 return true;
5220 elseif ( NuNData[itmIndex][tstNote] ) then
5221 cmplxName = NuNData[itmIndex][tstNote];
5222 if ( ( NuNData[pKey][Notes][cmplxName] ) or ( NuNData[Notes][cmplxName] ) ) then
5223 c_note = cmplxName;
5224 return true;
5225 end
5226 end
5227 c_note = nil;
5228 return false;
5229 end
5230  
5231  
5232 function NuN_DeleteItem(toDelete)
5233 local index;
5234 local value;
5235  
5236 for index, value in NuNData[itmIndex] do
5237 if ( NuNData[itmIndex][index] == toDelete ) then
5238 NuNData[itmIndex][index] = nil;
5239 return;
5240 end
5241 end
5242 end
5243  
5244  
5245  
5246 function NuN_GameTooltip_OnShow()
5247 local storePinned = NuN_PinnedTooltip.type;
5248 local p1 = 1;
5249 local strippedName = "";
5250 local sNLen = 0;
5251 local anchorBy, anchorTo;
5252  
5253 local tx, ty;
5254 tx, ty = GameTooltip:GetCenter();
5255 if ( ( not tx ) or ( not ty ) ) then
5256 noTipAnchor = true;
5257 return;
5258 end
5259  
5260 gtName = GameTooltipTextLeft1:GetText();
5261 if ( not UnitExists("mouseover") ) then
5262 sNLen = string.len(gtName);
5263 for i=sNLen, 1, -1 do
5264 local tstChar = string.sub(gtName, i, i);
5265 if ( tstChar == " " ) then
5266 p1 = i + 1;
5267 break;
5268 end
5269 end
5270 strippedName = string.sub(gtName, p1);
5271 if ( NuNData[pKey][strippedName] ) then
5272 gtName = strippedName;
5273 end
5274 end
5275  
5276 if ( ( UnitExists("mouseover") ) or ( ( RaidFrame:IsVisible() ) and ( MouseIsOver(RaidFrame) ) ) or ( ( TargetFrame:IsVisible() ) and ( MouseIsOver(TargetFrame) ) ) ) then
5277 if ( UnitExists("mouseover") ) then
5278 ttName = UnitName("mouseover");
5279 NuN_Fade = "True";
5280 else
5281 ttName = gtName;
5282 NuN_Fade = "False";
5283 end
5284 if ( ( ttName ~= nil ) and ( ( NuNData[pKey][ttName] ) or ( NuNData[pKey][Notes][ttName] ) or ( NuNData[Notes][ttName] ) ) ) then
5285 anchorBy, anchorTo = NuN_GetTipAnchor(GameTooltip);
5286 NuN_Tooltip:Hide();
5287 NuN_Tooltip:SetOwner(this, "ANCHOR_NONE");
5288 NuN_TT_Y_Offset = 0;
5289 NuN_PinnedTooltip.type = "Nil";
5290 NuN_MouseOver = true;
5291 NuN_BuildTT(NuN_Tooltip);
5292 NuN_MouseOver = false;
5293 NuN_PinnedTooltip.type = storePinned;
5294 NuN_Tooltip:SetPoint(anchorBy, "GameTooltip", anchorTo, -1, 0);
5295 NuN_Tooltip:Show();
5296 else
5297 NuN_Tooltip:ClearLines();
5298 NuN_Tooltip:Hide();
5299 end
5300 else
5301 ttName = gtName;
5302 if ( NuNData[itmIndex][ttName] ) then
5303 ttName = ( NuNData[itmIndex][ttName] );
5304 end
5305 if ( ( ttName ~= nil ) and ( ( NuNData[pKey][ttName] ) or ( NuNData[pKey][Notes][ttName] ) or ( NuNData[Notes][ttName] ) ) ) then
5306 NuN_Fade = "False";
5307 NuN_Tooltip:ClearLines();
5308 NuN_Tooltip:Hide();
5309 NuN_Tooltip:SetOwner(this, "ANCHOR_NONE");
5310 NuN_TT_Y_Offset = 0;
5311 NuN_PinnedTooltip.type = "Nil";
5312 NuN_BuildTT(NuN_Tooltip);
5313 NuN_PinnedTooltip.type = storePinned;
5314 local num1 = ShoppingTooltip1:NumLines();
5315 local num2 = ShoppingTooltip2:NumLines();
5316 if ( num2 and ( num2 > 0 ) and ShoppingTooltip2 and MerchantFrame and ( MerchantFrame:IsVisible() ) and ( MouseIsOver(MerchantFrame) ) ) or ( num2 and ( num2 > 0 ) and ShoppingTooltip2 and AuctionFrame and ( AuctionFrame:IsVisible() ) and ( MouseIsOver(AuctionFrame) ) ) then
5317 anchorBy, anchorTo = NuN_GetTipAnchor(ShoppingTooltip2);
5318 NuN_Tooltip:SetPoint(anchorBy, "ShoppingTooltip2", anchorTo, 0, 0);
5319 elseif ( num1 and ( num1 > 0 ) ) and ( ShoppingTooltip1 and MerchantFrame and ( MerchantFrame:IsVisible() ) and ( MouseIsOver(MerchantFrame) ) ) or ( num1 and ( num1 > 0 ) ) and ( ShoppingTooltip1 and AuctionFrame and ( AuctionFrame:IsVisible() ) and ( MouseIsOver(AuctionFrame) ) ) then
5320 anchorBy, anchorTo = NuN_GetTipAnchor(ShoppingTooltip1);
5321 NuN_Tooltip:SetPoint(anchorBy, "ShoppingTooltip1", anchorTo, 0, 0);
5322 else
5323 anchorBy, anchorTo = NuN_GetTipAnchor(GameTooltip);
5324 NuN_Tooltip:SetPoint(anchorBy, "GameTooltip", anchorTo, 1, 0);
5325 end
5326 NuN_Tooltip:Show();
5327 else
5328 NuN_Tooltip:ClearLines();
5329 NuN_Tooltip:Hide();
5330 end
5331 end
5332 end
5333  
5334  
5335  
5336 function NuN_WorldMapTooltip_OnShow(id)
5337 local noPopup = true;
5338 local MapNoting = true;
5339 local nName = WorldMapTooltipTextLeft1:GetText();
5340  
5341 NuNPopup:Hide();
5342 if ( NuNData[itmIndex][nName] ) then
5343 nName = ( NuNData[itmIndex][nName] );
5344 end
5345  
5346 local MNCont = nil;
5347 local MNZone = nil;
5348 local NuN_Key = nil;
5349 MNCont = GetCurrentMapContinent();
5350 if ( MNCont == -1 ) then
5351 MNCont = GetRealZoneText();
5352 MNZone = 0;
5353 else
5354 if ( MetaMapNotes_OnLoad ) then
5355 MNZone = MetaMapNotes_ZoneShift[MNCont][GetCurrentMapZone()];
5356 elseif ( MapNotes_OnLoad ) then
5357 MNZone = MapNotes_ZoneShift[MNCont][GetCurrentMapZone()];
5358 else
5359 MapNoting = nil;
5360 end
5361 if ( ( MapNoting ) and ( ( not MNZone ) or ( MNZone < 1 ) ) ) then
5362 return;
5363 end
5364 end
5365  
5366 if ( id ) then
5367 NuN_Key = MNCont.."-"..MNZone.."-"..id;
5368 end
5369  
5370 if ( NuN_Key ) then
5371 if ( ( NuNData[mrgIndex] ) and ( NuNData[mrgIndex][NuN_Key] ) ) then
5372 local index, value, lBttn, lHeight;
5373 local lWidth = NuNPopupTitle:GetWidth();
5374 local lCount = 0;
5375 NuNPopupButton1:SetText("");
5376 NuNPopupButton1:Hide();
5377 NuNPopupButton2:SetText("");
5378 NuNPopupButton2:Hide();
5379 NuNPopupButton3:SetText("");
5380 NuNPopupButton3:Hide();
5381 NuNPopupButton4:SetText("");
5382 NuNPopupButton4:Hide();
5383 NuNPopupButton5:SetText("");
5384 NuNPopupButton5:Hide();
5385 for index, value in NuNData[mrgIndex][NuN_Key] do
5386 if ( index ~= "noteCounter" ) then
5387 if ( ( NuNData[Notes][index] ) or ( NuNData[pKey][Notes][index] ) ) then
5388 lCount = lCount + 1;
5389 lBttn = getglobal("NuNPopupButton"..lCount);
5390 lBttn.note = index;
5391 lBttn:SetText(index);
5392 lBttn:Show();
5393 local tWidth = lBttn:GetTextWidth();
5394 if ( ( tWidth ) and ( tWidth > lWidth ) ) then
5395 lWidth = tWidth;
5396 end
5397 end
5398 end
5399 end
5400 if ( lCount > 0 ) then
5401 local lHeight = math.ceil( ((20*(lCount + 1)) + 10) );
5402 lWidth = math.ceil( (lWidth) * 1.15 );
5403 if ( lCount > 2 ) then
5404 lHeight = lHeight - (lCount * lCount);
5405 end
5406 NuNPopup:SetHeight(lHeight);
5407 NuNPopup:SetWidth(lWidth);
5408 NuNPopupButton1:SetWidth(lWidth - 4);
5409 NuNPopupButton2:SetWidth(lWidth - 4);
5410 NuNPopupButton3:SetWidth(lWidth - 4);
5411 NuNPopupButton4:SetWidth(lWidth - 4);
5412 NuNPopupButton5:SetWidth(lWidth - 4);
5413 NuNPopup:ClearAllPoints();
5414 NuNPopup.id = id;
5415 local x, y = GetCursorPosition();
5416 if ( y > 300 ) then
5417 if ( x > 500 ) then
5418 NuNPopup:SetPoint("TOPRIGHT", "WorldMapTooltip", "BOTTOMRIGHT", 0, 0);
5419 NuNPopup.point = "TOPRIGHT";
5420 NuNPopup.relativePoint = "BOTTOMRIGHT";
5421 else
5422 NuNPopup:SetPoint("TOPLEFT", "WorldMapTooltip", "BOTTOMLEFT", 0, 0);
5423 NuNPopup.point = "TOPLEFT";
5424 NuNPopup.relativePoint = "BOTTOMLEFT";
5425 end
5426 else
5427 if ( x > 500 ) then
5428 NuNPopup:SetPoint("BOTTOMRIGHT", "WorldMapTooltip", "TOPRIGHT", 0, 0);
5429 NuNPopup.point = "BOTTOMRIGHT";
5430 NuNPopup.relativePoint = "TOPRIGHT";
5431 else
5432 NuNPopup:SetPoint("BOTTOMLEFT", "WorldMapTooltip", "TOPLEFT", 0, 0);
5433 NuNPopup.point = "BOTTOMLEFT";
5434 NuNPopup.relativePoint = "TOPLEFT";
5435 end
5436 end
5437 NuNPopupTitle:SetTextColor(0.1, 0.9, 0.1, 0.9);
5438 popUpHide = nil;
5439 NuNPopup:SetAlpha(1);
5440 NuNPopup:Show();
5441 NuN_MapTooltipShow(NuNPopupButton1.note, "NuNPopup", NuNPopup.point, NuNPopup.relativePoint);
5442 NuNPopupButton1:LockHighlight();
5443 noPopup = nil;
5444 end
5445 end
5446 end
5447  
5448 if ( noPopup ) then
5449 if ( ( NuNData[pKey][nName] ) or ( NuNData[pKey][Notes][nName] ) or ( NuNData[Notes][nName] ) ) then
5450 NuN_MapTooltipShow(nName, "WorldMapTooltip", nil, nil);
5451 end
5452 end
5453 end
5454  
5455  
5456 function NuN_MapTooltipShow(nName, relativeTo, point, relativePoint)
5457 local storePinned = NuN_PinnedTooltip.type;
5458  
5459 NuNPopupButton1:UnlockHighlight();
5460 if ( not nName ) then
5461 return;
5462 end
5463 gtName = nName;
5464 ttName = gtName;
5465 if ( ( ttName ~= nil ) and ( ( NuNData[pKey][ttName] ) or ( NuNData[pKey][Notes][ttName] ) or ( NuNData[Notes][ttName] ) ) ) then
5466 NuN_Fade = "False";
5467 NuN_MapTooltip:ClearLines();
5468 NuN_MapTooltip:Hide();
5469 NuN_MapTooltip:SetOwner(this, "ANCHOR_NONE");
5470 NuN_PinnedTooltip.type = "Nil";
5471 NuN_BuildTT(NuN_MapTooltip);
5472 NuN_PinnedTooltip.type = storePinned;
5473 if ( ( point ) and ( relativePoint ) ) then
5474 NuN_MapTooltip:SetPoint(point, relativeTo, relativePoint, 0, 0);
5475 else
5476 local x, y = GetCursorPosition();
5477 if ( y > 300 ) then
5478 if ( x > 500 ) then
5479 NuN_MapTooltip:SetPoint("TOPRIGHT", "WorldMapTooltip", "BOTTOMRIGHT", 0, 0);
5480 else
5481 NuN_MapTooltip:SetPoint("TOPLEFT", "WorldMapTooltip", "BOTTOMLEFT", 0, 0);
5482 end
5483 else
5484 if ( x > 500 ) then
5485 NuN_MapTooltip:SetPoint("BOTTOMRIGHT", "WorldMapTooltip", "TOPRIGHT", 0, 0);
5486 else
5487 NuN_MapTooltip:SetPoint("BOTTOMLEFT", "WorldMapTooltip", "TOPLEFT", 0, 0);
5488 end
5489 end
5490 end
5491 NuN_MapTooltip:SetFrameLevel( WorldMapTooltip:GetFrameLevel() );
5492 NuN_MapTooltip:Show();
5493 else
5494 NuN_MapTooltip:ClearLines();
5495 NuN_MapTooltip:Hide();
5496 end
5497 end
5498  
5499  
5500 function NuN_WorldMapTooltip_OnHide()
5501 NuNPopup:Hide();
5502 NuN_MapTooltip:ClearLines();
5503 NuN_MapTooltip:Hide();
5504 end
5505  
5506  
5507  
5508  
5509  
5510 function NuN_ItemRefTooltip_OnShow()
5511 gtName = ItemRefTooltipTextLeft1:GetText();
5512 ttName = gtName;
5513  
5514 if ( NuNData[itmIndex][ttName] ) then
5515 ttName = ( NuNData[itmIndex][ttName] );
5516 end
5517 if ( ( ttName ~= nil ) and ( ( NuNData[pKey][Notes][ttName] ) or ( NuNData[Notes][ttName] ) ) ) then
5518 NuN_Fade = "False";
5519 NuN_ClearPinnedTT();
5520 NuN_PinnedTooltip:SetOwner(ItemRefTooltip, "ANCHOR_TOPLEFT");
5521 NuN_PinUpHeader = true;
5522 NuN_PinnedTooltip.type = "General";
5523 NuN_BuildTT(NuN_PinnedTooltip);
5524 NuN_PinUpHeader = false;
5525 NuN_PinnedTooltip:Show();
5526 pinnedTTMoved = false;
5527 elseif ( not pinnedTTMoved ) then
5528 NuN_ClearPinnedTT();
5529 end
5530 end
5531  
5532  
5533 function NuN_ItemRefTooltip_OnHide()
5534 if ( not pinnedTTMoved ) then
5535 NuN_ClearPinnedTT();
5536 pinnedTTMoved = true;
5537 end
5538 end
5539  
5540  
5541 function NuN_FlagMoved()
5542 pinnedTTMoved = true;
5543 end
5544  
5545  
5546 function NuN_GameTooltip_OnHide()
5547 noTipAnchor = nil;
5548 if ( NuN_Fade == "False" ) then
5549 NuN_Tooltip:ClearLines();
5550 NuN_Tooltip:Hide();
5551 end
5552 end
5553  
5554  
5555 function NuN_TTCheckBox_OnClick(frameType)
5556 if ( frameType == "Contact" ) then
5557 if ( NuN_CTTCheckBox:GetChecked() ) then
5558 ttName = c_name;
5559 NuN_ClearPinnedTT();
5560 NuN_PinnedTooltip:SetOwner(this, ANCHOR_BOTTOMRIGHT);
5561 NuN_PinUpHeader = true;
5562 NuN_PinnedTooltip.type = frameType;
5563 NuN_BuildTT(NuN_PinnedTooltip);
5564 NuN_PinUpHeader = false;
5565 NuN_PinnedTooltip:Show();
5566 else
5567 NuN_ClearPinnedTT();
5568 end
5569 elseif ( frameType == "General" ) then
5570 if ( NuN_GTTCheckBox:GetChecked() ) then
5571 ttName = c_note;
5572 NuN_ClearPinnedTT();
5573 NuN_PinnedTooltip:SetOwner(this, ANCHOR_BOTTOMRIGHT);
5574 NuN_PinUpHeader = true;
5575 NuN_PinnedTooltip.type = frameType;
5576 NuN_BuildTT(NuN_PinnedTooltip);
5577 NuN_PinUpHeader = false;
5578 NuN_PinnedTooltip:Show();
5579 else
5580 NuN_ClearPinnedTT();
5581 end
5582 end
5583 end
5584  
5585 function NuN_TTCheckBox_OnEnter()
5586 if ( NuNSettings[pKey].toolTips ) then
5587 NuN_Fade = "False";
5588 local x, y = GetCursorPosition();
5589 if ( x > 500 ) then
5590 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
5591 else
5592 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
5593 end
5594 NuN_Tooltip:ClearLines();
5595 NuN_Tooltip:AddLine(NUN_TT_PIN_TOOLTIP_TXT1, 1, 0.7, 0);
5596 NuN_Tooltip:AddLine(NUN_TT_PIN_TOOLTIP_TXT2, 0, 1, 0);
5597 NuN_Tooltip:AddLine(NUN_TT_PIN_TOOLTIP_TXT3, 0, 1, 0);
5598 NuN_Tooltip:Show();
5599 end
5600 end
5601  
5602  
5603 function NuN_ClearPinnedTT()
5604 if ( NuN_PinnedTooltip:IsVisible() ) then
5605 NuN_PinnedTooltip:ClearLines();
5606 NuN_PinnedTooltip:Hide();
5607 end
5608 end
5609  
5610  
5611 function NuN_CheckPinnedBox(tst)
5612 if ( NuN_PinnedTooltip:IsVisible() ) then
5613 if ( tst == lastPinned ) then
5614 return 1;
5615 else
5616 return 0;
5617 end
5618 else
5619 return 0;
5620 end
5621 end
5622  
5623  
5624  
5625 function NuN_PinnedTT_OnClick()
5626 local ttTitle = NuN_PinnedTooltipTextLeft2:GetText();
5627  
5628 if ( NuN_PinnedTooltip.type == "Contact" ) then
5629 if ( NuNData[pKey][ttTitle] ) then
5630 NuN_ShowSavedNote(ttTitle);
5631 end
5632 elseif ( NuN_PinnedTooltip.type == "General" ) then
5633 if ( NuNData[itmIndex][ttTitle] ) then
5634 ttTitle = NuNData[itmIndex][ttTitle];
5635 end
5636 if ( ( NuNData[pKey][Notes][ttTitle] ) or ( NuNData[Notes][ttTitle] ) ) then
5637 c_note = ttTitle;
5638 NuNGNoteFrame.fromQuest = nil;
5639 NuN_ShowSavedGNote();
5640 end
5641 end
5642 end
5643  
5644  
5645 function NuN_PinnedTT_OnHide()
5646 if ( NuN_PinnedTooltip.type == "Contact" ) then
5647 if ( ( NuNFrame:IsVisible() ) and ( NuN_CTTCheckBox:GetChecked() ) ) then
5648 NuN_CTTCheckBox:SetChecked(0);
5649 end
5650 elseif ( NuN_PinnedTooltip.type == "General" ) then
5651 if ( ( NuNGNoteFrame:IsVisible() ) and ( NuN_GTTCheckBox:GetChecked() ) ) then
5652 NuN_GTTCheckBox:SetChecked(0);
5653 end
5654 end
5655 end
5656  
5657  
5658 function NuN_OpenChat(noteType)
5659 local dspText, dspTextL;
5660 local hdrMax = 29;
5661  
5662 UIDropDownMenu_ClearAll(NuNChatDropDown);
5663 NuNTransmit:Disable();
5664 NuNChatTextBox:Hide();
5665 NuN_ChatFrame.type = noteType;
5666 if ( noteType == "Contact" ) then
5667 dspText = c_name;
5668 NuN_ChatCheckBox:Show();
5669 elseif ( noteType == "General" ) then
5670 dspText = c_note;
5671 NuN_ChatCheckBox:Hide();
5672 end
5673 if ( string.find(dspText, "|Hitem:") ) then
5674 hdrMax = hdrMax + 50;
5675 end
5676 dspTextL = string.len(dspText);
5677 if ( dspTextL > hdrMax ) then
5678 dspText = string.sub(dspText, 1, hdrMax).."...";
5679 end
5680 NuNChatNoteTitle:SetText(dspText);
5681 ShowUIPanel(NuN_ChatFrame);
5682  
5683 end
5684  
5685  
5686 function NuN_Transmit()
5687 local dfltLang;
5688 local user = nil;
5689 local error = nil;
5690 local singleLine;
5691 local parsedArray = {};
5692 local contents = nil;
5693 local linesInError = {};
5694 local nonCriticalError = false;
5695 local e = 0;
5696 local tLog = "Transmit Log ";
5697 local chatTarget;
5698 local prfx;
5699 local logText = "";
5700 local saveLvl;
5701  
5702 NuNTransmit:Disable();
5703  
5704 msgSeq = msgSeq + 1;
5705 if ( msgSeq > 9 ) then
5706 msgSeq = 1;
5707 end
5708 msgKey = pName..msgSeq..":";
5709 tLog = tLog..msgKey;
5710  
5711 if ( NuNSettings[pKey].dLevel ) then
5712 NuNData[Notes][tLog] = {};
5713 logText = NuN_GetDateStamp().."\n";
5714 NuNData[Notes][tLog].type = 3;
5715 saveLvl = "Account";
5716 else
5717 NuNData[pKey][Notes][tLog] = {};
5718 logText = NuN_GetDateStamp().."\n";
5719 NuNData[pKey][Notes][tLog].type = 3;
5720 saveLvl = "Realm";
5721 end
5722  
5723 if ( NuNChatTextBox:IsVisible() ) then
5724 user = NuNChatTextBox:GetText();
5725 end
5726  
5727 if ( sendTo == "WHISPER" ) or ( sendTo == "NuN" ) then
5728 chatTarget = user;
5729 else
5730 chatTarget = sendTo;
5731 end
5732  
5733 if ( horde ) then
5734 dfltLang = "Orcish";
5735 else
5736 dfltLang = "Common";
5737 end
5738  
5739 prfx = msgKey..NUN_TRANSMISSION_PREFIX1..pName.." ---> "..chatTarget;
5740 logText = logText.."\n"..prfx;
5741  
5742 if ( NuN_ChatFrame.type == "Contact" ) then
5743 parsedArray, error = NuN_TransmitContact(dfltLang, user);
5744 else
5745 parsedArray, error = NuN_TransmitGeneral(dfltLang, user);
5746 end
5747  
5748 if ( parsedArray ) then
5749 local tmp_c_note = c_note;
5750 local tmp_g_text = g_text;
5751 contents = getn(parsedArray);
5752 local lineCount = 0;
5753 local flagged = nil;
5754 for i=1, contents, 1 do
5755 singleLine = parsedArray[i];
5756 singleLine = string.gsub(singleLine, "\n", " ");
5757 singleLine = string.gsub(singleLine, "\\n", " ");
5758 if ( string.len(singleLine) > 255 ) then
5759 error = "Err02";
5760 break;
5761 end
5762 local beginnings = NuN_Validate(singleLine, "|c");
5763 local endings = NuN_Validate(singleLine, "|h|r");
5764 if ( beginnings == endings ) then
5765 parsedArray[i] = singleLine;
5766 lineCount = lineCount + 1;
5767 if ( ( string.len(logText) < (NUN_MAX_TXT_LIM - 360) ) and ( lineCount < 109 ) ) then
5768 logText = logText.."\n"..singleLine;
5769 elseif ( not flagged ) then
5770 flagged = true;
5771 logText = logText.."\n"..NUN_NOROOM;
5772 end
5773 else
5774 parsedArray[i] = "";
5775 nonCriticalError = true;
5776 e = e + 1;
5777 linesInError[e] = NUN_LINEERROR_TEXT.."----->"..i.." : \n";
5778 e = e + 1;
5779 linesInError[e] = singleLine.."\n";
5780 end
5781 end
5782 c_note = tLog;
5783 g_text = logText;
5784 NuN_SetGText(saveLvl);
5785 c_note = tmp_c_note;
5786 g_text = tmp_g_text;
5787 end
5788  
5789 if ( contents ) and ( not error ) then
5790 if ( sendTo == "SELF" ) then
5791 DEFAULT_CHAT_FRAME:AddMessage(prfx);
5792 else
5793 SendChatMessage(prfx, sendTo, dfltLang, user);
5794 end
5795 for i=1, contents, 1 do
5796 if ( sendTo == "SELF" ) then
5797 DEFAULT_CHAT_FRAME:AddMessage(msgKey..parsedArray[i]);
5798 else
5799 SendChatMessage(msgKey..parsedArray[i], sendTo, dfltLang, user);
5800 end
5801 end
5802 elseif ( error ) then
5803 NuN_Message(NUN_TRANSMISSION_ERROR..error);
5804 else
5805 NuN_Message(NUN_TRANSMISSION_MISSING);
5806 end
5807  
5808 if ( nonCriticalError ) then
5809 if ( NuNSettings[pKey].dLevel ) then
5810 NuNData[Notes][msgKey] = {};
5811 NuNData[Notes][msgKey].txt = "";
5812 else
5813 NuNData[pKey][Notes][msgKey] = {};
5814 NuNData[pKey][Notes][msgKey].txt = "";
5815 end
5816 for i=1, getn(linesInError), 1 do
5817 if ( NuNSettings[pKey].dLevel ) then
5818 NuNData[Notes][msgKey].txt = NuNData[Notes][msgKey].txt..linesInError[i].."\n";
5819 else
5820 NuNData[pKey][Notes][msgKey].txt = NuNData[pKey][Notes][msgKey].txt..linesInError[i].."\n";
5821 end
5822 end
5823 NuN_Message(NUN_NONCRITICAL_ERROR..msgKey);
5824 end
5825  
5826 NuNTransmit:Enable();
5827 end
5828  
5829  
5830  
5831 function NuN_TransmitContact(dfltLang, user)
5832 local parsedArray = {};
5833 local singleLine = "";
5834  
5835  
5836 if ( NuNData[pKey][c_name] ) then
5837 local parsedArray = {};
5838 local singleLine = "";
5839 local arrayCounter = 1;
5840 local parseText = "";
5841 local txtArray = {};
5842  
5843 parsedArray[arrayCounter] = NUN_TRANSMISSION_PREFIX2.."Contact : "..c_name;
5844  
5845 if ( not NuN_ChatCheckBox:GetChecked() ) then
5846 singleLine = NuNData[pKey][c_name].faction.." ";
5847 if ( NuNData[pKey][c_name].race ) then
5848 if ( horde ) then
5849 singleLine = singleLine..HRaces[NuNData[pKey][c_name].race].." ";
5850 else
5851 singleLine = singleLine..ARaces[NuNData[pKey][c_name].race].." ";
5852 end
5853 end
5854 if ( NuNData[pKey][c_name].cls ) then
5855 if ( horde ) then
5856 singleLine = singleLine..HClasses[NuNData[pKey][c_name].cls].." ";
5857 else
5858 singleLine = singleLine..AClasses[NuNData[pKey][c_name].cls].." ";
5859 end
5860 end
5861 if ( NuNData[pKey][c_name].sex ) then
5862 singleLine = singleLine..Sexes[NuNData[pKey][c_name].sex].." ";
5863 end
5864 if ( NuNData[pKey][c_name].prof1 ) then
5865 singleLine = singleLine..Professions[NuNData[pKey][c_name].prof1].." ";
5866 end
5867 if ( NuNData[pKey][c_name].prof2 ) then
5868 singleLine = singleLine..Professions[NuNData[pKey][c_name].prof2].." ";
5869 end
5870 if ( NuNData[pKey][c_name].crank ) then
5871 if ( horde ) then
5872 singleLine = singleLine..HRanks[NuNData[pKey][c_name].crank].." ";
5873 else
5874 singleLine = singleLine..ARanks[NuNData[pKey][c_name].crank].." ";
5875 end
5876 end
5877 if ( NuNData[pKey][c_name].hrank ) then
5878 if ( horde ) then
5879 singleLine = singleLine..HRanks[NuNData[pKey][c_name].hrank].." ";
5880 else
5881 singleLine = singleLine..ARanks[NuNData[pKey][c_name].hrank].." ";
5882 end
5883 end
5884  
5885 if ( singleLine ~= "" ) then
5886 singleLine = "G:"..singleLine;
5887 arrayCounter = arrayCounter + 1;
5888 parsedArray[arrayCounter] = singleLine;
5889 end
5890  
5891 for n = 1, uBttns, 1 do
5892 singleLine = "";
5893 hdNbr = pHead..n;
5894 nameHdNbr = c_name..hdNbr;
5895 nameDtNbr = c_name..pDetl..n;
5896 if ( NuNData[pKey][nameHdNbr] ) then
5897 singleLine = NuNData[pKey][nameHdNbr].txt.."~ ";
5898 elseif ( NuNSettings[pKey][hdNbr] ) then
5899 singleLine = NuNSettings[pKey][hdNbr].txt.."~ ";
5900 else
5901 singleLine = dfltHeadings[n].."~ ";
5902 end
5903 if ( NuNData[pKey][nameDtNbr] ) then
5904 singleLine = singleLine.."~"..NuNData[pKey][nameDtNbr].txt;
5905 end
5906 if ( singleLine ~= "" ) then
5907 arrayCounter = arrayCounter + 1;
5908 singleLine = "U"..n..":"..singleLine;
5909 parsedArray[arrayCounter] = singleLine;
5910 end
5911 end
5912 end
5913  
5914 -- parseText = NuN_GetCText(c_name);
5915 parseText = NuNText:GetText();
5916 txtArray = NuN_ParseNote(parseText);
5917 if ( txtArray ) then
5918 for i=1, getn(txtArray), 1 do
5919 arrayCounter = arrayCounter + 1;
5920 parsedArray[arrayCounter] = "T:"..txtArray[i];
5921 end
5922 end
5923  
5924 arrayCounter = arrayCounter + 1;
5925 parsedArray[arrayCounter] = NUN_TRANSMISSION_POSTFIX.."Contact : "..c_name;
5926  
5927 return parsedArray, nil;
5928 else
5929 return nil, "Err01";
5930 end
5931 end
5932  
5933  
5934  
5935 function NuN_TransmitGeneral(dfltLang, user)
5936 local ref = c_note;
5937  
5938 if ( NuNData[itmIndex][ref] ) then
5939 ref = NuNData[itmIndex][ref];
5940 end
5941  
5942 if ( ( NuNData[pKey][Notes][ref] ) or ( NuNData[Notes][ref] ) ) then
5943 local parsedArray = {};
5944 local singleLine = "";
5945 local arrayCounter = 1;
5946 local parseText = "";
5947 local txtArray = {};
5948  
5949 parsedArray[arrayCounter] = NUN_TRANSMISSION_PREFIX2.."General : "..c_note;
5950  
5951 -- parseText = NuN_GetGText(c_note);
5952 parseText = NuNGNoteTextScroll:GetText();
5953 txtArray = NuN_ParseNote(parseText);
5954 if ( txtArray ) then
5955 for i=1, getn(txtArray), 1 do
5956 arrayCounter = arrayCounter + 1;
5957 parsedArray[arrayCounter] = "T:"..txtArray[i];
5958 end
5959 end
5960  
5961 arrayCounter = arrayCounter + 1;
5962 parsedArray[arrayCounter] = NUN_TRANSMISSION_POSTFIX.."General : "..c_note;
5963  
5964 return parsedArray, nil;
5965 else
5966 return nil, "Err01";
5967 end
5968 end
5969  
5970  
5971  
5972 function NuN_ParseNote(parseText)
5973 local parsedArray = {};
5974 local arrayCounter = 0;
5975 local p1 = 0;
5976 local p2 = 0;
5977 local txtTmp = "";
5978  
5979 parseText = NuN_RemoveColours(parseText);
5980 parseText = NuN_CheckHyperlinkPositions(parseText);
5981  
5982 local parseTextLen = string.len(parseText);
5983 local negOffset = -1 * (parseTextLen);
5984  
5985 while ( negOffset < 0 ) do
5986 p2 = string.find(parseText, "\n", (p1+1) );
5987 if ( ( p2 == nil ) or ( p2 > ( NUN_CHAT_LIMIT + p1 ) ) ) then
5988 negOffset = p1 + NUN_CHAT_LIMIT - parseTextLen;
5989 if ( negOffset < 0 ) then
5990 p2 = string.find(parseText, " ", negOffset);
5991 if ( ( p2 == nil ) or ( p2 <= p1 ) ) then
5992 txtTmp = string.sub(parseText, (p1+1), (p1+NUN_CHAT_LIMIT));
5993 else
5994 txtTmp = string.sub(parseText, (p1+1), p2);
5995 end
5996 else
5997 txtTmp = string.sub(parseText, (p1+1));
5998 end
5999 else
6000 txtTmp = string.sub(parseText, (p1+1), p2);
6001 end
6002 if ( p2 ) then
6003 p1 = p2;
6004 else
6005 p1 = parseTextLen;
6006 end
6007 if ( txtTmp ~= "" ) and ( txtTmp ~= " " ) then
6008 arrayCounter = arrayCounter + 1;
6009 parsedArray[arrayCounter] = txtTmp;
6010 end
6011 end
6012  
6013 return parsedArray;
6014 end
6015  
6016  
6017 function NuN_RemoveColours(colouredText)
6018 local gp1 = 0;
6019 local gp2a = 0;
6020 local gp2b = 0;
6021 local gp3 = 0;
6022 local plainText="";
6023 local malformed = false;
6024 local postfix = "";
6025  
6026 while ( true ) do
6027 gp2a = string.find(colouredText, "|c", (gp1+1));
6028 if ( gp2a == nil ) then
6029 break;
6030 else
6031 if ( gp2a ~= (gp1+1) ) then
6032 plainText = plainText..string.sub(colouredText, (gp1+1), (gp2a-1));
6033 end
6034 gp2b = string.find(colouredText, "|Hitem:", (gp1+1));
6035 gp3 = string.find(colouredText, "|h|r", gp2a);
6036 if ( gp3 == nil ) then
6037 malformed = true;
6038 break;
6039 end
6040 if ( gp2b == nil ) or ( gp2b > gp3 ) then
6041 plainText = plainText..string.sub(colouredText, (gp2a+12), (gp3-1));
6042 elseif ( (gp2b-gp2a) == 10 ) then
6043 plainText = plainText..string.sub(colouredText, gp2a, (gp3+3));
6044 else
6045 malformed = true;
6046 break;
6047 end
6048 gp1 = gp3 + 3;
6049 end
6050 end
6051 if ( not malformed ) then
6052 postfix = string.sub(colouredText, (gp1+1));
6053 if ( postfix ) then
6054 plainText = plainText..postfix;
6055 end
6056 else
6057 plainText = "";
6058 NuN_Message(NUN_COLOUR_ERROR_REPORT);
6059 end
6060  
6061 return plainText;
6062 end
6063  
6064  
6065 function NuN_Validate(txt, tst)
6066 local p1 = 0;
6067 local p2 = 0;
6068 local count = 0;
6069  
6070 while ( true ) do
6071 p2 = string.find(txt, tst, (p1+1));
6072 if ( p2 == nil ) then
6073 break;
6074 else
6075 count = count + 1;
6076 p1 = p2;
6077 end
6078 end
6079  
6080 return count;
6081 end
6082  
6083  
6084 function NuN_ChatCheckBox_OnEnter()
6085 if ( NuNSettings[pKey].toolTips ) then
6086 NuN_Fade = "False";
6087 local x, y = GetCursorPosition();
6088 if ( x > 500 ) then
6089 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
6090 else
6091 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
6092 end
6093 NuN_Tooltip:ClearLines();
6094 NuN_Tooltip:AddLine(NUN_TT_CHATCHECK_TXT1, 1, 0.7, 0);
6095 NuN_Tooltip:AddLine(NUN_TT_CHATCHECK_TXT2, 0, 1, 0);
6096 NuN_Tooltip:AddLine(NUN_TT_CHATCHECK_TXT3, 0, 1, 0);
6097 NuN_Tooltip:Show();
6098 end
6099 end
6100  
6101  
6102  
6103 function NuN_CheckHyperlinkPositions(theText)
6104 local hypBegs = {};
6105 local p1 = 0;
6106 local p2 = 0;
6107 local counter = 0;
6108 local Begs = 0;
6109 local rtrnText = "";
6110  
6111 while ( true ) do
6112 p2 = string.find(theText, "|Hitem:", (p1+1) );
6113 if ( p2 == nil ) then
6114 break;
6115 else
6116 counter = counter + 1;
6117 hypBegs[counter] = p2 - 10;
6118 p1 = p2;
6119 end
6120 end
6121  
6122 if ( hypBegs ) then
6123 local base = 1;
6124 local preText = "";
6125 local len = 0;
6126 for i=1, getn(hypBegs), 1 do
6127 preText = string.sub(theText, base, (hypBegs[i] - 1));
6128 len = string.len(preText);
6129 local p3 = 0;
6130 local p4 = 0;
6131 p2 = nil;
6132 while ( true ) do
6133 p4 = string.find(preText, "\n", (p3+1));
6134 if ( p4 == nil ) then
6135 break;
6136 else
6137 p2 = p4;
6138 p3 = p4;
6139 end
6140 end
6141 if ( p2 == nil ) and ( len > 120 ) then
6142 rtrnText = rtrnText..preText.."\n";
6143 base = base + len;
6144 elseif ( p2 ) and ( (len - p2) > 120 ) then
6145 rtrnText = rtrnText..preText.."\n";
6146 base = base + len;
6147 elseif ( p2 ) then
6148 rtrnText = rtrnText..string.sub(theText, base, (base + p2));
6149 base = base + p2 + 1;
6150 end
6151 end
6152 rtrnText = rtrnText..string.sub(theText, base);
6153 end
6154  
6155 return rtrnText;
6156 end
6157  
6158  
6159  
6160 function NuN_Level_CheckBox_OnEnter()
6161 if ( NuNSettings[pKey].toolTips ) then
6162 NuN_Fade = "False";
6163 local x, y = GetCursorPosition();
6164 if ( x > 500 ) then
6165 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
6166 else
6167 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
6168 end
6169 NuN_Tooltip:ClearLines();
6170 NuN_Tooltip:AddLine(NUN_TT_LEVEL_TXT1, 1, 0.7, 0);
6171 NuN_Tooltip:AddLine(NUN_TT_LEVEL_TXT2, 0, 1, 0);
6172 NuN_Tooltip:AddLine(NUN_TT_LEVEL_TXT3, 0, 1, 0);
6173 NuN_Tooltip:Show();
6174 end
6175 end
6176  
6177  
6178  
6179 function NuNGTypeDropDown_OnEnter()
6180 if ( NuNSettings[pKey].toolTips ) then
6181 NuN_Fade = "False";
6182 local x, y = GetCursorPosition();
6183 if ( x > 500 ) then
6184 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
6185 else
6186 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
6187 end
6188 NuN_Tooltip:ClearLines();
6189 NuN_Tooltip:AddLine(NUN_TT_GTYPE_TXT1, 1, 0.7, 0);
6190 NuN_Tooltip:AddLine(NUN_TT_GTYPE_TXT2, 0, 1, 0);
6191 NuN_Tooltip:AddLine(NUN_TT_GTYPE_TXT3, 0, 1, 0);
6192 NuN_Tooltip:Show();
6193 end
6194 end
6195  
6196  
6197  
6198 function NuNScaleFrameButton_OnEnter()
6199 if ( NuNSettings[pKey].toolTips ) then
6200 NuN_Fade = "False";
6201 local x, y = GetCursorPosition();
6202 if ( x > 500 ) then
6203 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
6204 else
6205 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
6206 end
6207 NuN_Tooltip:ClearLines();
6208 NuN_Tooltip:AddLine(NUN_TT_SCALE_TXT1, 1, 0.7, 0);
6209 NuN_Tooltip:AddLine(NUN_TT_SCALE_TXT2, 0, 1, 0);
6210 NuN_Tooltip:AddLine(NUN_TT_SCALE_TXT3, 0, 1, 0);
6211 NuN_Tooltip:Show();
6212 end
6213 end
6214  
6215  
6216  
6217 function NuN_NPCTarget()
6218 local chkName = UnitName("target");
6219 local npcText = "";
6220  
6221 if ( ( chkName ) and ( not UnitPlayerControlled("target") ) ) then
6222 npcText = NuN_NPCInfo();
6223 NuNGNoteTextScroll:SetText( NuNGNoteTextScroll:GetText().."\n"..npcText );
6224 end
6225 end
6226  
6227  
6228 function NuNScaleFrameShow()
6229 if ( NuN_ScaleFrame:IsVisible() ) then
6230 HideUIPanel(NuN_ScaleFrame);
6231 else
6232 ShowUIPanel(NuN_ScaleFrame);
6233 end
6234 end
6235  
6236  
6237 function NuNFrameScaleSlider_OnShow()
6238 local pScale = NuNSettings[pKey].pScale;
6239  
6240 NuNFrameScaleSliderCurrent:SetText( string.format("%d", (pScale * 100)) .. "%");
6241 this:SetMinMaxValues(NUN_FRAMESCALE_MIN, NUN_FRAMESCALE_MAX);
6242 this:SetValueStep(NUN_FRAMESCALE_STEP);
6243 this:SetValue(NUN_FRAMESCALE_MIN + NUN_FRAMESCALE_MAX - pScale);
6244 this.previousValue = this:GetValue();
6245 end
6246  
6247  
6248 function NuNFrameScaleSlider_OnValueChanged()
6249 local pScale;
6250  
6251 if (this:GetValue() ~= this.previousValue) then
6252 this.previousValue = this:GetValue();
6253 pScale = (NUN_FRAMESCALE_MIN + NUN_FRAMESCALE_MAX - this:GetValue());
6254 NuNSettings[pKey].pScale = pScale;
6255 NuNFrameScaleSliderCurrent:SetText( string.format("%d", (pScale * 100)) .. "%");
6256 if ( NuNOptionsFrame:IsVisible() ) then
6257 NuNOptionsFrame:SetScale(NuNSettings[pKey].pScale);
6258 end
6259 if ( NuNFrame:IsVisible() ) then
6260 NuNFrame:SetScale(NuNSettings[pKey].pScale);
6261 end
6262 if ( NuNGNoteFrame:IsVisible() ) then
6263 NuNGNoteFrame:SetScale(NuNSettings[pKey].pScale);
6264 end
6265 if ( NuNSearchFrame:IsVisible() ) then
6266 NuNSearchFrame:SetScale(NuNSettings[pKey].pScale);
6267 end
6268 end
6269 end
6270  
6271  
6272 function NuNFontScaleSlider_OnShow()
6273 local tScale = NuNSettings[pKey].tScale;
6274  
6275 NuNFontScaleSliderCurrent:SetText( string.format("%d", (tScale * 100)) .. "%");
6276 this:SetMinMaxValues(NUN_TT_FONTSCALE_MIN, NUN_TT_FONTSCALE_MAX);
6277 this:SetValueStep(NUN_FONTSCALE_STEP);
6278 this:SetValue(NUN_TT_FONTSCALE_MIN + NUN_TT_FONTSCALE_MAX - tScale);
6279 this.previousValue = this:GetValue();
6280 end
6281  
6282  
6283 function NuNFontScaleSlider_OnValueChanged()
6284 local tScale;
6285  
6286 if (this:GetValue() ~= this.previousValue) then
6287 this.previousValue = this:GetValue();
6288 tScale = (NUN_TT_FONTSCALE_MIN + NUN_TT_FONTSCALE_MAX - this:GetValue());
6289 NuNSettings[pKey].tScale = tScale;
6290 NuNFontScaleSliderCurrent:SetText( string.format("%d", (tScale * 100)) .. "%");
6291 NuN_PinnedTooltip:SetScale(NuNSettings[pKey].tScale);
6292 NuN_Tooltip:SetScale(NuNSettings[pKey].tScale);
6293 end
6294 end
6295  
6296  
6297 function NuNMapFontScaleSlider_OnShow()
6298 local mScale = NuNSettings[pKey].mScale;
6299  
6300 NuNMapFontScaleSliderCurrent:SetText( string.format("%d", (mScale * 100)) .. "%");
6301 this:SetMinMaxValues(NUN_TT_MAPFONTSCALE_MIN, NUN_TT_MAPFONTSCALE_MAX);
6302 this:SetValueStep(NUN_MAPFONTSCALE_STEP);
6303 this:SetValue(NUN_TT_MAPFONTSCALE_MIN + NUN_TT_MAPFONTSCALE_MAX - mScale);
6304 this.previousValue = this:GetValue();
6305 end
6306  
6307  
6308 function NuNMapFontScaleSlider_OnValueChanged()
6309 local mScale;
6310  
6311 if (this:GetValue() ~= this.previousValue) then
6312 this.previousValue = this:GetValue();
6313 mScale = (NUN_TT_MAPFONTSCALE_MIN + NUN_TT_MAPFONTSCALE_MAX - this:GetValue());
6314 NuNSettings[pKey].mScale = mScale;
6315 NuNMapFontScaleSliderCurrent:SetText( string.format("%d", (mScale * 100)) .. "%");
6316 mScale = UIParent:GetScale() * NuNSettings[pKey].mScale;
6317 WorldMapTooltip:SetScale(NuNSettings[pKey].mScale);
6318 NuN_MapTooltip:SetScale(NuNSettings[pKey].mScale);
6319 NuNPopup:SetScale(NuNSettings[pKey].mScale);
6320 end
6321 end
6322  
6323  
6324  
6325 function NuN_BuildQuestText()
6326 local numQuestRewards, numQuestChoices, numQuestSpellRewards;
6327 local QuestRewardMoney, QuestRequiredMoney;
6328 local qText = "\n";
6329 local obj, objTxt, objType, itm, itmTxt;
6330 local gold, silver, copper, moneyTxt;
6331 local tmpQText1 = "";
6332 local tmpQText2 = "";
6333 local questItem = "QuestLogItem";
6334 local error = false;
6335  
6336 numQuestRewards = GetNumQuestLogRewards();
6337 numQuestChoices = GetNumQuestLogChoices();
6338 if ( GetQuestLogRewardSpell() ) then
6339 numQuestSpellRewards = 1;
6340 end
6341 QuestRewardMoney = GetQuestLogRewardMoney();
6342 QuestRequiredMoney = GetQuestLogRequiredMoney();
6343  
6344 tmpQText1, tmpQText2 = GetQuestLogQuestText();
6345 qText = tmpQText2.."\n\n";
6346  
6347 if ( GetQuestLogTimeLeft() ) then
6348 qText = qText.."\nTimed Quest\n";
6349 end
6350  
6351 if ( QuestRequiredMoney ) and ( QuestRequiredMoney > 0 ) then
6352 if ( QuestRequiredMoney > 9999 ) then
6353 gold = ( QuestRequiredMoney / 10000 );
6354 gold = string.format("%d", gold);
6355 QuestRequiredMoney = QuestRequiredMoney - ( gold * 10000 );
6356 else
6357 gold = 0;
6358 end
6359 if ( QuestRequiredMoney > 99 ) then
6360 silver = ( QuestRequiredMoney / 100 );
6361 silver = string.format("%d", silver);
6362 QuestRequiredMoney = QuestRequiredMoney - ( silver * 100 );
6363 else
6364 silver = 0;
6365 end
6366 copper = QuestRequiredMoney;
6367 QuestRequiredMoneyTxt = string.format("\n%dg %ds %dc", gold, silver, copper);
6368 qText = qText..QuestRequiredMoneyTxt.."\n\n";
6369 end
6370  
6371 qText = qText.."\n\n"..tmpQText1.."\n";
6372  
6373 if ( ( QuestRewardMoney ) and ( QuestRewardMoney > 0 ) ) or ( numQuestRewards > 0 ) then
6374 qText = qText.."\n"..NUN_REWARDS.."\n";
6375 end
6376  
6377 if ( QuestRewardMoney ) and ( QuestRewardMoney > 0 ) then
6378 QuestRewardMoneyTxt = NuN_BuildMoneyString(QuestRewardMoney);
6379 qText = qText..QuestRewardMoneyTxt.."\n";
6380 end
6381  
6382 for i=1, numQuestRewards, 1 do
6383 bttn = getglobal("QuestLogItem"..i + numQuestChoices);
6384 if ( bttn.type ) then
6385 local link = GetQuestLogItemLink(bttn.type, bttn:GetID());
6386 if ( link ) then
6387 qText = qText..link.."\n";
6388 else
6389 link = GetQuestLogItemLink(bttn.type, ( i + numQuestChoices ) );
6390 if ( link ) then
6391 qText = qText..link.."\n";
6392 else
6393 error = true;
6394 qText = NUN_SLOWSERVER.." : NuN Err03";
6395 return qText, error;
6396 end
6397 end
6398 end
6399 end
6400  
6401 if ( numQuestChoices > 1 ) then
6402 qText = qText.."\n"..NUN_CHOICES.."\n";
6403 end
6404  
6405 for i=1, numQuestChoices, 1 do
6406 bttn = getglobal("QuestLogItem"..i);
6407 if ( bttn.type ) then
6408 local link = GetQuestLogItemLink(bttn.type, bttn:GetID());
6409 if ( link ) then
6410 if ( i > 1 ) then
6411 qText = qText.." / "..link;
6412 else
6413 qText = qText..link;
6414 end
6415 else
6416 link = GetQuestLogItemLink(bttn.type, i);
6417 if ( link ) then
6418 if ( i > 1 ) then
6419 qText = qText.." / "..link;
6420 else
6421 qText = qText..link;
6422 end
6423 else
6424 error = true;
6425 qText = NUN_SLOWSERVER.." : NuN Err03";
6426 return qText, error;
6427 end
6428 end
6429 end
6430 end
6431  
6432 if ( qText ) then
6433 qText = NuN_CleanQuestText(qText);
6434 end
6435  
6436 return qText, error;
6437 end
6438  
6439 function NuN_CheckQuestList(findName)
6440 local qTitle, qLevel, qTag, qHeader, qCollapsed, qComplete;
6441 local foundIndex = -1;
6442 local rLevel, rTag, rComplete;
6443  
6444 NuNQuestLog = {};
6445  
6446 for i = 1, GetNumQuestLogEntries(), 1 do
6447 qTitle, qLevel, qTag, qHeader, qCollapsed, qComplete = GetQuestLogTitle(i);
6448 if ( ( qTitle ) and ( not qHeader ) ) then
6449 NuNQuestLog[qTitle] = 1;
6450 if ( ( findName ) and ( findName == qTitle ) ) then
6451 foundIndex = i;
6452 rLevel = qLevel;
6453 rTag = qTag;
6454 rComplete = qComplete;
6455 end
6456 end
6457 end
6458  
6459 return foundIndex, rLevel, rTag, rComplete;
6460 end
6461  
6462 function NuN_UpdateQuestNotes(qEvent)
6463 local quest, qLevel, qTag, qHeader, qCollapsed, qComplete;
6464  
6465 qTriggs = 0;
6466  
6467 if ( pFaction ) then
6468 for qI=1, GetNumQuestLogEntries(), 1 do
6469 quest, qLevel, qTag, qHeader, qCollapsed, qComplete = GetQuestLogTitle(qI);
6470 if ( ( quest ) and ( not qHeader ) ) then
6471 NuN_ProcessQuest(quest, qLevel, qTag, qHeader, qCollapsed, qComplete, qI);
6472 end
6473 end
6474 end
6475  
6476 if ( qTriggs > 2 ) then
6477 timeSinceLastUpdate = 0;
6478 NuN_QuestsUpdating = "True";
6479 end
6480 end
6481  
6482 function NuN_ProcessQuest(quest, qLevel, qTag, qHeader, qCollapsed, qComplete, qI)
6483 local saveLvl = nil;
6484 local qText;
6485 local location = NuN_GetLoc();
6486  
6487 local l_c_note = c_note;
6488 local l_g_text = g_text;
6489 local l_c_name = c_name;
6490  
6491 if ( ( NuNData[pKey].QuestHistory[pName][quest] ) and ( NuNData[pKey].QuestHistory[pName][quest].abandoned ) ) then
6492 NuNData[pKey].QuestHistory[pName][quest].abandoned = nil;
6493 return;
6494 end
6495  
6496 QuestLog_SetSelection(qI);
6497  
6498 local qChar = NuN_CheckTarget();
6499 if ( qChar == "N" ) then
6500 qChar = c_note;
6501 else
6502 qChar = "";
6503 end
6504 if ( ( not NuNData[pKey].QuestHistory[pName][quest] ) and ( NuNSettings[pKey].autoQ ) ) then
6505 NuNData[pKey].QuestHistory[pName][quest] = {};
6506 NuNData[pKey].QuestHistory[pName][quest].sortDate = tostring(date("%Y%m%d%H%M%S"))..":"..qI;
6507 NuNData[pKey].QuestHistory[pName][quest].pLevel = UnitLevel("player");
6508 NuNData[pKey].QuestHistory[pName][quest].txt = NUN_CREATED.." "..qChar.."\n "..NuN_GetDateStamp().."\n "..location.."\n";
6509 qTriggs = qTriggs + 1;
6510 end
6511  
6512 local chk = NuN_CleanQuestText( GetQuestLogQuestText() );
6513 if ( qLevel == nil ) then
6514 qLevel = "--";
6515 end
6516 if ( qTag == nil ) then
6517 qTag = "";
6518 end
6519 if ( qChar ~= "" ) then
6520 qChar = qChar.." "..NuN_LocStrip(location);
6521 end
6522 qText = "\n"..quest.." "..NUN_QLVL..qLevel.." "..qTag.."\n"..qChar.."\n\n"..NuN_BuildQuestText().."\n";
6523  
6524 if ( not string.find(chk, "Unknown Entity") ) then
6525 if ( ( qComplete ) and ( NuNData[pKey].QuestHistory[pName][quest] ) and ( ( not NuNData[pKey].QuestHistory[pName][quest].complete ) or ( ( NuNData[pKey].QuestHistory[pName][quest].complete ~= chk ) and ( string.find(qText, chk) ) ) ) ) then
6526 NuNData[pKey].QuestHistory[pName][quest].complete = chk;
6527 NuNData[pKey].QuestHistory[pName][quest].txt = NuNData[pKey].QuestHistory[pName][quest].txt.."\n\n"..NUN_COMPLETE.."\n "..NuN_GetDateStamp().."\n "..location.."\n";
6528 end
6529 if ( NuNData[Notes][quest] ) then
6530 c_note = quest;
6531 g_text = NuN_GetGText(c_note);
6532 if ( ( not string.find( g_text, chk) ) and ( string.find(qText, chk) ) ) then
6533 if ( ( NuNGNoteFrame:IsVisible() ) and ( noteTypes[NuNGNoteFrame.type].Command == "QST" ) ) then
6534 HideUIPanel(NuNGNoteFrame);
6535 end
6536 g_text = g_text.."\n\n".."--------------".."\n\n"..qText;
6537 NuN_SetGText("Account");
6538 end
6539 elseif ( NuNData[pKey][Notes][quest] ) then
6540 c_note = quest;
6541 g_text = NuN_GetGText(c_note);
6542 if ( ( not string.find( g_text, chk ) ) and ( string.find(qText, chk) ) ) then
6543 if ( ( NuNGNoteFrame:IsVisible() ) and ( noteTypes[NuNGNoteFrame.type].Command == "QST" ) ) then
6544 HideUIPanel(NuNGNoteFrame);
6545 end
6546 g_text = g_text.."\n\n".."--------------".."\n\n"..qText;
6547 NuN_SetGText("Realm");
6548 end
6549 elseif ( ( not NuNData[Notes][quest] ) and ( not NuNData[pKey][Notes][quest] ) and ( NuNSettings[pKey].autoQ ) ) then
6550 if ( NuNSettings[pKey].dLevel ) then
6551 NuNData[Notes][quest] = {};
6552 NuNData[Notes][quest].type = 5;
6553 saveLvl = "Account";
6554 else
6555 NuNData[pKey][Notes][quest] = {};
6556 NuNData[pKey][Notes][quest].type = 5;
6557 saveLvl = "Realm";
6558 end
6559 c_note = quest;
6560 g_text = qText;
6561 NuN_SetGText(saveLvl);
6562 if ( ( qChar ~= "" ) and ( NuNSettings[pKey].autoMapNotes ) ) then
6563 NuN_MapNote("Target", NUN_QUEST_GIVER, "", 9);
6564 end
6565 end
6566 end
6567  
6568 c_note = l_c_note;
6569 g_text = l_g_text;
6570 c_name = l_c_name;
6571 end
6572  
6573 function NuN_AbandonQuest(qTitle)
6574 if ( NuNData[pKey].QuestHistory[pName][qTitle] ) then
6575 NuNData[pKey].QuestHistory[pName][qTitle].abandoned = true;
6576 if ( NuNQuestLog[qTitle] ) then
6577 NuNQuestLog[qTitle] = nil;
6578 end
6579 end
6580 end
6581  
6582 function NuN_QuestHandIn(q)
6583 if ( NuNData[pKey].QuestHistory[pName][q] ) then
6584 local l_c_note = c_note;
6585 local l_c_name = c_name;
6586 local qChar = NuN_CheckTarget();
6587 if ( qChar == "N" ) then
6588 qChar = c_note;
6589 else
6590 qChar = "";
6591 end
6592 NuNData[pKey].QuestHistory[pName][q].handedIn = 1;
6593 NuNData[pKey].QuestHistory[pName][q].txt = NuNData[pKey].QuestHistory[pName][q].txt.."\n\n"..NUN_FINISHED.." "..qChar.."\n "..NuN_GetDateStamp().."\n "..NuN_GetLoc().."\n";
6594 c_note = l_c_note;
6595 c_name = l_c_name;
6596 end
6597 end
6598  
6599  
6600  
6601 function NuN_InitialiseSavedVariables()
6602 local index, value;
6603  
6604 pKey = GetCVar("realmName");
6605 if (not NuNData[pKey]) then
6606 NuNData[pKey] = {};
6607 NuNSettings[pKey] = {};
6608 NuNSettings[pKey].toolTips = "1";
6609 NuNSettings[pKey].pScale = 1.00;
6610 NuNSettings[pKey].tScale = 1.00;
6611 NuNSettings[pKey].mScale = 1.00;
6612 NuNSettings[pKey].ttLen = NUN_TT_MAX;
6613 NuNSettings[pKey].ttLLen = NUN_TT_LEN;
6614 NuNData[pKey][Notes] = {};
6615 NuNSettings[pKey].minOver = "1";
6616 NuNSettings[pKey].dLevel = "1";
6617 end
6618 if ( not NuNSettings.Version ) then
6619 for index, value in NuNSettings do
6620 if ( index ~= "Version" ) then
6621 NuNSettings[index].toolTips = "1";
6622 NuNSettings[index].pScale = 1.00;
6623 NuNSettings[index].tScale = 1.00;
6624 NuNSettings[index].mScale = 1.00;
6625 NuNSettings[index].ttLen = NUN_TT_MAX;
6626 NuNSettings[index].ttLLen = NUN_TT_LEN;
6627 NuNSettings[index].minOver = "1";
6628 NuNSettings[pKey].dLevel = "1";
6629 end
6630 end
6631 NuNSettings.Version = NUN_VERSION;
6632 end
6633 if ( NuNSettings.Version < "2.51" ) then
6634 for index, value in NuNSettings do
6635 if ( index ~= "Version" ) then
6636 NuNSettings[index].mScale = 1.00;
6637 NuNSettings[index].minOver = "1";
6638 end
6639 end
6640 NuNSettings.Version = NUN_VERSION;
6641 end
6642 if ( NuNSettings.Version < "3.00" ) then
6643 for index, value in NuNSettings do
6644 if ( index ~= "Version" ) then
6645 NuNSettings[index].mScale = 1.00;
6646 end
6647 end
6648 NuNSettings.Version = NUN_VERSION;
6649 end
6650 if ( NuNSettings.Version < NUN_VERSION ) then
6651 NuNSettings.Version = NUN_VERSION;
6652 end
6653 if ( not NuNData[itmIndex] ) then
6654 NuNData[itmIndex] = {};
6655 end
6656 if ( not NuNData[Notes] ) then
6657 NuNData[Notes] = {};
6658 end
6659 if ( not NuNData[pKey].QuestHistory ) then
6660 NuNData[pKey].QuestHistory = {};
6661 end
6662 if ( not NuNData[pKey].QuestHistory[pName] ) then
6663 NuNData[pKey].QuestHistory[pName] = {};
6664 end
6665 if ( not NuNData[mrgIndex] ) then
6666 NuNData[mrgIndex] = {};
6667 end
6668 end
6669  
6670  
6671  
6672 function NuN_OptionsTextLengthSet()
6673 local len = this:GetText();
6674  
6675 if ( len ) then
6676 NuNSettings[pKey].ttLen = len;
6677 else
6678 NuNSettings[pKey].ttLen = "0";
6679 end
6680 end
6681  
6682  
6683  
6684 function NuN_OptionsTextLineLengthSet()
6685 local len = this:GetText();
6686  
6687 if ( len ) then
6688 NuNSettings[pKey].ttLLen = len;
6689 else
6690 NuNSettings[pKey].ttLLen = "0";
6691 end
6692 end
6693  
6694  
6695  
6696 function NuN_FetchQuestHistory()
6697 local index, value;
6698 local counter = 0;
6699 local results = 0;
6700  
6701 foundNuN = {};
6702 for index, value in NuNData[pKey].QuestHistory[pName] do
6703 counter = counter + 1;
6704 foundNuN[counter] = NUN_QUEST_C..index;
6705 end
6706  
6707 table.sort(foundNuN, NuN_SortQuestHistory);
6708 results = getn(foundNuN);
6709 NuNSearchTitleText:SetText(pName.."'s "..NUN_QUESTS_TEXT.." ("..results..")");
6710  
6711 NuNSearch_Update();
6712 if ( ( deletedE ) and ( visibles > 0 ) and ( lastBttn ~= nil ) ) then
6713 deletedE = false;
6714 if ( lastBttnIndex > visibles ) then
6715 NuNSearch_HighlightRefresh(lastVisible);
6716 NuNSearchNote_OnClick(lastVisible);
6717 else
6718 NuNSearch_HighlightRefresh(lastBttn);
6719 NuNSearchNote_OnClick(lastBttn);
6720 end
6721 else
6722 NuNSearch_HighlightRefresh(nil);
6723 end
6724 end
6725  
6726  
6727  
6728 function NuN_SortQuestHistory(ele1, ele2)
6729 ele1 = string.sub(ele1, 2);
6730 ele2 = string.sub(ele2, 2);
6731 if ( NuNData[pKey].QuestHistory[pName][ele1].sortDate > NuNData[pKey].QuestHistory[pName][ele2].sortDate ) then
6732 return true;
6733 end
6734  
6735 return false;
6736 end
6737  
6738  
6739  
6740 function NuN_CleanQuestText(dirtyText)
6741 local cleanText = string.gsub(dirtyText, pName, NUN_REPLACEQNAME_TXT);
6742 cleanText = string.gsub(cleanText, "$N", NUN_REPLACEQNAME_TXT);
6743  
6744 local class = UnitClass("player");
6745 cleanText = string.gsub(cleanText, class, NUN_REPLACEQCLASS_TXT);
6746 cleanText = string.gsub(cleanText, strlower(class), NUN_REPLACEQCLASS_TXT);
6747  
6748 return cleanText;
6749 end
6750  
6751  
6752 function NuN_ToggleMicroButtons()
6753 if ( NuNMicroFrame:IsVisible() ) then
6754 HideUIPanel(NuNMicroFrame);
6755 NuNSettings[pKey].hideMicro = "1";
6756 else
6757 ShowUIPanel(NuNMicroFrame);
6758 NuNSettings[pKey].hideMicro = nil;
6759 end
6760 end
6761  
6762  
6763 function NuN_ProcessParty()
6764 local pChanged = nil;
6765 local lMember, index, value;
6766 local partyA = {};
6767 local lMembers = GetNumPartyMembers();
6768  
6769 if ( not NuNData[pKey][NuN_Parties] ) then
6770 NuNData[pKey][NuN_Parties] = {};
6771 end
6772 if ( ( not NuNData[pKey][NuN_Parties][pName] ) or ( ( not UnitInRaid("player") ) and ( lMembers == 0 ) ) ) then
6773 NuNData[pKey][NuN_Parties][pName] = {};
6774 end
6775  
6776 for i = 1, lMembers, 1 do
6777 lMember = UnitName("party"..i);
6778 if ( lMember == "Unknown Entity" ) then
6779 return;
6780 end
6781 if ( lMember ) then
6782 partyA[lMember] = {};
6783 partyA[lMember].pos = i;
6784 if ( not NuNData[pKey][NuN_Parties][pName][lMember] ) then
6785 NuNData[pKey][NuN_Parties][pName][lMember] = {};
6786 NuNData[pKey][NuN_Parties][pName][lMember].pos = i;
6787 if ( not NuNData[pKey][lMember] ) then
6788 NuNData[pKey][lMember] = {};
6789 NuNData[pKey][lMember].type = NUN_PARTY_C;
6790 NuNData[pKey][lMember].faction = pFaction;
6791 NuNData[pKey][lMember][txtTxt] = NUN_AUTO_PARTIED..NuN_GetDateStamp();
6792 NuNData[pKey][lMember][pName] = {};
6793 NuNData[pKey][lMember][pName].partied = 1;
6794 else
6795 if ( not NuNData[pKey][lMember][pName] ) then
6796 NuNData[pKey][lMember][pName] = {};
6797 NuNData[pKey][lMember][pName].partied = 1;
6798 elseif ( not NuNData[pKey][lMember][pName].partied ) then
6799 NuNData[pKey][lMember][pName].partied = 1;
6800 else
6801 NuNData[pKey][lMember][pName].partied = NuNData[pKey][lMember][pName].partied + 1;
6802 end
6803 end
6804 end
6805 end
6806 end
6807  
6808 for index, value in NuNData[pKey][NuN_Parties][pName] do
6809 if ( not partyA[index] ) then
6810 if ( UnitInRaid("player") ) then
6811 local rID = NuN_CheckRaidByName(index);
6812 if ( not rID ) then
6813 NuNData[pKey][NuN_Parties][pName][index] = nil;
6814 end
6815 else
6816 NuNData[pKey][NuN_Parties][pName][index] = nil;
6817 end
6818 end
6819 end
6820 end
6821  
6822  
6823  
6824 function NuN_PartyDownButton_OnClick()
6825 local lParties = NuNData[pKey][c_name][pName].partied;
6826  
6827 lParties = lParties - 1;
6828 if ( lParties < 1 ) then
6829 NuNData[pKey][c_name][pName].partied = nil;
6830 NuNPartiedLabel:Hide();
6831 NuNPartiedNumberLabel:SetText("(0)");
6832 NuNPartiedNumberLabel:Hide();
6833 NuNFramePartyDownButton:Hide();
6834 else
6835 NuNData[pKey][c_name][pName].partied = lParties;
6836 NuNPartiedNumberLabel:SetText("(x"..tostring(lParties)..")");
6837 end
6838 end
6839  
6840  
6841 function NuN_PartyDownButton_OnEnter()
6842 if ( NuNSettings[pKey].toolTips ) then
6843 NuN_Fade = "False";
6844 local x, y = GetCursorPosition();
6845 if ( x > 500 ) then
6846 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
6847 else
6848 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
6849 end
6850 NuN_Tooltip:ClearLines();
6851 NuN_Tooltip:AddLine(NUN_TT_PDOWN_TXT1, 1, 0.7, 0);
6852 NuN_Tooltip:AddLine(NUN_TT_PDOWN_TXT2, 0, 1, 0);
6853 NuN_Tooltip:AddLine(NUN_TT_PDOWN_TXT3, 0, 1, 0);
6854 NuN_Tooltip:Show();
6855 end
6856 end
6857  
6858 function NuN_bHaveTTCheckBox_OnEnter()
6859 if ( NuNSettings[pKey].toolTips ) then
6860 NuN_Fade = "False";
6861 NuN_Tooltip:SetOwner(this);
6862 NuN_Tooltip:ClearLines();
6863 NuN_Tooltip:AddLine(NUN_TT_BHAVE_TXT1, 1, 0.7, 0);
6864 NuN_Tooltip:AddLine(NUN_TT_BHAVE_TXT2, 0, 1, 0);
6865 NuN_Tooltip:AddLine(NUN_TT_BHAVE_TXT3, 0, 1, 0);
6866 NuN_Tooltip:AddLine(NUN_TT_BHAVE_TXT4, 0, 1, 0);
6867 NuN_Tooltip:AddLine(NUN_TT_BHAVE_TXT5, 0, 1, 0);
6868 NuN_Tooltip:Show();
6869 end
6870 end
6871  
6872 function NuN_BuildShoppingList()
6873 local listText = "";
6874 local mName = MerchantNameText:GetText();
6875  
6876 if ( mName == c_note ) then
6877 local iPrice, iPriceTxt, iQuant, iNumAvail, iLink, iDiscard;
6878 local numMerchantItems = GetMerchantNumItems();
6879  
6880 for i=1, numMerchantItems, 1 do
6881 iLink = GetMerchantItemLink(i);
6882 if ( iLink ) then
6883 listText = listText.."\n"..iLink;
6884 end
6885 iDiscard, iDiscard, iPrice, iQuant, iNumAvail = GetMerchantItemInfo(i);
6886 if ( ( iQuant ) and ( iQuant > 1 ) ) then
6887 listText = listText.." ("..iQuant..") ";
6888 end
6889 if ( ( iPrice ) and ( iPrice > 0 ) ) then
6890 iPriceTxt = NuN_BuildMoneyString(iPrice);
6891 listText = listText.." "..iPriceTxt;
6892 end
6893 if ( ( iNumAvail ) and ( iNumAvail > 0 ) ) then
6894 listText = listText.." "..NUN_LIMITED;
6895 end
6896 end
6897 end
6898  
6899 if ( listText == "" ) then
6900 return nil;
6901 else
6902 return listText;
6903 end
6904 end
6905  
6906  
6907 function NuN_BuildMoneyString(moneyVal)
6908 local moneyTxt = nil;
6909 local gold, silver, copper;
6910  
6911 if ( ( moneyVal ) and ( moneyVal > 0 ) ) then
6912 if ( moneyVal > 9999 ) then
6913 gold = ( moneyVal / 10000 );
6914 gold = string.format("%d", gold);
6915 moneyVal = moneyVal - ( gold * 10000 );
6916 else
6917 gold = 0;
6918 end
6919 if ( moneyVal > 99 ) then
6920 silver = ( moneyVal / 100 );
6921 silver = string.format("%d", silver);
6922 moneyVal = moneyVal - ( silver * 100 );
6923 else
6924 silver = 0;
6925 end
6926 copper = moneyVal;
6927 moneyTxt = string.format("%dg %ds %dc", gold, silver, copper);
6928 end
6929  
6930 return moneyTxt;
6931 end
6932  
6933  
6934 function NuN_SaveOpen()
6935 if ( NuNFrame:IsVisible() ) then
6936 NuN_WriteNote();
6937 end
6938 if ( NuNGNoteFrame:IsVisible() ) then
6939 NuNGNote_WriteNote();
6940 end
6941 end
6942  
6943  
6944 function NuN_TextEscape(lFrame, lText)
6945 if ( NuNSettings[pKey].bHave ) then
6946 lText:ClearFocus();
6947 if ( ( lText:GetText() == nil ) or ( lText:GetText() == "" ) ) then
6948 lText:SetText("\n");
6949 end
6950 else
6951 HideUIPanel(lFrame);
6952 end
6953 end
6954  
6955  
6956  
6957 function NuN_OverTTCheckBox_OnClick()
6958 if ( NuN_OverTTCheckBox:GetChecked() ) then
6959 NuNSettings[pKey].minOver = "1";
6960 else
6961 NuNSettings[pKey].minOver = nil;
6962 end
6963 end
6964  
6965  
6966  
6967 function NuN_AutoPartyCheckBox_OnClick()
6968 if ( NuN_AutoPartyCheckBox:GetChecked() ) then
6969 NuNSettings[pKey].autoP = "1";
6970 NuN_ProcessParty();
6971 else
6972 NuNSettings[pKey].autoP = nil;
6973  
6974 end
6975 end
6976  
6977  
6978 function NuN_BehaveCheckBox_OnClick()
6979 if ( NuN_BehaveCheckBox:GetChecked() ) then
6980 NuNSettings[pKey].bHave = "1";
6981 else
6982 NuNSettings[pKey].bHave = nil;
6983 end
6984 end
6985  
6986  
6987 function NuN_DeleteNote(dType)
6988 if ( NuNcDeleteFrame:IsVisible() ) then
6989 NuNcDeleteFrame:Hide();
6990 end
6991 NuNcDeleteFrame.type = dType;
6992 if ( dType == "Contact" ) then
6993 NuNcDeleteLabel:SetText(NUN_CONTACT_TXT.." :\n"..c_name);
6994 ShowUIPanel(NuNcDeleteFrame);
6995 NuNText:ClearFocus();
6996 NuNcDeleteGhostTextBox:SetFocus();
6997 else
6998 if ( NuNGNoteFrame.fromQuest ) then
6999 NuNcDeleteLabel:SetText(NUN_QUEST_NOTE.." :\n"..c_note);
7000 else
7001 NuNcDeleteLabel:SetText(NUN_GENERAL_TXT.." :\n"..c_note);
7002 end
7003 ShowUIPanel(NuNcDeleteFrame);
7004 NuNGNoteTextScroll:ClearFocus();
7005 NuNcDeleteGhostTextBox:SetFocus();
7006 end
7007 end
7008  
7009  
7010 function NuNcDeleteButton_OnClick()
7011 if ( NuNcDeleteFrame.type == "Contact" ) then
7012 HideUIPanel(NuNcDeleteFrame);
7013 NuN_Delete();
7014 elseif ( NuNcDeleteFrame.type == "General" ) then
7015 HideUIPanel(NuNcDeleteFrame);
7016 NuNGNote_Delete();
7017 end
7018 end
7019  
7020  
7021 function NuN_LocStrip(locData)
7022 if ( locData ) then
7023 local p = string.find(locData, " : ");
7024 if ( p ) then
7025 locData = string.sub(locData, (p+3));
7026 end
7027 end
7028  
7029 return locData;
7030 end
7031  
7032  
7033  
7034  
7035 function NuN_MapNote(MNType, MNxtra1, MNxtra2, MNColour)
7036 local MNCont, MNZone, x, y;
7037 local checknote = nil;
7038 local nKey = nil;
7039  
7040 if ( ( MetaMapNotes_OnLoad ) or ( MapNotes_OnLoad ) ) then
7041 else
7042 return;
7043 end
7044  
7045 MNCont, MNZone, x, y, checknote, nKey = NuN_GetMapNotesKey();
7046 if ( ( not MNCont ) or ( ( x == 0 ) and ( y == 0 ) ) ) then
7047 if ( MetaMapNotes_OnLoad ) then
7048 MetaMap_StatusPrint(METAMAPNOTES_QUICKNOTE_NOPOSITION);
7049 elseif ( MapNotes_OnLoad ) then
7050 MapNotes_StatusPrint(MAPNOTES_QUICKNOTE_NOPOSITION);
7051 end
7052 return;
7053 end
7054  
7055 local MNLine1, MNLine2, MNAuthor, NuN_Reaction;
7056 local MNName;
7057 local tName = UnitName("target");
7058 if ( ( MNType == "Target" ) and ( tName ) and ( not UnitPlayerControlled("target") ) ) then
7059 NuN_Reaction = UnitReaction("player", "target");
7060 if ( not MNColour ) then
7061 if ( NuN_Reaction < 4 ) then
7062 MNColour = 1;
7063 elseif ( NuN_Reaction == 4 ) then
7064 MNColour = 0;
7065 end
7066 end
7067 MNName = UnitName("target");
7068 else
7069 MNName = c_note;
7070 end
7071 if ( not MNColour ) then
7072 MNColour = 3;
7073 end
7074  
7075 local theData;
7076 if ( MetaMapNotes_OnLoad ) then
7077 theData = MetaMapNotes_Data[MNCont];
7078 elseif ( MapNotes_OnLoad ) then
7079 theData = MapNotes_Data[MNCont];
7080 end
7081  
7082 if (checknote) then
7083 if ( ( inBG ) and ( MNName == theData[checknote].name ) ) then
7084 NuN_ReLinkMapNote(MNName, MNCont, MNZone, checknote);
7085 return;
7086 elseif ( ( not inBG ) and ( MNName == theData[MNZone][checknote].name ) ) then
7087 NuN_ReLinkMapNote(MNName, MNCont, MNZone, checknote);
7088 return;
7089 end
7090 local mergeFailed = NuN_MergeMapNote(MNCont, MNZone, checknote, MNName, nKey, MNxtra1, MNxtra2);
7091 if ( mergeFailed ) then
7092 local repName;
7093 if ( inBG ) then
7094 repName = theData[checknote].name;
7095 else
7096 repName = theData[zone][checknote].name;
7097 end
7098 if ( MetaMapNotes_OnLoad ) then
7099 MetaMap_StatusPrint( format(METAMAPNOTES_QUICKNOTE_NOTETONEAR, repName));
7100 elseif ( MapNotes_OnLoad ) then
7101 MapNotes_StatusPrint( format(MAPNOTES_QUICKNOTE_NOTETONEAR, repName));
7102 end
7103 NuN_Message( NUN_MAX_MERGED );
7104 end
7105 else
7106 MNLine1 = MNxtra1;
7107 MNLine2 = MNxtra2;
7108 MNAuthor = "NotesUNeed - "..pName;
7109 NuN_WriteMapNote(MNCont, MNZone, x, y, MNColour, MNName, MNLine1, MNLine2, MNAuthor);
7110 end
7111 end
7112  
7113 function NuN_ReLinkMapNote(MNName, MNCont, MNZone, tmpID)
7114 local NuN_Key = MNCont.."-"..MNZone.."-"..tmpID;
7115 if ( not NuNData[mrgIndex] ) then
7116 NuNData[mrgIndex] = {};
7117 end
7118 if ( not NuNData[mrgIndex][NuN_Key] ) then
7119 NuNData[mrgIndex][NuN_Key] = {};
7120 NuNData[mrgIndex][NuN_Key].noteCounter = 0;
7121 end
7122 if ( NuNData[mrgIndex][NuN_Key][MNName] ) then
7123 NuN_Message(NUN_NOTESUNEED_INFO);
7124 return;
7125 end
7126 if ( not NuNData[mrgIndex][NuN_Key].noteCounter ) then
7127 NuNData[mrgIndex][NuN_Key].noteCounter = 0;
7128 end
7129 NuNData[mrgIndex][NuN_Key].noteCounter = NuNData[mrgIndex][NuN_Key].noteCounter + 1;
7130 NuNData[mrgIndex][NuN_Key][MNName] = "1";
7131 if ( MetaMapNotes_OnLoad ) then
7132 NuN_Message("NotesUNeed <> MetaMapNote");
7133 elseif ( MapNotes_OnLoad ) then
7134 NuN_Message("NotesUNeed <> MapNote");
7135 end
7136 end
7137  
7138 function NuN_MergeMapNote(MNCont, MNZone, id, MNName, NuN_Key, MNxtra1, MNxtra2)
7139 local Merged = nil;
7140 local MNLine1, MNLine2, MNAuthor;
7141 local mrgEntry = nil;
7142 local oriNote;
7143 local mapNoted = true;
7144 local theData;
7145  
7146 if ( MetaMapNotes_OnLoad ) then
7147 if ( inBG ) then
7148 theData = MetaMapNotes_Data[MNCont];
7149 else
7150 theData = MetaMapNotes_Data[MNCont][MNZone];
7151 end
7152 elseif ( MapNotes_OnLoad ) then
7153 if ( inBG ) then
7154 theData = MapNotes_Data[MNCont];
7155 else
7156 theData = MapNotes_Data[MNCont][MNZone];
7157 end
7158 else
7159 return;
7160 end
7161 oriNote = theData[id].name;
7162  
7163 if ( not string.find(oriNote, MNName) ) then
7164 mapNoted = nil;
7165 end
7166  
7167 if ( not NuNData[mrgIndex] ) then
7168 NuNData[mrgIndex] = {};
7169 end
7170 if ( not NuNData[mrgIndex][NuN_Key] ) then
7171 NuNData[mrgIndex][NuN_Key] = {};
7172 else
7173 mrgEntry = true;
7174 end
7175  
7176 if ( mrgEntry ) then
7177 if ( not NuNData[mrgIndex][NuN_Key].noteCounter ) then
7178 local counter = 0;
7179 local index, value;
7180 for index, value in NuNData[mrgIndex][NuN_Key] do
7181 counter = counter + 1;
7182 end
7183 NuNData[mrgIndex][NuN_Key].noteCounter = counter;
7184 end
7185 if ( NuNData[mrgIndex][NuN_Key].noteCounter > 4 ) then
7186 return "Failed";
7187 end
7188 if ( NuNData[mrgIndex][NuN_Key][MNName] ) then
7189 return nil;
7190 else
7191 NuNData[mrgIndex][NuN_Key].noteCounter = NuNData[mrgIndex][NuN_Key].noteCounter + 1;
7192 NuNData[mrgIndex][NuN_Key][MNName] = "1";
7193 end
7194 elseif ( mapNoted ) then
7195 NuN_ReLinkMapNote(MNName, MNCont, MNZone, id);
7196 else
7197 if ( ( not NuNData[Notes][oriNote] ) and ( not NuNData[pKey][Notes][oriNote] ) ) then
7198 NuNData[mrgIndex][NuN_Key].noteCounter = 1;
7199 NuNData[mrgIndex][NuN_Key][MNName] = "1";
7200 else
7201 NuNData[mrgIndex][NuN_Key].noteCounter = 2;
7202 NuNData[mrgIndex][NuN_Key][MNName] = "1";
7203 NuNData[mrgIndex][NuN_Key][oriNote] = "1";
7204 end
7205 end
7206  
7207 if ( not mapNoted ) then
7208 theData[id].name = theData[id].name.." | "..MNName;
7209 theData[id].inf1 = theData[id].inf1.." | "..MNxtra1;
7210 theData[id].inf2 = theData[id].inf2.." | "..MNxtra2;
7211 theData[id].creator = NUN_POPUP_TITLE.." - "..pName;
7212 end
7213  
7214 if ( MetaMapNotes_OnLoad ) then
7215 MetaMap_StatusPrint( format(NUN_MERGING.." "..theData[id].name) );
7216 elseif ( MapNotes_OnLoad ) then
7217 MapNotes_StatusPrint( format(NUN_MERGING.." "..theData[id].name) );
7218 end
7219  
7220 return nil;
7221 end
7222  
7223  
7224 function NuN_WriteMapNote(MNCont, MNZone, x, y, MNColour, MNName, MNLine1, MNLine2, MNAuthor)
7225 local id = 0;
7226 local NuN_Key;
7227 local theData, theMiniData;
7228 local NuN_SetNextAsMiniNote;
7229 local numNotes, i, j, tmpID;
7230  
7231 if ( MetaMapNotes_OnLoad ) then
7232 if ( inBG ) then
7233 theData = MetaMapNotes_Data[MNCont];
7234 else
7235 theData = MetaMapNotes_Data[MNCont][MNZone];
7236 end
7237 theMiniData = MetaMapNotes_MiniNote_Data;
7238 NuN_SetNextAsMiniNote = MetaMapNotes_SetNextAsMiniNote;
7239 numNotes = MetaMapNotes_NotesPerZone;
7240 i = MetaMapNotes_GetZoneTableSize(theData);
7241 elseif ( MapNotes_OnLoad ) then
7242 if ( inBG ) then
7243 theData = MapNotes_Data[MNCont];
7244 else
7245 theData = MapNotes_Data[MNCont][MNZone];
7246 end
7247 theMiniData = MapNotes_MiniNote_Data;
7248 NuN_SetNextAsMiniNote = MapNotes_SetNextAsMiniNote;
7249 numNotes = MapNotes_NotesPerZone;
7250 i = 0;
7251 for j, value in MapNotes_Data[MNCont][MNZone] do
7252 i = i + 1;
7253 end
7254 else
7255 return;
7256 end
7257  
7258 if (NuN_SetNextAsMiniNote ~= 2) then
7259 if (i < numNotes) then
7260 tmpID = i + 1;
7261 theData[tmpID] = {};
7262 theData[tmpID].name = MNName;
7263 theData[tmpID].ncol = 0;
7264 theData[tmpID].inf1 = MNLine1;
7265 theData[tmpID].in1c = 0;
7266 theData[tmpID].inf2 = MNLine2;
7267 theData[tmpID].in2c = 0;
7268 theData[tmpID].creator = MNAuthor;
7269 theData[tmpID].icon = MNColour;
7270 theData[tmpID].xPos = x;
7271 theData[tmpID].yPos = y;
7272 if ( MetaMapNotes_OnLoad ) then
7273 MetaMap_StatusPrint(format(METAMAPNOTES_QUICKNOTE_OK, GetRealZoneText()));
7274 else
7275 MapNotes_StatusPrint(format(MAPNOTES_QUICKNOTE_OK, GetRealZoneText()));
7276 end
7277  
7278 NuN_Key = MNCont.."-"..MNZone.."-"..tmpID;
7279 if ( not NuNData[mrgIndex] ) then
7280 NuNData[mrgIndex] = {};
7281 end
7282 if ( not NuNData[mrgIndex][NuN_Key] ) then
7283 NuNData[mrgIndex][NuN_Key] = {};
7284 end
7285 NuNData[mrgIndex][NuN_Key].noteCounter = 1;
7286 NuNData[mrgIndex][NuN_Key][MNName] = "1";
7287 else
7288 if ( MetaMapNotes_OnLoad ) then
7289 MetaMap_StatusPrint(format(METAMAPNOTES_QUICKNOTE_TOOMANY, GetRealZoneText()));
7290 elseif ( MapNotes_OnLoad ) then
7291 MapNotes_StatusPrint(format(MAPNOTES_QUICKNOTE_TOOMANY, GetRealZoneText()));
7292 end
7293 end
7294 end
7295  
7296 if (NuN_SetNextAsMiniNote ~= 0) then
7297 theMiniData.xPos = x;
7298 theMiniData.yPos = y;
7299 theMiniData.MNCont = MNCont;
7300 theMiniData.MNZone = MNZone;
7301 theMiniData.id = id;
7302 theMiniData.name = MNName;
7303 theMiniData.color = 0;
7304 theMiniData.icon = MNColour;
7305 MiniNotePOITexture:SetTexture("Interface\\AddOns\\MapNotes\\POIIcons\\Icon"..MNColour);
7306 MiniNotePOI:Show();
7307 if ( MetaMapNotes_OnLoad ) then
7308 MetaMapNotes_SetNextAsMiniNote = 0;
7309 MetaMap_StatusPrint(METAMAPNOTES_SETMININOTE.." - "..MNName);
7310 elseif ( MapNotes_OnLoad ) then
7311 MapNotes_SetNextAsMiniNote = 0;
7312 MapNotes_StatusPrint(MAPNOTES_SETMININOTE.." - "..MNName);
7313 end
7314 end
7315 end
7316  
7317  
7318 function NuN_GetMapNotesKey()
7319 local id = nil;
7320 local nKey = nil;
7321 local x, y;
7322 local MNCont = nil;
7323 local MNZone = nil;
7324  
7325 inBG = false;
7326  
7327 SetMapToCurrentZone();
7328 MNCont = GetCurrentMapContinent();
7329  
7330 if ( MetaMapNotes_OnLoad ) then
7331 if ( MNCont == -1 ) then
7332 if ( not MetaMapNotes_Data[GetRealZoneText()] ) then
7333 MetaMapNotes_Data[GetRealZoneText()] = {};
7334 end
7335 MNCont = GetRealZoneText();
7336 MNZone = 0;
7337 inBG = true;
7338 else
7339 MNZone = MetaMapNotes_ZoneShift[MNCont][GetCurrentMapZone()];
7340 if ( not MetaMapNotes_Data[MNCont][MNZone] ) then
7341 MetaMapNotes_Data[MNCont][MNZone] = {};
7342 end
7343 end
7344 elseif ( MapNotes_OnLoad ) then
7345 if ( MNCont == -1 ) then
7346 if ( not MapNotes_Data[GetRealZoneText()] ) then
7347 MapNotes_Data[GetRealZoneText()] = {};
7348 end
7349 MNCont = GetRealZoneText();
7350 MNZone = 0;
7351 inBG = true;
7352 else
7353 MNZone = MapNotes_ZoneShift[MNCont][GetCurrentMapZone()];
7354 if ( not MapNotes_Data[MNCont][MNZone] ) then
7355 MapNotes_Data[MNCont][MNZone] = {};
7356 end
7357 end
7358 end
7359  
7360 x, y = GetPlayerMapPosition("player");
7361 if ( ( ( x == 0 ) and ( y == 0 ) ) or ( MNCont == 0 ) ) then
7362 return nil;
7363 end
7364  
7365 if ( inBG ) then
7366 id = NuN_ProximityCheck(MNCont, x, y);
7367 elseif ( MetaMapNotes_OnLoad ) then
7368 id = MetaMapNotes_CheckNearNotes(MNCont, MNZone, x, y);
7369 elseif ( MapNotes_OnLoad ) then
7370 id = MapNotes_CheckNearNotes(MNCont, MNZone, x, y);
7371 end
7372  
7373 if ( id ) then
7374 nKey = MNCont.."-"..MNZone.."-"..id;
7375 end
7376  
7377 return MNCont, MNZone, x, y, id, nKey;
7378 end
7379  
7380 function NuN_ProximityCheck(theBG, xPos, yPos)
7381 local chkData = {};
7382 local minDiff;
7383  
7384 local chkData = {};
7385  
7386 if ( MetaMapNotes_OnLoad ) then
7387 chkData = MetaMapNotes_Data[theBG];
7388 minDiff = MetaMapNotes_MinDiff;
7389 elseif ( MapNotes_OnLoad ) then
7390 chkData = MapNotes_Data[theBG];
7391 minDiff = MapNotes_MinDiff;
7392 end
7393  
7394 if ( ( not minDiff ) or ( minDiff == 0 ) ) then
7395 minDiff = 7;
7396 end
7397  
7398 if ( not chkData ) then
7399 return;
7400 end
7401  
7402 local i = 1;
7403 for j, value in chkData do
7404 local deltax = abs(chkData[i].xPos - xPos);
7405 local deltay = abs(chkData[i].yPos - yPos);
7406 if(deltax <= 0.0009765625 * minDiff and deltay <= 0.0013020833 * minDiff) then
7407 return i;
7408 end
7409 i = i + 1;
7410 end
7411  
7412 return nil;
7413 end
7414  
7415  
7416  
7417 function NuN_AutoMapCheckBox_OnClick()
7418 if ( NuN_AutoMapCheckBox:GetChecked() ) then
7419 NuNSettings[pKey].autoMapNotes = "1";
7420 else
7421 NuNSettings[pKey].autoMapNotes = nil;
7422 end
7423 end
7424  
7425  
7426 function NuN_AutoMapCheckBox_OnEnter()
7427 if ( NuNSettings[pKey].toolTips ) then
7428 NuN_Fade = "False";
7429 local x, y = GetCursorPosition();
7430 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
7431 NuN_Tooltip:ClearLines();
7432 NuN_Tooltip:AddLine(NUN_TT_MAPCHECK_TXT1, 1, 0.7, 0);
7433 NuN_Tooltip:AddLine(NUN_TT_MAPCHECK_TXT2, 0, 1, 0);
7434 NuN_Tooltip:AddLine(NUN_TT_MAPCHECK_TXT3, 0, 1, 0);
7435 NuN_Tooltip:AddLine(NUN_TT_MAPCHECK_TXT4, 0, 1, 0);
7436 NuN_Tooltip:AddLine(NUN_TT_MAPCHECK_TXT5, 0, 1, 0);
7437 NuN_Tooltip:Show();
7438 end
7439 end
7440  
7441  
7442  
7443 function NuN_HyperButton_OnClick(nType)
7444 local p1, p2;
7445 local linkA = {};
7446 local aCounter = 0;
7447 local lText, lTextLen;
7448  
7449 if ( nType == "Contact" ) then
7450 lText = NuNText:GetText();
7451 elseif ( nType == "General" ) then
7452 lText = NuNGNoteTextScroll:GetText();
7453 else
7454 NuN_Message(NUN_LINKFAILURE);
7455 return;
7456 end
7457  
7458 lTextLen = string.len(lText);
7459  
7460 p1 = string.find(lText, "|Hitem");
7461 while ( ( p1 ) and ( p1 > 10 ) ) do
7462 p2 = string.find(lText, "|h|r", p1);
7463 if ( ( not p2 ) or ( (p2+3) > lTextLen ) ) then
7464 break;
7465 end
7466 p1 = p1 - 10;
7467 p2 = p2 + 3;
7468 local link = string.sub(lText, p1, p2);
7469 aCounter = aCounter + 1;
7470 linkA[aCounter] = link;
7471 p1 = string.find(lText, "|Hitem", (p2+1));
7472 end
7473  
7474 local loops = getn(linkA);
7475 if ( loops ) and ( loops > 0 ) then
7476 for i=1, loops, 1 do
7477 DEFAULT_CHAT_FRAME:AddMessage(linkA[i]);
7478 end
7479 else
7480 NuN_Message(NUN_NOLINKS);
7481 end
7482 end
7483  
7484  
7485  
7486 function NuN_HyperButton_OnEnter()
7487 if ( NuNSettings[pKey].toolTips ) then
7488 NuN_Fade = "False";
7489 local x, y = GetCursorPosition();
7490 if ( x > 500 ) then
7491 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
7492 else
7493 NuN_Tooltip:SetOwner(this, "ANCHOR_TOPLEFT");
7494 end
7495 NuN_Tooltip:ClearLines();
7496 NuN_Tooltip:AddLine(NUN_TT_HYPERLINKS_TXT1, 1, 0.7, 0);
7497 NuN_Tooltip:AddLine(NUN_TT_HYPERLINKS_TXT2, 0, 1, 0);
7498 NuN_Tooltip:AddLine(NUN_TT_HYPERLINKS_TXT3, 0, 1, 0);
7499 NuN_Tooltip:Show();
7500 end
7501 end
7502  
7503  
7504  
7505  
7506 function NuNPopup_OnClick(bttn, noteN)
7507 if ( IsAltKeyDown() ) then
7508 if ( bttn == "LeftButton" ) then
7509 HideUIPanel(WorldMapFrame);
7510 if ( NuNGNoteFrame:IsVisible() ) then
7511 if ( c_note == noteN ) then
7512 return;
7513 end
7514 NuNGNoteFrame:Hide();
7515 end
7516 NuNGNoteFrame.fromQuest = nil;
7517 c_note = noteN;
7518 NuN_ShowSavedGNote();
7519 elseif ( bttn == "RightButton" ) then
7520 NuN_DeleteMapIndexNote(NuNPopup.id, noteN);
7521 end
7522 end
7523 end
7524  
7525 function NuNPopup_OnShow()
7526 popUpHide = nil;
7527 end
7528  
7529 function NuNPopup_OnUpdate(arg1)
7530 popUpTimeSinceLastUpdate = popUpTimeSinceLastUpdate + arg1;
7531 if ( popUpTimeSinceLastUpdate > popUpUpdateInterval ) then
7532 if ( ( popUpHide ) and ( not MouseIsOver(NuNPopup) ) ) then
7533 NuNPopup:Hide();
7534 end
7535 popUpTimeSinceLastUpdate = 0;
7536 end
7537 end
7538  
7539  
7540 function NuN_Message(msg)
7541 msg = "NotesUNeed : "..msg;
7542 if DEFAULT_CHAT_FRAME then
7543 DEFAULT_CHAT_FRAME:AddMessage(msg, 0.64, 0.21, 0.93);
7544 end
7545 end
7546  
7547  
7548  
7549 function NuN_UpdateMapNotesIndex(deletedNote)
7550 local MNindex, MNvalue, nIndex, nValue;
7551  
7552 for MNindex, MNvalue in NuNData[mrgIndex] do
7553 for nIndex, nValue in NuNData[mrgIndex][MNindex] do
7554 if ( nIndex == deletedNote ) then
7555 NuNData[mrgIndex][MNindex][nIndex] = nil;
7556 NuNData[mrgIndex][MNindex].noteCounter = NuNData[mrgIndex][MNindex].noteCounter - 1;
7557 break;
7558 end
7559 if ( NuNData[mrgIndex][MNindex].noteCounter < 1 ) then
7560 NuNData[mrgIndex][MNindex] = nil;
7561 end
7562 end
7563 end
7564 end
7565  
7566  
7567  
7568 function NuN_PreDeleteMapIndex(id, cont, zone)
7569 local nKey, lstKey, curZ, lstEntry;
7570  
7571 if ( MetaMapNotes_OnLoad ) then
7572 curZ = MetaMapNotes_Data;
7573 elseif ( MapNotes_OnLoad ) then
7574 curZ = MapNotes_Data;
7575 end
7576  
7577 if ( ( not cont ) or ( cont < 1 ) or ( not zone ) or ( zone < 1 ) ) then
7578 cont = GetCurrentMapContinent();
7579 if ( cont == -1 ) then
7580 cont = GetRealZoneText();
7581 zone = 0;
7582 curZ = curZ[cont];
7583 elseif ( cont == 0 ) then
7584 return 0, 0, 0;
7585 else
7586 if ( MetaMapNotes_OnLoad ) then
7587 zone = MetaMapNotes_ZoneShift[cont][GetCurrentMapZone()];
7588 elseif ( MapNotes_OnLoad ) then
7589 zone = MapNotes_ZoneShift[cont][GetCurrentMapZone()];
7590 end
7591 if ( ( not zone ) or ( zone < 1 ) ) then
7592 return 0, 0, 0;
7593 end
7594 curZ = curZ[cont][zone];
7595 end
7596 end
7597  
7598 lstEntry = NuN_GetZoneTableSize(curZ);
7599 return cont, zone, lstEntry;
7600 end
7601  
7602 -- Called when a MapNote is deleted
7603  
7604 function NuN_DeleteMapIndex(id, cont, zone, lstEntry)
7605 local nKey = cont.."-"..zone.."-"..id;
7606 local lstKey = cont.."-"..zone.."-"..lstEntry;
7607 if ( NuNData[mrgIndex][nKey] ) then
7608 NuNData[mrgIndex][nKey] = nil;
7609 end
7610 if ( ( lstEntry ~= 0 ) and ( nKey ~= lstKey ) and ( NuNData[mrgIndex][lstKey] ) ) then
7611 local index, value;
7612 NuNData[mrgIndex][nKey] = {};
7613 for index, value in NuNData[mrgIndex][lstKey] do
7614 NuNData[mrgIndex][nKey][index] = NuNData[mrgIndex][lstKey][index];
7615 end
7616 NuNData[mrgIndex][lstKey] = nil;
7617 end
7618 end
7619  
7620  
7621  
7622 -- Called when Alt-Right Clicking on a button in the Popup to remove a single NuN - MapNote link
7623  
7624 function NuN_DeleteMapIndexNote(id, noteN)
7625 local cont = GetCurrentMapContinent();
7626 if ( cont == -1 ) then
7627 cont = GetRealZoneText();
7628 zone = 0;
7629 elseif ( cont == 0 ) then
7630 return;
7631 else
7632 if ( MetaMapNotes_OnLoad ) then
7633 zone = MetaMapNotes_ZoneShift[cont][GetCurrentMapZone()];
7634 elseif ( MapNotes_OnLoad ) then
7635 zone = MapNotes_ZoneShift[cont][GetCurrentMapZone()];
7636 end
7637 if ( ( not zone ) or ( zone < 1 ) ) then
7638 return;
7639 end
7640 end
7641 local nKey = cont.."-"..zone.."-"..id;
7642 if ( ( NuNData[mrgIndex][nKey] ) and ( NuNData[mrgIndex][nKey][noteN] ) ) then
7643 NuNData[mrgIndex][nKey][noteN] = nil;
7644 NuNData[mrgIndex][nKey].noteCounter = NuNData[mrgIndex][nKey].noteCounter - 1;
7645 if ( NuNData[mrgIndex][nKey].noteCounter < 1 ) then
7646 NuNData[mrgIndex][nKey] = nil;
7647 end
7648 end
7649 WorldMapTooltip:Hide();
7650 NuNPopup:Hide();
7651 NuN_MapTooltip:Hide();
7652 end
7653  
7654  
7655  
7656 function NuN_MapIndexHouseKeeping()
7657 local MNindex, MNvalue;
7658  
7659 if ( ( MetaMapNotes_OnLoad ) and ( MapNotes_OnLoad ) ) then
7660 return;
7661 end
7662  
7663 for MNindex, MNvalue in NuNData[mrgIndex] do
7664 local valid = NuN_ExtractMapNotesInfo(MNindex);
7665 if ( not valid ) then
7666 NuNData[mrgIndex][MNindex] = nil;
7667 end
7668 end
7669 end
7670  
7671  
7672 function NuN_ExtractMapNotesInfo(nKey)
7673 local cont, zone, id;
7674 local sep = "-";
7675 local p, q;
7676  
7677 p = string.find(nKey, sep);
7678 if ( not p ) then
7679 return nil;
7680 end
7681 q = string.find(nKey, sep, (p+1));
7682 if ( not q ) then
7683 return nil;
7684 end
7685  
7686 cont = tonumber( string.sub(nKey, 1, (p-1)) );
7687 zone = tonumber( string.sub(nKey, (p+1), (q-1)) );
7688 id = tonumber( string.sub(nKey, (q+1)) );
7689  
7690 if ( MetaMapNotes_OnLoad ) then
7691 theData = MetaMapNotes_Data;
7692 elseif ( MapNotes_OnLoad ) then
7693 theData = MapNotes_Data;
7694 end
7695 if ( ( zone == 0 ) and ( theData[cont] ) and ( theData[cont][id] ) ) then
7696 return true;
7697 elseif ( ( theData[cont] ) and ( theData[cont][zone] ) and ( theData[cont][zone][id] ) ) then
7698 return true;
7699 else
7700 return nil;
7701 end
7702 end
7703  
7704  
7705  
7706 function NuN_ValidateMapNotesVersion()
7707 if ( MAPNOTES_VERSION ) then
7708 local MNVersion = MAPNOTES_VERSION;
7709 for i = 1, getn(NuN_MapNotesValidVersions), 1 do
7710 if ( NuN_MapNotesValidVersions[1] == MNVersion ) then
7711 return true;
7712 end
7713 end
7714 if ( NuNSettings[pKey].mapNotesPlayedVersions ) then
7715 local vs = getn(NuNSettings[pKey].mapNotesPlayedVersions);
7716 for i = 1, vs, 1 do
7717 if ( NuNSettings[pKey].mapNotesPlayedVersions[i] == MNVersion ) then
7718 return true;
7719 end
7720 end
7721 vs = vs + 1;
7722 NuNSettings[pKey].mapNotesPlayedVersions[vs] = MNVersion;
7723 else
7724 NuNSettings[pKey].mapNotesPlayedVersions = {};
7725 NuNSettings[pKey].mapNotesPlayedVersions[1] = MNVersion;
7726 end
7727 end
7728 return nil;
7729 end
7730  
7731  
7732  
7733 function NuN_NotInfiniteIgored(ctact)
7734 ctact = string.lower(ctact);
7735 if ( ( InfinateIgnore_Config ) and ( InfinateIgnore_Config[pKey] ) and ( InfinateIgnore_Config[pKey].Ignoring ) and ( InfinateIgnore_Config[pKey].Ignoring[ctact] ) ) then
7736 return nil;
7737 end
7738 return true;
7739 end
7740  
7741  
7742  
7743  
7744 function NuN_SaveLast(saveType)
7745 NuN_LastOpen.type = saveType;
7746 if ( saveType == "Contact" ) then
7747 NuN_LastOpen.name = c_name;
7748 elseif ( saveType == "General" ) then
7749 NuN_LastOpen.note = c_note;
7750 end
7751 end
7752  
7753  
7754 function NuN_ReOpen()
7755 if ( NuN_LastOpen.type ) then
7756 if ( NuN_LastOpen.type == "Contact" ) then
7757 if ( NuNData[pKey][NuN_LastOpen.name] ) then
7758 NuN_ShowSavedNote(NuN_LastOpen.name);
7759 end
7760 elseif ( NuN_LastOpen.type == "General" ) then
7761 if ( ( NuNData[pKey][Notes][NuN_LastOpen.note] ) or ( NuNData[Notes][NuN_LastOpen.note] ) ) then
7762 c_note = NuN_LastOpen.note;
7763 NuN_ShowSavedGNote();
7764 end
7765 end
7766 end
7767 end
7768  
7769  
7770  
7771 function NuN_RunButton_OnClick()
7772 local script = NuNGNoteTextScroll:GetText();
7773  
7774 RunScript(script);
7775 end
7776  
7777 function NuN_RunButton_OnEnter()
7778 if ( NuNSettings[pKey].toolTips ) then
7779 NuN_Fade = "False";
7780 local x, y = GetCursorPosition();
7781 if ( x > 500 ) then
7782 NuN_Tooltip:SetOwner(this, "ANCHOR_RIGHT");
7783 else
7784 NuN_Tooltip:SetOwner(this, "ANCHOR_LEFT");
7785 end
7786 NuN_Tooltip:ClearLines();
7787 NuN_Tooltip:AddLine(NUN_TT_RUN_TXT1, 1, 0.7, 0);
7788 NuN_Tooltip:AddLine(NUN_TT_RUN_TXT2, 0, 1, 0);
7789 NuN_Tooltip:Show();
7790 end
7791 end
7792  
7793  
7794  
7795 function NuN_GetTipAnchor(theTT)
7796 local anchorBy, anchorTo;
7797 local x1, y1 = theTT:GetCenter();
7798 local x2, y2 = UIParent:GetCenter();
7799  
7800 if ( theTT == ShoppingTooltip1 ) then
7801 anchorBy = "TOPLEFT";
7802 anchorTo = "TOPRIGHT";
7803 return anchorBy, anchorTo;
7804 elseif ( theTT == ShoppingTooltip2 ) then
7805 anchorBy = "TOPLEFT";
7806 anchorTo = "BOTTOMLEFT";
7807 return anchorBy, anchorTo;
7808 end
7809  
7810 if ( ( not x1 ) or ( not y1 ) ) then
7811 anchorBy = "BOTTOMRIGHT";
7812 anchorTo = "BOTTOMLEFT";
7813 else
7814 if ( y1 > y2 ) then
7815 if ( x1 > x2 ) then
7816 anchorBy = "TOPRIGHT";
7817 anchorTo = "TOPLEFT";
7818 else
7819 anchorBy = "TOPLEFT";
7820 anchorTo = "TOPRIGHT";
7821 end
7822 else
7823 if ( x1 > x2 ) then
7824 anchorBy = "BOTTOMRIGHT";
7825 anchorTo = "BOTTOMLEFT";
7826 else
7827 anchorBy = "BOTTOMLEFT";
7828 anchorTo = "BOTTOMRIGHT";
7829 end
7830 end
7831 end
7832  
7833 return anchorBy, anchorTo;
7834 end
7835  
7836  
7837  
7838  
7839 --------------------------------------------------------------------------------
7840  
7841 function NuN_LocaliseDateStamp(dateStamp)
7842 if ( ( GetLocale() ~= "enUS" ) and ( NUN_DAY_LIST ) and ( NUN_MONTH_LIST ) ) then
7843 dateStamp = string.gsub(dateStamp, "Monday", NUN_DAY_LIST[1]);
7844 dateStamp = string.gsub(dateStamp, "Tuesday", NUN_DAY_LIST[2]);
7845 dateStamp = string.gsub(dateStamp, "Wednesday", NUN_DAY_LIST[3]);
7846 dateStamp = string.gsub(dateStamp, "Thursday", NUN_DAY_LIST[4]);
7847 dateStamp = string.gsub(dateStamp, "Friday", NUN_DAY_LIST[5]);
7848 dateStamp = string.gsub(dateStamp, "Saturday", NUN_DAY_LIST[6]);
7849 dateStamp = string.gsub(dateStamp, "Sunday", NUN_DAY_LIST[7]);
7850 dateStamp = string.gsub(dateStamp, "January", NUN_MONTH_LIST[1]);
7851 dateStamp = string.gsub(dateStamp, "February", NUN_MONTH_LIST[2]);
7852 dateStamp = string.gsub(dateStamp, "March", NUN_MONTH_LIST[3]);
7853 dateStamp = string.gsub(dateStamp, "April", NUN_MONTH_LIST[4]);
7854 dateStamp = string.gsub(dateStamp, "May", NUN_MONTH_LIST[5]);
7855 dateStamp = string.gsub(dateStamp, "June", NUN_MONTH_LIST[6]);
7856 dateStamp = string.gsub(dateStamp, "July", NUN_MONTH_LIST[7]);
7857 dateStamp = string.gsub(dateStamp, "August", NUN_MONTH_LIST[8]);
7858 dateStamp = string.gsub(dateStamp, "September", NUN_MONTH_LIST[9]);
7859 dateStamp = string.gsub(dateStamp, "October", NUN_MONTH_LIST[10]);
7860 dateStamp = string.gsub(dateStamp, "November", NUN_MONTH_LIST[11]);
7861 dateStamp = string.gsub(dateStamp, "December", NUN_MONTH_LIST[12]);
7862 end
7863 return dateStamp;
7864 end
7865  
7866 --------------------------------------------------------------------------------
7867  
7868 function NuN_LangPatch(langDirection)
7869 local toDeutschAR = {
7870 4,
7871 1,
7872 2,
7873 3
7874 }
7875  
7876 local toDeutschHC = {
7877 1,
7878 3,
7879 5,
7880 6,
7881 8,
7882 7,
7883 2,
7884 4
7885 }
7886  
7887 local toDeutschAC = {
7888 1,
7889 3,
7890 5,
7891 6,
7892 7,
7893 8,
7894 2,
7895 4
7896 }
7897  
7898 local toDeutschP = {
7899 1,
7900 12,
7901 13,
7902 14,
7903 15,
7904 16,
7905 18,
7906 3,
7907 4,
7908 5,
7909 6,
7910 8,
7911 9,
7912 10,
7913 11,
7914 2,
7915 7,
7916 17
7917 }
7918 local index, value;
7919  
7920 if ( NuNData[pKey] ) then
7921 if ( langDirection == "->de" ) then
7922 for index, value in NuNData[pKey] do
7923 if ( NuNData[pKey][index].faction ) then
7924 if ( NuNData[pKey][index].faction == "Horde" ) then
7925 if ( NuNData[pKey][index].cls ) then
7926 NuNData[pKey][index].cls = toDeutschHC[NuNData[pKey][index].cls];
7927 end
7928 else
7929 if ( NuNData[pKey][index].race ) then
7930 NuNData[pKey][index].race = toDeutschAR[NuNData[pKey][index].race];
7931 end
7932 if ( NuNData[pKey][index].cls ) then
7933 NuNData[pKey][index].cls = toDeutschAC[NuNData[pKey][index].cls];
7934 end
7935 end
7936 if ( NuNData[pKey][index].prof1 ) then
7937 NuNData[pKey][index].prof1 = toDeutschP[NuNData[pKey][index].prof1];
7938 end
7939 if ( NuNData[pKey][index].prof2 ) then
7940 NuNData[pKey][index].prof2 = toDeutschP[NuNData[pKey][index].prof2];
7941 end
7942 end
7943 end
7944 elseif ( langDirection == "->en" ) then
7945 for index, value in NuNData[pKey] do
7946 if ( NuNData[pKey][index].faction ) then
7947 if ( NuNData[pKey][index].faction == "Horde" ) then
7948 if ( NuNData[pKey][index].cls ) then
7949 NuNData[pKey][index].cls = NuNGet_TableID(toDeutschHC, NuNData[pKey][index].cls);
7950 end
7951 else
7952 if ( NuNData[pKey][index].race ) then
7953 NuNData[pKey][index].race = NuNGet_TableID(toDeutschAR, NuNData[pKey][index].race);
7954 end
7955 if ( NuNData[pKey][index].cls ) then
7956 NuNData[pKey][index].cls = NuNGet_TableID(toDeutschAC, NuNData[pKey][index].cls);
7957 end
7958 end
7959 if ( NuNData[pKey][index].prof1 ) then
7960 NuNData[pKey][index].prof1 = NuNGet_TableID(toDeutschP, NuNData[pKey][index].prof1);
7961 end
7962 if ( NuNData[pKey][index].prof2 ) then
7963 NuNData[pKey][index].prof2 = NuNGet_TableID(toDeutschP, NuNData[pKey][index].prof2);
7964 end
7965 end
7966 end
7967 end
7968 end
7969 end
7970  
7971