Displays help using the same code used to display the change log.
[QuestHelper.git] / dodads.lua
blobb3f0237d40a449d6bde1a1618749c8ab33969019
1 QuestHelper_File["dodads.lua"] = "Development Version"
3 local ofs = 0.000723339 * (GetScreenHeight()/GetScreenWidth() + 1/3) * 70.4;
4 local radius = ofs / 1.166666666666667;
6 local function convertLocation(p)
7 local c, x, y = p[1].c, p[3], p[4]
8 x, y = x/QuestHelper.continent_scales_x[c], y/QuestHelper.continent_scales_y[c]
9 return c, 0, x, y
10 end
12 local function convertLocationToScreen(p, c, z)
13 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)
14 end
16 local function convertNodeToScreen(n, c, z)
17 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)
18 end
20 QuestHelper.map_overlay = CreateFrame("FRAME", nil, WorldMapButton)
21 QuestHelper.map_overlay:SetFrameLevel(WorldMapButton:GetFrameLevel()+1)
22 QuestHelper.map_overlay:SetAllPoints()
23 QuestHelper.map_overlay:SetFrameStrata("FULLSCREEN")
25 local function ClampLine(x1, y1, x2, y2)
26 if x1 and y1 and x2 and y2 then
27 local x_div, y_div = (x2-x1), (y2-y1)
28 local x_0 = y1-x1/x_div*y_div
29 local x_1 = y1+(1-x1)/x_div*y_div
30 local y_0 = x1-y1/y_div*x_div
31 local y_1 = x1+(1-y1)/y_div*x_div
33 if y1 < 0 then
34 x1 = y_0
35 y1 = 0
36 end
38 if y2 < 0 then
39 x2 = y_0
40 y2 = 0
41 end
43 if y1 > 1 then
44 x1 = y_1
45 y1 = 1
46 end
48 if y2 > 1 then
49 x2 = y_1
50 y2 = 1
51 end
53 if x1 < 0 then
54 y1 = x_0
55 x1 = 0
56 end
58 if x2 < 0 then
59 y2 = x_0
60 x2 = 0
61 end
63 if x1 > 1 then
64 y1 = x_1
65 x1 = 1
66 end
68 if x2 > 1 then
69 y2 = x_1
70 x2 = 1
71 end
73 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
74 return x1, y1, x2, y2
75 end
76 end
77 end
79 local function pushPath(list, path, c, z)
80 if path then
81 pushPath(list, path.p, c, z)
82 local t = QuestHelper:CreateTable()
83 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)
84 table.insert(list, t)
85 end
86 end
88 function QuestHelper:CreateWorldMapWalker()
89 local walker = CreateFrame("Button", nil, QuestHelper.map_overlay)
90 walker:SetWidth(0)
91 walker:SetHeight(0)
92 walker:SetPoint("CENTER", QuestHelper.map_overlay, "TOPLEFT", 0, 0)
93 walker:Show()
95 walker.phase = 0.0
96 walker.dots = {}
97 walker.points = {}
98 walker.origin = {}
99 walker.frame = self
100 walker.map_dodads = {}
101 walker.used_map_dodads = 0
103 function walker:OnUpdate(elapsed)
104 local out = 0
106 if QuestHelper_Pref.show_ants then
107 local points = self.points
109 self.phase = self.phase + elapsed * 0.66
110 while self.phase > 1 do self.phase = self.phase - 1 end
112 local w, h = QuestHelper.map_overlay:GetWidth(), -QuestHelper.map_overlay:GetHeight()
114 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
116 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
118 for i, pos in ipairs(points) do
119 local new_x, new_y = unpack(pos)
120 local x1, y1, x2, y2 = ClampLine(last_x, last_y, new_x, new_y)
121 last_x, last_y = new_x, new_y
123 if x1 then
124 local len = math.sqrt((x1-x2)*(x1-x2)*16/9+(y1-y2)*(y1-y2))
126 if len > 0.0001 then
127 local interval = .025/len
128 local p = remainder*interval
130 while p < 1 do
131 out = out + 1
132 local dot = self.dots[out]
133 if not dot then
134 dot = QuestHelper:CreateDotTexture(self)
135 dot:SetDrawLayer("BACKGROUND")
136 self.dots[out] = dot
139 dot:ClearAllPoints()
140 dot:SetPoint("CENTER", QuestHelper.map_overlay, "TOPLEFT", x1*w*(1-p)+x2*w*p, y1*h*(1-p)+y2*h*p)
142 p = p + interval
145 remainder = (p-1)/interval
151 while #self.dots > out do
152 QuestHelper:ReleaseTexture(table.remove(self.dots))
156 function walker:RouteChanged()
157 if self.frame.Astrolabe.WorldMapVisible then
158 local points = self.points
159 local cur = self.frame.pos
161 while #points > 0 do self.frame:ReleaseTable(table.remove(points)) end
163 local travel_time = 0.0
165 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
167 if self.frame.target then
168 cur = self.frame.target
169 local t = self.frame:CreateTable()
170 t[1], t[2] = convertLocationToScreen(cur, c, z)
171 table.insert(points, t)
174 for i, obj in pairs(self.frame.route) do
175 local path, d = self.frame:ComputeRoute(cur, obj.pos)
177 pushPath(points, path, c, z)
179 travel_time = travel_time + d
180 obj.travel_time = travel_time
182 cur = obj.pos
184 local t = self.frame:CreateTable()
185 t[1], t[2] = convertLocationToScreen(cur, c, z)
187 table.insert(points, t)
190 for i = 1, #self.frame.route do
191 local dodad = self.map_dodads[i]
192 if not dodad then
193 self.map_dodads[i] = self.frame:CreateWorldMapDodad(self.frame.route[i], i)
194 else
195 self.map_dodads[i]:SetObjective(self.frame.route[i], i)
199 for i = #self.frame.route+1,self.used_map_dodads do
200 self.map_dodads[i]:SetObjective(nil, 0)
203 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 = self.map_overlay:GetWidth(), self.map_overlay: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 = QuestHelper.map_overlay:GetEffectiveScale()
231 local ies = 1/es
233 cx, cy = (cx-self.map_overlay:GetLeft()*es)*ies, (self.map_overlay:GetTop()*es-cy)*ies
235 local s = 10*QuestHelper_Pref.scale
237 for i, o in ipairs(self.route) do
238 if o == obj then
239 table.insert(list, o)
240 else
241 local x, y = o.pos[3], o.pos[4]
242 x, y = x / self.continent_scales_x[o.pos[1].c], y / self.continent_scales_y[o.pos[1].c]
243 x, y = self.Astrolabe:TranslateWorldMapPosition(o.pos[1].c, 0, x, y, c, z)
245 if x and y and x > 0 and y > 0 and x < 1 and y < 1 then
246 x, y = x*w, y*h
248 if cx >= x-s and cy >= y-s and cx <= x+s and cy <= y+s then
249 table.insert(list, o)
255 table.sort(list, function(a, b) return (a.travel_time or 0) < (b.travel_time or 0) end)
257 return list
260 local prog_sort_table = {}
262 function QuestHelper:AppendObjectiveProgressToTooltip(o, tooltip, font, depth)
263 if o.progress then
264 local theme = self:GetColourTheme()
266 local indent = (" "):rep(depth or 0)
268 for user, progress in pairs(o.progress) do
269 table.insert(prog_sort_table, user)
272 table.sort(prog_sort_table, function(a, b)
273 if o.progress[a][3] < o.progress[b][3] then
274 return true
275 elseif o.progress[a][3] == o.progress[b][3] then
276 return a < b
278 return false
279 end)
281 for i, u in ipairs(prog_sort_table) do
282 tooltip:AddDoubleLine(indent..QHFormat("PEER_PROGRESS", u),
283 self:ProgressString(o.progress[u][1].."/"..o.progress[u][2],
284 o.progress[u][3]), unpack(theme.tooltip))
286 if font then
287 local last, name = tooltip:NumLines(), tooltip:GetName()
288 local left, right = _G[name.."TextLeft"..last], _G[name.."TextRight"..last]
290 left:SetFont(font, 13)
291 right:SetFont(font, 13)
295 while table.remove(prog_sort_table) do end
299 function QuestHelper:AppendObjectiveToTooltip(o)
300 local theme = self:GetColourTheme()
302 self.tooltip:AddLine(o:Reason(), unpack(theme.tooltip))
303 self.tooltip:GetPrevLines():SetFont(self.font.serif, 14)
305 self:AppendObjectiveProgressToTooltip(o, self.tooltip, QuestHelper.font.sans)
307 self.tooltip:AddDoubleLine(QHText("TRAVEL_ESTIMATE"), QHFormat("TRAVEL_ESTIMATE_VALUE", o.travel_time or 0), unpack(theme.tooltip))
308 self.tooltip:GetPrevLines():SetFont(self.font.sans, 11)
309 select(2, self.tooltip:GetPrevLines()):SetFont(self.font.sans, 11)
312 function QuestHelper:CreateWorldMapDodad(objective, index)
313 local icon = CreateFrame("Button", nil, QuestHelper.map_overlay)
314 icon:SetFrameStrata("FULLSCREEN")
316 function icon:SetTooltip(list)
317 QuestHelper.tooltip:SetOwner(self, "ANCHOR_CURSOR")
318 QuestHelper.tooltip:ClearLines()
320 local first = true
322 for i, o in ipairs(list) do
323 if first then
324 first = false
325 else
326 QuestHelper.tooltip:AddLine("|c80ff0000 . . . . . .|r")
327 QuestHelper.tooltip:GetPrevLines():SetFont(QuestHelper.font.sans, 8)
330 QuestHelper:AppendObjectiveToTooltip(o)
333 QuestHelper.tooltip:Show()
336 function icon:SetObjective(objective, i)
337 self:SetHeight(20*QuestHelper_Pref.scale)
338 self:SetWidth(20*QuestHelper_Pref.scale)
340 if self.dot then
341 QuestHelper:ReleaseTexture(self.dot)
342 self.dot = nil
345 if self.bg then
346 QuestHelper:ReleaseTexture(self.bg)
347 self.bg = nil
350 if objective then
351 self.objective = objective
352 self.index = i
354 if i == 1 then
355 -- if it's the very next objective, give it the green background
356 self.bg = QuestHelper:CreateIconTexture(self, 13)
357 elseif objective.filter_blocked then
358 -- if there are still prerequisites, make it grey
359 -- filter_blocked is updated by [Add|Remove]ObjectiveWatch and ObjectiveObjectDependsOn,
360 -- and will be true if there are other objectives that need to be completed before this one.
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(QuestHelper.map_overlay, self, convertLocation(objective.pos))
375 else
376 self.objective = nil
377 self:Hide()
381 function icon:SetGlow(list)
382 local w, h = QuestHelper.map_overlay:GetWidth(), QuestHelper.map_overlay: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", QuestHelper.map_overlay, "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 -- You know, these numbers are harmonics of pi. Would SETI detected them, or would they just be seen as noise?
469 -- I'd vote for the later.
471 -- Pi - circumference over diameter - when was the last time you actually cared about diameters in math?
473 -- Pretty much everything in computer geometry depends on the pythagorean theorem, which you can use for
474 -- circles, spheres, and hyper-spheres, if you use radius.
476 -- It's even the basis of special relativity, with time being multiplied by c so that you get a distance
477 -- that you can use with the spatial dimensions. We're all in agreement that space traveling aliens are
478 -- going to know about relativity, right?
480 -- And if you ever do trig, a full circle would be exactly (circumference over radius) radians instead of
481 -- (circumference over diameter)*2 radians.
483 -- Obviously aliens are much more likely to prefer 6.283185307179586... as constant than our pi.
485 -- Important update: I just noticed that large factorials can be approximated using (2*pi*n)^.5*(n/e)^n
486 -- There's that 2 times pi thing again.
487 local r, g, b = math.sin(self.phase)*0.25+0.75,
488 math.sin(self.phase+2.094395102393195492308428922186335256131446266250070547316629728)*0.25+0.75,
489 math.sin(self.phase+4.188790204786390984616857844372670512262892532500141094633259456)*0.25+0.75
491 for i, tex in ipairs(self.glow_list) do
492 tex:SetVertexColor(r, g, b, self.glow_pct*tex.max_alpha)
497 function icon:OnEnter()
498 local list = QuestHelper:GetOverlapObjectives(self.objective)
499 self:SetTooltip(list)
500 self.old_count = #list
502 icon.show_glow = true
504 self:SetGlow(list)
506 self:SetScript("OnUpdate", self.OnUpdate)
509 function icon:OnLeave()
510 QuestHelper.tooltip:Hide()
511 self.show_glow = false
512 self.old_count = 0
515 function icon:OnEvent(event)
516 if self.objective and self.objective.pos then
517 QuestHelper.Astrolabe:PlaceIconOnWorldMap(QuestHelper.map_overlay, self, convertLocation(self.objective.pos))
518 else
519 self.objective = nil
520 self:Hide()
524 function icon:OnClick()
525 if self.objective then
526 local menu = QuestHelper:CreateMenu()
527 local list = QuestHelper:GetOverlapObjectives(self.objective)
528 local item
530 if #list > 1 then
531 QuestHelper:CreateMenuTitle(menu, "Objectives")
533 for i, o in ipairs(list) do
534 local submenu = QuestHelper:CreateMenu()
535 item = QuestHelper:CreateMenuItem(menu, o:Reason(true))
536 item:SetSubmenu(submenu)
537 item:AddTexture(QuestHelper:CreateIconTexture(item, o.icon_id), true)
538 QuestHelper:AddObjectiveOptionsToMenu(o, submenu)
540 else
541 QuestHelper:CreateMenuTitle(menu, self.objective:Reason(true))
542 QuestHelper:AddObjectiveOptionsToMenu(self.objective, menu)
545 menu:ShowAtCursor()
549 icon:SetScript("OnClick", icon.OnClick)
550 icon:SetScript("OnEnter", icon.OnEnter)
551 icon:SetScript("OnLeave", icon.OnLeave)
552 icon:SetScript("OnEvent", icon.OnEvent)
554 icon:RegisterForClicks("RightButtonUp")
556 icon:RegisterEvent("WORLD_MAP_UPDATE")
558 icon:SetObjective(objective, index)
559 return icon
562 local callbacks = {}
563 local last_c, last_z, last_x, last_y, last_desc
565 function QuestHelper:AddWaypointCallback(func, ...)
566 local cb = self:CreateTable()
567 callbacks[cb] = true
568 local len = select("#", ...)
569 cb.len = len
570 cb.func = func
571 for i = 1,len do cb[i] = select(i, ...) end
572 cb[len+1] = last_c
573 cb[len+2] = last_z
574 cb[len+3] = last_x
575 cb[len+4] = last_y
576 cb[len+5] = last_desc
577 func(unpack(cb, 1, len+5))
578 return cb
581 function QuestHelper:RemoveWaypointCallback(cb)
582 callbacks[cb] = nil
583 self:ReleaseTable(cb)
586 function QuestHelper:InvokeWaypointCallbacks(c, z, x, y, desc)
587 if c ~= last_c or z ~= last_z or x ~= last_x or y ~= last_y or desc ~= last_desc then
588 last_c, last_z, last_x, last_y, last_desc = c, z, x, y, desc
589 for cb in pairs(callbacks) do
590 local len = cb.len
591 cb[len+1] = c
592 cb[len+2] = z
593 cb[len+3] = x
594 cb[len+4] = y
595 cb[len+5] = desc
596 cb.func(unpack(cb, 1, len+5))
601 function QuestHelper:CreateMipmapDodad()
602 local icon = CreateFrame("Button", nil, Minimap)
603 icon:Hide()
604 icon.recalc_timeout = 0
606 icon.arrow = CreateFrame("Model", nil, icon)
607 icon.arrow:SetHeight(140.8)
608 icon.arrow:SetWidth(140.8)
609 icon.arrow:SetPoint("CENTER", Minimap, "CENTER", 0, 0)
610 icon.arrow:SetModel("Interface\\Minimap\\Rotating-MinimapArrow.mdx")
611 icon.arrow:Hide()
613 icon.phase = 0
614 icon.target = {0, 0, 0, 0}
615 icon.icon_id = 7
617 icon.bg = QuestHelper:CreateIconTexture(icon, 16)
618 icon.bg:SetDrawLayer("BACKGROUND")
619 icon.bg:SetAllPoints()
621 function icon:NextObjective()
622 for i, o in ipairs(QuestHelper.route) do
623 if not QuestHelper.to_remove[o] and o.pos then
624 return o
628 return nil
631 function icon:OnUpdate(elapsed)
632 if self.objective then
633 if not self.objective.pos then
634 self.objective = self:NextObjective()
635 if not self.objective then
636 self:Hide()
637 return
641 self:Show()
643 if self.recalc_timeout == 0 and not QuestHelper.graph_in_limbo then
644 self.recalc_timeout = 50
646 self.objective = self:NextObjective()
648 if not self.objective then
649 self:Hide()
650 return
653 local path, travel_time = QuestHelper:ComputeRoute(QuestHelper.pos, self.objective.pos)
654 local t = self.target
655 local id = self.objective.icon_id
656 t[1], t[2], t[3], t[4] = convertLocation(self.objective.pos)
657 t[5] = nil
659 self.objective.travel_time = travel_time
661 while path do
662 if path.g > 10.0 then
663 id = 8
664 t[1] = path.c
665 t[2] = 0
666 t[3] = path.x / QuestHelper.continent_scales_x[path.c]
667 t[4] = path.y / QuestHelper.continent_scales_y[path.c]
668 t[5] = path.name or "waypoint"
670 path = path.p
673 if not self.dot or id ~= self.icon_id then
674 self.icon_id = id
675 if self.dot then QuestHelper:ReleaseTexture(self.dot) end
676 self.dot = QuestHelper:CreateIconTexture(self, self.icon_id)
677 self.dot:SetPoint("TOPLEFT", icon, "TOPLEFT", 2, -2)
678 self.dot:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -2, 2)
681 if UnitIsDeadOrGhost("player") then
682 QuestHelper:InvokeWaypointCallbacks()
683 else
684 local reason = (t[5] and (QHFormat("WAYPOINT_REASON", t[5]).."\n"..self.objective:Reason(true)))
685 or self.objective:Reason(true)
687 if QuestHelper.c == t[1] then
688 -- Translate the position to the zone the player is standing in.
689 local c, z = QuestHelper.c, QuestHelper.z
690 local x, y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], c, z)
691 QuestHelper:InvokeWaypointCallbacks(c, z, x, y, reason)
692 else
693 -- Try to find the nearest zone on the continent the objective is in.
694 local index, distsqr, x, y
695 for z, i in pairs(QuestHelper_IndexLookup[t[1]]) do
696 local _x, _y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], t[1], z)
697 local d = (_x-0.5)*(_x-0.5)+(_y-0.5)*(_y-0.5)
698 if not index or d < distsqr then
699 index, distsqr, x, y = i, d, _x, _y
702 local c, z = QuestHelper_IndexLookup[index]
703 QuestHelper:InvokeWaypointCallbacks(c, z, x, y, reason)
707 QuestHelper.Astrolabe:PlaceIconOnMinimap(self, unpack(self.target))
708 else
709 self.recalc_timeout = self.recalc_timeout - 1
712 local edge = QuestHelper.Astrolabe:IsIconOnEdge(self)
714 if edge then
715 self.arrow:Show()
716 self.dot:Hide()
717 self.bg:Hide()
718 else
719 self.arrow:Hide()
720 self.dot:Show()
721 self.bg:Show()
724 if edge then
725 local angle = QuestHelper.Astrolabe:GetDirectionToIcon(self)
726 if GetCVar("rotateMinimap") == "1" then
727 angle = angle + MiniMapCompassRing:GetFacing()
730 self.arrow:SetFacing(angle)
731 self.arrow:SetPosition(ofs * (137 / 140) - radius * math.sin(angle),
732 ofs + radius * math.cos(angle), 0);
734 if self.phase > 6.283185307179586476925 then
735 self.phase = self.phase-6.283185307179586476925+elapsed*3.5
736 else
737 self.phase = self.phase+elapsed*3.5
739 self.arrow:SetModelScale(0.600000023841879+0.1*math.sin(self.phase))
741 else
742 self:Hide()
746 function icon:SetObjective(objective)
747 self:SetHeight(20*QuestHelper_Pref.scale)
748 self:SetWidth(20*QuestHelper_Pref.scale)
750 if objective ~= self.objective then
751 if objective and not QuestHelper_Pref.hide then
752 self:Show()
753 else
754 QuestHelper:InvokeWaypointCallbacks()
755 self:Hide()
758 self.objective = objective
759 self.recalc_timeout = 0
763 function icon:OnEnter()
764 if self.objective then
765 QuestHelper.tooltip:SetOwner(self, "ANCHOR_CURSOR")
766 QuestHelper.tooltip:ClearLines()
768 if self.target[5] then
769 QuestHelper.tooltip:AddLine(QHFormat("WAYPOINT_REASON", self.target[5]), unpack(QuestHelper:GetColourTheme().tooltip))
770 QuestHelper.tooltip:GetPrevLines():SetFont(QuestHelper.font.serif, 14)
773 QuestHelper:AppendObjectiveToTooltip(self.objective)
774 QuestHelper.tooltip:Show()
778 function icon:OnLeave()
779 QuestHelper.tooltip:Hide()
782 function icon:OnClick()
783 if self.objective then
784 local menu = QuestHelper:CreateMenu()
785 QuestHelper:CreateMenuTitle(menu, self.objective:Reason(true))
786 QuestHelper:AddObjectiveOptionsToMenu(self.objective, menu)
787 menu:ShowAtCursor()
791 function icon:OnEvent()
792 if self.objective and self.objective.pos then
793 self:Show()
794 else
795 self:Hide()
799 icon:SetScript("OnUpdate", icon.OnUpdate)
800 icon:SetScript("OnEnter", icon.OnEnter)
801 icon:SetScript("OnLeave", icon.OnLeave)
802 icon:SetScript("OnEvent", icon.OnEvent)
803 icon:SetScript("OnClick", icon.OnClick)
805 icon:RegisterForClicks("RightButtonUp")
806 icon:RegisterEvent("PLAYER_ENTERING_WORLD")
808 return icon