Quantcast

Fixed some of the bugs that exist, while breaking new features.

James Whitehead II [08-13-08 - 18:40]
Fixed some of the bugs that exist, while breaking new features.
  * The option to disable waypoints from other zones on the world and minimap is disabled, since it's broken in pieces right now
Filename
TomTom.lua
TomTom_Config.lua
TomTom_CrazyArrow.lua
TomTom_Waypoints.lua
diff --git a/TomTom.lua b/TomTom.lua
index e9227f3..1a93672 100755
--- a/TomTom.lua
+++ b/TomTom.lua
@@ -136,9 +136,9 @@ function TomTom:ADDON_LOADED(event, addon)
 		self.waypoints = waypoints

 		self:RegisterEvent("PLAYER_LEAVING_WORLD")
-		self:RegisterEvent("PLAYER_ENTERING_WORLD", "ReloadWaypoints")
-		self:RegisterEvent("ZONE_CHANGED_NEW_AREA", "ReloadWaypoints")
-		self:RegisterEvent("WORLD_MAP_UPDATE", "ReloadWaypoints")
+		self:RegisterEvent("PLAYER_ENTERING_WORLD", "ZoneChanged")
+		self:RegisterEvent("ZONE_CHANGED_NEW_AREA", "ZoneChanged")
+		self:RegisterEvent("WORLD_MAP_UPDATE", "ZoneChanged")
 		self:RegisterEvent("CHAT_MSG_ADDON")

 		self:ReloadOptions()
@@ -157,24 +157,12 @@ function TomTom:ReloadOptions()
 end

 function TomTom:ReloadWaypoints()
-	self:ShowHideCoordBlock()
-
-	-- Hide any waypoints that might be currently set
-	for uid,point in pairs(waypoints) do
-		self:ClearWaypoint(uid)
-	end
+	local pc, pz = GetCurrentMapContinent(), GetCurrentMapZone()

 	waypoints = {}
 	self.waypoints = waypoints
 	self.waypointprofile = self.waydb.profile
-
-	if IsInInstance() then
-		return
-	end
-
-	--local pc,pz = GetCurrentMapContinent(), GetCurrentMapZone()
-	local pc, pz = GetCurrentMapContinent(), GetCurrentMapZone()
-
+
 	for zone,data in pairs(self.waypointprofile) do
 		local c,z = self:GetCZ(zone)
 		local same = (c == pc) and (z == pz)
@@ -189,6 +177,11 @@ function TomTom:ReloadWaypoints()
 	end
 end

+function TomTom:ZoneChanged()
+	-- Update the visibility of the coordinate box
+	self:ShowHideCoordBlock()
+end
+
 function TomTom:ShowHideWorldCoords()
 	-- Bail out if we're not supposed to be showing this frame
 	if self.profile.mapcoords.playerenable or self.db.profile.mapcoords.cursorenable then
@@ -668,7 +661,7 @@ function TomTom:AddWaypoint(x, y, desc, persistent, minimap, world, silent)
 	return self:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, silent)
 end

-function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, custom_callbacks, silent)
+function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, custom_callbacks, silent, crazy)
 	local callbacks
 	if custom_callbacks then
 		callbacks = custom_callbacks
@@ -698,6 +691,7 @@ function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, custo
 	if persistent == nil then persistent = self.profile.persistence.savewaypoints end
 	if minimap == nil then minimap = self.profile.minimap.enable end
 	if world == nil then world = self.profile.worldmap.enable end
+	if crazy == nil then crazy = self.profile.arrow.autoqueue end

 	local coord = self:GetCoord(x / 100, y / 100)
 	local zone = self:GetMapFile(c, z)
@@ -714,7 +708,7 @@ function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, custo
 	end

 	local uid = self:SetWaypoint(c,z,x/100,y/100, callbacks, minimap, world)
-	if self.profile.arrow.autoqueue then
+	if crazy then
 		self:SetCrazyArrow(uid, self.profile.arrow.arrival, desc)
 	end

diff --git a/TomTom_Config.lua b/TomTom_Config.lua
index 3cb67b1..a6a9be9 100644
--- a/TomTom_Config.lua
+++ b/TomTom_Config.lua
@@ -306,6 +306,7 @@ local function createconfig()
 				desc = L["TomTom can hide waypoints in other zones, this setting toggles that functionality"],
 				width = "double",
 				arg = "minimap.otherzone",
+				disabled = true,
 			},
 			tooltip = {
 				type = "toggle",
@@ -350,6 +351,7 @@ local function createconfig()
 				desc = L["TomTom can hide waypoints in other zones, this setting toggles that functionality"],
 				width = "double",
 				arg = "worldmap.otherzone",
+				disabled = true,
 			},
 			tooltip = {
 				order = 4,
diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua
index 35d66e1..ac04d26 100644
--- a/TomTom_CrazyArrow.lua
+++ b/TomTom_CrazyArrow.lua
@@ -132,7 +132,7 @@ local function OnUpdate(self, elapsed)
 	end

 	local dist,x,y = TomTom:GetDistanceToWaypoint(active_point)
-	if not dist then
+	if not dist or IsInInstance() then
 		self:Hide()
 		return
 	end
diff --git a/TomTom_Waypoints.lua b/TomTom_Waypoints.lua
index 719a335..591e170 100644
--- a/TomTom_Waypoints.lua
+++ b/TomTom_Waypoints.lua
@@ -168,6 +168,8 @@ function TomTom:SetWaypoint(c, z, x, y, callbacks, show_minimap, show_world)

 	if show_world then
 		Astrolabe:PlaceIconOnWorldMap(WorldMapDetailFrame, point.worldmap, c, z, x, y)
+	else
+		point.worldmap.disabled = true
 	end

 	if not show_minimap then
@@ -186,6 +188,32 @@ function TomTom:SetWaypoint(c, z, x, y, callbacks, show_minimap, show_world)
 	return point.uid
 end

+function TomTom:HideWaypoint(uid, minimap, worldmap)
+	local point = resolveuid(uid)
+	if point then
+		if minimap then
+			point.minimap.disabled = true
+			point.minimap:Hide()
+		end
+
+		if worldmap then
+			point.worldmap.disabled = true
+			point.worldmap:Hide()
+		end
+	end
+end
+
+function TomTom:ShowWaypoint(uid)
+	local point = resolveuid(uid)
+	if point then
+		point.minimap.disabled = not point.data.show_minimap
+		point.minimap:Show()
+
+		point.worldmap.disabled = not point.data.show_worldmap
+		point.worldmap:Show()
+	end
+end
+
 function TomTom:ClearWaypoint(uid)
 	local point = resolveuid(uid, true)
 	if point then
@@ -198,6 +226,10 @@ function TomTom:ClearWaypoint(uid)
 		point.minimap.callbacks = nil
 		point.worldmap.callbacks = nil

+		-- Clear disabled flags
+		point.minimap.disabled = nil
+		point.worldmap.disabled = nil
+
 		point.dlist = nil
 		point.uid = nil
 		table.insert(pool, point)
@@ -278,7 +310,7 @@ do
 		local dist,x,y = Astrolabe:GetDistanceToIcon(self)
 		local disabled = self.disabled

-		if not dist and not disabled then
+		if disabled or not dist or IsInInstance() then
 			self:Hide()
 			return
 		end
@@ -377,7 +409,7 @@ do
 			end

 			local data = self.point
-			if data.worldmap and data.show_world then
+			if data.worldmap and data.show_world and not disabled then
 				local x,y = Astrolabe:PlaceIconOnWorldMap(WorldMapDetailFrame, self, data.c, data.z, data.x, data.y)
 				if (x and y and (0 < x and x <= 1) and (0 < y and y <= 1)) then
 					self:Show()