diff --git a/TomTom_Waypoints.lua b/TomTom_Waypoints.lua
index ffd1056..b1cbbf1 100644
--- a/TomTom_Waypoints.lua
+++ b/TomTom_Waypoints.lua
@@ -33,7 +33,7 @@ local DEFAULT_DISTANCE = 10
--
-- Creates a new waypoint object at the given coordinate, with the supplied
-- title and note. Returns a waypoint object. When
-function Waypoint:New(c,z,x,y,distance,title,note)
+function Waypoint:New(c,z,x,y,title,note,distance,callback)
if not self.pool then self.pool = {} end
-- Try to acquire a waypoint from the frame pool
@@ -55,9 +55,9 @@ function Waypoint:New(c,z,x,y,distance,title,note)
point.world = CreateFrame("Button", nil, WorldMapButton)
point.world:SetHeight(12)
point.world:SetWidth(12)
- point:RegisterForClicks("RightButtonUp")
- point:SetNormalTexture("Interface\\Minimap\\ObjectIcons")
- point:GetNormalTexture():SetTExCoords(0.5, 0.75, 0, 0.25)
+ point.world:RegisterForClicks("RightButtonUp")
+ point.world:SetNormalTexture("Interface\\Minimap\\ObjectIcons")
+ point.world:GetNormalTexture():SetTexCoord(0.5, 0.75, 0, 0.25)
-- Create the minimap model
point.arrow = CreateFrame("Model", nil, point)
@@ -74,9 +74,13 @@ function Waypoint:New(c,z,x,y,distance,title,note)
point:SetScript("OnUpdate", OnUpdate)
point:SetScript("OnClick", OnClick)
+ point.world:SetScript("OnEnter", OnEnter)
+ point.world:SetScript("OnLeave", OnLeave)
+ point.world:SetScript("OnClick", OnClick)
+
-- Copy all methods into the table
for k,v in pairs(Waypoint) do
- Waypoint[k] = v
+ point[k] = v
end
end
@@ -89,10 +93,24 @@ function Waypoint:New(c,z,x,y,distance,title,note)
point.note = note
point.distance = distance or DEFAULT_DISTANCE
point.callback = callback
+
+ -- Set the data for this waypoint
+ point.world.c = c
+ point.world.z = z
+ point.world.x = x
+ point.world.y = y
+ point.world.title = title
+ point.world.note = note
+ point.world.distance = distance or DEFAULT_DISTANCE
+ point.world.callback = callback
-- Use Astrolabe to place the waypoint
-- TODO: Place the waypoint via astrolabe
+ x,y = x/100,y/100
+ Astrolabe:PlaceIconOnMinimap(point, c, z, x, y)
+ Astrolabe:PlaceIconOnWorldMap(WorldMapDetailFrame, point.world, c, z, x, y)
+
return point
end
@@ -112,29 +130,35 @@ function Waypoint:Clear()
self.icon:Hide()
self.arrow:Hide()
self.world:Hide()
+
+ self:Hide()
+ Astrolabe:RemoveIconFromMinimap(self)
-- Add the waypoint back into the frame pool
table.insert(pool, self)
-
- -- TODO: Remove from Astrolabe
end
do
+ -- Local variable declarations
+ local tooltip_icon
+
function OnEnter(self, motion)
- tooltip:SetParent(self)
tooltip:SetOwner(self, "ANCHOR_CURSOR")
-- Display the title, and add the note if it exists
- tooltip:SetTitle(title or "TomTom Waypoint")
- tooltip:AddLine(self.note or "No note for this waypoint")
+ tooltip:SetText(title or "TomTom Waypoint")
+ tooltip:AddLine(self.note or "No note for this waypoint", 1, 1, 1)
local dist,x,y = Astrolabe:GetDistanceToIcon(self)
- tooltip:AddLine(format("%.2f, %.2f", self.x, self.y), 1, 1, 1)
- tooltip:AddLine(("%s yards away"):format(math.floor(dist)), 1, 1 ,1)
- tooltip:AddLine(TomTom:GetZoneText(self.zone), 0.7, 0.7, 0.7)
+ tooltip:AddLine(format("\n%.2f, %.2f", self.x, self.y), 1, 1, 1)
+ if dist then
+ tooltip:AddLine(("%s yards away"):format(math.floor(dist)), 1, 1 ,1)
+ end
+ tooltip:AddLine(TomTom:GetZoneName(self.c, self.z), 0.7, 0.7, 0.7)
tooltip:Show()
tooltip:SetScript("OnUpdate", Tooltip_OnUpdate)
+ tooltip_icon = self
end
function OnLeave(self, motion)
@@ -144,37 +168,76 @@ do
function OnClick(self, button, down)
--TODO: Implement dropdown
end
+
+ local halfpi = math.pi / 2
+
+ -- The magic number which represents the ratio of model position pixels to
+ -- logical screen pixels. I suspect this is really based on some property of the
+ -- model itself, but I figured it out through interpolation given 3 ratios
+ -- 4:3 5:4 16:10
+ local MAGIC_ARROW_NUMBER = 0.000723339
+
+ -- Calculation to determine the actual offset factor for the screen ratio, I dont
+ -- know where the 1/3 rationally comes from, but it works, there's probably some
+ -- odd logic within the client somewhere.
+ --
+ -- 70.4 is half the width of the frame so we move to the center
+ local ofs = MAGIC_ARROW_NUMBER * (GetScreenHeight()/GetScreenWidth() + 1/3) * 70.4;
+ -- The divisor here puts the arrow where the original magic number pair had it
+ local radius = ofs / 1.166666666666667;
+
+ local function gomove(model,angle)
+ model:SetFacing(angle);
+ -- The 137/140 simply adjusts for the fact that the textured
+ -- border around the minimap isn't exactly centered
+ model:SetPosition(ofs * (137 / 140) - radius * math.sin(angle),
+ ofs + radius * math.cos(angle), 0);
+ end
function OnUpdate(self, elapsed)
local edge = Astrolabe:IsIconOnEdge(self)
- if edge and not self.arrow:IsShown() then
- self.arrow:Show()
- self.icon:Hide()
- self.edge = true
- elseif not edge and not self.icon:IsShown() then
- self.icon:Show()
- self.arrow:Hide()
- self.edge = false
- end
+ if edge then
+ if not self.arrow:IsShown() then
+ self.arrow:Show()
+ self.icon:Hide()
+ self.edge = true
+ end
+ local angle = Astrolabe:GetDirectionToIcon(self)
+
+ if GetCVar("rotateMinimap") == "1" then
+ local cring = MiniMapCompassRing:GetFacing()
+ angle = angle + cring
+ end
+
+ gomove(self.arrow, angle)
+ else
+ if not self.icon:IsShown() then
+ self.icon:Show()
+ self.arrow:Hide()
+ self.edge = false
+ end
+ end
+
local dist,x,y = Astrolabe:GetDistanceToIcon(self)
- local cleardist = TomTom.profile.options.cleardist
-
+
if dist <= self.distance then
if self.callback then
self.callback(self)
- self:Clear()
end
+ self:Clear()
end
end
local count = 0
function Tooltip_OnUpdate(self, elapsed)
count = count + elapsed
- if count >= 0.1 then
- local dist,x,y = Astrolabe:GetDistanceToIcon(self:GetParent())
- TomTomTooltipTextLeft4:SetText(("%s yards away"):format(math.floor(dist)), 1, 1, 1)
+ if count >= 0.2 then
+ local dist,x,y = Astrolabe:GetDistanceToIcon(tooltip_icon)
+ if dist then
+ TomTomTooltipTextLeft4:SetText(("%s yards away"):format(math.floor(dist)), 1, 1, 1)
+ end
end
end
end
diff --git a/TomTom_Zones.lua b/TomTom_Zones.lua
index f7b2712..e54f6a8 100644
--- a/TomTom_Zones.lua
+++ b/TomTom_Zones.lua
@@ -10,6 +10,7 @@ local tokens = {
["Bloodmyst Isle"] = "BLOO",
["Darkshore"] = "DARK",
["Darnassus"] = "DARN",
+ ["Desolace"] = "DESO",
["Durotar"] = "DURO",
["Dustwallow Marsh"] = "DUST",
["Felwood"] = "FELW",
@@ -73,7 +74,10 @@ for c in pairs{GetMapContinents()} do
zones[c] = {GetMapZones(c)}
for idx,zone in ipairs(zones[c]) do
local token = tokens[zone]
- zones[token] = format("%d,%d", c, zone)
+ assert(token, tostring(zone))
+
+ zones[token] = format("%d,%d", c, idx)
+ zones[zones[token]] = zone
end
zones[c] = nil
end
@@ -98,5 +102,15 @@ end
-- Converts a zone name into a continent,zone pair usable by Astrolabe
function TomTom:GetZoneNumber(name)
local token = self:GetZoneToken(name)
- return strsplit(",", zones[token])
+ local c,z = strsplit(",", zones[token])
+ return tonumber(c),tonumber(z)
+end
+
+-- name = TomTom:GetZoneName(c,z)
+-- c (number) - The continent number
+-- z (number) - The zone number
+--
+-- Converts a c,z, pair into a zone name
+function TomTom:GetZoneName(c,z)
+ return zones[string.format("%d,%d", c, z)]
end