1 QuestHelper_File
["dodads.lua"] = "Development Version"
2 QuestHelper_Loadtime
["dodads.lua"] = GetTime()
4 local ofs
= 0.000723339 * (GetScreenHeight()/GetScreenWidth() + 1/3) * 70.4;
5 local radius
= ofs
/ 1.166666666666667;
7 -- These conversions are nasty, and this entire section needs a serious cleanup.
8 local function convertLocation(p
)
9 local c
, x
, y
= QuestHelper
.Astrolabe
:FromAbsoluteContinentPosition(p
.c
, p
.x
, p
.y
)
13 local function convertLocationToScreen(p
, c
, z
)
14 local pc
, _
, px
, py
= convertLocation(p
)
15 local ox
, oy
= QuestHelper
.Astrolabe
:TranslateWorldMapPosition(pc
, 0, px
, py
, c
, z
)
16 --QuestHelper:TextOut(string.format("%f/%f/%f to %f/%f/%f to %f/%f %f/%f", p.c, p.x, p.y, pc, px, py, c, z, ox, oy))
20 local function convertNodeToScreen(n
, c
, z
)
21 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
)
24 QuestHelper
.map_overlay
= CreateFrame("FRAME", nil, WorldMapButton
)
25 QuestHelper
.map_overlay
:SetFrameLevel(WorldMapButton
:GetFrameLevel()+1)
26 QuestHelper
.map_overlay
:SetAllPoints()
27 QuestHelper
.map_overlay
:SetFrameStrata("FULLSCREEN")
29 local function ClampLine(x1
, y1
, x2
, y2
)
30 if x1
and y1
and x2
and y2
then
31 local x_div
, y_div
= (x2
-x1
), (y2
-y1
)
32 local x_0
= y1
-x1
/x_div
*y_div
33 local x_1
= y1
+(1-x1
)/x_div
*y_div
34 local y_0
= x1
-y1
/y_div
*x_div
35 local y_1
= x1
+(1-y1
)/y_div
*x_div
77 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
85 function QuestHelper
:CreateWorldMapWalker()
86 local walker
= CreateFrame("Button", nil, QuestHelper
.map_overlay
)
90 walker
:SetPoint("CENTER", QuestHelper
.map_overlay
, "TOPLEFT", 0, 0)
98 walker
.map_dodads
= {}
99 walker
.used_map_dodads
= 0
101 QuestHelper
: Assert(self
== QuestHelper
)
102 QuestHelper
: Assert(self
.Astrolabe
)
104 function walker
:OnUpdate(elapsed
)
107 if QuestHelper_Pref
.show_ants
then
108 local points
= self
.points
110 self
.phase
= self
.phase
+ elapsed
* 0.66
111 while self
.phase
> 1 do self
.phase
= self
.phase
- 1 end
113 local w
, h
= QuestHelper
.map_overlay
:GetWidth(), -QuestHelper
.map_overlay
:GetHeight()
115 local c
, z
= GetCurrentMapContinent(), GetCurrentMapZone()
117 local last_x
, last_y
= self
.frame
.Astrolabe
:TranslateWorldMapPosition(self
.frame
.c
, self
.frame
.z
, self
.frame
.x
, self
.frame
.y
, c
, z
)
118 local remainder
= self
.phase
120 for i
, pos
in ipairs(points
) do
121 local new_x
, new_y
= unpack(pos
)
122 local x1
, y1
, x2
, y2
= ClampLine(last_x
, last_y
, new_x
, new_y
)
123 last_x
, last_y
= new_x
, new_y
126 local len
= math
.sqrt((x1
-x2
)*(x1
-x2
)*16/9+(y1
-y2
)*(y1
-y2
))
129 local interval
= .025/len
130 local p
= remainder
*interval
134 local dot
= self
.dots
[out
]
136 dot
= QuestHelper
:CreateDotTexture(self
)
137 dot
:SetDrawLayer("BACKGROUND")
142 dot
:SetPoint("CENTER", QuestHelper
.map_overlay
, "TOPLEFT", x1
*w
*(1-p
)+x2
*w
*p
, y1
*h
*(1-p
)+y2
*h
*p
)
147 remainder
= (p
-1)/interval
153 while #self
.dots
> out
do
154 QuestHelper
:ReleaseTexture(table.remove(self
.dots
))
158 function walker
:RouteChanged(route
)
159 if route
then self
.route
= route
end -- we cache it so we can refer to it later when the world map changes
160 if not self
.route
then return end
162 local dbgstr
= string.format("%s %s %s %s", tostring(self
), tostring(self
.frame
), tostring(QuestHelper
), tostring(QuestHelper
and QuestHelper
.Astrolabe
))
163 QuestHelper
: Assert(self
.frame
== QuestHelper
, dbgstr
)
164 QuestHelper
: Assert(QuestHelper
.Astrolabe
, dbgstr
)
166 if self
.frame
.Astrolabe
.WorldMapVisible
then
167 local points
= self
.points
168 local cur
= self
.frame
.pos
170 while #points
> 0 do self
.frame
:ReleaseTable(table.remove(points
)) end
172 local c
, z
= GetCurrentMapContinent(), GetCurrentMapZone()
174 -- I'm not quite sure what the point of this is.
176 if self.frame.target then
177 travel_time = math.max(0, self.frame.target_time-time())
178 cur = self.frame.target
179 local t = self.frame:CreateTable()
180 t[1], t[2] = convertLocationToScreen(cur, c, z)
181 table.insert(points, t)
184 for i
, obj
in ipairs(self
.route
) do
185 --QuestHelper:TextOut(string.format("%s", tostring(obj)))
188 local t = QuestHelper:CreateTable()
189 t[1], t[2] = convertLocationToScreen(obj.loc, c, z)
191 table.insert(list, t)]]
193 -- We're ignoring travel time for now.
195 travel_time = travel_time + 60
196 obj.travel_time = travel_time]]
197 if i
> 1 then -- skip the start location
198 local t
= self
.frame
:CreateTable()
199 t
[1], t
[2] = convertLocationToScreen(obj
.loc
, c
, z
)
201 table.insert(points
, t
)
203 --if lotsup then print(obj.ignore, obj.loc.x, obj.loc.y, obj.loc.c) end
205 --QuestHelper:TextOut(string.format("%s/%s/%s to %s/%s", tostring(obj.c), tostring(obj.x), tostring(obj.y), tostring(t[1]), tostring(t[2])))
210 for i
= 2, #self
.route
do -- 2 because we're skipping the player
211 if not self
.route
[i
].ignore
then
212 local dodad
= self
.map_dodads
[cur_dodad
]
214 self
.map_dodads
[cur_dodad
] = self
.frame
:CreateWorldMapDodad(self
.route
[i
], i
== 2)
216 self
.map_dodads
[cur_dodad
]:SetObjective(self
.route
[i
], i
== 2)
218 cur_dodad
= cur_dodad
+ 1
222 if cur_dodad
<= self
.used_map_dodads
then for i
= cur_dodad
,self
.used_map_dodads
do
223 self
.map_dodads
[i
]:SetObjective(nil, false)
226 self
.used_map_dodads
= cur_dodad
- 1
230 walker
:SetScript("OnEvent", function () walker
:RouteChanged() end) -- we do this just to strip the parameters out
231 walker
:RegisterEvent("WORLD_MAP_UPDATE")
233 walker
:SetScript("OnUpdate", walker
.OnUpdate
)
238 function QuestHelper
:GetOverlapObjectives(obj
)
239 local w
, h
= self
.map_overlay
:GetWidth(), self
.map_overlay
:GetHeight()
240 local c
, z
= GetCurrentMapContinent(), GetCurrentMapZone()
242 local list
= self
.overlap_list
246 self
.overlap_list
= list
248 while table.remove(list
) do end
251 local cx
, cy
= GetCursorPosition()
253 local es
= QuestHelper
.map_overlay
:GetEffectiveScale()
256 cx
, cy
= (cx
-self
.map_overlay
:GetLeft()*es
)*ies
, (self
.map_overlay
:GetTop()*es
-cy
)*ies
258 local s
= 10*QuestHelper_Pref
.scale
260 for i
, o
in ipairs(walker_loc
.route
) do
261 --QuestHelper: Assert(o, string.format("nil dodads pos issue, o %s", tostring(o)))
262 --QuestHelper: Assert(o.pos, string.format("nil dodads pos issue, pos %s", QuestHelper:StringizeTable(o)))
265 table.insert(list
, o
)
267 local x
, y
= convertLocationToScreen(o
.loc
, c
, z
)
269 if x
and y
and x
> 0 and y
> 0 and x
< 1 and y
< 1 then
272 if cx
>= x
-s
and cy
>= y
-s
and cx
<= x
+s
and cy
<= y
+s
then
273 table.insert(list
, o
)
280 table.sort(list
, function(a
, b
) return (a
.distance
or 0) < (b
.distance
or 0) end)
285 function QuestHelper
:AppendObjectiveProgressToTooltip(o
, tooltip
, font
, depth
)
287 local prog_sort_table
= {}
289 local theme
= self
:GetColourTheme()
291 local indent
= (" "):rep(depth
or 0)
293 for user
, progress
in pairs(o
.progress
) do
294 table.insert(prog_sort_table
, user
)
297 table.sort(prog_sort_table
, function(a
, b
)
298 if o
.progress
[a
][3] < o
.progress
[b
][3] then
300 elseif o
.progress
[a
][3] == o
.progress
[b
][3] then
306 for i
, u
in ipairs(prog_sort_table
) do
307 tooltip
:AddDoubleLine(indent
..QHFormat("PEER_PROGRESS", u
),
308 self
:ProgressString(o
.progress
[u
][1].."/"..o
.progress
[u
][2],
309 o
.progress
[u
][3]), unpack(theme
.tooltip
))
312 local last
, name
= tooltip
:NumLines(), tooltip
:GetName()
313 local left
, right
= _G
[name
.."TextLeft"..last
], _G
[name
.."TextRight"..last
]
315 left
:SetFont(font
, 13)
316 right
:SetFont(font
, 13)
320 while table.remove(prog_sort_table
) do end
324 function QuestHelper
:AppendObjectiveToTooltip(o
)
325 local theme
= self
:GetColourTheme()
327 QuestHelper
: Assert(o
.map_desc
)
328 for _
, v
in ipairs(o
.map_desc
) do
329 self
.tooltip
:AddLine(v
, unpack(theme
.tooltip
))
330 self
.tooltip
:GetPrevLines():SetFont(self
.font
.serif
, 14)
333 if o
.map_desc_chain
then
334 self
:AppendObjectiveToTooltip(o
.map_desc_chain
)
336 self
:AppendObjectiveProgressToTooltip(o
, self
.tooltip
, QuestHelper
.font
.sans
)
338 self
.tooltip
:AddDoubleLine(QHText("TRAVEL_ESTIMATE"), QHFormat("TRAVEL_ESTIMATE_VALUE", o
.distance
or 0), unpack(theme
.tooltip
))
339 self
.tooltip
:GetPrevLines():SetFont(self
.font
.sans
, 11)
340 select(2, self
.tooltip
:GetPrevLines()):SetFont(self
.font
.sans
, 11)
347 function QuestHelper
:CreateWorldMapDodad(objective
, nxt
)
348 local icon
= CreateFrame("Button", nil, QuestHelper
.map_overlay
)
349 icon
:SetFrameStrata("FULLSCREEN")
351 function icon
:SetTooltip(list
)
352 QuestHelper
.tooltip
:SetOwner(self
, "ANCHOR_CURSOR")
353 QuestHelper
.tooltip
:ClearLines()
357 for i
, o
in ipairs(list
) do
361 QuestHelper
.tooltip
:AddLine("|c80ff0000 . . . . . .|r")
362 QuestHelper
.tooltip
:GetPrevLines():SetFont(QuestHelper
.font
.sans
, 8)
365 QuestHelper
:AppendObjectiveToTooltip(o
)
368 QuestHelper
.tooltip
:Show()
371 function icon
:SetObjective(objective
, nxt
)
372 self
:SetHeight(20*QuestHelper_Pref
.scale
)
373 self
:SetWidth(20*QuestHelper_Pref
.scale
)
376 QuestHelper
:ReleaseTexture(self
.dot
)
381 QuestHelper
:ReleaseTexture(self
.bg
)
386 self
.objective
= objective
389 self
.bg
= QuestHelper
:CreateIconTexture(self
, 13)
390 elseif objective
.map_highlight
then
391 self
.bg
= QuestHelper
:CreateIconTexture(self
, 14)
393 self
.bg
= QuestHelper
:CreateIconTexture(self
, 16)
396 self
.dot
= QuestHelper
:CreateIconTexture(self
, objective
.icon_id
or 8)
398 self
.bg
:SetDrawLayer("BACKGROUND")
399 self
.bg
:SetAllPoints()
400 self
.dot
:SetPoint("TOPLEFT", self
, "TOPLEFT", 3*QuestHelper_Pref
.scale
, -3*QuestHelper_Pref
.scale
)
401 self
.dot
:SetPoint("BOTTOMRIGHT", self
, "BOTTOMRIGHT", -3*QuestHelper_Pref
.scale
, 3*QuestHelper_Pref
.scale
)
403 QuestHelper
.Astrolabe
:PlaceIconOnWorldMap(QuestHelper
.map_overlay
, self
, convertLocation(objective
.loc
))
404 --QuestHelper.Astrolabe:PlaceIconOnWorldMap(QuestHelper.map_overlay, self, 0, 0, globx, globy)
411 function icon
:SetGlow(list
)
412 local w
, h
= QuestHelper
.map_overlay
:GetWidth(), QuestHelper
.map_overlay
:GetHeight()
413 local c
, z
= GetCurrentMapContinent(), GetCurrentMapZone()
417 for _
, v
in ipairs(list
) do
419 for _
, i
in ipairs(v
.cluster
) do
429 for obj
, _
in pairs(nodes
) do
430 local x
, y
= convertLocationToScreen(obj
.loc
, c
, z
)
431 if x
and y
and x
> 0 and y
> 0 and x
< 1 and y
< 1 then
432 if not self
.glow_list
then
433 self
.glow_list
= QuestHelper
:CreateTable()
436 tex
= self
.glow_list
[out
]
438 tex
= QuestHelper
:CreateGlowTexture(self
)
439 table.insert(self
.glow_list
, tex
)
443 tex
:SetPoint("CENTER", QuestHelper
.map_overlay
, "TOPLEFT", x
*w
, -y
*h
)
444 tex
:SetVertexColor(1,1,1,0)
445 tex
:SetWidth(h
/ 4) -- we want it to be a circle
452 if self
.glow_list
then
453 while #self
.glow_list
>= out
do
454 QuestHelper
:ReleaseTexture(table.remove(self
.glow_list
))
457 if #self
.glow_list
== 0 then
458 QuestHelper
:ReleaseTable(self
.glow_list
)
464 icon
.show_glow
= false
469 function icon
:OnUpdate(elapsed
)
470 self
.phase
= (self
.phase
+ elapsed
)%6.283185307179586476925286766559005768394338798750211641949889185
472 if self
.old_count
> 0 then
473 local list
= QuestHelper
:GetOverlapObjectives(self
.objective
)
475 if #list
~= self
.old_count
then
476 self
:SetTooltip(list
)
477 self
.old_count
= #list
482 if self
.show_glow
then
483 self
.glow_pct
= math
.min(1, self
.glow_pct
+elapsed
*1.5)
485 self
.glow_pct
= math
.max(0, self
.glow_pct
-elapsed
*0.5)
487 if self
.glow_pct
== 0 then
488 if self
.glow_list
then
489 while #self
.glow_list
> 0 do
490 QuestHelper
:ReleaseTexture(table.remove(self
.glow_list
))
492 QuestHelper
:ReleaseTable(self
.glow_list
)
496 self
:SetScript("OnUpdate", nil)
501 if self
.glow_list
then
502 -- You know, these numbers are harmonics of pi. Would SETI detected them, or would they just be seen as noise?
503 -- I'd vote for the later.
505 -- Pi - circumference over diameter - when was the last time you actually cared about diameters in math?
507 -- Pretty much everything in computer geometry depends on the pythagorean theorem, which you can use for
508 -- circles, spheres, and hyper-spheres, if you use radius.
510 -- It's even the basis of special relativity, with time being multiplied by c so that you get a distance
511 -- that you can use with the spatial dimensions. We're all in agreement that space traveling aliens are
512 -- going to know about relativity, right?
514 -- And if you ever do trig, a full circle would be exactly (circumference over radius) radians instead of
515 -- (circumference over diameter)*2 radians.
517 -- Obviously aliens are much more likely to prefer 6.283185307179586... as constant than our pi.
519 -- Important update: I just noticed that large factorials can be approximated using (2*pi*n)^.5*(n/e)^n
520 -- There's that 2 times pi thing again.
521 local r
, g
, b
= math
.sin(self
.phase
)*0.25+0.75,
522 math
.sin(self
.phase
+2.094395102393195492308428922186335256131446266250070547316629728)*0.25+0.75,
523 math
.sin(self
.phase
+4.188790204786390984616857844372670512262892532500141094633259456)*0.25+0.75
525 for i
, tex
in ipairs(self
.glow_list
) do
526 tex
:SetVertexColor(r
, g
, b
, self
.glow_pct
*tex
.max_alpha
)
531 function icon
:OnEnter()
532 local list
= QuestHelper
:GetOverlapObjectives(self
.objective
)
533 self
:SetTooltip(list
)
534 self
.old_count
= #list
536 icon
.show_glow
= true
540 self
:SetScript("OnUpdate", self
.OnUpdate
)
543 function icon
:OnLeave()
544 QuestHelper
.tooltip
:Hide()
545 self
.show_glow
= false
549 function icon
:OnEvent(event
)
550 if self
.objective
then
551 QuestHelper
.Astrolabe
:PlaceIconOnWorldMap(QuestHelper
.map_overlay
, self
, convertLocation(self
.objective
.loc
))
558 function icon
:OnClick()
559 if self
.objective
then
560 local menu
= QuestHelper
:CreateMenu()
561 local list
= QuestHelper
:GetOverlapObjectives(self
.objective
)
565 QuestHelper
:CreateMenuTitle(menu
, "Objectives")
567 for i
, o
in ipairs(list
) do
568 local submenu
= QuestHelper
:CreateMenu()
569 item
= QuestHelper
:CreateMenuItem(menu
, o
.map_desc
[1])
570 item
:SetSubmenu(submenu
)
571 item
:AddTexture(QuestHelper
:CreateIconTexture(item
, o
.icon_id
), true)
572 QuestHelper
:AddObjectiveOptionsToMenu(o
, submenu
)
575 QuestHelper
:CreateMenuTitle(menu
, self
.objective
.map_desc
[1])
576 QuestHelper
:AddObjectiveOptionsToMenu(self
.objective
, menu
)
583 icon
:SetScript("OnClick", icon
.OnClick
)
584 icon
:SetScript("OnEnter", icon
.OnEnter
)
585 icon
:SetScript("OnLeave", icon
.OnLeave
)
586 icon
:SetScript("OnEvent", icon
.OnEvent
)
588 icon
:RegisterForClicks("RightButtonUp")
590 icon
:RegisterEvent("WORLD_MAP_UPDATE")
592 icon
:SetObjective(objective
, nxt
)
597 local last_c
, last_z
, last_x
, last_y
, last_desc
599 function QuestHelper
:AddWaypointCallback(func
, ...)
600 local cb
= self
:CreateTable()
602 local len
= select("#", ...)
605 for i
= 1,len
do cb
[i
] = select(i
, ...) end
610 cb
[len
+5] = last_desc
613 func(unpack(cb
, 1, len
+5))
619 function QuestHelper
:RemoveWaypointCallback(cb
)
621 self
:ReleaseTable(cb
)
624 function QuestHelper
:InvokeWaypointCallbacks(c
, z
, x
, y
, desc
)
625 if c
~= last_c
or z
~= last_z
or x
~= last_x
or y
~= last_y
or desc
~= last_desc
then
626 last_c
, last_z
, last_x
, last_y
, last_desc
= c
, z
, x
, y
, desc
627 if c
and z
and x
and y
and z
then
628 for cb
in pairs(callbacks
) do
635 cb
.func(unpack(cb
, 1, len
+5))
641 --[[ Small parts of the arrow rendering code are thanks to Tomtom, with the following license:
643 -------------------------------------------------------------------------
644 Copyright (c) 2006-2007, James N. Whitehead II
647 Redistribution and use in source and binary forms, with or without
648 modification, are permitted provided that the following conditions are
651 * Redistributions of source code must retain the above copyright
652 notice, this list of conditions and the following disclaimer.
653 * Redistributions in binary form must reproduce the above
654 copyright notice, this list of conditions and the following
655 disclaimer in the documentation and/or other materials provided
656 with the distribution.
657 * The name or alias of the copyright holder may not be used to endorse
658 or promote products derived from this software without specific prior
661 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
662 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
663 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
664 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
665 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
666 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
667 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
668 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
669 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
670 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
671 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
672 ---------------------------------------------------------------------------]]
674 function QuestHelper
:CreateMipmapDodad()
675 local icon
= CreateFrame("Button", nil, Minimap
)
677 icon
.recalc_timeout
= 0
679 icon
.arrow
= icon
:CreateTexture("BACKGROUND")
680 icon
.arrow
:SetHeight(40)
681 icon
.arrow
:SetWidth(40)
682 icon
.arrow
:SetPoint("CENTER", 0, 0)
683 icon
.arrow
:SetTexture("Interface\\AddOns\\QuestHelper\\MinimapArrow")
687 icon
.target
= {0, 0, 0, 0}
689 icon
.bg
= QuestHelper
:CreateIconTexture(icon
, 16)
690 icon
.bg
:SetDrawLayer("BACKGROUND")
691 icon
.bg
:SetAllPoints()
693 function icon
:OnUpdate(elapsed
)
694 if self
.obj
and not QuestHelper
.InBrokenInstance
then
695 self
:Show() -- really only triggers if the non-broken-instance code is being poked
697 -- Deal with waypoint callbacks
698 if QuestHelper_Pref
.hide
or UnitIsDeadOrGhost("player") then
699 QuestHelper
:InvokeWaypointCallbacks()
701 local c
, z
= QuestHelper
.collect_rc
or 0, QuestHelper
.collect_rz
or 0
702 local x
, y
= convertLocationToScreen(self
.obj
.loc
, c
, z
)
703 --QuestHelper:TextOut(string.format("internal: %f %f %f %f or %f %f %f", c, z, x, y, self.obj.loc.c, self.obj.loc.x, self.obj.loc.y))
706 if self
.obj
.map_desc_chain
then
707 -- the first line will just be an "enroute" line
708 textdesc
= self
.obj
.map_desc
[1] .. "\n" .. self
.obj
.map_desc_chain
.map_desc
[1]
710 textdesc
= self
.obj
.map_desc
[1]
713 QuestHelper
:InvokeWaypointCallbacks(c
, z
, x
, y
, textdesc
)
716 if QuestHelper
.c
== t
[1] then
717 -- Translate the position to the zone the player is standing in.
718 local c
, z
= QuestHelper
.c
, QuestHelper
.z
719 local x
, y
= QuestHelper
.Astrolabe
:TranslateWorldMapPosition(t
[1], t
[2], t
[3], t
[4], c
, z
)
720 QuestHelper
:InvokeWaypointCallbacks(c
, z
, x
, y
, reason
)
722 -- Try to find the nearest zone on the continent the objective is in.
723 local index
, distsqr
, x
, y
724 for z
, i
in pairs(QuestHelper_IndexLookup
[t
[1]]
) do
725 local _x
, _y
= QuestHelper
.Astrolabe
:TranslateWorldMapPosition(t
[1], t
[2], t
[3], t
[4], t
[1], z
)
726 local d
= (_x
-0.5)*(_x
-0.5)+(_y
-0.5)*(_y
-0.5)
727 if not index
or d
< distsqr
then
728 index
, distsqr
, x
, y
= i
, d
, _x
, _y
731 local c
, z
= QuestHelper_IndexLookup
[index
]
732 QuestHelper
:InvokeWaypointCallbacks(c
, z
, x
, y
, reason
)
736 if not QuestHelper_Pref
.hide
and QuestHelper
.Astrolabe
:PlaceIconOnMinimap(self
, convertLocation(self
.obj
.loc
)) ~= -1 then
737 local edge
= QuestHelper
.Astrolabe
:IsIconOnEdge(self
)
750 local angle
= QuestHelper
.Astrolabe
:GetDirectionToIcon(self
)
751 if GetCVar("rotateMinimap") == "1" then
752 angle
= angle
+ QuestHelper
.Astrolabe
:GetFacing()
756 if self
.phase
> 6.283185307179586476925 then
757 self
.phase
= self
.phase
-6.283185307179586476925+elapsed
*3.5
759 self
.phase
= self
.phase
+elapsed
*3.5
763 local scale
= 1.0 + 0.1 * math
.sin(self
.phase
)
765 local x
, y
= scale
* math
.sin(angle
+ 3.14159 * 0.75) * math
.sqrt(0.5), scale
* math
.cos(angle
+ 3.14159 * 0.75) * math
.sqrt(0.5)
766 self
.arrow
:SetTexCoord(0.5 - x
, 0.5 + y
, 0.5 + y
, 0.5 + x
, 0.5 - y
, 0.5 - x
, 0.5 + x
, 0.5 - y
)
776 function icon
:SetObjective(obj
)
777 self
:SetHeight(20*QuestHelper_Pref
.scale
)
778 self
:SetWidth(20*QuestHelper_Pref
.scale
)
780 if obj
~= self
.obj
then
782 if obj
and not QuestHelper_Pref
.hide
then
785 QuestHelper
:InvokeWaypointCallbacks()
790 self
.recalc_timeout
= 0
792 if self
.dot
then QuestHelper
:ReleaseTexture(self
.dot
) self
.dot
= nil end
795 self
.dot
= QuestHelper
:CreateIconTexture(self
, self
.obj
.icon_id
or 8)
796 self
.dot
:SetPoint("TOPLEFT", icon
, "TOPLEFT", 2, -2)
797 self
.dot
:SetPoint("BOTTOMRIGHT", icon
, "BOTTOMRIGHT", -2, 2)
804 function icon
:OnEnter()
806 QuestHelper
.tooltip
:SetOwner(self
, "ANCHOR_CURSOR")
807 QuestHelper
.tooltip
:ClearLines()
809 --[[if self.target[5] then
810 QuestHelper.tooltip:AddLine(QHFormat("WAYPOINT_REASON", self.target[5]), unpack(QuestHelper:GetColourTheme().tooltip))
811 QuestHelper.tooltip:GetPrevLines():SetFont(QuestHelper.font.serif, 14)
814 QuestHelper
:AppendObjectiveToTooltip(self
.obj
)
815 QuestHelper
.tooltip
:Show()
819 function icon
:OnLeave()
820 QuestHelper
.tooltip
:Hide()
823 function icon
:OnClick()
824 if self
.objective
then
825 local menu
= QuestHelper
:CreateMenu()
826 QuestHelper
:CreateMenuTitle(menu
, self
.objective
:Reason(true))
827 QuestHelper
:AddObjectiveOptionsToMenu(self
.obj
, menu
)
832 function icon
:OnEvent()
840 icon
:SetScript("OnUpdate", icon
.OnUpdate
)
841 icon
:SetScript("OnEnter", icon
.OnEnter
)
842 icon
:SetScript("OnLeave", icon
.OnLeave
)
843 icon
:SetScript("OnEvent", icon
.OnEvent
)
844 icon
:SetScript("OnClick", icon
.OnClick
)
846 icon
:RegisterForClicks("RightButtonUp")
847 icon
:RegisterEvent("PLAYER_ENTERING_WORLD")