Made purge command reset the locale of the saved data, and added files for 0.44 release.
[QuestHelper.git] / help.lua
blob8f69c48c8c92b3c510b1c0300288def7642a0e0e
1 function QuestHelper:SetIconScale(input)
2 if input == "" then
3 self:TextOut("Current icon scale is "..self:HighlightText(math.floor(QuestHelper_Pref.scale*100+0.5).."%")..".")
4 else
5 local scale = tonumber(input)
7 if not scale then
8 local _, _, x = string.find(input, "^%s*([%d%.]+)%s*%%%s*$")
9 scale = tonumber(x)
10 if not scale then
11 self:TextOut("I don't know how to interpret your input.")
12 return
13 end
14 scale = scale * 0.01
15 end
17 if scale < 0.5 then
18 self:TextOut("I won't accept a scale less than 50%.")
19 elseif scale > 3 then
20 self:TextOut("I won't accept a scale more than 300%.")
21 else
22 QuestHelper_Pref.scale = scale
23 self:TextOut("Icon scale set to "..self:HighlightText(math.floor(scale*100+0.5).."%")..".")
24 end
25 end
26 end
28 -----------------------------------------------------------------------------------------------
29 -- Set / show the Performance Factor
30 function QuestHelper:SetPerfFactor(input)
31 if input == "" then
32 self:TextOut("Current Performance Factor is "..self:HighlightText(math.floor(QuestHelper_Pref.perf_scale*100).."%")..".")
33 else
34 local perf = tonumber(input)
36 if not perf then
37 local _, _, x = string.find(input, "^%s*([%d%.]+)%s*%%%s*$")
38 perf = tonumber(x)
39 if not perf then
40 self:TextOut("I don't know how to interpret your input.")
41 return
42 end
43 perf = perf * 0.01
44 end
46 if perf < 0.1 then
47 self:TextOut("I won't accept a performance factor less than 10%.")
48 elseif perf > 5 then
49 self:TextOut("I won't accept a performance factor more than 500%.")
50 else
51 QuestHelper_Pref.perf_scale = perf
52 self:TextOut("Performance factor set to "..self:HighlightText(math.floor(perf*100+0.5).."%")..".")
53 end
54 end
55 end
57 function QuestHelper:SetLocale(loc)
58 if not loc or loc == "" then
59 self:TextOut(QHText("LOCALE_LIST_BEGIN"))
60 for loc, tbl in pairs(QuestHelper_Translations) do
61 self:TextOut(string.format(" %s%s %s", self:HighlightText(loc),
62 loc == QuestHelper_Pref.locale and " *" or " ",
63 tbl.LOCALE_NAME or "???"))
64 end
65 else
66 for l, tbl in pairs(QuestHelper_Translations) do
67 if string.find(string.lower(l), "^"..string.lower(loc)) or
68 string.find(string.lower(tbl.LOCALE_NAME or ""), "^"..string.lower(loc)) then
69 QuestHelper_Pref.locale = l
70 QHFormatSetLocale(l)
71 self:TextOut(QHFormat("LOCALE_CHANGED", l))
72 return
73 end
74 end
76 self:TextOut(QHFormat("LOCALE_UNKNOWN", tostring(loc) or "UNKNOWN"))
77 end
78 end
80 function QuestHelper:ToggleHide()
81 local current_objective = self.minimap_dodad.objective
83 QuestHelper_Pref.hide = not QuestHelper_Pref.hide
85 -- Desaturate the button texture if QuestHelper is disabled.
86 QuestHelperWorldMapButton:GetNormalTexture():SetDesaturated(QuestHelper_Pref.hide)
88 if QuestHelper_Pref.hide then
89 self.map_overlay:Hide()
90 self.minimap_dodad:SetObjective(nil)
91 self.minimap_dodad.objective = current_objective
92 self:TextOut("QuestHelper is now |cffff0000hidden|r.")
93 else
94 self.map_overlay:Show()
95 self.minimap_dodad.objective = nil
96 self.minimap_dodad:SetObjective(current_objective)
97 self:TextOut("QuestHelper is now |cff00ff00shown|r.")
98 -- WoW Will lockup inside ForceRouteUpdate, and so the UPDATING_ROUTE message won't appear until afterwards, making
99 -- this message kind of redundant.
100 -- self:TextOut(QHText("UPDATING_ROUTE"))
101 self:ForceRouteUpdate(4) -- Let the corutine do some overtime...
105 function QuestHelper:ToggleShare()
106 QuestHelper_Pref.share = not QuestHelper_Pref.share
107 if QuestHelper_Pref.share then
108 if QuestHelper_Pref.solo then
109 self:TextOut("Objective sharing will been |cff00ff00enabled|r when you disable solo mode.")
110 else
111 self:TextOut("Objective sharing has been |cff00ff00enabled|r.")
112 self:EnableSharing()
114 else
115 self:TextOut("Objective sharing has been |cffff0000disabled|r.")
116 if QuestHelper_Pref.solo then
117 self:TextOut("Objective sharing won't be reenabled when you disable solo mode.")
118 else
119 self:DisableSharing()
124 function QuestHelper:ToggleFlightTimes()
125 QuestHelper_Pref.flight_time = not QuestHelper_Pref.flight_time
126 if QuestHelper_Pref.flight_time then
127 self:TextOut("The flight timer has been |cff00ff00enabled|r.")
128 else
129 self:TextOut("The flight timer has been |cffff0000disabled|r.")
133 function QuestHelper:Purge(code)
134 if code == self.purge_code then
135 QuestHelper_Quests = {}
136 QuestHelper_Objectives = {}
137 QuestHelper_FlightInstructors = {}
138 QuestHelper_FlightRoutes = {}
139 QuestHelper_Locale = GetLocale()
140 QuestHelper_UID = self:CreateUID()
141 ReloadUI()
142 else
143 if not self.purge_code then self.purge_code = self:CreateUID(8) end
144 QuestHelper:TextOut("THIS COMMAND WILL DELETE ALL YOUR COLLECTED DATA")
145 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.")
146 QuestHelper:TextOut("Enter "..self:HighlightText("/qh nag verbose").." to check and see if you're destroying anything important.")
147 QuestHelper:TextOut("See the "..self:HighlightText("How You Can Help").." section on the project website for instructions.")
148 QuestHelper:TextOut("If you're sure you want to go through with this, enter: "..self:HighlightText("/qh purge "..self.purge_code))
152 function QuestHelper:ToggleSolo()
153 QuestHelper_Pref.solo = not QuestHelper_Pref.solo
154 if QuestHelper_Pref.solo then
155 if QuestHelper_Pref.share then
156 self:DisableSharing()
157 self:TextOut("Objective sharing has been temporarly |cffff0000disabled|r.")
159 self:TextOut("Solo mode has been |cff00ff00enabled|r.")
160 else
161 self:TextOut("Solo mode has been |cffff0000disabled|r.")
162 if QuestHelper_Pref.share then
163 self:EnableSharing()
164 self:TextOut("Objective sharing has been re|cff00ff00enabled|r.")
169 function QuestHelper:ToggleComm()
170 if QuestHelper_Pref.comm then
171 QuestHelper_Pref.comm = false
172 self:TextOut("Communication display has been |cffff0000disabled|r.")
173 else
174 QuestHelper_Pref.comm = true
175 self:TextOut("Communication display has been |cff00ff00enabled|r.")
179 function QuestHelper:ToggleAnts()
180 if QuestHelper_Pref.show_ants then
181 QuestHelper_Pref.show_ants = false
182 self:TextOut("Ant trails have been |cffff0000disabled|r.")
183 else
184 QuestHelper_Pref.show_ants = true
185 self:TextOut("Ant trails have been |cff00ff00enabled|r.")
189 function QuestHelper:LevelOffset(offset)
190 local level = tonumber(offset)
191 if level then
192 if level > 0 then
193 self:TextOut("Allowing quests up to "..self:HighlightText(level).." level"..(level==1 and " " or "s ")..self:HighlightText("above").." you.")
194 elseif level < 0 then
195 self:TextOut("Only allowing quests "..self:HighlightText(-level).." level"..(level==-1 and " " or "s ")..self:HighlightText("below").." you.")
196 else
197 self:TextOut("Only allowing quests "..self:HighlightText("at or below").." your current level.")
200 if not QuestHelper_Pref.filter_level then
201 self:TextOut("Note: This won't have any effect until you turn the level filter on.")
204 if QuestHelper_Pref.level ~= level then
205 QuestHelper_Pref.level = level
206 self.defered_quest_scan = true
208 elseif offset == "" then
209 if QuestHelper_Pref.level <= 0 then
210 self:TextOut("Level offset is currently set to "..self:HighlightText(QuestHelper_Pref.level)..".")
211 else
212 self:TextOut("Level offset is currently set to "..self:HighlightText("+"..QuestHelper_Pref.level)..".")
215 if self.party_levels then for n, l in ipairs(self.party_levels) do
216 self:TextOut("Your effective level in a "..self:HighlightText(n).." player quest is "..self:HighlightText(string.format("%.1f", l))..".")
217 end end
219 if QuestHelper_Pref.solo then
220 self:TextOut("Peers aren't considered in your effective level, because you're playing solo.")
222 else
223 self:TextOut("Expected a level offset.")
227 function QuestHelper:Filter(input)
228 input = string.upper(input)
229 if input == "ZONE" then
230 QuestHelper_Pref.filter_zone = not QuestHelper_Pref.filter_zone
231 self:TextOut("Filter "..self:HighlightText("zone").." set to "..self:HighlightText(QuestHelper_Pref.filter_zone and "active" or "inactive")..".")
232 elseif input == "DONE" then
233 QuestHelper_Pref.filter_done = not QuestHelper_Pref.filter_done
234 self:TextOut("Filter "..self:HighlightText("done").." set to "..self:HighlightText(QuestHelper_Pref.filter_done and "active" or "inactive")..".")
235 elseif input == "LEVEL" then
236 QuestHelper_Pref.filter_level = not QuestHelper_Pref.filter_level
237 self:TextOut("Filter "..self:HighlightText("level").." set to "..self:HighlightText(QuestHelper_Pref.filter_level and "active" or "inactive")..".")
238 elseif input == "" then
239 self:TextOut("Filter "..self:HighlightText("zone")..": "..self:HighlightText(QuestHelper_Pref.filter_zone and "active" or "inactive"))
240 self:TextOut("Filter "..self:HighlightText("level")..": "..self:HighlightText(QuestHelper_Pref.filter_level and "active" or "inactive"))
241 self:TextOut("Filter "..self:HighlightText("done")..": "..self:HighlightText(QuestHelper_Pref.filter_done and "active" or "inactive"))
242 else
243 self:TextOut("Don't know what you want filtered, expect "..self:HighlightText("zone")..", "..self:HighlightText("done")..", or "..self:HighlightText("level")..".")
247 function QuestHelper:ToggleCartWP()
248 QuestHelper_Pref.cart_wp = not QuestHelper_Pref.cart_wp
249 if QuestHelper_Pref.cart_wp then
250 if Cartographer_Waypoints then
251 self:TextOut("Will use "..self:HighlightText("Cartographer Waypoints").." to show objectives.")
252 else
253 self:TextOut("Would use "..self:HighlightText("Cartographer Waypoints").." to show objectives, except it doesn't seem to be present.")
255 else
256 self:HideCartographerWaypoint()
257 self:TextOut("Won't use "..self:HighlightText("Cartographer Waypoints").." to show objectives.")
261 function QuestHelper:WantPathingReset()
262 self:TextOut("Will reset world graph.")
263 self.defered_graph_reset = true
266 function QuestHelper:PrintVersion()
267 self:TextOut("Version: "..self:HighlightText(GetAddOnMetadata("QuestHelper", "Version") or "Unknown"))
270 local function RecycleStatusString(fmt, used, free)
271 return string.format(fmt, QuestHelper:ProgressString(string.format("%d/%d", used, used+free), ((used+free == 0) and 1) or (1-used/(used+free))))
274 function QuestHelper:RecycleInfo()
275 self:TextOut(RecycleStatusString("Using %s lua tables.", self.used_tables, #self.free_tables))
276 self:TextOut(RecycleStatusString("Using %s texture objects.", self.used_textures, #self.free_textures))
277 self:TextOut(RecycleStatusString("Using %s font objects.", self.used_text, #self.free_text))
278 self:TextOut(RecycleStatusString("Using %s frame objects.", self.used_frames, #self.free_frames))
281 local commands =
283 {"VERSION",
284 "Displays QuestHelper's version.", {}, QuestHelper.PrintVersion, QuestHelper},
286 {"RECALC",
287 "Recalculates the world graph and locations for any active objectives.", {}, QuestHelper.WantPathingReset, QuestHelper},
289 {"FTIME",
290 "Toggles display of flight time estimates.", {}, QuestHelper.ToggleFlightTimes, QuestHelper},
292 {"PURGE",
293 "Deletes all QuestHelper's collected data.", {}, QuestHelper.Purge, QuestHelper},
295 {"FILTER",
296 "Automatically ignores/unignores objectives based on criteria.",
297 {{"/qh filter zone", "Toggle showing objectives outside the current zone"},
298 {"/qh filter done", "Toggle showing objectives for uncompleted quests."},
299 {"/qh filter level", "Toggle showing objectives that are probably too hard."}}, QuestHelper.Filter, QuestHelper},
301 {"SCALE",
302 "Scales the map icons used by QuestHelper. Will accept values between 50% and 300%.",
303 {{"/qh scale 1", "Uses the default icon size."},
304 {"/qh scale 2", "Makes icons twice their default size."},
305 {"/qh scale 80%", "Makes icons slightly smaller than their default size."}}, QuestHelper.SetIconScale, QuestHelper},
307 {"NAG",
308 "Tells you if you have anything that's missing from the static database.",
309 {{"/qh nag", "Prints just the summary of changes."},
310 {"/qh nag verbose", "Prints the specific changes that were found."}}, QuestHelper.Nag, QuestHelper},
312 {"LEVEL",
313 "Adjusts the level offset used by the level filter. Naturally, the level filter must be turned on to have an effect.",
314 {{"/qh level", "See information related to the level filter."},
315 {"/qh level 0", "Only allow objectives at below your current level."},
316 {"/qh level +2", "Allow objectives up to two levels above your current level."},
317 {"/qh level -1", "Only allow objectives below your current level."}}, QuestHelper.LevelOffset, QuestHelper},
319 {"POS",
320 "Prints the player's current position. Exists mainly for my own personal convenience.",
321 {}, function (qh) qh:TextOut(qh:LocationString(qh.i, qh.x, qh.y)) end, QuestHelper},
323 {"HIDDEN",
324 "Compiles a list of objectives that QuestHelper is hiding from you. Depending on the reason, you can also unhide the objective.",
325 {}, QuestHelper.ShowHidden, QuestHelper},
327 {"FIND",
328 "Search for an item, location, or npc.",
329 {{"/qh find item rune of teleport", "Finds a reagent vendor."},
330 {"/qh find npc bragok", "Finds the Ratchet flight point."},
331 {"/qh find loc stormwind 50 60", "Finds the Stormwind auction house."}}, QuestHelper.PerformSearch, QuestHelper},
333 {"COMM",
334 "Toggles showing of the communication between QuestHelper users. Exists mainly for my own personal convenience.",
335 {}, QuestHelper.ToggleComm, QuestHelper},
337 {"RECYCLE",
338 "Displays how many unused entities QuestHelper is tracking, so that it can reuse them in the future instead of creating new ones in the future.",
339 {}, QuestHelper.RecycleInfo, QuestHelper},
341 {"CARTWP",
342 "Toggles displaying the current objective using Cartographer Waypoints.",
343 {}, QuestHelper.ToggleCartWP, QuestHelper},
345 {"SHARE",
346 "Toggles objective sharing between QuestHelper users.",
347 {}, QuestHelper.ToggleShare, QuestHelper},
349 {"HIDE",
350 "Hides QuestHelper's modifications to the minimap and world map, and pauses routing calculations.",
351 {}, QuestHelper.ToggleHide, QuestHelper},
353 {"ANTS",
354 "Toggles the world map ant trails on and off.",
355 {}, QuestHelper.ToggleAnts, QuestHelper},
357 {"SOLO",
358 "Toggles solo mode. When enabled, assumes you're playing alone, even when in a party.",
359 {}, QuestHelper.ToggleSolo, QuestHelper},
361 {"LOCALE",
362 "Select the locale to use for displayed messages.",
363 {}, QuestHelper.SetLocale, QuestHelper},
365 {"PERF",
366 "Sets / shows the Performance Factor. Higher means more agressive route updating, lower means better performance (better frame rate). Accepts numbers between 10% and 500%.",
367 {{"/qh perf", "Show current Performance Factor"},
368 {"/qh perf 1", "Sets standard performance"},
369 {"/qh perf 50%", "Does half as much background processing"},
370 {"/qh perf 3", "Computes routes 3 times more aggressively. Better have some good horsepower!"}},
371 QuestHelper.SetPerfFactor, QuestHelper}
374 function QuestHelper:SlashCommand(input)
375 local _, _, command, argument = string.find(input, "^%s*([^%s]-)%s+(.-)%s*$")
376 if not command then
377 command, argument = input, ""
380 command = string.upper(command)
382 for i, data in ipairs(commands) do
383 if data[1] == command then
384 local st = self:CreateTable()
386 for i = 5,#data do table.insert(st, data[5]) end
387 table.insert(st, argument)
389 if type(data[4]) == "function" then
390 data[4](unpack(st))
391 else
392 self:TextOut(data[1].." is not yet implemented.")
395 self:ReleaseTable(st)
396 return
400 if command == "HELP" then
401 argument = string.upper(argument)
403 for i, data in ipairs(commands) do
404 if data[1] == argument then
405 DEFAULT_CHAT_FRAME:AddMessage(data[1], 1.0, 0.8, 0.4)
406 DEFAULT_CHAT_FRAME:AddMessage(" "..data[2], 1.0, 0.6, 0.2)
407 if #data[3] > 0 then
408 DEFAULT_CHAT_FRAME:AddMessage(#data[3] == 1 and " Example:" or " Examples:", 1.0, 0.6, 0.2)
409 for i, pair in ipairs(data[3]) do
410 DEFAULT_CHAT_FRAME:AddMessage(" "..pair[1], 1.0, 1.0, 1.0)
411 DEFAULT_CHAT_FRAME:AddMessage(" "..pair[2], 1.0, 0.6, 0.2)
414 return
419 DEFAULT_CHAT_FRAME:AddMessage("Available Commands:", 1.0, 0.6, 0.2)
421 for i, data in ipairs(commands) do
422 DEFAULT_CHAT_FRAME:AddMessage(" "..string.lower(data[1]), 1.0, 0.6, 0.2)
426 SLASH_QuestHelper1 = "/qh"
427 SLASH_QuestHelper2 = "/questhelper"
428 SlashCmdList["QuestHelper"] = function (text) QuestHelper:SlashCommand(text) end