Merge branch 'master' into translations
[QuestHelper.git] / cartographer.lua
blob5ba1b0a53a940cc422f9ef4e13c70ee571174fa1
1 QuestHelper_File["cartographer.lua"] = "Development Version"
2 QuestHelper_Loadtime["cartographer.lua"] = GetTime()
4 local cartographer_cb
5 local cartographer_wp
7 local QuestHelperPoint
9 local function cartographer_wp_update(c, z, x, y, desc)
10 if cartographer_wp then
11 cartographer_wp:Cancel()
12 end
14 if not QuestHelper_Pref.hide and c and c >= 0 then
15 cartographer_wp = QuestHelperPoint:new(c, z, x, y, desc)
16 Cartographer_Waypoints:AddWaypoint(cartographer_wp)
17 end
18 end
20 function QuestHelper:EnableCartographer()
21 if Cartographer_Waypoints and Waypoint and not Waypoint.prototype then
22 if not QuestHelperPoint then
23 QuestHelperPoint = Waypoint:new()
24 QuestHelperPoint.ShowOnMap = false
26 function QuestHelperPoint:init(c, z, x, y, desc)
27 self.x, self.y, self.task = x, y, desc
29 local zone = QuestHelper.Astrolabe:GetMapVirtualZones(c)[z] -- wellllp
31 if Rock then
32 local LibBabble = Rock("LibBabble-Zone-3.0", false, true)
33 if LibBabble then
34 zone = LibBabble:GetReverseLookupTable()[zone]
35 end
36 end
38 self.Zone = zone
39 end
41 function QuestHelperPoint:Cancel()
42 self.task = nil
44 if cartographer_wp == self then
45 cartographer_wp = nil
46 end
48 Waypoint.Cancel(self)
49 end
51 function QuestHelperPoint:ToString()
52 return self.task or "Waypoint"
53 end
54 end
56 if not cartographer_cb then
57 cartographer_cb = QuestHelper:AddWaypointCallback(cartographer_wp_update)
58 end
59 end
60 end
62 function QuestHelper:DisableCartographer()
63 if cartographer_cb then
64 if cartographer_wp then
65 cartographer_wp:Cancel()
66 end
68 QuestHelper:RemoveWaypointCallback(cartographer_cb)
69 cartographer_cb = nil
70 end
71 end