Merge branch 'master' into flightpoint-rewrite
[QuestHelper.git] / dodads.lua
blob623d4c72dcff7aa9ca58d89f4a66e38f9b712dde
1 local ofs = 0.000723339 * (GetScreenHeight()/GetScreenWidth() + 1/3) * 70.4;
2 local radius = ofs / 1.166666666666667;
4 local function convertLocation(p)
5 local c, x, y = p[1].c, p[3], p[4]
6 x, y = x/QuestHelper.continent_scales_x[c], y/QuestHelper.continent_scales_y[c]
7 return c, 0, x, y
8 end
10 local function convertLocationToScreen(p, c, z)
11 return QuestHelper.Astrolabe:TranslateWorldMapPosition(p[1].c, 0, p[3]/QuestHelper.continent_scales_x[p[1].c], p[4]/QuestHelper.continent_scales_y[p[1].c], c, z)
12 end
14 local function convertNodeToScreen(n, c, z)
15 return QuestHelper.Astrolabe:TranslateWorldMapPosition(n.c, 0, n.x/QuestHelper.continent_scales_x[n.c], n.y/QuestHelper.continent_scales_y[n.c], c, z)
16 end
18 QuestHelper.map_overlay = CreateFrame("FRAME", nil, WorldMapButton)
19 QuestHelper.map_overlay:SetFrameLevel(WorldMapButton:GetFrameLevel()+1)
20 QuestHelper.map_overlay:SetAllPoints()
21 QuestHelper.map_overlay:SetFrameStrata("FULLSCREEN")
23 local function ClampLine(x1, y1, x2, y2)
24 if x1 and y1 and x2 and y2 then
25 local x_div, y_div = (x2-x1), (y2-y1)
26 local x_0 = y1-x1/x_div*y_div
27 local x_1 = y1+(1-x1)/x_div*y_div
28 local y_0 = x1-y1/y_div*x_div
29 local y_1 = x1+(1-y1)/y_div*x_div
31 if y1 < 0 then
32 x1 = y_0
33 y1 = 0
34 end
36 if y2 < 0 then
37 x2 = y_0
38 y2 = 0
39 end
41 if y1 > 1 then
42 x1 = y_1
43 y1 = 1
44 end
46 if y2 > 1 then
47 x2 = y_1
48 y2 = 1
49 end
51 if x1 < 0 then
52 y1 = x_0
53 x1 = 0
54 end
56 if x2 < 0 then
57 y2 = x_0
58 x2 = 0
59 end
61 if x1 > 1 then
62 y1 = x_1
63 x1 = 1
64 end
66 if x2 > 1 then
67 y2 = x_1
68 x2 = 1
69 end
71 if x1 >= 0 and x2 >= 0 and y1 >= 0 and y2 >= 0 and x1 <= 1 and x2 <= 1 and y1 <= 1 and y2 <= 1 then
72 return x1, y1, x2, y2
73 end
74 end
75 end
77 local function pushPath(list, path, c, z)
78 if path then
79 pushPath(list, path.p, c, z)
80 local t = QuestHelper:CreateTable()
81 t[1], t[2] = QuestHelper.Astrolabe:TranslateWorldMapPosition(path.c, 0, path.x/QuestHelper.continent_scales_x[path.c], path.y/QuestHelper.continent_scales_y[path.c], c, z)
82 table.insert(list, t)
83 end
84 end
86 function QuestHelper:CreateWorldMapWalker()
87 local walker = CreateFrame("Button", nil, QuestHelper.map_overlay)
88 walker:SetWidth(0)
89 walker:SetHeight(0)
90 walker:SetPoint("CENTER", WorldMapFrame, "TOPLEFT", 0, 0)
91 walker:Show()
93 walker.phase = 0.0
94 walker.dots = {}
95 walker.points = {}
96 walker.origin = {}
97 walker.frame = self
98 walker.map_dodads = {}
99 walker.used_map_dodads = 0
101 function walker:OnUpdate(elapsed)
102 local out = 0
104 if QuestHelper_Pref.show_ants then
105 local points = self.points
107 self.phase = self.phase + elapsed * 0.66
108 while self.phase > 1 do self.phase = self.phase - 1 end
110 local w, h = WorldMapDetailFrame:GetWidth(), -WorldMapDetailFrame:GetHeight()
112 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
114 local last_x, last_y = self.frame.Astrolabe:TranslateWorldMapPosition(self.frame.c, self.frame.z, self.frame.x, self.frame.y, c, z) local remainder = self.phase
116 for i, pos in ipairs(points) do
117 local new_x, new_y = unpack(pos)
118 local x1, y1, x2, y2 = ClampLine(last_x, last_y, new_x, new_y)
119 last_x, last_y = new_x, new_y
121 if x1 then
122 local len = math.sqrt((x1-x2)*(x1-x2)*16/9+(y1-y2)*(y1-y2))
124 if len > 0.0001 then
125 local interval = .025/len
126 local p = remainder*interval
128 while p < 1 do
129 out = out + 1
130 local dot = self.dots[out]
131 if not dot then
132 dot = QuestHelper:CreateDotTexture(self)
133 dot:SetDrawLayer("BACKGROUND")
134 self.dots[out] = dot
137 dot:ClearAllPoints()
138 dot:SetPoint("CENTER", WorldMapDetailFrame, "TOPLEFT", x1*w*(1-p)+x2*w*p, y1*h*(1-p)+y2*h*p)
140 p = p + interval
143 remainder = (p-1)/interval
149 while #self.dots > out do
150 QuestHelper:ReleaseTexture(table.remove(self.dots))
154 function walker:RouteChanged()
155 if self.frame.Astrolabe.WorldMapVisible then
156 local points = self.points
157 local cur = self.frame.pos
159 while #points > 0 do self.frame:ReleaseTable(table.remove(points)) end
161 local travel_time = 0.0
163 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
165 if self.frame.target then
166 cur = self.frame.target
167 local t = self.frame:CreateTable()
168 t[1], t[2] = convertLocationToScreen(cur, c, z)
169 table.insert(points, t)
172 for i, obj in pairs(self.frame.route) do
173 local path, d = self.frame:ComputeRoute(cur, obj.pos)
175 pushPath(points, path, c, z)
177 travel_time = travel_time + d
178 obj.travel_time = travel_time
180 cur = obj.pos
182 local t = self.frame:CreateTable()
183 t[1], t[2] = convertLocationToScreen(cur, c, z)
185 table.insert(points, t)
188 if not self.frame.limbo_node then
189 for i = 1, #self.frame.route do
190 local dodad = self.map_dodads[i]
191 if not dodad then
192 self.map_dodads[i] = self.frame:CreateWorldMapDodad(self.frame.route[i], i)
193 else
194 self.map_dodads[i]:SetObjective(self.frame.route[i], i)
198 for i = #self.frame.route+1,self.used_map_dodads do
199 self.map_dodads[i]:SetObjective(nil, 0)
202 self.used_map_dodads = #self.frame.route
207 walker:SetScript("OnEvent", walker.RouteChanged)
208 walker:RegisterEvent("WORLD_MAP_UPDATE")
210 walker:SetScript("OnUpdate", walker.OnUpdate)
212 return walker
215 function QuestHelper:GetOverlapObjectives(obj)
216 local w, h = WorldMapDetailFrame:GetWidth(), WorldMapDetailFrame:GetHeight()
217 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
219 local list = self.overlap_list
221 if not list then
222 list = {}
223 self.overlap_list = list
224 else
225 while table.remove(list) do end
228 local cx, cy = GetCursorPosition()
230 local es = WorldMapDetailFrame:GetEffectiveScale()
231 local ies = 1/es
233 cx, cy = (cx-WorldMapDetailFrame:GetLeft()*es)*ies, (WorldMapDetailFrame:GetTop()*es-cy)*ies
235 local s = 10*QuestHelper_Pref.scale
237 if self.limbo_node then
238 local o = self.limbo_node
239 local x, y = o.pos[3], o.pos[4]
240 x, y = x / self.continent_scales_x[o.pos[1].c], y / self.continent_scales_y[o.pos[1].c]
241 x, y = self.Astrolabe:TranslateWorldMapPosition(o.pos[1].c, 0, x, y, c, z)
243 if x and y and x > 0 and y > 0 and x < 1 and y < 1 then
244 x, y = x*w, y*h
246 if cx >= x-s and cy >= y-s and cx <= x+s and cy <= y+s then
247 table.insert(list, o)
252 for i, o in ipairs(self.route) do
253 if o == obj then
254 table.insert(list, o)
255 else
256 local x, y = o.pos[3], o.pos[4]
257 x, y = x / self.continent_scales_x[o.pos[1].c], y / self.continent_scales_y[o.pos[1].c]
258 x, y = self.Astrolabe:TranslateWorldMapPosition(o.pos[1].c, 0, x, y, c, z)
260 if x and y and x > 0 and y > 0 and x < 1 and y < 1 then
261 x, y = x*w, y*h
263 if cx >= x-s and cy >= y-s and cx <= x+s and cy <= y+s then
264 table.insert(list, o)
270 table.sort(list, function(a, b) return (a.travel_time or 0) < (b.travel_time or 0) end)
272 return list
275 local prog_sort_table = {}
277 function QuestHelper:AppendObjectiveToTooltip(o)
278 local theme = self:GetColourTheme()
280 self.tooltip:AddLine(o:Reason(), unpack(theme.tooltip))
281 self.tooltip:GetPrevLines():SetFont("Fonts\\FRIZQT__.TTF", 14)
283 if o.progress then
284 for user, progress in pairs(o.progress) do
285 table.insert(prog_sort_table, user)
288 table.sort(prog_sort_table, function(a, b)
289 if o.progress[a][3] < o.progress[b][3] then
290 return true
291 elseif o.progress[a][3] == o.progress[b][3] then
292 return a < b
294 return false
295 end)
297 for i, u in ipairs(prog_sort_table) do
298 self.tooltip:AddDoubleLine(QHFormat("PEER_PROGRESS", u),
299 self:ProgressString(o.progress[u][1].."/"..o.progress[u][2],
300 o.progress[u][3]), unpack(theme.tooltip))
302 self.tooltip:GetPrevLines():SetFont("Fonts\\ARIALN.TTF", 13)
303 select(2, self.tooltip:GetPrevLines()):SetFont("Fonts\\ARIALN.TTF", 13)
306 while table.remove(prog_sort_table) do end
309 QuestHelper.tooltip:AddDoubleLine(QHText("TRAVEL_ESTIMATE"), QHFormat("TRAVEL_ESTIMATE_VALUE", o.travel_time or 0), unpack(theme.tooltip))
310 QuestHelper.tooltip:GetPrevLines():SetFont("Fonts\\ARIALN.TTF", 11)
311 select(2, QuestHelper.tooltip:GetPrevLines()):SetFont("Fonts\\ARIALN.TTF", 11)
314 function QuestHelper:CreateWorldMapDodad(objective, index)
315 local icon = CreateFrame("Button", nil, QuestHelper.map_overlay)
316 icon:SetFrameStrata("FULLSCREEN")
318 function icon:SetTooltip(list)
319 QuestHelper.tooltip:SetOwner(self, "ANCHOR_CURSOR")
320 QuestHelper.tooltip:ClearLines()
322 local first = true
324 for i, o in ipairs(list) do
325 if first then
326 first = false
327 else
328 QuestHelper.tooltip:AddLine("|c80ff0000 . . . . . .|r")
329 QuestHelper.tooltip:GetPrevLines():SetFont("Fonts\\ARIALN.TTF", 8)
332 QuestHelper:AppendObjectiveToTooltip(o)
335 QuestHelper.tooltip:Show()
338 function icon:SetObjective(objective, i)
339 self:SetHeight(20*QuestHelper_Pref.scale)
340 self:SetWidth(20*QuestHelper_Pref.scale)
342 if self.dot then
343 QuestHelper:ReleaseTexture(self.dot)
344 self.dot = nil
347 if self.bg then
348 QuestHelper:ReleaseTexture(self.bg)
349 self.bg = nil
352 if objective then
353 self.objective = objective
354 self.index = i
356 if i == 1 then
357 self.bg = QuestHelper:CreateIconTexture(self, 13)
358 else
359 self.bg = QuestHelper:CreateIconTexture(self, objective.icon_bg)
362 self.dot = QuestHelper:CreateIconTexture(self, objective.icon_id)
364 self.bg:SetDrawLayer("BACKGROUND")
365 self.bg:SetAllPoints()
366 self.dot:SetPoint("TOPLEFT", self, "TOPLEFT", 3*QuestHelper_Pref.scale, -3*QuestHelper_Pref.scale)
367 self.dot:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -3*QuestHelper_Pref.scale, 3*QuestHelper_Pref.scale)
369 QuestHelper.Astrolabe:PlaceIconOnWorldMap(WorldMapDetailFrame, self, convertLocation(objective.pos))
370 else
371 self.objective = nil
372 self:Hide()
376 function icon:SetGlow(list)
377 local w, h = WorldMapDetailFrame:GetWidth(), WorldMapDetailFrame:GetHeight()
378 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
379 local _, x_size, y_size = QuestHelper.Astrolabe:ComputeDistance(c, z, 0.25, 0.25, c, z, 0.75, 0.75)
381 x_size = math.max(25, 200 / x_size * w)
382 y_size = math.max(25, 200 / y_size * h)
384 local out = 1
385 for _, objective in ipairs(list) do
386 if objective.p then for _, list in pairs(objective.p) do
387 for _, p in ipairs(list) do
388 local x, y = p[3], p[4]
389 x, y = x / QuestHelper.continent_scales_x[p[1].c], y / QuestHelper.continent_scales_y[p[1].c]
390 x, y = QuestHelper.Astrolabe:TranslateWorldMapPosition(p[1].c, 0, x, y, c, z)
391 if x and y and x > 0 and y > 0 and x < 1 and y < 1 then
392 if not self.glow_list then
393 self.glow_list = QuestHelper:CreateTable()
396 tex = self.glow_list[out]
397 if not tex then
398 tex = QuestHelper:CreateGlowTexture(self)
399 table.insert(self.glow_list, tex)
401 out = out + 1
403 tex:SetPoint("CENTER", WorldMapDetailFrame, "TOPLEFT", x*w, -y*h)
404 tex:SetVertexColor(1,1,1,0)
405 tex:SetWidth(x_size)
406 tex:SetHeight(y_size)
407 tex:Show()
408 tex.max_alpha = 1/p[5]
410 end end
414 if self.glow_list then
415 for i = out,#self.glow_list do
416 QuestHelper:ReleaseTexture(table.remove(self.glow_list))
419 if #self.glow_list == 0 then
420 QuestHelper:ReleaseTable(self.glow_list)
421 self.glow_list = nil
426 icon.show_glow = false
427 icon.glow_pct = 0.0
428 icon.phase = 0.0
429 icon.old_count = 0
431 function icon:OnUpdate(elapsed)
432 self.phase = (self.phase + elapsed)%6.283185307179586476925286766559005768394338798750211641949889185
434 if self.old_count > 0 then
435 local list = QuestHelper:GetOverlapObjectives(self.objective)
436 if #list ~= self.old_count then
437 self:SetTooltip(list)
438 self.old_count = #list
439 self:SetGlow(list)
443 if self.show_glow then
444 self.glow_pct = math.min(1, self.glow_pct+elapsed*1.5)
445 else
446 self.glow_pct = math.max(0, self.glow_pct-elapsed*0.5)
448 if self.glow_pct == 0 then
449 if self.glow_list then
450 while #self.glow_list > 0 do
451 QuestHelper:ReleaseTexture(table.remove(self.glow_list))
453 QuestHelper:ReleaseTable(self.glow_list)
454 self.glow_list = nil
457 self:SetScript("OnUpdate", nil)
458 return
462 if self.glow_list then
463 local r, g, b = math.sin(self.phase)*0.25+0.75,
464 math.sin(self.phase+2.094395102393195492308428922186335256131446266250070547316629728)*0.25+0.75,
465 math.sin(self.phase+4.188790204786390984616857844372670512262892532500141094633259456)*0.25+0.75
467 for i, tex in ipairs(self.glow_list) do
468 tex:SetVertexColor(r, g, b, self.glow_pct*tex.max_alpha)
473 function icon:OnEnter()
474 local list = QuestHelper:GetOverlapObjectives(self.objective)
475 self:SetTooltip(list)
476 self.old_count = #list
478 icon.show_glow = true
480 self:SetGlow(list)
482 self:SetScript("OnUpdate", self.OnUpdate)
485 function icon:OnLeave()
486 QuestHelper.tooltip:Hide()
487 self.show_glow = false
488 self.old_count = 0
491 function icon:OnEvent(event)
492 if self.objective and self.objective.pos then
493 QuestHelper.Astrolabe:PlaceIconOnWorldMap(WorldMapDetailFrame, self, convertLocation(self.objective.pos))
494 else
495 self.objective = nil
496 self:Hide()
500 function icon:OnClick()
501 if self.objective then
502 local menu = QuestHelper:CreateMenu()
503 local list = QuestHelper:GetOverlapObjectives(self.objective)
504 local item
506 if #list > 1 then
507 QuestHelper:CreateMenuTitle(menu, "Objectives")
509 for i, o in ipairs(list) do
510 local submenu = QuestHelper:CreateMenu()
511 item = QuestHelper:CreateMenuItem(menu, o:Reason(true))
512 item:SetSubmenu(submenu)
513 item:AddTexture(QuestHelper:CreateIconTexture(item, o.icon_id), true)
514 QuestHelper:AddObjectiveOptionsToMenu(o, submenu)
516 else
517 QuestHelper:CreateMenuTitle(menu, self.objective:Reason(true))
518 QuestHelper:AddObjectiveOptionsToMenu(self.objective, menu)
521 menu:ShowAtCursor()
525 icon:SetScript("OnClick", icon.OnClick)
526 icon:SetScript("OnEnter", icon.OnEnter)
527 icon:SetScript("OnLeave", icon.OnLeave)
528 icon:SetScript("OnEvent", icon.OnEvent)
530 icon:RegisterForClicks("RightButtonUp")
532 icon:RegisterEvent("WORLD_MAP_UPDATE")
534 icon:SetObjective(objective, index)
535 return icon
538 local function QH_CartographerWaypoint_Cancel(self)
539 self.task = nil
541 if QuestHelper.cartographer_wp == self then
542 QuestHelper.cartographer_wp = nil
545 Waypoint.Cancel(self)
548 local function QH_CartographerWaypoint_ToString(self)
549 return self.task
552 function QuestHelper:HideCartographerWaypoint()
553 if self.cartographer_wp then
554 self.cartographer_wp:Cancel()
557 if self.old_cartographer_wp_data then
558 self:ReleaseTable(self.old_cartographer_wp_data)
559 self.old_cartographer_wp_data = nil
563 function QuestHelper:CreateMipmapDodad()
564 local icon = CreateFrame("Button", nil, Minimap)
565 icon:Hide()
566 icon.recalc_timeout = 0
568 icon.arrow = CreateFrame("Model", nil, icon)
569 icon.arrow:SetHeight(140.8)
570 icon.arrow:SetWidth(140.8)
571 icon.arrow:SetPoint("CENTER", Minimap, "CENTER", 0, 0)
572 icon.arrow:SetModel("Interface\\Minimap\\Rotating-MinimapArrow.mdx")
573 icon.arrow:Hide()
575 icon.phase = 0
576 icon.target = {0, 0, 0, 0}
577 icon.icon_id = 7
579 icon.bg = QuestHelper:CreateIconTexture(icon, 16)
580 icon.bg:SetDrawLayer("BACKGROUND")
581 icon.bg:SetAllPoints()
583 function icon:NextObjective()
584 if QuestHelper.limbo_node then
585 -- If an objective is in limbo, don't try to figure out the next objective, because the node in limbo isn't it.
586 return self.objective.pos and self.objective or nil
589 for i, o in ipairs(QuestHelper.route) do
590 if not QuestHelper.to_remove[o] and o.pos then
591 return o
595 return nil
598 function icon:OnUpdate(elapsed)
599 if self.objective then
600 if not self.objective.pos then
601 self.objective = self:NextObjective()
602 if not self.objective then
603 self:Hide()
604 return
608 self:Show()
610 if self.recalc_timeout == 0 then
611 self.recalc_timeout = 50
613 self.objective = self:NextObjective()
615 if not self.objective then
616 self:Hide()
617 return
620 local path, travel_time = QuestHelper:ComputeRoute(QuestHelper.pos, self.objective.pos)
621 local t = self.target
622 local id = self.objective.icon_id
623 t[1], t[2], t[3], t[4] = convertLocation(self.objective.pos)
624 t[5] = nil
626 self.objective.travel_time = travel_time
628 while path do
629 if path.g > 10.0 then
630 id = 8
631 t[1] = path.c
632 t[2] = 0
633 t[3] = path.x / QuestHelper.continent_scales_x[path.c]
634 t[4] = path.y / QuestHelper.continent_scales_y[path.c]
635 t[5] = path.name or "waypoint"
637 path = path.p
640 if not self.dot or id ~= self.icon_id then
641 self.icon_id = id
642 if self.dot then QuestHelper:ReleaseTexture(self.dot) end
643 self.dot = QuestHelper:CreateIconTexture(self, self.icon_id)
644 self.dot:SetPoint("TOPLEFT", icon, "TOPLEFT", 2, -2)
645 self.dot:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -2, 2)
648 if QuestHelper_Pref.cart_wp and Cartographer_Waypoints and Waypoint then
649 if UnitIsDeadOrGhost("player") then
650 QuestHelper:HideCartographerWaypoint()
651 else
652 local x, y, z
654 if QuestHelper.c == t[1] then
655 -- Translate the position to the zone the player is standing in.
656 x, y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], QuestHelper.c, QuestHelper.z)
657 z = QuestHelper_NameLookup[QuestHelper.i]
658 else
659 -- Try to find the nearest zone on the continent the objective is in.
660 local index, distsqr
661 for z, i in pairs(QuestHelper_IndexLookup[t[1]]) do
662 local _x, _y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], t[1], z)
663 local d = (_x-0.5)*(_x-0.5)+(_y-0.5)*(_y-0.5)
664 if not index or d < distsqr then
665 index, distsqr, x, y = i, d, _x, _y
668 z = QuestHelper_NameLookup[index]
671 z = Rock("LibBabble-Zone-3.0"):GetReverseLookupTable()[z]
673 if QuestHelper.cartographer_wp and (QuestHelper.cartographer_wp.x ~= x or
674 QuestHelper.cartographer_wp.y ~= y or
675 QuestHelper.cartographer_wp.Zone ~= z) then
676 QuestHelper.cartographer_wp:Cancel()
679 local owp = QuestHelper.old_cartographer_wp_data
681 if not owp then
682 owp = QuestHelper:CreateTable()
683 QuestHelper.old_cartographer_wp_data = owp
686 if not QuestHelper.cartographer_wp and (not owp or owp.x ~= x or owp.y ~= y or owp.z ~= z) then
687 local wp = Waypoint:new()
688 wp.Cancel = QH_CartographerWaypoint_Cancel
689 wp.ToString = QH_CartographerWaypoint_ToString
691 wp.x, wp.y, wp.Zone, wp.task = x, y, z, (t[5] and (QHFormat("WAYPOINT_REASON", t[5]).."\n"..self.objective:Reason(true))) or self.objective:Reason(true)
692 owp.x, owp.y, owp.z = wp.x, wp.y, wp.Zone
693 Cartographer_Waypoints:AddWaypoint(wp)
694 QuestHelper.cartographer_wp = wp
697 elseif QuestHelper.cartographer_wp then
698 QuestHelper:HideCartographerWaypoint()
701 QuestHelper.Astrolabe:PlaceIconOnMinimap(self, unpack(self.target))
702 else
703 self.recalc_timeout = self.recalc_timeout - 1
706 local edge = QuestHelper.Astrolabe:IsIconOnEdge(self)
708 if edge then
709 self.arrow:Show()
710 self.dot:Hide()
711 self.bg:Hide()
712 else
713 self.arrow:Hide()
714 self.dot:Show()
715 self.bg:Show()
718 if edge then
719 local angle = QuestHelper.Astrolabe:GetDirectionToIcon(self)
720 if GetCVar("rotateMinimap") == "1" then
721 angle = angle + MiniMapCompassRing:GetFacing()
724 self.arrow:SetFacing(angle)
725 self.arrow:SetPosition(ofs * (137 / 140) - radius * math.sin(angle),
726 ofs + radius * math.cos(angle), 0);
728 if self.phase > 6.283185307179586476925 then
729 self.phase = self.phase-6.283185307179586476925+elapsed*3.5
730 else
731 self.phase = self.phase+elapsed*3.5
733 self.arrow:SetModelScale(0.600000023841879+0.1*math.sin(self.phase))
735 else
736 self:Hide()
740 function icon:SetObjective(objective)
741 self:SetHeight(20*QuestHelper_Pref.scale)
742 self:SetWidth(20*QuestHelper_Pref.scale)
744 if objective ~= self.objective then
745 if objective and not QuestHelper_Pref.hide then
746 self:Show()
747 else
748 QuestHelper:HideCartographerWaypoint()
749 self:Hide()
752 self.objective = objective
753 self.recalc_timeout = 0
757 function icon:OnEnter()
758 if self.objective then
759 QuestHelper.tooltip:SetOwner(self, "ANCHOR_CURSOR")
760 QuestHelper.tooltip:ClearLines()
762 if self.target[5] then
763 QuestHelper.tooltip:AddLine(QHFormat("WAYPOINT_REASON", self.target[5]), unpack(QuestHelper:GetColourTheme().tooltip))
764 QuestHelper.tooltip:GetPrevLines():SetFont("Fonts\\FRIZQT__.TTF", 14)
767 QuestHelper:AppendObjectiveToTooltip(self.objective)
768 QuestHelper.tooltip:Show()
772 function icon:OnLeave()
773 QuestHelper.tooltip:Hide()
776 function icon:OnClick()
777 if self.objective then
778 local menu = QuestHelper:CreateMenu()
779 QuestHelper:CreateMenuTitle(menu, self.objective:Reason(true))
780 QuestHelper:AddObjectiveOptionsToMenu(self.objective, menu)
781 menu:ShowAtCursor()
785 function icon:OnEvent()
786 if self.objective and self.objective.pos then
787 self:Show()
788 else
789 self:Hide()
793 icon:SetScript("OnUpdate", icon.OnUpdate)
794 icon:SetScript("OnEnter", icon.OnEnter)
795 icon:SetScript("OnLeave", icon.OnLeave)
796 icon:SetScript("OnEvent", icon.OnEvent)
797 icon:SetScript("OnClick", icon.OnClick)
799 icon:RegisterForClicks("RightButtonUp")
800 icon:RegisterEvent("PLAYER_ENTERING_WORLD")
802 return icon