Made purge command reset the locale of the saved data, and added files for 0.44 release.
[QuestHelper.git] / dodads.lua
bloba84f41bedce632f9397fa48cfaf3504018d67837
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(QuestHelper.font.serif, 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(QuestHelper.font.sans, 13)
303 select(2, self.tooltip:GetPrevLines()):SetFont(QuestHelper.font.sans, 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(QuestHelper.font.sans, 11)
311 select(2, QuestHelper.tooltip:GetPrevLines()):SetFont(QuestHelper.font.sans, 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(QuestHelper.font.sans, 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 -- if it's the very next objective, give it the green background
358 self.bg = QuestHelper:CreateIconTexture(self, 13)
359 elseif not objective:CouldBeFirst() then
360 -- if there are still prerequisites, make it grey
361 self.bg = QuestHelper:CreateIconTexture(self, 16)
362 else
363 -- otherwise give it the background selected by the objective
364 self.bg = QuestHelper:CreateIconTexture(self, objective.icon_bg)
367 self.dot = QuestHelper:CreateIconTexture(self, objective.icon_id)
369 self.bg:SetDrawLayer("BACKGROUND")
370 self.bg:SetAllPoints()
371 self.dot:SetPoint("TOPLEFT", self, "TOPLEFT", 3*QuestHelper_Pref.scale, -3*QuestHelper_Pref.scale)
372 self.dot:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -3*QuestHelper_Pref.scale, 3*QuestHelper_Pref.scale)
374 QuestHelper.Astrolabe:PlaceIconOnWorldMap(WorldMapDetailFrame, self, convertLocation(objective.pos))
375 else
376 self.objective = nil
377 self:Hide()
381 function icon:SetGlow(list)
382 local w, h = WorldMapDetailFrame:GetWidth(), WorldMapDetailFrame:GetHeight()
383 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
384 local _, x_size, y_size = QuestHelper.Astrolabe:ComputeDistance(c, z, 0.25, 0.25, c, z, 0.75, 0.75)
386 x_size = math.max(25, 200 / x_size * w)
387 y_size = math.max(25, 200 / y_size * h)
389 local out = 1
390 for _, objective in ipairs(list) do
391 if objective.p then for _, list in pairs(objective.p) do
392 for _, p in ipairs(list) do
393 local x, y = p[3], p[4]
394 x, y = x / QuestHelper.continent_scales_x[p[1].c], y / QuestHelper.continent_scales_y[p[1].c]
395 x, y = QuestHelper.Astrolabe:TranslateWorldMapPosition(p[1].c, 0, x, y, c, z)
396 if x and y and x > 0 and y > 0 and x < 1 and y < 1 then
397 if not self.glow_list then
398 self.glow_list = QuestHelper:CreateTable()
401 tex = self.glow_list[out]
402 if not tex then
403 tex = QuestHelper:CreateGlowTexture(self)
404 table.insert(self.glow_list, tex)
406 out = out + 1
408 tex:SetPoint("CENTER", WorldMapDetailFrame, "TOPLEFT", x*w, -y*h)
409 tex:SetVertexColor(1,1,1,0)
410 tex:SetWidth(x_size)
411 tex:SetHeight(y_size)
412 tex:Show()
413 tex.max_alpha = 1/p[5]
415 end end
419 if self.glow_list then
420 for i = out,#self.glow_list do
421 QuestHelper:ReleaseTexture(table.remove(self.glow_list))
424 if #self.glow_list == 0 then
425 QuestHelper:ReleaseTable(self.glow_list)
426 self.glow_list = nil
431 icon.show_glow = false
432 icon.glow_pct = 0.0
433 icon.phase = 0.0
434 icon.old_count = 0
436 function icon:OnUpdate(elapsed)
437 self.phase = (self.phase + elapsed)%6.283185307179586476925286766559005768394338798750211641949889185
439 if self.old_count > 0 then
440 local list = QuestHelper:GetOverlapObjectives(self.objective)
441 if #list ~= self.old_count then
442 self:SetTooltip(list)
443 self.old_count = #list
444 self:SetGlow(list)
448 if self.show_glow then
449 self.glow_pct = math.min(1, self.glow_pct+elapsed*1.5)
450 else
451 self.glow_pct = math.max(0, self.glow_pct-elapsed*0.5)
453 if self.glow_pct == 0 then
454 if self.glow_list then
455 while #self.glow_list > 0 do
456 QuestHelper:ReleaseTexture(table.remove(self.glow_list))
458 QuestHelper:ReleaseTable(self.glow_list)
459 self.glow_list = nil
462 self:SetScript("OnUpdate", nil)
463 return
467 if self.glow_list then
468 local r, g, b = math.sin(self.phase)*0.25+0.75,
469 math.sin(self.phase+2.094395102393195492308428922186335256131446266250070547316629728)*0.25+0.75,
470 math.sin(self.phase+4.188790204786390984616857844372670512262892532500141094633259456)*0.25+0.75
472 for i, tex in ipairs(self.glow_list) do
473 tex:SetVertexColor(r, g, b, self.glow_pct*tex.max_alpha)
478 function icon:OnEnter()
479 local list = QuestHelper:GetOverlapObjectives(self.objective)
480 self:SetTooltip(list)
481 self.old_count = #list
483 icon.show_glow = true
485 self:SetGlow(list)
487 self:SetScript("OnUpdate", self.OnUpdate)
490 function icon:OnLeave()
491 QuestHelper.tooltip:Hide()
492 self.show_glow = false
493 self.old_count = 0
496 function icon:OnEvent(event)
497 if self.objective and self.objective.pos then
498 QuestHelper.Astrolabe:PlaceIconOnWorldMap(WorldMapDetailFrame, self, convertLocation(self.objective.pos))
499 else
500 self.objective = nil
501 self:Hide()
505 function icon:OnClick()
506 if self.objective then
507 local menu = QuestHelper:CreateMenu()
508 local list = QuestHelper:GetOverlapObjectives(self.objective)
509 local item
511 if #list > 1 then
512 QuestHelper:CreateMenuTitle(menu, "Objectives")
514 for i, o in ipairs(list) do
515 local submenu = QuestHelper:CreateMenu()
516 item = QuestHelper:CreateMenuItem(menu, o:Reason(true))
517 item:SetSubmenu(submenu)
518 item:AddTexture(QuestHelper:CreateIconTexture(item, o.icon_id), true)
519 QuestHelper:AddObjectiveOptionsToMenu(o, submenu)
521 else
522 QuestHelper:CreateMenuTitle(menu, self.objective:Reason(true))
523 QuestHelper:AddObjectiveOptionsToMenu(self.objective, menu)
526 menu:ShowAtCursor()
530 icon:SetScript("OnClick", icon.OnClick)
531 icon:SetScript("OnEnter", icon.OnEnter)
532 icon:SetScript("OnLeave", icon.OnLeave)
533 icon:SetScript("OnEvent", icon.OnEvent)
535 icon:RegisterForClicks("RightButtonUp")
537 icon:RegisterEvent("WORLD_MAP_UPDATE")
539 icon:SetObjective(objective, index)
540 return icon
543 local function QH_CartographerWaypoint_Cancel(self)
544 self.task = nil
546 if QuestHelper.cartographer_wp == self then
547 QuestHelper.cartographer_wp = nil
550 Waypoint.Cancel(self)
553 local function QH_CartographerWaypoint_ToString(self)
554 return self.task
557 function QuestHelper:HideCartographerWaypoint()
558 if self.cartographer_wp then
559 self.cartographer_wp:Cancel()
562 if self.old_cartographer_wp_data then
563 self:ReleaseTable(self.old_cartographer_wp_data)
564 self.old_cartographer_wp_data = nil
568 function QuestHelper:CreateMipmapDodad()
569 local icon = CreateFrame("Button", nil, Minimap)
570 icon:Hide()
571 icon.recalc_timeout = 0
573 icon.arrow = CreateFrame("Model", nil, icon)
574 icon.arrow:SetHeight(140.8)
575 icon.arrow:SetWidth(140.8)
576 icon.arrow:SetPoint("CENTER", Minimap, "CENTER", 0, 0)
577 icon.arrow:SetModel("Interface\\Minimap\\Rotating-MinimapArrow.mdx")
578 icon.arrow:Hide()
580 icon.phase = 0
581 icon.target = {0, 0, 0, 0}
582 icon.icon_id = 7
584 icon.bg = QuestHelper:CreateIconTexture(icon, 16)
585 icon.bg:SetDrawLayer("BACKGROUND")
586 icon.bg:SetAllPoints()
588 function icon:NextObjective()
589 if QuestHelper.limbo_node then
590 -- If an objective is in limbo, don't try to figure out the next objective, because the node in limbo isn't it.
591 return self.objective.pos and self.objective or nil
594 for i, o in ipairs(QuestHelper.route) do
595 if not QuestHelper.to_remove[o] and o.pos then
596 return o
600 return nil
603 function icon:OnUpdate(elapsed)
604 if self.objective then
605 if not self.objective.pos then
606 self.objective = self:NextObjective()
607 if not self.objective then
608 self:Hide()
609 return
613 self:Show()
615 if self.recalc_timeout == 0 then
616 self.recalc_timeout = 50
618 self.objective = self:NextObjective()
620 if not self.objective then
621 self:Hide()
622 return
625 local path, travel_time = QuestHelper:ComputeRoute(QuestHelper.pos, self.objective.pos)
626 local t = self.target
627 local id = self.objective.icon_id
628 t[1], t[2], t[3], t[4] = convertLocation(self.objective.pos)
629 t[5] = nil
631 self.objective.travel_time = travel_time
633 while path do
634 if path.g > 10.0 then
635 id = 8
636 t[1] = path.c
637 t[2] = 0
638 t[3] = path.x / QuestHelper.continent_scales_x[path.c]
639 t[4] = path.y / QuestHelper.continent_scales_y[path.c]
640 t[5] = path.name or "waypoint"
642 path = path.p
645 if not self.dot or id ~= self.icon_id then
646 self.icon_id = id
647 if self.dot then QuestHelper:ReleaseTexture(self.dot) end
648 self.dot = QuestHelper:CreateIconTexture(self, self.icon_id)
649 self.dot:SetPoint("TOPLEFT", icon, "TOPLEFT", 2, -2)
650 self.dot:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -2, 2)
653 if QuestHelper_Pref.cart_wp and Cartographer_Waypoints and Waypoint then
654 if UnitIsDeadOrGhost("player") then
655 QuestHelper:HideCartographerWaypoint()
656 else
657 local x, y, z
659 if QuestHelper.c == t[1] then
660 -- Translate the position to the zone the player is standing in.
661 x, y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], QuestHelper.c, QuestHelper.z)
662 z = QuestHelper_NameLookup[QuestHelper.i]
663 else
664 -- Try to find the nearest zone on the continent the objective is in.
665 local index, distsqr
666 for z, i in pairs(QuestHelper_IndexLookup[t[1]]) do
667 local _x, _y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], t[1], z)
668 local d = (_x-0.5)*(_x-0.5)+(_y-0.5)*(_y-0.5)
669 if not index or d < distsqr then
670 index, distsqr, x, y = i, d, _x, _y
673 z = QuestHelper_NameLookup[index]
676 if Rock then
677 local LibBabble = Rock("LibBabble-Zone-3.0", false, true)
678 if LibBabble then
679 z = LibBabble:GetReverseLookupTable()[z]
683 if QuestHelper.cartographer_wp and (QuestHelper.cartographer_wp.x ~= x or
684 QuestHelper.cartographer_wp.y ~= y or
685 QuestHelper.cartographer_wp.Zone ~= z) then
686 QuestHelper.cartographer_wp:Cancel()
689 local owp = QuestHelper.old_cartographer_wp_data
691 if not owp then
692 owp = QuestHelper:CreateTable()
693 QuestHelper.old_cartographer_wp_data = owp
696 if not QuestHelper.cartographer_wp and (not owp or owp.x ~= x or owp.y ~= y or owp.z ~= z) then
697 local wp = Waypoint:new()
698 wp.Cancel = QH_CartographerWaypoint_Cancel
699 wp.ToString = QH_CartographerWaypoint_ToString
701 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)
702 owp.x, owp.y, owp.z = wp.x, wp.y, wp.Zone
703 Cartographer_Waypoints:AddWaypoint(wp)
704 QuestHelper.cartographer_wp = wp
707 elseif QuestHelper.cartographer_wp then
708 QuestHelper:HideCartographerWaypoint()
711 QuestHelper.Astrolabe:PlaceIconOnMinimap(self, unpack(self.target))
712 else
713 self.recalc_timeout = self.recalc_timeout - 1
716 local edge = QuestHelper.Astrolabe:IsIconOnEdge(self)
718 if edge then
719 self.arrow:Show()
720 self.dot:Hide()
721 self.bg:Hide()
722 else
723 self.arrow:Hide()
724 self.dot:Show()
725 self.bg:Show()
728 if edge then
729 local angle = QuestHelper.Astrolabe:GetDirectionToIcon(self)
730 if GetCVar("rotateMinimap") == "1" then
731 angle = angle + MiniMapCompassRing:GetFacing()
734 self.arrow:SetFacing(angle)
735 self.arrow:SetPosition(ofs * (137 / 140) - radius * math.sin(angle),
736 ofs + radius * math.cos(angle), 0);
738 if self.phase > 6.283185307179586476925 then
739 self.phase = self.phase-6.283185307179586476925+elapsed*3.5
740 else
741 self.phase = self.phase+elapsed*3.5
743 self.arrow:SetModelScale(0.600000023841879+0.1*math.sin(self.phase))
745 else
746 self:Hide()
750 function icon:SetObjective(objective)
751 self:SetHeight(20*QuestHelper_Pref.scale)
752 self:SetWidth(20*QuestHelper_Pref.scale)
754 if objective ~= self.objective then
755 if objective and not QuestHelper_Pref.hide then
756 self:Show()
757 else
758 QuestHelper:HideCartographerWaypoint()
759 self:Hide()
762 self.objective = objective
763 self.recalc_timeout = 0
767 function icon:OnEnter()
768 if self.objective then
769 QuestHelper.tooltip:SetOwner(self, "ANCHOR_CURSOR")
770 QuestHelper.tooltip:ClearLines()
772 if self.target[5] then
773 QuestHelper.tooltip:AddLine(QHFormat("WAYPOINT_REASON", self.target[5]), unpack(QuestHelper:GetColourTheme().tooltip))
774 QuestHelper.tooltip:GetPrevLines():SetFont(QuestHelper.font.serif, 14)
777 QuestHelper:AppendObjectiveToTooltip(self.objective)
778 QuestHelper.tooltip:Show()
782 function icon:OnLeave()
783 QuestHelper.tooltip:Hide()
786 function icon:OnClick()
787 if self.objective then
788 local menu = QuestHelper:CreateMenu()
789 QuestHelper:CreateMenuTitle(menu, self.objective:Reason(true))
790 QuestHelper:AddObjectiveOptionsToMenu(self.objective, menu)
791 menu:ShowAtCursor()
795 function icon:OnEvent()
796 if self.objective and self.objective.pos then
797 self:Show()
798 else
799 self:Hide()
803 icon:SetScript("OnUpdate", icon.OnUpdate)
804 icon:SetScript("OnEnter", icon.OnEnter)
805 icon:SetScript("OnLeave", icon.OnLeave)
806 icon:SetScript("OnEvent", icon.OnEvent)
807 icon:SetScript("OnClick", icon.OnClick)
809 icon:RegisterForClicks("RightButtonUp")
810 icon:RegisterEvent("PLAYER_ENTERING_WORLD")
812 return icon