vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 ---------------------------------------------------------------------------------------------------
2 --Name: Questie for Vanilla WoW
3 --Authors: Aero/Schaka/Logon/Dyaxler/Muehe/Zoey/everyone else
4 --Website: https://github.com/AeroScripts/QuestieDev
5 --Description: Questie started out being a simple backport of QuestHelper but it has grown beyond
6 --it's original design into something better. Questie will show you where quests are available and
7 --only display the quests you're eligible for based on level, profession, class, race etc. Questie
8 --will also assist you in where or what is needed to complete a quest. Map notes, an arrow, custom
9 --tooltips, quest tracker are also some of the tools included with Questie to assist you.
10 ---------------------------------------------------------------------------------------------------
11 --///////////////////////////////////////////////////////////////////////////////////////////////--
12 ---------------------------------------------------------------------------------------------------
13 Questie = CreateFrame("Frame", "QuestieLua", UIParent, "ActionButtonTemplate");
14 QuestieVersion = "3.7.1";
15 ---------------------------------------------------------------------------------------------------
16 --Setup Default Profile
17 ---------------------------------------------------------------------------------------------------
18 function Questie:SetupDefaults()
19 if not QuestieSeenQuests then QuestieSeenQuests = {}; end
20 if not QuestieCachedQuests then QuestieCachedQuests = {}; end
21 if not QuestieConfig then QuestieConfig = {
22 ["alwaysShowObjectives"] = true,
23 ["arrowEnabled"] = true,
24 ["arrowTime"] = true,
25 ["boldColors"] = false,
26 ["clusterQuests"] = true,
27 ["corpseArrow"] = true,
28 ["getVersion"] = QuestieVersion,
29 ["hideMinimapIcons"] = false,
30 ["hideObjectives"] = false,
31 ["maxLevelFilter"] = true,
32 ["maxShowLevel"] = 7,
33 ["minimapButton"] = true,
34 ["minimapZoom"] = false,
35 ["minLevelFilter"] = true,
36 ["minShowLevel"] = 4,
37 ["resizeWorldmap"] = false,
38 ["showMapNotes"] = true,
39 ["showProfessionQuests"] = false,
40 ["showToolTips"] = true,
41 ["showTrackerHeader"] = false,
42 ["trackerAlpha"] = 0.6,
43 ["trackerBackground"] = false,
44 ["trackerEnabled"] = true,
45 ["trackerList"] = false,
46 ["trackerMinimize"] = false,
47 ["trackerScale"] = 1.0,
48 ["useQuestLinks"] = true,
49 };
50 end
51 --Setup default settings and repositions the QuestTracker against the left side of the screen.
52 if not QuestieTrackerVariables then QuestieTrackerVariables = {
53 ["position"] = {
54 ["relativeTo"] = "UIParent",
55 ["point"] = "CENTER",
56 ["relativePoint"] = "CENTER",
57 ["yOfs"] = 0,
58 ["xOfs"] = 0,
59 },
60 };
61 end
62 end
63 ---------------------------------------------------------------------------------------------------
64 --Setup Default Values
65 ---------------------------------------------------------------------------------------------------
66 function Questie:CheckDefaults()
67 --Setups default QuestieConfig toggles for first time users. These are necessary to prevent nil
68 --errors from occurring after creating a new character or clearing the config
69 if QuestieConfig.alwaysShowObjectives == nil then
70 QuestieConfig.alwaysShowObjectives = true;
71 end
72 if QuestieConfig.arrowEnabled == nil then
73 QuestieConfig.arrowEnabled = true;
74 end
75 if QuestieConfig.arrowTime == nil then
76 QuestieConfig.arrowTime = false;
77 end
78 if QuestieConfig.boldColors == nil then
79 QuestieConfig.boldColors = false;
80 end
81 if QuestieConfig.clusterQuests == nil then
82 QuestieConfig.clusterQuests = true;
83 end
84 if QuestieConfig.corpseArrow == nil then
85 QuestieConfig.corpseArrow = true;
86 end
87 if QuestieConfig.hideMinimapIcons == nil then
88 QuestieConfig.hideMinimapIcons = false;
89 end
90 if QuestieConfig.hideObjectives == nil then
91 QuestieConfig.hideObjectives = false;
92 end
93 if QuestieConfig.maxLevelFilter == nil then
94 QuestieConfig.maxLevelFilter = true;
95 end
96 if QuestieConfig.maxShowLevel == nil then
97 QuestieConfig.maxShowLevel = 7;
98 end
99 if QuestieConfig.minimapButton == nil then
100 QuestieConfig.minimapButton = true;
101 elseif QuestieConfig.minimapButton == false then
102 Questie.minimapButton:Hide();
103 end
104 if QuestieConfig.minimapZoom == nil then
105 QuestieConfig.minimapZoom = false;
106 end
107 if QuestieConfig.minLevelFilter == nil then
108 QuestieConfig.minLevelFilter = true;
109 end
110 if QuestieConfig.minShowLevel == nil then
111 QuestieConfig.minShowLevel = 4;
112 end
113 if QuestieConfig.resizeWorldmap == nil then
114 QuestieConfig.resizeWorldmap = false;
115 end
116 if QuestieConfig.showMapNotes == nil then
117 QuestieConfig.showMapNotes = true;
118 end
119 if QuestieConfig.showProfessionQuests == nil then
120 QuestieConfig.showProfessionQuests = false;
121 end
122 if QuestieConfig.showTrackerHeader == nil then
123 QuestieConfig.showTrackerHeader = false;
124 end
125 if QuestieConfig.showToolTips == nil then
126 QuestieConfig.showToolTips = true;
127 end
128 if QuestieConfig.trackerAlpha == nil then
129 QuestieConfig.trackerAlpha = 0.6;
130 end
131 if QuestieConfig.trackerBackground == nil then
132 QuestieConfig.trackerBackground = false;
133 end
134 if QuestieConfig.trackerEnabled == nil then
135 QuestieConfig.trackerEnabled = true;
136 end
137 if QuestieConfig.trackerList == nil then
138 QuestieConfig.trackerList = false;
139 end
140 if QuestieConfig.trackerMinimize == nil then
141 QuestieConfig.trackerMinimize = false;
142 end
143 if QuestieConfig.trackerScale == nil then
144 QuestieConfig.trackerScale = 1.0;
145 end
146 if QuestieConfig.useQuestLinks == nil then
147 QuestieConfig.useQuestLinks = true;
148 end
149 --Version check
150 if (not QuestieConfig.getVersion) or (QuestieConfig.getVersion ~= QuestieVersion) then
151 Questie:ClearConfig("version");
152 end
153 --Setups default QuestDB's for fresh characters
154 if QuestieCachedQuests == nil then
155 QuestieCachedQuests = {};
156 end
157 --If the user deletes a character and makes a new one by the same name then it will continue to use
158 --the same Saved Variables file. This check will delete the Questie Saved Variables file to prevent
159 --any quest issues for the new character
160 if UnitLevel("player") == 1 then
161 local i = 0;
162 for _,_ in pairs(QuestieSeenQuests) do
163 if (i < 3) then
164 i = i + 1;
165 else
166 break;
167 end
168 end
169 if i > 2 then
170 Questie:NUKE("newcharacter");
171 end
172 end
173 --Sets some EQL3 settings to keep it from conflicting with Questie features
174 EQL3_Player = UnitName("player").."-"..GetRealmName();
175 if IsAddOnLoaded("EQL3") or IsAddOnLoaded("ShaguQuest") then
176 if (not QuestlogOptions[EQL3_Player]) then return; end
177 if (QuestieConfig.showToolTips == true) then
178 QuestlogOptions[EQL3_Player].MobTooltip = 0;
179 QuestlogOptions[EQL3_Player].ItemTooltip = 0;
180 else
181 QuestlogOptions[EQL3_Player].MobTooltip = 1;
182 QuestlogOptions[EQL3_Player].ItemTooltip = 1;
183 end
184 QuestlogOptions[EQL3_Player].RemoveCompletedObjectives = 0;
185 QuestlogOptions[EQL3_Player].RemoveFinished = 0;
186 QuestlogOptions[EQL3_Player].MinimizeFinished = 0;
187 end
188 end
189 ---------------------------------------------------------------------------------------------------
190 --In Vanilla WoW there is no official Russian client so an addon was made to translate some of the
191 --global strings. Two of the translated strings conflicted with Questie, displaying the wrong info
192 --on the World Map. This function simply over-rides those stings to force them back to English so
193 --Questie can understand the returned sting in order to display the correct locations and icons.
194 ---------------------------------------------------------------------------------------------------
195 function Questie:BlockTranslations()
196 if (IsAddOnLoaded("RuWoW") or IsAddOnLoaded("ProffBot")) or (IsAddOnLoaded("ruRU")) then
197 QUEST_MONSTERS_KILLED = "%s slain: %d/%d"; --Lists the monsters killed for the selected quest
198 ERR_QUEST_ADD_KILL_SII = "%s slain: %d/%d"; --%s is the monster name
199 end
200 end
201 ---------------------------------------------------------------------------------------------------
202 --OnLoad Handler
203 ---------------------------------------------------------------------------------------------------
204 function Questie:OnLoad()
205 this:RegisterEvent("ADDON_LOADED");
206 this:RegisterEvent("CHAT_MSG_LOOT");
207 this:RegisterEvent("MINIMAP_UPDATE_ZOOM");
208 this:RegisterEvent("PLAYER_DEAD");
209 this:RegisterEvent("PLAYER_ENTERING_WORLD");
210 this:RegisterEvent("PLAYER_LEAVING_WORLD");
211 this:RegisterEvent("PLAYER_LEVEL_UP");
212 this:RegisterEvent("PLAYER_LOGIN");
213 this:RegisterEvent("PLAYER_UNGHOST");
214 this:RegisterEvent("QUEST_PROGRESS");
215 this:RegisterEvent("VARIABLES_LOADED");
216 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
217 Questie:NOTES_LOADED();
218 QuestieTracker:BlizzardHooks();
219 SlashCmdList["QUESTIE"] = Questie_SlashHandler;
220 SLASH_QUESTIE1 = "/questie";
221 end
222 ---------------------------------------------------------------------------------------------------
223 --QuestEvents OnLoad Handler
224 ---------------------------------------------------------------------------------------------------
225 function Questie:OnLoad_QuestEvents()
226 this:RegisterEvent("QUEST_LOG_UPDATE");
227 this:RegisterEvent("QUEST_ITEM_UPDATE");
228 end
229 ---------------------------------------------------------------------------------------------------
230 --Global vars
231 ---------------------------------------------------------------------------------------------------
232 IsQuestieActive = true;
233 QUESTIE_EVENTQUEUE = {};
234 QuestieCompletedQuestMessages = {};
235 QUESTIE_LAST_UPDATE_FINISHED = GetTime();
236 QUESTIE_LAST_UPDATE = GetTime();
237 QUESTIE_LAST_CHECKLOG = GetTime();
238 QUESTIE_LAST_UPDATECACHE = GetTime();
239 QUESTIE_LAST_TRACKER = GetTime();
240 QUESTIE_LAST_SYNCLOG = GetTime();
241 QUESTIE_LAST_DRAWNOTES = GetTime();
242 QUESTIE_UPDATE_EVENT = 0;
243 SetMapToCurrentZone();
244 GameLoadingComplete = false;
245 ---------------------------------------------------------------------------------------------------
246 --Questie OnUpdate Handler
247 ---------------------------------------------------------------------------------------------------
248 function Questie:OnUpdate(elapsed)
249 if (not GameTooltip.IsVisible(GameTooltip) ) then
250 GameTooltip.QuestieDone = nil;
251 GameTooltip.lastmonster = nil;
252 GameTooltip.lastobjective = nil;
253 end
254 Astrolabe:OnUpdate(nil, elapsed);
255 Questie:NOTES_ON_UPDATE(elapsed);
256 local index = 1;
257 if (table.getn(QUESTIE_EVENTQUEUE) > 0) then
258 for k, v in pairs(QUESTIE_EVENTQUEUE) do
259 if GetTime()- v.TIME > v.DELAY then
260 if (v.EVENT == "UPDATE") then
261 local UpdateTime = GetTime();
262 while (true) do
263 local d = Questie:UpdateQuests();
264 if (not d) then
265 QUESTIE_EVENTQUEUE[k] = nil;
266 break;
267 end
268 end
269 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring(GetTime()- UpdateTime).." ms");
270 Questie:debug_Print();
271 elseif (v.EVENT == "UPDATECACHE") then
272 local UpdateCacheTime = GetTime();
273 Questie:UpdateGameClientCache();
274 QUESTIE_EVENTQUEUE[k] = nil;
275 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring((GetTime()- UpdateCacheTime)*1000).." ms");
276 Questie:debug_Print();
277 elseif (v.EVENT == "CHECKLOG") then
278 local CheckLogTime = GetTime();
279 Questie:CheckQuestLog();
280 QUESTIE_EVENTQUEUE[k] = nil;
281 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring((GetTime()- CheckLogTime)*1000).." ms");
282 elseif (v.EVENT == "TRACKER") then
283 local TrackerTime = GetTime();
284 QuestieTracker:SortTrackingFrame();
285 QuestieTracker:FillTrackingFrame();
286 QUESTIE_EVENTQUEUE[k] = nil;
287 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring((GetTime()- TrackerTime)*1000).." ms");
288 Questie:debug_Print();
289 elseif (v.EVENT == "SYNCLOG") then
290 local SyncLogTime = GetTime();
291 QuestieTracker:syncQuestLog();
292 QUESTIE_EVENTQUEUE[k] = nil;
293 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring((GetTime()- SyncLogTime)*1000).." ms");
294 Questie:debug_Print();
295 elseif (v.EVENT == "SYNCWATCH") and (not IsAddOnLoaded("EQL3")) and (not IsAddOnLoaded("ShaguQuest")) then
296 local SyncWoWLogTime = GetTime();
297 QuestieTracker:syncQuestWatch();
298 QUESTIE_EVENTQUEUE[k] = nil;
299 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring((GetTime()- SyncWoWLogTime)*1000).." ms");
300 Questie:debug_Print();
301 elseif (v.EVENT == "DRAWNOTES") then
302 local DrawNotesTime = GetTime();
303 Questie:SetAvailableQuests();
304 Questie:RedrawNotes();
305 QUESTIE_EVENTQUEUE[k] = nil;
306 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring((GetTime()- DrawNotesTime)*1000).." ms");
307 Questie:debug_Print();
308 elseif (v.EVENT == "LOADEVENTS") then
309 local LoadEventsTime = GetTime();
310 GameLoadingComplete = true;
311 Questie:OnLoad_QuestEvents();
312 QUESTIE_EVENTQUEUE[k] = nil;
313 Questie:debug_Print("OnUpdate: "..v.EVENT.." Took: "..tostring((GetTime()- LoadEventsTime)*1000).." ms");
314 Questie:debug_Print();
315 end
316 else
317 if k ~= index then
318 QUESTIE_EVENTQUEUE[index] = v;
319 QUESTIE_EVENTQUEUE[k] = nil;
320 end
321 index = index + 1;
322 end
323 end
324 end
325 --Check if player is dead and NOT released and if the corpseArrow is on. No sense entering the
326 --function if the player is not dead or the corpseArrow isn't turned on.
327 local runonce = true
328 if UnitIsDeadOrGhost("player") and (QuestieConfig.corpseArrow == true) and (runonce == true) then
329 local bgactive = false
330 for i=1, MAX_BATTLEFIELD_QUEUES do
331 bgstatus = GetBattlefieldStatus(i)
332 if (bgstatus and bgstatus == "active") then
333 bgactive = true
334 end
335 end
336 --Checks if player released and not in a Battleground. No sense painting a corpseArrow if
337 --the player is waiting to be rez'd. If player is in a Battleground then this code never
338 --runs.
339 if (UnitIsDead("player") ~= 1) and (bgactive == false) then
340 if DiedAtX and DiedAtY and DiedAtX ~= 0 and DiedAtY ~= 0 then --<--set globally by PLAYER_DEAD event
341 local ddist, xDelta, yDelta = Astrolabe:ComputeDistance(DiedInCont, DiedInZone, DiedAtX, DiedAtY, continent, zone, xNote, yNote)
342 local dtitle = "My Dead Corpse"
343 local dpoint = {c = DiedInCont, z = DiedInZone, x = DiedAtX, y = DiedAtY}
344 SetCrazyArrow(dpoint, ddist, dtitle) --<--sets corpseArrow
345 if (not WorldMapFrame:IsVisible() == nil) then
346 return
347 end
348 --Allows the player to browse to a different map zone while dead. Otherwise, they'd
349 --be stuck looking at the map zone they died in.
350 if (WorldMapFrame:IsVisible() == nil) and (WorldMapUpdateSpamOff == nil) then
351 SetMapToCurrentZone()
352 WorldMapUpdateSpamOff = true
353 end
354 end
355 else
356 --Catch-all while the 'if' statement is false and hiding the arrow fails to fire in
357 --some other update, event or function. This function always overwrites the objective
358 --point so it's safe to always hide the arrow once we're inside the function.
359 TomTomCrazyArrow:Hide()
360 end
361 end
362 runonce = false
363 end
364 ---------------------------------------------------------------------------------------------------
365 --Questie Event Handlers
366 ---------------------------------------------------------------------------------------------------
367 function Questie:AddEvent(EVENT, DELAY, MSG)
368 local evnt = {};
369 evnt.EVENT = EVENT;
370 evnt.TIME = GetTime();
371 evnt.DELAY = DELAY;
372 evnt.MSG = MSG;
373 table.insert(QUESTIE_EVENTQUEUE, evnt);
374 end
375 ---------------------------------------------------------------------------------------------------
376 function Questie:CheckQuestLogStatus()
377 QUESTIE_UPDATE_EVENT = 1;
378 if(GetTime() - QUESTIE_LAST_UPDATECACHE > 0.01) then
379 Questie:AddEvent("UPDATECACHE", 0.2);
380 QUESTIE_LAST_UPDATECACHE = GetTime();
381 else
382 QUESTIE_LAST_UPDATECACHE = GetTime();
383 end
384 if(GetTime() - QUESTIE_LAST_CHECKLOG > 0.01) then
385 Questie:AddEvent("CHECKLOG", 0.4);
386 QUESTIE_LAST_CHECKLOG = GetTime();
387 else
388 QUESTIE_LAST_CHECKLOG = GetTime();
389 end
390 if(GetTime() - QUESTIE_LAST_UPDATE > 0.01) then
391 Questie:AddEvent("UPDATE", 0.6);
392 QUESTIE_LAST_UPDATE = GetTime();
393 else
394 QUESTIE_LAST_UPDATE = GetTime();
395 end
396 end
397 ---------------------------------------------------------------------------------------------------
398 function Questie:RefreshQuestStatus()
399 QUESTIE_UPDATE_EVENT = 1;
400 if (GetTime() - QUESTIE_LAST_SYNCLOG > 0.1) then
401 Questie:AddEvent("SYNCLOG", 1.0);
402 QUESTIE_LAST_SYNCLOG = GetTime();
403 else
404 QUESTIE_LAST_SYNCLOG = GetTime();
405 end
406 if (GetTime() - QUESTIE_LAST_DRAWNOTES > 0.1) then
407 Questie:AddEvent("DRAWNOTES", 1.2);
408 QUESTIE_LAST_DRAWNOTES = GetTime();
409 else
410 QUESTIE_LAST_DRAWNOTES = GetTime();
411 end
412 if (GetTime() - QUESTIE_LAST_TRACKER > 0.1) then
413 Questie:AddEvent("TRACKER", 1.2);
414 QUESTIE_LAST_TRACKER = GetTime();
415 else
416 QUESTIE_LAST_TRACKER = GetTime();
417 end
418 end
419 ---------------------------------------------------------------------------------------------------
420 function Questie:OnEvent(this, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
421 if (event =="ADDON_LOADED" and arg1 == "!Questie") then
422 Questie:CreateMinimapButton();
423 -------------------------------------------------
424 elseif (event == "CHAT_MSG_LOOT") then
425 --Questie:debug_Print("OnEvent: CHAT_MSG_LOOT");
426 Questie:ParseQuestLoot(arg1);
427 -------------------------------------------------
428 elseif (event == "MINIMAP_UPDATE_ZOOM" ) then
429 if (QuestieConfig.minimapZoom == true) then
430 Astrolabe:isMinimapInCity();
431 end
432 -------------------------------------------------
433 elseif (event == "PLAYER_DEAD") then
434 --Records players continent, zone and coordinates upon death to be used later. This is more
435 --accurate than "posX, posY = GetCorpseMapPosition()" Blizzards API only records X and Y
436 --coordinates.
437 DiedInCont, DiedInZone, DiedAtX, DiedAtY = Astrolabe:GetCurrentPlayerPosition();
438 -------------------------------------------------
439 elseif ( event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED_NEW_AREA" ) then
440 if not WorldMapFrame:IsVisible() then SetMapToCurrentZone() end
441 -------------------------------------------------
442 elseif ( event == "PLAYER_LEAVING_WORLD" ) then
443 Questie:CLEAR_ALL_NOTES();
444 -------------------------------------------------
445 elseif (event == "PLAYER_LEVEL_UP") then
446 Questie:SetAvailableQuests(tonumber(arg1));
447 Questie:AddEvent("DRAWNOTES", 0.1);
448 -------------------------------------------------
449 elseif (event == "PLAYER_LOGIN") then
450 Questie:debug_Print("OnEvent: PLAYER_LOGIN");
451 Questie:hookTooltip();
452 Questie:hookTooltipLineCheck();
453 QuestieTracker:createTrackingFrame();
454 QuestieTracker:LoadModule();
455 Questie:BlockTranslations();
456 Astrolabe:isMinimapInCity();
457 Questie:LoadEQL3Fix();
458 Questie:Toggle_Position();
459 Questie:AddEvent("UPDATECACHE", 1.8);
460 Questie:AddEvent("CHECKLOG", 2.0);
461 Questie:AddEvent("UPDATE", 2.2);
462 Questie:AddEvent("LOADEVENTS", 2.4);
463 Questie:AddEvent("SYNCWATCH", 2.5);
464 Questie:AddEvent("SYNCLOG", 2.6);
465 Questie:AddEvent("DRAWNOTES", 2.7);
466 Questie:AddEvent("TRACKER", 2.8);
467 -------------------------------------------------
468 elseif (event == "PLAYER_UNGHOST") then
469 --If the corpseArrow is turned off and if the player has an objective active on the
470 --questArrow, this check won't clear it. The corpseArrow is only active when it's enabled
471 if (QuestieConfig.corpseArrow == false) and (QuestieConfig.arrowEnabled == true) then
472 return;
473 --Safety check in case this isn't done in another event or function.
474 elseif (QuestieConfig.corpseArrow == true) then
475 TomTomCrazyArrow:Hide();
476 end
477 WorldMapUpdateSpamOff = nil;
478 -------------------------------------------------
479 elseif (event == "QUEST_PROGRESS") then
480 Questie:debug_Print("OnEvent: QUEST_PROGRESS.\n GetNumQuestItems: "..GetNumQuestItems())
481 Questie:OnQuestProgress()
482 -------------------------------------------------
483 elseif (event == "QUEST_LOG_UPDATE") then
484 --Questie:debug_Print("OnEvent: QUEST_LOG_UPDATE");
485 Questie:CheckQuestLogStatus();
486 -------------------------------------------------
487 elseif (event == "QUEST_ITEM_UPDATE") then
488 Questie:debug_Print("OnEvent: QUEST_ITEM_UPDATE");
489 Questie:CheckQuestLogStatus();
490 -------------------------------------------------
491 elseif (event == "VARIABLES_LOADED") then
492 Questie:SetupDefaults();
493 Questie:CheckDefaults();
494 end
495 end
496 ---------------------------------------------------------------------------------------------------
497 --Questie Worldmap Toggle Button
498 ---------------------------------------------------------------------------------------------------
499 function Questie:Toggle()
500 if (QuestieConfig.showMapNotes == true) and (IsQuestieActive == true) then
501 QuestieConfig.showMapNotes = false;
502 IsQuestieActive = false;
503 QuestieMapNotes = {};
504 QuestieAvailableMapNotes = {};
505 Questie:CLEAR_ALL_NOTES();
506 LastQuestLogHashes = nil;
507 else
508 LastQuestLogHashes = nil;
509 IsQuestieActive = true;
510 QuestieConfig.showMapNotes = true;
511 Questie:UpdateGameClientCache(true)
512 end
513 end
514 ---------------------------------------------------------------------------------------------------
515 --Reposition Questie Worldmap Toggle Button - MetaMap & Cartographer support
516 ---------------------------------------------------------------------------------------------------
517 function Questie:Toggle_Position()
518 if IsAddOnLoaded("MetaMap") then
519 Questie_Toggle:ClearAllPoints();
520 Questie_Toggle:SetPoint("CENTER", WorldMapFrame, "CENTER", -430, 335);
521 end
522 if IsAddOnLoaded("Cartographer") then
523 Questie_Toggle:ClearAllPoints();
524 Questie_Toggle:SetPoint("CENTER", WorldMapFrame, "CENTER", 0, 338);
525 end
526 end
527 ---------------------------------------------------------------------------------------------------
528 -- QuestieSeenQuests flags to denote quest status in all cache and saved variable checks.
529 -- 1 : Quest Complete
530 -- 0 : Found in QuestLog
531 -- -1 : Abandoned Quest
532 -- Example: QuestieSeenQuests[hash] = flag
533 ---------------------------------------------------------------------------------------------------
534 --Cleans and resets the users Questie SavedVariables. Will also perform some quest and quest
535 --tracker database clean up to purge stale/invalid entries. More notes below. Popup confirmation
536 --of Yes or No - Popup has a 60 second timeout.
537 ---------------------------------------------------------------------------------------------------
538 function Questie:ClearConfig(arg)
539 if arg == "slash" then
540 msg = "|cFFFFFF00You are about to clear your characters settings. This will NOT delete your quest database but it will clean it up a little. This will reset abandoned quests, and remove any finished or stale quest entries in the QuestTracker database. Your UI will be reloaded automatically to finalize the new settings.|n|nAre you sure you want to continue?|r";
541 elseif arg == "version" then
542 msg = "|cFFFFFF00VERSION CHECK!|n|nIt appears you have installed Questie for the very first time or you have recently upgraded to a new version. Your UI will automatically be reloaded and your QuestieConfig will be updated and cleaned of any stale entries. This will NOT clear your quest history.|n|nPlease click Yes to begin the update.|r";
543 end
544 StaticPopupDialogs["CLEAR_CONFIG"] = {
545 text = TEXT(msg),
546 button1 = TEXT(YES),
547 button2 = TEXT(NO),
548 OnAccept = function()
549 --Clears config
550 QuestieConfig = nil;
551 --Clears tracker settings
552 QuestieTrackerVariables = nil;
553 --Set default settings
554 Questie:SetupDefaults();
555 --Clean QuestieSeenQuests DB
556 for k,v in pairs(QuestieSeenQuests) do
557 if (k == 0) or (k == -1) then
558 QuestieSeenQuests[k] = nil;
559 end
560 end
561 --Clear QuestieCachedQuests DB
562 QuestieCachedQuests = {};
563 Questie:CheckDefaults();
564 ReloadUI();
565 end,
566 timeout = 60,
567 exclusive = 1,
568 hideOnEscape = 1
569 };
570 StaticPopup_Show ("CLEAR_CONFIG");
571 end
572 ---------------------------------------------------------------------------------------------------
573 --Clears and deletes the users Questie SavedVariables. One option is for a user initiated NUKE and
574 --the other option will execute when Questie senses a new level 1 character using a Saved Variables
575 --file from a deleted character. Popup confirmation of Yes or No - Popup has a 60 second timeout.
576 ---------------------------------------------------------------------------------------------------
577 function Questie:NUKE(arg)
578 if arg == "slash" then
579 msg = "|cFFFFFF00You are about to completely wipe your characters saved variables. This includes all quests you've completed, settings and preferences, and QuestTracker location.|n|nAre you sure you want to continue?|r";
580 elseif arg == "newcharacter" then
581 msg = "|cFFFFFF00ERROR! Database Detected!|n|nIt appears that you've used this name for a previous character. There are entries in the QuestDatabase that need to be cleared in order for Questie to work properly with this character. Your UI will be reloaded automatically to clear your config.|n|nAre you sure you want to continue?|r";
582 end
583 StaticPopupDialogs["NUKE_CONFIG"] = {
584 text = TEXT(msg),
585 button1 = TEXT(YES),
586 button2 = TEXT(NO),
587 OnAccept = function()
588 --Clears quests DB
589 QuestieSeenQuests = {};
590 --Clears cached quests DB
591 QuestieCachedQuests = {};
592 --Clears config settings
593 QuestieConfig = nil;
594 --Clears tracker settings
595 QuestieTrackerVariables = nil;
596 --Set default settings
597 Questie:SetupDefaults();
598 Questie:CheckDefaults();
599 ReloadUI();
600 end,
601 timeout = 60,
602 exclusive = 1,
603 hideOnEscape = 1
604 }
605 StaticPopup_Show ("NUKE_CONFIG");
606 end
607 ---------------------------------------------------------------------------------------------------
608 --Questie Slash Handler and Help Menu
609 ---------------------------------------------------------------------------------------------------
610 QuestieFastSlash = {
611 ["arrow"] = function()
612 --Default: True
613 QuestieConfig.arrowEnabled = not QuestieConfig.arrowEnabled;
614 if QuestieConfig.arrowEnabled then
615 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Arrow On) |r");
616 else
617 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Arrow Off) |r");
618 TomTomCrazyArrow:Hide();
619 end
620 end,
621 ["arrowtime"] = function()
622 --Default: False
623 QuestieConfig.arrowTime = not QuestieConfig.arrowTime;
624 if QuestieConfig.arrowTime then
625 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Arrow Time to Arrive On) |r");
626 TomTomCrazyArrow.tta:Show();
627 else
628 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Arrow Time to Arrive Off) |r");
629 TomTomCrazyArrow.tta:Hide();
630 end
631 end,
632 ["background"] = function()
633 --Default: False
634 QuestieConfig.trackerBackground = not QuestieConfig.trackerBackground;
635 if QuestieConfig.trackerBackground then
636 ReloadUI();
637 else
638 ReloadUI();
639 end
640 end,
641 ["backgroundalpha"] = function(args)
642 --Default: 0.6 (60%)
643 if args then
644 local val = tonumber(args);
645 QuestieConfig.trackerAlpha = val/100;
646 QuestieTracker:FillTrackingFrame();
647 DEFAULT_CHAT_FRAME:AddMessage("QuestieTracker:|c0000ffc0 (Background Alpha Set To: |r|c0000c0ff"..val.."%|r|c0000ffc0)|r");
648 else
649 DEFAULT_CHAT_FRAME:AddMessage("|cFFFF2222 Error: Invalid Number Supplied! |r");
650 end
651 end,
652 ["clearconfig"] = function()
653 Questie:ClearConfig("slash")
654 end,
655 ["cleartracker"] = function()
656 --Default: None - Popup confirmation of Yes or No - Popup has a 60 second timeout.
657 StaticPopupDialogs["CLEAR_TRACKER"] = {
658 text = "|cFFFFFF00You are about to reset your QuestTracker. This will only reset it's saved location and place it in the center of your screen. Your UI will be reloaded automatically.|n|nAre you sure you want to continue?|r",
659 button1 = TEXT(YES),
660 button2 = TEXT(NO),
661 OnAccept = function()
662 --Clears tracker settings
663 QuestieTrackerVariables = {};
664 --Setup default settings and repositions the QuestTracker against the left side of
665 --the screen.
666 QuestieTrackerVariables = {
667 ["position"] = {
668 ["relativeTo"] = "UIParent",
669 ["point"] = "CENTER",
670 ["relativePoint"] = "CENTER",
671 ["yOfs"] = 0,
672 ["xOfs"] = 0,
673 },
674 };
675 ReloadUI();
676 end,
677 timeout = 60,
678 exclusive = 1,
679 hideOnEscape = 1
680 };
681 StaticPopup_Show ("CLEAR_TRACKER");
682 end,
683 ["cluster"] = function()
684 --Default: True
685 QuestieConfig.clusterQuests = not QuestieConfig.clusterQuests;
686 if QuestieConfig.clusterQuests then
687 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Clustered Icons On) |r");
688 else
689 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Clustered Icons Off) |r");
690 end
691 Questie:AddEvent("DRAWNOTES", 0.1);
692 end,
693 ["color"] = function()
694 --Default: False
695 QuestieConfig.boldColors = not QuestieConfig.boldColors;
696 if QuestieConfig.boldColors then
697 DEFAULT_CHAT_FRAME:AddMessage("QuestTracker:|c0000ffc0 (Alternate Colors On) |r");
698 else
699 DEFAULT_CHAT_FRAME:AddMessage("QuestTracker:|c0000ffc0 (Alternate Colors Off) |r");
700 end
701 QuestieTracker:FillTrackingFrame();
702 end,
703 ["corpsearrow"] = function()
704 --Default: True
705 QuestieConfig.corpseArrow = not QuestieConfig.corpseArrow;
706 if QuestieConfig.corpseArrow then
707 DEFAULT_CHAT_FRAME:AddMessage("QuestieCorpse:|c0000ffc0 (Arrow On) |r");
708 else
709 DEFAULT_CHAT_FRAME:AddMessage("QuestieCorpse:|c0000ffc0 (Arrow Off) |r");
710 TomTomCrazyArrow:Hide();
711 end
712 end,
713 ["header"] = function()
714 --Default: False
715 if (QuestieConfig.showTrackerHeader == false) then
716 StaticPopupDialogs["TRACKER_HEADER_F"] = {
717 text = "|cFFFFFF00Due to the way the QuestTracker frame is rendered, your UI will automatically be reloaded.|n|nAre you sure you want to continue?|r",
718 button1 = TEXT(YES),
719 button2 = TEXT(NO),
720 OnAccept = function()
721 QuestieConfig.showTrackerHeader = true;
722 ReloadUI();
723 end,
724 timeout = 60,
725 exclusive = 1,
726 hideOnEscape = 1
727 };
728 StaticPopup_Show ("TRACKER_HEADER_F");
729 end
730 if (QuestieConfig.showTrackerHeader == true) then
731 StaticPopupDialogs["TRACKER_HEADER_T"] = {
732 text = "|cFFFFFF00Due to the way the QuestTracker frame is rendered, your UI will automatically be reloaded.|n|nAre you sure you want to continue?|r",
733 button1 = TEXT(YES),
734 button2 = TEXT(NO),
735 OnAccept = function()
736 QuestieConfig.showTrackerHeader = false;
737 ReloadUI();
738 end,
739 timeout = 60,
740 exclusive = 1,
741 hideOnEscape = 1
742 };
743 StaticPopup_Show ("TRACKER_HEADER_T");
744 end
745 end,
746 ["hideminimap"] = function()
747 --Default: False
748 QuestieConfig.hideMinimapIcons = not QuestieConfig.hideMinimapIcons;
749 if QuestieConfig.hideMinimapIcons then
750 DEFAULT_CHAT_FRAME:AddMessage("QuestieStarters:|c0000ffc0 (Are now being hidden) |r");
751 else
752 DEFAULT_CHAT_FRAME:AddMessage("QuestieStarters:|c0000ffc0 (Are now being shown) |r");
753 end
754 Questie:AddEvent("DRAWNOTES", 0.1);
755 end,
756 ["hideobjectives"] = function()
757 --Default: False
758 QuestieConfig.hideObjectives = not QuestieConfig.hideObjectives;
759 if QuestieConfig.hideObjectives then
760 DEFAULT_CHAT_FRAME:AddMessage("QuestieObjectives:|c0000ffc0 (Set to always hide) |r");
761 else
762 DEFAULT_CHAT_FRAME:AddMessage("QuestieObjectives:|c0000ffc0 (Set to always show) |r");
763 end
764 Questie:AddEvent("DRAWNOTES", 0.1);
765 end,
766 ["listdirection"] = function()
767 --Default: False
768 if (QuestieConfig.trackerList == false) then
769 StaticPopupDialogs["BOTTOM_UP"] = {
770 text = "|cFFFFFF00You are about to change the way quests are listed in the QuestTracker. They will grow from bottom --> up and sorted by distance from top --> down.|n|nYour UI will be automatically reloaded to apply the new settings.|n|nAre you sure you want to continue?|r",
771 button1 = TEXT(YES),
772 button2 = TEXT(NO),
773 OnAccept = function()
774 QuestieConfig.trackerList = true;
775 QuestieTrackerVariables = {};
776 QuestieTrackerVariables["position"] = {
777 ["point"] = "CENTER",
778 ["relativePoint"] = "CENTER",
779 ["relativeTo"] = "UIParent",
780 ["yOfs"] = 0,
781 ["xOfs"] = 0,
782 };
783 ReloadUI();
784 end,
785 timeout = 120,
786 exclusive = 1,
787 hideOnEscape = 1
788 };
789 StaticPopup_Show ("BOTTOM_UP");
790 elseif (QuestieConfig.trackerList == true) then
791 StaticPopupDialogs["TOP_DOWN"] = {
792 text = "|cFFFFFF00You are about to change the tracker back to it's default state. Quests will grow from top --> down and also sorted by distance from top --> down in the QuestTracker.|n|nYour UI will be reloaded to apply the new settings.|n|nAre you sure you want to continue?|r",
793 button1 = TEXT(YES),
794 button2 = TEXT(NO),
795 OnAccept = function()
796 QuestieConfig.trackerList = false;
797 QuestieTrackerVariables = {};
798 QuestieTrackerVariables["position"] = {
799 ["point"] = "CENTER",
800 ["relativePoint"] = "CENTER",
801 ["relativeTo"] = "UIParent",
802 ["yOfs"] = 0,
803 ["xOfs"] = 0,
804 };
805 ReloadUI();
806 end,
807 timeout = 60,
808 exclusive = 1,
809 hideOnEscape = 1
810 };
811 StaticPopup_Show ("TOP_DOWN");
812 end
813 end,
814 ["mapnotes"] = function()
815 --Default: True
816 Questie:Toggle();
817 if QuestieConfig.showMapNotes then
818 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Map Notes On) |r");
819 else
820 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Map Notes Off) |r");
821 end
822 end,
823 ["maxlevel"] = function()
824 --Default: True
825 QuestieConfig.maxLevelFilter = not QuestieConfig.maxLevelFilter;
826 if QuestieConfig.maxLevelFilter then
827 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Max-Level Filter On) |r");
828 else
829 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Max-Level Filter Off) |r");
830 end
831 Questie:AddEvent("DRAWNOTES", 0.1);
832 end,
833 ["minimapbutton"] = function()
834 --Default: True
835 QuestieConfig.minimapButton = not QuestieConfig.minimapButton;
836 if QuestieConfig.minimapButton then
837 Questie.minimapButton:Show();
838 else
839 Questie.minimapButton:Hide();
840 end
841 end,
842 ["minimapzoom"] = function()
843 --Default: False
844 QuestieConfig.minimapZoom = not QuestieConfig.minimapZoom;
845 if QuestieConfig.minimapZoom then
846 DEFAULT_CHAT_FRAME:AddMessage("QuestieMiniMap:|c0000ffc0 (MiniMap Auto-Zoom On) |r");
847 QuestieConfig.minimapZoom = true;
848 else
849 DEFAULT_CHAT_FRAME:AddMessage("QuestieMiniMap:|c0000ffc0 (MiniMap Auto-Zoom Off) |r");
850 QuestieConfig.minimapZoom = false;
851 end
852 end,
853 ["minlevel"] = function()
854 --Default: True
855 QuestieConfig.minLevelFilter = not QuestieConfig.minLevelFilter;
856 if QuestieConfig.minLevelFilter then
857 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Min-Level Filter On) |r");
858 else
859 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Min-Level Filter Off) |r");
860 end
861 Questie:AddEvent("DRAWNOTES", 0.1);
862 end,
863 ["mintracker"] = function()
864 --Default: False
865 if QuestieConfig.trackerMinimize then
866 DEFAULT_CHAT_FRAME:AddMessage("QuestTracker:|c0000ffc0 (Maximized) |r");
867 QuestieConfig.trackerMinimize = false;
868 QuestieTracker.frame:Show();
869 else
870 DEFAULT_CHAT_FRAME:AddMessage("QuestTracker:|c0000ffc0 (Minimized) |r");
871 QuestieConfig.trackerMinimize = true;
872 QuestieTracker.frame:Hide();
873 end
874 end,
875 ["NUKE"] = function()
876 --Default: None - Popup confirmation of Yes or No - Popup has a 60 second timeout.
877 Questie:NUKE("slash")
878 end,
879 ["professions"] = function()
880 --Default: False
881 QuestieConfig.showProfessionQuests = not QuestieConfig.showProfessionQuests;
882 if QuestieConfig.showProfessionQuests then
883 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Profession Quests On) |r");
884 else
885 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Profession Quests Off) |r");
886 end
887 Questie:AddEvent("DRAWNOTES", 0.1);
888 end,
889 ["qtscale"] = function(arg)
890 --Default: Small
891 if arg == "large" then
892 QuestieConfig.trackerScale = 1.4;
893 ReloadUI();
894 elseif arg == "medium" then
895 QuestieConfig.trackerScale = 1.2;
896 ReloadUI();
897 elseif arg == "small" then
898 QuestieConfig.trackerScale = 1.0;
899 ReloadUI();
900 else
901 DEFAULT_CHAT_FRAME:AddMessage("|cFFFF2222 Error: Invalid Option.");
902 end
903 end,
904 ["resizemap"] = function()
905 --Default: False
906 QuestieConfig.resizeWorldmap = not QuestieConfig.resizeWorldmap;
907 if QuestieConfig.resizeWorldmap then
908 ReloadUI();
909 else
910 ReloadUI();
911 end
912 end,
913 ["setmaxlevel"] = function(args)
914 --Default7:Quests will not appear until your level is 7 levels below the quest's minimum level
915 if args then
916 local val = tonumber(args);
917 DEFAULT_CHAT_FRAME:AddMessage("Max-Level filter set to "..val);
918 QuestieConfig.maxShowLevel = val;
919 else
920 DEFAULT_CHAT_FRAME:AddMessage("|cFFFF2222Error: Invalid Number Supplied!");
921 end
922 Questie:AddEvent("DRAWNOTES", 0.1);
923 end,
924 ["setminlevel"] = function(args)
925 --Default4:Quests will stop appearing when their recommended level is below your level minus 4
926 if args then
927 local val = tonumber(args);
928 DEFAULT_CHAT_FRAME:AddMessage("Min-Level filter set to "..val);
929 QuestieConfig.minShowLevel = val;
930 else
931 DEFAULT_CHAT_FRAME:AddMessage("|cFFFF2222Error: Invalid Number Supplied!");
932 end
933 Questie:AddEvent("DRAWNOTES", 0.1);
934 end,
935 ["settings"] = function()
936 Questie:CurrentUserToggles();
937 end,
938 ["showobjectives"] = function()
939 --Default: True
940 QuestieConfig.alwaysShowObjectives = not QuestieConfig.alwaysShowObjectives;
941 if QuestieConfig.alwaysShowObjectives then
942 DEFAULT_CHAT_FRAME:AddMessage("QuestieOjectives:|c0000ffc0 (Set to always show) |r");
943 else
944 DEFAULT_CHAT_FRAME:AddMessage("QuestieObjectives:|c0000ffc0 (Only show on maps while tracking) |r");
945 end
946 Questie:AddEvent("DRAWNOTES", 0.1);
947 end,
948 ["tooltips"] = function()
949 --Default: True
950 QuestieConfig.showToolTips = not QuestieConfig.showToolTips;
951 if QuestieConfig.showToolTips then
952 ReloadUI();
953 Questie:CheckDefaults();
954 else
955 ReloadUI();
956 Questie:CheckDefaults();
957 end
958 end,
959 ["tracker"] = function()
960 --Default: True
961 if (QuestieConfig.trackerEnabled == true) then
962 StaticPopupDialogs["HIDE_TRACKER"] = {
963 text = "|cFFFFFF00You are about to disable the QuestieTracker. If you're using a QuestLog mod with a built in tracker then after your UI reloads you will be using that mods default tracker. Otherwise you'll use WoW's default tracker.|n|nYour UI will be automatically reloaded to apply the new settings.|n|nAre you sure you want to continue?|r",
964 button1 = TEXT(YES),
965 button2 = TEXT(NO),
966 OnAccept = function()
967 QuestieConfig.trackerEnabled = false;
968 QuestieTracker:Hide();
969 QuestieTracker.frame:Hide();
970 ReloadUI();
971 end,
972 timeout = 120,
973 exclusive = 1,
974 hideOnEscape = 1
975 };
976 StaticPopup_Show ("HIDE_TRACKER");
977 elseif (QuestieConfig.trackerEnabled == false) then
978 StaticPopupDialogs["SHOW_TRACKER"] = {
979 text = "|cFFFFFF00You are about to enabled the QuestieTracker. The previous quest tracker will be disabled.|n|nYour UI will be reloaded to apply the new settings.|n|nAre you sure you want to continue?|r",
980 button1 = TEXT(YES),
981 button2 = TEXT(NO),
982 OnAccept = function()
983 QuestieConfig.trackerEnabled = true;
984 QuestieTracker:Show();
985 ReloadUI();
986 end,
987 timeout = 60,
988 exclusive = 1,
989 hideOnEscape = 1
990 };
991 StaticPopup_Show ("SHOW_TRACKER");
992 end
993 end,
994 ["questlinks"] = function()
995 --Default: True
996 QuestieConfig.useQuestLinks = not QuestieConfig.useQuestLinks;
997 if QuestieConfig.useQuestLinks then
998 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Quest Links On) |r");
999 else
1000 DEFAULT_CHAT_FRAME:AddMessage("QuestieQuest:|c0000ffc0 (Quest Links Off) |r");
1001 end
1002 end,
1003 ---------------------------------------------------------------------------------------------------
1004 --Questie Help Menu
1005 ---------------------------------------------------------------------------------------------------
1006 ["help"] = function()
1007 DEFAULT_CHAT_FRAME:AddMessage("Questie SlashCommand Help Menu:", 1, 0.75, 0);
1008 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie arrow |r|c0000ffc0(toggle)|r QuestArrow: Toggle", 0.75, 0.75, 0.75);
1009 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie arrowtime |r|c0000ffc0(toggle)|r QuestArrow: Toggle Time to Arrive", 0.75, 0.75, 0.75);
1010 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie background |r|c0000ffc0(toggle)|r QuestTracker: Background", 0.75, 0.75, 0.75);
1011 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie backgroundalpha |r|c0000ffc0(10-100%)|r QuestTracker: Background Alpha Level (default=60%)", 0.75, 0.75, 0.75);
1012 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie clearconfig |r|c0000ffc0(Pop-up)|r UserSettings: Reset settings. Will NOT delete quest data.", 0.75, 0.75, 0.75);
1013 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie cleartracker |r|c0000ffc0(Pop-up)|r QuestTracker: Reset & move tracker to center screen.", 0.75, 0.75, 0.75);
1014 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie cluster |r|c0000ffc0(toggle)|r QuestMap: Groups nearby start/finish/objective icons together.", 0.75, 0.75, 0.75);
1015 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie color |r|c0000ffc0(toggle)|r QuestTracker: Select two different color themes", 0.75, 0.75, 0.75);
1016 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie corpsearrow |r|c0000ffc0(toggle)|r CorpseArrow: Toggle", 0.75, 0.75, 0.75);
1017 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie header |r|c0000ffc0(toggle)|r QuestTracker: Header & Quest Counter", 0.75, 0.75, 0.75);
1018 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie hideminimap |r|c0000ffc0(toggle)|r QuestMap: Removes quest starter icons from Minimap", 0.75, 0.75, 0.75);
1019 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie hideobjectives |r|c0000ffc0(toggle)|r QuestMap: Hide all objectives for obtained quests", 0.75, 0.75, 0.75);
1020 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie listdirection |r|r|c0000ffc0(list)|r QuestTracker: Change list order: Top-->Down or Bottom-->Up", 0.75, 0.75, 0.75);
1021 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie mapnotes |r|c0000ffc0(toggle)|r Questie: Commandline version of ToggleQuestie button", 0.75, 0.75, 0.75);
1022 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie maxlevel |r|c0000ffc0(toggle)|r QuestMap: Filter - see setmaxlevel", 0.75, 0.75, 0.75);
1023 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie minimapbutton |r|c0000ffc0(toggle)|r QuestMap: Removes questie minimap button", 0.75, 0.75, 0.75);
1024 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie minimapzoom |r|c0000ffc0(toggle)|r QuestMap: Removes questie minimap auto-zoom", 0.75, 0.75, 0.75);
1025 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie minlevel |r|c0000ffc0(toggle)|r QuestMap: Filter - see setminlevel", 0.75, 0.75, 0.75);
1026 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie mintracker |r|c0000ffc0(toggle)|r QuestTracker: Minimize or Maximize the QuestieTracker", 0.75, 0.75, 0.75);
1027 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie NUKE |r|r|c0000ffc0(Pop-up)|r Database: Resets ALL Questie data and settings", 0.75, 0.75, 0.75);
1028 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie options |r-- Displays the Questie Options configuration interface", 0.75, 0.75, 0.75); -- TODO:Remove when minimap button is used
1029 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie professions |r|c0000ffc0(toggle)|r QuestQuest: Profession quest filter", 0.75, 0.75, 0.75);
1030 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie setmaxlevel |r|c0000ffc0<number>|r QuestMap: Show quests <X> levels above players level (default=7)", 0.75, 0.75, 0.75);
1031 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie setminlevel |r|c0000ffc0<number>|r QuestMap: Show quests <X> levels below players level (default=4)", 0.75, 0.75, 0.75);
1032 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie settings |r|c0000ffc0(list)|r Questie: Displays your current toggles and settings.", 0.75, 0.75, 0.75);
1033 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie showobjectives |r|c0000ffc0(toggle)|r QuestTracker: Show only quest objectives for actively tracked quests ", 0.75, 0.75, 0.75);
1034 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie tooltips |r|c0000ffc0(toggle)|r QuestMobs&Items: Always show quest and objective tool tips", 0.75, 0.75, 0.75);
1035 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie tracker |r|c0000ffc0(toggle)|r QuestTracker: Turn on and off the quest tracker", 0.75, 0.75, 0.75);
1036 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie qtscale |r|c0000ffc0(small|medium|large)|r QuestTracker: Adjust the scale of the tracker (default=small)", 0.75, 0.75, 0.75);
1037 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie questlinks |r|c0000ffc0(toggle)|r QuestLog: Paste links instead of text into chat when shift-clicking a quest", 0.75, 0.75, 0.75);
1038 if (IsAddOnLoaded("Cartographer")) or (IsAddOnLoaded("MetaMap")) then
1039 return;
1040 elseif (not IsAddOnLoaded("Cartographer")) or (not IsAddOnLoaded("MetaMap")) then
1041 DEFAULT_CHAT_FRAME:AddMessage("|c0000c0ff /questie resizemap |r--|c0000ffc0(toggle)|r QuestMap: Shrinks Worldmap and allows dragging", 0.75, 0.75, 0.75);
1042 end
1043 end,
1044 ["options"] = function()
1045 Questie:OptionsForm_Display()
1046 end,
1047 };
1048 ---------------------------------------------------------------------------------------------------
1049 function Questie_SlashHandler(msgbase)
1050 local space = findFirst(msgbase, " ");
1051 local msg, args;
1052 if not space or space == 1 then
1053 msg = msgbase;
1054 else
1055 msg = string.sub(msgbase, 1, space);
1056 args = string.sub(msgbase, space+2);
1057 end
1058 if QuestieFastSlash[msg] ~= nil then
1059 if ( QuestieOptionsForm:IsVisible() ) then
1060 DEFAULT_CHAT_FRAME:AddMessage("|cffff0000Error: cannot execute commands while the Questie options window is open.|r")
1061 else
1062 QuestieFastSlash[msg](args);
1063 end
1064 else
1065 if (not msg or msg=="") then
1066 QuestieFastSlash["help"]();
1067 else
1068 DEFAULT_CHAT_FRAME:AddMessage("Unknown operation: " .. msg .. " try /questie help");
1069 end
1070 end
1071 end
1072 ---------------------------------------------------------------------------------------------------
1073 --Displays to the player all Questie vars
1074 ---------------------------------------------------------------------------------------------------
1075 function Questie:CurrentUserToggles()
1076 DEFAULT_CHAT_FRAME:AddMessage("Questie Settings:", 0.5, 0.5, 1);
1077 local Vars = {
1078 [1] = { "alwaysShowObjectives" },
1079 [2] = { "arrowEnabled" },
1080 [3] = { "arrowTime" },
1081 [4] = { "boldColors" },
1082 [5] = { "clusterQuests" },
1083 [6] = { "corpseArrow" },
1084 [7] = { "getVersion" },
1085 [8] = { "hideMinimapIcons" },
1086 [9] = { "hideObjectives" },
1087 [10] = { "maxLevelFilter" },
1088 [11] = { "maxShowLevel" },
1089 [12] = { "minimapButton" },
1090 [13] = { "minimapZoom" },
1091 [14] = { "minLevelFilter" },
1092 [15] = { "minShowLevel" },
1093 [16] = { "resizeWorldmap" },
1094 [17] = { "showMapNotes" },
1095 [18] = { "showProfessionQuests" },
1096 [19] = { "showTrackerHeader" },
1097 [20] = { "showToolTips" },
1098 [21] = { "trackerAlpha" },
1099 [22] = { "trackerBackground" },
1100 [23] = { "trackerEnabled" },
1101 [24] = { "trackerList" },
1102 [25] = { "trackerMinimize" },
1103 [26] = { "trackerScale" },
1104 [27] = { "useQuestLinks" },
1105 };
1106 if QuestieConfig then
1107 i = 1;
1108 v = 1;
1109 while Vars[i] and Vars[i][v]do
1110 curVar = Vars[i][v];
1111 DEFAULT_CHAT_FRAME:AddMessage(" "..curVar.." = "..(tostring(QuestieConfig[curVar])), 0.5, 0.5, 1);
1112 i = i + 1;
1113 end
1114 end
1115 end
1116 ---------------------------------------------------------------------------------------------------
1117 --Handles linked Quests from chat - functionality introduced in Burning Crusade.
1118 ---------------------------------------------------------------------------------------------------
1119 local HookSetItemRef = SetItemRef;
1120 function SetItemRef(link, text, button)
1121 if ItemRefTooltip:IsVisible() then
1122 ItemRefTooltip:Hide();
1123 else
1124 isQuest, _, _ = string.find(link, "quest:(%d+):.*");
1125 if isQuest then
1126 _, _, QuestTitle = string.find(text, ".*|h%[(.*)%]|h.*");
1127 local questTitle = tostring(QuestTitle);
1128 if questTitle then
1129 ShowUIPanel(ItemRefTooltip);
1130 ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
1131 ItemRefTooltip:AddLine(questTitle);
1132 local questHash = Questie:getQuestHash(questTitle);
1133 questOb = nil;
1134 local QuestName = QuestieHashMap[questHash].name;
1135 if QuestName == questTitle then
1136 local index = 0;
1137 for k,v in pairs(Questie:SanitisedQuestLookup(QuestName)) do
1138 index = index + 1;
1139 if (index == 1) and (v[2] == questHash) and (k ~= "") then
1140 questOb = k;
1141 elseif (index > 0) and(v[2] == questHash) and (k ~= "") then
1142 questOb = k;
1143 elseif (index == 1) and (v[2] ~= questHash) and (k ~= "") then
1144 questOb = k;
1145 end
1146 end
1147 ItemRefTooltip:AddLine("Started by: |cFFa6a6a6"..QuestieHashMap[questHash].startedBy.."|r",1,1,1);
1148 if questOb ~= nil then
1149 ItemRefTooltip:AddLine("|cffffffff"..questOb.."|r",1,1,1,true);
1150 else
1151 ItemRefTooltip:AddLine("Quest *Objective* not found in Questie Database!", 1, .8, .8);
1152 ItemRefTooltip:AddLine("Please file a bug report on our GitHub portal:)", 1, .8, .8);
1153 ItemRefTooltip:AddLine("https://github.com/AeroScripts/QuestieDev/issues", 1, .8, .8);
1154 end
1155 local _, _, questLevel = string.find(QuestieHashMap[questHash].questLevel, "(%d+)");
1156 if questLevel ~= 0 and questLevel ~= "0" then
1157 local color = GetDifficultyColor(questLevel);
1158 ItemRefTooltip:AddLine("Quest Level " ..QuestieHashMap[questHash].questLevel, color.r, color.g, color.b);
1159 end
1160 ItemRefTooltip:Show();
1161 else
1162 ShowUIPanel(ItemRefTooltip);
1163 ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
1164 ItemRefTooltip:AddLine(questTitle, 1,1,0);
1165 ItemRefTooltip:AddLine("Quest not found in Questie Database!", 1, .8, .8);
1166 ItemRefTooltip:AddLine("Please file a bug report on our GitHub portal:)", 1, .8, .8);
1167 ItemRefTooltip:AddLine("https://github.com/AeroScripts/QuestieDev/issues", 1, .8, .8);
1168 end
1169 ItemRefTooltip:Show();
1170 end
1171 else
1172 HookSetItemRef(link, text, button);
1173 end
1174 end
1175 end
1176 ---------------------------------------------------------------------------------------------------
1177 --Misc helper functions and short cuts
1178 ---------------------------------------------------------------------------------------------------
1179 function findFirst(haystack, needle)
1180 local i=string.find(haystack, " ");
1181 if i==nil then return nil; else return i-1; end
1182 end
1183 ---------------------------------------------------------------------------------------------------
1184 function findLast(haystack, needle)
1185 local i=string.gfind(haystack, ".*"..needle.."()")()
1186 if i==nil then return nil; else return i-1; end
1187 end
1188 function Questie:LinkToID(link)
1189 if link then
1190 local _, _, id = string.find(link, "(%d+):");
1191 return tonumber(id);
1192 end
1193 end
1194 ---------------------------------------------------------------------------------------------------
1195 function GetCurrentMapID()
1196 local file = GetMapInfo();
1197 if file == nil then
1198 return -1;
1199 end
1200 local zid = QuestieZones[file];
1201 if zid == nil then
1202 return -1;
1203 else
1204 return zid[1];
1205 end
1206 end
1207 ---------------------------------------------------------------------------------------------------
1208 function Questie:MixString(mix, str)
1209 return Questie:MixInt(mix, Questie:HashString(str));
1210 end
1211 ---------------------------------------------------------------------------------------------------
1212 --Computes an Adler-32 checksum.
1213 function Questie:HashString(text)
1214 local a, b = 1, 0;
1215 for i=1,string.len(text) do
1216 a = Questie:Modulo((a+string.byte(text,i)), 65521);
1217 b = Questie:Modulo((b+a), 65521);
1218 end
1219 return b*65536+a;
1220 end
1221 ---------------------------------------------------------------------------------------------------
1222 --Lua5 doesnt support mod math via the % operator
1223 function Questie:Modulo(val, by)
1224 return val - math.floor(val/by)*by;
1225 end
1226 ---------------------------------------------------------------------------------------------------
1227 function Questie:MixInt(hash, addval)
1228 return bit.lshift(hash, 6) + addval;
1229 end
1230 ---------------------------------------------------------------------------------------------------
1231 --Returns the Levenshtein distance between the two given strings credit to:
1232 --https://gist.github.com/Badgerati/3261142
1233 function Questie:Levenshtein(str1, str2)
1234 local len1 = string.len(str1);
1235 local len2 = string.len(str2);
1236 local matrix = {};
1237 local cost = 0;
1238 --quick cut-offs to save time
1239 if (len1 == 0) then
1240 return len2;
1241 elseif (len2 == 0) then
1242 return len1;
1243 elseif (str1 == str2) then
1244 return 0;
1245 end
1246 --initialise the base matrix values
1247 for i = 0, len1, 1 do
1248 matrix[i] = {};
1249 matrix[i][0] = i;
1250 end
1251 for j = 0, len2, 1 do
1252 matrix[0][j] = j;
1253 end
1254 --actual Levenshtein algorithm
1255 for i = 1, len1, 1 do
1256 for j = 1, len2, 1 do
1257 if (string.byte(str1,i) == string.byte(str2,j)) then
1258 cost = 0;
1259 else
1260 cost = 1;
1261 end
1262 matrix[i][j] = math.min(matrix[i-1][j] + 1, matrix[i][j-1] + 1, matrix[i-1][j-1] + cost);
1263 end
1264 end
1265 --return the last value - this is the Levenshtein distance
1266 return matrix[len1][len2];
1267 end
1268  
1269 -- Simple function to convert values to booleans
1270 function Questie:toboolean(bool)
1271 return not not bool
1272 end
1273 ---------------------------------------------------------------------------------------------------
1274 --End of misc helper functions and short cuts
1275 ---------------------------------------------------------------------------------------------------