From 1683dfa9bb0e339a2a7f3a722f645deb551a094f Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Thu, 22 Oct 2009 09:52:41 +0000 Subject: [PATCH] Added the ability to right-click on the coordinate block to set a waypoint at the current location --- TomTom.lua | 7 +++++++ TomTom_Waypoints.lua | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/TomTom.lua b/TomTom.lua index 64014bf..57e2a6a 100755 --- a/TomTom.lua +++ b/TomTom.lua @@ -909,6 +909,13 @@ do function Block_OnDragStop(self, button, down) self:StopMovingOrSizing() end + + function Block_OnClick(self, button, down) + local c,z,x,y = Astrolabe:GetCurrentPlayerPosition() + local zone = TomTom:GetMapFile(c, z) + local desc = format("%s: %.2f, %.2f", zone, x*100, y*100) + TomTom:AddZWaypoint(c, z, x*100, y*100, desc) + end end local function usage() diff --git a/TomTom_Waypoints.lua b/TomTom_Waypoints.lua index 59561bd..1ebd2bf 100644 --- a/TomTom_Waypoints.lua +++ b/TomTom_Waypoints.lua @@ -26,8 +26,12 @@ do until not line end +-- Store a reference to the minimap parent +local minimapParent = Minimap + -- Create a local table used as a frame pool local pool = {} +local all_points = {} -- Create a mapping from uniqueID to waypoint local getuid,resolveuid @@ -87,6 +91,14 @@ local function rotateArrow(self) self.arrow:SetTexCoord(0.5-sin, 0.5+cos, 0.5+cos, 0.5+sin, 0.5-cos, 0.5-sin, 0.5+sin, 0.5-cos) end +function TomTom:ReparentMinimap(minimap) + minimapParent = minimap + for idx, waypoint in ipairs(all_points) do + waypoint:SetParent(minimap) + end +end + + function TomTom:SetWaypoint(c, z, x, y, callbacks, show_minimap, show_world) -- Try to acquire a waypoint from the frame pool local point = table.remove(pool) @@ -94,11 +106,14 @@ function TomTom:SetWaypoint(c, z, x, y, callbacks, show_minimap, show_world) if not point then point = {} - local minimap = CreateFrame("Button", nil, Minimap) + local minimap = CreateFrame("Button", nil, minimapParent) minimap:SetHeight(20) minimap:SetWidth(20) minimap:RegisterForClicks("RightButtonUp") + -- Add to the "All points" table so we can reparent easily + table.insert(all_points, minimap) + minimap.icon = minimap:CreateTexture("BACKGROUND") minimap.icon:SetTexture("Interface\\AddOns\\TomTom\\Images\\GoldGreenDot") minimap.icon:SetPoint("CENTER", 0, 0) -- 1.7.9.5