vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --------------------------------------------------------------------------------------------------- |
2 | -- Name: QuestieTracker |
||
3 | -- Description: Handles all the quest tracker related functions |
||
4 | --------------------------------------------------------------------------------------------------- |
||
5 | --///////////////////////////////////////////////////////////////////////////////////////////////-- |
||
6 | --------------------------------------------------------------------------------------------------- |
||
7 | QuestieTracker = CreateFrame("Frame", "QuestieTracker", UIParent, "ActionButtonTemplate"); |
||
8 | --------------------------------------------------------------------------------------------------- |
||
9 | -- Local vars |
||
10 | --------------------------------------------------------------------------------------------------- |
||
11 | local QGet_TitleText = GetTitleText; |
||
12 | local QGet_QuestLogTitle = GetQuestLogTitle; |
||
13 | local QGet_NumQuestLeaderBoards = GetNumQuestLeaderBoards; |
||
14 | local QGet_QuestLogLeaderBoard = GetQuestLogLeaderBoard; |
||
15 | local QGet_QuestLogQuestText = GetQuestLogQuestText; |
||
16 | local QGet_NumQuestLogEntries = GetNumQuestLogEntries; |
||
17 | local QGet_NumQuestWatches = GetNumQuestWatches; |
||
18 | local QGet_QuestLogSelection = GetQuestLogSelection; |
||
19 | local QSelect_QuestLogEntry = SelectQuestLogEntry; |
||
20 | --------------------------------------------------------------------------------------------------- |
||
21 | -- Global vars |
||
22 | --------------------------------------------------------------------------------------------------- |
||
23 | QuestieTracker.hasCleared = false; |
||
24 | QuestieTracker.questsyncUpdate = 0; |
||
25 | QuestieTracker.trackerUpdate = 0; |
||
26 | QuestieTracker.trackerSize = 0; |
||
27 | QuestieTracker.GeneralInterval = 0; |
||
28 | QuestieTracker.btnUpdate = 1; |
||
29 | QuestieTracker.questButtons = {}; |
||
30 | QuestieTracker.questNames = {}; |
||
31 | QuestieTracker.questObjects = {}; |
||
32 | QuestieTracker.MaxButtonWidths = {}; |
||
33 | QuestieTracker.highestIndex = 0; |
||
34 | QAddQuestWatch = nil; |
||
35 | QRemoveQuestWatch = nil; |
||
36 | QAutoQuestWatch_CheckDeleted = nil; |
||
37 | QAutoQuestWatch_Update = nil; |
||
38 | QIsQuestWatched = nil; |
||
39 | QAutoQuestWatch_OnUpdate = nil; |
||
40 | --------------------------------------------------------------------------------------------------- |
||
41 | -- OnEvent |
||
42 | --------------------------------------------------------------------------------------------------- |
||
43 | function QuestieTracker:OnEvent() |
||
44 | QuestieTracker[event](QuestieTracker, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); |
||
45 | end |
||
46 | --------------------------------------------------------------------------------------------------- |
||
47 | -- OnUpdate |
||
48 | --------------------------------------------------------------------------------------------------- |
||
49 | function QuestieTracker_OnUpdate() |
||
50 | if (IsAddOnLoaded("EQL3") or IsAddOnLoaded("ShaguQuest")) then |
||
51 | if (QuestieConfig.trackerEnabled == true) then |
||
52 | QuestWatchFrame:Hide(); |
||
53 | EQL3_QuestWatchFrame:Hide(); |
||
54 | else |
||
55 | QuestieTracker.frame:Hide(); |
||
56 | QuestieTrackerHeader:Hide(); |
||
57 | end |
||
58 | else |
||
59 | if (QuestieConfig.trackerEnabled == true) then |
||
60 | QuestWatchFrame:Hide(); |
||
61 | else |
||
62 | QuestieTracker.frame:Hide(); |
||
63 | QuestieTrackerHeader:Hide(); |
||
64 | end |
||
65 | end |
||
66 | if GetTime() - QuestieTracker.trackerUpdate >= 2 then |
||
67 | if (QuestieConfig.showMapNotes == true) or (QuestieConfig.alwaysShowObjectives == true) then |
||
68 | QuestieTracker:SortTrackingFrame(); |
||
69 | end |
||
70 | end |
||
71 | QuestieTracker.trackerUpdate = GetTime(); |
||
72 | end |
||
73 | --------------------------------------------------------------------------------------------------- |
||
74 | -- Register events |
||
75 | --------------------------------------------------------------------------------------------------- |
||
76 | QuestieTracker:SetScript("OnEvent", QuestieTracker.OnEvent); |
||
77 | QuestieTracker:SetScript("OnUpdate", QuestieTracker_OnUpdate); |
||
78 | --------------------------------------------------------------------------------------------------- |
||
79 | -- Automatically Calculates QuestieTracker Height and Width |
||
80 | --------------------------------------------------------------------------------------------------- |
||
81 | function QuestieTracker:updateTrackingFrameSize() |
||
82 | if (QuestieConfig.trackerEnabled == true) then |
||
83 | if (QuestieTracker.highestIndex == 0) or (QGet_NumQuestLogEntries == 0) then |
||
84 | QuestieTracker.frame:SetHeight(0.1); |
||
85 | QuestieTracker.frame:SetWidth(0.1); |
||
86 | QuestieTracker.frame:SetBackdropColor(0,0,0,0); |
||
87 | QuestieTracker.frame:Hide(); |
||
88 | if (QuestieConfig.showTrackerHeader == true) then |
||
89 | QuestieTrackerHeader:Hide(); |
||
90 | end |
||
91 | return; |
||
92 | end |
||
93 | QuestieTracker.frame:Hide(); |
||
94 | local lastButton = QuestieTracker.questButtons[QuestieTracker.highestIndex]; |
||
95 | if lastButton == nil then return; end |
||
96 | local maxWidth = QuestieTracker.questButtons.maxWidth; |
||
97 | if maxWidth == nil then maxWidth = 0; end |
||
98 | local totalWidth = maxWidth; |
||
99 | QuestieTracker.frame:SetWidth(totalWidth); |
||
100 | if (QuestieConfig.trackerList == true) then |
||
101 | local lastbuttonTop = lastButton:GetTop(); |
||
102 | local trackerBottom = QuestieTracker.frame:GetBottom(); |
||
103 | --what if nothing is tracked? |
||
104 | if trackerBottom == nil then trackerBottom = 0; end |
||
105 | if lastbuttonTop == nil then lastbuttonTop = 0; end |
||
106 | --dynamically set the size of the tracker |
||
107 | local totalHeight = lastbuttonTop - trackerBottom; |
||
108 | if (QuestieConfig.showTrackerHeader == true) then |
||
109 | QuestieTracker.frame:SetHeight(totalHeight + 7); |
||
110 | if totalWidth < watcher:GetStringWidth() + 22 then |
||
111 | QuestieTracker.frame:SetWidth(watcher:GetStringWidth() + 22); |
||
112 | end |
||
113 | else |
||
114 | QuestieTracker.frame:SetHeight(totalHeight + 11); |
||
115 | QuestieTracker.frame:SetWidth(totalWidth); |
||
116 | end |
||
117 | QuestieTracker.frame:SetBackdropColor(0,0,0,QuestieConfig.trackerAlpha); |
||
118 | else |
||
119 | local lastbuttonBottom = lastButton:GetBottom(); |
||
120 | local trackerTop = QuestieTracker.frame:GetTop(); |
||
121 | --what if nothing is tracked? |
||
122 | if trackerTop == nil then trackerTop = 0; end |
||
123 | if lastbuttonBottom == nil then lastbuttonBottom = 0; end |
||
124 | --dynamically set the size of the tracker |
||
125 | local totalHeight = trackerTop - lastbuttonBottom; |
||
126 | if (QuestieConfig.showTrackerHeader == true) then |
||
127 | QuestieTracker.frame:SetHeight(totalHeight + 11); |
||
128 | if totalWidth < watcher:GetStringWidth() + 22 then |
||
129 | QuestieTracker.frame:SetWidth(watcher:GetStringWidth() + 22); |
||
130 | end |
||
131 | else |
||
132 | QuestieTracker.frame:SetHeight(totalHeight + 11); |
||
133 | QuestieTracker.frame:SetWidth(totalWidth); |
||
134 | end |
||
135 | QuestieTracker.frame:SetBackdropColor(0,0,0,QuestieConfig.trackerAlpha); |
||
136 | end |
||
137 | QuestieTracker.frame:Show(); |
||
138 | end |
||
139 | end |
||
140 | --------------------------------------------------------------------------------------------------- |
||
141 | -- Color quest objective scheme for quest tracker color option 2 |
||
142 | --------------------------------------------------------------------------------------------------- |
||
143 | function QuestieTracker:getRGBForObjective(objective) |
||
144 | if QuestieConfig.boldColors == false then |
||
145 | if not (type(objective) == "function") then |
||
146 | local lastIndex = findLast(objective, ":"); |
||
147 | if not (lastIndex == nil) then |
||
148 | local progress = string.sub(objective, lastIndex+2); |
||
149 | local slash = findLast(progress, "/"); |
||
150 | local have = tonumber(string.sub(progress, 0, slash-1)); |
||
151 | local need = tonumber(string.sub(progress, slash+1)); |
||
152 | if not have or not need then return 0.8, 0.8, 0.8; end |
||
153 | local float = have / need; |
||
154 | return 0.8-float/2, 0.8+float/3, 0.8-float/2; |
||
155 | end |
||
156 | end |
||
157 | return 0.3, 1, 0.3; |
||
158 | else |
||
159 | if not (type(objective) == "function") then |
||
160 | local lastIndex = findLast(objective, ":"); |
||
161 | if not (lastIndex == nil) then |
||
162 | local progress = string.sub(objective, lastIndex+2); |
||
163 | local slash = findLast(progress, "/"); |
||
164 | local have = tonumber(string.sub(progress, 0, slash-1)); |
||
165 | local need = tonumber(string.sub(progress, slash+1)); |
||
166 | if not have or not need then return 1, 0, 0; end |
||
167 | local float = have / need; |
||
168 | if float < .49 then return 1, 0+float/.5, 0; end |
||
169 | if float == .50 then return 1, 1, 0; end |
||
170 | if float > .50 then return 1-float/2, 1, 0; end |
||
171 | end |
||
172 | end |
||
173 | return 0, 1, 0; |
||
174 | end |
||
175 | end |
||
176 | --------------------------------------------------------------------------------------------------- |
||
177 | -- Clears tracking frame |
||
178 | --------------------------------------------------------------------------------------------------- |
||
179 | function QuestieTracker:clearTrackingFrame() |
||
180 | for i=1, 8 do |
||
181 | getglobal("QuestieTrackerButtonNew"..i):Hide(); |
||
182 | for j=1,20 do |
||
183 | getglobal("QuestieTrackerButtonNew"..i.."QuestWatchLine"..j):Hide(); |
||
184 | end |
||
185 | end |
||
186 | end |
||
187 | --------------------------------------------------------------------------------------------------- |
||
188 | -- Makes or retrieves one of the quest objective buttons |
||
189 | --------------------------------------------------------------------------------------------------- |
||
190 | function QuestieTracker:createOrGetTrackingButton(index) |
||
191 | if QuestieTracker.questButtons[index] == nil then |
||
192 | local parent; |
||
193 | local parentString; |
||
194 | if index == 1 then |
||
195 | parent = QuestieTracker.frame; |
||
196 | else |
||
197 | parent = QuestieTracker.questButtons[index-1]; |
||
198 | end |
||
199 | local btn = CreateFrame("Button", "QuestieTrackerButtonNew"..index, QuestieTracker.frame); |
||
200 | btn.objectives = {}; |
||
201 | btn:SetWidth(0); |
||
202 | btn:SetHeight(0); |
||
203 | btn:EnableMouse(true); |
||
204 | btn:SetMovable(true); |
||
205 | btn:SetScript("OnDragStart", QuestieTracker.frame.StartMoving); |
||
206 | btn:SetScript("OnDragStop", QuestieTracker.frame.StopMovingOrSizing); |
||
207 | btn:SetScript("OnMouseDown", function() |
||
208 | btn.dragstartx, btn.dragstarty = GetCursorPosition(); |
||
209 | if IsControlKeyDown() and IsShiftKeyDown() then |
||
210 | QuestieTracker.frame:StartMoving(); |
||
211 | end |
||
212 | end) |
||
213 | btn:SetScript("OnMouseUp", function() |
||
214 | local dragstopx, dragstopy = GetCursorPosition(); |
||
215 | if (btn.dragstartx == dragstopx and btn.dragstarty == dragstopy) then |
||
216 | btn:click(); |
||
217 | end |
||
218 | QuestieTracker.frame:StopMovingOrSizing(); |
||
219 | QuestieTracker.frame:SetUserPlaced(false); |
||
220 | QuestieTracker:saveFramePosition(); |
||
221 | end) |
||
222 | btn:SetScript("OnEnter", function() |
||
223 | local questHash = btn.hash; |
||
224 | local quest = QuestieCachedQuests[questHash]; |
||
225 | local questTitle = quest["questName"]; |
||
226 | Tooltip = GameTooltip; |
||
227 | local questOb = nil; |
||
228 | if questTitle then |
||
229 | local x = tonumber(QuestieTrackerVariables["position"]["xOfs"]); |
||
230 | if (x > 0 and x < 700) or (x > 1280 and x < 1700) then |
||
231 | Tooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
232 | else |
||
233 | Tooltip:SetOwner(this, "ANCHOR_LEFT"); |
||
234 | end |
||
235 | local index = 0; |
||
236 | for k,v in pairs(Questie:SanitisedQuestLookup(QuestieHashMap[questHash].name)) do |
||
237 | index = index + 1; |
||
238 | if (index == 1) and (v[2] == questHash) and (k ~= "") then |
||
239 | questOb = k; |
||
240 | elseif (index > 0) and(v[2] == questHash) and (k ~= "") then |
||
241 | questOb = k; |
||
242 | elseif (index == 1) and (v[2] ~= questHash) and (k ~= "") then |
||
243 | questOb = k; |
||
244 | end |
||
245 | end |
||
246 | if (QuestieConfig.showToolTips == true) then |
||
247 | if questOb ~= nil and (quest["isComplete"] or quest["leaderboards"] == 0) then |
||
248 | Tooltip:AddLine("|cFFa6a6a6To finish this quest... |r",1,1,1,true); |
||
249 | Tooltip:AddLine("|cffffffff"..Questie:RemoveUniqueSuffix(questOb).."|r",1,1,1,true); |
||
250 | elseif questOb == nil then |
||
251 | Tooltip:AddLine("Quest *Objective* not found in Questie Database!", 1, .8, .8); |
||
252 | Tooltip:AddLine("Please file a bug report on our GitHub portal:)", 1, .8, .8); |
||
253 | Tooltip:AddLine("https://github.com/AeroScripts/QuestieDev/issues", 1, .8, .8); |
||
254 | end |
||
255 | Tooltip:Show(); |
||
256 | end |
||
257 | end |
||
258 | end) |
||
259 | btn:SetScript("OnLeave", function() |
||
260 | Tooltip:SetFrameStrata("TOOLTIP"); |
||
261 | Tooltip:Hide(); |
||
262 | end) |
||
263 | btn.dragstartx = 0; |
||
264 | btn.dragstarty = 0; |
||
265 | btn:RegisterForClicks("RightButtonDown","LeftButtonUp", "LeftClick"); |
||
266 | btn.click = function() |
||
267 | if (QuestieConfig.arrowEnabled == true) and (not IsShiftKeyDown()) then |
||
268 | SetArrowObjective(btn.hash); |
||
269 | else |
||
270 | return; |
||
271 | end |
||
272 | end |
||
273 | if (QuestieConfig.showTrackerHeader == true) then |
||
274 | if (QuestieConfig.trackerList == true) then |
||
275 | if index == 1 then |
||
276 | btn:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 0, 22); |
||
277 | else |
||
278 | btn:SetPoint("BOTTOMLEFT", parent, "TOPLEFT", 0, 2); |
||
279 | end |
||
280 | else |
||
281 | if index == 1 then |
||
282 | btn:SetPoint("TOPLEFT", parent, "TOPLEFT", 0, -22); |
||
283 | else |
||
284 | btn:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", 0, -2); |
||
285 | end |
||
286 | end |
||
287 | else |
||
288 | if (QuestieConfig.trackerList == true) then |
||
289 | if index == 1 then |
||
290 | btn:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 0, 10); |
||
291 | else |
||
292 | btn:SetPoint("BOTTOMLEFT", parent, "TOPLEFT", 0, 0); |
||
293 | end |
||
294 | else |
||
295 | if index == 1 then |
||
296 | btn:SetPoint("TOPLEFT", parent, "TOPLEFT", 0, -10); |
||
297 | else |
||
298 | btn:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", 0, -2); |
||
299 | end |
||
300 | end |
||
301 | end |
||
302 | local quest = btn:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
303 | quest:SetPoint("TOPLEFT", btn, "TOPLEFT", 10, 0); |
||
304 | btn.quest = quest; |
||
305 | local level = btn:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
306 | level:SetPoint("TOPLEFT", btn, "TOPLEFT", 10, 0); |
||
307 | btn.level = level; |
||
308 | QuestieTracker.questButtons[index] = btn; |
||
309 | end |
||
310 | return QuestieTracker.questButtons[index]; |
||
311 | end |
||
312 | --------------------------------------------------------------------------------------------------- |
||
313 | -- Determines quest difficulty color based on payers level |
||
314 | --------------------------------------------------------------------------------------------------- |
||
315 | function QuestieTracker:GetDifficultyColor(level) |
||
316 | if type(level) == "string" then |
||
317 | for x in string.gfind(level, "%d+") do level = x; end |
||
318 | level = tonumber(level); |
||
319 | end |
||
320 | if level == nil then return "FFFFFFFF"; end |
||
321 | local levelDiff = level - UnitLevel("player"); |
||
322 | if (levelDiff >= 5) then return "FFFF1A1A"; |
||
323 | elseif (levelDiff >= 3) then return "FFFF8040"; |
||
324 | elseif (levelDiff >= -2) then return "FFFFFF00"; |
||
325 | elseif (-levelDiff <= GetQuestGreenRange()) then return "FF40C040"; |
||
326 | else return "FFC0C0C0"; end |
||
327 | end |
||
328 | --------------------------------------------------------------------------------------------------- |
||
329 | -- todo move to QuestieUtils |
||
330 | function RGBToHex(r, g, b) |
||
331 | if r > 255 then r = 255; end |
||
332 | if g > 255 then g = 255; end |
||
333 | if b > 255 then b = 255; end |
||
334 | return string.format("%02x%02x%02x", r, g, b); |
||
335 | end |
||
336 | --------------------------------------------------------------------------------------------------- |
||
337 | -- todo move to QuestieUtils |
||
338 | function fRGBToHex(r, g, b) |
||
339 | return RGBToHex(r*254, g*254, b*254); |
||
340 | end |
||
341 | --------------------------------------------------------------------------------------------------- |
||
342 | -- Adds quest type 'objective' text to quest objective button |
||
343 | --------------------------------------------------------------------------------------------------- |
||
344 | function QuestieTracker:AddObjectiveToButton(button, objective, index) |
||
345 | local objt; |
||
346 | if button.objectives[index] == nil then |
||
347 | objt = button:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
348 | else |
||
349 | objt = button.objectives[index]; |
||
350 | end |
||
351 | objt:SetPoint("TOPLEFT", button, "TOPLEFT", 20, -(index * 11+1)); |
||
352 | local r, g, b = QuestieTracker:getRGBForObjective(objective["desc"]); |
||
353 | local clr = fRGBToHex(r, g, b); |
||
354 | objt:SetText("|cFF"..clr..objective["desc"].."|r"); |
||
355 | button.objectives[index] = objt; |
||
356 | for i, v in (button.objectives) do |
||
357 | local otextWidth = button.objectives[i]:GetStringWidth() + 32; |
||
358 | table.insert(QuestieTracker.questObjects, otextWidth); |
||
359 | end |
||
360 | local omaxWidth = 0; |
||
361 | for i, v in ipairs(QuestieTracker.questObjects) do |
||
362 | if (QuestieTracker.questObjects) then |
||
363 | omaxWidth = math.max(omaxWidth, v); |
||
364 | table.insert(QuestieTracker.MaxButtonWidths, omaxWidth); |
||
365 | QuestieTracker.questObjects = {}; |
||
366 | end |
||
367 | end |
||
368 | end |
||
369 | --------------------------------------------------------------------------------------------------- |
||
370 | -- Adds quest type 'event' text to quest objective button |
||
371 | --------------------------------------------------------------------------------------------------- |
||
372 | function QuestieTracker:AddEventToButton(button, objective, index) |
||
373 | local objt; |
||
374 | if button.objectives[index] == nil then |
||
375 | objt = button:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
376 | else |
||
377 | objt = button.objectives[index]; |
||
378 | end |
||
379 | objt:SetPoint("TOPLEFT", button, "TOPLEFT", 20, -(index * 11+1)); |
||
380 | local r, g, b = QuestieTracker:getRGBForObjective(objective["desc"]); |
||
381 | local clr = fRGBToHex(r, g, b); |
||
382 | if QuestieConfig.boldColors == true then |
||
383 | objt:SetText("|cFFFF0000"..objective["desc"].."|r"); |
||
384 | else |
||
385 | objt:SetText("|cFFCCCCCC"..objective["desc"].."|r"); |
||
386 | end |
||
387 | button.objectives[index] = objt; |
||
388 | for i, v in (button.objectives) do |
||
389 | local otextWidth = button.objectives[i]:GetStringWidth() + 32; |
||
390 | table.insert(QuestieTracker.questObjects, otextWidth); |
||
391 | end |
||
392 | local omaxWidth = 0; |
||
393 | for i, v in ipairs(QuestieTracker.questObjects) do |
||
394 | if (QuestieTracker.questObjects) then |
||
395 | omaxWidth = math.max(omaxWidth, v); |
||
396 | table.insert(QuestieTracker.MaxButtonWidths, omaxWidth); |
||
397 | QuestieTracker.questObjects = {}; |
||
398 | end |
||
399 | end |
||
400 | end |
||
401 | --------------------------------------------------------------------------------------------------- |
||
402 | -- Finds quest finisher location by type and name |
||
403 | --------------------------------------------------------------------------------------------------- |
||
404 | function QuestieTracker:GetFinisherLocations(typ, name) |
||
405 | local C, Z, X, Y; |
||
406 | if typ == "monster" then |
||
407 | local paths = GetMonsterLocations(name); |
||
408 | return Questie:RecursiveGetPathLocations(paths); |
||
409 | elseif typ == "object" then |
||
410 | local paths = GetObjectLocations(name); |
||
411 | return Questie:RecursiveGetPathLocations(paths); |
||
412 | end |
||
413 | return C, Z, X, Y; |
||
414 | end |
||
415 | --------------------------------------------------------------------------------------------------- |
||
416 | -- Updates the QuestieTracker frames distance sorting feature |
||
417 | --------------------------------------------------------------------------------------------------- |
||
418 | function QuestieTracker:SortTrackingFrame() |
||
419 | local sortedByDistance = {}; |
||
420 | local distanceControlTable = {}; |
||
421 | local C,Z,X,Y = Astrolabe:GetCurrentPlayerPosition(); -- continent, zone, x, y |
||
422 | local distanceNotes = {}; |
||
423 | local objc = 0; |
||
424 | QuestieTracker.GeneralInterval = QuestieTracker.GeneralInterval + 1; |
||
425 | if (QuestieTracker.GeneralInterval > (QuestieTracker.btnUpdate*0.99)) then |
||
426 | QuestieTracker.GeneralInterval = 0; |
||
427 | for hash, quest in pairs(QuestieHandledQuests) do |
||
428 | local questTrack = QuestieCachedQuests[hash]; |
||
429 | if questTrack ~= nil and questTrack.tracked then |
||
430 | local objectiveCount = 0; |
||
431 | if not questTrack.isComplete then |
||
432 | for objectiveid, objective in pairs(quest.objectives) do |
||
433 | if not objective.done then |
||
434 | local locations = Questie:RecursiveGetPathLocations(objective.path); |
||
435 | for i, location in pairs(locations) do |
||
436 | local dist, xDelta, yDelta = Astrolabe:ComputeDistance( C, Z, X, Y, location[1], location[2], location[3], location[4]); |
||
437 | if dist and xDelta and yDelta then |
||
438 | local info = { |
||
439 | ["dist"] = dist, |
||
440 | ["hash"] = hash, |
||
441 | ["xDelta"] = xDelta, |
||
442 | ["yDelta"] = yDelta, |
||
443 | ["c"] = location[1], |
||
444 | ["z"] = location[2], |
||
445 | ["x"] = location[3], |
||
446 | ["y"] = location[4], |
||
447 | }; |
||
448 | objectiveCount = objectiveCount + 1; |
||
449 | table.insert(distanceNotes, info); |
||
450 | end |
||
451 | end |
||
452 | end |
||
453 | end |
||
454 | end |
||
455 | if objectiveCount == 0 then |
||
456 | -- Show quest finished in tracker |
||
457 | local quest = QuestieHashMap[hash]; |
||
458 | if quest ~= nil then |
||
459 | local locations = QuestieTracker:GetFinisherLocations(quest.finishedType, quest.finishedBy) or {}; |
||
460 | for i, location in pairs(locations) do |
||
461 | local dist, xDelta, yDelta = Astrolabe:ComputeDistance( C, Z, X, Y, location[1], location[2], location[3], location[4]); |
||
462 | if dist and xDelta and yDelta then |
||
463 | local info = { |
||
464 | ["dist"] = dist, |
||
465 | ["hash"] = hash, |
||
466 | ["xDelta"] = xDelta, |
||
467 | ["yDelta"] = yDelta, |
||
468 | ["c"] = location[1], |
||
469 | ["z"] = location[2], |
||
470 | ["x"] = location[3], |
||
471 | ["y"] = location[4], |
||
472 | }; |
||
473 | table.insert(distanceNotes, info); |
||
474 | end |
||
475 | end |
||
476 | end |
||
477 | end |
||
478 | end |
||
479 | end |
||
480 | end |
||
481 | sort(distanceNotes, function (a, b) |
||
482 | if (not a["dist"]) or (not b["dist"]) then |
||
483 | return false; |
||
484 | end |
||
485 | return a["dist"] < b["dist"]; |
||
486 | end) |
||
487 | for k,v in pairs(distanceNotes) do |
||
488 | if not distanceControlTable[v["hash"]] then |
||
489 | distanceControlTable[v["hash"]] = true; |
||
490 | table.insert(sortedByDistance, v); |
||
491 | end |
||
492 | end |
||
493 | for i,v in pairs(sortedByDistance) do |
||
494 | local hash = v["hash"]; |
||
495 | local quest = QuestieCachedQuests[hash]; |
||
496 | local colorString = "|c" .. QuestieTracker:GetDifficultyColor(quest["level"]); |
||
497 | if QuestieConfig.boldColors == true then |
||
498 | if quest["questTag"] then |
||
499 | v["title"] = colorString .. "[" .. quest["level"] .. "+" .. "] |r" .. quest["questName"]; |
||
500 | else |
||
501 | v["title"] = colorString .. "[" .. quest["level"] .. "] |r" .. quest["questName"]; |
||
502 | end |
||
503 | else |
||
504 | if quest["questTag"] then |
||
505 | v["title"] = colorString .. "[" .. quest["level"] .. "+" .. "] " .. quest["questName"] .. "|r"; |
||
506 | else |
||
507 | v["title"] = colorString .. "[" .. quest["level"] .. "] " .. quest["questName"] .. "|r"; |
||
508 | end |
||
509 | end |
||
510 | quest["arrowPoint"] = v; |
||
511 | end |
||
512 | return sortedByDistance; |
||
513 | end |
||
514 | --------------------------------------------------------------------------------------------------- |
||
515 | -- Populates the quest tracker frame with objective buttons |
||
516 | --------------------------------------------------------------------------------------------------- |
||
517 | function QuestieTracker:FillTrackingFrame() |
||
518 | local index = 1; |
||
519 | local sortedByDistance = QuestieTracker:SortTrackingFrame(); |
||
520 | for i,v in pairs(sortedByDistance) do |
||
521 | local hash = v["hash"]; |
||
522 | local quest = QuestieCachedQuests[hash]; |
||
523 | local button = QuestieTracker:createOrGetTrackingButton(index); |
||
524 | button.hash = hash; |
||
525 | local colorString = "|c" .. QuestieTracker:GetDifficultyColor(quest["level"]); |
||
526 | local titleData = colorString; |
||
527 | if quest["questTag"] then |
||
528 | titleData = titleData .. "[" .. quest["level"] .. "+" .. "] "; |
||
529 | else |
||
530 | titleData = titleData .. "[" .. quest["level"] .. "] "; |
||
531 | end |
||
532 | if QuestieConfig.boldColors == true then |
||
533 | titleData = titleData .. "|r|cFFFFFFFF" .. quest["questName"] .. "|r"; |
||
534 | else |
||
535 | titleData = titleData .. quest["questName"]; |
||
536 | titleData = titleData .. "|r"; |
||
537 | end |
||
538 | button.quest:SetText(titleData); |
||
539 | local obj = 1; |
||
540 | if quest["isComplete"] or quest["leaderboards"] == 0 then |
||
541 | QuestieTracker:AddObjectiveToButton(button, {['desc']="Quest Complete!"}, obj); |
||
542 | obj = 2; |
||
543 | else |
||
544 | while true do |
||
545 | local beefcake = quest["objective" .. obj]; |
||
546 | if beefcake == nil then break; end |
||
547 | if beefcake["type"] == "event" then |
||
548 | QuestieTracker:AddEventToButton(button, beefcake, obj); |
||
549 | obj = obj + 1; |
||
550 | else |
||
551 | QuestieTracker:AddObjectiveToButton(button, beefcake, obj); |
||
552 | obj = obj + 1; |
||
553 | end |
||
554 | end |
||
555 | end |
||
556 | button.currentObjectiveCount = obj - 1; |
||
557 | local heightLoss = 0; |
||
558 | while true do |
||
559 | if button.objectives[obj] == nil then break; end |
||
560 | button.objectives[obj]:SetText(""); |
||
561 | heightLoss = heightLoss + 11; |
||
562 | obj = obj + 1; |
||
563 | end |
||
564 | button:SetHeight(14 + (button.currentObjectiveCount * 11)); |
||
565 | for i, v in (button.quest) do |
||
566 | local qtextWidth = button.quest:GetStringWidth() + 20; |
||
567 | table.insert(QuestieTracker.questNames, qtextWidth); |
||
568 | end |
||
569 | local qmaxWidth = 0; |
||
570 | for i, v in ipairs(QuestieTracker.questNames) do |
||
571 | if (QuestieTracker.questObjects) then |
||
572 | qmaxWidth = math.max(qmaxWidth, v); |
||
573 | table.insert(QuestieTracker.MaxButtonWidths, qmaxWidth); |
||
574 | QuestieTracker.questNames = {}; |
||
575 | end |
||
576 | end |
||
577 | local maxWidth = 0; |
||
578 | for i, v in ipairs(QuestieTracker.MaxButtonWidths) do |
||
579 | maxWidth = math.max(maxWidth, v); |
||
580 | QuestieTracker.questButtons.maxWidth = maxWidth; |
||
581 | end |
||
582 | button:SetWidth(maxWidth); |
||
583 | button:Show(); |
||
584 | if (QuestieConfig.showTrackerHeader == true) and (QuestieConfig.trackerEnabled == true) then |
||
585 | local numEntries, numQuests = QGet_NumQuestLogEntries(); |
||
586 | watcher:SetText("QuestLog Status: ("..numQuests.."/20)"); |
||
587 | QuestieTrackerHeader:Show(); |
||
588 | end |
||
589 | index = index + 1; |
||
590 | end |
||
591 | QuestieTracker.highestIndex = index - 1; |
||
592 | while true do |
||
593 | local d = QuestieTracker.questButtons[index]; |
||
594 | if d == nil then break; end |
||
595 | d:Hide(); |
||
596 | index = index + 1; |
||
597 | end |
||
598 | if (QuestieConfig.trackerEnabled == true) and (QuestieConfig.trackerMinimize == false) then |
||
599 | if (QuestieTracker.highestIndex >= 1) and (QuestieConfig.trackerBackground == false) then |
||
600 | trackerWidth = QuestieTracker.questButtons.maxWidth; |
||
601 | if (QuestieConfig.trackerList == false) then |
||
602 | trackerHeight = QuestieTracker.frame:GetTop() - QuestieTracker.questButtons[QuestieTracker.highestIndex]:GetBottom(); |
||
603 | else |
||
604 | trackerHeight = QuestieTracker.questButtons[QuestieTracker.highestIndex]:GetTop() - QuestieTracker.frame:GetBottom(); |
||
605 | end |
||
606 | QuestieTracker.frame:SetWidth(trackerWidth); |
||
607 | QuestieTracker.frame:SetHeight(trackerHeight); |
||
608 | end |
||
609 | QuestieTracker.MaxButtonWidths = {}; |
||
610 | QuestieTracker:updateTrackingFrameSize(); |
||
611 | end |
||
612 | end |
||
613 | --------------------------------------------------------------------------------------------------- |
||
614 | -- Creates a blank quest tracking frame and sets up the optional haeder |
||
615 | --------------------------------------------------------------------------------------------------- |
||
616 | function QuestieTracker:createTrackingFrame() |
||
617 | QuestieTracker.frame = CreateFrame("Frame", "QuestieTrackerFrame", UIParent, "ActionButtonTemplate"); |
||
618 | if trackerWidth or trackerHeight == nil then trackerWidth = 1; trackerHeight = 1; end |
||
619 | QuestieTracker.frame:SetWidth(trackerWidth); |
||
620 | QuestieTracker.frame:SetHeight(trackerHeight); |
||
621 | QuestieTracker.frame:SetPoint( |
||
622 | QuestieTrackerVariables["position"]["point"], |
||
623 | QuestieTrackerVariables["position"]["relativeTo"], |
||
624 | QuestieTrackerVariables["position"]["relativePoint"], |
||
625 | QuestieTrackerVariables["position"]["xOfs"], |
||
626 | QuestieTrackerVariables["position"]["yOfs"] |
||
627 | ); |
||
628 | QuestieTracker.frame:SetScale(QuestieConfig.trackerScale); |
||
629 | if (QuestieConfig.trackerBackground == true) then |
||
630 | QuestieTracker.frame:SetBackdrop({bgFile="Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile=true, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }}); |
||
631 | QuestieTracker.frame:SetBackdropColor(0,0,0,QuestieConfig.trackerAlpha); |
||
632 | end |
||
633 | QuestieTracker.frame:EnableMouse(true); |
||
634 | QuestieTracker.frame:SetMovable(true); |
||
635 | QuestieTracker.frame:SetClampedToScreen(true); |
||
636 | QuestieTracker.frame.prevoffset = 0; |
||
637 | QuestieTracker.frame:SetScript("OnMouseUp", function() |
||
638 | this:StopMovingOrSizing(); |
||
639 | this:SetUserPlaced(false); |
||
640 | QuestieTracker:saveFramePosition(); |
||
641 | end) |
||
642 | --QuestTracker Header Button |
||
643 | local header = CreateFrame("Button", "QuestieTrackerHeader", UIParent); |
||
644 | if (QuestieConfig.trackerList == true) then |
||
645 | if (QuestieConfig.showTrackerHeader == true) then |
||
646 | watcher = header:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
647 | watcher:SetPoint("BOTTOMLEFT", QuestieTracker.frame, "BOTTOMLEFT", 10, 8); |
||
648 | --QuestTracker Minimize Button |
||
649 | qmenu = CreateFrame("Button", "QuestieTrackerMenu", watcher.frame); |
||
650 | qmenu:SetPoint("BOTTOMLEFT", QuestieTracker.frame, "BOTTOMLEFT", 6, 5); |
||
651 | else |
||
652 | watcher = header:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
653 | watcher:SetPoint("BOTTOMLEFT", QuestieTracker.frame, "BOTTOMLEFT", 10, 8); |
||
654 | end |
||
655 | else |
||
656 | if (QuestieConfig.showTrackerHeader == true) then |
||
657 | watcher = header:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
658 | watcher:SetPoint("TOPLEFT", QuestieTracker.frame, "TOPLEFT", 6, -8); |
||
659 | --QuestTracker Minimize Button |
||
660 | qmenu = CreateFrame("Button", "QuestieTrackerMenu", watcher.frame); |
||
661 | qmenu:SetPoint("TOPLEFT", QuestieTracker.frame, "TOPLEFT", 0, -6); |
||
662 | else |
||
663 | watcher = header:CreateFontString(nil, "OVERLAY", "GameFontNormal"); |
||
664 | watcher:SetPoint("TOPLEFT", QuestieTracker.frame, "TOPLEFT", 6, -8); |
||
665 | end |
||
666 | end |
||
667 | if (QuestieConfig.showTrackerHeader == true) and (QuestieConfig.trackerEnabled == true) then |
||
668 | qmenu:SetFrameStrata("HIGH"); |
||
669 | qmenu:SetWidth(180); |
||
670 | qmenu:SetHeight(10); |
||
671 | qmenu.texture = qmenu:CreateTexture(nil, "BACKGROUND"); |
||
672 | qmenu.texture:SetTexture(0,0,0); |
||
673 | qmenu.texture:SetAlpha(0.0); |
||
674 | qmenu.texture:SetAllPoints(qmenu); |
||
675 | qmenu:EnableMouse(true); |
||
676 | qmenu:SetScript("OnClick", function() |
||
677 | if (QuestieConfig.trackerMinimize == false) then |
||
678 | QuestieConfig.trackerMinimize = true; |
||
679 | QuestieTracker.frame:Hide(); |
||
680 | else |
||
681 | QuestieConfig.trackerMinimize = false; |
||
682 | QuestieTracker.frame:Show(); |
||
683 | end |
||
684 | end) |
||
685 | end |
||
686 | QuestieTrackerHeader:Hide(); |
||
687 | QuestieTracker.frame:Hide(); |
||
688 | end |
||
689 | --------------------------------------------------------------------------------------------------- |
||
690 | --Credit to Shagu for this fix for EQL3's freezing and event flooding upon Login. |
||
691 | --Let QuestWatch Update only be triggered once per second in the first 10 seconds after login. |
||
692 | --------------------------------------------------------------------------------------------------- |
||
693 | function Questie:LoadEQL3Fix() |
||
694 | if (IsAddOnLoaded("EQL3")) and (not IsAddOnLoaded("ShaguQuest")) then |
||
695 | local EQL_Loader = CreateFrame("Frame",nil); |
||
696 | EQL_Loader.tick = GetTime(); |
||
697 | EQL_Loader.step = 0; |
||
698 | EQL_Loader:SetScript("OnUpdate", function() |
||
699 | if EQL_Loader.tick + 1 <= GetTime() then |
||
700 | EQL_Loader.abort = false; |
||
701 | QuestWatch_Update(); |
||
702 | EQL_Loader.tick = GetTime(); |
||
703 | if EQL_Loader.step < 10 then |
||
704 | EQL_Loader.step = EQL_Loader.step + 1; |
||
705 | else |
||
706 | EQL_Loader:Hide(); |
||
707 | end |
||
708 | end |
||
709 | end) |
||
710 | --------------------------------------------------------------------------------------------------- |
||
711 | --Intercepts and injects extra code into EQL3 |
||
712 | --------------------------------------------------------------------------------------------------- |
||
713 | local QQuestWatch_Update = QuestWatch_Update; |
||
714 | function QuestWatch_Update() |
||
715 | if EQL_Loader.abort == nil then EQL_Loader.abort = true end |
||
716 | if(not EQL3_Temp.hasManaged) or (EQL_Loader.abort == true and EQL_Loader.step < 10) then |
||
717 | QuestWatchFrame:Hide(); |
||
718 | return; |
||
719 | end |
||
720 | EQL_Loader.abort = true; |
||
721 | QQuestWatch_Update(); |
||
722 | end |
||
723 | end |
||
724 | end |
||
725 | --------------------------------------------------------------------------------------------------- |
||
726 | -- Adds or removes quests to be tracked from the quest tracker. Also handles 'chat linking'. |
||
727 | --------------------------------------------------------------------------------------------------- |
||
728 | function QuestLogTitleButton_OnClick(button) |
||
729 | if (IsAddOnLoaded("EQL3") or IsAddOnLoaded("ShaguQuest")) then |
||
730 | local questName = this:GetText(); |
||
731 | local questIndex = this:GetID() + FauxScrollFrame_GetOffset(EQL3_QuestLogListScrollFrame); |
||
732 | if (button == "LeftButton") then |
||
733 | if (IsShiftKeyDown()) then |
||
734 | if (IsControlKeyDown()) then |
||
735 | if (this.isHeader) then |
||
736 | return; |
||
737 | end |
||
738 | if (not ChatFrameEditBox:IsVisible()) then |
||
739 | EQL3_ClearTracker(); |
||
740 | AddQuestWatch(questIndex); |
||
741 | Questie:AddEvent("SYNCLOG", 0); |
||
742 | QuestWatch_Update(); |
||
743 | end |
||
744 | else |
||
745 | local questLogTitleText, isHeader, isCollapsed, firstTrackable, lastTrackable, numTracked, numUntracked; |
||
746 | lastTrackable = -1; |
||
747 | numTracked = 0; |
||
748 | numUntracked = 0; |
||
749 | local track = false; |
||
750 | if (this.isHeader) then |
||
751 | local i = 1; |
||
752 | local qc = 0; |
||
753 | local nEntry, nQuests = QGet_NumQuestLogEntries(); |
||
754 | local tEntry = nQuests; |
||
755 | while qc < nQuests do |
||
756 | questLogTitleText, _, _, isHeader, isCollapsed, _ = QGet_QuestLogTitle(i); |
||
757 | if (questLogTitleText == questName) then |
||
758 | track = true; |
||
759 | firstTrackable = i + 1; |
||
760 | elseif (track) then |
||
761 | if (not isHeader) then |
||
762 | if (IsQuestWatched(i)) then |
||
763 | numTracked = numTracked + 1; |
||
764 | RemoveQuestWatch(i); |
||
765 | else |
||
766 | numUntracked = numUntracked + 1; |
||
767 | RemoveQuestWatch(i); |
||
768 | end |
||
769 | end |
||
770 | QuestWatch_Update(); |
||
771 | if (isHeader and questLogTitleText ~= questName) then |
||
772 | lastTrackable = i - 1; |
||
773 | break; |
||
774 | end |
||
775 | end |
||
776 | if not isHeader then |
||
777 | qc = qc + 1; |
||
778 | else |
||
779 | tEntry = tEntry + 1; |
||
780 | end |
||
781 | i = i + 1; |
||
782 | end |
||
783 | if (lastTrackable == -1) then |
||
784 | lastTrackable = tEntry; |
||
785 | end |
||
786 | if (numUntracked == 0) then |
||
787 | for i = firstTrackable, lastTrackable, 1 do |
||
788 | RemoveQuestWatch(i); |
||
789 | end |
||
790 | else |
||
791 | for i = firstTrackable, lastTrackable, 1 do |
||
792 | AddQuestWatch(i); |
||
793 | end |
||
794 | end |
||
795 | Questie:AddEvent("SYNCLOG", 0); |
||
796 | if QuestieConfig["alwaysShowObjectives"] == false then |
||
797 | Questie:AddEvent("DRAWNOTES", 0.1); |
||
798 | end |
||
799 | QuestWatch_Update(); |
||
800 | QuestLog_Update(); |
||
801 | return; |
||
802 | end |
||
803 | if ChatFrameEditBox:IsVisible() then |
||
804 | local text = this:GetText(); |
||
805 | if QuestieConfig.useQuestLinks then text = "|cffffff00|Hquest:0:0:0:0|h["..gsub(text, ".*%] (.*)", "%1").."]|h|r"; end |
||
806 | ChatFrameEditBox:Insert(text); |
||
807 | elseif (WIM_EditBoxInFocus) then |
||
808 | local text = this:GetText(); |
||
809 | if QuestieConfig.useQuestLinks then text = "|cffffff00|Hquest:0:0:0:0|h["..gsub(text, ".*%] (.*)", "%1").."]|h|r"; end |
||
810 | WIM_EditBoxInFocus:Insert(text); |
||
811 | else |
||
812 | if (IsQuestWatched(questIndex)) then |
||
813 | RemoveQuestWatch(questIndex); |
||
814 | else |
||
815 | if (GetNumQuestWatches() >= 20) then |
||
816 | UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, "20"), 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME); |
||
817 | return; |
||
818 | end |
||
819 | AddQuestWatch(questIndex); |
||
820 | end |
||
821 | Questie:AddEvent("SYNCLOG", 0); |
||
822 | if QuestieConfig["alwaysShowObjectives"] == false then |
||
823 | Questie:AddEvent("DRAWNOTES", 0.1); |
||
824 | end |
||
825 | QuestWatch_Update(); |
||
826 | end |
||
827 | end |
||
828 | end |
||
829 | if (this.isHeader) then |
||
830 | if (EQL3_OrganizeFrame:IsVisible()) then |
||
831 | EQL3_OrganizeFrame_Text:SetText(questName); |
||
832 | EQL3_OrganizeFrame_Text:ClearFocus(); |
||
833 | EQL3_OrganizeFunctions(questName); |
||
834 | EQL3_OrganizeFrame:Hide(); |
||
835 | end |
||
836 | end |
||
837 | end |
||
838 | if (QuestLog_SetSelection(questIndex) == 1) then |
||
839 | if (not EQL3_QuestLogFrame_Description:IsVisible() and not IsShiftKeyDown() and not IsControlKeyDown() and QuestlogOptions[EQL3_Player].RestoreUponSelect == 1) then |
||
840 | EQL3_Maximize(); |
||
841 | end |
||
842 | end |
||
843 | if (button == "LeftButton") then |
||
844 | if (not IsShiftKeyDown() and IsControlKeyDown()) then |
||
845 | if ChatFrameEditBox:IsVisible() then |
||
846 | if (ChatFrameEditBox:IsVisible()) then |
||
847 | AddQuestStatusToChatFrame(questIndex, questName); |
||
848 | end |
||
849 | end |
||
850 | end |
||
851 | else |
||
852 | if (not this.isHeader ) then |
||
853 | if (EQL3_IsQuestWatched(questIndex)) then |
||
854 | EQL3_Organize_Popup_Track_Text:SetText(EQL3_POPUP_UNTRACK); |
||
855 | else |
||
856 | EQL3_Organize_Popup_Track_Text:SetText(EQL3_POPUP_TRACK); |
||
857 | end |
||
858 | EQL3_Organize_Popup:ClearAllPoints(); |
||
859 | EQL3_Organize_Popup:SetPoint("TOPLEFT", this, "TOPLEFT", 24, 0); |
||
860 | EQL3_Organize_Popup:Raise(); |
||
861 | EQL3_Organize_Popup:Show(); |
||
862 | end |
||
863 | end |
||
864 | QuestLog_Update(); |
||
865 | else |
||
866 | local prevQuestLogSelection = QGet_QuestLogSelection(); |
||
867 | local questName = this:GetText(); |
||
868 | local questIndex = this:GetID() + FauxScrollFrame_GetOffset(QuestLogListScrollFrame); |
||
869 | local qName, level, questTag, isHeader, isCollapsed, isComplete = QGet_QuestLogTitle(questIndex); |
||
870 | QSelect_QuestLogEntry(questIndex); |
||
871 | local questText, objectiveText = QGet_QuestLogQuestText(); |
||
872 | if (IsShiftKeyDown()) then |
||
873 | if (this.isHeader) then |
||
874 | return; |
||
875 | end |
||
876 | local hash = Questie:getQuestHash(qName, level, objectiveText, headerName); |
||
877 | if ChatFrameEditBox:IsVisible() then |
||
878 | local text = this:GetText(); |
||
879 | if QuestieConfig.useQuestLinks then text = "|cffffff00|Hquest:0:0:0:0|h["..gsub(text, " (.)", "%1").."]|h|r"; end |
||
880 | ChatFrameEditBox:Insert(text); |
||
881 | elseif (WIM_EditBoxInFocus) then |
||
882 | local text = this:GetText(); |
||
883 | if QuestieConfig.useQuestLinks then text = "|cffffff00|Hquest:0:0:0:0|h["..gsub(text, " (.)", "%1").."]|h|r"; end |
||
884 | WIM_EditBoxInFocus:Insert(text); |
||
885 | else |
||
886 | if (IsQuestWatched(questIndex)) then |
||
887 | Questie:debug_Print("Tracker:QuestLogTitleButton_OnClick --> RemoveQuestWatch: [Id: "..questIndex.."] | [hash: "..hash.."]"); |
||
888 | RemoveQuestWatch(questIndex); |
||
889 | else |
||
890 | ------------------------------------------------------------------------------------ |
||
891 | -- We want to track anything and more than 5 quests in the Defalut WoW Quest Tracker |
||
892 | --[[-------------------------------------------------------------------------------- |
||
893 | if (QGet_NumQuestLeaderBoards(questIndex) == 0) then |
||
894 | UIErrorsFrame:AddMessage(QUEST_WATCH_NO_OBJECTIVES, 1.0, 0.1, 0.1, 1.0); |
||
895 | return; |
||
896 | end |
||
897 | if (QGet_NumQuestWatches() >= MAX_WATCHABLE_QUESTS) then |
||
898 | UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, MAX_WATCHABLE_QUESTS), 1.0, 0.1, 0.1, 1.0); |
||
899 | return; |
||
900 | end |
||
901 | ----------------------------------------------------------------------------------]] |
||
902 | AddQuestWatch(questIndex); |
||
903 | Questie:debug_Print("Tracker:QuestLogTitleButton_OnClick --> AutoQuestWatch_Insert: [Id: "..questIndex.."] | [hash: "..hash.."]"); |
||
904 | end |
||
905 | Questie:AddEvent("SYNCLOG", 0); |
||
906 | if QuestieConfig["alwaysShowObjectives"] == false then |
||
907 | Questie:AddEvent("DRAWNOTES", 0.02); |
||
908 | end |
||
909 | QuestWatch_Update(); |
||
910 | end |
||
911 | end |
||
912 | QSelect_QuestLogEntry(prevQuestLogSelection); |
||
913 | QuestLog_SetSelection(questIndex); |
||
914 | QuestLog_Update(); |
||
915 | end |
||
916 | end |
||
917 | --------------------------------------------------------------------------------------------------- |
||
918 | -- If a quest is tracked, add quest to tracker and retrieve cached quest data |
||
919 | --------------------------------------------------------------------------------------------------- |
||
920 | local function trim(s) |
||
921 | return string.gsub(s, "^%s*(.-)%s*$", "%1"); |
||
922 | end |
||
923 | --------------------------------------------------------------------------------------------------- |
||
924 | function QuestieTracker:addQuestToTrackerCache(hash, logId, level) |
||
925 | if not QuestieCachedQuests[hash] then |
||
926 | QuestieCachedQuests[hash] = {}; |
||
927 | end |
||
928 | if not logId then |
||
929 | logId = Questie:GetQuestIdFromHash(hash); |
||
930 | end |
||
931 | if logId == nil then |
||
932 | DEFAULT_CHAT_FRAME:AddMessage("TrackerError! LogId still nil after GetQuestIdFromHash ", hash); |
||
933 | return; |
||
934 | end |
||
935 | local questName, level, questTag, isHeader, isCollapsed, isComplete = QGet_QuestLogTitle(logId); |
||
936 | if (not QuestieCachedQuests[hash]["tracked"] == true) then |
||
937 | QuestieCachedQuests[hash]["tracked"] = false; |
||
938 | end |
||
939 | QuestieCachedQuests[hash]["questName"] = questName; |
||
940 | QuestieCachedQuests[hash]["level"] = level; |
||
941 | QuestieCachedQuests[hash]["logId"] = logId; |
||
942 | QuestieCachedQuests[hash]["questTag"] = questTag; |
||
943 | QuestieCachedQuests[hash]["isComplete"] = isComplete; |
||
944 | QuestieCachedQuests[hash]["leaderboards"] = QGet_NumQuestLeaderBoards(logId); |
||
945 | for i=1, QGet_NumQuestLeaderBoards(logId) do |
||
946 | local desc, type, done = QGet_QuestLogLeaderBoard(i, logId); |
||
947 | if QuestieCachedQuests[hash]["objective"..i] then |
||
948 | if isComplete or (QGet_NumQuestLeaderBoards() == 0) or (QuestieCachedQuests[hash]["objective"..i]["done"] == 1) then |
||
949 | RemoveCrazyArrow(hash); |
||
950 | QuestieCachedQuests[hash]["objective"..i] = { |
||
951 | ["desc"] = "Quest Complete!", |
||
952 | ["type"] = type, |
||
953 | ["done"] = true, |
||
954 | ["notes"] = {}, |
||
955 | }; |
||
956 | else |
||
957 | QuestieCachedQuests[hash]["objective"..i] = { |
||
958 | ["desc"] = desc, |
||
959 | ["type"] = type, |
||
960 | ["done"] = done, |
||
961 | ["notes"] = {}, |
||
962 | }; |
||
963 | end |
||
964 | else |
||
965 | QuestieCachedQuests[hash]["objective"..i] = { |
||
966 | ["desc"] = desc, |
||
967 | ["type"] = type, |
||
968 | ["done"] = done, |
||
969 | ["notes"] = {}, |
||
970 | }; |
||
971 | end |
||
972 | end |
||
973 | --Questie:debug_Print("Tracker:addQuestToTrackerCache: [Hash: "..hash.."]"); |
||
974 | if QuestieCachedQuests[hash]["objective1"] then |
||
975 | if (QuestieCachedQuests[hash]["objective1"]["done"] ~= true) or (QuestieCachedQuests[hash]["objective1"]["done"] ~= 1) or (QuestieCachedQuests[hash]["objective1"]["type"] == nil) or (not QuestieCachedQuests[hash]["arrowPoint"]) then |
||
976 | QuestieTracker:updateTrackerCache(hash, logId, level); |
||
977 | end |
||
978 | end |
||
979 | end |
||
980 | --------------------------------------------------------------------------------------------------- |
||
981 | -- This function is used to update the quest log index of a quest in the QUEST_WATCH_LIST and |
||
982 | -- QuestieCachedQuests tables when another quest is added/removed from the quest log, and therefore |
||
983 | -- the index might have changed. It's currently only called from updateTrackerCache and syncQuestLog |
||
984 | -- in this file, which might have to be changed yet, but testing has shown no errors so far. |
||
985 | --------------------------------------------------------------------------------------------------- |
||
986 | function QuestieTracker:updateQuestWatchLogId(hash, logId) |
||
987 | if QUEST_WATCH_LIST[hash] and QUEST_WATCH_LIST[hash].questIndex ~= logId then |
||
988 | Questie:debug_Print("Tracker:updateQuestWatchLogId: QUEST_WATCH_LIST["..hash.."].questIndex changed from "..QUEST_WATCH_LIST[hash].questIndex.." to "..logId) |
||
989 | QUEST_WATCH_LIST[hash].questIndex = logId |
||
990 | end |
||
991 | if QuestieCachedQuests[hash] and QuestieCachedQuests[hash].logId ~= logId then |
||
992 | Questie:debug_Print("Tracker:updateQuestWatchLogId: QuestieCachedQuests["..hash.."].logId changed from "..QuestieCachedQuests[hash].logId.." to "..logId) |
||
993 | QuestieCachedQuests[hash].logId = logId |
||
994 | end |
||
995 | end |
||
996 | --------------------------------------------------------------------------------------------------- |
||
997 | -- If a quest is tracked, update quest on tracker and also update quest data cache |
||
998 | --------------------------------------------------------------------------------------------------- |
||
999 | function QuestieTracker:updateTrackerCache(hash, logId, level) |
||
1000 | if (not QUEST_WATCH_LIST[logId]) and (not QuestieCachedQuests[hash]) then |
||
1001 | QuestieTracker:addQuestToTrackerCache(hash, logId, level); |
||
1002 | end |
||
1003 | if not QuestieCachedQuests[hash] then |
||
1004 | QuestieCachedQuests[hash] = {}; |
||
1005 | end |
||
1006 | if not logId then |
||
1007 | logId = Questie:GetQuestIdFromHash(hash); |
||
1008 | end |
||
1009 | if logId == nil then |
||
1010 | DEFAULT_CHAT_FRAME:AddMessage("TrackerError! LogId still nil after GetQuestIdFromHash ", hash); |
||
1011 | return; |
||
1012 | end |
||
1013 | local questName, level, questTag, isHeader, isCollapsed, isComplete = QGet_QuestLogTitle(logId); |
||
1014 | QuestieCachedQuests[hash]["questName"] = questName; |
||
1015 | QuestieCachedQuests[hash]["isComplete"] = isComplete; |
||
1016 | QuestieCachedQuests[hash]["questTag"] = questTag; |
||
1017 | QuestieCachedQuests[hash]["level"] = level; |
||
1018 | QuestieCachedQuests[hash]["logId"] = logId; |
||
1019 | QuestieCachedQuests[hash]["leaderboards"] = QGet_NumQuestLeaderBoards(logId); |
||
1020 | QuestieTracker:updateQuestWatchLogId(hash, logId); |
||
1021 | local uggo = 0; |
||
1022 | for i=1, QGet_NumQuestLeaderBoards(logId) do |
||
1023 | local desc, type, done = QGet_QuestLogLeaderBoard(i, logId); |
||
1024 | if not QuestieCachedQuests[hash]["objective"..i] then |
||
1025 | QuestieCachedQuests[hash]["objective"..i] = {}; |
||
1026 | end |
||
1027 | QuestieCachedQuests[hash]["objective"..i]["desc"] = desc; |
||
1028 | QuestieCachedQuests[hash]["objective"..i]["done"] = done; |
||
1029 | uggo = i; |
||
1030 | end |
||
1031 | uggo = uggo - 1; |
||
1032 | --Questie:debug_Print("Tracker:updateTrackerCache: [Hash: "..hash.."]"); |
||
1033 | end |
||
1034 | --------------------------------------------------------------------------------------------------- |
||
1035 | -- Adds quest from tracker when it's tracked - will not clear cached quest data |
||
1036 | --------------------------------------------------------------------------------------------------- |
||
1037 | function QuestieTracker:addQuestToTracker(hash) |
||
1038 | if (QuestieCachedQuests[hash] and QuestieCachedQuests[hash]["tracked"] ~= true) then |
||
1039 | QuestieCachedQuests[hash]["tracked"] = true; |
||
1040 | end |
||
1041 | end |
||
1042 | --------------------------------------------------------------------------------------------------- |
||
1043 | -- Removes quest from tracker when it's untracked - will not clear cached quest data |
||
1044 | --------------------------------------------------------------------------------------------------- |
||
1045 | function QuestieTracker:removeQuestFromTracker(hash) |
||
1046 | if (QuestieSeenQuests[hash] == 0) and (QuestieCachedQuests[hash] ~= nil) then |
||
1047 | QuestieCachedQuests[hash]["tracked"] = false; |
||
1048 | RemoveCrazyArrow(hash); |
||
1049 | end |
||
1050 | end |
||
1051 | --------------------------------------------------------------------------------------------------- |
||
1052 | --Blizzard Hooks to override the Default QuestLog behaviors |
||
1053 | --------------------------------------------------------------------------------------------------- |
||
1054 | function QuestieTracker:BlizzardHooks() |
||
1055 | if (not IsAddOnLoaded("EQL3")) and (not IsAddOnLoaded("ShaguQuest")) then |
||
1056 | --Hooks Blizzards AddQuestWatch to bypass thier method of populating the QUEST_WATCH_LIST table |
||
1057 | QAddQuestWatch = AddQuestWatch; |
||
1058 | function AddQuestWatch(questIndex) |
||
1059 | local prevQuestLogSelection = QGet_QuestLogSelection(); |
||
1060 | local questName, level, questTag, isHeader, isCollapsed, isComplete = QGet_QuestLogTitle(questIndex); |
||
1061 | QSelect_QuestLogEntry(questIndex); |
||
1062 | local questText, objectiveText = QGet_QuestLogQuestText(); |
||
1063 | local hash = Questie:getQuestHash(questName, level, objectiveText); |
||
1064 | if not QUEST_WATCH_LIST[hash] then |
||
1065 | QUEST_WATCH_LIST[hash] = {}; |
||
1066 | end |
||
1067 | if (QuestieCachedQuests[hash]) then |
||
1068 | QUEST_WATCH_LIST[hash]["questIndex"] = questIndex; |
||
1069 | QUEST_WATCH_LIST[hash]["questName"] = questName; |
||
1070 | --Questie:debug_Print("AddQuestWatch: [Hash: "..hash.."] | [Id: "..questIndex.."]"); |
||
1071 | end |
||
1072 | QSelect_QuestLogEntry(prevQuestLogSelection); |
||
1073 | QAddQuestWatch(questIndex); |
||
1074 | end |
||
1075 | ----------------------------------------------------------------------------------------------- |
||
1076 | --Hooks Blizzards RemoveQuestWatch to bypass thier |
||
1077 | --method of populating the QUEST_WATCH_LIST table |
||
1078 | QRemoveQuestWatch = RemoveQuestWatch; |
||
1079 | function RemoveQuestWatch(questIndex) |
||
1080 | local prevQuestLogSelection = QGet_QuestLogSelection(); |
||
1081 | local questName, level, questTag, isHeader, isCollapsed, isComplete = QGet_QuestLogTitle(questIndex); |
||
1082 | QSelect_QuestLogEntry(questIndex); |
||
1083 | local questText, objectiveText = QGet_QuestLogQuestText(); |
||
1084 | local hash = Questie:getQuestHash(questName, level, objectiveText); |
||
1085 | if (QuestieCachedQuests[hash]) then |
||
1086 | QUEST_WATCH_LIST[hash] = nil; |
||
1087 | --Questie:debug_Print("RemoveQuestWatch: [Hash: "..hash.."] | [Id: "..questIndex.."]"); |
||
1088 | end |
||
1089 | QSelect_QuestLogEntry(prevQuestLogSelection); |
||
1090 | QRemoveQuestWatch(questIndex); |
||
1091 | end |
||
1092 | ----------------------------------------------------------------------------------------------- |
||
1093 | --Hooks Blizzards AutoQuestWatch_CheckDeleted to bypass the default quest log checks |
||
1094 | QAutoQuestWatch_CheckDeleted = AutoQuestWatch_CheckDeleted; |
||
1095 | function AutoQuestWatch_CheckDeleted() |
||
1096 | end |
||
1097 | ----------------------------------------------------------------------------------------------- |
||
1098 | --Hooks Blizzards AutoQuestWatch_Update to bypass the default quest log checks |
||
1099 | QAutoQuestWatch_Update = AutoQuestWatch_Update; |
||
1100 | function AutoQuestWatch_Update(questIndex) |
||
1101 | end |
||
1102 | ----------------------------------------------------------------------------------------------- |
||
1103 | --Hooks Blizzards AutoQuestWatch_OnUpdate to bypass the default quest log checks |
||
1104 | QAutoQuestWatch_OnUpdate = AutoQuestWatch_OnUpdate; |
||
1105 | function AutoQuestWatch_OnUpdate(elapsed) |
||
1106 | -- Prevents QuestWatcher "flickering bug" |
||
1107 | if (QuestieConfig.trackerEnabled == true) then |
||
1108 | QuestWatchFrame:Hide(); |
||
1109 | end |
||
1110 | end |
||
1111 | ----------------------------------------------------------------------------------------------- |
||
1112 | --Hooks Blizzards IsQuestWatched so we can return our own values |
||
1113 | QIsQuestWatched = IsQuestWatched; |
||
1114 | function IsQuestWatched(id) |
||
1115 | local isWatched = false |
||
1116 | local questName, level, questTag, isHeader, isCollapsed, isComplete = QGet_QuestLogTitle(id) |
||
1117 | if not isHeader then |
||
1118 | local prevQuestLogSelection = QGet_QuestLogSelection() |
||
1119 | QSelect_QuestLogEntry(id) |
||
1120 | local questText, objectiveText = QGet_QuestLogQuestText() |
||
1121 | local hash = Questie:getQuestHash(questName, level, objectiveText) |
||
1122 | if (QuestieCachedQuests[hash]) then |
||
1123 | if QUEST_WATCH_LIST[hash] then |
||
1124 | --Questie:debug_Print("IsQuestWatched: [Hash: "..hash.."] | [Id: "..id.."] | YES") |
||
1125 | isWatched = true |
||
1126 | end |
||
1127 | end |
||
1128 | QSelect_QuestLogEntry(prevQuestLogSelection) |
||
1129 | end |
||
1130 | QIsQuestWatched(id) |
||
1131 | return isWatched |
||
1132 | end |
||
1133 | end |
||
1134 | end |
||
1135 | --------------------------------------------------------------------------------------------------- |
||
1136 | --End of Blizzard Hooks |
||
1137 | --------------------------------------------------------------------------------------------------- |
||
1138 | --///////////////////////////////////////////////////////////////////////////////////////////////-- |
||
1139 | --------------------------------------------------------------------------------------------------- |
||
1140 | --Adds new quests to the Blizzard QUEST_WATCH_LIST table and syncs with the quest log |
||
1141 | --------------------------------------------------------------------------------------------------- |
||
1142 | function QuestieTracker:syncQuestWatch() |
||
1143 | if (not IsAddOnLoaded("EQL3")) and (not IsAddOnLoaded("ShaguQuest")) then |
||
1144 | if (AUTO_QUEST_WATCH == "1") then |
||
1145 | for hash,v in pairs(QuestieCachedQuests) do |
||
1146 | if hash and v["logId"] then |
||
1147 | local id = v["logId"] |
||
1148 | if QuestieSeenQuests[hash] == 0 and QuestieCachedQuests[hash]["tracked"] == true then |
||
1149 | AddQuestWatch(id); |
||
1150 | Questie:debug_Print("Tracker:syncQuestWatch --> AddQuestWatch: [ID: "..id.."] | [hash: "..hash.."]"); |
||
1151 | elseif QuestieSeenQuests[hash] == 0 and QuestieCachedQuests[hash]["tracked"] == false then |
||
1152 | RemoveQuestWatch(id); |
||
1153 | Questie:debug_Print("Tracker:syncQuestWatch --> RemoveQuestWatch: [ID: "..id.."] | [hash: "..hash.."]"); |
||
1154 | end |
||
1155 | QuestWatch_Update(); |
||
1156 | -- Prevents QuestWatcher "flickering bug" |
||
1157 | if (QuestieConfig.trackerEnabled == true) then |
||
1158 | QuestWatchFrame:Hide(); |
||
1159 | end |
||
1160 | QuestLog_SetSelection(id); |
||
1161 | QuestLog_Update(); |
||
1162 | end |
||
1163 | end |
||
1164 | end |
||
1165 | end |
||
1166 | end |
||
1167 | --------------------------------------------------------------------------------------------------- |
||
1168 | --Checks and flags tracked quest status and then adds them to the quest tracker |
||
1169 | --------------------------------------------------------------------------------------------------- |
||
1170 | function QuestieTracker:syncQuestLog() |
||
1171 | Questie:debug_Print("****************| Running QuestieTracker:syncQuestLog |**************** "); |
||
1172 | if IsAddOnLoaded("EQL3") or IsAddOnLoaded("ShaguQuest") then |
||
1173 | QuestLogSync = EQL3_IsQuestWatched; |
||
1174 | else |
||
1175 | QuestLogSync = IsQuestWatched; |
||
1176 | end |
||
1177 | local prevQuestLogSelection = QGet_QuestLogSelection(); |
||
1178 | local id = 1; |
||
1179 | local qc = 0; |
||
1180 | local nEntry, nQuests = QGet_NumQuestLogEntries(); |
||
1181 | while qc < nQuests do |
||
1182 | local isWatched = QuestLogSync(id); |
||
1183 | local questName, level, questTag, isHeader, isCollapsed, isComplete = QGet_QuestLogTitle(id); |
||
1184 | if not isHeader and not isCollapsed then |
||
1185 | QSelect_QuestLogEntry(id); |
||
1186 | local questText, objectiveText = QGet_QuestLogQuestText(); |
||
1187 | local hash = Questie:getQuestHash(questName, level, objectiveText); |
||
1188 | QuestieTracker:updateQuestWatchLogId(hash, id); |
||
1189 | if (isWatched) and (QuestieCachedQuests[hash] and QuestieCachedQuests[hash]["tracked"] ~= true) then |
||
1190 | if QuestieCachedQuests[hash] then |
||
1191 | Questie:debug_Print("Tracker:syncQuestLog --> addQuestToTracker: Flagging [Hash: "..hash.."] TRUE"); |
||
1192 | QuestieTracker:addQuestToTracker(hash); |
||
1193 | else |
||
1194 | Questie:debug_Print("Tracker:syncQuestLog --> Add quest to Tracker and MapNotes caches: [Hash: "..hash.."]"); |
||
1195 | Questie:AddQuestToMap(hash); |
||
1196 | QuestieTracker:addQuestToTrackerCache(hash, id, level); |
||
1197 | QuestieTracker:addQuestToTracker(hash); |
||
1198 | end |
||
1199 | elseif (not isWatched) and (QuestieCachedQuests[hash] and QuestieCachedQuests[hash]["tracked"] ~= false) then |
||
1200 | Questie:debug_Print("Tracker:syncQuestLog --> removeQuestFromTracker: Flagging [Hash: "..hash.."] FALSE"); |
||
1201 | QuestieTracker:removeQuestFromTracker(hash); |
||
1202 | end |
||
1203 | end |
||
1204 | if not isHeader then |
||
1205 | qc = qc + 1; |
||
1206 | end |
||
1207 | id = id + 1; |
||
1208 | end |
||
1209 | QSelect_QuestLogEntry(prevQuestLogSelection); |
||
1210 | QuestieTracker:FillTrackingFrame(); |
||
1211 | QuestieTracker:updateTrackingFrameSize(); |
||
1212 | end |
||
1213 | --------------------------------------------------------------------------------------------------- |
||
1214 | -- Saves the position of the tracker after the user moves it |
||
1215 | --------------------------------------------------------------------------------------------------- |
||
1216 | function QuestieTracker:saveFramePosition() |
||
1217 | local frame = getglobal("QuestieTrackerFrame"); |
||
1218 | local resolution = ({GetScreenResolutions()})[GetCurrentResolution()]; |
||
1219 | local _, _, x, y = string.find(resolution, "(%d+)x(%d+)"); |
||
1220 | local scrndiv = tonumber(x) / 2; |
||
1221 | local point, _, relativePoint, xOfs, yOfs = frame:GetPoint(); |
||
1222 | if QuestieTracker.frame:GetLeft() < scrndiv then |
||
1223 | if (QuestieConfig.trackerList == true) then |
||
1224 | QuestieTrackerVariables = {}; |
||
1225 | QuestieTrackerVariables["position"] = { |
||
1226 | ["point"] = "BOTTOMLEFT", |
||
1227 | ["relativePoint"] = "BOTTOMLEFT", |
||
1228 | ["relativeTo"] = "UIParent", |
||
1229 | ["yOfs"] = (QuestieTracker.frame:GetBottom()), |
||
1230 | ["xOfs"] = (QuestieTracker.frame:GetLeft()), |
||
1231 | }; |
||
1232 | else |
||
1233 | QuestieTrackerVariables = {} |
||
1234 | QuestieTrackerVariables["position"] = { |
||
1235 | ["point"] = "TOPLEFT", |
||
1236 | ["relativePoint"] = "TOPLEFT", |
||
1237 | ["relativeTo"] = "UIParent", |
||
1238 | ["yOfs"] = yOfs, |
||
1239 | ["xOfs"] = xOfs, |
||
1240 | }; |
||
1241 | end |
||
1242 | else |
||
1243 | if (QuestieConfig.trackerList == true) then |
||
1244 | QuestieTrackerVariables = {} |
||
1245 | QuestieTrackerVariables["position"] = { |
||
1246 | ["point"] = "BOTTOMRIGHT", |
||
1247 | ["relativePoint"] = "BOTTOMLEFT", |
||
1248 | ["relativeTo"] = "UIParent", |
||
1249 | ["yOfs"] = (QuestieTracker.frame:GetBottom()), |
||
1250 | ["xOfs"] = (QuestieTracker.frame:GetRight()), |
||
1251 | }; |
||
1252 | else |
||
1253 | QuestieTrackerVariables = {} |
||
1254 | QuestieTrackerVariables["position"] = { |
||
1255 | ["point"] = "TOPRIGHT", |
||
1256 | ["relativePoint"] = "TOPLEFT", |
||
1257 | ["relativeTo"] = "UIParent", |
||
1258 | ["yOfs"] = yOfs, |
||
1259 | ["xOfs"] = (QuestieTracker.frame:GetRight()), |
||
1260 | }; |
||
1261 | end |
||
1262 | end |
||
1263 | end |
||
1264 | --------------------------------------------------------------------------------------------------- |
||
1265 | -- If no quest tracker frame position is present in the users SavedVariables then this sets a |
||
1266 | -- default location in memory so when the user desicdes to move it, it won't throw a nil error. |
||
1267 | -- This function will also resize the world map from fullscreen to 80% via a slash toggle when |
||
1268 | -- map mods such as Cartographer or MetaMap aren't being used. |
||
1269 | --------------------------------------------------------------------------------------------------- |
||
1270 | function QuestieTracker:LoadModule() |
||
1271 | if not ( QuestieTrackerVariables ) then |
||
1272 | QuestieTrackerVariables = {}; |
||
1273 | QuestieTrackerVariables["position"] = { |
||
1274 | point = "CENTER", |
||
1275 | relativeTo = "UIParent", |
||
1276 | relativePoint = "CENTER", |
||
1277 | xOfs = 0, |
||
1278 | yOfs = 0, |
||
1279 | }; |
||
1280 | end |
||
1281 | -- This adds the ability to scale the Worldmap from FULLSCREEN or to a WINDOW if a player isn't using Cargographer or MetaMap. |
||
1282 | if (QuestieConfig == nil) or (QuestieConfig.resizeWorldmap == nil) or (QuestieConfig.resizeWorldmap == false) or (IsAddOnLoaded("Cartographer")) or (IsAddOnLoaded("MetaMap")) then return; end |
||
1283 | if (not IsAddOnLoaded("Cartographer")) or (not IsAddOnLoaded("MetaMap")) then |
||
1284 | UIPanelWindows["WorldMapFrame"] = { area = "center", pushable = 0 }; |
||
1285 | WorldMapFrame:SetFrameStrata("FULLSCREEN"); |
||
1286 | WorldMapFrame:SetScript("OnKeyDown", nil); |
||
1287 | WorldMapFrame:RegisterForDrag("LeftButton"); |
||
1288 | WorldMapFrame:EnableMouse(true); |
||
1289 | WorldMapFrame:SetMovable(true); |
||
1290 | WorldMapFrame:SetScale(.8); |
||
1291 | WorldMapTooltip:SetScale(1); |
||
1292 | WorldMapFrame:SetWidth(1024); |
||
1293 | WorldMapFrame:SetHeight(768); |
||
1294 | WorldMapFrame:ClearAllPoints(); |
||
1295 | WorldMapFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, 0); |
||
1296 | BlackoutWorld:Hide(); |
||
1297 | WorldMapFrame:SetScript("OnDragStart", function() |
||
1298 | this:SetWidth(1024); |
||
1299 | this:SetHeight(768); |
||
1300 | this:StartMoving(); |
||
1301 | end) |
||
1302 | WorldMapFrame:SetScript("OnDragStop", function() |
||
1303 | this:StopMovingOrSizing(); |
||
1304 | this:SetWidth(1024); |
||
1305 | this:SetHeight(768); |
||
1306 | local x,y = this:GetCenter(); |
||
1307 | local z = UIParent:GetEffectiveScale() / 2 / this:GetScale(); |
||
1308 | x = x - GetScreenWidth() * z; |
||
1309 | y = y - GetScreenHeight() * z; |
||
1310 | this:ClearAllPoints(); |
||
1311 | this:SetPoint("CENTER", "UIParent", "CENTER", x, y); |
||
1312 | end) |
||
1313 | WorldMapFrame:SetScript("OnShow", function() |
||
1314 | local continent = GetCurrentMapContinent(); |
||
1315 | local zone = GetCurrentMapZone(); |
||
1316 | SetMapZoom(continent, zone); |
||
1317 | SetMapToCurrentZone(); |
||
1318 | end) |
||
1319 | end |
||
1320 | end |