-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMapping.lua
114 lines (100 loc) · 4.42 KB
/
Mapping.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
local L = TourGuide.Locale
local zonei, zonec, zonenames = {}, {}, {}
for contMapIndex, contMap in pairs(C_Map.GetMapChildrenInfo(C_Map.GetMapInfo(C_Map.GetFallbackWorldMapID()).mapID)) do
if contMap.mapType == 2 then
local cont_children = C_Map.GetMapChildrenInfo(contMap.mapID)
local znames = {}
for zoneMapIndex, zoneMap in pairs(cont_children) do
if zoneMap.mapType == 3 then
table.insert(znames,zoneMap.name)
zonei[zoneMap.name], zonec[zoneMap.name] = zoneMap.mapID, contMap.mapID
end
end
zonenames[contMapIndex] = znames
end
end
-- for ci,c in pairs{GetMapContinents()} do
-- zonenames[ci] = {GetMapZones(ci)}
-- for zi,z in pairs(zonenames[ci]) do
-- zonei[z], zonec[z] = zi, ci
-- end
-- end
local cache = {}
local function MapPoint(zone, x, y, desc, c, z)
TourGuide:DebugF(1, "Mapping %q - %s (%.2f, %.2f)", desc, zone or z, x, y)
local zi, zc = z or zone and zonei[zone], c or zone and zonec[zone]
if not zi then
if zone then TourGuide:PrintF(L["Cannot find zone %q, using current zone."], zone)
else TourGuide:Print(L["No zone provided, using current zone."]) end
zi, zc = GetCurrentMapZone(), GetCurrentMapContinent()
end
zone = zone or zonenames[zc][zi]
if TomTom then table.insert(cache, TomTom:AddWaypoint(zi, x/100, y/100, {
title = desc or L["TomTom waypoint"],
}))
elseif Cartographer_Waypoints then
local pt = NotePoint:new(zone, x/100, y/100, desc)
Cartographer_Waypoints:AddWaypoint(pt)
table.insert(cache, pt.WaypointID)
end
C_ChatInfo.SendAddonMessage("TGuideWP", string.join(" ", zc, zi, x, y, desc), "PARTY")
end
-- local function MapPoint(zone, x, y, desc)
-- TourGuide:DebugF(1, "Mapping %q - %s (%.2f, %.2f)", desc, zone, x, y)
-- if zone then TourGuide:PrintF(L["Cannot find zone %q, using current zone."], zone)
-- else TourGuide:Print(L["No zone provided, using current zone."]) end
--
-- zone = zone or hbd:GetLocalizedMap(C_Map.GetBestMapForUnit("player"))
--
-- if TomTom then
-- table.insert(cache, TomTom:AddWaypoint(TomTom.NameToMapId[zone], {title = desc, persistent = false}))
-- -- elseif Cartographer_Waypoints then
-- -- local pt = NotePoint:new(zone, x/100, y/100, desc)
-- -- Cartographer_Waypoints:AddWaypoint(pt)
-- -- table.insert(cache, pt.WaypointID)
-- end
--
-- C_ChatInfo.SendAddonMessage("TGuideWP", string.join(" ", zc, zi, x, y, desc), "PARTY")
-- end
local elapsed, taction, tquest, tzone, tnote, tqid, tlogi
local f = CreateFrame("Frame")
f:Hide()
f:SetScript("OnShow", function() elapsed = 0 end)
f:SetScript("OnUpdate", function(self, elap)
elapsed = elapsed + elap
if elapsed < 1 then return end
self:Hide()
TourGuide:ParseAndMapCoords(taction, tquest, tzone, tnote, tqid, tlogi)
end)
local temp = {}
function TourGuide:ParseAndMapCoords(action, quest, zone, note, qid, logi)
taction, tquest, tzone, tnote, tqid, tlogi = action, quest, zone, note, qid, logi
if TomTom and TomTom.RemoveWaypoint then
while cache[1] do TomTom:RemoveWaypoint(table.remove(cache)) end
elseif Cartographer_Waypoints then
while cache[1] do Cartographer_Waypoints:CancelWaypoint(table.remove(cache)) end
end
if logi and (action == "COMPLETE" or action == "TURNIN") then
-- QuestMapUpdateAllQuests()
-- QuestPOIUpdateIcons()
local _, x, y, obj --= QuestPOIGetIconInfo(qid)
if x and y then table.insert(temp, y*100) table.insert(temp, x*100)
--else return f:Show()
end
end
if not temp[1] and (action == "ACCEPT" or action == "TURNIN") and LightHeaded then self:MapLightHeadedNPC(qid, action, quest) end
if not temp[1] and note and self.db.char.mapnotecoords then for x,y in note:gmatch(L.COORD_MATCH) do table.insert(temp, tonumber(y)); table.insert(temp, tonumber(x)) end end
while temp[1] do MapPoint(zone, table.remove(temp), table.remove(temp), "[TG] "..quest) end
end
function TourGuide:MapLightHeadedNPC(qid, action, quest)
if not self.db.char.mapquestgivers then return end
local npcid, npcname, stype
if action == "ACCEPT" then _, _, _, _, stype, npcname, npcid = LightHeaded:GetQuestInfo(qid)
else _, _, _, _, _, _, _, stype, npcname, npcid = LightHeaded:GetQuestInfo(qid) end
self:Debug(1, "LightHeaded lookup", action, qid, stype, npcname, npcid)
if stype ~= "npc" then return end
local data = LightHeaded:LoadNPCData(tonumber(npcid))
if not data then return end
for zid,x,y in data:gmatch("([^,]+),([^,]+),([^:]+):") do MapPoint(nil, tonumber(x), tonumber(y), "[TG] "..quest.." ("..npcname..")", LightHeaded:WZIDToCZ(tonumber(zid))) end
return true
end