vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- MetaMap
2 -- Written by MetaHawk - aka Urshurak
3  
4 METAMAP_TITLE = "MetaMap";
5 METAMAP_TOC = 11200;
6 METAMAP_VERSION = METAMAP_TOC.."-"..2;
7  
8 METAMAP_NAME = METAMAP_TITLE.." v"..METAMAP_VERSION;
9 METAMAPFWM_NAME = "MetaMapPOI";
10 METAMAP_ICON = "Interface\\WorldMap\\WorldMap-Icon";
11 METAMAP_MAP_PATH = "Interface\\AddOns\\MetaMap\\Maps\\";
12 METAMAP_ICON_PATH = "Interface\\AddOns\\MetaMap\\Icons\\";
13 METAMAP_IMAGE_PATH = "Interface\\AddOns\\MetaMap\\Images\\"
14 METAMAP_SHADER_PATH = "Interface\\AddOns\\MetaMap\\Shaders\\"
15 METAMAP_MAPCREDITS = "Maps created by Niflheim";
16 TITAN_METAMAP_ID = METAMAP_TITLE;
17 TITAN_METAMAP_FREQUENCY = 1;
18  
19 METAMAPMENU_BUTTON_HEIGHT = 16;
20 METAMAPLIST_SCROLL_FRAME_BUTTON_HEIGHT = 20;
21 METAMAPLIST_SCROLL_FRAME_BUTTONS_SHOWN = 30;
22 METAMAP_SORTBY_NAME = "name";
23 METAMAP_SORTBY_DESC = "desc";
24 METAMAP_SORTBY_LEVEL = "level";
25 METAMAP_SORTBY_LOCATION = "location";
26  
27 MetaMap_Details = {
28 name = METAMAP_TITLE,
29 description = METAMAP_DESC,
30 version = METAMAP_VERSION,
31 releaseDate = "November 26, 2005",
32 author = "MetaHawk",
33 email = "admin@metaserve.org.uk",
34 website = "",
35 category = MYADDONS_CATEGORY_MAP,
36 }
37  
38 MetaMapOptions = {};
39 MetaMap_ZoneNames = {};
40 MetaMap_ZoneNames[0] = {};
41 MetaMap_ZoneNames[1] = {};
42 MetaMap_ZoneNames[2] = {};
43 MetaMap_NoteList = {};
44 MetaMap_NoteFilter = {};
45  
46 MetaMapNotes_MiniNote_Data = {};
47 MetaMapNotes_PartyNoteData = {};
48 MetaMapNotes_Relocate = {};
49 MetaMapNotes_LastLineClick = {};
50  
51 MetaMap_CurrentMap = 0;
52 MetaMap_ListOffset = 0;
53 MetaMap_VarsLoaded = false;
54 MetaMap_FilterName = "";
55 MetaMap_PingTime = 15;
56 MetaMap_FullScreenMode = false;
57 MetaMapContainer_CurrentFrame = nil;
58 MetaMap_CurrentSaveSet = 1;
59 MetaMap_sortDone = true;
60 MetaMap_sortType = METAMAP_SORTBY_NAME;
61  
62 MetaMapNotes_LastNote = 0;
63 MetaMapNotes_LastLine = 0;
64 MetaMapNotes_TempData_Id = "";
65 MetaMapNotes_TempData_Name = "";
66 MetaMapNotes_TempData_Creator = "";
67 MetaMapNotes_TempData_xPos = "";
68 MetaMapNotes_TempData_yPos = "";
69 MetaMapNotes_TempData_Icon = "";
70 MetaMapNotes_TempData_TextColor = "";
71 MetaMapNotes_TempData_Info1Color = "";
72 MetaMapNotes_TempData_Info2Color = "";
73 MetaMapNotes_TempData_LootID = nil;
74 MetaMapNotes_SetNextAsMiniNote = 0;
75 MetaMapNotes_LastLineClick.time = 0;
76 MetaMapNotes_Qnote = false;
77 MetaMapNotes_MiniNote_IsInCity = false;
78 MetaMapNotes_MiniNote_MapzoomInit = false;
79 MetaMapNotes_vnote_xPos = nil;
80 MetaMapNotes_vnote_yPos = nil;
81 MetaMapNotes_PartyNoteSet = false;
82  
83 local MetaMapNotes_Mininote_UpdateRate = 0;
84 local MetaMap_OrigWorldMapButton_OnClick;
85 local MetaMap_OrigChatFrame_OnEvent;
86  
87 METAMAPMENU_LIST = {
88 {name = METAMAP_OPTIONS_COORDS},
89 {name = METAMAP_OPTIONS_MINICOORDS},
90 {name = METAMAP_OPTIONS_SHOWNOTES},
91 {name = METAMAP_ACTION_MODE},
92 {name = METAMAP_OPTIONS_SAVESET},
93 {name = METAMAP_OPTIONS_SHADESET},
94 {name = "Spacer"},
95 {name = METAMAP_OPTIONS_EXT},
96 {name = METAMAP_FLIGHTMAP_OPTIONS},
97 {name = METAMAP_GATHERER_OPTIONS},
98 {name = METAMAP_BWP_OPTIONS},
99 {name = METAMAP_OPTIONS_USEMAPMOD},
100 {name = METAMAP_KB_TEXT},
101 {name = METAMAP_OPTIONS_FWM}
102 };
103  
104 function MetaMap_SetVars()
105 if(MetaMapOptions.SaveSet == nil) then MetaMapOptions.SaveSet = 1; end
106 if(MetaMapOptions.MetaMapAlpha1 == nil) then MetaMapOptions.MetaMapAlpha1 = 1.0; end
107 if(MetaMapOptions.MetaMapAlpha2 == nil) then MetaMapOptions.MetaMapAlpha2 = 0.60; end
108 if(MetaMapOptions.BDshader1 == nil) then MetaMapOptions.BDshader1 = 0.0; end
109 if(MetaMapOptions.BDshader2 == nil) then MetaMapOptions.BDshader2 = 0.0; end
110 if(MetaMapOptions.MetaMapScale1 == nil) then MetaMapOptions.MetaMapScale1 = 0.75; end
111 if(MetaMapOptions.MetaMapScale2 == nil) then MetaMapOptions.MetaMapScale2 = 0.55; end
112 if(MetaMapOptions.MetaMapTTScale1 == nil) then MetaMapOptions.MetaMapTTScale1 = 1.0; end
113 if(MetaMapOptions.MetaMapTTScale2 == nil) then MetaMapOptions.MetaMapTTScale2 = 0.75; end
114 if(MetaMapOptions.MetaMapCoords == nil) then MetaMapOptions.MetaMapCoords = true; end
115 if(MetaMapOptions.MetaMapMiniCoords == nil) then MetaMapOptions.MetaMapMiniCoords = true; end
116 if(MetaMapOptions.MetaMapButtonShown == nil) then MetaMapOptions.MetaMapButtonShown = true; end
117 if(MetaMapOptions.MetaMapButtonPosition == nil) then MetaMapOptions.MetaMapButtonPosition = 220; end
118 if(MetaMapOptions.TooltipWrap == nil) then MetaMapOptions.TooltipWrap = true; end
119 if(MetaMapOptions.MetaMapShowAuthor == nil) then MetaMapOptions.MetaMapShowAuthor = true; end
120 if(MetaMapOptions.MenuMode == nil) then MetaMapOptions.MenuMode = false; end
121 if(MetaMapOptions.UseMapMod == nil) then MetaMapOptions.UseMapMod = false; end
122 if(MetaMapOptions.ShowMapList == nil) then MetaMapOptions.ShowMapList = false; end
123 if(MetaMapOptions.ActionMode1 == nil) then MetaMapOptions.ActionMode = false; end
124 if(MetaMapOptions.ActionMode2 == nil) then MetaMapOptions.ActionMode = false; end
125 if(MetaMapOptions.LastHighlight == nil) then MetaMapOptions.LastHighlight = true; end
126 if(MetaMapOptions.LastMiniHighlight == nil) then MetaMapOptions.LastMiniHighlight = true; end
127 if(MetaMapOptions.AcceptIncoming == nil) then MetaMapOptions.AcceptIncoming = true; end
128 if(MetaMapOptions.MiniParty == nil) then MetaMapOptions.MiniParty = true; end
129 if(MetaMapOptions.ListColors == nil) then MetaMapOptions.ListColors = true; end
130 if(MetaMapOptions.ShadeSet == nil) then MetaMapOptions.ShadeSet = 1; end
131 if(MetaMapOptions.MiniColor == nil) then MetaMapOptions.MiniColor = 4; end
132 if(MetaMapOptions.MetaMapZone == nil) then MetaMapOptions.MetaMapZone = 1; end
133 if(MetaMapOptions.ZoneHeader == nil) then MetaMapOptions.ZoneHeader = false; end
134 if(MetaMapOptions.ZoneShiftVersion == nil) then MetaMapOptions.ZoneShiftVersion = 0; end
135 if(MetaMapOptions.usePOI == nil) then MetaMapOptions.usePOI = false; end
136 if(MetaMapOptions.FWMretain == nil) then MetaMapOptions.FWMretain = false; end
137 if(MetaMapOptions.BWPalwaysOn == nil) then MetaMapOptions.BWPalwaysOn = false; end
138 if(MetaMapOptions.WKBalwaysOn == nil) then MetaMapOptions.WKBalwaysOn = false; end
139 if(MetaMapOptions.SortList == nil) then MetaMapOptions.SortList = false; end
140 for i=0, 9, 1 do
141 if(MetaMap_NoteFilter[i] == nil) then MetaMap_NoteFilter[i] = true; end
142 end
143 end
144  
145 function MetaMap_SetWorldMap()
146 BlackoutWorld:Hide();
147 WorldMapZoomOutButton:Hide();
148 WorldMapFrame:SetMovable(true);
149 WorldMapMagnifyingGlassButton:Hide();
150 WMF_OldScript = WorldMapFrame:GetScript("OnKeyDown")
151 WorldMapFrame:SetScript("OnKeyDown", nil);
152 UIPanelWindows["WorldMapFrame"] = { area = "center", pushable = 0 };
153 SetMapToCurrentZone();
154 end
155  
156 function MetaMapTopFrame_OnLoad()
157 math.randomseed(GetTime());
158 this:RegisterEvent("ADDON_LOADED");
159 this:RegisterEvent("VARIABLES_LOADED");
160 this:RegisterEvent("PLAYER_ENTERING_WORLD");
161 this:RegisterEvent("WORLD_MAP_UPDATE");
162 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
163 if (IsAddOnLoaded("FuBar")) then
164 MetaMap_FuBar_OnLoad();
165 end
166 end
167  
168 function MetaMapFrameDropDown_OnLoad()
169 UIDropDownMenu_ClearAll(MetaMapFrameDropDown);
170 UIDropDownMenu_Initialize(MetaMapFrameDropDown, MetaMapFrameDropDown_Initialize);
171 UIDropDownMenu_SetWidth(175);
172 end
173  
174 function MetaMapList_OnLoad()
175 this:SetFrameLevel(WorldMapButton:GetFrameLevel()+1);
176 this:SetHeight(WorldMapButton:GetHeight());
177 this:SetBackdropColor(0,0,0,0.65);
178 end
179  
180 function MetaMapContainerFrame_OnLoad()
181 this:SetWidth(WorldMapButton:GetWidth() - MetaMap_MapListFrame:GetWidth()-1);
182 this:SetHeight(WorldMapButton:GetHeight()-41);
183 end
184  
185 function MetaMapNotes_OnLoad()
186 MiniNotePOI.TimeSinceLastUpdate = 0;
187 SlashCmdList["MAPNOTE"] = MetaMapNotes_GetNoteBySlashCommand;
188 for i = 1, table.getn(METAMAPNOTES_ENABLE_COMMANDS) do
189 setglobal("SLASH_MAPNOTE"..i, METAMAPNOTES_ENABLE_COMMANDS[i]);
190 end
191 SlashCmdList["MININOTE"] = MetaMapNotes_NextMiniNote;
192 for i = 1, table.getn(METAMAPNOTES_MININOTE_COMMANDS) do
193 setglobal("SLASH_MININOTE"..i, METAMAPNOTES_MININOTE_COMMANDS[i]);
194 end
195 SlashCmdList["MININOTEONLY"] = MetaMapNotes_NextMiniNoteOnly;
196 for i = 1, table.getn(METAMAPNOTES_MININOTEONLY_COMMANDS) do
197 setglobal("SLASH_MININOTEONLY"..i, METAMAPNOTES_MININOTEONLY_COMMANDS[i]);
198 end
199 SlashCmdList["MININOTEOFF"] = MetaMapNotes_ClearMiniNote;
200 for i = 1, table.getn(METAMAPNOTES_MININOTEOFF_COMMANDS) do
201 setglobal("SLASH_MININOTEOFF"..i, METAMAPNOTES_MININOTEOFF_COMMANDS[i]);
202 end
203 SlashCmdList["QUICKNOTE"] = MetaMapNotes_Quicknote;
204 for i = 1, table.getn(METAMAPNOTES_QUICKNOTE_COMMANDS) do
205 setglobal("SLASH_QUICKNOTE"..i, METAMAPNOTES_QUICKNOTE_COMMANDS[i]);
206 end
207 end
208  
209 function MetaMapTopFrame_OnShow()
210 if(not MetaMap_VarsLoaded) then return; end
211 MetaMap_CurrentMap = GetCurrentMapZone();
212 StaticPopup1:SetFrameStrata("FULLSCREEN");
213 if(MetaMap_FullScreenMode) then
214 MetaMapNotesEditFrame:SetParent("WorldMapFrame");
215 MetaMapNotesSendFrame:SetParent("WorldMapFrame");
216 end
217 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
218 if(zone == 0) then return; end
219 local pX, pY = GetPlayerMapPosition("Player");
220 if(pX == 0 and pY == 0 and continent == 0) then
221 MetaMapOptions.MetaMapZone = zone;
222 MetaMap_Toggle(true)
223 end
224 end
225  
226 function MetaMapTopFrame_OnHide()
227 SetMapToCurrentZone();
228 MetaMapNotes_HideAll()
229 MetaMap_Toggle(false);
230 MetaMapOptions.SaveSet = MetaMap_CurrentSaveSet;
231 MetaMapContainerFrame:Hide();
232 StaticPopup1:SetFrameStrata("DIALOG");
233 MetaMapNotesEditFrame:SetParent("UIParent");
234 MetaMapNotesEditFrame:SetFrameStrata("FULLSCREEN");
235 MetaMapNotesSendFrame:SetParent("UIParent");
236 MetaMapNotesSendFrame:SetFrameStrata("FULLSCREEN");
237 end
238  
239  
240 function MetaMap_OnEvent(event)
241 if(event == "ADDON_LOADED" and arg1 == "MetaMap") then
242 MetaMap_SetWorldMap();
243 MetaMap_SetVars();
244 MetaMap_LoadZones();
245 MetaMap_VerifyData();
246 MetaMap_OptionsDialogInit();
247 MetaMap_FilterInit();
248 end
249 if(event == "VARIABLES_LOADED") then
250 MetaMap_CurrentSaveSet = MetaMapOptions.SaveSet;
251 MetaMapOptions_Init();
252 MetaMapMenu_Init();
253 if(myAddOnsFrame_Register) then
254 myAddOnsFrame_Register(MetaMap_Details);
255 end
256 if MetaMapNotes_MiniNote_Data.icon == "party" then
257 MetaMapNotes_ClearMiniNote(true);
258 end
259 if MetaMapNotes_MiniNote_Data.icon ~= nil then
260 MiniNotePOITexture:SetTexture(METAMAP_ICON_PATH.."Icon"..MetaMapNotes_MiniNote_Data.icon);
261 end
262 MetaMap_OrigWorldMapButton_OnClick = WorldMapButton_OnClick;
263 WorldMapButton_OnClick = MetaMapNotes_WorldMapButton_OnClick;
264 MetaMap_OrigChatFrame_OnEvent = ChatFrame_OnEvent;
265 ChatFrame_OnEvent = MetaMap_ChatFrame_OnEvent;
266 MetaMap_SetNUNtooltip();
267 if(MetaMapOptions.WKBalwaysOn) then MetaMap_LoadWKB(3); end
268 if(MetaMapOptions.BWPalwaysOn) then MetaMap_LoadBWP(0, 3); end
269 if(MetaMapOptions.FWMretain) then MetaMap_LoadFWM(); end
270 MetaMap_VarsLoaded = true;
271 end
272 if(event == "INSTANCE_MAP_UPDATE") then
273 if(not MetaMap_VarsLoaded) then return; end
274 if(IsAddOnLoaded("MetaMapWKB")) then
275 MetaKB_OnEvent("INSTANCE_MAP_UPDATE");
276 else
277 MetaMapContainerFrame:Hide();
278 end
279 MetaMapNotes_HideAll();
280 MetaMap_Refresh();
281 MetaMap_ZoneHeader();
282 end
283 if(event == "WORLD_MAP_UPDATE") then
284 if(not MetaMap_VarsLoaded) then return; end
285 if(MetaMap_CurrentMap ~= GetCurrentMapZone() and MetaMapFrame:IsVisible()) then
286 MetaMap_Toggle(false);
287 end
288 MetaMap_CurrentMap = GetCurrentMapZone();
289 if(MetaMapOptions.usePOI) then
290 MetaMapPOI_OnEvent(1);
291 end
292 if(not IsAddOnLoaded("MetaMapWKB")) then
293 MetaMapContainerFrame:Hide();
294 end
295 if(MetaMap_CurrentMap ~= 0) then
296 MetaMapNotes_HideAll();
297 end
298 MetaMapOptions_Init();
299 MetaMapNotes_MapUpdate();
300 MetaMap_ZoneHeader();
301 end
302 if(event == "ZONE_CHANGED_NEW_AREA") then
303 if(not MetaMap_VarsLoaded) then return; end
304 SetMapToCurrentZone();
305 MetaMapNotes_MiniNote_OnUpdate(0);
306 if(MetaMapOptions.usePOI) then
307 MetaMapPOI_OnEvent(2);
308 end
309 if(WorldMapFrame:IsVisible()) then
310 MetaMapNotes_MapUpdate();
311 end
312 MetaMapNotes_HideAll();
313 end
314 if(event == "PLAYER_ENTERING_WORLD") then
315 if(not MetaMap_VarsLoaded) then return; end
316 MetaMap_CurrentMap = GetCurrentMapZone();
317 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
318 if(zone == 0) then return; end
319 local pX, pY = GetPlayerMapPosition("Player");
320 if(pX == 0 and pY == 0 and continent == 0) then
321 MetaMapOptions.MetaMapZone = zone;
322 MetaMap_Toggle(true);
323 end
324 end
325 if(event == "MINIMAP_UPDATE_ZOOM") then
326 MetaMapNotes_MinimapUpdateZoom();
327 end
328 end
329  
330 function MetaMap_ChatFrame_OnEvent(...)
331 local event = unpack(arg);
332 if(strsub(event, 1, 16) == "CHAT_MSG_WHISPER" and strsub(arg1, 1, 6) == "<MapN>") then
333 if(arg2 ~= UnitName("player")) then
334 MetaMapNotes_GetNoteFromChat(arg1, arg2);
335 end
336 else
337 MetaMap_OrigChatFrame_OnEvent(unpack(arg));
338 end
339 end
340  
341 function MetaMap_VerifyData()
342 local TempData = {}
343 for continent=0, 2, 1 do
344 local numZones = table.getn(MetaMap_ZoneNames[continent]);
345 TempData[continent] = {};
346 for zone, zoneTable in MetaMapNotes_Data[continent] do
347 if(zone <= numZones) then
348 TempData[continent][zone] = {};
349 local newIndex = 1;
350 for i, value in MetaMapNotes_Data[continent][zone] do
351 local newNote = MetaMapNotes_Data[continent][zone][i];
352 if(newNote.xPos and newNote.yPos and newNote.name) then
353 TempData[continent][zone][newIndex] = value;
354 newIndex = newIndex +1;
355 end
356 end
357 end
358 end
359 end
360 for continent, value in MetaMapNotes_Data do
361 if(type(continent) == "String") then
362 TempData[continent] = {};
363 TempData[continent] = value;
364 end
365 end
366 MetaMapNotes_Data = {};
367 MetaMapNotes_Data = TempData;
368 TempData = {};
369 for continent=0, 2, 1 do
370 local numZones = table.getn(MetaMap_ZoneNames[continent]);
371 TempData[continent] = {};
372 for zone, zoneTable in MetaMapNotes_Lines[continent] do
373 if(zone <= numZones) then
374 TempData[continent][zone] = {};
375 local newIndex = 1;
376 for i, value in MetaMapNotes_Lines[continent][zone] do
377 TempData[continent][zone][newIndex] = value;
378 newIndex = newIndex +1;
379 end
380 end
381 end
382 end
383 for continent, value in MetaMapNotes_Lines do
384 if(type(continent) == "String") then
385 TempData[continent] = {};
386 TempData[continent] = value;
387 end
388 end
389 MetaMapNotes_Lines = {};
390 MetaMapNotes_Lines = TempData;
391 TempData = nil;
392 end
393  
394 function MetaMap_VerifyNotes()
395 if(MetaMapNotes_Data == nil) then
396 MetaMapNotes_Data = {};
397 MetaMapNotes_Data[0] = {};
398 MetaMapNotes_Data[1] = {};
399 MetaMapNotes_Data[2] = {};
400 end
401 if(MetaMapNotes_Data[0] == nil) then
402 MetaMapNotes_Data[0] = {};
403 end
404 if(MetaMapNotes_Data[1] == nil) then
405 MetaMapNotes_Data[1] = {};
406 end
407 if(MetaMapNotes_Data[2] == nil) then
408 MetaMapNotes_Data[2] = {};
409 end
410 end
411  
412 function MetaMap_VerifyLines()
413 if(MetaMapNotes_Lines == nil) then
414 MetaMapNotes_Lines = {};
415 MetaMapNotes_Lines[0] = {};
416 MetaMapNotes_Lines[1] = {};
417 MetaMapNotes_Lines[2] = {};
418 end
419 if(MetaMapNotes_Lines[0] == nil) then
420 MetaMapNotes_Lines[0] = {};
421 end
422 if(MetaMapNotes_Lines[1] == nil) then
423 MetaMapNotes_Lines[1] = {};
424 end
425 if(MetaMapNotes_Lines[2] == nil) then
426 MetaMapNotes_Lines[2] = {};
427 end
428 end
429  
430 function MetaMap_LoadZones()
431 MetaMap_VerifyNotes();
432 MetaMap_VerifyLines();
433 for zoneKey in MetaMap_Data do
434 if(MetaMapNotes_Data[0][zoneKey] == nil) then
435 MetaMapNotes_Data[0][zoneKey] = {};
436 end
437 if(MetaMapNotes_Lines[0][zoneKey] == nil) then
438 MetaMapNotes_Lines[0][zoneKey] = {};
439 end
440 MetaMap_ZoneNames[0][zoneKey] = MetaMap_Data[zoneKey]["ZoneName"];
441 end
442 for continentKey,continentName in ipairs{GetMapContinents()} do
443 MetaMap_ZoneNames[continentKey] = {};
444 for zoneKey,zoneName in ipairs{GetMapZones(continentKey)} do
445 if(MetaMapNotes_Data[continentKey][zoneKey] == nil) then
446 MetaMapNotes_Data[continentKey][zoneKey] = {};
447 end
448 if(MetaMapNotes_Lines[continentKey][zoneKey] == nil) then
449 MetaMapNotes_Lines[continentKey][zoneKey] = {};
450 end
451 MetaMap_ZoneNames[continentKey][zoneKey] = zoneName;
452 end
453 end
454 end
455  
456 function MetaMap_NameToZoneID(zoneText, mode)
457 for continentKey in MetaMapNotes_Data do
458 if zoneText == MetaMap_ZoneNames[continentKey] then
459 return zoneText, 0;
460 end
461 end
462 for continentKey in MetaMap_ZoneNames do
463 for zoneKey in MetaMap_ZoneNames[continentKey] do
464 if zoneText == MetaMap_ZoneNames[continentKey][zoneKey] then
465 return continentKey, zoneKey;
466 end
467 end
468 end
469 if(type(zoneText) == "string" and strlen(zoneText) >0 and mode == nil) then
470 if(MetaMapNotes_Data[zoneText] == nil) then
471 MetaMapNotes_Data[zoneText] = {};
472 MetaMapNotes_Lines[zoneText] = {};
473 end
474 return zoneText, 0;
475 end
476 return 0, 0;
477 end
478  
479 function MetaMap_GetCurrentMapInfo()
480 local continent, zone, currentZone, mapName;
481 continent = GetCurrentMapContinent();
482 zone = GetCurrentMapZone();
483 if(MetaMapFrame:IsVisible()) then
484 continent = 0;
485 zone = MetaMapOptions.MetaMapZone;
486 currentZone = MetaMapNotes_Data[continent][zone];
487 mapName = MetaMap_Data[zone]["ZoneName"];
488 elseif(continent == -1) then
489 if(MetaMapNotes_Data[GetRealZoneText()] == nil) then
490 MetaMapNotes_Data[GetRealZoneText()] = {};
491 MetaMapNotes_Lines[GetRealZoneText()] = {};
492 end
493 currentZone = MetaMapNotes_Data[GetRealZoneText()];
494 mapName = GetRealZoneText();
495 elseif(continent > 0) then
496 currentZone = MetaMapNotes_Data[continent][zone];
497 mapName = MetaMap_ZoneNames[continent][zone];
498 end
499 if(continent == 1 and mapName == nil) then
500 mapName = "Kalimdor";
501 elseif(continent == 2 and mapName == nil) then
502 mapName = "Eastern Kingdoms";
503 elseif(mapName == nil) then
504 mapName = "World";
505 end
506 return continent, zone, currentZone, mapName;
507 end
508  
509 function MetaMap_ToggleFrame(frame)
510 if frame:IsVisible() then
511 HideUIPanel(frame);
512 else
513 ShowUIPanel(frame);
514 end
515 end
516  
517 function MetaMapContainer_ShowFrame(frame, header, footer, info)
518 if(frame == nil) then
519 MetaMapContainer_CurrentFrame = nil;
520 MetaMapContainerFrame:Hide();
521 return;
522 end
523 if(header ~= nil) then
524 MetaMapContainer_HeaderText:SetText(header);
525 MetaMapContainer_HeaderText:Show();
526 else
527 MetaMapContainer_HeaderText:Hide();
528 end
529 if(footer ~= nil) then
530 MetaMapContainer_FooterText:SetText(footer);
531 MetaMapContainer_FooterText:Show();
532 else
533 MetaMapContainer_FooterText:Hide();
534 end
535 if(info ~= nil) then
536 MetaMapContainer_InfoText:SetText(info);
537 MetaMapContainer_InfoText:Show();
538 else
539 MetaMapContainer_InfoText:Hide();
540 end
541 if(MetaMapContainer_CurrentFrame ~= nil) then
542 MetaMapContainer_CurrentFrame:Hide();
543 end
544 MetaMapContainer_CurrentFrame = frame;
545 MetaMapContainer_CurrentFrame:Show();
546 MetaMapContainerFrame:Show();
547 end
548  
549 function MetaMap_FullScreenToggle()
550 local mMap = false;
551 local continent = GetCurrentMapContinent();
552 local zone = GetCurrentMapZone();
553 if(MetaMapFrame:IsVisible()) then
554 MetaMapShown = true;
555 end
556 if(MetaMap_FullScreenMode) then
557 WorldMapFrame:SetScript("OnKeyDown", nil);
558 WorldMapFrame:SetScript("OnKeyUp", nil);
559 UIPanelWindows["WorldMapFrame"] = { area = "center", pushable = 9 };
560 MetaMapNotesEditFrame:SetParent("UIParent");
561 MetaMapNotesEditFrame:SetFrameStrata("FULLSCREEN");
562 MetaMapNotesSendFrame:SetParent("UIParent");
563 MetaMapNotesSendFrame:SetFrameStrata("FULLSCREEN");
564 MetaMapMenu:SetParent("UIParent");
565 MetaMapMenu:SetFrameStrata("FULLSCREEN");
566 UIPanelWindows['MetaMapMenu'] = {area = 'center', pushable = 0};
567 MetaMap_FullScreenMode = false;
568 BlackoutWorld:Hide();
569 if(WorldMapFrame:IsVisible()) then
570 CloseAllWindows();
571 ShowUIPanel(WorldMapFrame);
572 end
573 MetaMapOptions_Init();
574 else
575 MetaMapMenu:SetParent("WorldMapFrame");
576 MetaMapNotesEditFrame:SetParent("WorldMapFrame");
577 MetaMapNotesSendFrame:SetParent("WorldMapFrame");
578 WorldMapFrame:SetScale(1.0);
579 WorldMapFrame:SetScript("OnKeyDown", WMF_OldScript);
580 WorldMapFrame:SetScript("OnKeyUp", X_Frame:GetScript("OnKeyUp"));
581 UIPanelWindows["WorldMapFrame"] = { area = "full", pushable = 0 };
582 BlackoutWorld:Show();
583 MetaMap_FullScreenMode = true;
584 if(WorldMapFrame:IsVisible()) then
585 CloseAllWindows();
586 ShowUIPanel(WorldMapFrame);
587 end
588 end
589 SetMapZoom(continent, zone);
590 if(MetaMapShown) then MetaMap_Toggle(true); end
591 end
592  
593 function MetaMap_Toggle(show)
594 if(show) then
595 ShowUIPanel(MetaMapFrame);
596 HideUIPanel(WorldMapDetailFrame);
597 HideUIPanel(WorldMapButton);
598 ShowWorldMapArrowFrame(0);
599 else
600 HideUIPanel(MetaMapFrame);
601 ShowUIPanel(WorldMapDetailFrame);
602 ShowUIPanel(WorldMapButton);
603 ShowWorldMapArrowFrame(1);
604 end
605 MetaMap_OnEvent("INSTANCE_MAP_UPDATE");
606 end
607  
608 function MiniMapCoords_OnUpdate()
609 if (MetaMapOptions.MetaMapMiniCoords and Minimap:IsVisible()) then
610 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
611 local px, py = GetPlayerMapPosition("player");
612 if(zone == 0) then
613 MetaMapMiniCoords:SetText("Dead Zone");
614 elseif((continent == GetCurrentMapContinent() and zone == GetCurrentMapZone() and px ~= 0) or (type(continent) == "string" and px ~= 0)) then
615 MetaMapMiniCoords:SetText(MetaMap_round(px * 100)..","..MetaMap_round(py * 100));
616 elseif(px == 0 and py == 0 and continent == 0) then --GetRealZoneText() == MetaMap_Data[MetaMapOptions.MetaMapZone]["ZoneName"]) then
617 MetaMapMiniCoords:SetText("Instance");
618 elseif(continent == GetCurrentMapContinent() and zone == GetCurrentMapZone()) then
619 MetaMapMiniCoords:SetText("Dead Zone");
620 end
621 MetaMapMiniCoords:Show();
622 else
623 MetaMapMiniCoords:Hide();
624 end
625 end
626  
627 function MetaMapCoordsWorldMap_OnUpdate()
628 if (MetaMapOptions.MetaMapCoords and WorldMapFrame:IsVisible()) then
629 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
630 local x, y = GetCursorPosition();
631 local px, py = GetPlayerMapPosition("player");
632 local OFFSET_X = 0.0022;
633 local OFFSET_Y = -0.0262;
634 local centerX, centerY = WorldMapFrame:GetCenter();
635 local width = WorldMapButton:GetWidth();
636 local height = WorldMapButton:GetHeight();
637 x = x / WorldMapFrame:GetEffectiveScale();
638 y = y / WorldMapFrame:GetEffectiveScale();
639 local adjustedX = (x - (centerX - (width/2))) / width;
640 local adjustedY = (centerY + (height/2) - y ) / height;
641 x = 100 * (adjustedX + OFFSET_X);
642 y = 100 * (adjustedY + OFFSET_Y);
643 if(x < 0 or y < 0 or x > 100 or y > 100) then
644 MetaMapCoordsCursor:SetText("");
645 else
646 MetaMapCoordsCursor:SetText("|cffffffff"..format("%d,%d",x, y));
647 end
648 if(zone == 0) then
649 MetaMapCoordsPlayer:SetText("|cff00ff00Dead Zone");
650 elseif(px == 0 and py == 0 and GetRealZoneText() == MetaMap_Data[MetaMapOptions.MetaMapZone]["ZoneName"]) then
651 MetaMapCoordsPlayer:SetText("|cff00ff00Instance");
652 elseif((continent == GetCurrentMapContinent() and zone == GetCurrentMapZone() and px == 0) or (type(continent) == "string" and px == 0)) then
653 MetaMapMiniCoords:SetText("Dead Zone");
654 elseif(px == 0 and py == 0) then
655 MetaMapCoordsPlayer:SetText("");
656 else
657 MetaMapCoordsPlayer:SetText("|cff00ff00"..MetaMap_round(px * 100)..","..MetaMap_round(py * 100));
658 end
659 end
660 end
661  
662 function MetaMap_UpdateBackDrop()
663 if(MetaMapOptions.SaveSet == 1) then
664 MetaMapOptions.BDshader1 = MetaMap_BackDropSlider:GetValue();
665 MetaMap_MapBackDrop:SetAlpha(MetaMapOptions.BDshader1);
666 else
667 MetaMapOptions.BDshader2 = MetaMap_BackDropSlider:GetValue();
668 MetaMap_MapBackDrop:SetAlpha(MetaMapOptions.BDshader2);
669 end
670 if(MetaMapOptions.ShowMapList) then
671 MetaMap_MapBackDrop:SetWidth(MetaMapFrame:GetWidth() - MetaMap_MapListFrame:GetWidth() -1);
672 else
673 MetaMap_MapBackDrop:SetWidth(MetaMapFrame:GetWidth());
674 end
675 MetaMap_MapBackDrop:SetHeight(MetaMapFrame:GetHeight());
676 end
677  
678 function MetaMap_UpdateAlpha()
679 if(MetaMapOptions.SaveSet == 1) then
680 MetaMapOptions.MetaMapAlpha1 = MetaMapAlphaSlider:GetValue();
681 WorldMapFrame:SetAlpha(MetaMapOptions.MetaMapAlpha1);
682 else
683 MetaMapOptions.MetaMapAlpha2 = MetaMapAlphaSlider:GetValue();
684 WorldMapFrame:SetAlpha(MetaMapOptions.MetaMapAlpha2);
685 end
686 MetaMapMainCoords:SetAlpha(255);
687 MetaMapMenu:SetAlpha(255);
688 WorldMapButton:SetAlpha(MetaMapAlphaSlider:GetValue() + 0.2);
689 end
690  
691 function MetaMap_UpdateScale()
692 if(not MetaMap_FullScreenMode) then
693 if(MetaMapOptions.SaveSet == 1) then
694 MetaMapOptions.MetaMapScale1 = MetaMapScaleSlider:GetValue();
695 SetEffectiveScale(WorldMapFrame, MetaMapOptions.MetaMapScale1);
696 else
697 MetaMapOptions.MetaMapScale2 = MetaMapScaleSlider:GetValue();
698 SetEffectiveScale(WorldMapFrame, MetaMapOptions.MetaMapScale2);
699 end
700 MetaMapTopFrame:SetWidth(WorldMapButton:GetWidth()+10);
701 MetaMapTopFrame:SetHeight(WorldMapButton:GetHeight()+100);
702 end
703 end
704  
705 function MetaMap_UpdateTTScale()
706 if(MetaMapOptions.SaveSet == 1) then
707 MetaMapOptions.MetaMapTTScale1 = MetaMapTTScaleSlider:GetValue();
708 WorldMapTooltip:SetScale(MetaMapOptions.MetaMapTTScale1);
709 else
710 MetaMapOptions.MetaMapTTScale2 = MetaMapTTScaleSlider:GetValue();
711 WorldMapTooltip:SetScale(MetaMapOptions.MetaMapTTScale2);
712 end
713 MetaMap_SetNUNtooltip();
714 end
715  
716 function MetaMapFrameDropDown_Initialize()
717 local DropDownList = {};
718 for zoneKey in MetaMap_Data do
719 local detail = {zone = zoneKey, location = MetaMap_Data[zoneKey]["ZoneName"]};
720 table.insert(DropDownList, detail);
721 end
722 local sort = MetaMap_sortType;
723 MetaMap_sortType = METAMAP_SORTBY_LOCATION;
724 table.sort(DropDownList, MetaMap_SortCriteria);
725 MetaMap_sortType = sort;
726  
727 for zoneKey in DropDownList do
728 local info = {
729 text = DropDownList[zoneKey]["location"];
730 value = DropDownList[zoneKey]["zone"];
731 func = MetaMapDropDown_OnClick;
732 };
733 UIDropDownMenu_AddButton(info);
734 end
735 UIDropDownMenu_SetSelectedValue(MetaMapFrameDropDown, MetaMapOptions.MetaMapZone);
736 end
737  
738 function MetaMapDropDown_OnClick()
739 local id = this:GetID();
740 UIDropDownMenu_SetSelectedID(MetaMapFrameDropDown, id);
741 MetaMapOptions.MetaMapZone = this.value;
742 MetaMap_Toggle(true);
743 end
744  
745 function MetaMap_Refresh()
746 if(MetaMapOptions.MetaMapZone > 0 and MetaMapOptions.MetaMapZone < table.getn(MetaMap_Data)+1) then
747 MetaMap_MapImage:SetTexture(METAMAP_MAP_PATH..MetaMap_Data[MetaMapOptions.MetaMapZone]["texture"]);
748 MetaMapText_Instance:SetText("|cffffffff"..MetaMap_Data[MetaMapOptions.MetaMapZone]["ZoneName"]);
749 MetaMapNotes_MapUpdate();
750 end
751 end
752  
753 function MetaMapMenu_Init()
754 local x = 1; local y = 1;
755 for i, menudata in METAMAPMENU_LIST do
756 local flag = false;
757 local button = getglobal("MetaMapMenu_Option"..x);
758 button:SetHeight(METAMAPMENU_BUTTON_HEIGHT);
759 button.shade = false;
760 if(x == 1) then
761 button.toggle = MetaMapOptions.MetaMapCoords;
762 elseif(x == 2) then
763 button.toggle = MetaMapOptions.MetaMapMiniCoords;
764 elseif(x == 3) then
765 button.toggle = false;
766 elseif(x == 4) then
767 if(MetaMapOptions.SaveSet == 1) then
768 button.toggle = MetaMapOptions.ActionMode1;
769 else
770 button.toggle = MetaMapOptions.ActionMode2;
771 end
772 elseif(x == 5) then
773 button.toggle = false;
774 getglobal("MetaMapMenu_Option"..x.."Text"):SetText(MetaMapOptions.SaveSet)
775 elseif(x == 6) then
776 if(MetaMapFrame:IsVisible()) then
777 button.shade = true;
778 button.toggle = false;
779 else
780 flag = true;
781 end
782 elseif(x == 7) then
783 -- spacer
784 elseif(x == 8) then
785 button.toggle = false;
786 elseif(x == 9) then
787 if(IsAddOnLoaded("FlightMap")) then
788 button.toggle = false;
789 else
790 flag = true;
791 end
792 elseif(x == 10) then
793 if(IsAddOnLoaded("Gatherer")) then
794 button.toggle = false;
795 else
796 flag = true;
797 end
798 elseif(x == 11) then
799 button.toggle = false;
800 elseif(x == 12) then
801 if(IsAddOnLoaded("CT_MapMod")) then
802 button.toggle = MetaMapOptions.UseMapMod;
803 else
804 MetaMapOptions.UseMapMod = false;
805 flag = true;
806 end
807 elseif(x == 13) then
808 button.toggle = false;
809 elseif(x == 14) then
810 button.toggle = FWM_ShowUnexplored;
811 end
812  
813 if(flag) then
814 button:SetHeight(1);
815 button:Hide();
816 y = y - 1;
817 elseif(menudata.name == "Spacer") then
818 button:SetHeight(8);
819 button:Hide();
820 else
821 if button.toggle then
822 getglobal("MetaMapMenu_Option"..x.."Check"):Show();
823 else
824 getglobal("MetaMapMenu_Option"..x.."Check"):Hide();
825 end
826 if button.shade then
827 getglobal("MetaMapMenu_Option"..x.."Shade"):SetTexture(METAMAP_IMAGE_PATH.."Color"..MetaMapOptions.ShadeSet);
828 getglobal("MetaMapMenu_Option"..x.."Shade"):Show();
829 else
830 getglobal("MetaMapMenu_Option"..x.."Shade"):Hide();
831 end
832 button:SetText(menudata.name);
833 button:Show();
834 end
835 x = x + 1; y = y + 1;
836 end
837 MetaMapMenu:SetHeight((METAMAPMENU_BUTTON_HEIGHT * y) + (METAMAPMENU_BUTTON_HEIGHT * 2));
838 end
839  
840 function MetaMapMenu_Select(id)
841 id = tonumber(id)
842 local button = getglobal("MetaMapMenu_Option"..id);
843 if button.toggle then
844 button.toggle = false;
845 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
846 else
847 button.toggle = true;
848 getglobal("MetaMapMenu_Option"..id.."Check"):Show()
849 end
850 if(id == 1) then
851 MetaMapOptions.MetaMapCoords = button.toggle;
852 MetaMapOptions_Init();
853 elseif(id == 2) then
854 MetaMapOptions.MetaMapMiniCoords = button.toggle;
855 MetaMapOptions_Init();
856 elseif(id == 3) then
857 if(MetaMapFilterMenu:IsVisible()) then
858 MetaMapFilterMenu:Hide();
859 else
860 MetaMapFilterMenu:Show();
861 end
862 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
863 elseif(id == 4) then
864 ActionMode = button.toggle;
865 if(MetaMapOptions.SaveSet == 1) then
866 MetaMapOptions.ActionMode1 = button.toggle;
867 else
868 MetaMapOptions.ActionMode2 = button.toggle;
869 end
870 MetaMapOptions_Init();
871 elseif(id == 5) then
872 MetaMapSaveSet_Toggle();
873 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
874 getglobal("MetaMapMenu_Option"..id.."Text"):SetText(MetaMapOptions.SaveSet)
875 MetaMapOptions_Init();
876 elseif(id == 6) then
877 MetaMapShadeSet_Toggle();
878 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
879 getglobal("MetaMapMenu_Option"..id.."Shade"):SetTexture(METAMAP_IMAGE_PATH.."Color"..MetaMapOptions.ShadeSet);
880 MetaMapOptions_Init();
881 elseif(id == 7) then
882 -- spacer
883 elseif(id == 8) then
884 MetaMapExtOptions_Toggle();
885 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
886 elseif(id == 9) then
887 FlightMapOptions_Toggle();
888 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
889 elseif(id == 10) then
890 GathererOptions_Toggle();
891 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
892 elseif(id == 11) then
893 MetaMap_LoadBWP();
894 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
895 elseif(id == 12) then
896 MetaMapOptions.UseMapMod = button.toggle;
897 elseif(id == 13) then
898 MetaMap_LoadWKB();
899 getglobal("MetaMapMenu_Option"..id.."Check"):Hide()
900 elseif(id == 14) then
901 FWM_ShowUnexplored = button.toggle;
902 MetaMap_LoadFWM(1);
903 end
904 end
905  
906 function MetaMapMenu_OnShow(mode)
907 MetaMapMenu:ClearAllPoints();
908 local setBottom = false;
909 local x, y = GetCursorPosition();
910 if(y < (UIParent:GetHeight() /2)) then setBottom = true; end
911 if(MetaMap_FullScreenMode) then
912 x = x / WorldMapFrame:GetEffectiveScale();
913 y = y / WorldMapFrame:GetEffectiveScale();
914 else
915 x = x / UIParent:GetEffectiveScale();
916 y = y / UIParent:GetEffectiveScale();
917 end
918 if(mode == "FuBar" or mode == "Titan") then
919 if(mode == "FuBar") then
920 y = y + 10
921 end
922 if(setBottom) then
923 MetaMapMenu:SetPoint("BOTTOM", "UIParent", "BOTTOMLEFT", x, y);
924 else
925 MetaMapMenu:SetPoint("TOP", "UIParent", "BOTTOMLEFT", x, y);
926 end
927 MetaMapSliderMenu:Hide();
928 MetaMapMenu:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 32, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }});
929 MetaMapFilterMenu:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 32, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }});
930 elseif(mode == "Minimap") then
931 if(setBottom) then
932 MetaMapMenu:SetPoint("BOTTOMRIGHT", "UIParent", "BOTTOMLEFT", x +10, y +10);
933 else
934 MetaMapMenu:SetPoint("TOPRIGHT", "UIParent", "BOTTOMLEFT", x +10, y +10);
935 end
936 MetaMapSliderMenu:Show();
937 MetaMapButtonSlider:Show();
938 MetaMapAlphaSlider:Hide();
939 MetaMap_BackDropSlider:Hide();
940 MetaMapScaleSlider:Hide();
941 MetaMapTTScaleSlider:Hide();
942 MetaMapSliderMenu:SetHeight(55);
943 MetaMapMenu:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = true, tileSize = 32, edgeSize = 32, insets = { left = 11, right = 12, top = 12, bottom = 11 }});
944 MetaMapFilterMenu:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = true, tileSize = 32, edgeSize = 32, insets = { left = 11, right = 12, top = 12, bottom = 11 }});
945 elseif(mode == "Mainmap") then
946 MetaMapMenu:SetPoint("TOP", "UIParent", "BOTTOMLEFT", x, y);
947 MetaMapSliderMenu:Show();
948 MetaMapButtonSlider:Hide();
949 MetaMapAlphaSlider:Show();
950 MetaMapScaleSlider:Show();
951 MetaMapTTScaleSlider:Show();
952 if(MetaMapFrame:IsVisible()) then
953 MetaMap_BackDropSlider:Show();
954 MetaMapSliderMenu:SetHeight(130);
955 else
956 MetaMap_BackDropSlider:Hide();
957 MetaMapSliderMenu:SetHeight(105);
958 end
959 MetaMapMenu:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = true, tileSize = 32, edgeSize = 32, insets = { left = 11, right = 12, top = 12, bottom = 11 }});
960 MetaMapFilterMenu:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = true, tileSize = 32, edgeSize = 32, insets = { left = 11, right = 12, top = 12, bottom = 11 }});
961 end
962 MetaMapMenu:Show();
963 end
964  
965 function MetaMapMenu_OnUpdate()
966 if (MetaMapMenu:IsVisible()) then
967 if (not MouseIsOver(MetaMapMenu) and not MouseIsOver(MetaMapButton)
968 and not MouseIsOver(MetaMap_OptionsButton) and not MouseIsOver(MetaMapSliderMenu)
969 and not MouseIsOver(TitanPanelMetaMapButton) and not MouseIsOver(MetaMapFilterMenu)) then
970 MetaMapMenu:Hide();
971 MetaMapFilterMenu:Hide();
972 end
973 end
974 end
975  
976 function MetaMap_FilterInit()
977 for i=0, 9, 1 do
978 getglobal("MetaMapSubMenu_Option"..i):SetChecked(MetaMap_NoteFilter[i]);
979 getglobal("MetaMapSubMenu_Option"..i.."Texture"):SetTexture(METAMAP_ICON_PATH.."Icon"..i);
980 end
981 end
982  
983 function MetaMap_FilterNotes(setAll)
984 if(setAll ~= nil) then
985 for i=0, 9, 1 do
986 getglobal("MetaMapSubMenu_Option"..i):SetChecked(setAll);
987 MetaMap_NoteFilter[i] = setAll;
988 end
989 else
990 for i=0, 9, 1 do
991 if(getglobal("MetaMapSubMenu_Option"..i):GetChecked()) then
992 MetaMap_NoteFilter[i] = true;
993 else
994 MetaMap_NoteFilter[i] = false;
995 end
996 end
997 end
998 MetaMapNotes_MapUpdate();
999 end
1000  
1001 function MetaMap_ToggleDialog(tab)
1002 local subFrame = getglobal(tab);
1003 MetaMap_GeneralDialog:Hide();
1004 MetaMap_NotesDialog:Hide();
1005 MetaKB_HoldingFrame:Hide();
1006 MetaFWM_HoldingFrame:Hide();
1007 MetaMap_ImportDialog:Hide();
1008 MetaMap_ZoneShiftDialog:Hide();
1009 if(MetaMapBKP_BackUpFrame ~= nil and MetaMapBKP_BackUpFrame:IsVisible()) then
1010 MetaMapBKP_BackUpFrame:Hide();
1011 end
1012 if(subFrame) then
1013 if(MetaMap_DialogFrame:IsVisible()) then
1014 PlaySound("igCharacterInfoTab");
1015 getglobal(tab):Show();
1016 else
1017 ShowUIPanel(MetaMap_DialogFrame);
1018 getglobal(tab):Show();
1019 end
1020 end
1021 end
1022  
1023 function MetaMap_OptionsTab_OnClick()
1024 if(this:GetName() == "MetaMap_DialogFrameTab1") then
1025 MetaMap_ToggleDialog("MetaMap_GeneralDialog");
1026 elseif(this:GetName() == "MetaMap_DialogFrameTab2") then
1027 MetaMap_ToggleDialog("MetaMap_NotesDialog");
1028 elseif(this:GetName() == "MetaMap_DialogFrameTab3") then
1029 MetaMap_ToggleDialog("MetaKB_HoldingFrame");
1030 elseif(this:GetName() == "MetaMap_DialogFrameTab4") then
1031 MetaMap_ToggleDialog("MetaFWM_HoldingFrame");
1032 elseif(this:GetName() == "MetaMap_DialogFrameTab5") then
1033 MetaMap_ToggleDialog("MetaMap_ImportDialog");
1034 elseif(this:GetName() == "MetaMap_DialogFrameTab6") then
1035 MetaMap_ToggleDialog("MetaMap_ZoneShiftDialog");
1036 end
1037 PlaySound("igCharacterInfoTab");
1038 end
1039  
1040 function MetaMapExtOptions_Toggle()
1041 if(MetaMap_DialogFrame:IsVisible()) then
1042 HideUIPanel(MetaMap_DialogFrame);
1043 else
1044 if(MetaMap_FullScreenMode) then
1045 MetaMap_DialogFrame:SetParent("WorldMapFrame");
1046 end
1047 ShowUIPanel(MetaMap_DialogFrame);
1048 end
1049 end
1050  
1051 function MetaMapSaveSet_Toggle()
1052 if(MetaMapOptions.SaveSet == 1) then
1053 MetaMapOptions.SaveSet = 2;
1054 else
1055 MetaMapOptions.SaveSet = 1;
1056 end
1057 MetaMapOptions_Init();
1058 MetaMap_CurrentSaveSet = MetaMapOptions.SaveSet;
1059 end
1060  
1061 function MetaMap_MapModeToggle(mode)
1062 MetaMapOptions.SaveSet = mode;
1063 MetaMap_ToggleFrame(WorldMapFrame);
1064 end
1065  
1066 function MetaMapShadeSet_Toggle()
1067 if(MetaMapOptions.ShadeSet == 1) then
1068 MetaMapOptions.ShadeSet = 2;
1069 elseif(MetaMapOptions.ShadeSet == 2) then
1070 MetaMapOptions.ShadeSet = 3;
1071 elseif(MetaMapOptions.ShadeSet == 3) then
1072 MetaMapOptions.ShadeSet = 4;
1073 elseif(MetaMapOptions.ShadeSet == 4) then
1074 MetaMapOptions.ShadeSet = 1;
1075 end
1076 MetaMapOptions_Init();
1077 end
1078  
1079 function MetaMap_OptionsDialogInit()
1080 MetaMap_MenuModeCheckButton:SetChecked(MetaMapOptions.MenuMode);
1081 MetaMap_TTWrapCheckButton:SetChecked(MetaMapOptions.TooltipWrap);
1082 MetaMap_MiniButtonCheckButton:SetChecked(MetaMapOptions.MetaMapButtonShown);
1083 MetaMap_POICheckButton:SetChecked(MetaMapOptions.usePOI);
1084 MetaMap_ListColorsButton:SetChecked(MetaMapOptions.ListColors);
1085 MetaMap_ZoneHeaderButton:SetChecked(MetaMapOptions.ZoneHeader);
1086 MetaMap_LastNoteHighlight:SetChecked(MetaMapOptions.LastHighlight);
1087 MetaMap_LastMiniHighlight:SetChecked(MetaMapOptions.LastMiniHighlight);
1088 MetaMap_AcceptIncoming:SetChecked(MetaMapOptions.AcceptIncoming);
1089 MetaMap_PartyAsMini:SetChecked(MetaMapOptions.MiniParty);
1090 MetaMap_ShowCreator:SetChecked(MetaMapOptions.MetaMapShowAuthor);
1091 end
1092  
1093 function MetaMapOptions_Init()
1094 local ActionMode = false;
1095 MetaMap_MapBackDrop:SetTexture(METAMAP_SHADER_PATH.."Shader"..MetaMapOptions.ShadeSet);
1096 MetaMapMiniCoords:SetTextColor(MetaMapNotes_Colors[MetaMapOptions.MiniColor].r, MetaMapNotes_Colors[MetaMapOptions.MiniColor].g, MetaMapNotes_Colors[MetaMapOptions.MiniColor].b);
1097  
1098 if(MetaMapOptions.SaveSet == 1) then
1099 if(MetaMapOptions.MetaMapAlpha1 < 0.15) then MetaMapOptions.MetaMapAlpha1 = 0.15; end
1100 MetaMapScaleSlider:SetValue(MetaMapOptions.MetaMapScale1);
1101 MetaMap_BackDropSlider:SetValue(MetaMapOptions.BDshader1);
1102 MetaMapAlphaSlider:SetValue(MetaMapOptions.MetaMapAlpha1);
1103 MetaMapTTScaleSlider:SetValue(MetaMapOptions.MetaMapTTScale1);
1104 ActionMode = MetaMapOptions.ActionMode1;
1105 else
1106 if(MetaMapOptions.MetaMapAlpha2 < 0.15) then MetaMapOptions.MetaMapAlpha2 = 0.15; end
1107 MetaMapScaleSlider:SetValue(MetaMapOptions.MetaMapScale2);
1108 MetaMap_BackDropSlider:SetValue(MetaMapOptions.BDshader2);
1109 MetaMapAlphaSlider:SetValue(MetaMapOptions.MetaMapAlpha2);
1110 MetaMapTTScaleSlider:SetValue(MetaMapOptions.MetaMapTTScale2);
1111 ActionMode = MetaMapOptions.ActionMode2;
1112 end
1113 if(ActionMode) then
1114 WorldMapButton:EnableMouse(false);
1115 MetaMapTopFrame:EnableMouse(false);
1116 MetaMapFrame:EnableMouse(false);
1117 else
1118 WorldMapButton:EnableMouse(true);
1119 MetaMapTopFrame:EnableMouse(true);
1120 MetaMapFrame:EnableMouse(true);
1121 end
1122 if(MetaMapOptions.MetaMapButtonShown) then
1123 MetaMapButtonSlider:SetValue(MetaMapOptions.MetaMapButtonPosition);
1124 MetaMapButton_UpdatePosition();
1125 MetaMapButton:Show();
1126 else
1127 MetaMapButton:Hide();
1128 end
1129 if(MetaMapOptions.MetaMapCoords) then
1130 MetaMapMainCoords:Show();
1131 else
1132 MetaMapMainCoords:Hide();
1133 end
1134 if(MetaMapOptions.MetaMapMiniCoords) then
1135 MetaMap_MiniCoords:Show();
1136 else
1137 MetaMap_MiniCoords:Hide();
1138 end
1139 if(MetaMapOptions.ShowMapList) then
1140 MetaMapList_Init();
1141 else
1142 MetaMap_MapListFrame:Hide();
1143 end
1144 MetaMap_UpdateAlpha();
1145 MetaMap_UpdateScale();
1146 MetaMap_UpdateTTScale();
1147 MetaMap_UpdateBackDrop();
1148 end
1149  
1150 function MetaMapButton_UpdatePosition()
1151 MetaMapButton:SetPoint("TOPLEFT", "Minimap", "TOPLEFT",
1152 52 - (80 * cos(MetaMapOptions.MetaMapButtonPosition)),
1153 (80 * sin(MetaMapOptions.MetaMapButtonPosition)) - 52
1154 );
1155 end
1156  
1157 function MetaMap_ButtonTooltip()
1158 GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
1159 GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
1160 GameTooltip:SetText(METAMAP_TITLE, 0, 1, 0);
1161 GameTooltip:AddLine(METAMAP_BUTTON_TOOLTIP1, 1, 1, 1);
1162 if(MetaMapOptions.MenuMode) then
1163 GameTooltip:AddLine(METAMAP_BUTTON_TOOLTIP2, 1, 1, 1);
1164 end
1165 GameTooltip:Show();
1166 end
1167  
1168 function MetaMap_round(num, idp)
1169 local mult = 10^(idp or 0);
1170 return (math.floor(num * mult + 0.5) / mult);
1171 end
1172  
1173 function SetEffectiveScale(frame, scale)
1174 frame.scale = scale;
1175 local parent = frame:GetParent();
1176 if(parent) then
1177 scale = scale / parent:GetEffectiveScale();
1178 end
1179 frame:SetScale(scale);
1180 end
1181  
1182 function MiniMapCoords_OnClick()
1183 local mmc = MetaMapOptions.MiniColor;
1184 if(IsShiftKeyDown() and ChatFrameEditBox:IsVisible()) then
1185 local msg = "My location: "..GetRealZoneText().." ("..MetaMapMiniCoords:GetText()..")";
1186 ChatFrameEditBox:Insert(msg);
1187 elseif(IsControlKeyDown()) then
1188 if(mmc == 9) then
1189 mmc = 0;
1190 else
1191 mmc = mmc +1;
1192 end
1193 MetaMapMiniCoords:SetTextColor(MetaMapNotes_Colors[mmc].r, MetaMapNotes_Colors[mmc].g, MetaMapNotes_Colors[mmc].b);
1194 end
1195 MetaMapOptions.MiniColor = mmc;
1196 end
1197  
1198 function MetaMapList_Init()
1199 if(not MetaMapOptions.ShowMapList) then
1200 return;
1201 end
1202 if(MetaMapOptions.SortList) then
1203 MetaMapList_Header:SetText(METAMAPLIST_UNSORTED);
1204 else
1205 MetaMapList_Header:SetText(METAMAPLIST_SORTED);
1206 end
1207 MetaMap_MapListFrame:Show();
1208 MetaMapPing_OnUpdate(30)
1209 FauxScrollFrame_SetOffset(MetaMapList_ScrollFrame, MetaMap_ListOffset);
1210 MetaMapList_BuildList();
1211 if(not MetaMap_NoteList[1]) then
1212 MetaMap_MapListFrame:Hide();
1213 return;
1214 end
1215 MetaMapList_UpdateScroll();
1216 end
1217  
1218 function MetaMapList_OnClick(button, id)
1219 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
1220 if(button == "LeftButton") then
1221 if(IsControlKeyDown()) then
1222 local LootID = MetaMapNotes_Data[continent][zone][id].lootid;
1223 local Name = MetaMapNotes_Data[continent][zone][id].name;
1224 MetaMap_LoadBLT(LootID, Name);
1225 elseif(IsShiftKeyDown() and ChatFrameEditBox:IsVisible()) then
1226 if(not currentZone) then return; end
1227 local tname = currentZone[id].name;
1228 local tinf1 = currentZone[id].inf1;
1229 local x = MetaMap_round(currentZone[id].xPos *100);
1230 local y = MetaMap_round(currentZone[id].yPos *100);
1231 local tzone = MetaMap_ZoneNames[continent][zone];
1232 if(strlen(tinf1) > 0) then tinf1 = " ["..tinf1.."] "; end
1233 local msg = tname.." "..tinf1.." ("..tzone.." - "..x..","..y..")";
1234 ChatFrameEditBox:Insert(msg);
1235 elseif(id == 0) then
1236 MetaMapPing_SetPing(currentZone, id);
1237 else
1238 MetaMapPing_SetPing(currentZone, MetaMap_NoteList[this:GetID() + MetaMap_ListOffset].id);
1239 end
1240 elseif(button == "RightButton") then
1241 if(IsControlKeyDown() or IsShiftKeyDown()) then
1242 -- Maybe for other functions.
1243 else
1244 MetaMapNotes_Note_OnClick("LeftButton", id);
1245 end
1246 end
1247 end
1248  
1249 function MetaMapList_BuildList()
1250 MetaMap_NoteList = {};
1251 local zone = GetCurrentMapZone();
1252 local continent = GetCurrentMapContinent();
1253 local selectedZone;
1254 MetaMapList_InfoText:Hide();
1255 MetaMapList_PlayerButton:Hide();
1256  
1257 if(MetaMapFrame:IsVisible()) then
1258 continent = 0;
1259 selectedZone = MetaMapNotes_Data[0][MetaMapOptions.MetaMapZone];
1260 elseif(continent == -1) then
1261 selectedZone = MetaMapNotes_Data[GetRealZoneText()];
1262 else
1263 selectedZone = MetaMapNotes_Data[continent][zone];
1264 end
1265 local playerContinent, playerZone = MetaMap_NameToZoneID(GetRealZoneText());
1266 if(continent == playerContinent and zone == playerZone and not MetaMapFrame:IsVisible()) then
1267 getglobal("MetaMapList_PlayerButton".."Name"):SetText(UnitName("Player"));
1268 MetaMapList_PlayerButton:Show();
1269 elseif(MetaMapFrame:IsVisible()) then
1270 MetaMapList_InfoText:Show();
1271 end
1272 if(not selectedZone or zone < 0) then
1273 MetaMap_MapListFrame:Hide();
1274 else
1275 local index = 1;
1276 for i, value in selectedZone do
1277 if(MetaMap_NoteFilter[selectedZone[i].icon]) then
1278 MetaMap_NoteList[index] = {};
1279 MetaMap_NoteList[index]["name"] = selectedZone[i]["name"];
1280 MetaMap_NoteList[index]["xPos"] = selectedZone[i]["xPos"];
1281 MetaMap_NoteList[index]["yPos"] = selectedZone[i]["yPos"];
1282 MetaMap_NoteList[index]["ncol"] = selectedZone[i]["ncol"];
1283 MetaMap_NoteList[index]["icon"] = selectedZone[i]["icon"];
1284 MetaMap_NoteList[index]["id"] = i;
1285 MetaMap_NoteList.lastEntry = index;
1286 index = index +1;
1287 end
1288 end
1289 if(MetaMapOptions.SortList) then
1290 local sort = MetaMap_sortType;
1291 MetaMap_sortType = METAMAP_SORTBY_NAME;
1292 table.sort(MetaMap_NoteList, MetaMap_SortCriteria);
1293 MetaMap_sortType = sort;
1294 end
1295 end
1296 end
1297  
1298 function MetaMapList_UpdateScroll()
1299 for i = 1, METAMAPLIST_SCROLL_FRAME_BUTTONS_SHOWN, 1 do
1300 local buttonIndex = i + FauxScrollFrame_GetOffset(MetaMapList_ScrollFrame);
1301 local scrollFrameButton = getglobal("MetaMapList_ScrollFrameButton"..i);
1302 local NameButton = getglobal("MetaMapList_ScrollFrameButton"..i.."Name");
1303 if(buttonIndex < MetaMap_NoteList.lastEntry +1) then
1304 MetaMap_ListOffset = buttonIndex - i;
1305 NameButton:SetText(MetaMap_NoteList[buttonIndex]["name"]);
1306 getglobal("MetaMapList_ScrollFrameButton"..i.."NoteID"):SetText(MetaMap_NoteList[buttonIndex]["id"]);
1307 if(MetaMapOptions.ListColors) then
1308 local cNr = MetaMap_NoteList[buttonIndex]["ncol"]
1309 NameButton:SetTextColor(MetaMapNotes_Colors[cNr].r, MetaMapNotes_Colors[cNr].g, MetaMapNotes_Colors[cNr].b);
1310 else
1311 NameButton:SetTextColor(MetaMapNotes_Colors[0].r, MetaMapNotes_Colors[0].g, MetaMapNotes_Colors[0].b);
1312 end
1313 scrollFrameButton:Show();
1314 else
1315 scrollFrameButton:Hide();
1316 end
1317 end
1318 FauxScrollFrame_Update(MetaMapList_ScrollFrame, MetaMap_NoteList.lastEntry,
1319 METAMAPLIST_SCROLL_FRAME_BUTTONS_SHOWN, METAMAPLIST_SCROLL_FRAME_BUTTON_HEIGHT);
1320 end
1321  
1322 function MetaMapPing_SetPing(currentZone, id)
1323 if(MetaMapPing:IsVisible()) then
1324 MetaMapPing:Hide();
1325 return;
1326 end
1327 local x, y;
1328 if(id == 0) then
1329 MetaMapPing:SetParent(WorldMapButton);
1330 x, y = GetPlayerMapPosition("player");
1331 else
1332 MetaMapPing:SetParent(getglobal("MetaMapNotesPOI"..id));
1333 x = currentZone[id]["xPos"];
1334 y = currentZone[id]["yPos"];
1335 end
1336 x = (x * WorldMapButton:GetWidth()) - (WorldMapButton:GetScale() * 7);
1337 y = (-y * WorldMapButton:GetHeight()) - (WorldMapButton:GetScale() * 7);
1338 MetaMapPing:SetPoint("CENTER", WorldMapButton, "TOPLEFT", x, y);
1339 MetaMapPing:SetAlpha(255);
1340 MetaMapPing.timer = MetaMap_PingTime;
1341 MetaMapPing:Show();
1342 PlaySound("MapPing");
1343 end
1344  
1345 function MetaMapPing_OnUpdate(elapsed)
1346 if(MetaMapPing:IsVisible()) then
1347 if ( MetaMapPing.timer > 0 ) then
1348 MetaMapPing.timer = MetaMapPing.timer - elapsed;
1349 else
1350 MetaMapPing:Hide();
1351 end
1352 end
1353 end
1354  
1355 function MetaMap_ZoneHeader()
1356 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
1357 MetaMapNotes_ZoneSearchResult:SetText(format(METAMAPNOTES_ZONESEARCH_TEXT, mapName));
1358 if(not MetaMapOptions.ZoneHeader) then
1359 MetaMap_ZoneHeaderFrame:Hide();
1360 return;
1361 end
1362 local realContinent, realZone = MetaMap_NameToZoneID(GetRealZoneText());
1363 if(realZone == nil) then realZone = 0; end
1364 continent = "|cfff0B300Map Continent: |cffffffff"..continent;
1365 zone = " |cfff0B300Map Zone: |cffffffff"..mapName.." ("..zone..")";
1366 realContinent = "|cfff0B300Real Continent: |cffffffff"..realContinent;
1367 realZone = " |cfff0B300Real Zone: |cffffffff"..GetRealZoneText().." ("..realZone..")";
1368 MetaMapZoneHeaderText1:SetText(continent..zone);
1369 MetaMapZoneHeaderText2:SetText(realContinent..realZone);
1370 MetaMap_ZoneHeaderFrame:SetWidth(WorldMapDetailFrame:GetWidth()-200);
1371 MetaMap_ZoneHeaderFrame:Show();
1372 end
1373  
1374 function MetaMap_LoadImports()
1375 if(not IsAddOnLoaded("MetaMapCVT")) then
1376 LoadAddOn("MetaMapCVT");
1377 end
1378 if(IsAddOnLoaded("MetaMapCVT")) then
1379 MetaMap_LoadExportsButton:Disable();
1380 MetaMapCVT_CheckData();
1381 else
1382 MetaMap_ImportHeader:SetTextColor(1,0,0);
1383 MetaMap_ImportHeader:SetText(METAMAPCVT_NOLOAD);
1384 end
1385 end
1386  
1387 function MetaMap_LoadExports()
1388 if(not IsAddOnLoaded("MetaMapEXP")) then
1389 LoadAddOn("MetaMapEXP");
1390 end
1391 if(IsAddOnLoaded("MetaMapEXP")) then
1392 MetaMap_LoadImportsButton:Disable();
1393 MetaMapEXP_CheckData();
1394 else
1395 MetaMap_ImportHeader:SetTextColor(1,0,0);
1396 MetaMap_ImportHeader:SetText(METAMAPEXP_NOT_ENABLED);
1397 end
1398 end
1399  
1400 function MetaMap_ZSMOnShow()
1401 if(GetLocale() == "deDE") then
1402 MetaMapZSM_TextHeader:SetText("German client detected");
1403 elseif(GetLocale() == "frFR") then
1404 MetaMapZSM_TextHeader:SetText("French client detected");
1405 else
1406 MetaMap_LoadZSMButton:Disable();
1407 MetaMapZSM_TextHeader:SetText("English client detected - no zoneshift required");
1408 end
1409 end
1410  
1411 function MetaMap_LoadZSM()
1412 if(not IsAddOnLoaded("MetaMapZSM")) then
1413 LoadAddOn("MetaMapZSM");
1414 end
1415 if(IsAddOnLoaded("MetaMapZSM")) then
1416 MetaMapZSM_TextHeader:Hide();
1417 MetaMap_LoadZSMButton:Hide();
1418 else
1419 MetaMap_LoadZSMButton:Disable();
1420 MetaMapZSM_TextHeader:SetText(METAMAPZSM_NOT_ENABLED);
1421 end
1422 end
1423  
1424 function MetaMap_LoadBKP()
1425 if(not IsAddOnLoaded("MetaMapBKP")) then
1426 LoadAddOn("MetaMapBKP");
1427 end
1428 if(IsAddOnLoaded("MetaMapBKP")) then
1429 MetaMap_GeneralDialog:Hide();
1430 MetaMapBKP_BackUpFrame:Show();
1431 else
1432 MetaMap_LoadBKP:Disable();
1433 MetaMapBKP_NoLoad:Show();
1434 end
1435 end
1436  
1437 function MetaMap_LoadBLT(lootID, Name)
1438 if(not IsAddOnLoaded("MetaMapBLT")) then
1439 LoadAddOn("MetaMapBLT");
1440 end
1441 if(IsAddOnLoaded("MetaMapBLT")) then
1442 MetaMapBLT_ClassMenu:Hide();
1443 MetaMapBLT_OnSelect(lootID, Name);
1444 else
1445 MetaMap_StatusPrint("MetaMapBLT addon is not enabled!", true);
1446 end
1447 end
1448  
1449 function MetaMap_LoadBWP(id, mode)
1450 if(not IsAddOnLoaded("MetaMapBWP")) then
1451 LoadAddOn("MetaMapBWP");
1452 end
1453 if(IsAddOnLoaded("MetaMapBWP")) then
1454 if(mode == nil) then
1455 BWP_CallMenu();
1456 elseif(mode == 1) then
1457 MetaKBMenu_RBSelect(id);
1458 elseif(mode == 2) then
1459 MetaMapNotes_RBSelect(id);
1460 end
1461 else
1462 MetaMap_StatusPrint(METAMAPBWP_NOT_ENABLED, true);
1463 end
1464 end
1465  
1466 function MetaMap_LoadWKB(mode)
1467 if(not IsAddOnLoaded("MetaMapWKB")) then
1468 LoadAddOn("MetaMapWKB");
1469 end
1470 if(IsAddOnLoaded("MetaMapWKB")) then
1471 if(mode == nil or mode == 1) then
1472 MetaKB_ToggleFrame(mode);
1473 elseif(mode == 2) then
1474 MetaKB_UpdateKeySelectedUnit();
1475 end
1476 else
1477 if(MetaKB_HoldingFrame:IsVisible()) then
1478 MetaKB_HoldingFrameInfo:SetText(METAKB_NOT_ENABLED);
1479 else
1480 MetaMap_StatusPrint(METAKB_NOT_ENABLED, true);
1481 end
1482 end
1483 end
1484  
1485 function MetaMap_LoadFWM(mode)
1486 if(not IsAddOnLoaded("MetaMapFWM")) then
1487 LoadAddOn("MetaMapFWM");
1488 end
1489 if(IsAddOnLoaded("MetaMapFWM")) then
1490 if(mode == nil) then
1491 FWM_ShowUnexplored = true;
1492 end
1493 WorldMapFrame_Update();
1494 else
1495 FWM_ShowUnexplored = false;
1496 MetaMapOptions.FWMretain = false;
1497 if(MetaFWM_HoldingFrame:IsVisible()) then
1498 MetaFWM_HoldingFrameInfo:SetText(METAMAPFWM_NOT_ENABLED);
1499 else
1500 MetaMap_StatusPrint(METAMAPFWM_NOT_ENABLED, true);
1501 end
1502 end
1503 end
1504  
1505 function MetaMap_HelpOnEnter(header, ...)
1506 local myArgs = { unpack(arg) };
1507 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
1508 GameTooltip:SetText(header, 0.2, 0.5, 1, true);
1509 for i,string in myArgs do
1510 GameTooltip:AddLine(string, 1, 1, 1, true);
1511 end
1512 GameTooltip:Show();
1513 end
1514  
1515 function MetaMap_StatusPrint(msg, display, r, g, b)
1516 if(not display) then return; end
1517 msg = "<"..METAMAP_TITLE..">: "..msg;
1518 if DEFAULT_CHAT_FRAME then
1519 if(r == nil or g == nil or b == nil) then
1520 r = 0.60;
1521 g = 0.80;
1522 b = 1.00;
1523 end
1524 DEFAULT_CHAT_FRAME:AddMessage(msg, r, g, b);
1525 end
1526 end
1527  
1528 function MetaMap_CreateNoteObject(noteNumber)
1529 local button;
1530 if(getglobal("MetaMapNotesPOI"..noteNumber)) then
1531 button = getglobal("MetaMapNotesPOI"..noteNumber);
1532 else
1533 button = CreateFrame("Button" ,"MetaMapNotesPOI"..noteNumber, WorldMapButton, "MetaMapNotes_NoteTemplate");
1534 button:SetID(noteNumber);
1535 MetaMapNotes_LastNote = MetaMapNotes_LastNote +1;
1536 end
1537 return button;
1538 end
1539  
1540 function MetaMap_CreateLineObject(lineNumber)
1541 local line;
1542 if(getglobal("MetaMapNotesLines_"..lineNumber)) then
1543 line = getglobal("MetaMapNotesLines_"..lineNumber);
1544 else
1545 MetaMapNotesLinesFrame:CreateTexture("MetaMapNotesLines_"..lineNumber, "ARTWORK");
1546 line = getglobal("MetaMapNotesLines_"..lineNumber);
1547 MetaMapNotes_LastLine = MetaMapNotes_LastLine +1;
1548 end
1549 return line
1550 end
1551  
1552 function MetaMapNotes_AddNewNote(continent, zone, xPos, yPos, name, inf1, inf2, creator, icon, ncol, in1c, in2c, mininote)
1553 if(xPos == 0 and yPos == 0) then
1554 MetaMap_StatusPrint(METAMAPNOTES_INVALIDZONE, true);
1555 return;
1556 end
1557 if(continent == nil or zone == nil or xPos == nil or yPos == nil or name == nil) then return; end
1558 if(inf1 == nil) then inf1 = ""; end
1559 if(inf2 == nil) then inf2 = ""; end
1560 if(icon == nil) then icon = 0; end
1561 if(ncol == nil) then ncol = 0; end
1562 if(in1c == nil) then in1c = 0; end
1563 if(in2c == nil) then in2c = 0; end
1564 if(creator == nil) then creator = unitName("player"); end
1565 local id = 0;
1566 local index = 0;
1567 local checkNote;
1568 local returnValue = true;
1569 local currentZone = MetaMapNotes_Data[continent][zone];
1570 if(continent == -1 or type(continent) == "string") then
1571 currentZone = MetaMapNotes_Data[continent]
1572 else
1573 index = MetaMapNotes_GetZoneTableSize(currentZone);
1574 end
1575  
1576 if(mininote == 0 or mininote == nil) then
1577 MetaMapNotes_SetNextAsMiniNote = 0;
1578 elseif(mininote == 1) then
1579 MetaMapNotes_SetNextAsMiniNote = 1;
1580 elseif(mininote == 2) then
1581 MetaMapNotes_SetNextAsMiniNote = 2;
1582 end
1583  
1584 if(MetaMapNotes_SetNextAsMiniNote ~= 2) then
1585 checkNote = MetaMapNotes_CheckNearNotes(continent, zone, xPos, yPos);
1586 if(checkNote) then
1587 returnValue = false;
1588 else
1589 MetaMapNotes_TempData_Id = index + 1
1590 currentZone[MetaMapNotes_TempData_Id] = {};
1591 currentZone[MetaMapNotes_TempData_Id].name = name;
1592 currentZone[MetaMapNotes_TempData_Id].ncol = ncol;
1593 currentZone[MetaMapNotes_TempData_Id].inf1 = inf1;
1594 currentZone[MetaMapNotes_TempData_Id].in1c = in1c;
1595 currentZone[MetaMapNotes_TempData_Id].inf2 = inf2;
1596 currentZone[MetaMapNotes_TempData_Id].in2c = in2c;
1597 currentZone[MetaMapNotes_TempData_Id].creator = creator;
1598 currentZone[MetaMapNotes_TempData_Id].icon = icon;
1599 currentZone[MetaMapNotes_TempData_Id].xPos = xPos;
1600 currentZone[MetaMapNotes_TempData_Id].yPos = yPos;
1601 id = MetaMapNotes_TempData_Id;
1602 if(MetaMapNotes_MiniNote_Data ~= nil and MetaMapNotes_MiniNote_Data.name == name) then
1603 MetaMapNotes_MiniNote_Data.id = id;
1604 end
1605 returnValue = true;
1606 end
1607 end
1608 if(MetaMapNotes_SetNextAsMiniNote ~= 0) then
1609 for i=0, index, 1 do
1610 if(currentZone[i] ~= nil) then
1611 if(currentZone[i].name == name and currentZone[i].xPos == xPos and currentZone[i].yPos == yPos) then
1612 id = i;
1613 break;
1614 end
1615 end
1616 end
1617 MetaMapNotes_SetMiniNote(id, continent, zone, xPos, yPos, name, inf1, inf2, creator, icon, ncol, in1c, in2c);
1618 returnValue = returnValue;
1619 end
1620 return returnValue, checkNote;
1621 end
1622  
1623 function MetaMapNotes_SetMiniNote(id, continent, zone, xPos, yPos, name, inf1, inf2, creator, icon, ncol, in1c, in2c)
1624 if(type(continent) == "string") then
1625 MetaMap_StatusPrint(METAMAPNOTES_INVALIDZONE, true);
1626 return;
1627 end
1628 local currentZone;
1629 local mapName = MetaMap_ZoneNames[continent][zone];
1630  
1631 MetaMapNotes_MiniNote_Data.id = id;
1632 MetaMapNotes_MiniNote_Data.continent = continent;
1633 MetaMapNotes_MiniNote_Data.zone = zone;
1634 MetaMapNotes_MiniNote_Data.zonetext = mapName;
1635 MetaMapNotes_MiniNote_Data.inf1 = "";
1636 MetaMapNotes_MiniNote_Data.inf2 = "";
1637 MetaMapNotes_MiniNote_Data.in1c = 1;
1638 MetaMapNotes_MiniNote_Data.in2c = 1;
1639 MetaMapNotes_MiniNote_Data.color = 0;
1640 MetaMapNotes_MiniNote_Data.creator = creator;
1641 if(id == 0) then
1642 MetaMapNotes_MiniNote_Data.xPos = xPos;
1643 MetaMapNotes_MiniNote_Data.yPos = yPos;
1644 MetaMapNotes_MiniNote_Data.name = name;
1645 MetaMapNotes_MiniNote_Data.inf1 = inf1;
1646 MetaMapNotes_MiniNote_Data.inf2 = inf2;
1647 MetaMapNotes_MiniNote_Data.in1c = in1c;
1648 MetaMapNotes_MiniNote_Data.in2c = in2c;
1649 MetaMapNotes_MiniNote_Data.color = ncol;
1650 MetaMapNotes_MiniNote_Data.icon = icon;
1651 elseif(id == -1) then
1652 MetaMapNotes_MiniNote_Data.xPos = MetaMapNotes_PartyNoteData.xPos;
1653 MetaMapNotes_MiniNote_Data.yPos = MetaMapNotes_PartyNoteData.yPos;
1654 MetaMapNotes_MiniNote_Data.name = METAMAPNOTES_PARTYNOTE;
1655 MetaMapNotes_MiniNote_Data.icon = "party";
1656 elseif(id > 0) then
1657 currentZone = MetaMapNotes_Data[continent][zone][id];
1658 MetaMapNotes_MiniNote_Data.xPos = currentZone.xPos;
1659 MetaMapNotes_MiniNote_Data.yPos = currentZone.yPos;
1660 MetaMapNotes_MiniNote_Data.name = currentZone.name;
1661 MetaMapNotes_MiniNote_Data.inf1 = currentZone.inf1;
1662 MetaMapNotes_MiniNote_Data.inf2 = currentZone.inf2;
1663 MetaMapNotes_MiniNote_Data.in1c = currentZone.in1c;
1664 MetaMapNotes_MiniNote_Data.in2c = currentZone.in2c;
1665 MetaMapNotes_MiniNote_Data.color = currentZone.ncol;
1666 MetaMapNotes_MiniNote_Data.icon = currentZone.icon;
1667 MetaMapNotes_MiniNote_Data.creator = currentZone.creator;
1668 end
1669 MiniNotePOITexture:SetTexture(METAMAP_ICON_PATH.."Icon"..MetaMapNotes_MiniNote_Data.icon);
1670 MiniNotePOI:Show();
1671 MetaMapNotes_SetNextAsMiniNote = 0;
1672 MetaMapNotesButtonMiniNoteOff:Enable();
1673 MetaMapNotes_MapUpdate();
1674 end
1675  
1676 function MetaMapNotes_CheckNearNotes(continent, zone, xPos, yPos)
1677 local currentZone = MetaMapNotes_Data[continent][zone];
1678 if(currentZone == nil) then return; end
1679 for i, value in currentZone do
1680 local deltax = abs(currentZone[i].xPos - xPos);
1681 local deltay = abs(currentZone[i].yPos - yPos);
1682 if(deltax <= 0.0009765625 * MetaMapNotes_MinDiff and deltay <= 0.0013020833 * MetaMapNotes_MinDiff) then
1683 return i;
1684 end
1685 end
1686 return false;
1687 end
1688  
1689 function MetaMapNotes_GenerateSendString(version)
1690 -- <MapN> c<1> z<1> x<0.123123> y<0.123123> t<> i1<> i2<> cr<> i<8> tf<3> i1f<5> i2f<6>
1691 local text = ""
1692 local pName = UnitName("player");
1693 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
1694 if(not currentZone) then return; end
1695 zone = MetaMapNotes_ZoneShift[continent][zone];
1696 currentZone = MetaMapNotes_Data[continent][zone];
1697 if(version == 1) then text = "<MapN>"; end
1698 text = text.." c<"..continent.."> z<"..zone..">";
1699  
1700 if(MetaMapNotes_PartyNoteSet) then
1701 local xPos = floor(MetaMapNotes_PartyNoteData.xPos * 1000000)/1000000;
1702 local yPos = floor(MetaMapNotes_PartyNoteData.yPos * 1000000)/1000000;
1703 text = text.." x<"..xPos.."> y<"..yPos..">";
1704 text = text.." t<"..METAMAPNOTES_PARTYNOTE..">";
1705 text = text.." i1<>";
1706 text = text.." i2<>";
1707 text = text.." cr<"..pName..">";
1708 text = text.." i<0>";
1709 text = text.." tf<0>";
1710 text = text.." i1f<0>";
1711 text = text.." i2f<0>";
1712 text = text.." p<1>";
1713 elseif(MetaMapNotes_MiniNote_Data.id == 0) then
1714 local xPos = floor(MetaMapNotes_MiniNote_Data.xPos * 1000000)/1000000;
1715 local yPos = floor(MetaMapNotes_MiniNote_Data.yPos * 1000000)/1000000;
1716 text = text.." x<"..xPos.."> y<"..yPos..">";
1717 text = text.." t<"..MetaMapNotes_EliminateUsedChars(MetaMapNotes_MiniNote_Data.name)..">";
1718 text = text.." i1<"..MetaMapNotes_EliminateUsedChars(MetaMapNotes_MiniNote_Data.inf1)..">";
1719 text = text.." i2<"..MetaMapNotes_EliminateUsedChars(MetaMapNotes_MiniNote_Data.inf2)..">";
1720 text = text.." cr<"..MetaMapNotes_MiniNote_Data.creator..">";
1721 text = text.." i<"..MetaMapNotes_MiniNote_Data.icon..">";
1722 text = text.." tf<"..MetaMapNotes_MiniNote_Data.color..">";
1723 text = text.." i1f<"..MetaMapNotes_MiniNote_Data.in1c..">";
1724 text = text.." i2f<"..MetaMapNotes_MiniNote_Data.in2c..">";
1725 else
1726 if(not currentZone[MetaMapNotes_TempData_Id].creator) then
1727 currentZone[MetaMapNotes_TempData_Id].creator = pName;
1728 end
1729 local xPos = floor(currentZone[MetaMapNotes_TempData_Id].xPos * 1000000)/1000000; --cut to six digits behind the 0
1730 local yPos = floor(currentZone[MetaMapNotes_TempData_Id].yPos * 1000000)/1000000;
1731 text = text.." x<"..xPos.."> y<"..yPos..">";
1732 text = text.." t<"..MetaMapNotes_EliminateUsedChars(currentZone[MetaMapNotes_TempData_Id].name)..">";
1733 text = text.." i1<"..MetaMapNotes_EliminateUsedChars(currentZone[MetaMapNotes_TempData_Id].inf1)..">";
1734 text = text.." i2<"..MetaMapNotes_EliminateUsedChars(currentZone[MetaMapNotes_TempData_Id].inf2)..">";
1735 text = text.." cr<"..currentZone[MetaMapNotes_TempData_Id].creator..">";
1736 text = text.." i<"..currentZone[MetaMapNotes_TempData_Id].icon..">";
1737 text = text.." tf<"..currentZone[MetaMapNotes_TempData_Id].ncol..">";
1738 text = text.." i1f<"..currentZone[MetaMapNotes_TempData_Id].in1c..">";
1739 text = text.." i2f<"..currentZone[MetaMapNotes_TempData_Id].in2c..">";
1740 end
1741 MetaMapNotes_PartyNoteSet = false;
1742 return text;
1743 end
1744  
1745 function MetaMapNotes_EliminateUsedChars(text)
1746 text = string.gsub(text, "<", "")
1747 text = string.gsub(text, ">", "")
1748 return text
1749 end
1750  
1751 function MetaMapNotes_GetSendString(msg, who)
1752 local continent = gsub(msg,".*<MapN+> c<([^>]*)>.*","%1",1)+0;
1753 local zone = gsub(msg,".*<MapN+>%s+%w+.*z<([^>]*)>.*","%1",1)+0;
1754 local xPos = gsub(msg,".*<MapN+>%s+%w+.*x<([^>]*)>.*","%1",1)+0;
1755 local yPos = gsub(msg,".*<MapN+>%s+%w+.*y<([^>]*)>.*","%1",1)+0;
1756 local name = gsub(msg,".*<MapN+>%s+%w+.*t<([^>]*)>.*","%1",1);
1757 local inf1 = gsub(msg,".*<MapN+>%s+%w+.*i1<([^>]*)>.*","%1",1);
1758 local inf2 = gsub(msg,".*<MapN+>%s+%w+.*i2<([^>]*)>.*","%1",1);
1759 local creator = gsub(msg,".*<MapN+>%s+%w+.*cr<([^>]*)>.*","%1",1);
1760 local icon = gsub(msg,".*<MapN+>%s+%w+.*i<([^>]*)>.*","%1",1)+0;
1761 local ncol = gsub(msg,".*<MapN+>%s+%w+.*tf<([^>]*)>.*","%1",1)+0;
1762 local in1c = gsub(msg,".*<MapN+>%s+%w+.*i1f<([^>]*)>.*","%1",1)+0;
1763 local in2c = gsub(msg,".*<MapN+>%s+%w+.*i2f<([^>]*)>.*","%1",1)+0;
1764 zone = MetaMapNotes_ZoneShift[continent][zone];
1765 local setNote, nearNote = MetaMapNotes_AddNewNote(continent, zone, xPos, yPos, name, inf1, inf2, creator, icon, ncol, in1c, in2c, MetaMapNotes_SetNextAsMiniNote);
1766 if(who == nil) then
1767 if(setNote) then
1768 MetaMap_StatusPrint(format(METAMAPNOTES_ACCEPT_NOTE, MetaMap_ZoneNames[continent][zone]), true);
1769 else
1770 MetaMap_StatusPrint(format(METAMAPNOTES_DECLINE_NOTE, MetaMapNotes_Data[continent][zone][nearNote].name, MetaMap_ZoneNames[continent][zone]), true);
1771 end
1772 else
1773 if(setNote) then
1774 MetaMap_StatusPrint(format(METAMAPNOTES_ACCEPT_GET, who, MetaMap_ZoneNames[continent][zone]), true);
1775 else
1776 MetaMap_StatusPrint(format(METAMAPNOTES_DECLINE_GET, who, MetaMap_ZoneNames[continent][zone], MetaMapNotes_Data[continent][zone][nearNote].name), true);
1777 end
1778 end
1779 return setNote;
1780 end
1781  
1782 function MetaMapNotes_Quicknote(msg)
1783 local currentZone;
1784 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText())
1785 if(type(continent) == "string") then
1786 SetMapToCurrentZone();
1787 tx, ty = GetPlayerMapPosition("player");
1788 if(tx == 0 or tx == nil) then
1789 MetaMap_StatusPrint(METAMAPNOTES_INVALIDZONE, true);
1790 return;
1791 end
1792 currentZone = MetaMapNotes_Data[continent];
1793 else
1794 currentZone = MetaMapNotes_Data[continent][zone];
1795 end
1796 local name = METAMAPNOTES_QUICKNOTE_DEFAULTNAME;
1797 if(msg ~= "" and msg ~= nil) then
1798 if(strlen(msg) == 1) then
1799 mode = tonumber(strsub(msg, 1, 1));
1800 msg = "";
1801 else
1802 local mCheck = strsub(msg, 1, 2);
1803 if(mCheck == "1 " or mCheck == "2 " or mCheck == "3 ") then
1804 mode = tonumber(strsub(msg, 1, 1));
1805 msg = strsub(msg, 3);
1806 else
1807 mode = MetaMapNotes_SetNextAsMiniNote;
1808 end
1809 end
1810 else
1811 mode = MetaMapNotes_SetNextAsMiniNote;
1812 end
1813 local i,j,x,y,tmp = string.find(msg,"%s*(%d+)%s*[,.]%s*(%d+)%s*([^%c]*)");
1814 if(x == nil or y == nil) then
1815 SetMapToCurrentZone();
1816 x, y = GetPlayerMapPosition("player");
1817 else
1818 x = x / 100;
1819 y = y / 100;
1820 msg = tmp;
1821 end
1822 if(mode == 3) then
1823 MetaMapNotes_vnote_xPos = x;
1824 MetaMapNotes_vnote_yPos = y;
1825 MetaMap_StatusPrint(METAMAPNOTES_VNOTE_SET, true);
1826 return;
1827 end
1828 if msg ~= "" and msg ~= nil then
1829 name = string.sub(msg,string.find(msg,"%s*([^%c]*)"));
1830 end
1831 local checkNote, nearNote = MetaMapNotes_AddNewNote(continent, zone, x, y, name, "", "", UnitName("player"), 0, 0, 0, 0, mode);
1832 if(checkNote) then
1833 if(mode ~= 2) then
1834 MetaMap_StatusPrint(format(METAMAPNOTES_ACCEPT_NOTE, GetRealZoneText()), true);
1835 end
1836 else
1837 MetaMap_StatusPrint(format(METAMAPNOTES_DECLINE_NOTE, currentZone[nearNote].name, GetRealZoneText()), true);
1838 end
1839 if(mode > 0) then
1840 MetaMap_StatusPrint(format(METAMAPNOTES_ACCEPT_MININOTE, GetRealZoneText()), true);
1841 end
1842 MetaMapNotes_Qnote = false;
1843 end
1844  
1845 function MetaMapNotes_QuickNoteShow()
1846 local x, y = GetPlayerMapPosition("player");
1847 x = MetaMap_round(x*100);
1848 y = MetaMap_round(y*100);
1849 Coords_EditBox:SetText(x..","..y);
1850 MiniNote_CheckButton:SetChecked(false);
1851 MetaMapNotes_Qnote = true;
1852 end
1853  
1854 function MetaMapNotes_SetQuickNote(mode)
1855 local msg;
1856 if(mode == 1) then
1857 msg = Coords_EditBox:GetText().." "..Note_EditBox:GetText();
1858 else
1859 msg = "3 "..Coords_EditBox:GetText();
1860 end
1861 MetaMapNotes_Quicknote(msg);
1862 end
1863  
1864 function MetaMapNotes_GetNoteFromChat(msg, who)
1865 if(not MetaMapOptions.AcceptIncoming) then
1866 MetaMap_StatusPrint(format(METAMAPNOTES_DISABLED_GET, who), true)
1867 return;
1868 end
1869 if(gsub(msg,".*<MapN+>%s+%w+.*p<([^>]*)>.*","%1",1) == "1") then -- Party Note
1870 local id = -1;
1871 local continent = gsub(msg,".*<MapN+> c<([^>]*)>.*","%1",1)+0;
1872 local zone = gsub(msg,".*<MapN+>%s+%w+.*z<([^>]*)>.*","%1",1)+0;
1873 local xPos = gsub(msg,".*<MapN+>%s+%w+.*x<([^>]*)>.*","%1",1)+0;
1874 local yPos = gsub(msg,".*<MapN+>%s+%w+.*y<([^>]*)>.*","%1",1)+0;
1875 local icon = "party";
1876 zone = MetaMapNotes_ZoneShift[continent][zone];
1877 MetaMapNotes_PartyNoteData.continent = continent;
1878 MetaMapNotes_PartyNoteData.zone = zone;
1879 MetaMapNotes_PartyNoteData.xPos = xPos;
1880 MetaMapNotes_PartyNoteData.yPos = yPos;
1881 if(MetaMapOptions.MiniParty) then
1882 MetaMapNotes_SetMiniNote(id, continent, zone, xPos, yPos, name, inf1, inf2, creator, icon, ncol, in1c, in2c);
1883 MetaMap_StatusPrint(format(METAMAPNOTES_PARTY_GET, who, MetaMap_ZoneNames[continent][zone]), true)
1884 end
1885 else
1886 MetaMapNotes_GetSendString(msg, who);
1887 end
1888 end
1889  
1890 function MetaMapNotes_GetNoteBySlashCommand(msg)
1891 if msg ~= "" and msg ~= nil then
1892 msg = "<MapN> "..msg;
1893 return MetaMapNotes_GetSendString(msg);
1894 else
1895 MetaMap_StatusPrint(METAMAPNOTES_MAPNOTEHELP, true);
1896 return false;
1897 end
1898 end
1899  
1900 function MetaMapNotes_Misc_OnClick(button)
1901 if(not MetaMapNotes_FramesHidden()) then return; end
1902 if button == "LeftButton" then
1903 if(this:GetID() == 0) then
1904 MetaMapNotes_TempData_Id = 0;
1905 MetaMapNotes_OpenEditForExistingNote(MetaMapNotes_TempData_Id);
1906 elseif(this:GetID() == 1) then
1907 MetaMapNotes_PartyNoteSet = true;
1908 MetaMapNotes_TempData_Id = -1;
1909 MetaMapNotes_ShowSendFrame(1);
1910 end
1911 end
1912 end
1913  
1914 function MetaMapNotes_NextMiniNote(msg)
1915 msg = string.lower(msg)
1916 if msg == "on" then
1917 MetaMapNotes_SetNextAsMiniNote = 1
1918 elseif msg == "off" then
1919 MetaMapNotes_SetNextAsMiniNote = 0
1920 elseif MetaMapNotes_SetNextAsMiniNote == 1 then
1921 MetaMapNotes_SetNextAsMiniNote = 0
1922 else
1923 MetaMapNotes_SetNextAsMiniNote = 1
1924 end
1925 end
1926  
1927 function MetaMapNotes_NextMiniNoteOnly(msg)
1928 msg = string.lower(msg)
1929 if msg == "on" then
1930 MetaMapNotes_SetNextAsMiniNote = 2
1931 elseif msg == "off" then
1932 MetaMapNotes_SetNextAsMiniNote = 0
1933 elseif MetaMapNotes_SetNextAsMiniNote == 2 then
1934 MetaMapNotes_SetNextAsMiniNote = 0
1935 else
1936 MetaMapNotes_SetNextAsMiniNote = 2
1937 end
1938 end
1939  
1940 function MetaMapNotes_MinimapUpdateZoom()
1941 if MetaMapNotes_MiniNote_MapzoomInit then
1942 if MetaMapNotes_MiniNote_IsInCity then
1943 MetaMapNotes_MiniNote_IsInCity = false
1944 else
1945 MetaMapNotes_MiniNote_IsInCity = true
1946 end
1947 else
1948 local tempzoom = 0
1949 if GetCVar("minimapZoom") == GetCVar("minimapInsideZoom") then
1950 if GetCVar("minimapInsideZoom")+0 >= 3 then
1951 Minimap:SetZoom(Minimap:GetZoom() - 1)
1952 tempzoom = 1
1953 else
1954 Minimap:SetZoom(Minimap:GetZoom() + 1)
1955 tempzoom = -1
1956 end
1957 end
1958  
1959 if GetCVar("minimapInsideZoom")+0 == Minimap:GetZoom() then
1960 MetaMapNotes_MiniNote_IsInCity = true
1961 else
1962 MetaMapNotes_MiniNote_IsInCity = false
1963 end
1964  
1965 Minimap:SetZoom(Minimap:GetZoom() + tempzoom)
1966 MetaMapNotes_MiniNote_MapzoomInit = true
1967 end
1968 end
1969  
1970 function MetaMapNotes_MiniNote_OnUpdate(delay)
1971 if(MetaMapNotes_MiniNote_Data.xPos == nil or GetRealZoneText() ~= MetaMapNotes_MiniNote_Data.zonetext) then
1972 MiniNotePOI:Hide();
1973 return;
1974 end
1975 local continent, zone = MetaMap_NameToZoneID(GetRealZoneText());
1976 MiniNotePOI.TimeSinceLastUpdate = MiniNotePOI.TimeSinceLastUpdate + delay;
1977 if MiniNotePOI.TimeSinceLastUpdate >= MetaMapNotes_Mininote_UpdateRate then
1978 local x, y = GetPlayerMapPosition("player");
1979 if x == 0 and y == 0 then
1980 MiniNotePOI:Hide()
1981 return
1982 end
1983 local currentConst
1984 if(type(continent) == "string") then
1985 currentConst = MetaMapNotes_Const[continent]
1986 elseif continent > 0 and MetaMapNotes_MiniNote_Data.continent > 0 then
1987 local c = MetaMapNotes_MiniNote_Data.continent
1988 local z = MetaMapNotes_MiniNote_Data.zone
1989 currentConst = MetaMapNotes_Const[c][z]
1990 else
1991 MiniNotePOI:Hide();
1992 return;
1993 end
1994 local currentZoom = Minimap:GetZoom()
1995 if currentConst and x ~= 0 and y ~= 0 and currentConst.scale ~= 0 then
1996 local xscale,yscale
1997 if zone > 0 then
1998 xscale = MetaMapNotes_Const[MetaMapNotes_MiniNote_Data.continent][currentZoom].xscale
1999 yscale = MetaMapNotes_Const[MetaMapNotes_MiniNote_Data.continent][currentZoom].yscale
2000 else
2001 xscale = MetaMapNotes_Const[2][currentZoom].xscale
2002 yscale = MetaMapNotes_Const[2][currentZoom].yscale
2003 end
2004  
2005 if MetaMapNotes_MiniNote_IsInCity then
2006 xscale = xscale * MetaMapNotes_Const[2][currentZoom].cityscale
2007 yscale = yscale * MetaMapNotes_Const[2][currentZoom].cityscale
2008 end
2009 local xpos = MetaMapNotes_MiniNote_Data.xPos * currentConst.scale + currentConst.xoffset
2010 local ypos = MetaMapNotes_MiniNote_Data.yPos * currentConst.scale + currentConst.yoffset
2011 x = x * currentConst.scale + currentConst.xoffset
2012 y = y * currentConst.scale + currentConst.yoffset
2013 local deltax = (xpos - x) * xscale
2014 local deltay = (ypos - y) * yscale
2015 if sqrt( (deltax * deltax) + (deltay * deltay) ) > 56.5 then
2016 local adjust = 1
2017 if deltax == 0 then
2018 deltax = deltax + 0.0000000001
2019 elseif deltax < 0 then
2020 adjust = -1
2021 end
2022 local m = math.atan(deltay / deltax)
2023 deltax = math.cos(m) * 57 * adjust
2024 deltay = math.sin(m) * 57 * adjust
2025 end
2026 MiniNotePOI:SetPoint("CENTER", "MinimapCluster", "TOPLEFT", 105 + deltax, -93 - deltay)
2027 MiniNotePOI:Show()
2028 else
2029 MiniNotePOI:Hide()
2030 end
2031 end
2032 MiniNotePOI.TimeSinceLastUpdate = 0
2033 end
2034  
2035 function MetaMapNotes_MiniNote_OnClick(arg1)
2036 if(arg1 == "LeftButton" and IsShiftKeyDown() and ChatFrameEditBox:IsVisible()) then
2037 local x = MetaMap_round(MetaMapNotes_MiniNote_Data.xPos *100);
2038 local y = MetaMap_round(MetaMapNotes_MiniNote_Data.yPos *100);
2039 local msg = MetaMapNotes_MiniNote_Data.name.." ("..GetRealZoneText().." - "..x..","..y..")";
2040 ChatFrameEditBox:Insert(msg);
2041 else
2042 if(MetaMapNotes_MiniNote_Data.id > 0) then
2043 SetMapToCurrentZone();
2044 if(not WorldMapFrame:IsVisible()) then
2045 MetaMapNotesEditFrame:SetParent("UIParent");
2046 end
2047 MetaMapNotes_OpenEditForExistingNote(MetaMapNotes_MiniNote_Data.id);
2048 elseif(MetaMapNotes_MiniNote_Data.id == 0) then
2049 MetaMapNotes_TempData_Id = 0;
2050 MetaMapNotes_ShowSendFrame(0);
2051 else
2052 MetaMapNotes_PartyNoteSet = true;
2053 MetaMapNotes_TempData_Id = -1;
2054 MetaMapNotes_ShowSendFrame(1);
2055 end
2056 end
2057 end
2058  
2059 function MetaMapNotes_ShowNewFrame(ax, ay)
2060 if(not MetaMapNotes_FramesHidden()) then return; end
2061 local width = WorldMapButton:GetWidth();
2062 local height = WorldMapButton:GetHeight();
2063 local xOffset,yOffset;
2064 MetaMapNotes_TempData_xPos = ax;
2065 MetaMapNotes_TempData_yPos = ay;
2066 MetaMapNotes_TempData_Id = nil;
2067 if ax*1002 >= (1002 - 195) then
2068 xOffset = ax * width - 176;
2069 else
2070 xOffset = ax * width;
2071 end
2072 if ay*668 <= (668 - 156) then
2073 yOffset = -(ay * height) - 75;
2074 else
2075 yOffset = -(ay * height) + 87;
2076 end
2077 MetaMapNotesButtonMiniNoteOff:Disable();
2078 MetaMapNotesButtonMiniNoteOn:Disable();
2079 MetaMapNotesButtonDeleteNote:Disable();
2080 MetaMapNotesButtonToggleLine:Disable();
2081 MetaMapNotesButtonSendNote:Disable();
2082 MetaMapNotesButtonMoveNote:Disable();
2083 MetaMapNotesEditFrameTitle:SetText(METAMAPNOTES_NEW_NOTE);
2084 MetaMapNotes_OpenEditForNewNote();
2085 end
2086  
2087 function MetaMapNotes_OpenEditForNewNote()
2088 if MetaMapNotes_TempData_Id == 0 then
2089 MetaMapNotes_vnote_xPos = nil
2090 MetaMapNotes_vnote_yPos = nil
2091 end
2092 MetaMapNotes_TempData_Id = MetaMapNotes_NewNoteSlot()
2093 MetaMapNotes_TempData_Creator = UnitName("player")
2094 MetaMapNotes_Edit_SetIcon(0)
2095 MetaMapNotes_Edit_SetTextColor(0)
2096 MetaMapNotes_Edit_SetInfo1Color(0)
2097 MetaMapNotes_Edit_SetInfo2Color(0)
2098 TitleWideEditBox:SetText("")
2099 Info1WideEditBox:SetText("")
2100 Info2WideEditBox:SetText("")
2101 CreatorWideEditBox:SetText(MetaMapNotes_TempData_Creator)
2102 MetaMapNotes_HideAll()
2103 MetaMapNotesEditFrame:Show()
2104 end
2105  
2106 function MetaMapNotes_OpenEditForExistingNote(id)
2107 MetaMapNotes_HideAll();
2108 MetaMapNotesEditFrameTitle:SetText(METAMAPNOTES_EDIT_NOTE);
2109 if(MetaMapNotes_MiniNote_Data.xPos == nil) then
2110 MetaMapNotesButtonMiniNoteOff:Disable();
2111 else
2112 MetaMapNotesButtonMiniNoteOff:Enable();
2113 end
2114 MetaMapNotesButtonMiniNoteOn:Enable();
2115 MetaMapNotesButtonDeleteNote:Enable();
2116 MetaMapNotesButtonToggleLine:Enable();
2117 MetaMapNotesButtonMoveNote:Enable();
2118  
2119 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
2120 MetaMapNotes_TempData_Id = id
2121  
2122 if(id == 0) then
2123 WorldMapTooltip:Hide();
2124 MetaMapNotes_ShowNewFrame(MetaMapNotes_vnote_xPos, MetaMapNotes_vnote_yPos);
2125 return;
2126 elseif(id == -1) then
2127 WorldMapTooltip:Hide();
2128 MetaMapNotes_ShowNewFrame(MetaMapNotes_PartyNoteData.xPos, MetaMapNotes_PartyNoteData.yPos);
2129 return;
2130 end
2131 MetaMapNotes_TempData_LootID = nil;
2132 if(currentZone[MetaMapNotes_TempData_Id].lootid ~= nil)then
2133 MetaMapNotes_TempData_LootID = currentZone[MetaMapNotes_TempData_Id].lootid
2134 end
2135 MetaMapNotes_TempData_Name = currentZone[MetaMapNotes_TempData_Id].name;
2136 MetaMapNotes_TempData_Creator = currentZone[MetaMapNotes_TempData_Id].creator;
2137 MetaMapNotes_TempData_xPos = currentZone[MetaMapNotes_TempData_Id].xPos;
2138 MetaMapNotes_TempData_yPos = currentZone[MetaMapNotes_TempData_Id].yPos;
2139 MetaMapNotes_Edit_SetIcon(currentZone[MetaMapNotes_TempData_Id].icon);
2140 MetaMapNotes_Edit_SetTextColor(currentZone[MetaMapNotes_TempData_Id].ncol);
2141 MetaMapNotes_Edit_SetInfo1Color(currentZone[MetaMapNotes_TempData_Id].in1c);
2142 MetaMapNotes_Edit_SetInfo2Color(currentZone[MetaMapNotes_TempData_Id].in2c);
2143 TitleWideEditBox:SetText(currentZone[MetaMapNotes_TempData_Id].name);
2144 Info1WideEditBox:SetText(currentZone[MetaMapNotes_TempData_Id].inf1);
2145 Info2WideEditBox:SetText(currentZone[MetaMapNotes_TempData_Id].inf2);
2146 CreatorWideEditBox:SetText(currentZone[MetaMapNotes_TempData_Id].creator);
2147 MetaMapNotesEditFrame:Show();
2148 end
2149  
2150 function MetaMapNotes_ShowSendFrame(number)
2151 MetaMapNotesSendPlayer:Enable();
2152 MetaMapNotesSendParty:Enable();
2153 MetaMapNotesChangeSendFrame:Enable();
2154 SendWideEditBox:Show();
2155 MetaMapNotes_SendFrame_Player:Show();
2156 if(number == 0) then
2157 MetaMapNotesDeletePartyNote:Show();
2158 MetaMapNotes_ToggleSendValue = 2;
2159 elseif(number == 1) then
2160 if(MetaMapNotes_PartyNoteSet) then
2161 MetaMapNotesDeletePartyNote:Show();
2162 MetaMapNotesSendPlayer:Disable();
2163 MetaMapNotesChangeSendFrame:Disable();
2164 SendWideEditBox:Hide();
2165 MetaMapNotes_SendFrame_Player:Hide();
2166 end
2167 MetaMapNotesChangeSendFrame:SetText(METAMAPNOTES_SLASHCOMMAND);
2168 SendWideEditBox:SetText("");
2169 if(UnitCanCooperate("player", "target")) then
2170 SendWideEditBox:SetText(UnitName("target"));
2171 end
2172 MetaMapNotes_SendFrame_Title:SetText(METAMAPNOTES_SEND_NOTE);
2173 MetaMapNotes_SendFrame_Tip:SetText(METAMAPNOTES_SEND_TIP);
2174 MetaMapNotes_SendFrame_Player:SetText(METAMAPNOTES_SEND_PLAYER);
2175 MetaMapNotes_ToggleSendValue = 2;
2176 elseif(number == 2) then
2177 MetaMapNotesChangeSendFrame:SetText(METAMAPNOTES_SHOWSEND);
2178 SendWideEditBox:SetText("/mapnote"..MetaMapNotes_GenerateSendString(2));
2179 MetaMapNotes_SendFrame_Title:SetText(METAMAPNOTES_SEND_SLASHTITLE);
2180 MetaMapNotes_SendFrame_Tip:SetText(METAMAPNOTES_SEND_SLASHTIP);
2181 MetaMapNotes_SendFrame_Player:SetText(METAMAPNOTES_SEND_SLASHCOMMAND);
2182 MetaMapNotes_ToggleSendValue = 1;
2183 end
2184 if(not MetaMapNotesSendFrame:IsVisible()) then
2185 MetaMapNotes_HideAll();
2186 MetaMapNotesSendFrame:Show();
2187 end
2188 end
2189  
2190 function MetaMapNotes_Edit_SetIcon(icon)
2191 MetaMapNotes_TempData_Icon = icon;
2192 IconOverlay:SetPoint("TOPLEFT", "EditIcon"..icon, "TOPLEFT", -3, 3);
2193 end
2194  
2195 function MetaMapNotes_Edit_SetTextColor(color)
2196 MetaMapNotes_TempData_TextColor = color
2197 TextColorOverlay:SetPoint("TOPLEFT", "TextColor"..color, "TOPLEFT", -3, 3)
2198 end
2199  
2200 function MetaMapNotes_Edit_SetInfo1Color(color)
2201 MetaMapNotes_TempData_Info1Color = color
2202 Info1ColorOverlay:SetPoint("TOPLEFT", "Info1Color"..color, "TOPLEFT", -3, 3)
2203 end
2204  
2205 function MetaMapNotes_Edit_SetInfo2Color(color)
2206 MetaMapNotes_TempData_Info2Color = color
2207 Info2ColorOverlay:SetPoint("TOPLEFT", "Info2Color"..color, "TOPLEFT", -3, 3)
2208 end
2209  
2210 function MetaMapNotes_SendNote(type)
2211 if(type == 1) then
2212 SendChatMessage(MetaMapNotes_GenerateSendString(1), "WHISPER", this.language, SendWideEditBox:GetText())
2213 MetaMap_StatusPrint(format(METAMAPNOTES_NOTE_SENT, SendWideEditBox:GetText()), true);
2214 elseif(type == 2) then
2215 local name;
2216 if(GetNumRaidMembers() > 0 ) then
2217 for i=1, GetNumRaidMembers(), 1 do
2218 name = GetRaidRosterInfo(i);
2219 if(name ~= UnitName("player")) then
2220 SendChatMessage(MetaMapNotes_GenerateSendString(1), "WHISPER", this.language, name)
2221 end
2222 end
2223 MetaMap_StatusPrint(METAMAPNOTES_RAIDSENT, true);
2224 elseif(GetNumPartyMembers() > 0) then
2225 for i=1, GetNumPartyMembers(), 1 do
2226 name = UnitName("party"..i);
2227 if(name ~= UnitName("player")) then
2228 SendChatMessage(MetaMapNotes_GenerateSendString(1), "WHISPER", this.language, name)
2229 end
2230 end
2231 MetaMap_StatusPrint(METAMAPNOTES_PARTYSENT, true);
2232 else
2233 MetaMap_StatusPrint(METAMAPNOTES_NOPARTY, true);
2234 end
2235 end
2236 MetaMapNotes_HideAll()
2237 end
2238  
2239 function MetaMapNotes_ClearMiniNote(skipMapUpdate)
2240 MetaMapNotes_MiniNote_Data = {};
2241 if(MetaMapNotes_PartyNoteData ~= nil) then
2242 MetaMapNotes_DeleteNote(-1)
2243 end
2244 MiniNotePOI:Hide();
2245 MetaMapNotesButtonMiniNoteOff:Disable();
2246 if not skipMapUpdate then
2247 MetaMapNotes_MapUpdate();
2248 end
2249 end
2250  
2251 function MetaMapNotes_WriteNote()
2252 MetaMapNotes_HideAll();
2253 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
2254 if(not currentZone) then return; end
2255  
2256 currentZone[MetaMapNotes_TempData_Id] = {};
2257 currentZone[MetaMapNotes_TempData_Id].name = TitleWideEditBox:GetText();
2258 currentZone[MetaMapNotes_TempData_Id].ncol = MetaMapNotes_TempData_TextColor;
2259 currentZone[MetaMapNotes_TempData_Id].inf1 = Info1WideEditBox:GetText();
2260 currentZone[MetaMapNotes_TempData_Id].in1c = MetaMapNotes_TempData_Info1Color;
2261 currentZone[MetaMapNotes_TempData_Id].inf2 = Info2WideEditBox:GetText();
2262 currentZone[MetaMapNotes_TempData_Id].in2c = MetaMapNotes_TempData_Info2Color;
2263 currentZone[MetaMapNotes_TempData_Id].creator = CreatorWideEditBox:GetText();
2264 currentZone[MetaMapNotes_TempData_Id].icon = MetaMapNotes_TempData_Icon;
2265 currentZone[MetaMapNotes_TempData_Id].xPos = MetaMapNotes_TempData_xPos;
2266 currentZone[MetaMapNotes_TempData_Id].yPos = MetaMapNotes_TempData_yPos;
2267 if(MetaMapNotes_TempData_LootID ~= nil)then
2268 currentZone[MetaMapNotes_TempData_Id].lootid = MetaMapNotes_TempData_LootID;
2269 MetaMapNotes_TempData_LootID = nil;
2270 end
2271  
2272 if(continent == MetaMapNotes_MiniNote_Data.continent and MetaMapNotes_MiniNote_Data.zone == zone and MetaMapNotes_MiniNote_Data.id == MetaMapNotes_TempData_Id) then
2273 MetaMapNotes_MiniNote_Data.zonetext = mapName;
2274 MetaMapNotes_MiniNote_Data.name = TitleWideEditBox:GetText();
2275 MetaMapNotes_MiniNote_Data.icon = MetaMapNotes_TempData_Icon;
2276 MiniNotePOITexture:SetTexture(METAMAP_ICON_PATH.."Icon"..MetaMapNotes_MiniNote_Data.icon);
2277 MetaMapNotes_MiniNote_Data.inf1 = Info1WideEditBox:GetText();
2278 MetaMapNotes_MiniNote_Data.inf2 = Info2WideEditBox:GetText();
2279 MetaMapNotes_MiniNote_Data.in1c = MetaMapNotes_TempData_Info1Color;
2280 MetaMapNotes_MiniNote_Data.in2c = MetaMapNotes_TempData_Info2Color;
2281 MetaMapNotes_MiniNote_Data.color = MetaMapNotes_TempData_TextColor;
2282 MetaMapNotes_MiniNote_Data.creator = CreatorWideEditBox:GetText();
2283 end
2284  
2285 if(MetaMapNotes_vnote_xPos == MetaMapNotes_TempData_xPos and MetaMapNotes_vnote_yPos == MetaMapNotes_TempData_yPos) then
2286 MetaMapNotes_vnote_xPos = nil;
2287 MetaMapNotes_vnote_yPos = nil;
2288 end
2289 MetaMapNotes_MapUpdate();
2290 end
2291  
2292 function MetaMapNotes_MapUpdate()
2293 if(WorldMapButton:IsVisible() or MetaMapFrame:IsVisible()) then
2294 MetaMapNotes_WorldMapButton_OnUpdate();
2295 end
2296 if(Minimap:IsVisible()) then
2297 Minimap_OnUpdate(0);
2298 end
2299 end
2300  
2301 function MetaMapNotes_HideAll()
2302 MetaMapNotesEditFrame:Hide()
2303 MetaMapNotesSendFrame:Hide()
2304 MetaMapNotes_QuickNoteFrame:Hide()
2305 MetaMapNotes_ClearGUI()
2306 end
2307  
2308 function MetaMapNotes_FramesHidden()
2309 if(MetaMapNotesEditFrame:IsVisible() or MetaMapNotesSendFrame:IsVisible()
2310 or MetaMapNotes_QuickNoteFrame:IsVisible()) then
2311 return false;
2312 else
2313 return true;
2314 end
2315 end
2316  
2317 function MetaMapNotes_GetZoneTableSize(zoneTable)
2318 local i = 0;
2319 for id in zoneTable do
2320 i = i + 1;
2321 end
2322 return i;
2323 end
2324  
2325 function MetaMapNotes_OnEnter(id)
2326 if MetaMapNotes_FramesHidden() then
2327 local x, y = this:GetCenter()
2328 local x2, y2 = WorldMapButton:GetCenter()
2329 local anchor = ""
2330 if x > x2 then
2331 anchor = "ANCHOR_LEFT"
2332 else
2333 anchor = "ANCHOR_RIGHT"
2334 end
2335 WorldMapTooltip:SetOwner(this, anchor)
2336 if id == 0 then
2337 WorldMapTooltip:SetText(METAMAPNOTES_VNOTE_DEFAULTNAME)
2338 elseif id == -1 then
2339 WorldMapTooltip:SetText(METAMAPNOTES_PARTYNOTE)
2340 else
2341 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
2342 if(not currentZone) then return; end
2343 local blt = "";
2344 local cNr = currentZone[id].ncol
2345 if(currentZone[id].lootid ~= nil and currentZone[id].lootid ~= "") then
2346 blt = "|cffff00ffBLT";
2347 end
2348 WorldMapTooltip:AddDoubleLine(currentZone[id].name, blt, MetaMapNotes_Colors[cNr].r, MetaMapNotes_Colors[cNr].g, MetaMapNotes_Colors[cNr].b, MetaMapOptions.TooltipWrap)
2349 if currentZone[id].inf1 ~= nil and currentZone[id].inf1 ~= "" then
2350 cNr = currentZone[id].in1c
2351 WorldMapTooltip:AddLine(currentZone[id].inf1, MetaMapNotes_Colors[cNr].r, MetaMapNotes_Colors[cNr].g, MetaMapNotes_Colors[cNr].b, MetaMapOptions.TooltipWrap)
2352 end
2353 if currentZone[id].inf2 ~= nil and currentZone[id].inf2 ~= "" then
2354 cNr = currentZone[id].in2c
2355 WorldMapTooltip:AddLine(currentZone[id].inf2, MetaMapNotes_Colors[cNr].r, MetaMapNotes_Colors[cNr].g, MetaMapNotes_Colors[cNr].b, MetaMapOptions.TooltipWrap)
2356 end
2357 if(currentZone[id].creator ~= nil and currentZone[id].creator ~= "" and MetaMapOptions.MetaMapShowAuthor) then
2358 WorldMapTooltip:AddDoubleLine(METAMAPNOTES_CREATEDBY, currentZone[id].creator, 0.79, 0.69, 0.0, 0.79, 0.69, 0.0);
2359 end
2360 end
2361 WorldMapTooltip:Show()
2362 else
2363 WorldMapTooltip:Hide()
2364 end
2365 end
2366  
2367 function MetaMapNotes_MiniNote_OnEnter()
2368 GameTooltip:SetOwner(this, "ANCHOR_CURSOR");
2369 if(MetaMapNotes_MiniNote_Data.id == -1) then
2370 GameTooltip:SetText(METAMAPNOTES_PARTYNOTE);
2371 else
2372 GameTooltip:SetText(MetaMapNotes_MiniNote_Data.name,
2373 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.color].r,
2374 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.color].g,
2375 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.color].b);
2376  
2377 GameTooltip:AddLine(MetaMapNotes_MiniNote_Data.inf1,
2378 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.in1c].r,
2379 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.in1c].g,
2380 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.in1c].b);
2381  
2382 GameTooltip:AddLine(MetaMapNotes_MiniNote_Data.inf2,
2383 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.in2c].r,
2384 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.in2c].g,
2385 MetaMapNotes_Colors[MetaMapNotes_MiniNote_Data.in2c].b);
2386 if(MetaMapNotes_MiniNote_Data.creator ~= nil and MetaMapNotes_MiniNote_Data.creator ~= "" and MetaMapOptions.MetaMapShowAuthor) then
2387 GameTooltip:AddDoubleLine(METAMAPNOTES_CREATEDBY, MetaMapNotes_MiniNote_Data.creator, 0.79, 0.69, 0.0, 0.79, 0.69, 0.0);
2388 end
2389 end
2390 GameTooltip:Show();
2391 end
2392  
2393 function MetaMapNotes_Note_OnClick(button, id)
2394 if(not MetaMapNotes_FramesHidden()) then return; end
2395 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
2396 if(not currentZone) then return; end
2397  
2398 if MetaMapNotes_LastLineClick.GUIactive then
2399 id = id + 0
2400 local ax = currentZone[id].xPos
2401 local ay = currentZone[id].yPos
2402 if (MetaMapNotes_LastLineClick.x ~= ax or MetaMapNotes_LastLineClick.y ~= ay) and MetaMapNotes_LastLineClick.continent == continent and MetaMapNotes_LastLineClick.zone == zone then
2403 MetaMapNotes_ToggleLine(continent, zone, ax, ay, MetaMapNotes_LastLineClick.x, MetaMapNotes_LastLineClick.y)
2404 end
2405 MetaMapNotes_ClearGUI()
2406 elseif(button == "LeftButton" and IsShiftKeyDown()) then
2407 if (ChatFrameEditBox:IsVisible()) then
2408 local mode = 1;
2409 if(MetaMapFrame:IsVisible()) then mode = 2; end
2410 local tname = currentZone[id].name;
2411 local tinf1 = currentZone[id].inf1;
2412 local x = MetaMap_round(currentZone[id].xPos *100);
2413 local y = MetaMap_round(currentZone[id].yPos *100);
2414 local tzone = MetaMap_ZoneNames[continent][zone];
2415 if(strlen(tinf1) > 0) then tinf1 = " ["..tinf1.."] "; end
2416 local msg = tname.." "..tinf1.." ("..tzone.." - "..x..","..y..")";
2417 ChatFrameEditBox:Insert(msg);
2418 end
2419 elseif(button == "LeftButton" and IsControlKeyDown()) then
2420 local LootID = MetaMapNotes_Data[continent][zone][id].lootid;
2421 local Name = MetaMapNotes_Data[continent][zone][id].name;
2422 MetaMap_LoadBLT(LootID, Name);
2423 elseif(button == "LeftButton" and currentZone[id].icon ~= 10) then
2424 local width = WorldMapButton:GetWidth()
2425 local height = WorldMapButton:GetHeight()
2426 id = id + 0
2427 MetaMapNotes_TempData_Id = id
2428 local ax = currentZone[id].xPos
2429 local ay = currentZone[id].yPos
2430 if ax*1002 >= (1002 - 195) then
2431 xOffset = ax * width - 176
2432 else
2433 xOffset = ax * width
2434 end
2435 if ay*668 <= (668 - 156) then
2436 yOffset = -(ay * height) - 75
2437 else
2438 yOffset = -(ay * height) + 113
2439 end
2440 MetaMapNotesButtonSendNote:Enable()
2441 WorldMapTooltip:Hide()
2442 MetaMapNotes_OpenEditForExistingNote(MetaMapNotes_TempData_Id)
2443 elseif(button == "RightButton") then
2444 if(IsControlKeyDown()) then
2445 MetaMapNotes_CRBSelect(id);
2446 elseif(IsShiftKeyDown()) then
2447 MetaMapNotes_SRBSelect(id);
2448 else
2449 MetaMap_LoadBWP(this:GetID(), 2);
2450 end
2451 end
2452 end
2453  
2454 function MetaMapNotes_StartGUIToggleLine()
2455 MetaMapNotes_HideAll()
2456 MetaMapText_NoteTotals:SetText("|cffffffff"..METAMAPNOTES_CLICK_ON_SECOND_NOTE)
2457 MetaMapNotes_LastLineClick.GUIactive = true
2458 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
2459  
2460 MetaMapNotes_LastLineClick.x = MetaMapNotes_Data[continent][zone][MetaMapNotes_TempData_Id].xPos
2461 MetaMapNotes_LastLineClick.y = MetaMapNotes_Data[continent][zone][MetaMapNotes_TempData_Id].yPos
2462 MetaMapNotes_LastLineClick.zone = zone
2463 MetaMapNotes_LastLineClick.continent = continent
2464 end
2465  
2466 function MetaMapNotes_StartMoveNote(ID)
2467 MetaMapNotes_HideAll()
2468 MetaMapText_NoteTotals:SetText("|cffffffff"..METAMAPNOTES_CLICK_ON_LOCATION);
2469 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
2470 MetaMapNotes_Relocate.continent = continent;
2471 MetaMapNotes_Relocate.zone = zone;
2472 MetaMapNotes_Relocate.id = ID;
2473 end
2474  
2475 function MetaMapNotes_MoveNote(continent, zone, id)
2476 local zoneTable = MetaMapNotes_Lines[continent][zone]
2477 local lineCount = MetaMapNotes_GetZoneTableSize(zoneTable)
2478 local currentX = MetaMapNotes_Data[continent][zone][id].xPos;
2479 local currentY = MetaMapNotes_Data[continent][zone][id].yPos;
2480 local centerX, centerY = WorldMapButton:GetCenter();
2481 local width = WorldMapButton:GetWidth();
2482 local height = WorldMapButton:GetHeight();
2483 local x, y = GetCursorPosition();
2484 x = x / WorldMapButton:GetEffectiveScale();
2485 y = y / WorldMapButton:GetEffectiveScale();
2486 local adjustedY = (centerY + height/2 - y) / height;
2487 local adjustedX = (x - (centerX - width/2)) / width;
2488 MetaMapNotes_Data[continent][zone][id].xPos = adjustedX;
2489 MetaMapNotes_Data[continent][zone][id].yPos = adjustedY;
2490 if(MetaMapNotes_MiniNote_Data.id == id) then
2491 MetaMapNotes_MiniNote_Data.xPos = adjustedX;
2492 MetaMapNotes_MiniNote_Data.yPos = adjustedY;
2493 end
2494 for i = 1, lineCount, 1 do
2495 if i <= lineCount then
2496 if(zoneTable[i].x1 == currentX and zoneTable[i].y1 == currentY) then
2497 zoneTable[i].x1 = adjustedX;
2498 zoneTable[i].y1 = adjustedY;
2499 elseif(zoneTable[i].x2 == currentX and zoneTable[i].y2 == currentY) then
2500 zoneTable[i].x2 = adjustedX;
2501 zoneTable[i].y2 = adjustedY;
2502 end
2503 end
2504 end
2505 MetaMapNotes_MapUpdate();
2506 end
2507  
2508 function MetaMapNotes_ClearGUI()
2509 MetaMapNotes_LastLineClick.GUIactive = false;
2510 MetaMapNotes_Relocate = {};
2511 end
2512  
2513 function MetaMapNotes_DrawLine(id, x1, y1, x2, y2)
2514 assert(x1 and y1 and x2 and y2)
2515 local MetaMapNotesLine = MetaMap_CreateLineObject(id);
2516 local positiveSlopeTexture = METAMAP_IMAGE_PATH.."LineTemplatePositive256"
2517 local negativeSlopeTexture = METAMAP_IMAGE_PATH.."LineTemplateNegative256"
2518 local width = WorldMapDetailFrame:GetWidth()
2519 local height = WorldMapDetailFrame:GetHeight()
2520 local deltax = math.abs((x1 - x2) * width)
2521 local deltay = math.abs((y1 - y2) * height)
2522 local xOffset = math.min(x1,x2) * width
2523 local yOffset = -(math.min(y1,y2) * height)
2524 local lowerpixel = math.min(deltax, deltay)
2525 lowerpixel = lowerpixel / 256
2526 if lowerpixel > 1 then
2527 lowerpixel = 1
2528 end
2529 if deltax == 0 then
2530 deltax = 2
2531 MetaMapNotesLine:SetTexture(0, 0, 0)
2532 MetaMapNotesLine:SetTexCoord(0, 1, 0, 1)
2533 elseif deltay == 0 then
2534 deltay = 2
2535 MetaMapNotesLine:SetTexture(0, 0, 0)
2536 MetaMapNotesLine:SetTexCoord(0, 1, 0, 1)
2537 elseif x1 - x2 < 0 then
2538 if y1 - y2 < 0 then
2539 MetaMapNotesLine:SetTexture(negativeSlopeTexture)
2540 MetaMapNotesLine:SetTexCoord(0, lowerpixel, 0, lowerpixel)
2541 else
2542 MetaMapNotesLine:SetTexture(positiveSlopeTexture)
2543 MetaMapNotesLine:SetTexCoord(0, lowerpixel, 1-lowerpixel, 1)
2544 end
2545 else
2546 if y1 - y2 < 0 then
2547 MetaMapNotesLine:SetTexture(positiveSlopeTexture)
2548 MetaMapNotesLine:SetTexCoord(0, lowerpixel, 1-lowerpixel, 1)
2549 else
2550 MetaMapNotesLine:SetTexture(negativeSlopeTexture)
2551 MetaMapNotesLine:SetTexCoord(0, lowerpixel, 0, lowerpixel)
2552 end
2553 end
2554  
2555 if(MetaMapFrame:IsVisible()) then
2556 MetaMapNotesLine:SetPoint("TOPLEFT", "MetaMapFrame", "TOPLEFT", xOffset, yOffset)
2557 else
2558 MetaMapNotesLine:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", xOffset, yOffset)
2559 end
2560 MetaMapNotesLine:SetWidth(deltax)
2561 MetaMapNotesLine:SetHeight(deltay)
2562 MetaMapNotesLine:Show()
2563 end
2564  
2565 function MetaMapNotes_DeleteLines(continent, zone, x, y)
2566 local zoneTable = MetaMapNotes_Lines[continent][zone]
2567 local lineCount = MetaMapNotes_GetZoneTableSize(zoneTable)
2568 local offset = 0
2569  
2570 for i = 1, lineCount, 1 do
2571 if (zoneTable[i-offset].x1 == x and zoneTable[i-offset].y1 == y) or (zoneTable[i-offset].x2 == x and zoneTable[i-offset].y2 == y) then
2572 for j = i, lineCount-1, 1 do
2573 zoneTable[j-offset].x1 = zoneTable[j+1-offset].x1
2574 zoneTable[j-offset].x2 = zoneTable[j+1-offset].x2
2575 zoneTable[j-offset].y1 = zoneTable[j+1-offset].y1
2576 zoneTable[j-offset].y2 = zoneTable[j+1-offset].y2
2577 end
2578 zoneTable[lineCount-offset] = nil
2579 offset = offset + 1
2580 end
2581 end
2582 MetaMapNotes_LastLineClick.zone = 0
2583 end
2584  
2585 function MetaMapNotes_ToggleLine(continent, zone, x1, y1, x2, y2)
2586 local zoneTable = MetaMapNotes_Lines[continent][zone]
2587 local newline = true
2588 local lineCount = MetaMapNotes_GetZoneTableSize(zoneTable)
2589  
2590 for i = 1, lineCount, 1 do
2591 if i <= lineCount then
2592 if (zoneTable[i].x1 == x1 and zoneTable[i].y1 == y1 and
2593 zoneTable[i].x2 == x2 and zoneTable[i].y2 == y2) or
2594 (zoneTable[i].x1 == x2 and zoneTable[i].y1 == y2 and
2595 zoneTable[i].x2 == x1 and zoneTable[i].y2 == y1) then
2596 for j = i, lineCount-1, 1 do
2597 zoneTable[j].x1 = zoneTable[j+1].x1
2598 zoneTable[j].x2 = zoneTable[j+1].x2
2599 zoneTable[j].y1 = zoneTable[j+1].y1
2600 zoneTable[j].y2 = zoneTable[j+1].y2
2601 end
2602 zoneTable[lineCount] = nil
2603 PlaySound("igMainMenuOption")
2604 newline = false
2605 lineCount = lineCount - 1
2606 end
2607 end
2608 end
2609 if(newline) then
2610 zoneTable[lineCount+1] = {}
2611 zoneTable[lineCount+1].x1 = x1
2612 zoneTable[lineCount+1].x2 = x2
2613 zoneTable[lineCount+1].y1 = y1
2614 zoneTable[lineCount+1].y2 = y2
2615 end
2616 MetaMapNotes_LastLineClick.zone = 0
2617 MetaMapNotes_MapUpdate()
2618 end
2619  
2620 function MetaMapNotes_NewNoteSlot()
2621 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
2622 if(not currentZone) then return 1; end
2623 return MetaMapNotes_GetZoneTableSize(currentZone) + 1
2624 end
2625  
2626 function MetaMapNotes_SetPartyNote(xPos, yPos)
2627 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
2628 xPos = floor(xPos * 1000000) / 1000000
2629 yPos = floor(yPos * 1000000) / 1000000
2630 MetaMapNotes_PartyNoteData.continent = continent
2631 MetaMapNotes_PartyNoteData.zone = zone
2632 MetaMapNotes_PartyNoteData.xPos = xPos
2633 MetaMapNotes_PartyNoteData.yPos = yPos
2634 if MetaMapNotes_MiniNote_Data.icon == "party" or MetaMapOptions.MiniParty then
2635 MetaMapNotes_MiniNote_Data.zonetext = mapName;
2636 MetaMapNotes_MiniNote_Data.id = -1;
2637 MetaMapNotes_MiniNote_Data.continent = continent;
2638 MetaMapNotes_MiniNote_Data.zone = zone;
2639 MetaMapNotes_MiniNote_Data.xPos = xPos;
2640 MetaMapNotes_MiniNote_Data.yPos = yPos;
2641 MetaMapNotes_MiniNote_Data.name = METAMAPNOTES_PARTYNOTE;
2642 MetaMapNotes_MiniNote_Data.color = 0;
2643 MetaMapNotes_MiniNote_Data.icon = "party"
2644 MiniNotePOITexture:SetTexture(METAMAP_ICON_PATH.."Icon"..MetaMapNotes_MiniNote_Data.icon)
2645 MiniNotePOI:Show()
2646 end
2647 MetaMapNotes_MapUpdate()
2648 end
2649  
2650 function MetaMapNotes_WorldMapButton_OnClick(...)
2651 if(not MetaMapNotes_FramesHidden()) then return; end
2652 local mouseButton, button = unpack(arg)
2653 local continent, zone = MetaMap_GetCurrentMapInfo();
2654  
2655 if(MetaMapNotes_Relocate.id ~= nil and zone > 0) then
2656 if(mouseButton == "LeftButton" and not IsControlKeyDown() and not IsShiftKeyDown()) then
2657 MetaMapNotes_MoveNote(MetaMapNotes_Relocate.continent, MetaMapNotes_Relocate.zone, MetaMapNotes_Relocate.id)
2658 MetaMapNotes_Relocate = {};
2659 return;
2660 end
2661 end
2662  
2663 if(MetaMapFrame:IsVisible() and mouseButton == "RightButton") then
2664 MetaMap_Toggle(false);
2665 return;
2666 elseif mouseButton == "RightButton" or (mouseButton == "LeftButton" and not IsControlKeyDown() and not IsShiftKeyDown()) then
2667 if(MetaMapFrame:IsVisible() and mouseButton == "LeftButton") then
2668 return;
2669 end
2670 MetaMap_OrigWorldMapButton_OnClick(unpack(arg));
2671 return;
2672 else
2673 if(MetaMapOptions.UseMapMod and not MetaMapFrame:IsVisible() and IsControlKeyDown()) then
2674 MetaMap_OrigWorldMapButton_OnClick(unpack(arg));
2675 return;
2676 end
2677 end
2678  
2679 if(continent == -1 or zone ~= 0 or MetaMapFrame:IsVisible()) then
2680 if not button then
2681 button = this
2682 end
2683 local centerX, centerY = button:GetCenter()
2684 local width = button:GetWidth()
2685 local height = button:GetHeight()
2686 local x, y = GetCursorPosition()
2687 x = x / button:GetEffectiveScale()
2688 y = y / button:GetEffectiveScale()
2689 local adjustedY = (centerY + height/2 - y) / height
2690 local adjustedX = (x - (centerX - width/2)) / width
2691  
2692 if(IsShiftKeyDown()) then
2693 MetaMapNotes_SetPartyNote(adjustedX, adjustedY);
2694 elseif(IsControlKeyDown()) then
2695 MetaMapNotes_ShowNewFrame(adjustedX, adjustedY);
2696 end
2697 end
2698 end
2699  
2700 function MetaMapNotes_WorldMapButton_OnUpdate(...)
2701 if(MetaMapNotes_Drawing) then
2702 return;
2703 end
2704 local lastNote = 0;
2705 local lastLine = 0;
2706 local showLine = true;
2707 local xOffset,yOffset = 0;
2708 local currentLineZone;
2709 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
2710 MetaMapNotes_Drawing = true;
2711  
2712 if(currentZone) then
2713 if(continent ==-1) then
2714 currentLineZone = MetaMapNotes_Lines[GetRealZoneText];
2715 else
2716 currentLineZone = MetaMapNotes_Lines[continent][zone];
2717 end
2718 if(currentLineZone) then
2719 for i,line in currentLineZone do
2720 MetaMapNotes_DrawLine(i, line.x1, line.y1, line.x2, line.y2)
2721 lastLine = i;
2722 end
2723 end
2724 for i, value in currentZone do
2725 local temp = MetaMap_CreateNoteObject(i);
2726 local xPos = currentZone[i].xPos;
2727 local yPos = currentZone[i].yPos;
2728 local xOffset = xPos * WorldMapButton:GetWidth();
2729 local yOffset = -yPos * WorldMapButton:GetHeight();
2730 if(MetaMapFrame:IsVisible()) then
2731 temp:SetParent("MetaMapFrame");
2732 temp:SetPoint("CENTER", "MetaMapFrame", "TOPLEFT", xOffset, yOffset)
2733 else
2734 temp:SetParent("WorldMapButton");
2735 temp:SetPoint("CENTER", "WorldMapButton", "TOPLEFT", xOffset, yOffset)
2736 end
2737 getglobal("MetaMapNotesPOI"..i.."Texture"):SetTexture(METAMAP_ICON_PATH.."Icon"..currentZone[i].icon)
2738 getglobal("MetaMapNotesPOI"..i.."Highlight"):Hide();
2739 for landmarkIndex = 1, GetNumMapLandmarks(), 1 do
2740 local worldMapPOI = getglobal("WorldMapFramePOI"..landmarkIndex);
2741 if(worldMapPOI == nil) then break; end
2742 local metaMapPOI = getglobal("MetaMapNotesPOI"..i);
2743 local name, unknown, textureIndex, x, y = GetMapLandmarkInfo(landmarkIndex);
2744 local xPosmin = xPos - 2; local xPosmax = xPos + 2;
2745 local yPosmin = yPos - 2; local yPosmax = yPos + 2;
2746 if((x > xPosmin and x < xPosmax) and (y > yPosmin and y < yPosmax)) then
2747 metaMapPOI:SetFrameLevel(worldMapPOI:GetFrameLevel() +1);
2748 end
2749 end
2750 if(currentZone[i].icon == 10) then
2751 if(currentZone[i].name == MetaMap_FilterName) then
2752 temp:Hide();
2753 showLine = false;
2754 else
2755 temp:Show();
2756 end
2757 elseif(MetaMap_NoteFilter[currentZone[i].icon]) then
2758 temp:Show();
2759 else
2760 MetaMap_FilterName = currentZone[i].name;
2761 temp:Hide();
2762 showLine = false;
2763 end
2764 if(not showLine) then
2765 for line = 1, lastLine, 1 do
2766 if(currentLineZone[line].x1 == xPos and currentLineZone[line].y1 == yPos) then
2767 getglobal("MetaMapNotesLines_"..line):Hide();
2768 elseif(currentLineZone[line].x2 == xPos and currentLineZone[line].y2 == yPos) then
2769 getglobal("MetaMapNotesLines_"..line):Hide();
2770 end
2771 end
2772 end
2773 lastNote = i;
2774 showLine = true;
2775 end
2776 if(MetaMapOptions.LastHighlight and lastNote ~= 0 and currentZone[lastNote].icon ~= 10) then
2777 if getglobal("MetaMapNotesPOI"..lastNote):IsVisible() then
2778 getglobal("MetaMapNotesPOI"..lastNote.."Highlight"):SetTexture(METAMAP_ICON_PATH.."IconGlowRed")
2779 getglobal("MetaMapNotesPOI"..lastNote.."Highlight"):Show();
2780 end
2781 end
2782 if(MetaMapOptions.LastMiniHighlight and MetaMapNotes_MiniNote_Data.continent == continent and
2783 MetaMapNotes_MiniNote_Data.zone == zone and MetaMapNotes_MiniNote_Data.id > 0) then
2784 getglobal("MetaMapNotesPOI"..MetaMapNotes_MiniNote_Data.id.."Highlight"):SetTexture(METAMAP_ICON_PATH.."IconGlowBlue")
2785 getglobal("MetaMapNotesPOI"..MetaMapNotes_MiniNote_Data.id.."Highlight"):Show();
2786 end
2787 for i=lastNote+1, MetaMapNotes_LastNote, 1 do
2788 getglobal("MetaMapNotesPOI"..i):Hide()
2789 end
2790 for i=lastLine+1, MetaMapNotes_LastLine, 1 do
2791 getglobal("MetaMapNotesLines_"..i):Hide()
2792 end
2793 else
2794 for i=1, MetaMapNotes_LastNote, 1 do
2795 getglobal("MetaMapNotesPOI"..i):Hide();
2796 end
2797  
2798 for i=1, MetaMapNotes_LastLine, 1 do
2799 getglobal("MetaMapNotesLines_"..i):Hide();
2800 end
2801 end
2802  
2803 if currentZone then
2804 -- vNote button
2805 if MetaMapNotes_vnote_xPos ~= nil and zone ~= 0 then
2806 xOffset = MetaMapNotes_vnote_xPos * WorldMapButton:GetWidth();
2807 yOffset = -MetaMapNotes_vnote_yPos * WorldMapButton:GetHeight();
2808 if(MetaMapFrame:IsVisible()) then
2809 MetaMapNotesPOIvNote:SetPoint("CENTER", "MetaMapFrame", "TOPLEFT", xOffset, yOffset)
2810 else
2811 MetaMapNotesPOIvNote:SetPoint("CENTER", "WorldMapButton", "TOPLEFT", xOffset, yOffset)
2812 end
2813 MetaMapNotesPOIvNote:Show()
2814 else
2815 MetaMapNotesPOIvNote:Hide()
2816 end
2817  
2818 -- party note
2819 if MetaMapNotes_PartyNoteData.xPos ~= nil and zone == MetaMapNotes_PartyNoteData.zone and
2820 continent == MetaMapNotes_PartyNoteData.continent then
2821 if MetaMapOptions.LastMiniHighlight and MetaMapNotes_MiniNote_Data.icon == "party" then
2822 MetaMapNotesPOIpartyTexture:SetTexture(METAMAP_ICON_PATH.."Iconpartyblue")
2823 else
2824 MetaMapNotesPOIpartyTexture:SetTexture(METAMAP_ICON_PATH.."Iconparty")
2825 end
2826 xOffset = MetaMapNotes_PartyNoteData.xPos * WorldMapButton:GetWidth();
2827 yOffset = -MetaMapNotes_PartyNoteData.yPos * WorldMapButton:GetHeight();
2828 if(MetaMapFrame:IsVisible()) then
2829 MetaMapNotesPOIparty:SetParent("MetaMapFrame");
2830 MetaMapNotesPOIparty:SetPoint("CENTER", "MetaMapFrame", "TOPLEFT", xOffset, yOffset)
2831 else
2832 MetaMapNotesPOIparty:SetParent("WorldMapButton");
2833 MetaMapNotesPOIparty:SetPoint("CENTER", "WorldMapButton", "TOPLEFT", xOffset, yOffset)
2834 end
2835 MetaMapNotesPOIparty:Show()
2836 else
2837 MetaMapNotesPOIparty:Hide()
2838 end
2839 end
2840 MetaMapNotes_Drawing = nil
2841 MetaMapText_NoteTotals:SetText("|cff00ff00"..METAMAP_NOTES_SHOWN..": ".."|cffffffff"..(lastNote).." ".."|cff00ff00"..METAMAP_LINES_SHOWN..": ".."|cffffffff"..(lastLine));
2842  
2843 if(MetaMapOptions.UseMapMod and IsAddOnLoaded("CT_MapMod")) then
2844 if(MetaMapFrame:IsVisible()) then
2845 CT_NumNotes:Hide();
2846 MetaMapText_NoteTotals:Show();
2847 else
2848 CT_NumNotes:Show();
2849 MetaMapText_NoteTotals:Hide();
2850 end
2851 else
2852 if(IsAddOnLoaded("CT_MapMod")) then
2853 CT_NumNotes:Hide();
2854 end
2855 MetaMapText_NoteTotals:Show();
2856 end
2857 MetaMapList_Init();
2858 MetaMap_FilterName = "";
2859 end
2860  
2861 function MetaMap_DeleteNotesListInit()
2862 local Temp_List = {};
2863 for continent, continentTable in MetaMapNotes_Data do
2864 for zone, zoneTable in continentTable do
2865 for index, indexTable in zoneTable do
2866 local currentZone = MetaMapNotes_Data[continent][zone][index];
2867 if(Temp_List[currentZone.creator] == nil) then
2868 Temp_List[currentZone.creator] = currentZone.creator;
2869 end
2870 end
2871 end
2872 end
2873 for index, creators in Temp_List do
2874 local uText;
2875 if(Temp_List[index] == "") then
2876 uText = "Unsigned";
2877 else
2878 uText = Temp_List[index];
2879 end
2880 local info = {
2881 checked = nil;
2882 notCheckable = 1;
2883 text = uText;
2884 func = MetaMap_DeleteNotesList_OnClick;
2885 };
2886 UIDropDownMenu_AddButton(info);
2887 end
2888 UIDropDownMenu_JustifyText("LEFT", MetaMap_DeleteNotesList)
2889 UIDropDownMenu_SetText("[Click for Creator]", MetaMap_DeleteNotesList)
2890 end
2891  
2892 function MetaMap_DeleteNotesList_OnClick()
2893 local creator = this:GetText();
2894 if(creator == "Unsigned") then
2895 cFlag = "";
2896 else
2897 cFlag = creator;
2898 end
2899 UIDropDownMenu_SetSelectedName(MetaMap_DeleteNotesList, this:GetText());
2900 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
2901 StaticPopupDialogs["Delete_Notes"] = {
2902 text = TEXT(format(METAMAPNOTES_BATCHDELETE, mapName, creator)),
2903 button1 = TEXT(ACCEPT),
2904 button2 = TEXT(DECLINE),
2905 OnAccept = function()
2906 MetaMap_DeleteNotes(cFlag, nil, mapName);
2907 end,
2908 timeout = 60,
2909 showAlert = 1,
2910 };
2911 StaticPopup_Show("Delete_Notes");
2912 end
2913  
2914 function MetaMap_DeleteNotes(creator, name, zoneName)
2915 if(zoneName == nil or zoneName == "World") then
2916 assert(creator ~= nil, "ERROR: nil creator passed to DeleteNotesByCreatorAndName!");
2917 for continent, continentTable in MetaMapNotes_Data do
2918 for zone, zoneTable in continentTable do
2919 for id=MetaMapNotes_GetZoneTableSize(zoneTable), 1, -1 do
2920 if(zoneTable[id] ~= nil and creator == zoneTable[id].creator and (name == zoneTable[id].name or name == nil)) then
2921 MetaMapNotes_DeleteNote(id, continent, zone)
2922 end
2923 end
2924 end
2925 end
2926 else
2927 local continent, setZone = MetaMap_NameToZoneID(zoneName, 1);
2928 if(zoneName == "Kalimdor") then
2929 continent = 1;
2930 elseif(zoneName == "Eastern Kingdoms") then
2931 continent = 2;
2932 end
2933 for zone, zoneTable in MetaMapNotes_Data[continent] do
2934 for id=MetaMapNotes_GetZoneTableSize(zoneTable), 1, -1 do
2935 if(setZone == 0 and zoneTable[id] ~= nil and creator == zoneTable[id].creator) then
2936 MetaMapNotes_DeleteNote(id, continent, zone);
2937 elseif(setZone == zone and zoneTable[id] ~= nil and creator == zoneTable[id].creator) then
2938 MetaMapNotes_DeleteNote(id, continent, zone);
2939 end
2940 end
2941 end
2942 end
2943 if(creator == "") then creator = "Unsigned"; end
2944 if(zoneName ~= nil) then
2945 if(MetaMap_NotesDialog:IsVisible()) then
2946 MetaMapNotes_InfoText:SetText(format(METAMAPNOTES_DELETED_BY_ZONE, zoneName, creator), true);
2947 MetaMapNotes_InfoText:Show();
2948 else
2949 MetaMap_StatusPrint(format(METAMAPNOTES_DELETED_BY_ZONE, zoneName, creator), true);
2950 end
2951 elseif(name ~= nil) then
2952 MetaMap_StatusPrint(format(METAMAPNOTES_DELETED_BY_NAME, creator, name), true);
2953 else
2954 MetaMap_StatusPrint(format(METAMAPNOTES_DELETED_BY_CREATOR, creator), true);
2955 end
2956 end
2957  
2958 function MetaMap_CheckLinks(id)
2959 local continent, zone, currentZone = MetaMap_GetCurrentMapInfo();
2960 local name = currentZone[id].name;
2961 local count = 0;
2962 for i=1, 4, 1 do
2963 if(currentZone[id+i] ~= nil and currentZone[id+i].name == name and currentZone[id+i].icon == 10) then
2964 count = count +1;
2965 end
2966 end
2967 for i=1, count +1, 1 do
2968 MetaMapNotes_DeleteNote(id, continent, zone);
2969 end
2970 end
2971  
2972 function MetaMapNotes_DeleteNote(id, continent, zone)
2973 MetaMapNotes_HideAll()
2974 if id == 0 then
2975 MetaMapNotes_vnote_xPos = nil;
2976 MetaMapNotes_vnote_yPos = nil;
2977 MetaMapNotes_MapUpdate();
2978 return;
2979 elseif id == -1 then
2980 MetaMapNotes_PartyNoteData.xPos = nil;
2981 MetaMapNotes_PartyNoteData.yPos = nil;
2982 MetaMapNotes_PartyNoteData.continent = nil;
2983 MetaMapNotes_PartyNoteData.zone = nil;
2984 if(MetaMapNotes_MiniNote_Data.id == -1) then
2985 MetaMapNotes_MiniNote_Data = {};
2986 end
2987 MetaMapNotes_MapUpdate();
2988 return;
2989 end
2990  
2991 local currentZone
2992 local TempData = {};
2993 if(continent == -1 or zone == 0) then
2994 continent = GetRealZoneText();
2995 MetaMapNotes_Data[continent][id] = nil;
2996 MetaMapNotes_MapUpdate();
2997 return;
2998 else
2999 currentZone = MetaMapNotes_Data[continent][zone];
3000 end
3001 TempData[continent] = {};
3002 TempData[continent][zone] = {};
3003 local lastEntry = MetaMapNotes_GetZoneTableSize(currentZone);
3004  
3005 if(continent ~= -1 and currentZone[id] ~= nil) then
3006 MetaMapNotes_DeleteLines(continent, zone, currentZone[id].xPos, currentZone[id].yPos);
3007 end
3008 if(lastEntry ~= 0 and id <= lastEntry) then
3009 TempData[continent][zone] = MetaMapNotes_Data[continent][zone];
3010 MetaMapNotes_Data[continent][zone] = {};
3011 local newZone = TempData[continent][zone];
3012 for index, indexTable in newZone do
3013 if(index ~= id) then
3014 local oldData = newZone[index];
3015 MetaMapNotes_AddNewNote(continent, zone, oldData.xPos, oldData.yPos, oldData.name, oldData.inf1, oldData.inf2, oldData.creator, oldData.icon, oldData.ncol, oldData.in1c, oldData.in2c)
3016 end
3017 end
3018 end
3019  
3020 if continent == MetaMapNotes_MiniNote_Data.continent and zone == MetaMapNotes_MiniNote_Data.zone then
3021 if MetaMapNotes_MiniNote_Data.id > id then
3022 MetaMapNotes_MiniNote_Data.id = MetaMapNotes_MiniNote_Data.id - 1;
3023 elseif MetaMapNotes_MiniNote_Data.id == id then
3024 MetaMapNotes_ClearMiniNote(true);
3025 end
3026 end
3027 MetaMapNotes_MapUpdate();
3028 end
3029  
3030 function MetaMapPOI_OnEvent(mode)
3031 if(GetCurrentMapZone() == 0 or GetCurrentMapContinent() == -1) then return; end
3032 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
3033 local noteAdded1, noteAdded2;
3034 local name, unknown, textureIndex, x, y;
3035 local icon = 9;
3036 for landmarkIndex = 1, GetNumMapLandmarks(), 1 do
3037 name, unknown, textureIndex, x, y = GetMapLandmarkInfo(landmarkIndex);
3038 if (textureIndex == 15) then
3039 icon = 5;
3040 elseif (textureIndex == 6) then
3041 icon = 6;
3042 end
3043 if(mode == 1) then
3044 if(textureIndex==6) then
3045 noteAdded1 = MetaMapNotes_AddNewNote(continent, zone, x, y, name, "", "", METAMAPFWM_NAME, icon, 6, 0, 0);
3046 end
3047 else
3048 noteAdded2 = MetaMapNotes_AddNewNote(continent, zone, x, y, name, "", "", METAMAPFWM_NAME, icon, 6, 0, 0);
3049 end
3050 end
3051 if(noteAdded1 and noteAdded2) then
3052 MetaMap_StatusPrint("MetaMapPOI updated map notes for "..GetRealZoneText(), true);
3053 else
3054 if(noteAdded2) then
3055 MetaMap_StatusPrint("MetaMapPOI updated map notes for "..GetRealZoneText(), true);
3056 end
3057 if(noteAdded1) then
3058 MetaMap_StatusPrint("MetaMapPOI set Guard note for "..name, true);
3059 end
3060 end
3061 end
3062  
3063 function MetaMap_SortCriteria(a, b)
3064 if(MetaMap_sortType == METAMAP_SORTBY_NAME) then
3065 if (a.name < b.name) then
3066 return true;
3067 elseif (a.name > b.name) then
3068 return false;
3069 end
3070 elseif(MetaMap_sortType == METAMAP_SORTBY_DESC) then
3071 if (a.desc < b.desc) then
3072 return true;
3073 elseif (a.desc > b.desc) then
3074 return false;
3075 end
3076 elseif(MetaMap_sortType == METAMAP_SORTBY_LEVEL) then
3077 if (a.level < b.level) then
3078 return true;
3079 elseif (a.level > b.level) then
3080 return false;
3081 end
3082 elseif(MetaMap_sortType == METAMAP_SORTBY_LOCATION) then
3083 if (a.location < b.location) then
3084 return true;
3085 elseif (a.location > b.location) then
3086 return false;
3087 end
3088 else
3089 if (a == nil) then
3090 if (b == nil) then
3091 return false;
3092 else
3093 return true;
3094 end
3095 elseif (b == nil) then
3096 return false;
3097 end
3098 end
3099 end
3100  
3101 function MetaMap_InvertList(list)
3102 local newlist = {};
3103 local count = table.getn(list);
3104 for i=1,count
3105 do
3106 table.insert(newlist, list[(count +1) -i]);
3107 end
3108 return newlist;
3109 end
3110  
3111 function MetaMap_InfoLine(button)
3112 if(button == "RightButton") then
3113 MetaMapOptions.ShowMapList = not MetaMapOptions.ShowMapList;
3114 MetaMapOptions_Init();
3115 return;
3116 end
3117 if(MetaMap_InfoLineFrame:IsVisible()) then
3118 MetaMap_InfoLineFrame:Hide();
3119 MetaMapContainerFrame:Hide();
3120 return;
3121 end
3122 local header, footer, info;
3123 if(MetaMapFrame:IsVisible()) then
3124 header = METAMAP_STRING_LOCATION..": ".."|cffffffff"..MetaMap_Data[MetaMapOptions.MetaMapZone]["Location"].."|r";
3125 header = header.." "..METAMAP_STRING_LEVELRANGE..": ".."|cffffffff"..MetaMap_Data[MetaMapOptions.MetaMapZone]["LevelRange"].."|r";
3126 header = header.." "..METAMAP_STRING_PLAYERLIMIT..": ".."|cffffffff"..MetaMap_Data[MetaMapOptions.MetaMapZone]["PlayerLimit"].."|r";
3127 MetaMap_InfoLineFrameText:SetText(MetaMap_Data[MetaMapOptions.MetaMapZone].infoline);
3128 else
3129 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
3130 header = "|cffffffff"..mapName.."|r";
3131 info = "|cffffffffFurther information may be added at a later date...|r";
3132 MetaMap_InfoLineFrameText:SetText("|cffffffffFurther information may be added at a later date...|r");
3133 end
3134 MetaMapContainer_ShowFrame(MetaMap_InfoLineFrame, header, footer, info);
3135 end
3136  
3137 function MetaMap_InfoLineOnEnter()
3138 WorldMapTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT");
3139 if(MetaMapFrame:IsVisible()) then
3140 WorldMapTooltip:SetText(MetaMap_Data[MetaMapOptions.MetaMapZone].ZoneName, 0, 1, 0, false);
3141 WorldMapTooltip:AddLine(METAMAP_STRING_LOCATION..": ".."|cffffffff"..MetaMap_Data[MetaMapOptions.MetaMapZone]["Location"], 1, 1, 0, false);
3142 WorldMapTooltip:AddLine(METAMAP_STRING_LEVELRANGE..": ".."|cffffffff"..MetaMap_Data[MetaMapOptions.MetaMapZone]["LevelRange"], 1, 1, 0, false);
3143 WorldMapTooltip:AddLine(METAMAP_STRING_PLAYERLIMIT..": ".."|cffffffff"..MetaMap_Data[MetaMapOptions.MetaMapZone]["PlayerLimit"], 1, 1, 0, false);
3144 WorldMapTooltip:AddLine(" ");
3145 WorldMapTooltip:AddDoubleLine("Saved Instances:", "ID:");
3146 if(GetNumSavedInstances() > 0) then
3147 for i=1, GetNumSavedInstances() do
3148 local name, ID, remaining = GetSavedInstanceInfo(i);
3149 remaining = SecondsToTime(remaining);
3150 WorldMapTooltip:AddDoubleLine(name, "|cffffffff"..ID, 0, 1, 0, false);
3151 WorldMapTooltip:AddLine("|cffffffff"..remaining);
3152 end
3153 else
3154 WorldMapTooltip:AddLine("|cffffffffNo saved instances");
3155 end
3156 else
3157 local continent, zone, currentZone, mapName = MetaMap_GetCurrentMapInfo();
3158 if(type(continent) == "string" or zone == 0) then
3159 WorldMapTooltip:SetText(mapName, 1, 1, 0, false);
3160 else
3161 zone = MetaMapNotes_ZoneShift[continent][zone];
3162 currentZone = MetaMap_ZoneLevels[continent][zone];
3163 local fColor = {}; local lColor = {};
3164 local Friendly = { r = 0.2, g = 0.9, b = 0.2 };
3165 local Hostile = { r = 0.9, g = 0.2, b = 0.2 };
3166 local Contested = { r = 0.8, g = 0.6, b = 0.4 };
3167 local fID = currentZone[3];
3168 local _, faction = UnitFactionGroup("player");
3169 if(fID == "Contested") then
3170 fColor = Contested;
3171 elseif(fID == faction) then
3172 fColor = Friendly;
3173 else
3174 fColor = Hostile;
3175 end
3176 if(UnitLevel("player") > currentZone[2]) then
3177 lColor = { r = 0.5, g = 0.5, b = 0.5 };
3178 elseif(UnitLevel("player") < currentZone[1]) then
3179 lColor = Hostile;
3180 else
3181 lColor = Friendly;
3182 end
3183 WorldMapTooltip:AddDoubleLine(mapName, fID, fColor.r, fColor.g, fColor.b, fColor.r, fColor.g, fColor.b, false);
3184 WorldMapTooltip:AddDoubleLine(METAMAP_STRING_LEVELRANGE, currentZone[1].." - "..currentZone[2], 1, 1, 0, lColor.r, lColor.g, lColor.b, false);
3185 end
3186 end
3187 WorldMapTooltip:AddLine(" ");
3188 WorldMapTooltip:AddLine(METAMAP_INFOLINE_HINT1, 0.75, 0, 0.75, false);
3189 WorldMapTooltip:AddLine(METAMAP_INFOLINE_HINT2, 0.75, 0, 0.75, false);
3190 WorldMapTooltip:AddLine(" ");
3191 WorldMapTooltip:AddLine(METAMAPNOTES_WORLDMAP_HELP_1, 0.40, 0.40, 0.40, false);
3192 WorldMapTooltip:AddLine(METAMAPNOTES_WORLDMAP_HELP_2, 0.40, 0.40, 0.40, false);
3193 WorldMapTooltip:Show()
3194 end
3195  
3196 function MetaKBMenu_RBSelect(id)
3197 -- Slot assigned to MetaMapBWP.
3198 end
3199  
3200 function MetaKBMenu_CRBSelect(id)
3201 -- Available for other mods to run their own routine.
3202 -- Initiated when CTRL+RightClicking on KB display item.
3203 -- Usage: MetaKBMenu_CRBSelect = MyFunction
3204 end
3205  
3206 function MetaKBMenu_SRBSelect(id)
3207 -- Available for other mods to run their own routine.
3208 -- Initiated when Shift+RightClicking on KB display item.
3209 -- Usage: MetaKBMenu_SRBSelect = MyFunction
3210 end
3211  
3212 function MetaMapNotes_RBSelect(id)
3213 -- Slot assigned to MetaMapBWP.
3214 end
3215  
3216 function MetaMapNotes_CRBSelect(id)
3217 -- Available for other mods to run their own routine.
3218 -- Initiated when CTRL+RightClicking on a map note.
3219 -- Usage: MetaMapNotes_CRBSelect = MyFunction
3220 end
3221  
3222 function MetaMapNotes_SRBSelect(id)
3223 -- Available for other mods to run their own routine.
3224 -- Initiated when Shift+RightClicking on a map note.
3225 -- Usage: MetaMapNotes_SRBSelect = MyFunction
3226 end
3227  
3228 ----------------
3229 -- FuBar Support
3230 ----------------
3231 function MetaMap_FuBar_OnLoad()
3232 local tablet = TabletLib:GetInstance('1.0')
3233  
3234 MetaMapFu = FuBarPlugin:GetInstance("1.2"):new({
3235 name = METAMAP_TITLE,
3236 version = METAMAP_VERSION,
3237 description = METAMAP_DESC,
3238 aceCompatible = 103,
3239 category = "map",
3240 hasIcon = METAMAP_ICON,
3241 hasNoText = TRUE,
3242 })
3243  
3244 function MetaMapFu:OnClick()
3245 MetaMap_ToggleFrame(WorldMapFrame);
3246 end
3247 function MetaMapFu:UpdateTooltip()
3248 MetaMapMenu_OnShow("FuBar");
3249 end
3250  
3251 MetaMapFu:RegisterForLoad();
3252 end
3253  
3254 ----------------
3255 -- Titan Support
3256 ----------------
3257 function TitanPanelMetaMapButton_OnLoad()
3258 this.registry = {
3259 id = TITAN_METAMAP_ID,
3260 version = METAMAP_VERSION,
3261 menuText = METAMAP_TITLE,
3262 category = METAMAP_CATEGORY,
3263 tooltipTitle = METAMAP_TITLE ,
3264 tooltipTextFunction = "TitanPanelMetaMapButton_GetTooltipText",
3265 frequency = TITAN_METAMAP_FREQUENCY,
3266 icon = METAMAP_ICON,
3267 iconWidth = 16,
3268 savedVariables = {
3269 ShowIcon = 1,
3270 }
3271 };
3272 end
3273  
3274 function TitanPanelMetaMapButton_GetTooltipText()
3275 if(MetaMapOptions.MenuMode) then
3276 retText = METAMAP_BUTTON_TOOLTIP1.."\n"..METAMAP_BUTTON_TOOLTIP2;
3277 return retText;
3278 end
3279 end
3280  
3281 function TitalPanelMetaMapButton_OnClick(button)
3282 if ( button == "LeftButton" ) then
3283 MetaMap_ToggleFrame(WorldMapFrame);
3284 end
3285 end
3286  
3287 ---------
3288 -- CT_Mod
3289 ---------
3290 if(IsAddOnLoaded("CT_MapMod")) then
3291 CT_CoordX:Hide();
3292 CT_CoordY:Hide();
3293 CT_NumNotes:SetPoint("TOPLEFT","WorldMapDetailFrame","TOPLEFT",10,-10);
3294 WorldMapFrameCreateNoteOnPlayer:SetPoint("RIGHT","WorldMapContinentDropDown","LEFT",-190,0);
3295 end
3296  
3297 -----------
3298 -- FlightMap
3299 -----------
3300 function FlightMapOptions_Toggle()
3301 FlightMapOptionsFrame:SetFrameStrata("FULLSCREEN");
3302 MetaMap_ToggleFrame(FlightMapOptionsFrame);
3303 end
3304  
3305 -----------
3306 -- Gatherer
3307 -----------
3308 function GathererOptions_Toggle()
3309 GathererUI_DialogFrame:SetFrameStrata("FULLSCREEN");
3310 MetaMap_ToggleFrame(GathererUI_DialogFrame);
3311 end
3312  
3313 -------------
3314 -- NotesUNeed
3315 -------------
3316 function MetaMap_SetNUNtooltip()
3317 if(IsAddOnLoaded("NotesUNeed")) then
3318 local pKey = GetCVar("realmName");
3319 if(MetaMapOptions.SaveSet == 1) then
3320 NuNSettings[pKey].mScale = MetaMapOptions.MetaMapTTScale1;
3321 else
3322 NuNSettings[pKey].mScale = MetaMapOptions.MetaMapTTScale2;
3323 end
3324 end
3325 end