Merge branch 'master' of git+ssh://questhelper@192.168.2.1/server/git/QuestHelper
[QuestHelper.git] / dodads.lua
blobe9607c7755f043c9d1f461c001da132bcc137b8f
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, WorldMapDetailFrame)
21 QuestHelper.map_overlay:SetFrameLevel(WorldMapDetailFrame: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)
263 if o.progress then
264 local theme = self:GetColourTheme()
266 for user, progress in pairs(o.progress) do
267 table.insert(prog_sort_table, user)
270 table.sort(prog_sort_table, function(a, b)
271 if o.progress[a][3] < o.progress[b][3] then
272 return true
273 elseif o.progress[a][3] == o.progress[b][3] then
274 return a < b
276 return false
277 end)
279 for i, u in ipairs(prog_sort_table) do
280 tooltip:AddDoubleLine(QHFormat("PEER_PROGRESS", u),
281 self:ProgressString(o.progress[u][1].."/"..o.progress[u][2],
282 o.progress[u][3]), unpack(theme.tooltip))
284 if font then
285 local last, name = tooltip:NumLines(), tooltip:GetName()
286 local left, right = _G[name.."TextLeft"..last], _G[name.."TextRight"..last]
288 left:SetFont(font, 13)
289 right:SetFont(font, 13)
293 while table.remove(prog_sort_table) do end
297 function QuestHelper:AppendObjectiveToTooltip(o)
298 local theme = self:GetColourTheme()
300 self.tooltip:AddLine(o:Reason(), unpack(theme.tooltip))
301 self.tooltip:GetPrevLines():SetFont(self.font.serif, 14)
303 self:AppendObjectiveProgressToTooltip(o, self.tooltip, QuestHelper.font.sans)
305 self.tooltip:AddDoubleLine(QHText("TRAVEL_ESTIMATE"), QHFormat("TRAVEL_ESTIMATE_VALUE", o.travel_time or 0), unpack(theme.tooltip))
306 self.tooltip:GetPrevLines():SetFont(self.font.sans, 11)
307 select(2, self.tooltip:GetPrevLines()):SetFont(self.font.sans, 11)
310 function QuestHelper:CreateWorldMapDodad(objective, index)
311 local icon = CreateFrame("Button", nil, QuestHelper.map_overlay)
312 icon:SetFrameStrata("FULLSCREEN")
314 function icon:SetTooltip(list)
315 QuestHelper.tooltip:SetOwner(self, "ANCHOR_CURSOR")
316 QuestHelper.tooltip:ClearLines()
318 local first = true
320 for i, o in ipairs(list) do
321 if first then
322 first = false
323 else
324 QuestHelper.tooltip:AddLine("|c80ff0000 . . . . . .|r")
325 QuestHelper.tooltip:GetPrevLines():SetFont(QuestHelper.font.sans, 8)
328 QuestHelper:AppendObjectiveToTooltip(o)
331 QuestHelper.tooltip:Show()
334 function icon:SetObjective(objective, i)
335 self:SetHeight(20*QuestHelper_Pref.scale)
336 self:SetWidth(20*QuestHelper_Pref.scale)
338 if self.dot then
339 QuestHelper:ReleaseTexture(self.dot)
340 self.dot = nil
343 if self.bg then
344 QuestHelper:ReleaseTexture(self.bg)
345 self.bg = nil
348 if objective then
349 self.objective = objective
350 self.index = i
352 if i == 1 then
353 -- if it's the very next objective, give it the green background
354 self.bg = QuestHelper:CreateIconTexture(self, 13)
355 elseif objective.filter_blocked then
356 -- if there are still prerequisites, make it grey
357 -- We checked status of pre-requisites last time we scanned the quest log, so just check the flag.
358 self.bg = QuestHelper:CreateIconTexture(self, 16)
359 else
360 -- otherwise give it the background selected by the objective
361 self.bg = QuestHelper:CreateIconTexture(self, objective.icon_bg)
364 self.dot = QuestHelper:CreateIconTexture(self, objective.icon_id)
366 self.bg:SetDrawLayer("BACKGROUND")
367 self.bg:SetAllPoints()
368 self.dot:SetPoint("TOPLEFT", self, "TOPLEFT", 3*QuestHelper_Pref.scale, -3*QuestHelper_Pref.scale)
369 self.dot:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -3*QuestHelper_Pref.scale, 3*QuestHelper_Pref.scale)
371 QuestHelper.Astrolabe:PlaceIconOnWorldMap(QuestHelper.map_overlay, self, convertLocation(objective.pos))
372 else
373 self.objective = nil
374 self:Hide()
378 function icon:SetGlow(list)
379 local w, h = QuestHelper.map_overlay:GetWidth(), QuestHelper.map_overlay:GetHeight()
380 local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
381 local _, x_size, y_size = QuestHelper.Astrolabe:ComputeDistance(c, z, 0.25, 0.25, c, z, 0.75, 0.75)
383 x_size = math.max(25, 200 / x_size * w)
384 y_size = math.max(25, 200 / y_size * h)
386 local out = 1
387 for _, objective in ipairs(list) do
388 if objective.p then for _, list in pairs(objective.p) do
389 for _, p in ipairs(list) do
390 local x, y = p[3], p[4]
391 x, y = x / QuestHelper.continent_scales_x[p[1].c], y / QuestHelper.continent_scales_y[p[1].c]
392 x, y = QuestHelper.Astrolabe:TranslateWorldMapPosition(p[1].c, 0, x, y, c, z)
393 if x and y and x > 0 and y > 0 and x < 1 and y < 1 then
394 if not self.glow_list then
395 self.glow_list = QuestHelper:CreateTable()
398 tex = self.glow_list[out]
399 if not tex then
400 tex = QuestHelper:CreateGlowTexture(self)
401 table.insert(self.glow_list, tex)
403 out = out + 1
405 tex:SetPoint("CENTER", QuestHelper.map_overlay, "TOPLEFT", x*w, -y*h)
406 tex:SetVertexColor(1,1,1,0)
407 tex:SetWidth(x_size)
408 tex:SetHeight(y_size)
409 tex:Show()
410 tex.max_alpha = 1/p[5]
412 end end
416 if self.glow_list then
417 for i = out,#self.glow_list do
418 QuestHelper:ReleaseTexture(table.remove(self.glow_list))
421 if #self.glow_list == 0 then
422 QuestHelper:ReleaseTable(self.glow_list)
423 self.glow_list = nil
428 icon.show_glow = false
429 icon.glow_pct = 0.0
430 icon.phase = 0.0
431 icon.old_count = 0
433 function icon:OnUpdate(elapsed)
434 self.phase = (self.phase + elapsed)%6.283185307179586476925286766559005768394338798750211641949889185
436 if self.old_count > 0 then
437 local list = QuestHelper:GetOverlapObjectives(self.objective)
438 if #list ~= self.old_count then
439 self:SetTooltip(list)
440 self.old_count = #list
441 self:SetGlow(list)
445 if self.show_glow then
446 self.glow_pct = math.min(1, self.glow_pct+elapsed*1.5)
447 else
448 self.glow_pct = math.max(0, self.glow_pct-elapsed*0.5)
450 if self.glow_pct == 0 then
451 if self.glow_list then
452 while #self.glow_list > 0 do
453 QuestHelper:ReleaseTexture(table.remove(self.glow_list))
455 QuestHelper:ReleaseTable(self.glow_list)
456 self.glow_list = nil
459 self:SetScript("OnUpdate", nil)
460 return
464 if self.glow_list then
465 -- You know, these numbers are harmonics of pi. Would SETI detected them, or would they just be seen as noise?
466 -- I'd vote for the later.
468 -- Pi - circumference over diameter - when was the last time you actually cared about diameters in math?
470 -- Pretty much everything in computer geometry depends on the pythagorean theorem, which you can use for
471 -- circles, spheres, and hyper-spheres, if you use radius.
473 -- It's even the basis of special relativity, with time being multiplied by c so that you get a distance
474 -- that you can use with the spatial dimensions. We're all in agreement that space traveling aliens are
475 -- going to know about relativity, right?
477 -- And if you ever do trig, a full circle would be exactly (circumference over radius) radians instead of
478 -- (circumference over diameter)*2 radians.
480 -- Obviously aliens are much more likely to prefer 6.283185307179586... as constant than our pi.
481 local r, g, b = math.sin(self.phase)*0.25+0.75,
482 math.sin(self.phase+2.094395102393195492308428922186335256131446266250070547316629728)*0.25+0.75,
483 math.sin(self.phase+4.188790204786390984616857844372670512262892532500141094633259456)*0.25+0.75
485 for i, tex in ipairs(self.glow_list) do
486 tex:SetVertexColor(r, g, b, self.glow_pct*tex.max_alpha)
491 function icon:OnEnter()
492 local list = QuestHelper:GetOverlapObjectives(self.objective)
493 self:SetTooltip(list)
494 self.old_count = #list
496 icon.show_glow = true
498 self:SetGlow(list)
500 self:SetScript("OnUpdate", self.OnUpdate)
503 function icon:OnLeave()
504 QuestHelper.tooltip:Hide()
505 self.show_glow = false
506 self.old_count = 0
509 function icon:OnEvent(event)
510 if self.objective and self.objective.pos then
511 QuestHelper.Astrolabe:PlaceIconOnWorldMap(QuestHelper.map_overlay, self, convertLocation(self.objective.pos))
512 else
513 self.objective = nil
514 self:Hide()
518 function icon:OnClick()
519 if self.objective then
520 local menu = QuestHelper:CreateMenu()
521 local list = QuestHelper:GetOverlapObjectives(self.objective)
522 local item
524 if #list > 1 then
525 QuestHelper:CreateMenuTitle(menu, "Objectives")
527 for i, o in ipairs(list) do
528 local submenu = QuestHelper:CreateMenu()
529 item = QuestHelper:CreateMenuItem(menu, o:Reason(true))
530 item:SetSubmenu(submenu)
531 item:AddTexture(QuestHelper:CreateIconTexture(item, o.icon_id), true)
532 QuestHelper:AddObjectiveOptionsToMenu(o, submenu)
534 else
535 QuestHelper:CreateMenuTitle(menu, self.objective:Reason(true))
536 QuestHelper:AddObjectiveOptionsToMenu(self.objective, menu)
539 menu:ShowAtCursor()
543 icon:SetScript("OnClick", icon.OnClick)
544 icon:SetScript("OnEnter", icon.OnEnter)
545 icon:SetScript("OnLeave", icon.OnLeave)
546 icon:SetScript("OnEvent", icon.OnEvent)
548 icon:RegisterForClicks("RightButtonUp")
550 icon:RegisterEvent("WORLD_MAP_UPDATE")
552 icon:SetObjective(objective, index)
553 return icon
556 local callbacks = {}
557 local last_c, last_z, last_x, last_y, last_desc
559 function QuestHelper:AddWaypointCallback(func, ...)
560 local cb = self:CreateTable()
561 callbacks[cb] = true
562 local len = select("#", ...)
563 cb.len = len
564 cb.func = func
565 for i = 1,len do cb[i] = select(i, ...) end
566 cb[len+1] = last_c
567 cb[len+2] = last_z
568 cb[len+3] = last_x
569 cb[len+4] = last_y
570 cb[len+5] = last_desc
571 func(unpack(cb, 1, len+5))
572 return cb
575 function QuestHelper:RemoveWaypointCallback(cb)
576 callbacks[cb] = nil
577 self:ReleaseTable(cb)
580 function QuestHelper:InvokeWaypointCallbacks(c, z, x, y, desc)
581 if c ~= last_c or z ~= last_z or x ~= last_x or y ~= last_y or desc ~= last_desc then
582 last_c, last_z, last_x, last_y, last_desc = c, z, x, y, desc
583 for cb in pairs(callbacks) do
584 local len = cb.len
585 cb[len+1] = c
586 cb[len+2] = z
587 cb[len+3] = x
588 cb[len+4] = y
589 cb[len+5] = desc
590 cb.func(unpack(cb, 1, len+5))
595 function QuestHelper:CreateMipmapDodad()
596 local icon = CreateFrame("Button", nil, Minimap)
597 icon:Hide()
598 icon.recalc_timeout = 0
600 icon.arrow = CreateFrame("Model", nil, icon)
601 icon.arrow:SetHeight(140.8)
602 icon.arrow:SetWidth(140.8)
603 icon.arrow:SetPoint("CENTER", Minimap, "CENTER", 0, 0)
604 icon.arrow:SetModel("Interface\\Minimap\\Rotating-MinimapArrow.mdx")
605 icon.arrow:Hide()
607 icon.phase = 0
608 icon.target = {0, 0, 0, 0}
609 icon.icon_id = 7
611 icon.bg = QuestHelper:CreateIconTexture(icon, 16)
612 icon.bg:SetDrawLayer("BACKGROUND")
613 icon.bg:SetAllPoints()
615 function icon:NextObjective()
616 for i, o in ipairs(QuestHelper.route) do
617 if not QuestHelper.to_remove[o] and o.pos then
618 return o
622 return nil
625 function icon:OnUpdate(elapsed)
626 if self.objective then
627 if not self.objective.pos then
628 self.objective = self:NextObjective()
629 if not self.objective then
630 self:Hide()
631 return
635 self:Show()
637 if self.recalc_timeout == 0 then
638 self.recalc_timeout = 50
640 self.objective = self:NextObjective()
642 if not self.objective then
643 self:Hide()
644 return
647 local path, travel_time = QuestHelper:ComputeRoute(QuestHelper.pos, self.objective.pos)
648 local t = self.target
649 local id = self.objective.icon_id
650 t[1], t[2], t[3], t[4] = convertLocation(self.objective.pos)
651 t[5] = nil
653 self.objective.travel_time = travel_time
655 while path do
656 if path.g > 10.0 then
657 id = 8
658 t[1] = path.c
659 t[2] = 0
660 t[3] = path.x / QuestHelper.continent_scales_x[path.c]
661 t[4] = path.y / QuestHelper.continent_scales_y[path.c]
662 t[5] = path.name or "waypoint"
664 path = path.p
667 if not self.dot or id ~= self.icon_id then
668 self.icon_id = id
669 if self.dot then QuestHelper:ReleaseTexture(self.dot) end
670 self.dot = QuestHelper:CreateIconTexture(self, self.icon_id)
671 self.dot:SetPoint("TOPLEFT", icon, "TOPLEFT", 2, -2)
672 self.dot:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -2, 2)
675 if UnitIsDeadOrGhost("player") then
676 QuestHelper:InvokeWaypointCallbacks()
677 else
678 local reason = (t[5] and (QHFormat("WAYPOINT_REASON", t[5]).."\n"..self.objective:Reason(true)))
679 or self.objective:Reason(true)
681 if QuestHelper.c == t[1] then
682 -- Translate the position to the zone the player is standing in.
683 local c, z = QuestHelper.c, QuestHelper.z
684 local x, y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], c, z)
685 QuestHelper:InvokeWaypointCallbacks(c, z, x, y, reason)
686 else
687 -- Try to find the nearest zone on the continent the objective is in.
688 local index, distsqr, x, y
689 for z, i in pairs(QuestHelper_IndexLookup[t[1]]) do
690 local _x, _y = QuestHelper.Astrolabe:TranslateWorldMapPosition(t[1], t[2], t[3], t[4], t[1], z)
691 local d = (_x-0.5)*(_x-0.5)+(_y-0.5)*(_y-0.5)
692 if not index or d < distsqr then
693 index, distsqr, x, y = i, d, _x, _y
696 local c, z = QuestHelper_IndexLookup[index]
697 QuestHelper:InvokeWaypointCallbacks(c, z, x, y, reason)
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:InvokeWaypointCallbacks()
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(QuestHelper.font.serif, 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