Quantcast

Added support for Cartographer_Waypoints (and thereby Carbonite).

James D. Callahan III [07-02-10 - 04:40]
Added support for Cartographer_Waypoints (and thereby Carbonite).
Filename
Config.lua
Frame.lua
Waypoint.lua
diff --git a/Config.lua b/Config.lua
index 874ed8c..be3ad5f 100644
--- a/Config.lua
+++ b/Config.lua
@@ -212,7 +212,7 @@ end
 local arlmap

 local function giveMap()
-	local has_tomtom = TomTom and true or false
+	local has_waypoints = _G.TomTom or _G.Cartographer_Waypoints or false

 	if not arlmap then
 		arlmap = {
@@ -231,7 +231,7 @@ local function giveMap()
 					type	= "toggle",
 					name	= L["Auto Scan Map"],
 					desc	= L["AUTOSCANMAP_DESC"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					get	= function() return addon.db.profile.autoscanmap end,
 					set	= function() addon.db.profile.autoscanmap = not addon.db.profile.autoscanmap end,
 				},
@@ -240,7 +240,7 @@ local function giveMap()
 					type	= "toggle",
 					name	= _G.WORLD_MAP,
 					desc	= L["WORLDMAP_DESC"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					get	= function() return addon.db.profile.worldmap end,
 					set	= function() addon.db.profile.worldmap = not addon.db.profile.worldmap end,
 				},
@@ -249,7 +249,7 @@ local function giveMap()
 					type	= "toggle",
 					name	= L["Mini Map"],
 					desc	= L["MINIMAP_DESC"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					get	= function() return addon.db.profile.minimap end,
 					set	= function() addon.db.profile.minimap = not addon.db.profile.minimap end,
 				},
@@ -258,7 +258,7 @@ local function giveMap()
 					type	= "toggle",
 					name	= L["Trainer"],
 					desc	= L["MAP_TRAINER_DESC"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					get	= function() return addon.db.profile.maptrainer end,
 					set	= function() addon.db.profile.maptrainer = not addon.db.profile.maptrainer end,
 				},
@@ -267,7 +267,7 @@ local function giveMap()
 					type	= "toggle",
 					name	= L["Vendor"],
 					desc	= L["MAP_VENDOR_DESC"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					get	= function() return addon.db.profile.mapvendor end,
 					set	= function() addon.db.profile.mapvendor = not addon.db.profile.mapvendor end,
 				},
@@ -276,7 +276,7 @@ local function giveMap()
 					type	= "toggle",
 					name	= L["Monster"],
 					desc	= L["MAP_MONSTER_DESC"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					get	= function() return addon.db.profile.mapmob end,
 					set	= function() addon.db.profile.mapmob = not addon.db.profile.mapmob end,
 				},
@@ -285,7 +285,7 @@ local function giveMap()
 					type	= "toggle",
 					name	= L["Quest"],
 					desc	= L["MAP_QUEST_DESC"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					get	= function() return addon.db.profile.mapquest end,
 					set	= function() addon.db.profile.mapquest = not addon.db.profile.mapquest end,
 				},
@@ -293,7 +293,7 @@ local function giveMap()
 					order	= 20,
 					type	= "execute",
 					name	= L["Clear Waypoints"],
-					disabled = not has_tomtom,
+					disabled = not has_waypoints,
 					desc	= L["CLEAR_WAYPOINTS_DESC"],
 					func	= function() addon:ClearMap() end,
 				},
diff --git a/Frame.lua b/Frame.lua
index 76bcf6a..e3e2911 100644
--- a/Frame.lua
+++ b/Frame.lua
@@ -906,7 +906,7 @@ do
 			ttAdd(0, -1, 0, L["CTRL_CLICK"], color_1)
 			ttAdd(0, -1, 0, L["SHIFT_CLICK"], color_1)

-			if _G.TomTom and (addon.db.profile.worldmap or addon.db.profile.minimap) then
+			if (_G.TomTom or _G.Cartographer_Waypoints) and (addon.db.profile.worldmap or addon.db.profile.minimap) then
 				ttAdd(0, -1, 0, L["CTRL_SHIFT_CLICK"], color_1)
 			end
 		end
diff --git a/Waypoint.lua b/Waypoint.lua
index c68897d..a3ddbe2 100644
--- a/Waypoint.lua
+++ b/Waypoint.lua
@@ -307,11 +307,14 @@ local iconlist = {}

 -- Clears all the icons from the world map and the mini-map
 function addon:ClearMap()
-	if TomTom then
-		for i in pairs(iconlist) do
-			TomTom:RemoveWaypoint(iconlist[i])
+	if _G.TomTom and _G.TomTom.RemoveWaypoint then
+		while iconlist[1] do
+			_G.TomTom:RemoveWaypoint(table.remove(iconlist))
+		end
+	elseif _G.Cartographer_Waypoints then
+		while iconlist[1] do
+			_G.Cartographer_Waypoints:CancelWaypoint(table.remove(iconlist))
 		end
-		iconlist = table.wipe(iconlist)
 	end
 end

@@ -371,10 +374,10 @@ local maplist = {}

 -- Adds mini-map and world map icons with tomtom.
 -- Expected result: Icons are added to the world map and mini-map.
--- Input: An optional recipe ID
+-- Input: An optional recipe ID, acquire ID, and location ID.
 -- Output: Points are added to the maps
 function addon:AddWaypoint(recipe_id, acquire_id, location_id)
-	if not TomTom then
+	if not _G.TomTom and not _G.Cartographer_Waypoints then
 		return
 	end
 	local worldmap = addon.db.profile.worldmap
@@ -521,9 +524,13 @@ function addon:AddWaypoint(recipe_id, acquire_id, location_id)
 				addon:Debug("Location is \"0, 0\" for ID %d. Location: %s.", spell_id, location)
 			end

-			local iconuid = TomTom:AddZWaypoint(continent, zone, x, y, name, false, minimap, worldmap)
-
-			tinsert(iconlist, iconuid)
+			if _G.TomTom then
+				table.insert(iconlist, _G.TomTom:AddZWaypoint(continent, zone, x, y, name, false, minimap, worldmap))
+			elseif _G.Cartographer_Waypoints then
+				local pt = _G.NotePoint:new(zone, x/100, y/100, desc)
+				_G.Cartographer_Waypoints:AddWaypoint(pt)
+				table.insert(iconlist, pt.WaypointID)
+			end
 		else
 			--@alpha@
 			if not zone then