vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1  
2 BWP_NAME = "MetaMapBWP";
3 BWP_IMAGE_PATH = "Interface\\AddOns\\MetaMapBWP\\Artwork\\Arrows\\"
4 BWP_BUTTON_HEIGHT = 16;
5 BWP_BUTTON_COUNT = 11;
6  
7 BWP_Options = {};
8 BWP_Data = {};
9 BWP_CZone = {};
10 BWP_Destination = nil;
11 BWP_Data["Kalimdor"] = {};
12 BWP_Data["Eastern Kingdoms"] = {};
13  
14 local BWPnode = {};
15 local BWPmeta = {};
16 local BWPDisp = {};
17 local BWPDispm = {};
18  
19 BWP_CountDown = 0;
20 BWP_SetDist = 0;
21 BWP_ArrowIcon = nil;
22 BWP_playerIsDead = false;
23 BWP_GuardActive = false;
24  
25 BWP_Highlighttext ="|cffFFFFFF";
26 BWP_Redtext="|cffFF0000";
27 BWP_Greentext = "|cff00FF00";
28  
29 local BWP_Zones = {};
30 local BWP_KalimdorZones = {};
31 local BWP_EasternZones = {};
32 local BWP_Player = nil;
33 local BWP_SetSpecial = false;
34 local BWP_SpecialDest = 0;
35 local old_ToggleDropDownMenu = ToggleDropDownMenu;
36 local Old_AbandonQuest = AbandonQuest
37 oldBWPFOLLOW_UnitPopup_OnClick = UnitPopup_OnClick
38 -- Query redirect
39 BWPDispm.__index = SNDisp;
40 -- Query redirect
41 BWPmeta.__index = BWPnode;
42 local BWP_FirstLoad = true;
43 local gdpx, gdpy, gddx, gddy, gddir, gdclx, gdcly;
44 --Map Variables below
45 local MAX_LOC_SAMPLES = 50;-- Circular arrays to store X,Y,time locations
46 local LOC_X_SAMPLES = {};
47 local LOC_Y_SAMPLES = {};
48 local LOC_T_SAMPLES = {};
49 -- The last index written into
50 local lastIdx = 0;
51 -- Last coordinates, used to avoid spamming location arrays
52 local lastX,lastY = 0,0;
53 -- Configuration/thresholds -- Tune these together with coordinate
54 -- system for a balance of update speed and jitter reduction
55 -- Make sure that MIN_CUMUL_RANGE is at least 2 times as large as
56 -- MIN_SAMPLE_DISTANCE (Preferably between about 3-10 times)
57 -- Minimum change in at least one direction to store something
58 local MIN_SAMPLE_DISTANCE = 0.0001;
59 -- Maximum age of an old record to look at
60 local MAX_CUMUL_TIME = 2.0;
61 -- Minimum range for a significant vector
62 local MIN_CUMUL_RANGE = 0.0003;
63 -- Square of minimum range to avoid an unnecessary sqrt
64 local MIN_CUMUL_RANGE_SQ = MIN_CUMUL_RANGE * MIN_CUMUL_RANGE;
65 -- Last degree value, just here for debugging sanity
66 local lastDeg = nil;
67  
68 function BWP_SetVars()
69 if(BWP_Options.ShowYards == nil) then BWP_Options.ShowYards = false; end
70 if(BWP_Options.ShowCorpse == nil) then BWP_Options.ShowCorpse = false; end
71 if(BWP_Options.ShowOnGuard == nil) then BWP_Options.ShowOnGuard = false; end
72 if(BWP_Options.SetAlpha == nil) then BWP_Options.SetAlpha = 1.0; end
73 if(BWP_Options.SetDistance == nil) then BWP_Options.SetDistance = 0.0040; end
74 if(BWP_Options.ShowPoints == nil) then BWP_Options.ShowPoints = true; end
75 if(BWP_Options.ShowNPC == nil) then BWP_Options.ShowNPC = true; end
76 if(BWP_Options.ClearDest == nil) then BWP_Options.ClearDest = true; end
77 end
78  
79 function BWP_OnLoad()
80 SLASH_BWPCOMMAND1 = "/bwp";
81 SlashCmdList["BWPCOMMAND"] = BWP_LocCommand
82 this:RegisterEvent("ADDON_LOADED");
83 this:RegisterEvent("WORLD_MAP_UPDATE");
84 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
85 this:RegisterEvent("CHAT_MSG_SYSTEM");
86 this:RegisterEvent("QUEST_GREETING");
87 this:RegisterEvent("UNIT_NAME_UPDATE");
88 this:RegisterEvent("QUEST_COMPLETE");
89 this:RegisterEvent("QUEST_FINISHED");
90 this:RegisterEvent("QUEST_GREETING");
91 this:RegisterEvent("QUEST_ACCEPT_CONFIRM");
92 this:RegisterEvent("GOSSIP_CLOSED");
93 this:RegisterEvent("PLAYER_DEAD");
94 table.insert(UnitPopupMenus["PLAYER"],"BWPFOLLOW")
95 table.insert(UnitPopupMenus["PARTY"],"BWPFOLLOW")
96 table.insert(UnitPopupMenus["RAID"],"BWPFOLLOW")
97 UnitPopupButtons["BWPFOLLOW"] = { text = "Set As Waypoint", dist = 0 }
98 end
99  
100 function BWP_OnEvent(event)
101 if(event == "ADDON_LOADED") then
102 BWP_SetVars()
103 BWP_OptionsInit();
104 BWP_Generate()
105 MetaKBMenu_RBSelect = BWP_ShowKBMenu;
106 MetaMapNotes_RBSelect = BWP_ShowNoteMenu;
107 end
108 if(event == "ZONE_CHANGED_NEW_AREA" or event == "PLAYER_ENTERING_WORLD") then
109 BWP_OptionsInit();
110 end
111 if (event == "UNIT_NAME_UPDATE" and arg1 == "player") then
112 if (BWP_FirstLoad) then
113 BWP_Player = UnitName("player");
114 if (playerName ~= UNKNOWNOBJECT) then
115 BWP_FirstLoad = nil;
116 end
117 end
118 end
119 if(event == "GOSSIP_CLOSED") then
120 BWP_SetSpecial = true;
121 BWP_SpecialDest = 2;
122 end
123 if(event == "QUEST_COMPLETE") then
124 local title = GetTitleText() or "";
125 clearquest(title)
126 end
127 if(strsub(event,1,16) == "CHAT_MSG_SYSTEM") then
128 local msg = arg1;
129 local plr = arg2;
130 if ( (msg and msg ~= nil) and (plr and plr ~= nil) ) then
131 local _,_,questname = string.find(msg,"Quest accepted: (.*)")
132 if(questname) then
133 BWP_AddQuest(questname)
134 end
135 end
136 end
137 end
138  
139 function BWP_OnUpdate(arg)
140 if(UnitIsDeadOrGhost("player")) then
141 DeadMan();
142 else
143 BWP_Alive();
144 end
145 if(BWP_SetSpecial) then BWP_Special_Dest(); end
146  
147 if(BWP_CountDown > 0) then
148 BWP_CountDown = BWP_CountDown - 1;
149 if(BWP_CountDown == 1 and BWP_Options.ClearDest) then
150 BWP_CountDown = 0;
151 if(BWP_SpecialDest) then
152 BWP_SpecialOff();
153 else
154 BWP_ClearDest();
155 end
156 end
157 return;
158 end
159 if(BWP_Destination) then
160 local UpdateBWP = BWP_GetDir();
161 if(UpdateBWP) then BWP_SetRotation(UpdateBWP); end
162 BWPDistanceText:SetText(BWP_GetDistText())
163 end
164 end
165  
166 function BWP_LocCommand(msg)
167 local name = "QuickLoc";
168 local i,j,x,y,tmp = string.find(msg,"%s*(%d+)%s*[,.]%s*(%d+)%s*([^%c]*)");
169 if(x == nil or y == nil) then
170 SetMapToCurrentZone();
171 x, y = GetPlayerMapPosition("player");
172 if(msg ~= "" and msg ~= nil) then
173 name = msg;
174 end
175 else
176 x = x / 100;
177 y = y / 100;
178 if(tmp ~= "" and tmp ~= nil) then
179 name = tmp;
180 end
181 end
182 setmininote(x, y, name, 7);
183 BWP_OptionsInit();
184 end
185  
186 function BWP_SelectionDropDown_OnLoad()
187 UIDropDownMenu_Initialize(BWP_OptionsDropDown, BWP_DropDownFrame_Initialize );
188 UIDropDownMenu_SetWidth(80);
189 end
190  
191 function ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset)
192 if(this:GetParent()) and (this:GetParent():GetName())and(this:GetParent():GetName()== "BWP_MenuFrame_DropDown")then
193 BWP_MenuFrame:Show();
194 old_ToggleDropDownMenu(level, value, dropDownFrame,"BWP_MenuFrame", xOffset, yOffset)
195 else
196 old_ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset)
197 BWP_MenuFrame:Hide();
198 end
199 return nil
200 end
201  
202 function BWP_OptionsInit()
203 if(BWP_Options.SetAlpha < 0.15) then BWP_Options.SetAlpha = 0.15; end
204 BWP_DistanceSlider:SetValue(BWP_Options.SetDistance);
205 BWP_AlphaSlider:SetValue(BWP_Options.SetAlpha);
206 if(BWP_Destination and BWP_Destination.zone == GetRealZoneText()) then
207 BWPDestText:SetText("("..BWP_Destination.name..")");
208 BWPDistanceText:SetText(BWP_GetDistText())
209 BWP_DisplayFrame:Show();
210 else
211 BWP_DisplayFrame:Hide();
212 end
213 end
214  
215 function MetaMapBWP_UpdateDistance()
216 BWP_Options.SetDistance = this:GetValue();
217 local dist = MetaMap_round(this:GetValue() * 4000)
218 BWP_SetDistText:SetText(dist);
219 end
220  
221 function MetaMapBWP_UpdateAlpha()
222 BWP_Options.SetAlpha = this:GetValue();
223 BWP_DisplayFrame:SetAlpha(BWP_Options.SetAlpha);
224 end
225  
226 function MetaMapBWPMenu_Init()
227 local items = 0;
228 for i=1, BWP_BUTTON_COUNT, 1 do
229 local button = getglobal("MetaMapBWPMenu_Option"..i);
230 button:SetHeight(BWP_BUTTON_HEIGHT);
231 if(i == 1) then
232 button:SetText("Always load on startup");
233 button.toggle = MetaMapOptions.BWPalwaysOn;
234 elseif(i == 2) then
235 button:SetText(BWP_SHOW_CORPSE);
236 button.toggle = BWP_Options.ShowCorpse;
237 elseif(i == 3) then
238 button:SetText(BWP_SHOW_GUARD);
239 button.toggle = BWP_Options.ShowOnGuard;
240 elseif(i == 4) then
241 button:SetText(BWP_SHOW_QNPC);
242 button.toggle = BWP_Options.ShowNPC;
243 elseif(i == 5) then
244 button:SetText(BWP_SHOW_MAPPOINTS);
245 button.toggle = BWP_Options.ShowPoints;
246 elseif(i == 6) then
247 button:SetText(BWP_CLEAR_ARRIVE);
248 button.toggle = BWP_Options.ClearDest;
249 elseif(i == 7) then
250 if(BWP_Options.ShowYards) then
251 button:SetText(BWP_SHOW_METRES);
252 else
253 button:SetText(BWP_SHOW_YARDS);
254 end
255 button.toggle = false;
256 elseif(i == 8) then
257 button:SetHeight(10); -- Spacer
258 elseif(i == 9) then
259 button:SetText(BWP_CLEAR_DEST);
260 button.toggle = false;
261 elseif(i == 10) then
262 button:SetHeight(0); -- Spare
263 button.toggle = false;
264 elseif(i == 11) then
265 button:SetHeight(0); -- Spare
266 button.toggle = false;
267 end
268 if(button.toggle) then
269 getglobal("MetaMapBWPMenu_Option"..i.."Check"):Show();
270 else
271 getglobal("MetaMapBWPMenu_Option"..i.."Check"):Hide();
272 end
273 button:Show();
274 items = i;
275 end
276 MetaMapBWPMenu:ClearAllPoints();
277 local yPos = "TOP";
278 local xPos = "RIGHT";
279 local x, y = GetCursorPosition();
280 x = x / UIParent:GetEffectiveScale() +15;
281 y = y / UIParent:GetEffectiveScale() +15;
282 if(y <= (UIParent:GetHeight() /2)) then yPos = "BOTTOM"; y = y +50; end
283 if(x <= (UIParent:GetHeight() /2)) then xPos = "LEFT"; x = x -30; end
284 MetaMapBWPMenu:SetPoint(yPos..xPos, "UIParent", "BOTTOMLEFT", x, y);
285 MetaMapBWPMenu:SetHeight((BWP_BUTTON_HEIGHT *items) + (BWP_BUTTON_HEIGHT *2));
286 PlaySound("UChatScrollButton");
287 MetaMapBWPMenu:Show();
288 end
289  
290 function MetaMapBWPMenu_Select(id)
291 local button = getglobal("MetaMapBWPMenu_Option"..id);
292 if(id == 1) then
293 MetaMapOptions.BWPalwaysOn = not MetaMapOptions.BWPalwaysOn;
294 button.toggle = MetaMapOptions.BWPalwaysOn;
295 elseif(id == 2) then
296 BWP_Options.ShowCorpse = not BWP_Options.ShowCorpse;
297 button.toggle = BWP_Options.ShowCorpse;
298 elseif(id == 3) then
299 BWP_Options.ShowOnGuard = not BWP_Options.ShowOnGuard;
300 button.toggle = BWP_Options.ShowOnGuard;
301 elseif(id == 4) then
302 BWP_Options.ShowNPC = not BWP_Options.ShowNPC;
303 button.toggle = BWP_Options.ShowNPC;
304 elseif(id == 5) then
305 BWP_Options.ShowPoints = not BWP_Options.ShowPoints;
306 elseif(id == 6) then
307 BWP_Options.ClearDest = not BWP_Options.ClearDest;
308 button.toggle = BWP_Options.ClearDest;
309 elseif(id == 7) then
310 BWP_Options.ShowYards = not BWP_Options.ShowYards;
311 if(BWP_Options.ShowYards) then
312 button:SetText(BWP_SHOW_METRES);
313 else
314 button:SetText(BWP_SHOW_YARDS);
315 end
316 button.toggle = false;
317 elseif(id == 8) then
318 -- Spacer
319 elseif(id == 9) then
320 BWP_ClearDest();
321 button.toggle = false;
322 elseif(id == 10) then
323 -- spare
324 elseif(id == 11) then
325 -- spare
326 end
327 if(button.toggle) then
328 getglobal("MetaMapBWPMenu_Option"..id.."Check"):Show();
329 else
330 getglobal("MetaMapBWPMenu_Option"..id.."Check"):Hide();
331 end
332 BWP_OptionsInit()
333 end
334  
335 function MetaMapBWPMenu_OnUpdate()
336 if (MetaMapBWPMenu:IsVisible()) then
337 if (not MouseIsOver(MetaMapBWPMenu) and not MouseIsOver(MetaMapBWPMenuSliderMenu)) then
338 MetaMapBWPMenu:Hide();
339 end
340 end
341 end
342  
343 function BWP_SetDest() --Sets the current Destination
344 if(this.value.QuestGiver) then
345 UIDropDownMenu_SetText(this.value.QuestGiver, BWP_MenuFrame_DropDown)
346 setmininote(this.value.X,this.value.Y,this.value.QuestGiver,"7")
347 elseif(this.value.title) then
348 UIDropDownMenu_SetText(this.value.title, BWP_MenuFrame_DropDown)
349 setmininote(this.value.xcoord, this.value.ycoord,this.value.title,"7")
350 end
351 BWP_OptionsInit();
352 end
353  
354 function BWP_GetDistText()
355 local px , py = GetPlayerMapPosition("player")
356 if(px == 0 and py==0) then
357 return "Dead Zone";
358 end
359 local dx, dy = nil,nil
360 if(BWP_Destination and BWP_Destination.x and BWP_Destination.y) then
361 dx, dy = BWP_Destination.x, BWP_Destination.y
362 else
363 return nil
364 end
365 local loc1,loc2 = {x = px , y= py},{x=dx,y=dy}
366 local thisDistance, theseUnits , flag = BWP_FormatDist(loc1,loc2)
367 if (flag == "A") then
368 return BWPGreenText("("..BWP_ARRIVED..")")
369 elseif flag == "Y" then
370 return "("..thisDistance..theseUnits..")"
371 end
372 local colortext = getglobal("BWP"..flag.."Text")
373 local testtext = colortext(thisDistance..theseUnits)
374 return "("..testtext..")"
375 end
376  
377 function DeadMan()
378 if(BWP_playerIsDead) then return; end
379 deadx, deady = GetCorpseMapPosition();
380 deadx = deadx * 100; deady = deady * 100;
381 if(deadx and deady and deadx ~= 0 and deady ~= 0) then
382 if(BWP_Destination) then
383 BWP_OldDest = BWP_Destination;
384 end
385 BWP_playerIsDead = true;
386 if(BWP_Options.ShowCorpse) then
387 setmininote(deadx, deady, BWP_CORPSE_TEXT , "7");
388 else
389 BWP_DisplayFrame:Hide();
390 end
391 end
392 end
393  
394 function BWP_Alive()
395 if(not BWP_playerIsDead) then return; end
396 if(BWP_OldDest)then
397 local continent, zone = MetaMap_NameToZoneID(BWP_OldDest.zone);
398 setmininote(BWP_OldDest.x, BWP_OldDest.y, BWP_OldDest.name, "7", continent, zone);
399 BWP_OldDest = nil;
400 BWP_playerIsDead = false;
401 elseif(BWP_playerIsDead)then
402 BWP_playerIsDead = false;
403 BWP_ClearDest();
404 end
405 end
406  
407 function BWP_SpecialOff()
408 if(BWP_OldDest)then
409 local continent, zone = MetaMap_NameToZoneID(BWP_OldDest.zone);
410 setmininote(BWP_OldDest.x, BWP_OldDest.y, BWP_OldDest.name, "7", continent, zone);
411 BWP_OldDest = nil;
412 else
413 BWP_ClearDest();
414 end
415 BWP_SpecialDest = 0;
416 end
417  
418 function UnitPopup_OnClick()
419 if UnitPopupMenus[this.owner][this.value]=="BWPFOLLOW" then
420 BWPFOLLOW_Name = UnitName(getglobal(UIDROPDOWNMENU_INIT_MENU).unit)
421 if(not BWPFOLLOWPLAYER) then
422 BWP_TargetPlayer = string.lower(BWPFOLLOW_Name);
423 BWP_SetSpecial = true;
424 BWP_SpecialDest = 1
425 BWPFOLLOWPLAYER = 1
426 DEFAULT_CHAT_FRAME:AddMessage("Now Following "..BWPFOLLOW_Name)
427 UnitPopupButtons["BWPFOLLOW"] = { text = "Stop Following", dist = 0 }
428 else
429 BWPFOLLOWPLAYER = nil
430 BWP_SetSpecial = false;
431 BWP_SpecialDest = 0;
432 BWP_ClearDest()
433 DEFAULT_CHAT_FRAME:AddMessage("No Longer Following "..BWPFOLLOW_Name)
434 UnitPopupButtons["BWPFOLLOW"] = { text = "Set As Waypoint", dist = 0 }
435 end
436 end
437 oldBWPFOLLOW_UnitPopup_OnClick()
438 end
439  
440 function BWP_DropDownFrame_Initialize() --Create Dropdown
441 if( UIDROPDOWNMENU_MENU_LEVEL == 1) then
442 descript = {};
443 descript.text = BWPGreenText("-"..BWP_NAME.." "..BWP_OPTION_TEXT.."-")
444 descript.func = BWP_ShowOptions;
445 UIDropDownMenu_AddButton(descript)
446  
447 info = {}
448 info.text = BWP_SELECTMSG
449 info.notClickable = 1;
450 info.isTitle = 1;
451 info.notCheckable = 1;
452 UIDropDownMenu_AddButton(info);
453 local x, y = GetPlayerMapPosition("player");
454 if(x == 0 and y == 0)then
455 --Header
456 info = {
457 text = BWP_NILLOCATION;
458 notClickable = 1;
459 isTitle = 1;
460 notCheckable = 1; }
461 UIDropDownMenu_AddButton(info);
462 return;
463 end
464 end
465 BWP_Generate();
466 bwpx,bwpy = nil,nil
467 local BWP_BREAK_IT_DOWN = nil
468 if(BWP_numpoints() > 20) then BWP_BREAK_IT_DOWN = 1 end
469 if(BWP_Options.ShowPoints) then
470 if(not BWP_BREAK_IT_DOWN) or ( UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
471 local ZonePoints = {nil}
472 local isExtra = nil
473 if(this.value == "BWP_CZone") then
474 ZonePoints = getglobal(this.value)
475 elseif(this.value) and (BWP_CZone_XTRA) and (BWP_CZone_XTRA[this.value])then
476 ZonePoints = BWP_CZone_XTRA[this.value]
477 elseif(not this.value) then
478 ZonePoints = BWP_CZone
479 end
480 if(ZonePoints) then
481 for val,k in ZonePoints do
482 if(k) then
483 title = ZonePoints[val].title;
484 end
485 if (strlen(title) >= 24) then
486 title = strsub(title, 1, 21).."...";
487 end
488 if (title == "") then
489 title = SN_CZone[val]:getNote1();
490 end
491 descript = {}
492 descript.text = val..". "..title;
493 descript.func = BWP_SetDest;
494 descript.value = k;
495 descript.notCheckable = 1;
496 UIDropDownMenu_AddButton(descript, UIDROPDOWNMENU_MENU_LEVEL);
497 end
498 end
499 else --Break It Down Too many Points
500 info = {};
501 info.text = BWP_Get_MenuTitle(BWP_CZone);
502 info.hasArrow = 1;
503 info.value = "BWP_CZone";
504 UIDropDownMenu_AddButton(info);
505 if(BWP_CZone_XTRA) then
506 for k,v in BWP_CZone_XTRA do
507 if(BWP_Get_MenuTitle(v)) then
508 local info = {};
509 info.text = BWP_Get_MenuTitle(v);
510 info.hasArrow = 1;
511 info.value = k;
512 UIDropDownMenu_AddButton(info);
513 descript.notCheckable = 1;
514 end
515 end
516 end
517 end
518 end
519  
520 local LocalQList = BWP_GetQuestList()
521 if(LocalQList and BWP_Options.ShowNPC) then
522 if(not BWP_BREAK_IT_DOWN) or (( UIDROPDOWNMENU_MENU_LEVEL == 2 ) and (this.value == "Q")) then
523 table.sort(LocalQList,BWPSortByQuestGiverName)
524 local thisindex = 0
525 for v, thisquest in LocalQList do
526 if(thisquest) then
527 descript = {};--Make our menu Options
528 descript.text = BWP_NPC_TEXT..thisquest["QuestGiver"];
529 descript.func = BWP_SetDest;
530 descript.value = thisquest;
531 descript.notCheckable = 1;
532 UIDropDownMenu_AddButton(descript,UIDROPDOWNMENU_MENU_LEVEL );
533 end
534 end
535 elseif(UIDROPDOWNMENU_MENU_LEVEL == 1) then
536 local info = {};
537 local info = {};
538 info.text = BWP_QUEST_NPCSTRING ;
539 info.hasArrow = 1;
540 info.value = "Q";
541 descript.notCheckable = 1;
542 UIDropDownMenu_AddButton(info);
543 end
544 end
545 end
546  
547 function BWP_Get_MenuTitle(MList)
548 local tempstring = nil
549 local firstword,lastword = nil, nil
550 for k,v in MList do
551  
552 if(not tempstring) then -- if its our first word in the List
553 if(v.title) then
554 tempstring = v.title
555 elseif (v.QuestGiver) then
556 tempstring = v.QuestGiver
557 end --set tempstring(so it will have a value)
558 firstword = tempstring
559 else
560 if(v.title) then
561 tempstring = v.title
562 elseif (v.QuestGiver) then
563 tempstring = v.QuestGiver
564 end
565 end
566  
567 end
568 if(tempstring) and (firstword) then
569 lastword = strsub(tempstring, 1, 5)
570 firstword = strsub(firstword, 1, 5)
571 return "Notes: "..firstword.." - "..lastword
572 else return nil end
573 end
574  
575 function BWP_ShowOptions()
576 MetaMapBWPMenu_Init();
577 end
578  
579 function BWP_ClearDest() --Removes current destination
580 UIDropDownMenu_SetText(nil, BWP_MenuFrame_DropDown)
581 if(MiniNotePOI)then
582 MetaMapNotes_ClearMiniNote();
583 end
584 BWP_Destination = nil;
585 BWP_SetSpecial = false;
586 BWP_SpecialDest = 0;
587 if(BWPFOLLOWPLAYER)then BWPFOLLOWPLAYER = nil; UnitPopupButtons["BWPFOLLOW"] = { text = "Set As Waypoint", dist = 0 }; end
588 BWP_DisplayFrame:Hide();
589 BWP_Arrow:SetTexture(BWP_IMAGE_PATH.."forward");
590 end
591  
592 function BWPGreenText(inText) --TextOverride
593 if (inText) then
594 return BWP_Greentext..inText..FONT_COLOR_CODE_CLOSE;
595 end
596 end
597 function BWPRedText(inText) --Text Override
598 if (inText) then
599 return BWP_Redtext..inText..FONT_COLOR_CODE_CLOSE;
600 end
601 end
602 function BWPHilightText(inText) --Text Override
603 if (inText) then
604 return BWP_Highlighttext..inText..FONT_COLOR_CODE_CLOSE;
605 end
606 end
607  
608 function BWP_SpecialOn()
609 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
610 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
611 local name, unknown, textureIndex, x, y;
612 for landmarkIndex = 1, GetNumMapLandmarks(), 1 do
613 name, unknown, textureIndex, x, y = GetMapLandmarkInfo(landmarkIndex);
614 if (textureIndex == 6) then
615 if(BWP_Destination) then
616 BWP_OldDest = BWP_Destination;
617 end
618 setmininote(x, y, name, "7", continent, zone);
619 end
620 end
621 end
622  
623 function clearquest(title) --Removes a quest/questgiver
624 _,_,realtitle = string.find(title,".*%[%d%]% (.*)")
625 if(realtitle)then
626  
627 title = realtitle
628 end
629 if(BWP_QuestList)then
630 for v, thisquest in BWP_QuestList do
631 if(string.find(thisquest["QuestName"],title))then
632 if(thisquest["QuestName"] == title) then
633 if(BWP_Destination) and (thisquest["QuestGiver"] == BWP_Destination.name)then
634 BWP_ClearDest()
635 end
636  
637 BWP_QuestList[v]= nil
638 tempQuestlist = {}
639 local index = 1
640 for i,q in BWP_QuestList do
641 tempQuestlist[index] = q
642 index = index + 1
643 end
644 BWP_QuestList = tempQuestlist
645 else
646 BWPqnamestring=BWP_QuestList[v]["QuestName"]
647 _,_,tempstring1 = string.find(BWPqnamestring,"(.*)"..title)
648 _,_,tempstring2 = string.find(BWPqnamestring,".*"..title.."%,(.*)")
649 if(not tempstring1)and (tempstring2)then
650 BWPqnamestring = tempstring2
651 elseif(not tempstring2)and(tempstring1)then
652 BWPqnamestring = tempstring1
653 elseif(tempstring2) and (tempstring1) then
654 BWPqnamestring = tempstring1..tempstring2
655 else
656 DEFAULT_CHAT_FRAME:AddMessage("ERROR ON QUEST TURN IN:BWP[Unable to perform string operation]")
657 end
658 BWP_QuestList[v]["QuestName"]=BWPqnamestring
659 end
660 end
661 end
662 end
663 end
664  
665 function BWP_numpoints()
666 if(table.getn(BWP_CZone) > 20 ) then BWP_ChecknumPOI() end
667 local tempnum = 0
668 if(BWP_CZone) then
669 tempnum = table.getn(BWP_CZone)
670 end
671 if (BWP_CZone_XTRA) then
672 if(BWP_CZone_XTRA[1]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[1]) end
673 if(BWP_CZone_XTRA[2]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[2]) end
674 if(BWP_CZone_XTRA[3]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[3]) end
675 if(BWP_CZone_XTRA[4]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[4]) end
676 if(BWP_CZone_XTRA[5]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[5]) end
677 if(BWP_CZone_XTRA[6]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[6]) end
678 if(BWP_CZone_XTRA[7]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[7]) end
679 if(BWP_CZone_XTRA[8]) then tempnum = tempnum + table.getn(BWP_CZone_XTRA[8]) end -- max number of second menus
680 end
681 if(BWP_QuestList) then
682 for v, thisquest in BWP_QuestList do
683 if(thisquest)and(thisquest.Zone == GetCurrentMapZone())then
684 tempnum = tempnum + 1
685 end
686 end
687 end
688 return tempnum
689 end
690  
691 function BWP_Special_Dest()
692 if(BWPFOLLOWPLAYER)then
693 if(BWP_TargetPlayer) then
694 local bwpthisflag
695 local playeridindex = GetNumRaidMembers()
696 if (playeridindex == 0) then playeridindex = GetNumPartyMembers();bwpthisflag = nil else bwpthisflag = "R" end
697 if (playeridindex == 0 ) then
698 DEFAULT_CHAT_FRAME:AddMessage(BWPGROUPERROR)
699 BWP_SpecialDest = 0;
700 BWP_SetSpecial = false;
701 else
702 if(bwpthisflag) then -- if its a raid group
703 for x = 1, playeridindex do
704 local Rname, Rrank, Rsubgroup, Rlevel, Rclass, RfileName, Rzone, Ronline = GetRaidRosterInfo(x)
705 if (Rname) then
706 local tempuid = "raid"..x
707 if(string.lower(Rname) == BWP_TargetPlayer) then
708 BWP_TargetUnitID = tempuid
709  
710 elseif(x == 1) then --If the player wasnt found in the current group
711 DEFAULT_CHAT_FRAME:AddMessage(BWPGROUPERROR1)
712 BWP_SpecialDest = 0;
713 BWP_SetSpecial = false;
714 BWPFOLLOWPLAYER = nil
715 end
716 end
717 end
718 else -- its a normal PARTy
719 for x = 1,playeridindex do
720 if (GetPartyMember(x)) then --Doesnt work in Raid :(
721 local tempuid = "party"..x
722 if(string.lower(UnitName(tempuid)) == BWP_TargetPlayer) then
723 BWP_TargetUnitID = tempuid
724  
725 elseif(x == playeridindex) and (not BWP_TargetUnitID) then --If the player wasnt found in the current group
726 DEFAULT_CHAT_FRAME:AddMessage(BWPGROUPERROR2)
727 BWP_SpecialDest = 0;
728 BWP_SetSpecial = flase;
729 BWPFOLLOWPLAYER = nil;
730 end
731 end
732 end
733 end
734 if(BWP_TargetUnitID) then
735 local posX, posY = GetPlayerMapPosition(BWP_TargetUnitID)
736 BWP_TargetUnitID = nil
737 BWP_Destination = {
738 name = BWP_TargetPlayer,
739 x = posX ,
740 y = posY ,
741 zone = GetRealZoneText()}
742 BWP_SetRotation();
743 end
744 end
745 end
746 else
747 if(BWP_SpecialDest == 2) then
748 BWP_SetSpecial = false;
749 BWP_SpecialOn();
750 end
751 end
752 end
753  
754 function BWP_GetQuestList() -- Returns an Array of QuestNPC Data
755 local localquestlist = {}
756 if(BWP_QuestList) then
757 for k,v in BWP_QuestList do
758 zone = GetCurrentMapZone()
759 if(v.Zone == zone) then
760 table.insert(localquestlist,v)
761 end
762 end
763 end
764 return localquestlist
765 end
766  
767 function BWP_AddQuest(questname)--Adds a quest giver to waypoint menu
768 if(UnitExists("target")) and(not UnitIsPlayer("Target")) and (UnitReaction("Player", "Target")>3)and (not UnitAffectingCombat("Player"))and ((UnitName("target")~= nil)or(UnitName("target")~= "")) then
769 if (not BWP_QuestList) then
770 BWP_QuestList = {}
771 local Questlist ={}
772 local questitem = {}
773 questitem["QuestName"] = questname
774 questitem["QuestGiver"] = UnitName("Target")
775 questitem["X"],questitem["Y"] = GetPlayerMapPosition("Player")
776 questitem["Zone"]= GetCurrentMapZone()
777 Questlist[1] = questitem
778 BWP_QuestList = Questlist
779 else
780 local Questlist = BWP_QuestList
781 local questitem = {}
782 local index = 0
783 questitem["QuestName"] = questname
784 questitem["QuestGiver"] = UnitName("Target")
785 questitem["Zone"]= GetCurrentMapZone()
786 questitem["X"],questitem["Y"] = GetPlayerMapPosition("Player")
787 for k,v in Questlist do
788 index = index + 1
789 if(UnitName("Target") == v["QuestGiver"]) then
790 if(v["QuestName"])then
791 questitem = nil
792 questitem = v
793 if(questitem["QuestName"])then
794 if(not string.find(questitem["QuestName"],questname))then
795 questitem["QuestName"] = (questitem["QuestName"]..","..questname)
796 end
797 end
798 end
799 Questlist[index] = questitem
800 BWP_QuestList = Questlist
801 return 1
802 end
803 end
804 Questlist[index+1] = questitem
805 BWP_QuestList = Questlist
806 end
807 end
808 end
809  
810 --Abandon quest to know when you drop a quest and no longer require that questgiver
811 function AbandonQuest()
812 local title = GetAbandonQuestName()
813 if(title)then
814 DEFAULT_CHAT_FRAME:AddMessage("Abandoning:"..title)
815 clearquest(title)
816 end
817 Old_AbandonQuest()
818 return Old_AbandonQuest
819 end
820  
821 function setmininote(x, y, name, icon, continent, zone)
822 if(continent == nil or zone == nil) then
823 continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
824 end
825 if(type(continent) == "string") then return; end
826 if(x >= 1) then x = x / 100; end
827 if(y >= 1) then y = y / 100; end
828 MetaMapNotes_AddNewNote(continent, zone, x, y, name, "", "", "MetaMapBWP", icon, 0, 0, 0, 2);
829 BWP_Destination = {};
830 BWP_Destination.name = name;
831 BWP_Destination.x = x;
832 BWP_Destination.y = y;
833 BWP_Destination.zone = MetaMap_ZoneNames[continent][zone];
834 BWPDestText:SetText("("..BWP_Destination.name..")");
835 BWPDistanceText:SetText(BWP_GetDistText())
836 BWP_DisplayFrame:Show();
837 end
838  
839 --Set up Mini Menu
840 function BWP_MiniDropMenu_OnLoad()
841 UIDropDownMenu_Initialize(this, BWP_MiniDropMenu_Initialize);
842 UIDropDownMenu_SetWidth(80, BWP_MiniDropMenu);
843 end
844  
845 --Initialize minimenu with options
846 function BWP_MiniDropMenu_Initialize()
847 local info;
848 if(tempitem_XBWP) then -- Make sure you have a valid object
849 if(tempitem_XBWP.X and tempitem_XBWP.Y) then -- Make sure X and Y coords Exist(means were in same zone)
850 info = {};
851 info.text = BWP_INFO_TEXT2..tempitem_XBWP.Name..BWP_INFO_TEXT3; --Option message "Set"..$name.."as waypoint"
852 info.func = QuickSetMiniMenu; -- Function to set as destination
853 info.value = tempitem_XBWP --Pass the object value
854 tempitem_XBWP = nil
855 UIDropDownMenu_AddButton(info);
856 else --X and Y dont Exist so its not in out current zone
857 info = {};
858 info.text = BWP_INFO_TEXT1..tempitem_XBWP.Name..BWP_INFO_TEXT3; --non click message "Must be in same zone blah blah"
859 info.isTitle = 1
860 tempitem_XBWP = nil
861 UIDropDownMenu_AddButton(info);
862 end
863 end
864 end
865  
866 --sets a mininote from the value passed by the mini menu
867 function QuickSetMiniMenu()
868 UIDropDownMenu_SetText(this.value.Name, BWP_MenuFrame_DropDown);
869 setmininote(this.value.X,this.value.Y,this.value.Name, "7", this.value.continent, this.value.zone);
870 BWP_OptionsInit();
871 end
872  
873 function BWP_CallMenu()
874 ToggleDropDownMenu(1,1,BWP_MenuFrame_DropDown, "cursor",-150,0)
875 end
876  
877 function BWP_ShowKBMenu(id)
878 local centerx, centery;
879 local name = getglobal("MetaKB_ScrollFrameButton"..id.."Name"):GetText();
880 local zCheck = getglobal("MetaKB_ScrollFrameButton"..id.."Coords"):GetText();
881 if(string.find(zCheck, "%(%d+\.?-?%d*%)?, %(?%d+\.?-?%d*%)")) then
882 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
883 local coords = MetaKB_Data[MetaKB_dbID][name][continent][zone];
884 local dx = coords[2]/100 - coords[4]/100;
885 local dy = coords[3]/100 - coords[1]/100;
886 centerx = MetaMap_round(coords[4]/100 + dx/2, 0);
887 centery = MetaMap_round(coords[1]/100 + dy/2, 0);
888 end
889 local cx, cy = GetCursorPosition();
890 BWP_MiniDropMenu:ClearAllPoints()
891 BWP_MiniDropMenu:SetPoint("BOTTOM","UIParent","BOTTOMLEFT", cx, cy)
892 tempitem_XBWP ={X = centerx, Y = centery, Name = name, continent = continent, zone = zone};
893 ToggleDropDownMenu(1,1,BWP_MiniDropMenu)
894 end
895  
896 function BWP_ShowNoteMenu(id)
897 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
898 if not currentZone then return end
899 tempitem_XBWP ={X = currentZone[id].xPos,Y = currentZone[id].yPos ,Name = currentZone[id].name} --call our minimenu (only option is to set waypoint)
900 ToggleDropDownMenu(1,1,BWP_MiniDropMenu,"cursor",-150,0)
901 end
902  
903  
904 function BWP_ChecknumPOI()
905 BWP_CZone_XTRA = nil
906 local POIinZone = table.getn(BWP_CZone)
907 if( POIinZone > 20) then
908 local temp_CZone = {nil}
909 BWP_CZone_XTRA = {nil}
910 BWP_CZone_XTRA[1] = {nil}
911 BWP_CZone_XTRA[2] = {nil}
912 BWP_CZone_XTRA[3] = {nil}
913 BWP_CZone_XTRA[4] = {nil}
914 BWP_CZone_XTRA[5] = {nil}
915 BWP_CZone_XTRA[6] = {nil}
916 BWP_CZone_XTRA[7] = {nil}
917 BWP_CZone_XTRA[8] = {nil}
918 local BWPcount = 0
919 table.sort(BWP_CZone,BWPsortbyName)
920 for k,v in BWP_CZone do
921 BWPcount = BWPcount + 1
922 if(BWPcount < 21) then
923 tinsert(temp_CZone, v)
924 elseif(BWPcount < 42) then
925 tinsert(BWP_CZone_XTRA[1], v );
926 elseif(BWPcount < 63) then
927 tinsert(BWP_CZone_XTRA[2], v );
928 elseif(BWPcount < 84) then
929 tinsert(BWP_CZone_XTRA[3], v );
930 elseif(BWPcount < 105) then
931 tinsert(BWP_CZone_XTRA[4], v );
932 elseif(BWPcount < 126) then
933 tinsert(BWP_CZone_XTRA[5], v );
934 elseif(BWPcount < 147) then
935 tinsert(BWP_CZone_XTRA[6], v );
936 elseif(BWPcount < 168) then
937 tinsert(BWP_CZone_XTRA[7], v );
938 elseif(BWPcount < 189) then
939 tinsert(BWP_CZone_XTRA[8], v );
940 end
941 end
942 BWP_CZone = temp_CZone
943 end
944 end
945  
946  
947 -- Constructor
948 function BWPnode:new(x, y, text, who)
949 return setmetatable( { xcoord = x, ycoord = y, note = text, author = who}, SNmeta);
950 end
951  
952 -- Deconstructor
953 function BWPnode:delete()
954 return setmetatable({}, BWPmeta);
955 end
956  
957 --Getters
958 function BWPnode:getX() return self.xcoord; end
959 function BWPnode:getY() return self.ycoord; end
960 function BWPnode:getNote() return self.note; end
961 function BWPnode:getAuthor() return self.author; end
962  
963 -- Setters
964 function BWPnode:setX(x) self.xcoord = x; end
965 function BWPnode:setY(y) self.ycoord = y; end
966 function BWPnode:setNote(text) self.note = text; end
967 function BWPnode:setAuthor(text) self.author = text; end
968  
969 -- Constructor
970 function BWPDisp:new(x, y, who, desc, txt1, txt2, mod)
971 return setmetatable( { xcoord = x, ycoord = y, author = who, title = desc, inf1 = txt1, inf2 = txt2, type = mod }, BWPDispm);
972 end
973  
974 -- Deconstructor
975 function BWPDisp:delete()
976 return setmetatable({}, BWPDispm);
977 end
978  
979 -- Getters
980 function BWPDisp:getX() return self.xcoord; end
981 function BWPDisp:getY() return self.ycoord; end
982 function BWPDisp:getTitle() return self.title; end
983 function BWPDisp:getNote1() return self.inf1; end
984 function BWPDisp:getNote2() return self.inf2; end
985 function BWPDisp:getAuthor() return self.author; end
986 function BWPDisp:getType() return self.type; end
987  
988 function BWP_FormatCoords(x, y)
989 local rx, ry, fx, fy, nx, ny;
990 nx = string.format("%i", x*10000); ny = string.format("%i", y*10000);
991 fx = string.format("%i", x*1000); fy = string.format("%i", y*1000);
992 rx = string.format("%i", x*100); ry = string.format("%i", y*100);
993  
994 fx = tonumber(strsub(fx, strlen(fx),strlen(fx))); fy = tonumber(strsub(fy, strlen(fy), strlen(fy)));
995  
996 if (tonumber(strsub(nx, strlen(nx), strlen(nx))) >= 5) then fx = fx + 1; end
997 if (tonumber(strsub(ny, strlen(ny), strlen(ny))) >= 5) then fy = fy + 1; end
998  
999 return tonumber(rx.."."..fx), tonumber(ry.."."..fy);
1000 end
1001  
1002 --Returns Distance(in whatever units it recieves)
1003 function BWP_GetDist(loc1 , loc2)
1004 if(not loc1) or (not loc2) then return nil
1005 else return math.sqrt((loc1.x - loc2.x)^2 + (loc1.y - loc2.y)^2)
1006 end
1007 end
1008  
1009 --formats to yards or meters or clicks
1010 function BWP_FormatDist(loc1,loc2)
1011 local zone = GetRealZoneText();
1012 local thisDistance = BWP_GetDist(loc1 , loc2)
1013 local flag = BWP_getflag(thisDistance) -- gets the color flag based on distance in Units
1014 thisDistance = BWP_ConvertToYards(loc1.x, loc1.y, loc2.x, loc2.y) /10;
1015 if(BWP_Options.ShowYards) then
1016 theseUnits = " Yds"
1017 else
1018 thisDistance = thisDistance * 0.9144
1019 theseUnits = " Mtrs"
1020 end
1021 thisDistance = tonumber(string.format("%.0f" , thisDistance)) -- we dont really need decimal places with this small of units
1022 return thisDistance, theseUnits, flag
1023 end
1024  
1025 function BWP_getflag(distanceinUNITS)-- Really returns a color equivilent of a distance range
1026 local tcd = BWP_Options.SetDistance
1027 if(BWP_Options.SetDistance < 0.0040) then tcd = 0.0040 end
1028 if (distanceinUNITS <= (BWP_Options.SetDistance *1.215)) then return "A"
1029 elseif (distanceinUNITS < tcd * 2.452) then return "Green" --for Green Text
1030 elseif (distanceinUNITS < tcd * 242.5) then return "Y" --For Yellow text
1031 else return "Red" -- for red text
1032 end
1033 end
1034  
1035 function BWP_ConvertToYards(x1, y1, x2, y2)
1036 if(x1 == nil) then
1037 x1, y1, x2, y2 = 0, 0, 0, 0;
1038 end
1039 local dx = (x1 - x2) * 40482.686754239;
1040 local dy = (y1 - y2) * (40482.686754239 / 1.5);
1041 return math.sqrt(dx * dx + dy * dy)
1042 end
1043  
1044 function BWP_GetDir()
1045 if(not updCount)then
1046 updCount = 0
1047 end
1048 updCount = updCount + 1;
1049 if (updCount < 2) then
1050 return;
1051 end
1052 updCount = 0;
1053 -- Find out where we are now
1054 local x,y = GetPlayerMapPosition("player");
1055  
1056 local t = GetTime();
1057 -- Store data if we've moved at least min sample distance
1058 local dx,dy = 0.00001,0.0001
1059 if ((x ~= 0) or (y ~= 0)) then
1060 dx,dy = lastX - x, lastY - y
1061 end
1062 if ((math.abs(dx) >= MIN_SAMPLE_DISTANCE)
1063 or (math.abs(dy) >= MIN_SAMPLE_DISTANCE)) then
1064  
1065 lastIdx = lastIdx + 1;
1066 if (lastIdx > MAX_LOC_SAMPLES) then
1067 lastIdx = 1;
1068 end
1069 LOC_X_SAMPLES[lastIdx] = x;
1070  
1071 LOC_Y_SAMPLES[lastIdx] = y;
1072  
1073 LOC_T_SAMPLES[lastIdx] = t;
1074  
1075 lastX,lastY = x,y;
1076 end
1077 if (lastIdx == 0) then
1078 return;
1079 end
1080  
1081 local idx = lastIdx;
1082 local cx,cy,ct = LOC_X_SAMPLES[idx], LOC_Y_SAMPLES[idx];
1083 local ct = LOC_T_SAMPLES[idx];
1084 local cutoff = t - MAX_CUMUL_TIME;
1085 local tx,ty,tt;
1086 local found = nil;
1087 -- Scan back through the sample list for a long enough vector
1088 while (true) do
1089 idx = idx - 1;
1090 if (idx == 0) then
1091 idx = MAX_LOC_SAMPLES;
1092 end
1093 tx, ty, tt = LOC_X_SAMPLES[idx], LOC_Y_SAMPLES[idx], LOC_T_SAMPLES[idx];
1094 -- If we ran out of samples without finding a long enough
1095 -- vector then stop
1096 if (not tt) or (tt >= ct) or (tt < cutoff) then
1097 break
1098 end
1099 dx = cx - tx;
1100 dy = cy - ty;
1101  
1102 -- If this vector is finally long enough, set found flag and break
1103 -- dx,dy, tx,ty,tt, and idx will all be useful
1104  
1105 if ((dx*dx + dy*dy) >= MIN_CUMUL_RANGE_SQ) then
1106 found = true;
1107 break;
1108 end
1109 end
1110 -- Not enough data
1111 if (not found) then
1112 if (lastDeg) then
1113 lastDeg = nil;
1114 end
1115 return
1116 end
1117 -- If we get here we have a vector, let's convert it to degrees
1118 local deg = math.deg(math.atan2(dx,-dy));
1119 local loc1 , loc2 = {}, {}
1120 loc1.x, loc1.y = BWP_Destination.x, BWP_Destination.y
1121 loc2.x, loc2.y = GetPlayerMapPosition("player")
1122 gdclx = (loc1.x - loc2.x );
1123 gdcly = (loc1.y - loc2.y );
1124 _,_,Arrivedyet = BWP_FormatDist(loc1,loc2)
1125 if (Arrivedyet == "A")and(not BWPFOLLOWPLAYER) then
1126 return "Arrived!"
1127 end
1128 local goaldeg = math.deg(math.atan2(gdclx,-gdcly))
1129 return (goaldeg - deg)
1130 end
1131  
1132 function GetLocalPoints()
1133 local Waypoints = {}
1134 local countit = 0
1135 local zone = GetRealZoneText();
1136 local cont = nil;
1137 local cData;
1138  
1139 if (BWP_Zones and BWP_Zones[zone] == 1) then cont = "Kalimdor";
1140 elseif (BWP_Zones and BWP_Zones[zone] == 2) then cont = "Eastern Kingdoms"; end
1141 if (BWP_Data[cont] and BWP_Data[cont][zone]) then
1142 text = "\n"
1143 local temp = BWP_Data[cont][zone];
1144 local node = nil;
1145 for key in temp do
1146 node = setmetatable(temp[key], BWPmeta);
1147 cData = BWPDisp:new(node:getX(), node:getY(), node:getAuthor(), "", node:getNote(), "", "BWP");
1148 tinsert(Waypoints, cData);
1149 countit = countit + 1
1150 end
1151 end
1152 if (MetaMapNotes_Data) then
1153 local BWP_mnCont, BWP_mnZone = MetaMap_GetCurrentMapInfo();
1154 if (MetaMapNotes_Data[BWP_mnCont] and MetaMapNotes_Data[BWP_mnCont][BWP_mnZone]) then
1155 for key in MetaMapNotes_Data[BWP_mnCont][BWP_mnZone] do
1156  
1157 local adjx, adjy = MetaMapNotes_Data[BWP_mnCont][BWP_mnZone][key].xPos * 100, MetaMapNotes_Data[BWP_mnCont][BWP_mnZone][key].yPos* 100;
1158 cData = BWPDisp:new(adjx, adjy, MetaMapNotes_Data[BWP_mnCont][BWP_mnZone][key].creator, MetaMapNotes_Data[BWP_mnCont][BWP_mnZone][key].name, MetaMapNotes_Data[BWP_mnCont][BWP_mnZone][key].inf1, MetaMapNotes_Data[BWP_mnCont][BWP_mnZone][key].inf2, "MN");
1159 tinsert(Waypoints, cData);
1160  
1161 countit = countit + 1
1162 end
1163 end
1164 end
1165 return Waypoints , countit
1166 end
1167  
1168 function BWP_Generate()
1169 BWP_CZone = {};
1170 BWP_CZone , localpoints = GetLocalPoints()
1171 end
1172  
1173 function BWPsortbyName(a,b) return string.lower(a.title) < string.lower(b.title) end
1174 function BWPSortByQuestGiverName(a,b) return string.lower(a.QuestGiver) < string.lower(b.QuestGiver) end
1175  
1176 function BWP_SetRotation(dir)
1177 if(dir) then
1178 OffSet = tonumber(dir)
1179 if(OffSet)then
1180 if(OffSet > 180 )then
1181 OffSet = OffSet - 360
1182 elseif(OffSet < -180) then
1183 OffSet = OffSet + 360
1184 end
1185 end
1186 if(dir == "Arrived!") then
1187 BWP_CountDown = 75
1188 BWP_ArrowIcon = BWP_IMAGE_PATH.."Arrived"
1189 elseif(OffSet)and ((OffSet >=-5) and ( OffSet <= 5))or(OffSet < -355) then
1190 BWP_ArrowIcon = BWP_IMAGE_PATH.."forward"
1191 elseif(OffSet)and (OffSet < -5) and (OffSet >= -15) then
1192 BWP_ArrowIcon = BWP_IMAGE_PATH.."FLeft+2"
1193 elseif(OffSet)and (OffSet < -15) and (OffSet >= -35) then
1194 BWP_ArrowIcon = BWP_IMAGE_PATH.."FLeft+1"
1195 elseif(OffSet)and (OffSet < -35) and (OffSet >= -55) then
1196 BWP_ArrowIcon = BWP_IMAGE_PATH.."FLeft"
1197 elseif(OffSet)and (OffSet < -55) and (OffSet >= -65) then
1198 BWP_ArrowIcon = BWP_IMAGE_PATH.."FLeft-1"
1199 elseif(OffSet)and (OffSet < -65) and (OffSet >= -80) then
1200 BWP_ArrowIcon = BWP_IMAGE_PATH.."FLeft-2"
1201 elseif(OffSet)and (OffSet < -80) and (OffSet >= -100) then
1202 BWP_ArrowIcon = BWP_IMAGE_PATH.."left"
1203 elseif(OffSet)and (OffSet < -100) and (OffSet >= -115) then
1204 BWP_ArrowIcon = BWP_IMAGE_PATH.."BLeft-2"
1205 elseif(OffSet)and (OffSet < -115) and (OffSet >= -135) then
1206 BWP_ArrowIcon = BWP_IMAGE_PATH.."BLeft-1"
1207 elseif(OffSet)and (OffSet < -135) and (OffSet >= -155) then
1208 BWP_ArrowIcon = BWP_IMAGE_PATH.."BLeft"
1209 elseif(OffSet)and (OffSet < -155) and (OffSet >= -165) then
1210 BWP_ArrowIcon = BWP_IMAGE_PATH.."BLeft+1"
1211 elseif(OffSet)and (OffSet < -165) and (OffSet >= -175) then
1212 BWP_ArrowIcon = BWP_IMAGE_PATH.."BLeft+2"
1213 elseif(OffSet)and ((OffSet < -175) and (OffSet >= -190)) or((OffSet > 175) and (OffSet <= 190)) then
1214 BWP_ArrowIcon = BWP_IMAGE_PATH.."Backward"
1215 elseif(OffSet)and (OffSet > 165) and (OffSet <= 175) then
1216 BWP_ArrowIcon = BWP_IMAGE_PATH.."BRight+2"
1217 elseif(OffSet)and (OffSet > 155) and (OffSet <= 165) then
1218 BWP_ArrowIcon = BWP_IMAGE_PATH.."BRight+1"
1219 elseif(OffSet)and (OffSet > 135) and (OffSet <= 155) then
1220 BWP_ArrowIcon = BWP_IMAGE_PATH.."BRight"
1221 elseif(OffSet)and (OffSet > 115) and (OffSet <= 135) then
1222 BWP_ArrowIcon = BWP_IMAGE_PATH.."BRight-1"
1223 elseif(OffSet)and (OffSet > 100) and (OffSet <= 115) then
1224 BWP_ArrowIcon = BWP_IMAGE_PATH.."BRight-2"
1225 elseif(OffSet)and (OffSet > 80) and (OffSet <= 100) then
1226 BWP_ArrowIcon = BWP_IMAGE_PATH.."right"
1227 elseif(OffSet)and (OffSet > 65) and (OffSet <= 80) then
1228 BWP_ArrowIcon = BWP_IMAGE_PATH.."FRight-2"
1229 elseif(OffSet)and (OffSet > 55) and (OffSet <= 65) then
1230 BWP_ArrowIcon = BWP_IMAGE_PATH.."FRight-1"
1231 elseif(OffSet)and (OffSet > 35) and (OffSet <= 55) then
1232 BWP_ArrowIcon = BWP_IMAGE_PATH.."FRight"
1233 elseif(OffSet)and (OffSet > 15) and (OffSet <= 35) then
1234 BWP_ArrowIcon = BWP_IMAGE_PATH.."FRight+1"
1235 elseif(OffSet)and (OffSet > 5) and (OffSet <= 15) then
1236 BWP_ArrowIcon = BWP_IMAGE_PATH.."FRight+2"
1237 end
1238 end
1239 if(BWP_Destination) then
1240 BWP_Arrow:SetTexture(BWP_ArrowIcon);
1241 end
1242 end