diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua index 0a6bb6b..c6faa28 100644 --- a/TomTom_CrazyArrow.lua +++ b/TomTom_CrazyArrow.lua @@ -38,15 +38,24 @@ local function OnDragStop(self, button) self:StopMovingOrSizing() end +local function OnEvent(self, event, ...) + if event == "ZONE_CHANGED_NEW_AREA" then + self:Show() + end +end + wayframe:SetScript("OnDragStart", OnDragStart) wayframe:SetScript("OnDragStop", OnDragStop) wayframe:RegisterForDrag("LeftButton") +wayframe:RegisterEvent("ZONE_CHANGED_NEW_AREA") +wayframe:SetScript("OnEvent", OnEvent) wayframe.arrow = wayframe:CreateTexture("OVERLAY") wayframe.arrow:SetTexture("Interface\\Addons\\TomTom\\Images\\Arrow") wayframe.arrow:SetAllPoints() local active_point, arrive_distance, showDownArrow + function TomTom:SetCrazyArrow(point, dist) active_point = point.minimap arrive_distance = dist @@ -58,7 +67,11 @@ local arrow = wayframe.arrow local count = 0 local function OnUpdate(self, elapsed) local dist,x,y = Astrolabe:GetDistanceToIcon(active_point) - + if not dist then + self:Hide() + return + end + status:SetText(string.format("%d yards", dist)) -- Showing the arrival arrow? diff --git a/TomTom_Waypoints.lua b/TomTom_Waypoints.lua index 0dc5307..0f64253 100644 --- a/TomTom_Waypoints.lua +++ b/TomTom_Waypoints.lua @@ -12,7 +12,7 @@ local tooltip = CreateFrame("GameTooltip", "TomTomTooltip", nil, "GameTooltipTem local pool = {} -- Local declarations -local Minimap_OnEnter,Minimap_OnLeave,Minimap_OnUpdate,Minimap_OnClick +local Minimap_OnEnter,Minimap_OnLeave,Minimap_OnUpdate,Minimap_OnClick,Minimap_OnEvent local Arrow_OnUpdate local Minimap_OnEvent local World_OnEnter,World_OnLeave,World_OnClick,World_OnEvent @@ -85,7 +85,9 @@ function TomTom:SetWaypoint(c,z,x,y,far,near,arrive,callback) point.minimap:SetScript("OnLeave", Minimap_OnLeave) point.minimap:SetScript("OnUpdate", Minimap_OnUpdate) point.minimap:SetScript("OnClick", Minimap_OnClick) - + point.minimap:RegisterEvent("PLAYER_ENTERING_WORLD") + point.minimap:SetScript("OnEvent", Minimap_OnEvent) + point.world:RegisterEvent("WORLD_MAP_UPDATE") point.world:SetScript("OnEnter", World_OnEnter) point.world:SetScript("OnLeave", World_OnLeave) @@ -276,4 +278,11 @@ do end end end + + function Minimap_OnEvent(self, event, ...) + if event == "PLAYER_ENTERING_WORLD" then + local data = self.data + Astrolabe:PlaceIconOnMinimap(self, data.c, data.z, data.x/100, data.y/100) + end + end end