aha, figured out that weird problem with split objectives
[QuestHelper.git] / help.lua
blob29cbd034e213316b154719551cdc927542e38d6e
1 QuestHelper_File["help.lua"] = "Development Version"
2 QuestHelper_Loadtime["help.lua"] = GetTime()
4 local QuestHelper_Version = QuestHelper_File["help.lua"]
6 function QuestHelper:scaleString(val)
7 return self:HighlightText(math.floor(val*100+0.5).."%")
8 end
10 function QuestHelper:genericSetScale(varname, name, mn, mx, input, onchange, ...)
11 if input == "" then
12 self:TextOut(string.format("Current %s scale is %s.", name, self:scaleString(QuestHelper_Pref[varname])))
13 else
14 local scale = tonumber(input)
16 if not scale then
17 local x = string.match(input or "", "^%s*([%d%.]+)%s*%%%s*$")
18 scale = tonumber(x) or 0
19 if not scale then
20 self:TextOut("I don't know how to interpret your input.")
21 return
22 end
23 scale = scale * 0.01
24 end
26 if scale < mn then
27 self:TextOut(string.format("I won't accept a scale less than %s.", self:scaleString(mn)))
28 elseif scale > mx then
29 self:TextOut(string.format("I won't accept a scale more than %s.", self:scaleString(mx)))
30 else
31 QuestHelper_Pref[varname] = scale
32 self:TextOut(string.format("Set %s scale set to %s.", name, self:scaleString(scale)))
33 if onchange then
34 onchange(...)
35 end
36 end
37 end
38 end
40 function QuestHelper:TrackerScale(scale)
41 QuestHelper:genericSetScale("track_scale", "tracker scale", .5, 2, scale,
42 function() QuestHelper.tracker:SetScale(QuestHelper_Pref.track_scale) end)
43 end
45 function QuestHelper:SetLocale(loc)
46 if not loc or loc == "" then
47 self:TextOut(QHText("LOCALE_LIST_BEGIN"))
48 for loc, tbl in pairs(QuestHelper_Translations) do
49 self:TextOut(string.format(" %s%s %s", self:HighlightText(loc),
50 loc == QuestHelper_Pref.locale and " *" or " ",
51 tbl.LOCALE_NAME or "???"))
52 end
53 else
54 for l, tbl in pairs(QuestHelper_Translations) do
55 if string.find(string.lower(l), "^"..string.lower(loc)) or
56 string.find(string.lower(tbl.LOCALE_NAME or ""), "^"..string.lower(loc)) then
57 QuestHelper_Pref.locale = l
58 QHFormatSetLocale(l)
59 self:SetLocaleFonts()
60 self:TextOut(QHFormat("LOCALE_CHANGED", l))
61 return
62 end
63 end
65 self:TextOut(QHFormat("LOCALE_UNKNOWN", tostring(loc) or "UNKNOWN"))
66 end
67 end
69 function QuestHelper:ToggleMetric()
70 QuestHelper_Pref.metric = not QuestHelper_Pref.metric
72 if QuestHelper_Pref.metric then
73 self:TextOut("Distances are now in metres.")
74 else
75 self:TextOut("Distances are now in yards.")
76 end
77 end
79 function QuestHelper:ToggleHide()
80 QuestHelper_Pref.hide = not QuestHelper_Pref.hide
82 -- Desaturate the button texture if QuestHelper is disabled.
83 if self.MapButton then
84 -- This should always be true, but just in case...
85 self.MapButton:GetNormalTexture():SetDesaturated(QuestHelper_Pref.hide)
86 end
88 if QuestHelper_Pref.hide then
89 if QuestHelper_Pref.track then
90 self:HideTracker()
91 end
93 self.map_overlay:Hide()
94 self:TextOut("QuestHelper is now |cffff0000hidden|r.")
95 else
96 if QuestHelper_Pref.track then
97 self:ShowTracker()
98 end
100 self.map_overlay:Show()
101 self.minimap_marker:Show()
102 self:TextOut("QuestHelper is now |cff00ff00shown|r.")
104 QH_Timeslice_Bonus(20) -- Let the corutine do some overtime...
108 function QuestHelper:ToggleShare()
109 QuestHelper_Pref.share = not QuestHelper_Pref.share
110 if QuestHelper_Pref.share then
111 if QuestHelper_Pref.solo then
112 self:TextOut("Objective sharing will been |cff00ff00enabled|r when you disable solo mode.")
113 else
114 self:TextOut("Objective sharing has been |cff00ff00enabled|r.")
115 self:SetShare(true)
117 else
118 self:TextOut("Objective sharing has been |cffff0000disabled|r.")
119 if QuestHelper_Pref.solo then
120 self:TextOut("Objective sharing won't be reenabled when you disable solo mode.")
121 else
122 self:SetShare(false)
127 function QuestHelper:ToggleFlightTimes()
128 QuestHelper_Pref.flight_time = not QuestHelper_Pref.flight_time
129 if QuestHelper_Pref.flight_time then
130 self:TextOut("The flight timer has been |cff00ff00enabled|r.")
131 else
132 self:TextOut("The flight timer has been |cffff0000disabled|r.")
136 function QuestHelper:ToggleTravelTimes()
137 QuestHelper_Pref.travel_time = not QuestHelper_Pref.travel_time
138 if QuestHelper_Pref.travel_time then
139 self:TextOut("The travel timer has been |cff00ff00enabled|r.")
140 else
141 self:TextOut("The travel timer has been |cffff0000disabled|r.")
145 function QuestHelper:ToggleTrack()
146 QuestHelper_Pref.track = not QuestHelper_Pref.track
147 if QuestHelper_Pref.track then
148 self:ShowTracker()
149 self:TextOut("The quest tracker has been |cff00ff00enabled|r.")
150 else
151 self:HideTracker()
152 self:TextOut("The quest tracker has been |cffff0000disabled|r.")
156 function QuestHelper:ToggleBlizzMap()
157 QuestHelper_Pref.blizzmap = not QuestHelper_Pref.blizzmap
158 if QuestHelper_Pref.blizzmap then
159 self:TextOut("The Blizzard quest points have been |cff00ff00enabled|r.")
160 else
161 self:TextOut("The Blizzard quest points have been |cffff0000disabled|r.")
164 if UpdateQuestMapPOI then UpdateQuestMapPOI() end
167 if UpdateQuestMapPOI then
168 local uqmp_def = UpdateQuestMapPOI
169 function UpdateQuestMapPOI(...)
170 if QuestHelper_Pref.blizzmap then
171 return uqmp_def(...)
172 else
173 for i = 1, #QUEST_MAP_POI do
174 QUEST_MAP_POI[i]:Hide()
180 function QuestHelper:ToggleTrackLevel()
181 QuestHelper_Pref.track_level = not QuestHelper_Pref.track_level
182 if QuestHelper_Pref.track_level then
183 self:TextOut("Display of levels in the quest tracker has been |cff00ff00enabled|r.")
184 else
185 self:TextOut("Display of levels in the quest tracker has been |cffff0000disabled|r.")
187 QH_UpdateQuests(true)
188 QH_Tracker_Rescan()
191 function QuestHelper:ToggleTrackQColour()
192 QuestHelper_Pref.track_qcolour = not QuestHelper_Pref.track_qcolour
193 if QuestHelper_Pref.track_qcolour then
194 self:TextOut("Colour for quest difficulty in quest tracker has been |cff00ff00enabled|r.")
195 else
196 self:TextOut("Colour for quest difficulty in quest tracker has been |cffff0000disabled|r.")
198 QH_UpdateQuests(true)
199 QH_Tracker_Rescan()
202 function QuestHelper:ToggleTrackOColour()
203 QuestHelper_Pref.track_ocolour = not QuestHelper_Pref.track_ocolour
204 if QuestHelper_Pref.track_ocolour then
205 self:TextOut("Colour for objective progress in quest tracker has been |cff00ff00enabled|r.")
206 else
207 self:TextOut("Colour for objective progress in quest tracker has been |cffff0000disabled|r.")
209 QH_UpdateQuests(true)
210 QH_Tracker_Rescan()
213 function QuestHelper:ToggleTooltip()
214 QuestHelper_Pref.tooltip = not QuestHelper_Pref.tooltip
215 if QuestHelper_Pref.tooltip then
216 self:TextOut("Objective tooltip information has been |cff00ff00enabled|r.")
217 else
218 self:TextOut("Objective tooltip information has been |cffff0000disabled|r.")
222 function QuestHelper:Purgewarning()
223 QuestHelper:TextOut("I would consider this a tragic loss, and would appreciate it if you sent me your saved data before going through with it.")
224 QuestHelper:TextOut("Enter "..self:HighlightText("/qh nag verbose").." to check and see if you're destroying anything important.")
225 QuestHelper:TextOut("Enter "..self:HighlightText("/qh submit").." for instructions on how to submit your collected data.")
226 QuestHelper:TextOut("See the "..self:HighlightText("How You Can Help").." section on the project website for instructions.")
229 function QuestHelper:Purge(code, force, noreload)
230 if code == self.purge_code or force then
231 QuestHelper_Quests = nil
232 QuestHelper_Objectives = nil
233 QuestHelper_FlightInstructors = nil
234 QuestHelper_FlightRoutes = nil
235 QuestHelper_Locale = nil
236 QuestHelper_UID = nil
237 QuestHelper_Version = nil
238 QuestHelper_SaveVersion = nil
240 QuestHelper_SaveDate = nil
241 QuestHelper_SeenRealms = nil
243 QuestHelper_Collector = nil
244 QuestHelper_Collector_Version = nil
246 QuestHelper_Errors = nil -- sigh
248 if not noreload then ReloadUI() end
249 else
250 if not self.purge_code then self.purge_code = self:CreateUID(8) end
251 QuestHelper:TextOut("THIS COMMAND WILL DELETE ALL YOUR COLLECTED DATA")
252 QuestHelper:Purgewarning()
253 QuestHelper:TextOut("If you're sure you want to go through with this, enter: "..self:HighlightText("/qh purge "..self.purge_code))
257 function QuestHelper:HardReset(code)
258 if code == self.purge_code then
259 self:ResetTrackerPosition() -- do this before we kill off the prefs, since it touches a pref
260 QH_Arrow_Reset()
261 QuestHelper_Pref = nil
262 QuestHelper_ErrorList = nil -- BIZAM
263 QuestHelper_KnownFlightRoutes = nil
264 QuestHelper_Home = nil
265 QuestHelper_CharVersion = nil
266 self:Purge(nil, true)
267 else
268 if not self.purge_code then self.purge_code = self:CreateUID(8) end
269 QuestHelper:TextOut("THIS COMMAND WILL DELETE ALL YOUR COLLECTED DATA AND RESET ALL YOUR PREFERENCES")
270 QuestHelper:Purgewarning()
271 QuestHelper:TextOut("If you're sure you want to go through with this, enter: "..self:HighlightText("/qh hardreset "..self.purge_code))
275 function QuestHelper:ToggleSolo()
276 QuestHelper_Pref.solo = not QuestHelper_Pref.solo
277 if QuestHelper_Pref.solo then
278 if QuestHelper_Pref.share then
279 self:SetShare(false)
280 self:TextOut("Objective sharing has been temporarly |cffff0000disabled|r.")
282 self:TextOut("Solo mode has been |cff00ff00enabled|r.")
283 else
284 self:TextOut("Solo mode has been |cffff0000disabled|r.")
285 if QuestHelper_Pref.share then
286 self:SetShare(true)
287 self:TextOut("Objective sharing has been re|cff00ff00enabled|r.")
292 function QuestHelper:ToggleAnts()
293 if QuestHelper_Pref.show_ants then
294 QuestHelper_Pref.show_ants = false
295 self:TextOut("Ant trails have been |cffff0000disabled|r.")
296 else
297 QuestHelper_Pref.show_ants = true
298 self:TextOut("Ant trails have been |cff00ff00enabled|r.")
302 function QuestHelper:SetZones()
303 if QuestHelper_Pref.zones == "next" then
304 QuestHelper_Pref.zones = "none"
305 self:TextOut("Next zone display has been |cffff0000disabled|r.")
306 else
307 QuestHelper_Pref.zones = "next"
308 self:TextOut("Next zone display has been |cff00ff00enabled|r.")
312 function QuestHelper:LevelOffset(offset)
313 local level = tonumber(offset)
314 if level then
315 if level > 0 then
316 self:TextOut("Allowing quests up to "..self:HighlightText(level).." level"..(level==1 and " " or "s ")..self:HighlightText("above").." you.")
317 elseif level < 0 then
318 self:TextOut("Only allowing quests "..self:HighlightText(-level).." level"..(level==-1 and " " or "s ")..self:HighlightText("below").." you.")
319 else
320 self:TextOut("Only allowing quests "..self:HighlightText("at or below").." your current level.")
323 if not QuestHelper_Pref.filter_level then
324 self:TextOut("Note: This won't have any effect until you turn the level filter on.")
327 if QuestHelper_Pref.level ~= level then
328 QuestHelper_Pref.level = level
329 QH_Route_Filter_Rescan("filter_quest_level")
331 elseif offset == "" then
332 if QuestHelper_Pref.level <= 0 then
333 self:TextOut("Level offset is currently set to "..self:HighlightText(QuestHelper_Pref.level)..".")
334 else
335 self:TextOut("Level offset is currently set to "..self:HighlightText("+"..QuestHelper_Pref.level)..".")
338 if self.party_levels then for n, l in ipairs(self.party_levels) do
339 self:TextOut("Your effective level in a "..self:HighlightText(n).." player quest is "..self:HighlightText(string.format("%.1f", l))..".")
340 end end
342 if QuestHelper_Pref.solo then
343 self:TextOut("Peers aren't considered in your effective level, because you're playing solo.")
345 else
346 self:TextOut("Expected a level offset.")
350 function QuestHelper:GroupOffset(offset)
351 local group = tonumber(offset)
352 if offset == "instance" then group = 5 end
353 if offset == "raid" then group = 10 end
354 if group == 0 then group = 1 end
355 if group then
356 self:TextOut("Allowing quests requiring at most "..self:HighlightText(group).." player"..(group==1 and " " or "s ")..".")
358 if not QuestHelper_Pref.filter_group then
359 self:TextOut("Note: This won't have any effect until you turn the group filter on.")
362 QuestHelper_Pref.filter_group_param = group
363 QH_Route_Filter_Rescan("filter_quest_level")
364 elseif offset == "" then
365 self:TextOut("Group cutoff is currently set to "..self:HighlightText(QuestHelper_Pref.filter_group_param)..".")
366 else
367 self:TextOut("Expected a player count.")
371 function QuestHelper:Filter(input)
372 input = string.upper(input)
373 if input == "ZONE" then
374 QuestHelper_Pref.filter_zone = not QuestHelper_Pref.filter_zone
375 self:TextOut("Filter "..self:HighlightText("zone").." set to "..self:HighlightText(QuestHelper_Pref.filter_zone and "active" or "inactive")..".")
376 QH_Route_Filter_Rescan("filter_zone")
377 elseif input == "DONE" then
378 QuestHelper_Pref.filter_done = not QuestHelper_Pref.filter_done
379 self:TextOut("Filter "..self:HighlightText("done").." set to "..self:HighlightText(QuestHelper_Pref.filter_done and "active" or "inactive")..".")
380 QH_Route_Filter_Rescan("filter_quest_done")
381 elseif input == "LEVEL" then
382 QuestHelper_Pref.filter_level = not QuestHelper_Pref.filter_level
383 self:TextOut("Filter "..self:HighlightText("level").." set to "..self:HighlightText(QuestHelper_Pref.filter_level and "active" or "inactive")..".")
384 QH_Route_Filter_Rescan("filter_quest_level")
385 elseif input == "GROUP" then
386 QuestHelper_Pref.filter_group = not QuestHelper_Pref.filter_group
387 self:TextOut("Filter "..self:HighlightText("group").." set to "..self:HighlightText(QuestHelper_Pref.filter_group and "active" or "inactive")..".")
388 QH_Route_Filter_Rescan("filter_quest_group")
389 elseif input == "BLOCKED" or input == "BLOCK" then
390 QuestHelper_Pref.filter_blocked = not QuestHelper_Pref.filter_blocked
391 self:TextOut("Filter "..self:HighlightText("blocked").." set to "..self:HighlightText(QuestHelper_Pref.filter_blocked and "active" or "inactive")..".")
392 QH_Route_Filter_Rescan("filter_blocked")
393 elseif input == "WATCHED" or input == "WATCH" then
394 QuestHelper_Pref.filter_watched = not QuestHelper_Pref.filter_watched
395 self:TextOut("Filter "..self:HighlightText("watched").." set to "..self:HighlightText(QuestHelper_Pref.filter_watched and "active" or "inactive")..".")
396 QH_Route_Filter_Rescan("filter_quest_watched")
397 elseif input == "WINTERGRASP" or input == "WG" then
398 QuestHelper_Pref.filter_wintergrasp = not QuestHelper_Pref.filter_wintergrasp
399 self:TextOut("Filter "..self:HighlightText("wintergrasp").." set to "..self:HighlightText(QuestHelper_Pref.filter_wintergrasp and "active" or "inactive")..".")
400 QH_Route_Filter_Rescan("filter_quest_wintergrasp")
401 elseif input == "RAIDACCESSIBLE" or input == "RA" then
402 QuestHelper_Pref.filter_raid_accessible = not QuestHelper_Pref.filter_raid_accessible
403 self:TextOut("Filter "..self:HighlightText("raidaccessible").." set to "..self:HighlightText(QuestHelper_Pref.filter_raid_accessible and "active" or "inactive")..".")
404 QH_Route_Filter_Rescan("filter_quest_raid_accessible")
405 elseif input == "" then
406 self:TextOut("Filter "..self:HighlightText("zone")..": "..self:HighlightText(QuestHelper_Pref.filter_zone and "active" or "inactive"))
407 self:TextOut("Filter "..self:HighlightText("level")..": "..self:HighlightText(QuestHelper_Pref.filter_level and "active" or "inactive"))
408 self:TextOut("Filter "..self:HighlightText("group")..": "..self:HighlightText(QuestHelper_Pref.filter_group and "active" or "inactive"))
409 self:TextOut("Filter "..self:HighlightText("done")..": "..self:HighlightText(QuestHelper_Pref.filter_done and "active" or "inactive"))
410 self:TextOut("Filter "..self:HighlightText("blocked")..": "..self:HighlightText(QuestHelper_Pref.filter_blocked and "active" or "inactive"))
411 self:TextOut("Filter "..self:HighlightText("watched")..": "..self:HighlightText(QuestHelper_Pref.filter_watched and "active" or "inactive"))
412 self:TextOut("Filter "..self:HighlightText("wintergrasp")..": "..self:HighlightText(QuestHelper_Pref.filter_wintergrasp and "active" or "inactive"))
413 self:TextOut("Filter "..self:HighlightText("raidaccessible")..": "..self:HighlightText(QuestHelper_Pref.filter_raid_accessible and "active" or "inactive"))
414 else
415 self:TextOut("Don't know what you want filtered, expect "..self:HighlightText("zone")..", "..self:HighlightText("done")..", "..self:HighlightText("level")..", "..self:HighlightText("group")..", "..self:HighlightText("blocked")..", "..self:HighlightText("watched")..", "..self:HighlightText("wintergrasp")..", or "..self:HighlightText("raidaccessible")..".")
419 function QuestHelper:ToggleArrow(text)
420 if text == "reset" then QH_Arrow_Reset() return end
422 QuestHelper_Pref.arrow = not QuestHelper_Pref.arrow
423 if QuestHelper_Pref.arrow then
424 QH_Arrow_Show()
425 self:TextOut(QHFormat("SETTINGS_ARROWLINK_ON", QHText("SETTINGS_ARROWLINK_ARROW")))
426 else
427 self:TextOut(QHFormat("SETTINGS_ARROWLINK_OFF", QHText("SETTINGS_ARROWLINK_ARROW")))
431 function QuestHelper:ToggleCartWP()
432 QuestHelper_Pref.cart_wp_new = not QuestHelper_Pref.cart_wp_new
433 if QuestHelper_Pref.cart_wp_new then
434 self:EnableCartographer()
435 if Cartographer_Waypoints then
436 if Waypoint and Waypoint.prototype then
437 self:TextOut("Would use "..self:HighlightText("Cartographer Waypoints").." to show objectives, but another mod is interfering with it.")
438 else
439 self:TextOut(QHFormat("SETTINGS_ARROWLINK_ON", QHText("SETTINGS_ARROWLINK_CART")))
441 else
442 self:TextOut("Would use "..self:HighlightText("Cartographer Waypoints").." to show objectives, except it doesn't seem to be present.")
444 else
445 self:DisableCartographer()
446 self:TextOut(QHFormat("SETTINGS_ARROWLINK_OFF", QHText("SETTINGS_ARROWLINK_CART")))
450 function QuestHelper:ToggleTomTomWP()
451 QuestHelper_Pref.tomtom_wp_new = not QuestHelper_Pref.tomtom_wp_new
452 if QuestHelper_Pref.tomtom_wp_new then
453 self:EnableTomTom()
454 if TomTom then
455 self:TextOut(QHFormat("SETTINGS_ARROWLINK_ON", QHText("SETTINGS_ARROWLINK_TOMTOM")))
456 else
457 self:TextOut("Would use "..self:HighlightText("TomTom").." to show objectives, except it doesn't seem to be present.")
459 else
460 self:DisableTomTom()
461 self:TextOut(QHFormat("SETTINGS_ARROWLINK_OFF", QHText("SETTINGS_ARROWLINK_TOMTOM")))
465 function QuestHelper:PrintVersion()
466 self:TextOut("Version: "..self:HighlightText(GetAddOnMetadata("QuestHelper", "Version") or "Unknown"))
469 local function RecycleStatusString(fmt, usedcount, freetable, usedtable)
470 local freetablecount = QuestHelper:TableSize(freetable)
471 if usedtable then
472 local usedtablecount = QuestHelper:TableSize(usedtable)
473 return string.format(fmt, QuestHelper:ProgressString(string.format("%d/%d", usedtablecount, usedtablecount+freetablecount), ((usedtablecount+freetablecount == 0) and 1) or (1-usedtablecount/(usedtablecount+freetablecount)))) .. string.format(" (%d \"leaked\")", usedcount - usedtablecount)
474 else
475 return string.format(fmt, QuestHelper:ProgressString(string.format("%d/%d", usedcount, usedcount+freetablecount), ((usedcount+freetablecount == 0) and 1) or (1-usedcount/(usedcount+freetablecount))))
479 function QuestHelper:Top(cmd)
480 if cmd and string.find(cmd, "all") then
481 cmd = cmd .. " collected recycle clear boot usage"
484 if cmd and string.find(cmd, "boot") then
485 local bootv = {}
486 for k, v in pairs(QuestHelper_Loadtime) do
487 table.insert(bootv, {time = v, file = k})
489 table.sort(bootv, function (a, b) return a.time < b.time end)
491 if string.find(cmd, "sort") then
492 local boott = {}
493 for i = 1, #bootv - 1 do
494 table.insert(boott, {time = bootv[i + 1].time - bootv[i].time, file = bootv[i].file})
496 table.sort(boott, function(a, b) return a.time < b.time end)
498 for _, v in pairs(boott) do
499 QuestHelper:TextOut(string.format("%s: %f", v.file, v.time))
501 QuestHelper:TextOut(string.format("%s: shrug", bootv[#bootv].file))
502 else
503 for i = 1, #bootv do
504 QuestHelper:TextOut(string.format("%f: %s", bootv[i].time - bootv[1].time, bootv[i].file))
509 local pre_ttf
510 local pre_db
511 if cmd and string.find(cmd, "collected") then
512 pre_ttf = self:DumpTableTypeFrequencies(true)
513 pre_db = DB_DumpItems()
516 if cmd and string.find(cmd, "recycle") then
517 self:DumpTableTypeFrequencies()
518 self:TextOut(RecycleStatusString("Using %s lua tables.", self.used_tables, self.free_tables, self.recycle_tabletyping))
519 self:TextOut(RecycleStatusString("Using %s texture objects.", self.used_textures, self.free_textures))
520 self:TextOut(RecycleStatusString("Using %s font objects.", self.used_text, self.free_text))
521 self:TextOut(RecycleStatusString("Using %s frame objects.", self.used_frames, self.free_frames))
524 if cmd and string.find(cmd, "usage") then
525 self:DumpTableTypeFrequencies()
528 if cmd and string.find(cmd, "cache") then
529 self:DumpCacheData()
532 if cmd and string.find(cmd, "perf") then
533 QH_Timeslice_DumpPerf()
536 local uncd = 0
537 for k, v in pairs(QuestHelper_Collector) do
538 if not v.compressed then uncd = uncd + 1 end
540 uncd = uncd - 1
541 local uncs = ""
542 if uncd > 0 then
543 uncs = string.format(" (%d uncompressed IDs)", uncd)
546 UpdateAddOnMemoryUsage()
547 local pre_gc = GetAddOnMemoryUsage("QuestHelper")
549 collectgarbage("collect")
551 UpdateAddOnMemoryUsage()
552 local post_gc = GetAddOnMemoryUsage("QuestHelper")
554 if cmd and string.find(cmd, "collected") then
555 local post_ttf = self:DumpTableTypeFrequencies(true)
557 local union = {}
558 for k, v in pairs(pre_ttf) do union[k] = (pre_ttf[k] or 0) - (post_ttf[k] or 0) end
559 for k, v in pairs(post_ttf) do union[k] = (pre_ttf[k] or 0) - (post_ttf[k] or 0) end
561 local sorted = {}
562 for k, v in pairs(union) do
563 table.insert(sorted, {k = k, d = v})
566 table.sort(sorted, function(a, b) return a.d < b.d end)
567 for _, v in pairs(sorted) do
568 if v.d > 0 then
569 QuestHelper:TextOut(string.format("%d: %s", v.d, v.k))
573 local post_db = DB_DumpItems()
575 local st = {}
576 for k, v in pairs(pre_db) do
577 if not post_db[k] then
578 table.insert(st, k)
581 table.sort(st)
583 for _, v in ipairs(st) do
584 QuestHelper:TextOut("DB: " .. v)
588 self:TextOut(string.format("QuestHelper is using %dkb (pre-collect %dkb) of RAM (%s/%s/%s/%s)%s", post_gc, pre_gc, QuestHelper_local_version, QuestHelper_toc_version, GetBuildInfo(), GetLocale(), uncs))
590 if cmd and string.find(cmd, "clear") then
591 local cleared = QH_ClearPathcache()
593 collectgarbage("collect")
594 UpdateAddOnMemoryUsage()
595 local new_post_gc = GetAddOnMemoryUsage("QuestHelper")
596 self:TextOut(string.format("QuestHelper is using %dkb/%dkb/%dkb (%d pathcache cleared) of RAM (%s/%s/%s/%s)%s", pre_gc, post_gc, new_post_gc, cleared, QuestHelper_local_version, QuestHelper_toc_version, GetBuildInfo(), GetLocale(), uncs))
598 local cleared = QuestHelper:RecycleClear()
600 collectgarbage("collect")
601 UpdateAddOnMemoryUsage()
602 local new_post_gc_2 = GetAddOnMemoryUsage("QuestHelper")
603 self:TextOut(string.format("QuestHelper is using %dkb/%dkb/%dkb/%dkb (%d recycle cleared) of RAM (%s/%s/%s/%s)%s", pre_gc, post_gc, new_post_gc, new_post_gc_2, cleared, QuestHelper_local_version, QuestHelper_toc_version, GetBuildInfo(), GetLocale(), uncs))
607 function QuestHelper:ToggleMapButton()
608 QuestHelper_Pref.map_button = not QuestHelper_Pref.map_button
610 if QuestHelper_Pref.map_button then
611 QuestHelper:InitMapButton()
612 self:TextOut("Map button has been |cff00ff00enabled|r.")
613 else
614 QuestHelper:HideMapButton()
615 self:TextOut("Map button has been |cffff0000disabled|r. Use '/qh button' to restore it.")
619 function QuestHelper:ChangeLog()
620 self:ShowText(QuestHelper_ChangeLog, string.format("QuestHelper %s ChangeLog", QuestHelper_Version))
623 function QuestHelper:Submit()
624 self:ShowText([[
625 |TInterface\AddOns\QuestHelper\Art\Upload.tga:100:300|t
626 Your data can't be submitted automatically, since AddOns can't interact with anything outside of World of Warcraft.
628 To do this would require me to create some third party software, and I don't want to include such software with QuestHelper, because that's the kind of thing that ill intended people are likely to tamper with.
630 World of Warcraft stores QuestHelper's data in a file named |cff40bbffQuestHelper.lua|r.
632 To find this file, first find the the directory you installed World of Warcraft to. In Windows, this defaults to |cff40bbffC:\Program Files\World of Warcraft|r, and on Mac, I believe this is |cff40bbff/Applications/World of Warcraft|r.
634 If you're using Windows Vista, Windows might protect the Program Files directory from changes, and redirect Warcraft's saved data to |cff40bbffC:\Users\|cffff8000USER|cff40bbff\AppData\Local\VirtualStore\Program Files\World of Warcraft|r, or possibly |cff40bbffC:\Users\Public\Games\World of Warcraft|r.
636 In that directory, the needed file is in |cff40bbffWTF/Account/|cffff8000ACCOUNT|cff40bbff/SavedVariables|r, replacing ACCOUNT with the name of your account, and in that directory, you should find |cff40bbffQuestHelper.lua|r.
638 There are other directories with the names of the realms where your characters are stored, |cffffff00but don't enter them|r. They contain information specific to your characters, such as the flight points they know about, and don't contain the quest information I want.
640 After you find |cff40bbffQuestHelper.lua|r, you can email it to me here: |cff40bbffqhaddon@gmail.com|r
641 ]], "How To Submit Your Data")
644 function QuestHelper:ShowError(params)
645 if params and params == "full" then
646 QuestHelper_ErrorCatcher_GenerateReport()
648 QuestHelper_ErrorCatcher_ReportError()
651 local commands
653 function QuestHelper:Help(argument)
654 local text = ""
655 local argument = argument and argument:upper() or ""
657 for i1, cat in ipairs(commands) do
658 text = string.format("%s|cffffff00%s|r\n\n", text, cat[1])
659 for i, data in ipairs(cat[2]) do
660 if data[1]:find(argument, 1, true) then
661 text = string.format("%s |cffff8000%s|r %s\n", text, data[1], data[2])
663 if #data[3] > 0 then
664 text = string.format("%s\n %s\n", text, #data[3] == 1 and "Example:" or "Examples:")
665 for i, pair in ipairs(data[3]) do
666 text = string.format("%s |cff40bbff%s|r\n %s\n", text, pair[1], pair[2])
670 text = text .. "\n"
673 text = text .. "\n\n"
676 self:ShowText(text == "" and ("No commands containing '"..argument.."'") or text, "QuestHelper Slash Commands")
679 function QuestHelper:Donate(argument)
680 local text = ""
681 local argument = argument and argument:upper() or ""
683 for i1, cat in ipairs(commands) do
684 text = string.format("%s|cffffff00%s|r\n\n", text, cat[1])
685 for i, data in ipairs(cat[2]) do
686 if data[1]:find(argument, 1, true) then
687 text = string.format("%s |cffff8000%s|r %s\n", text, data[1], data[2])
689 if #data[3] > 0 then
690 text = string.format("%s\n %s\n", text, #data[3] == 1 and "Example:" or "Examples:")
691 for i, pair in ipairs(data[3]) do
692 text = string.format("%s |cff40bbff%s|r\n %s\n", text, pair[1], pair[2])
696 text = text .. "\n"
699 text = text .. "\n\n"
702 self:ShowText([[
703 QuestHelper currently survives on |cffff8000your donations|r. I'm trying to make this into a full-time job so I can add more features and fix bugs, and I can't do that without paying the bills.
705 There's a lot of stuff I plan to add if I can get enough donations to live off. Some of the most-requested features include:
707 |cff40bbffReduced memory and CPU usage for smoother gameplay|r
709 |cff40bbffFlying mount support for both Northrend and Outland|r
711 |cff40bbffBetter support for Northrend "phased" quests|r
713 |cff40bbffAchievementHelper, built right into QuestHelper|r
715 |cff40bbffPaths that lead you around obstacles instead of through them|r
717 I can't guarantee these will show up soon, as there's a lot of work involved in them, but every donation - no matter how small - helps!
719 To donate, open up your web browser and go to |cffff8000http://www.quest-helper.com/donate|r. Enter however much you feel comfortable donating, then bask in the knowledge that you're supporting QuestHelper.
721 Thanks!]], "Please Donate!", 500, 20, 10)
724 commands =
726 { "Common commands", {
727 {"HIDDEN",
728 "Compiles a list of objectives that QuestHelper is hiding from you. Depending on the reason, you can also unhide the objective.",
729 {}, QH_Hidden_Menu},
731 {"HIDE",
732 "Hides QuestHelper's modifications to the minimap and world map, and pauses routing calculations.",
733 {}, QuestHelper.ToggleHide, QuestHelper},
735 {"ARROW",
736 "Toggles Questhelper's built-in directional arrow.",
737 {{"/qh arrow reset", "Reset location to the center of the screen."}},
738 QuestHelper.ToggleArrow, QuestHelper},
740 {"METRIC",
741 "Toggles distance units between metres and yards.",
742 {}, QuestHelper.ToggleMetric, QuestHelper},
744 {"CARTWP",
745 "Toggles displaying the current objective using Cartographer Waypoints (must be installed separately).",
746 {}, QuestHelper.ToggleCartWP, QuestHelper},
748 {"TOMTOM",
749 "Toggles displaying the current objective using TomTom (must be installed separately).",
750 {}, QuestHelper.ToggleTomTomWP, QuestHelper},
752 {"FIND",
753 "Search for an item, location, or npc.",
754 {{"/qh find item rune of teleport", "Finds a reagent vendor."},
755 {"/qh find npc bragok", "Finds the Ratchet flight point."},
756 {"/qh find loc stormwind 50 60", "Finds the Stormwind auction house."},
757 {"/qh find loc 50 50", "Finds the center of the zone you're in."},
758 {"/qh find something", "Searches for something in all categories."},
759 {"/qh find", "Lists objectives you manually created so that you can remove them."}}, QH_FindName},
761 {"SOLO",
762 "Toggles solo mode. When enabled, assumes your party members don't exist. Objective sharing with party members will also be disabled.",
763 {}, QuestHelper.ToggleSolo, QuestHelper},
766 { "Objective filtering", {
767 {"FILTER",
768 "Automatically ignores/unignores objectives based on criteria.",
770 {"/qh filter level", "Toggle showing objectives that are probably too hard, by considering the levels of you and your party members, and the offset set by the level command."},
771 {"/qh filter group", "Toggle showing objectives that require groups. Automatically disables while grouped."},
773 {"/qh filter zone", "Toggle showing objectives outside the current zone."},
774 {"/qh filter done", "Toggle showing objectives for uncompleted quests."},
776 {"/qh filter blocked", "Toggle showing blocked objectives, such as quest turn-ins for incomplete quests."},
777 {"/qh filter watched", "Toggle limiting to objectives watched in the Quest Log"},
779 {"/qh filter wintergrasp", "Toggle ignoring of PvP Wintergrasp quest objectives while not in Wintergrasp"},
780 {"/qh filter raidaccessible", "Toggle ignoring non-raid quests when in a raid"},
781 }, QuestHelper.Filter, QuestHelper},
783 {"LEVEL",
784 "Adjusts the level offset used by the level filter. Naturally, the level filter must be turned on to have an effect.",
785 {{"/qh level", "See information related to the level filter."},
786 {"/qh level 0", "Only allow objectives at or below your current level."},
787 {"/qh level +2", "Allow objectives up to two levels above your current level."},
788 {"/qh level -1", "Only allow objectives below your current level."}}, QuestHelper.LevelOffset, QuestHelper},
790 {"GROUP",
791 "Adjusts the player cutoff used by the group filter. Naturally, the group filter must be turned on to have an effect.",
792 {{"/qh group", "See information related to the group filter."},
793 {"/qh group 0", "Only allow objectives that can be done solo."},
794 {"/qh group 2", "Allow objectives that require, at most, two groupmembers."},
795 {"/qh group 5", "Allow objectives that require, at most, five groupmembers."},
796 {"/qh group instance", "Equivalent to /qh group 5."},
797 {"/qh group raid", "Equivalent to /qh group 10. All raid quests are currently assumed to be 10-person raids."},
798 }, QuestHelper.GroupOffset, QuestHelper},
800 {"SCALE",
801 "Scales the map icons used by QuestHelper. Will accept values between 50% and 300%.",
802 {{"/qh scale 1", "Uses the default icon size."},
803 {"/qh scale 2", "Makes icons twice their default size."},
804 {"/qh scale 80%", "Makes icons slightly smaller than their default size."}},
805 QuestHelper.genericSetScale, QuestHelper, "scale", "icon scale", .5, 3},
807 {"SHARE",
808 "Toggles objective sharing between QuestHelper users.",
809 {}, QuestHelper.ToggleShare, QuestHelper},
812 { "Interface", {
813 --[[{"BLIZZMAP",
814 "Toggles the visibility of Blizzard's built-in map points.",
815 {}, QuestHelper.ToggleBlizzMap, QuestHelper},]]
817 {"TRACK",
818 "Toggles the visibility of the QuestHelper's replacement quest tracker.",
819 {}, QuestHelper.ToggleTrack, QuestHelper},
821 {"TSCALE",
822 "Scales the quest tracker provided by QuestHelper. Will accept values between 50% and 300%.",
824 QuestHelper.TrackerScale, QuestHelper},
826 {"TRESET",
827 "Reset's the position of the quest tracker provided by QuestHelper, in cause you move it somewhere inaccessable.",
828 {{"/qh treset center", "Resets to the center of the screen, instead of a more normal quest tracker location."}}, QuestHelper.ResetTrackerPosition, QuestHelper},
830 {"TLEVEL",
831 "Toggles display of levels in the quest tracker provided by QuestHelper.",
832 {}, QuestHelper.ToggleTrackLevel, QuestHelper},
834 {"TQCOL",
835 "Toggles display of colours for the difficulty level of quests in the quest tracker provided by QuestHelper.",
836 {}, QuestHelper.ToggleTrackQColour, QuestHelper},
838 {"TOCOL",
839 "Toggles display of colours for objective progress in the quest tracker provided by QuestHelper.",
840 {}, QuestHelper.ToggleTrackOColour, QuestHelper},
842 {"TOOLTIP",
843 "Toggles appending information about tracked items and NPCs to their tooltips.",
844 {}, QuestHelper.ToggleTooltip, QuestHelper},
846 {"FTIME",
847 "Toggles display of flight time estimates.", {}, QuestHelper.ToggleFlightTimes, QuestHelper},
849 {"TRAVELTIME",
850 "Toggles display of travel time estimates.", {}, QuestHelper.ToggleTravelTimes, QuestHelper},
852 {"ANTS",
853 "Toggles the display of trails on the world map on and off.",
854 {}, QuestHelper.ToggleAnts, QuestHelper},
856 {"ZONES",
857 "Changes the display of the quest objective zones on the main map.",
858 {}, QuestHelper.SetZones, QuestHelper},
860 {"MINIOPACITY",
861 "Set the opacity of icons on the minimap.",
862 {}, QuestHelper.genericSetScale, QuestHelper, "mini_opacity", "minimap icon opacity", .1, 1.0},
864 {"LOCALE",
865 "Select the locale to use for displayed messages.",
866 {}, QuestHelper.SetLocale, QuestHelper},
868 {"BUTTON",
869 "Toggles the display of QuestHelper's button on the world map.",
870 {}, QuestHelper.ToggleMapButton, QuestHelper},
872 {"SETTINGS",
873 "Opens the Settings menu at the current cursor location. Note that not all settings can be changed through the menu.",
874 {}, QuestHelper.DoSettingsMenu, QuestHelper},
877 { "Data collection", {
878 {"SUBMIT",
879 "Displays instructions for submitting your collected data.",
880 {}, QuestHelper.Submit, QuestHelper},
882 --[[
883 {"NAG",
884 "Tells you if you have anything that's missing from the static database. It can only check quests from your own faction, as the quests of your opposing faction are ommitted to save memory.",
885 {{"/qh nag verbose", "Prints the specific changes that were found."}}, QuestHelper.Nag, QuestHelper},]]
887 {"PURGE",
888 "Deletes all QuestHelper's collected data.", {}, QuestHelper.Purge, QuestHelper},
890 {"HARDRESET",
891 "Deletes all QuestHelper's collected data and resets QuestHelper preferences.", {}, QuestHelper.HardReset, QuestHelper},
894 { "Performance and debug", {
895 {"PERF",
896 "Sets or shows the route workload. Higher means more agressive route updating, lower means better performance Accepts numbers between 10% and 500%.",
897 {{"/qh perf", "Show current Performance Factor"},
898 {"/qh perf 1", "Sets standard performance"},
899 {"/qh perf 50%", "Does half as much background processing"},
900 {"/qh perf 3", "Computes routes 3 times more aggressively. Better have some good horsepower!"}},
901 QuestHelper.genericSetScale, QuestHelper, "perf_scale_2", "performance factor", .1, 5},
903 {"PERFLOAD",
904 "Sets or shows the initialization workload. Higher numbers will make QuestHelper load faster, lower numbers will result in better framerate while it's loading.",
905 {{"/qh perfload", "Show current Performance Factor"},
906 {"/qh perfload 1", "Sets standard performance"},
907 {"/qh perfload 50%", "Does half as much background processing"},
908 {"/qh perfload 3", "Loads 3 times as quickly."}},
909 QuestHelper.genericSetScale, QuestHelper, "perfload_scale", "boot performance factor", .2, 5},
911 {"TOP",
912 "Displays various performance stats on QuestHelper.",
914 {"/qh top recycle", "Displays detailed information on QuestHelper's recycled item pools"},
915 {"/qh top usage", "Displays detailed information on which table types are most common"},
916 {"/qh top cache", "Displays detailed information on the internal distance cache"},
917 {"/qh top perf", "Displays detailed information on coroutine CPU usage"},
918 }, QuestHelper.Top, QuestHelper},
920 {"ERROR",
921 "Displays the first QuestHelper error that has been generated this session in a form which can be copied out of WoW.",
922 {}, QuestHelper.ShowError, QuestHelper},
924 {"POS",
925 "Prints the player's current position. Exists mainly for my own personal convenience.",
926 {}, function (qh) qh:TextOut(qh:LocationString(qh.i, qh.x, qh.y) .. " " .. qh:Location_RawString(qh:Location_RawRetrieve()) .. " " .. qh:Location_AbsoluteString(qh:Location_AbsoluteRetrieve())) end, QuestHelper},
929 { "Help", {
930 {"HELP",
931 "Displays a list of help commands. Listed commands are filtered by the passed string.",
932 {}, QuestHelper.Help, QuestHelper},
934 {"VERSION",
935 "Displays QuestHelper's version.", {}, QuestHelper.PrintVersion, QuestHelper},
937 {"CHANGES",
938 "Displays a summary of changes recently made to QuestHelper.",
939 {}, QuestHelper.ChangeLog, QuestHelper},
941 --[[{"DONATE",
942 "Displays some instructions and a link for donating.",
943 {}, QuestHelper.Donate, QuestHelper},]]
946 { "Incredibly Experimental And Unsupported", {
947 {"BONFIRES",
948 "Adds waypoints for the Midsummer Bonfires.",
949 {}, QH_AddFires},
950 {"BUCKETS",
951 "Adds waypoints for the Hallow's End Candy Buckets. (Northrend buckets currently not supported)",
952 {{"/qh buckets kalimdor", "Add waypoints for Kalimdor only"},
953 {"/qh buckets ek", "Add waypoints for Eastern Kingdoms only"},
954 {"/qh buckets outland", "Add waypoints for Outland only"},
955 }, QH_AddBuckets},
959 function QuestHelper_SlashCommand(input)
960 local _, _, command, argument = string.find(input, "^%s*([^%s]-)%s+(.-)%s*$")
961 if not command then
962 command, argument = input, ""
965 command = string.upper(command)
967 for i1, cat in ipairs(commands) do
968 for i, data in ipairs(cat[2]) do
969 if data[1] == command then
970 local st = {}
972 for i = 5,#data do table.insert(st, data[i]) end
973 table.insert(st, argument)
975 if type(data[4]) == "function" then
976 data[4](unpack(st))
977 else
978 QuestHelper:TextOut(data[1].." is not yet implemented.")
981 return
986 QuestHelper:Help()
989 SLASH_QuestHelper1 = "/qh"
990 SLASH_QuestHelper2 = "/questhelper"
991 SlashCmdList["QuestHelper"] = function (text) QuestHelper_SlashCommand(text) end