Automated update from: http://smariot.no-ip.org/translate
[QuestHelper.git] / tracker.lua
blobc9b2d2719e600e5ada285082e1a66c329ace2b1c
1 QuestHelper_File["tracker.lua"] = "Development Version"
2 QuestHelper_Loadtime["tracker.lua"] = GetTime()
4 local debug_output = false
5 if QuestHelper_File["tracker.lua"] == "Development Version" then debug_output = true end
7 --[[ NOTES TO SELF
9 So here's what we want to do.
11 We want a "refresh notification" where we send it the current route.
13 If things aren't in the route, we don't care about them . . . unless they're pinned.
15 So we have "refresh notification" and "pin toggles". In both cases, the objective and only the objective is passed in. Right now there's no concept of priority within the pins.
17 We're also not bothering with the whole metaobjective tree, we're just going one step up.
19 So, our algorithm:
21 Note that "add" means "add iff it hasn't already been added."
23 Iff we haven't loaded yet, add a loaded message and a gap.
25 For each pinned objective, add the metaobjective and all objectives in its internal order. Iff we added things, add a gap.
27 For each route objective, add the metaobjective and all objectives in route order.
29 Later on we'll add an option for "splitting" metaobjectives, or possibly following the metaobjective tree all the way up.
33 So, "add" is complicated, due to the two requirements. We have to both add everything, and not add everything *yet*. I think the goal here is to make an Add function for adding a metaobjective that takes a list of objectives to be children, then doublecheck inside the function that we have all objectives.
35 We don't actually want "all objectives" long-term, note, we want only unfinished objectives. I sort of don't like the idea of keeping "finished objectives" around, however. Maybe we should only toss objectives in if they're in the routing system? Then how do I handle unknown objectives? (Simple - you pin them, and point out that we don't know how to do them.)
37 Also, to handle the "moving things around", we need to be a little clever. One line might be either a metaobjective or an objective, but in either case, we need a counter for which case it is. If everything shuffles, and we had two copies of metaobjective, MO1 moves to MO1 and MO2 moves to MO2. Easy.
40 local tracker = CreateFrame("Frame", "QuestHelperQuestWatchFrame", UIParent)
41 local minbutton = CreateFrame("Button", "QuestHelperQuestWatchFrameMinimizeButton", UIParent)
43 QuestHelper.tracker = tracker
45 local resizing = false
46 tracker:SetWidth(200)
47 tracker:SetHeight(100)
48 tracker:SetFrameStrata("BACKGROUND")
49 tracker.dw, tracker.dh = 200, 100
51 local in_tracker = 0
53 minbutton:SetFrameStrata("LOW")
54 minbutton:Hide()
55 minbutton:SetPoint("TOPRIGHT", WatchFrame) -- We default to a different location to make it more likely to display the right item.
56 minbutton:SetMovable(true)
57 minbutton:SetUserPlaced(true)
58 minbutton:SetWidth(24 / 1.6)
59 minbutton:SetHeight(24)
60 minbutton:SetFrameLevel(3)
61 local minbutton_tex = minbutton:CreateTexture()
62 minbutton_tex:SetAllPoints()
63 minbutton_tex:SetTexture(.6, .6, .6)
64 minbutton_tex:SetParent(minbutton)
66 local sigargh = CreateFrame("Frame", minbutton)
67 sigargh:SetFrameStrata("LOW")
68 sigargh:SetFrameLevel(4)
70 local sigil = sigargh:CreateTexture("BACKGROUND")
71 sigil:SetHeight(24)
72 sigil:SetWidth(24)
73 --sigil:SetPoint("CENTER", 0, 0)
74 sigil:SetTexture("Interface\\AddOns\\QuestHelper\\sigil")
75 sigil:SetPoint("CENTER", minbutton_tex, "CENTER")
78 tracker:SetPoint("CENTER", minbutton)
80 function minbutton:moved()
81 local x, y = self:GetCenter()
82 local w, h = UIParent:GetWidth(), UIParent:GetHeight()
83 local anchor = (y < h*.45 and "BOTTOM" or y > h*.55 and "TOP" or "")..(x < w*.45 and "LEFT" or x > w*.55 and "RIGHT" or "")
85 tracker:ClearAllPoints()
86 tracker:SetPoint("CENTER", self)
88 if anchor ~= "" then
89 tracker:SetPoint(anchor, self)
90 end
91 end
93 function QuestHelper:ResetTrackerPosition(cmd)
94 minbutton:ClearAllPoints()
95 if cmd and string.find(cmd, "center") then
96 minbutton:SetPoint("CENTER", nil, "CENTER", 100, 100)
97 else
98 minbutton:SetPoint("RIGHT", nil, "RIGHT", -20, 230)
99 end
100 minbutton:moved()
101 QuestHelper_Pref.track_minimized = false
102 tracker:Show()
103 self:TextOut("Quest tracker postion reset.")
106 QH_Event({"DISPLAY_SIZE_CHANGED", "PLAYER_ENTERING_WORLD"}, function () minbutton:moved() end)
108 QH_Hook(minbutton, "OnClick", function ()
109 QuestHelper_Pref.track_minimized = not QuestHelper_Pref.track_minimized
110 if QuestHelper_Pref.track_minimized then
111 tracker:Hide()
112 else
113 tracker:Show()
115 end)
117 minbutton:RegisterForDrag("LeftButton")
119 QH_Hook(minbutton, "OnDragStart", function(self)
120 if self:IsVisible() then
121 self:StartMoving()
122 QH_Hook(self, "OnUpdate", self.moved)
124 end)
126 QH_Hook(minbutton, "OnDragStop", function(self)
127 QH_Hook(self, "OnUpdate", nil)
128 self:StopMovingOrSizing()
129 self:moved()
130 end)
132 local entered_main = false
133 local entered_tracker = false
134 local function RefreshColor()
135 if entered_main then
136 minbutton:SetAlpha(1)
137 sigargh:SetAlpha(1)
138 elseif entered_tracker then
139 minbutton:SetAlpha(.3)
140 sigargh:SetAlpha(.3)
141 elseif QuestHelper_Pref.track_minimized then
142 minbutton:SetAlpha(.3)
143 sigargh:SetAlpha(.3)
144 else
145 minbutton:SetAlpha(0)
146 sigargh:SetAlpha(0)
149 local function SetEnteredMain(x)
150 entered_main = x
151 RefreshColor()
153 local function SetEnteredTracker(x)
154 entered_tracker = x
155 RefreshColor()
158 QH_Hook(minbutton, "OnEnter", function (self)
159 SetEnteredMain(true)
160 end)
162 QH_Hook(minbutton, "OnLeave", function (self)
163 SetEnteredMain(false)
164 end)
166 -- used_items[objective][index]
167 -- used_count[objective] is incremented as the last valid index
168 -- so, therefore, used_items[objective][used_count[objective]] is not nil
169 local used_items = {}
170 local used_count = {}
172 -- it's possible for an item to be in neither used_items nor recycled_items, if it's in the process of fading out
173 local recycled_items = {}
175 -- These two functions are basically identical. Combine them.
176 local function itemupdate(item, delta)
177 local done = true
179 local a = item:GetAlpha()
180 a = a + delta
182 if a < 1 then
183 item:SetAlpha(a)
184 done = false
185 else
186 item:SetAlpha(1)
189 local t = item.t + delta
191 if t < 1 then
192 item.t = t
193 local it = 1-t
194 local sp = math.sqrt(t-t*t)
195 item.x, item.y = item.sx*it+item.ex*t+(item.sy-item.ey)*sp, item.sy*it+item.ey*t+(item.ex-item.sx)*sp
196 done = false
197 else
198 item.t = 1
199 item.x, item.y = item.ex, item.ey
202 item:ClearAllPoints()
203 item:SetPoint("TOPLEFT", tracker, "TOPLEFT", item.x, -item.y)
205 if done then
206 QH_Hook(item, "OnUpdate", nil)
210 local function itemfadeout(item, delta)
211 local a = item:GetAlpha()
212 a = a - delta
214 if a > 0 then
215 item:SetAlpha(a)
216 else
217 item:SetAlpha(1)
218 item:Hide()
219 QH_Hook(item, "OnUpdate", nil)
220 table.insert(recycled_items, item)
221 return
224 local t = item.t + delta
226 if t < 1 then
227 item.t = t
228 local it = 1-t
229 local sp = math.sqrt(t-t*t)
230 item.x, item.y = item.sx*it+item.ex*t+(item.sy-item.ey)*sp, item.sy*it+item.ey*t+(item.ex-item.sx)*sp
231 else
232 item.t = 1
233 item.x, item.y = item.ex, item.ey
236 item:ClearAllPoints()
237 item:SetPoint("TOPLEFT", tracker, "TOPLEFT", item.x, -item.y)
240 --[[function QH_ToggleQuestLog() -- This seems to be gone in 3.0, so I'm adding it here.
241 if (QuestLogFrame:IsShown()) then
242 HideUIPanel(QuestLogFrame);
243 else
244 ShowUIPanel(QuestLogFrame);
248 -- Grim stuff with uberquest, I need a better way to handle this
249 local function itemclick(item, button)
250 if button == "RightButton" then
251 local quest = item.quest
252 local index = 1
253 while true do
254 local title = GetQuestLogTitle(index)
255 if not title then break end
257 if title == quest then
258 if UberQuest then
259 -- UberQuest needs a little extra effort to work properly.
261 if UberQuest_List:IsShown() and GetQuestLogSelection() == index then
262 QH_ToggleQuestLog()
263 else
264 QuestLog_SetSelection(index)
266 -- By hiding the list, the replaced ToggleQuestLog function should try to reshow it
267 -- and in the process update the frames to reflect the selected quest.
268 UberQuest_List:Hide()
269 UberQuest_Details:Show()
270 QH_ToggleQuestLog()
272 else
273 -- This code seems to work properly with the builtin questlog, as well as bEQL and DoubleWide.
275 if QuestLogFrame:IsShown() and GetQuestLogSelection() == index then
276 -- If the selected quest is already being shown, hide it.
277 QH_ToggleQuestLog()
278 else
279 -- Otherwise, select it and show it.
280 QuestLog_SetSelection(index)
282 if not QuestLogFrame:IsShown() then
283 QH_ToggleQuestLog()
288 return
291 index = index + 1
294 end]]
296 local function allocateItem()
297 local item
299 item = table.remove(recycled_items)
300 if item then return item end
302 item = CreateFrame("Frame", nil, tracker)
303 item.text = item:CreateFontString()
304 item.text:SetShadowColor(0, 0, 0, .8)
305 item.text:SetShadowOffset(1, -1)
306 item.text:SetPoint("TOPLEFT", item)
307 return item
310 local specitem_max = 1
311 local specitem_unused = {}
313 -- This is adding a *single item*. This won't be called by the main parsing loop, but it does need some serious hackery. Let's see now
314 local function addItem(objective, y, meta)
315 local obj_key = objective
316 if obj_key.cluster then obj_key = obj_key.cluster end
317 used_count[obj_key] = (used_count[obj_key] or 0) + 1
318 if not used_items[obj_key] then used_items[obj_key] = QuestHelper:CreateTable("additem used_items") end
319 local item = used_items[obj_key][used_count[obj_key]]
321 local x = meta and 4 or 20
323 if not item then
324 used_items[obj_key][used_count[obj_key]] = allocateItem()
325 item = used_items[obj_key][used_count[obj_key]]
327 if meta then
328 item.text:SetFont(QuestHelper.font.serif, 12)
329 item.text:SetTextColor(.82, .65, 0)
330 else
331 item.text:SetFont(QuestHelper.font.sans, 12)
332 item.text:SetTextColor(.82, .82, .82)
335 item.obj = objective
337 item.sx, item.sy, item.x, item.y, item.ex, item.ey, item.t = x+30, y, x, y, x, y, 0
338 QH_Hook(item, "OnUpdate", itemupdate)
339 item:SetAlpha(0)
340 item:Show()
343 item.text:SetText(item.obj.tracker_desc or "(no description)")
345 local w, h = item.text:GetWidth(), item.text:GetHeight()
346 item:SetWidth(w)
347 item:SetHeight(h)
349 if objective.tracker_clicked then
350 QH_Hook(item, "OnMouseDown", function (self, button) if button == "RightButton" then objective.tracker_clicked() end end)
351 item:EnableMouse(true)
354 if item.ex ~= x or item.ey ~= y then
355 item.sx, item.sy, item.ex, item.ey = item.x, item.y, x, y
356 item.t = 0
357 QH_Hook(item, "OnUpdate", itemupdate)
360 -- we're just going to recycle this each time
361 if item.specitem then
362 item.specitem:Hide()
363 table.insert(specitem_unused, item.specitem)
364 item.specitem = nil
367 local spacer = 0
368 -- hacky - progress only shows up if we're not on a metaobjective. wheee
369 if objective.type_quest and objective.type_quest.index and not objective.progress and GetQuestLogSpecialItemInfo(objective.type_quest.index) then
370 item.specitem = table.remove(specitem_unused)
371 if not item.specitem then
372 item.specitem = CreateFrame("BUTTON", "QH_SpecItem_" .. tostring(specitem_max), item, "WatchFrameItemButtonTemplate")
373 QuestHelper: Assert(item.specitem)
375 local rangey = _G["QH_SpecItem_" .. tostring(specitem_max) .. "HotKey"]
376 QuestHelper: Assert(rangey)
377 local fn, fh, ff = rangey:GetFont()
378 rangey:SetFont("Fonts\\ARIALN.TTF", fh, ff)
379 rangey:SetText(RANGE_INDICATOR)
380 rangey:ClearAllPoints()
381 rangey:SetPoint("BOTTOMRIGHT", item.specitem, "BOTTOMRIGHT", 0, 2)
383 specitem_max = specitem_max + 1
386 item.specitem:SetScale(0.9)
387 item.specitem:ClearAllPoints()
388 item.specitem:SetParent(item)
389 item.specitem:SetPoint("TOPRIGHT", item, "TOPLEFT", 0, 0)
391 local _, tex, charges = GetQuestLogSpecialItemInfo(objective.type_quest.index)
392 item.specitem:SetID(objective.type_quest.index)
393 SetItemButtonTexture(item.specitem, tex)
394 item.specitem.rangeTimer = -1 -- This makes the little dot go away. Why does it do that?
395 item.specitem.charges = charges
397 item.specitem:Show()
399 spacer = h
402 return w+x+4, y+h, y+h+spacer
405 local function addMetaObjective(metaobj, items, y, depth)
406 local seen_texts = QuestHelper:CreateTable("amo_seen_texts")
408 local x, spacer
409 x, y, spacer = addItem(metaobj, y, true)
410 for _, v in ipairs(items) do
411 if not v.tracker_hide_dupes or not seen_texts[v.tracker_desc] then
412 x, y = addItem(v, y, false)
413 seen_texts[v.tracker_desc] = true
416 return math.max(y, spacer), depth + #items + 1
419 local function removeUnusedItem(item)
420 item.t = 0
421 item.sx, item.sy, item.dx, item.dy = item.x, item.y, item.x+30, item.y
422 QH_Hook(item, "OnMouseDown", nil)
423 item:EnableMouse(false)
424 QH_Hook(item, "OnUpdate", itemfadeout)
426 if item.specitem then
427 item.specitem:Hide()
428 table.insert(specitem_unused, item.specitem)
429 item.specitem = nil
435 local loading_vquest = {tracker_desc = QHFormat("QH_LOADING", "0")}
436 local flightpath_vquest = {tracker_desc = QHFormat("QH_FLIGHTPATH", "0")}
437 local recalculating_vquest = {tracker_desc = QHFormat("QH_RECALCULATING", "0")}
439 local recalculating_start = nil
442 local hidden_vquest1 = { tracker_desc = QHText("QUESTS_HIDDEN_1"), tracker_clicked = QH_Hidden_Menu }
443 local hidden_vquest2 = { tracker_desc = " " .. QHText("QUESTS_HIDDEN_2"), tracker_clicked = QH_Hidden_Menu }
445 local route = {}
446 local pinned = {}
448 -- This is actually called surprisingly often.
449 function QH_Tracker_Rescan()
450 used_count = QuestHelper:CreateTable("tracker rescan used_count")
452 local mo_done = QuestHelper:CreateTable("tracker rescan mo_done")
453 local obj_done = QuestHelper:CreateTable("tracker rescan obj_done")
455 local y, depth = 0, 0
458 local had_pinned = false
460 local objs = QuestHelper:CreateTable("tracker objs")
461 for k, v in pairs(pinned) do
462 if not objs[k.why] then objs[k.why] = QuestHelper:CreateTable("tracker objs sub") end
463 if not k.ignore and not k.tracker_hidden then table.insert(objs[k.why], k) end
464 obj_done[k.cluster] = true
467 local sort_objs = QuestHelper:CreateTable("tracker sobjs")
468 for k, v in pairs(objs) do
469 v.cluster = k
470 v.trackkey = k
471 table.insert(sort_objs, v)
474 table.sort(sort_objs, function (a, b) return tostring(a.trackkey) < tostring(b.trackkey) end)
476 for _, v in ipairs(sort_objs) do
477 y, depth = addMetaObjective(v.cluster, v, y, depth)
478 had_pinned = true
479 QuestHelper:ReleaseTable(v)
481 QuestHelper:ReleaseTable(sort_objs)
482 QuestHelper:ReleaseTable(objs)
484 if had_pinned then y = y + 10 end
487 if QuestHelper.loading_main then
488 loading_vquest.tracker_desc = QHFormat("QH_LOADING", string.format("%d", QuestHelper.loading_main:GetPercentage() * 100))
489 local x, ty = addItem(loading_vquest, y)
490 y = ty + 10
492 if QuestHelper.flightpathing then
493 flightpath_vquest.tracker_desc = QHFormat("QH_FLIGHTPATH", string.format("%d", QuestHelper.flightpathing:GetPercentage() * 100))
494 local x, ty = addItem(flightpath_vquest, y)
495 y = ty + 10
497 if not QuestHelper.loading_main and not QuestHelper.flightpathing and QuestHelper.route_change_progress then
498 if recalculating_start then
499 if recalculating_start + 5 < GetTime() then
500 recalculating_vquest.tracker_desc = QHFormat("QH_RECALCULATING", string.format("%d", QuestHelper.route_change_progress:GetPercentage() * 100))
501 local x, ty = addItem(recalculating_vquest, y)
502 y = ty + 10
504 else
505 recalculating_start = GetTime()
507 else
508 recalculating_start = nil
511 local metalookup = QuestHelper:CreateTable("tracker rescan metalookup")
512 for k, v in ipairs(route) do
513 if not v.ignore then
514 if not metalookup[v.why] then metalookup[v.why] = QuestHelper:CreateTable("tracker rescan metalookup item") end
515 if not v.tracker_hidden then table.insert(metalookup[v.why], v) end
520 local current_mo
521 local current_mo_cluster
522 for k, v in ipairs(route) do
523 if depth > QuestHelper_Pref.track_size and not debug_output then break end
524 if not v.ignore and not v.why.tracker_hidden and not obj_done[v.cluster] then
525 if current_mo and v.why ~= current_mo and (v.why.tracker_split or not mo_done[v.why]) then
526 y, depth = addMetaObjective(current_mo, current_mo_cluster, y, depth)
527 QuestHelper:ReleaseTable(current_mo_cluster)
528 current_mo, current_mo_cluster = nil, nil
531 if not v.why.tracker_split then
532 if not mo_done[v.why] then
533 y, depth = addMetaObjective(v.why, metalookup[v.why], y, depth)
534 mo_done[v.why] = true
536 else
537 if not current_mo then
538 current_mo = v.why
539 current_mo_cluster = QuestHelper:CreateTable("tracker current cluster")
541 if not v.tracker_hidden then table.insert(current_mo_cluster, v) end
544 obj_done[v] = true
547 if current_mo and not (depth > QuestHelper_Pref.track_size and not debug_output) then
548 y, depth = addMetaObjective(current_mo, current_mo_cluster, y, depth)
550 if current_mo_cluster then
551 QuestHelper:ReleaseTable(current_mo_cluster)
555 -- now we check to see if we need a hidden display
556 if (debug_output or depth < QuestHelper_Pref.track_size) and not QuestHelper.loading_main and not QuestHelper_Pref.filter_done and not QuestHelper_Pref.filter_zone and not QuestHelper_Pref.filter_watched then
557 local show = false
559 QH_Route_TraverseClusters(
560 function (clust)
561 if not show then
562 QH_Route_IgnoredReasons_Cluster(clust, function (reason)
563 show = true
564 end)
566 for _, v in ipairs(clust) do
567 QH_Route_IgnoredReasons_Node(v, function (reason)
568 show = true
569 end)
575 if show then
576 y = y + 10
577 _, y = addItem(hidden_vquest1, y)
578 _, y = addItem(hidden_vquest2, y)
583 -- any manipulations of the tracker should be done by now, everything after this is bookkeeping
585 for k, v in pairs(used_items) do
586 if not used_count[k] or used_count[k] < #v then
587 local ttp = QuestHelper:CreateTable("used_items ttp")
588 for m = 1, (used_count[k] or 0) do
589 table.insert(ttp, v[m])
591 for m = (used_count[k] or 0) + 1, #v do
592 removeUnusedItem(v[m])
595 if used_items[k] then
596 QuestHelper:ReleaseTable(used_items[k])
599 if #ttp > 0 then
600 used_items[k] = ttp
601 else
602 used_items[k] = nil
603 QuestHelper:ReleaseTable(ttp)
608 QuestHelper:ReleaseTable(mo_done)
609 QuestHelper:ReleaseTable(obj_done)
610 for k, v in pairs(metalookup) do
611 QuestHelper:ReleaseTable(v)
613 QuestHelper:ReleaseTable(metalookup)
615 QuestHelper:ReleaseTable(used_count)
616 used_count = nil
618 if y ~= tracker.dh then
619 tracker.t = 0
620 tracker.sh = tracker:GetHeight()
621 tracker.dh = y
622 tracker.sw = tracker.dw
623 resizing = true
627 function QH_Tracker_UpdateRoute(new_route)
628 route = new_route
629 QH_Tracker_Rescan()
632 function QH_Tracker_Pin(metaobjective, suppress)
633 if not pinned[metaobjective] then
634 pinned[metaobjective] = true
636 if not suppress then
637 QH_Tracker_Rescan()
642 function QH_Tracker_Unpin(metaobjective, suppress)
643 if pinned[metaobjective] then
644 pinned[metaobjective] = nil -- nil, not false, so it'll be garbage-collected appropriately
646 if not suppress then
647 QH_Tracker_Rescan()
652 function QH_Tracker_SetPin(metaobjective, flag, suppress)
653 if flag then
654 QH_Tracker_Pin(metaobjective, suppress)
655 else
656 QH_Tracker_Unpin(metaobjective, suppress)
661 local check_delay = 4
663 -- This function does the grunt work of cursor positioning and rescaling. It does not actually reorganize items.
664 function tracker:update(delta)
665 if not delta then
666 -- This is called without a value when the questlog is updated.
667 -- We'll make sure we update the display on the next update.
668 check_delay = 1e99
669 return
672 if resizing then
673 local t = self.t+delta
675 if t > 1 then
676 self:SetWidth(self.dw)
677 self:SetHeight(self.dh)
678 resizing = false
679 else
680 self.t = t
681 local it = 1-t
682 self:SetWidth(self.sw*it+self.dw*t)
683 self:SetHeight(self.sh*it+self.dh*t)
687 -- Manually checking if the mouse is in the frame, because if I used on OnEnter, i'd have to enable mouse input,
688 -- and if I did that, it would prevent the player from using the mouse to change the view if they clicked inside
689 -- the tracker.
690 local x, y = GetCursorPosition()
691 local s = 1/self:GetEffectiveScale()
692 x, y = x*s, y*s
694 QuestHelper: Assert(x)
695 QuestHelper: Assert(y)
696 --[[ QuestHelper: Assert(self:GetLeft())
697 QuestHelper: Assert(self:GetBottom())
698 QuestHelper: Assert(self:GetRight())
699 QuestHelper: Assert(self:GetTop())]]
701 -- Sometimes it just doesn't know its own coordinates. Not sure why. Maybe this will fix it.
702 local inside = (self:GetLeft() and (x >= self:GetLeft() and y >= self:GetBottom() and x < self:GetRight() and y < self:GetTop()))
703 if inside ~= was_inside then
704 was_inside = inside
705 if inside then
706 SetEnteredTracker(true)
707 else
708 SetEnteredTracker(false)
712 check_delay = check_delay + delta
713 if check_delay > 1 then
714 check_delay = 0
716 QH_Tracker_Rescan()
720 QH_Hook(tracker, "OnUpdate", tracker.update)
722 -- Some hooks to update the tracker when quests are added or removed. These should be moved into the quest director.
723 --[[
724 local orig_AddQuestWatch, orig_RemoveQuestWatch = AddQuestWatch, RemoveQuestWatch
726 function AddQuestWatch(...)
727 tracker:update()
728 return orig_AddQuestWatch(...)
731 function RemoveQuestWatch(...)
732 tracker:update()
733 return orig_RemoveQuestWatch(...)
734 end]]
736 -------------------------------------------------------------------------------------------------
737 -- This batch of stuff is to make sure the original tracker (and any modifications) stay hidden
739 local orig_TrackerBackdropOnShow -- bEQL (and perhaps other mods) add a backdrop to the tracker
740 local TrackerBackdropFound = false
742 local function TrackerBackdropOnShow(self, ...)
743 if QuestHelper_Pref.track and not QuestHelper_Pref.hide then
744 TrackerBackdropFound:Hide()
747 if orig_TrackerBackdropOnShow then
748 return orig_TrackerBackdropOnShow(self, ...)
752 function tracker:HideDefaultTracker()
753 -- The easy part: hide the original tracker
754 WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests)
755 WatchFrame_ClearDisplay()
756 WatchFrame_Update()
758 -- The harder part: hide all those little buttons
760 local index = 1
761 while true do
762 local orig = _G["WatchFrameItem" .. tostring(index)]
763 if orig then orig:Hide() else break end
764 index = index + 1
768 -- The harder part: check if a known backdrop is present (but we don't already know about it).
769 -- If it is, make sure it's hidden, and hook its OnShow to make sure it stays that way.
770 -- Unfortunately, I can't figure out a good time to check for this once, so we'll just have
771 -- to keep checking. Hopefully, this won't happen too often.
772 if not TrackerBackdropFound then
773 if QuestWatchFrameBackdrop then
774 -- Found bEQL's QuestWatchFrameBackdrop...
775 TrackerBackdropFound = QuestWatchFrameBackdrop
778 if TrackerBackdropFound then
779 -- OK, we found something - so hide it, and make sure it doesn't rear its ugly head again
780 TrackerBackdropFound:Hide()
782 orig_TrackerBackdropOnShow = TrackerBackdropFound:GetScript("OnShow")
783 QH_Hook(TrackerBackdropFound, "OnShow", TrackerBackdropOnShow)
788 function tracker:ShowDefaultTracker()
789 -- I like how there's code explicitly to allow us to do this without checking if it's already added
790 WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
791 -- Make sure the default tracker is up to date on what what's being watched and what isn't.
792 WatchFrame_Update()
794 if TrackerBackdropFound then
795 TrackerBackdropFound:Show()
799 function QuestHelper:ShowTracker()
800 tracker:HideDefaultTracker()
801 minbutton:Show()
803 RefreshColor()
804 if not QuestHelper_Pref.track_minimized then
805 tracker:Show()
809 function QuestHelper:HideTracker()
810 tracker:ShowDefaultTracker()
811 tracker:Hide()
812 minbutton:Hide()