vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Log Script file for Extended Questlog 3.5
2 -- Copyright © 2006 Daniel Rehn
3  
4 function EQL3_Maximize()
5 EQL3_QuestLogFrameCloseButton:Hide();
6 EQL3_QuestLogFrameMaximizeButton:Hide();
7 EQL3_QuestLogCountRight:SetPoint("TOPRIGHT", -28, -43);
8 EQL3_QuestLogTitleText:SetPoint("TOP", 48, -16);
9 EQL3_QuestLogVersionText:SetPoint("TOPRIGHT", -67, -16);
10 EQL3_QuestFrameOptionsButton:SetPoint("BOTTOMRIGHT", -25, 5);
11  
12 EQL3_Top_Switch_On:Show();
13 EQL3_Bottom_Switch_On:Show();
14 EQL3_Top_Switch_Off:Hide();
15 EQL3_Bottom_Switch_Off:Hide();
16 -- EQL3_Top_Switch:SetTexture("Interface\Addons\EQL3\Images\EQL3_TopSwitchOn.tga");
17 -- EQL3_Bottom_Switch:SetTexture("Interface\Addons\EQL3\Images\EQL3_BottomSwitchOn.tga");
18  
19 QuestlogOptions[EQL3_Player].WindowState = 1;
20 ShowUIPanel(EQL3_QuestLogFrame_Description);
21 end
22  
23 function EQL3_Minimize()
24 EQL3_QuestLogFrameCloseButton:Show();
25 EQL3_QuestLogFrameMaximizeButton:Show();
26 EQL3_QuestLogCountRight:SetPoint("TOPRIGHT", -356, -43);
27 EQL3_QuestLogTitleText:SetPoint("TOP", -114, -16);
28 EQL3_QuestLogVersionText:SetPoint("TOPRIGHT", -395, -16);
29 EQL3_QuestFrameOptionsButton:SetPoint("BOTTOMRIGHT", -354, 5);
30  
31 EQL3_Top_Switch_On:Hide();
32 EQL3_Bottom_Switch_On:Hide();
33 EQL3_Top_Switch_Off:Show();
34 EQL3_Bottom_Switch_Off:Show();
35 -- EQL3_Top_Switch:SetTexture("Interface\Addons\EQL3\Images\EQL3_TopSwitchOff");
36 -- EQL3_Bottom_Switch:SetTexture("Interface\Addons\EQL3\Images\EQL3_BottomSwitchOff");
37  
38 QuestlogOptions[EQL3_Player].WindowState = 0;
39 HideUIPanel(EQL3_QuestLogFrame_Description);
40 end
41  
42 -- Toggle
43 local old_ToggleQuestLog = ToggleQuestLog;
44 function ToggleQuestLog()
45 if ( EQL3_QuestLogFrame:IsVisible() ) then
46 HideUIPanel(EQL3_QuestLogFrame);
47 else
48 ShowUIPanel(EQL3_QuestLogFrame);
49 end
50 end
51  
52  
53  
54 -- ::::::::::::::::::: On Functions ::::::::::::::::::: --
55  
56 -- OnLoad
57 function EQL_QuestLog_OnLoad()
58 this:RegisterEvent("VARIABLES_LOADED");
59 this:RegisterEvent("QUEST_PROGRESS");
60 this:RegisterEvent("QUEST_COMPLETE");
61 end
62  
63 -- OnEvent
64 function EQL_QuestLog_OnEvent(event)
65 if (event == "VARIABLES_LOADED") then
66 EQL3_Player = UnitName("player").."-"..GetRealmName();
67  
68 DEFAULT_CHAT_FRAME:AddMessage("Extended QuestLog "..EQL3_QUESTLOG_VERSION.." Loaded for "..UnitName("player").. " of "..GetRealmName()..".", 1, 1, 1, 1);
69  
70 if(QuestlogOptions == nil) then
71 QuestlogOptions = {};
72 end
73 if(QuestlogOptions[EQL3_Player] == nil) then
74 QuestlogOptions[EQL3_Player] = {};
75 end
76  
77 -- Organizer
78  
79 if (QuestlogOptions[EQL3_Player].OrganizerSettings == nil) then
80 QuestlogOptions[EQL3_Player].OrganizerSettings = {};
81 end
82  
83 if (QuestlogOptions[EQL3_Player].WindowState == nil) then
84 QuestlogOptions[EQL3_Player].WindowState = 0;
85 end
86 if(QuestlogOptions[EQL3_Player].WindowState == 1) then
87 EQL3_Maximize();
88 end
89  
90 if(QuestlogOptions[EQL3_Player].QuestWatches == nil) then
91 QuestlogOptions[EQL3_Player].QuestWatches = {};
92 end
93  
94 if(QuestlogOptions[EQL3_Player].ShowQuestLevels == nil) then
95 QuestlogOptions[EQL3_Player].ShowQuestLevels = 1;
96 end
97  
98 if(QuestlogOptions[EQL3_Player].RestoreUponSelect == nil) then
99 QuestlogOptions[EQL3_Player].RestoreUponSelect = 1;
100 end
101  
102 if(QuestlogOptions[EQL3_Player].MinimizeUponClose == nil) then
103 QuestlogOptions[EQL3_Player].MinimizeUponClose = 1;
104 end
105  
106 if(QuestlogOptions[EQL3_Player].LockQuestLog == nil) then
107 QuestlogOptions[EQL3_Player].LockQuestLog = 1;
108 end
109 -- Make It movable if so...
110 if(QuestlogOptions[EQL3_Player].LockQuestLog == 1) then
111 EQL3_QuestLogFrame:RegisterForDrag(0);
112 EQL3_QuestLogFrame_Description:RegisterForDrag(0);
113 else
114 EQL3_QuestLogFrame:RegisterForDrag("LeftButton");
115 EQL3_QuestLogFrame_Description:RegisterForDrag("LeftButton");
116 end
117  
118 if (QuestlogOptions[EQL3_Player].LogLockPoints and
119 QuestlogOptions[EQL3_Player].LogLockPoints.pointone and
120 QuestlogOptions[EQL3_Player].LogLockPoints.pointtwo) then
121 EQL3_QuestLogFrame:ClearAllPoints();
122 EQL3_QuestLogFrame:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",QuestlogOptions[EQL3_Player].LogLockPoints.pointone,QuestlogOptions[EQL3_Player].LogLockPoints.pointtwo);
123 end
124  
125 if(QuestlogOptions[EQL3_Player].LogOpacity == nil) then
126 QuestlogOptions[EQL3_Player].LogOpacity = 1.0;
127 end
128 EQL3_QuestLogFrame:SetAlpha(QuestlogOptions[EQL3_Player].LogOpacity);
129  
130 if(QuestlogOptions[EQL3_Player].ShowZonesInTracker == nil) then
131 QuestlogOptions[EQL3_Player].ShowZonesInTracker = 1;
132 end
133  
134 if(QuestlogOptions[EQL3_Player].SortTrackerItems == nil) then
135 QuestlogOptions[EQL3_Player].SortTrackerItems = 0;
136 end
137  
138 if(QuestlogOptions[EQL3_Player].CustomZoneColor == nil) then
139 QuestlogOptions[EQL3_Player].CustomZoneColor = 0;
140 end
141  
142 if(QuestlogOptions[EQL3_Player].CustomHeaderColor == nil) then
143 QuestlogOptions[EQL3_Player].CustomHeaderColor = 0;
144 end
145  
146 if(QuestlogOptions[EQL3_Player].CustomObjetiveColor == nil) then
147 QuestlogOptions[EQL3_Player].CustomObjetiveColor = 0;
148 end
149  
150 if(QuestlogOptions[EQL3_Player].FadeHeaderColor == nil) then
151 QuestlogOptions[EQL3_Player].FadeHeaderColor = 0;
152 end
153  
154 if(QuestlogOptions[EQL3_Player].FadeObjectiveColor == nil) then
155 QuestlogOptions[EQL3_Player].FadeObjectiveColor = 0;
156 end
157  
158 if(QuestlogOptions[EQL3_Player].CustomTrackerBGColor == nil) then
159 QuestlogOptions[EQL3_Player].CustomTrackerBGColor = 0;
160 end
161  
162 if(QuestlogOptions[EQL3_Player].UseTrackerListing == nil) then
163 QuestlogOptions[EQL3_Player].UseTrackerListing = 0;
164 end
165  
166 if(QuestlogOptions[EQL3_Player].TrackerList == nil) then
167 QuestlogOptions[EQL3_Player].TrackerList = 0;
168 end
169  
170 if(QuestlogOptions[EQL3_Player].TrackerSymbol == nil) then
171 QuestlogOptions[EQL3_Player].TrackerSymbol = 0;
172 end
173  
174 if(QuestlogOptions[EQL3_Player].Color == nil) then
175 QuestlogOptions[EQL3_Player].Color = {};
176 end
177  
178 -- Colors
179  
180 if(QuestlogOptions[EQL3_Player].Color["TrackerBG"] == nil) then
181 QuestlogOptions[EQL3_Player].Color["TrackerBG"] = { r = TOOLTIP_DEFAULT_BACKGROUND_COLOR.r,
182 g = TOOLTIP_DEFAULT_BACKGROUND_COLOR.g,
183 b = TOOLTIP_DEFAULT_BACKGROUND_COLOR.b,
184 a = 0.0};
185 end
186  
187 if(QuestlogOptions[EQL3_Player].Color["TrackerBG"].a == nil) then
188 QuestlogOptions[EQL3_Player].Color["TrackerBG"].a = 0.0;
189 end
190  
191 if(QuestlogOptions[EQL3_Player].Color["Zone"] == nil) then
192 QuestlogOptions[EQL3_Player].Color["Zone"] = {r = 1.0, g = 1.0, b = 1.0};
193 end
194  
195 if(QuestlogOptions[EQL3_Player].Color["HeaderEmpty"] == nil) then
196 QuestlogOptions[EQL3_Player].Color["HeaderEmpty"] = {r = 0.75, g = 0.61, b = 0.0};
197 end
198  
199 if(QuestlogOptions[EQL3_Player].Color["HeaderComplete"] == nil) then
200 QuestlogOptions[EQL3_Player].Color["HeaderComplete"] = {r = NORMAL_FONT_COLOR.r,
201 g = NORMAL_FONT_COLOR.g,
202 b = NORMAL_FONT_COLOR.b};
203 end
204  
205 if(QuestlogOptions[EQL3_Player].Color["ObjectiveEmpty"] == nil) then
206 QuestlogOptions[EQL3_Player].Color["ObjectiveEmpty"] = {r = 0.8, g = 0.8, b = 0.8};
207 end
208  
209 if(QuestlogOptions[EQL3_Player].Color["ObjectiveComplete"] == nil) then
210 QuestlogOptions[EQL3_Player].Color["ObjectiveComplete"] = {r = HIGHLIGHT_FONT_COLOR.r,
211 g = HIGHLIGHT_FONT_COLOR.g,
212 b = HIGHLIGHT_FONT_COLOR.b};
213 end
214  
215  
216  
217 if(QuestlogOptions[EQL3_Player].LockTracker == nil) then
218 QuestlogOptions[EQL3_Player].LockTracker = 0;
219 end
220 if(QuestlogOptions[EQL3_Player].LockPoints == nil) then
221 QuestlogOptions[EQL3_Player].LockPoints = {};
222 end
223  
224 if(QuestlogOptions[EQL3_Player].AddNew == nil) then
225 QuestlogOptions[EQL3_Player].AddNew = 0;
226 end
227 if(QuestlogOptions[EQL3_Player].RemoveFinished == nil) then
228 QuestlogOptions[EQL3_Player].RemoveFinished = 0;
229 end
230 if(QuestlogOptions[EQL3_Player].MinimizeFinished == nil) then
231 QuestlogOptions[EQL3_Player].MinimizeFinished = 0;
232 end
233 if(QuestlogOptions[EQL3_Player].AddUntracked == nil) then
234 QuestlogOptions[EQL3_Player].AddUntracked = 0;
235 end
236  
237  
238 if(QuestlogOptions[EQL3_Player].TrackerFontHeight == nil) then
239 QuestlogOptions[EQL3_Player].TrackerFontHeight = 12;
240 end
241  
242 if(QuestlogOptions[EQL3_Player].TrackerShowMinimizer == nil) then
243 QuestlogOptions[EQL3_Player].TrackerShowMinimizer = 0;
244 end
245 if(QuestlogOptions[EQL3_Player].TrackerIsMinimized == nil) then
246 QuestlogOptions[EQL3_Player].TrackerIsMinimized = 0;
247 end
248  
249 -- 3.5.6b
250 if( QuestlogOptions[EQL3_Player].AutoCompleteQuests == nil ) then
251 QuestlogOptions[EQL3_Player].AutoCompleteQuests = 0;
252 end
253 if( QuestlogOptions[EQL3_Player].RemoveCompletedObjectives == nil ) then
254 QuestlogOptions[EQL3_Player].RemoveCompletedObjectives = 0;
255 end
256 if( QuestlogOptions[EQL3_Player].ShowObjectiveMarkers == nil ) then
257 QuestlogOptions[EQL3_Player].ShowObjectiveMarkers = 1;
258 end
259 if( QuestlogOptions[EQL3_Player].OnlyLevelsInLog == nil ) then
260 QuestlogOptions[EQL3_Player].OnlyLevelsInLog = 0;
261 end
262  
263 -- 3.5.9
264 if( QuestlogOptions[EQL3_Player].ItemTooltip == nil ) then
265 QuestlogOptions[EQL3_Player].ItemTooltip = 0;
266 end
267 if( QuestlogOptions[EQL3_Player].MobTooltip == nil ) then
268 QuestlogOptions[EQL3_Player].MobTooltip = 0;
269 end
270 if( QuestlogOptions[EQL3_Player].InfoOnQuestCompletion == nil ) then
271 QuestlogOptions[EQL3_Player].InfoOnQuestCompletion = 0;
272 end
273  
274  
275 if(QuestlogOptions[EQL3_Player].Color["Tooltip"] == nil) then
276 QuestlogOptions[EQL3_Player].Color["Tooltip"] = {r = 1.0, g = 0.8, b = 0.0};
277 end
278  
279 if(QuestlogOptions[EQL3_Player].CustomTooltipColor == nil) then
280 QuestlogOptions[EQL3_Player].CustomTooltipColor = 0;
281 end
282  
283  
284  
285 elseif ( event == "QUEST_PROGRESS" ) then
286 if ( QuestlogOptions[EQL3_Player].AutoCompleteQuests == 1 ) then
287 if ( IsQuestCompletable() ) then
288 CompleteQuest();
289 end
290 end
291 elseif ( event == "QUEST_COMPLETE" ) then
292 if ( QuestlogOptions[EQL3_Player].AutoCompleteQuests == 1 and GetNumQuestChoices() == 0 ) then
293 GetQuestReward(QuestFrameRewardPanel.itemChoice);
294 end
295 end
296 end
297  
298 local old_QuestLog_OnEvent = QuestLog_OnEvent;
299 function QuestLog_OnEvent(event)
300 if ( event == "QUEST_LOG_UPDATE" or event == "UPDATE_FACTION" or (event == "UNIT_QUEST_LOG_CHANGED" and arg1 == "player") ) then
301 QuestLog_Update();
302 QuestWatch_Update();
303 if ( EQL3_QuestLogFrame:IsVisible() ) then
304 QuestLog_UpdateQuestDetails(1);
305 end
306  
307 if(event == "QUEST_LOG_UPDATE") then
308 if(QuestlogOptions[EQL3_Player].InfoOnQuestCompletion == 1) then
309 LookForCompletedQuests();
310 end
311 end
312 else
313 QuestLog_Update();
314 if ( event == "PARTY_MEMBERS_CHANGED" ) then
315 -- Determine whether the selected quest is pushable or not
316 if ( GetQuestLogPushable() and GetNumPartyMembers() > 0 ) then
317 EQL3_QuestFramePushQuestButton:Enable();
318 else
319 EQL3_QuestFramePushQuestButton:Disable();
320 end
321 end
322 end
323 end
324  
325  
326 -- OnShow
327 local old_QuestLog_OnShow = QuestLog_OnShow;
328 function QuestLog_OnShow()
329 -- fix for crash with gypsy causing blank log and error
330 if ( Gypsy_ShowQuestLevels and Gypsy_ShowQuestLevels == 1 ) then Gypsy_ShowQuestLevels = 0 end
331  
332 if(QuestLogFrame:IsVisible()) then
333 QuestLogFrame:Hide();
334 end
335  
336 ShowUIPanel(EQL3_QuestLogFrame);
337  
338 if (QuestlogOptions[EQL3_Player].LogLockPoints and
339 QuestlogOptions[EQL3_Player].LogLockPoints.pointone and
340 QuestlogOptions[EQL3_Player].LogLockPoints.pointtwo) then
341 EQL3_QuestLogFrame:ClearAllPoints();
342 EQL3_QuestLogFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", QuestlogOptions[EQL3_Player].LogLockPoints.pointone,QuestlogOptions[EQL3_Player].LogLockPoints.pointtwo);
343 end
344  
345 UpdateMicroButtons();
346 PlaySound("igQuestLogOpen");
347 QuestLog_SetSelection(GetQuestLogSelection());
348 QuestLog_Update();
349 end
350  
351 -- OnHide
352 local old_QuestLog_OnHide = QuestLog_OnHide;
353 function QuestLog_OnHide()
354 HideUIPanel(EQL3_QuestLogFrame);
355 UpdateMicroButtons();
356 PlaySound("igQuestLogClose");
357 EQL3_Organize_Popup:Hide();
358 EQL3_OptionsFrame:Hide();
359 if ( QuestlogOptions[EQL3_Player].MinimizeUponClose == 1 ) then
360 EQL3_Minimize();
361 end
362 end
363  
364 -- OnUpdate
365 local old_QuestLog_OnUpdate = QuestLog_OnUpdate;
366 function QuestLog_OnUpdate(elapsed)
367 if ( EQL3_QuestLogFrame.hasTimer ) then
368 EQL3_QuestLogFrame.timePassed = EQL3_QuestLogFrame.timePassed + elapsed;
369 if ( EQL3_QuestLogFrame.timePassed > UPDATE_DELAY ) then
370 EQL3_QuestLogTimerText:SetText(TEXT(TIME_REMAINING).." "..SecondsToTime(GetQuestLogTimeLeft()));
371 EQL3_QuestLogFrame.timePassed = 0;
372 end
373 end
374 end
375  
376  
377  
378 local normal_QuestLog_Update = QuestLog_Update;
379  
380 function QuestLog_Update()
381 local numEntries, numQuests = GetNumQuestLogEntries();
382 if ( numEntries == 0 ) then
383 EQL3_EmptyQuestLogFrame:Show();
384 EQL3_QuestLogFrameAbandonButton:Disable();
385 QuestLogFrame.hasTimer = nil;
386 EQL3_QuestLogDetailScrollFrame:Hide();
387 EQL3_QuestLogExpandButtonFrame:Hide();
388 else
389 EQL3_EmptyQuestLogFrame:Hide();
390 EQL3_QuestLogFrameAbandonButton:Enable();
391 EQL3_QuestLogDetailScrollFrame:Show();
392 EQL3_QuestLogExpandButtonFrame:Show();
393 end
394  
395 -- Update Quest Count
396 EQL3_QuestLogQuestCount:SetText(format(QUEST_LOG_COUNT_TEMPLATE, numQuests, MAX_QUESTLOG_QUESTS));
397 EQL3_QuestLogCountMiddle:SetWidth(EQL3_QuestLogQuestCount:GetWidth());
398  
399 -- ScrollFrame update
400 FauxScrollFrame_Update(EQL3_QuestLogListScrollFrame, numEntries, EQL3_QUESTS_DISPLAYED, QUESTLOG_QUEST_HEIGHT, nil, nil, nil, EQL3_QuestLogHighlightFrame, 293, 316 )
401  
402 -- Update the quest listing
403 EQL3_QuestLogHighlightFrame:Hide();
404  
405 local questIndex, questLogTitle, questTitleTag, questNumGroupMates, questNormalText, questHighlightText, questDisabledText, questHighlight, questCheck;
406 local questLogTitleText, level, questTag, isHeader, isCollapsed, isComplete, color;
407 local numPartyMembers, partyMembersOnQuest, tempWidth, textWidth, tempLevel;
408 for i=1, EQL3_QUESTS_DISPLAYED, 1 do
409 questIndex = i + FauxScrollFrame_GetOffset(EQL3_QuestLogListScrollFrame);
410 questLogTitle = getglobal("EQL3_QuestLogTitle"..i);
411 questTitleTag = getglobal("EQL3_QuestLogTitle"..i.."Tag");
412 questNumGroupMates = getglobal("EQL3_QuestLogTitle"..i.."GroupMates");
413 questCheck = getglobal("EQL3_QuestLogTitle"..i.."Check");
414 questNormalText = getglobal("EQL3_QuestLogTitle"..i.."NormalText");
415 questHighlightText = getglobal("EQL3_QuestLogTitle"..i.."NormalText");
416 questDisabledText = getglobal("EQL3_QuestLogTitle"..i.."NormalText");
417 questHighlight = getglobal("EQL3_QuestLogTitle"..i.."Highlight");
418 if ( questIndex <= numEntries ) then
419 questLogTitleText, level, questTag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questIndex);
420 if(not questLogTitleText) then questLogTitleText = "Please report this error!" end
421 if ( isHeader ) then
422 if ( questLogTitleText ) then
423 questLogTitle:SetText(questLogTitleText);
424 else
425 questLogTitle:SetText("");
426 end
427  
428 --[[
429 if ( isCollapsed ) then
430 questLogTitle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up");
431 else
432 questLogTitle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up");
433 end
434 ]]--
435  
436 questLogTitle:SetNormalTexture("Interface\\Addons\\EQL3\\Images\\EQL3_Header_Icon");
437  
438 questHighlight:SetTexture("Interface\\Buttons\\UI-PlusButton-Hilight");
439 questNumGroupMates:SetText("");
440 questCheck:Hide();
441 else
442  
443 if(QuestlogOptions[EQL3_Player].ShowQuestLevels == 1) then
444 tempLevel = level;
445 if (questTag ~= NIL) then
446 tempLevel = tempLevel.."+";
447 end
448 questLogTitle:SetText(" ".."["..tempLevel.."] "..questLogTitleText);
449 else
450 questLogTitle:SetText(" "..questLogTitleText);
451 end
452  
453  
454 -- Set Dummy text to get text width *SUPER HACK*
455 QuestLogDummyText:SetText(questLogTitle:GetText());
456  
457 questLogTitle:SetNormalTexture("");
458 questHighlight:SetTexture("");
459  
460 -- If not a header see if any nearby group mates are on this quest
461 numPartyMembers = GetNumPartyMembers();
462 if ( numPartyMembers == 0 ) then
463 --return;
464 end
465 partyMembersOnQuest = 0;
466 for j=1, numPartyMembers do
467 if ( IsUnitOnQuest(questIndex, "party"..j) ) then
468 partyMembersOnQuest = partyMembersOnQuest + 1;
469 end
470 end
471 if ( partyMembersOnQuest > 0 ) then
472 questNumGroupMates:SetText("["..partyMembersOnQuest.."]");
473 else
474 questNumGroupMates:SetText("");
475 end
476 end
477 -- Save if its a header or not
478 questLogTitle.isHeader = isHeader;
479  
480 -- Set the quest tag
481 if ( isComplete and isComplete < 0 ) then
482 questTag = FAILED;
483 elseif ( isComplete and isComplete > 0 ) then
484 questTag = COMPLETE;
485 end
486 if ( questTag ) then
487 questTitleTag:SetText("("..questTag..")");
488 -- Shrink text to accomdate quest tags without wrapping
489 tempWidth = 275 - 15 - questTitleTag:GetWidth();
490  
491 if ( QuestLogDummyText:GetWidth() > tempWidth ) then
492 textWidth = tempWidth;
493 else
494 textWidth = QuestLogDummyText:GetWidth();
495 end
496  
497 questNormalText:SetWidth(tempWidth);
498 questHighlightText:SetWidth(tempWidth);
499 questDisabledText:SetWidth(tempWidth);
500  
501 -- If there's quest tag position check accordingly
502 questCheck:Hide();
503 if ( IsQuestWatched(questIndex) ) then
504 questCheck:SetPoint("LEFT", questLogTitle, "LEFT", textWidth+24, 0);
505 questCheck:Show();
506 end
507 else
508 questTitleTag:SetText("");
509 -- Reset to max text width
510 questNormalText:SetWidth(275);
511 questHighlightText:SetWidth(275);
512 questDisabledText:SetWidth(275);
513  
514 -- Show check if quest is being watched
515 questCheck:Hide();
516 if ( IsQuestWatched(questIndex) ) then
517 questCheck:SetPoint("LEFT", questLogTitle, "LEFT", QuestLogDummyText:GetWidth()+24, 0);
518 questCheck:Show();
519 end
520 end
521  
522  
523  
524 -- Color the quest title and highlight according to the difficulty level
525  
526 if(not level) then level = 0; end
527  
528 local playerLevel = UnitLevel("player");
529 if ( isHeader ) then
530 color = QuestDifficultyColor["header"];
531 else
532 color = GetDifficultyColor(level);
533 end
534 questTitleTag:SetTextColor(color.r, color.g, color.b);
535 questLogTitle:SetTextColor(color.r, color.g, color.b);
536 questNumGroupMates:SetTextColor(color.r, color.g, color.b);
537 questLogTitle.r = color.r;
538 questLogTitle.g = color.g;
539 questLogTitle.b = color.b;
540 questLogTitle:Show();
541  
542 -- Place the highlight and lock the highlight state
543 if ( EQL3_QuestLogFrame.selectedButtonID and GetQuestLogSelection() == questIndex ) then
544 EQL3_QuestLogHighlightFrame:SetPoint("TOPLEFT", "EQL3_QuestLogTitle"..i, "TOPLEFT", 0, 0);
545 EQL3_QuestLogHighlightFrame:Show();
546 questTitleTag:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
547 questLogTitle:LockHighlight();
548 else
549 questLogTitle:UnlockHighlight();
550 end
551 else
552 questLogTitle:Hide();
553 end
554 end
555  
556 -- Set the expand/collapse all button texture
557 local numHeaders = 0;
558 local notExpanded = 0;
559 -- Somewhat redundant loop, but cleaner than the alternatives
560 for i=1, numEntries, 1 do
561 local index = i;
562 local questLogTitleText, level, questTag, isHeader, isCollapsed = GetQuestLogTitle(i);
563 if ( questLogTitleText and isHeader ) then
564 numHeaders = numHeaders + 1;
565 if ( isCollapsed ) then
566 notExpanded = notExpanded + 1;
567 end
568 end
569 end
570 -- If all headers are not expanded then show collapse button, otherwise show the expand button
571 if ( notExpanded ~= numHeaders ) then
572 EQL3_QuestLogCollapseAllButton.collapsed = nil;
573 EQL3_QuestLogCollapseAllButton:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up");
574 else
575 EQL3_QuestLogCollapseAllButton.collapsed = 1;
576 EQL3_QuestLogCollapseAllButton:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up");
577 end
578  
579 -- Update Quest Count
580 EQL3_QuestLogQuestCount:SetText(format(QUEST_LOG_COUNT_TEMPLATE, numQuests, MAX_QUESTLOG_QUESTS));
581 EQL3_QuestLogCountMiddle:SetWidth(EQL3_QuestLogQuestCount:GetWidth());
582  
583 -- If no selection then set it to the first available quest
584 if ( GetQuestLogSelection() == 0 ) then
585 QuestLog_SetFirstValidSelection();
586 end
587  
588 -- Determine whether the selected quest is pushable or not
589 if ( numEntries == 0 ) then
590 EQL3_QuestFramePushQuestButton:Disable();
591 elseif ( GetQuestLogPushable() and GetNumPartyMembers() > 0 ) then
592 EQL3_QuestFramePushQuestButton:Enable();
593 else
594 EQL3_QuestFramePushQuestButton:Disable();
595 end
596 end
597  
598  
599  
600 local normal_QuestLog_SetSelection = QuestLog_SetSelection;
601  
602 function QuestLog_SetSelection(questID)
603 local selectedQuest;
604 if ( questID == 0 ) then
605 EQL3_QuestLogDetailScrollFrame:Hide();
606 return 0;
607 end
608  
609 -- Get xml id
610 local id = questID - FauxScrollFrame_GetOffset(EQL3_QuestLogListScrollFrame);
611  
612 SelectQuestLogEntry(questID);
613 local titleButton = getglobal("EQL3_QuestLogTitle"..id);
614 local titleButtonTag = getglobal("EQL3_QuestLogTitle"..id.."Tag");
615  
616 local questLogTitleText, level, questTag, isHeader, isCollapsed = GetQuestLogTitle(questID);
617 if ( isHeader ) then
618 if ( isCollapsed ) then
619 ExpandQuestHeader(questID);
620 MakeQuestHeaderList();
621 return 0;
622 else
623 CollapseQuestHeader(questID);
624 MakeQuestHeaderList();
625 return 0;
626 end
627 else
628 -- Set newly selected quest and highlight it
629 EQL3_QuestLogFrame.selectedButtonID = questID;
630 local scrollFrameOffset = FauxScrollFrame_GetOffset(EQL3_QuestLogListScrollFrame);
631 if ( questID > scrollFrameOffset and questID <= (scrollFrameOffset + EQL3_QUESTS_DISPLAYED) and questID <= GetNumQuestLogEntries() ) then
632 titleButton:LockHighlight();
633 titleButtonTag:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
634  
635 EQL3_QuestLogSkillHighlight:SetVertexColor(titleButton.r, titleButton.g, titleButton.b);
636 EQL3_QuestLogHighlightFrame:SetPoint("TOPLEFT", "EQL3_QuestLogTitle"..id, "TOPLEFT", 5, 0);
637 EQL3_QuestLogHighlightFrame:Show();
638 end
639 end
640 if ( GetQuestLogSelection() > GetNumQuestLogEntries() ) then
641 return 0;
642 end
643 QuestLog_UpdateQuestDetails();
644 return 1;
645 end
646  
647  
648 local normal_QuestLog_UpdateQuestDetails = QuestLog_UpdateQuestDetails;
649  
650 function QuestLog_UpdateQuestDetails(doNotScroll)
651 local questID = GetQuestLogSelection();
652 local questTitle = GetQuestLogTitle(questID);
653 if ( not questTitle ) then
654 questTitle = "";
655 end
656 if ( IsCurrentQuestFailed() ) then
657 questTitle = questTitle.." - ("..TEXT(FAILED)..")";
658 end
659 EQL3_QuestLogQuestTitle:SetText(questTitle);
660  
661 local questDescription;
662 local questObjectives;
663 questDescription, questObjectives = GetQuestLogQuestText();
664 EQL3_QuestLogObjectivesText:SetText(questObjectives);
665  
666 local questTimer = GetQuestLogTimeLeft();
667 if ( questTimer ) then
668 EQL3_QuestLogFrame.hasTimer = 1;
669 EQL3_QuestLogFrame.timePassed = 0;
670 EQL3_QuestLogTimerText:Show();
671 EQL3_QuestLogTimerText:SetText(TEXT(TIME_REMAINING).." "..SecondsToTime(questTimer));
672 EQL3_QuestLogObjective1:SetPoint("TOPLEFT", "EQL3_QuestLogTimerText", "BOTTOMLEFT", 0, -10);
673 else
674 EQL3_QuestLogFrame.hasTimer = nil;
675 EQL3_QuestLogTimerText:Hide();
676 EQL3_QuestLogObjective1:SetPoint("TOPLEFT", "EQL3_QuestLogObjectivesText", "BOTTOMLEFT", 0, -10);
677 end
678  
679 -- Show Quest Watch if track quest is checked
680 local numObjectives = GetNumQuestLeaderBoards();
681  
682 for i=1, numObjectives, 1 do
683 local string = getglobal("EQL3_QuestLogObjective"..i);
684 local text;
685 local type;
686 local finished;
687 text, type, finished = GetQuestLogLeaderBoard(i);
688 if ( not text or strlen(text) == 0 ) then
689 text = type;
690 end
691 if ( finished ) then
692 string:SetTextColor(0.2, 0.2, 0.2);
693 text = text.." ("..TEXT(COMPLETE)..")";
694 else
695 string:SetTextColor(0, 0, 0);
696 end
697 string:SetText(text);
698 string:Show();
699 QuestFrame_SetAsLastShown(string);
700 end
701  
702 for i=numObjectives + 1, MAX_OBJECTIVES, 1 do
703 getglobal("EQL3_QuestLogObjective"..i):Hide();
704 end
705  
706 -- If there's money required then anchor and display it
707 if ( GetQuestLogRequiredMoney() > 0 ) then
708 if ( numObjectives > 0 ) then
709 EQL3_QuestLogRequiredMoneyText:SetPoint("TOPLEFT", "EQL3_QuestLogObjective"..numObjectives, "BOTTOMLEFT", 0, -4);
710 else
711 EQL3_QuestLogRequiredMoneyText:SetPoint("TOPLEFT", "EQL3_QuestLogObjectivesText", "BOTTOMLEFT", 0, -10);
712 end
713  
714 MoneyFrame_Update("EQL3_QuestLogRequiredMoneyFrame", GetQuestLogRequiredMoney());
715  
716 if ( GetQuestLogRequiredMoney() > GetMoney() ) then
717 -- Not enough money
718 EQL3_QuestLogRequiredMoneyText:SetTextColor(0, 0, 0);
719 SetMoneyFrameColor("EQL3_QuestLogRequiredMoneyFrame", 1.0, 0.1, 0.1);
720 else
721 EQL3_QuestLogRequiredMoneyText:SetTextColor(0.2, 0.2, 0.2);
722 SetMoneyFrameColor("EQL3_QuestLogRequiredMoneyFrame", 1.0, 1.0, 1.0);
723 end
724 EQL3_QuestLogRequiredMoneyText:Show();
725 EQL3_QuestLogRequiredMoneyFrame:Show();
726 else
727 EQL3_QuestLogRequiredMoneyText:Hide();
728 EQL3_QuestLogRequiredMoneyFrame:Hide();
729 end
730  
731 if ( GetQuestLogRequiredMoney() > 0 ) then
732 EQL3_QuestLogDescriptionTitle:SetPoint("TOPLEFT", "EQL3_QuestLogRequiredMoneyText", "BOTTOMLEFT", 0, -10);
733 elseif ( numObjectives > 0 ) then
734 EQL3_QuestLogDescriptionTitle:SetPoint("TOPLEFT", "EQL3_QuestLogObjective"..numObjectives, "BOTTOMLEFT", 0, -10);
735 else
736 if ( questTimer ) then
737 EQL3_QuestLogDescriptionTitle:SetPoint("TOPLEFT", "EQL3_QuestLogTimerText", "BOTTOMLEFT", 0, -10);
738 else
739 EQL3_QuestLogDescriptionTitle:SetPoint("TOPLEFT", "EQL3_QuestLogObjectivesText", "BOTTOMLEFT", 0, -10);
740 end
741 end
742 if ( questDescription ) then
743 EQL3_QuestLogQuestDescription:SetText(questDescription);
744 QuestFrame_SetAsLastShown(EQL3_QuestLogQuestDescription);
745 end
746 local numRewards = GetNumQuestLogRewards();
747 local numChoices = GetNumQuestLogChoices();
748 local money = GetQuestLogRewardMoney();
749  
750 if ( (numRewards + numChoices + money) > 0 ) then
751 EQL3_QuestLogRewardTitleText:Show();
752 QuestFrame_SetAsLastShown(EQL3_QuestLogRewardTitleText);
753 else
754 EQL3_QuestLogRewardTitleText:Hide();
755 end
756  
757 QuestFrameItems_Update("QuestLog");
758 if ( not doNotScroll ) then
759 EQL3_QuestLogDetailScrollFrameScrollBar:SetValue(0);
760 end
761 EQL3_QuestLogDetailScrollFrame:UpdateScrollChildRect();
762 end
763  
764  
765  
766 local normal_QuestFrame_SetAsLastShown = QuestFrame_SetAsLastShown;
767 function QuestFrame_SetAsLastShown(frame, spacerFrame)
768 if ( not spacerFrame ) then
769 spacerFrame = EQL3_QuestLogSpacerFrame;
770 end
771 spacerFrame:SetPoint("TOP", frame, "BOTTOM", 0, 0);
772 end
773  
774  
775  
776 local normal_QuestLogTitleButton_OnClick = QuestLogTitleButton_OnClick;
777 function QuestLogTitleButton_OnClick(button)
778 local questName = this:GetText();
779 local questIndex = this:GetID() + FauxScrollFrame_GetOffset(EQL3_QuestLogListScrollFrame);
780  
781 if(button == "LeftButton") then
782 if ( IsShiftKeyDown() ) then
783 if( IsControlKeyDown() ) then
784 if ( this.isHeader ) then
785 return;
786 end
787 if ( not ChatFrameEditBox:IsVisible() ) then
788 EQL3_ClearTracker();
789 AddQuestWatch(questIndex);
790 QuestWatch_Update();
791 end
792 else
793 -- If header then return
794 local questLogTitleText, isHeader, isCollapsed, firstTrackable, lastTrackable, numTracked, numUntracked;
795 lastTrackable = -1;
796 numTracked = 0;
797 numUntracked = 0;
798 local track = false;
799 if ( this.isHeader ) then
800  
801 for i=1, GetNumQuestLogEntries(), 1 do
802 questLogTitleText, _, _, isHeader, isCollapsed, _ = GetQuestLogTitle(i);
803 if ( questLogTitleText == questName ) then
804 track = true;
805 firstTrackable = i+1;
806 elseif ( track ) then
807 if ( not isHeader ) then
808 if( IsQuestWatched(i) ) then
809 numTracked = numTracked+1;
810 RemoveQuestWatch(i);
811 else
812 numUntracked = numUntracked+1;
813 RemoveQuestWatch(i);
814 end;
815 end
816 if ( isHeader and questLogTitleText ~= questName ) then
817 lastTrackable = i-1;
818 break;
819 end
820 end
821 end
822 if ( lastTrackable == -1 ) then
823 lastTrackable = GetNumQuestLogEntries();
824 end
825 if ( numUntracked == 0 ) then
826 -- Untrack all
827 for i=firstTrackable, lastTrackable, 1 do
828 RemoveQuestWatch(i);
829 end
830 QuestWatch_Update();
831 else
832 -- Track all
833 for i=firstTrackable, lastTrackable, 1 do
834 AddQuestWatch(i);
835 end
836 QuestWatch_Update();
837 end
838 QuestLog_Update();
839 return;
840 end
841  
842 -- Otherwise try to track it or put it into chat
843 if ( ChatFrameEditBox:IsVisible() ) then
844 -- Trim leading whitespace
845 ChatFrameEditBox:Insert(gsub(this:GetText(), " *(.*)", "%1"));
846 else
847 -- Shift-click toggles quest-watch on this quest.
848 if ( IsQuestWatched(questIndex) ) then
849 RemoveQuestWatch(questIndex);
850 QuestWatch_Update();
851 else
852 --[[ Set error if no objectives
853 if ( GetNumQuestLeaderBoards(questIndex) == 0 ) then
854 UIErrorsFrame:AddMessage(QUEST_WATCH_NO_OBJECTIVES, 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME);
855 return;
856 end]]--
857 -- Set an error message if trying to show too many quests
858 if ( GetNumQuestWatches() >= MAX_WATCHABLE_QUESTS ) then
859 UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, MAX_WATCHABLE_QUESTS), 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME);
860 return;
861 end
862 AddQuestWatch(questIndex);
863 QuestWatch_Update();
864 end
865 end
866 end
867 end
868  
869 if(this.isHeader) then
870 if ( EQL3_OrganizeFrame:IsVisible() ) then
871 EQL3_OrganizeFrame_Text:SetText(questName);
872 EQL3_OrganizeFrame_Text:ClearFocus();
873  
874 EQL3_OrganizeFunctions(questName);
875 EQL3_OrganizeFrame:Hide();
876 end
877 end
878  
879 end
880  
881 if(QuestLog_SetSelection(questIndex) == 1) then
882 if(not EQL3_QuestLogFrame_Description:IsVisible() and not IsShiftKeyDown() and not IsControlKeyDown() and QuestlogOptions[EQL3_Player].RestoreUponSelect == 1) then
883 EQL3_Maximize();
884 end
885 end
886  
887  
888 if(button == "LeftButton") then
889 if( not IsShiftKeyDown() and IsControlKeyDown() ) then
890 if ( ChatFrameEditBox:IsVisible() ) then
891 AddQuestStatusToChatFrame(questIndex, questName);
892 end
893 end
894 else
895 if ( not this.isHeader ) then
896 if ( EQL3_IsQuestWatched(questIndex) ) then
897 EQL3_Organize_Popup_Track_Text:SetText(EQL3_POPUP_UNTRACK);
898 else
899 EQL3_Organize_Popup_Track_Text:SetText(EQL3_POPUP_TRACK);
900 end
901 EQL3_Organize_Popup:ClearAllPoints();
902 EQL3_Organize_Popup:SetPoint("TOPLEFT", this, "TOPLEFT", 24, 0);
903 EQL3_Organize_Popup:Raise();
904 EQL3_Organize_Popup:Show();
905 end
906 end
907  
908 QuestLog_Update();
909 end
910  
911  
912 function AddQuestStatusToChatFrame(questIndex, questName)
913 local text, type, finished;
914 if ( ChatFrameEditBox:IsVisible() ) then
915 local questLogTitleText, level, questTag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questIndex);
916  
917 if(isComplete) then
918 ChatFrameEditBox:Insert("(Complete) ");
919 end
920  
921 ChatFrameEditBox:Insert(questLogTitleText);
922  
923 local numObjectives = GetNumQuestLeaderBoards();
924 if (numObjectives>0) then
925 ChatFrameEditBox:Insert(": ");
926 for i=1, numObjectives, 1 do
927 text, type, finished = GetQuestLogLeaderBoard(i);
928 if(not text or strlen(text) == 0) then
929 text = type;
930 end
931 ChatFrameEditBox:Insert(text);
932 if(i < numObjectives) then
933 ChatFrameEditBox:Insert(", ");
934 end
935 end
936 end
937 end
938 end
939  
940  
941 -- Only called on load
942 function ManageQuestHeaders()
943 QuestLog_SetSelection(GetQuestLogSelection());
944 EQL3_Temp.hasManaged = true;
945 if(QuestlogOptions[EQL3_Player].HeaderList) then
946  
947 local questLogTitleText, isHeader, isCollapsed;
948 local numHeaders = table.getn(QuestlogOptions[EQL3_Player].HeaderList);
949 local numEntries = GetNumQuestLogEntries();
950  
951 if(numHeaders > 0) then
952  
953 for i=numEntries, 1, -1 do
954 questLogTitleText, _, _, isHeader, isCollapsed = GetQuestLogTitle(i);
955  
956 if(isHeader) then
957 for j=1, numHeaders, 1 do
958 if(questLogTitleText == QuestlogOptions[EQL3_Player].HeaderList[j]) then
959 CollapseQuestHeader(i);
960 end
961 end
962 end
963  
964 end
965  
966 end
967 end
968 end
969  
970 function MakeQuestHeaderList()
971 QuestlogOptions[EQL3_Player].HeaderList = {};
972  
973 local numEntries = GetNumQuestLogEntries();
974 local questLogTitleText, isHeader, isCollapsed;
975  
976 for j=numEntries, 1, -1 do
977 questLogTitleText, _, _, isHeader, isCollapsed = GetQuestLogTitle(j);
978 if (isHeader and isCollapsed) then
979 table.insert(QuestlogOptions[EQL3_Player].HeaderList, questLogTitleText);
980 end
981 end
982 end
983  
984  
985  
986  
987 local normal_QuestLog_UpdatePartyInfoTooltip = QuestLog_UpdatePartyInfoTooltip;
988  
989 function QuestLog_UpdatePartyInfoTooltip()
990 local index = this:GetID() + FauxScrollFrame_GetOffset(EQL3_QuestLogListScrollFrame);
991 local numPartyMembers = GetNumPartyMembers();
992 if ( numPartyMembers == 0 or this.isHeader ) then
993 return;
994 end
995 GameTooltip_SetDefaultAnchor(GameTooltip, this);
996  
997 local questLogTitleText = GetQuestLogTitle(index);
998 GameTooltip:SetText(questLogTitleText);
999  
1000 local partyMemberOnQuest;
1001 for i=1, numPartyMembers do
1002 if ( IsUnitOnQuest(index, "party"..i) ) then
1003 if ( not partyMemberOnQuest ) then
1004 GameTooltip:AddLine(HIGHLIGHT_FONT_COLOR_CODE..PARTY_QUEST_STATUS_ON..FONT_COLOR_CODE_CLOSE);
1005 partyMemberOnQuest = 1;
1006 end
1007 GameTooltip:AddLine(LIGHTYELLOW_FONT_COLOR_CODE..UnitName("party"..i)..FONT_COLOR_CODE_CLOSE);
1008 end
1009 end
1010 if ( not partyMemberOnQuest ) then
1011 GameTooltip:AddLine(HIGHLIGHT_FONT_COLOR_CODE..PARTY_QUEST_STATUS_NONE..FONT_COLOR_CODE_CLOSE);
1012 end
1013 GameTooltip:Show();
1014 end
1015  
1016  
1017 local normal_QuestLogCollapseAllButton_OnClick = QuestLogCollapseAllButton_OnClick;
1018 function QuestLogCollapseAllButton_OnClick()
1019 if (this.collapsed) then
1020 this.collapsed = nil;
1021 ExpandQuestHeader(0);
1022 MakeQuestHeaderList();
1023 else
1024 this.collapsed = 1;
1025 EQL3_QuestLogListScrollFrameScrollBar:SetValue(0);
1026 CollapseQuestHeader(0);
1027 MakeQuestHeaderList();
1028 end
1029 end
1030  
1031  
1032 old_GetQuestLogTitle = GetQuestLogTitle;
1033 function GetQuestLogTitle(questIndex)
1034 local questLogTitleText, level, questTag, isHeader, isCollapsed, isComplete;
1035  
1036  
1037 if (not EQL3_UpdateDB()) then
1038 questLogTitleText, level, questTag, isHeader, isCollapsed, isComplete = old_GetQuestLogTitle(questIndex);
1039 end
1040 if(EQL3_Temp.savedQuestIDMap and EQL3_Temp.savedQuestIDMap[questIndex]) then
1041 if(EQL3_Temp.savedQuestIDMap[questIndex].questID) then
1042 questLogTitleText, level, questTag, isHeader, isCollapsed, isComplete = old_GetQuestLogTitle(EQL3_Temp.savedQuestIDMap[questIndex].questID);
1043 else
1044 return EQL3_Temp.savedQuestIDMap[questIndex].header, 0, nil, true, nil, nil;
1045 end
1046 end
1047  
1048 if ( isHeader or not questLogTitleText ) then
1049 else
1050 if ( not QuestLevel_Quest2Level[questLogTitleText] ) then
1051 local queststorage = "";
1052 queststorage = QuestLevel_StorageSet(queststorage, "levelmin", level);
1053 if (questTag ~= NIL) then
1054 queststorage = QuestLevel_StorageSet(queststorage, "elite", "x");
1055 end
1056 QuestLevel_Quest2Level[questLogTitleText] = queststorage;
1057 else
1058 local queststorage = QuestLevel_Quest2Level[questLogTitleText];
1059 local levelmin = tonumber(QuestLevel_StorageGet(queststorage, "levelmin"));
1060 local levelmax = QuestLevel_StorageGet(queststorage, "levelmax");
1061 if ( levelmax == nil ) then
1062 levelmax = levelmin;
1063 else
1064 levelmax = tonumber(levelmax);
1065 end
1066 if (levelmin > level) then
1067 queststorage = QuestLevel_StorageSet(queststorage, "levelmin", level);
1068 queststorage = QuestLevel_StorageSet(queststorage, "levelmax", levelmax);
1069 end
1070 if (levelmax < level) then
1071 queststorage = QuestLevel_StorageSet(queststorage, "levelmax", level);
1072 end
1073 if (questTag ~= NIL and QuestLevel_StorageGet(queststorage, "elite") == nil) then
1074 queststorage = QuestLevel_StorageSet(queststorage, "elite", "");
1075 end
1076 QuestLevel_Quest2Level[questLogTitleText] = queststorage;
1077 end
1078 end
1079  
1080 return questLogTitleText, level, questTag, isHeader, isCollapsed, isComplete;
1081 end
1082  
1083  
1084  
1085  
1086 local old_QuestFrameItems_Update = QuestFrameItems_Update;
1087 function QuestFrameItems_Update(questState)
1088 local isQuestLog = 0;
1089 if ( questState == "QuestLog" ) then
1090 isQuestLog = 1;
1091 questState = "EQL3_QuestLog";
1092 end
1093 local numQuestRewards;
1094 local numQuestChoices;
1095 local numQuestSpellRewards = 0;
1096 local money;
1097 local spacerFrame;
1098 if ( isQuestLog == 1 ) then
1099 numQuestRewards = GetNumQuestLogRewards();
1100 numQuestChoices = GetNumQuestLogChoices();
1101 if ( GetQuestLogRewardSpell() ) then
1102 numQuestSpellRewards = 1;
1103 end
1104 money = GetQuestLogRewardMoney();
1105 spacerFrame = EQL3_QuestLogSpacerFrame;
1106 else
1107 numQuestRewards = GetNumQuestRewards();
1108 numQuestChoices = GetNumQuestChoices();
1109 if ( GetRewardSpell() ) then
1110 numQuestSpellRewards = 1;
1111 end
1112 money = GetRewardMoney();
1113 spacerFrame = QuestSpacerFrame;
1114 end
1115  
1116 local totalRewards = numQuestRewards + numQuestChoices + numQuestSpellRewards;
1117 local questItemName = questState.."Item";
1118 local material = QuestFrame_GetMaterial();
1119 local questItemReceiveText = getglobal(questState.."ItemReceiveText")
1120 if ( totalRewards == 0 and money == 0 ) then
1121 getglobal(questState.."RewardTitleText"):Hide();
1122 else
1123 getglobal(questState.."RewardTitleText"):Show();
1124 QuestFrame_SetTitleTextColor(getglobal(questState.."RewardTitleText"), material);
1125 QuestFrame_SetAsLastShown(getglobal(questState.."RewardTitleText"), spacerFrame);
1126 end
1127 if ( money == 0 ) then
1128 getglobal(questState.."MoneyFrame"):Hide();
1129 else
1130 getglobal(questState.."MoneyFrame"):Show();
1131 QuestFrame_SetAsLastShown(getglobal(questState.."MoneyFrame"), spacerFrame);
1132 MoneyFrame_Update(questState.."MoneyFrame", money);
1133 end
1134  
1135 for i=totalRewards + 1, MAX_NUM_ITEMS, 1 do
1136 getglobal(questItemName..i):Hide();
1137 end
1138 local questItem, name, texture, quality, isUsable, numItems = 1;
1139 if ( numQuestChoices > 0 ) then
1140 getglobal(questState.."ItemChooseText"):Show();
1141 QuestFrame_SetTextColor(getglobal(questState.."ItemChooseText"), material);
1142 QuestFrame_SetAsLastShown(getglobal(questState.."ItemChooseText"), spacerFrame);
1143 for i=1, numQuestChoices, 1 do
1144 questItem = getglobal(questItemName..i);
1145 questItem.type = "choice";
1146 numItems = 1;
1147 if ( isQuestLog == 1 ) then
1148 name, texture, numItems, quality, isUsable = GetQuestLogChoiceInfo(i);
1149 else
1150 name, texture, numItems, quality, isUsable = GetQuestItemInfo(questItem.type, i);
1151 end
1152 questItem:SetID(i)
1153 questItem:Show();
1154 -- For the tooltip
1155 questItem.rewardType = "item"
1156 QuestFrame_SetAsLastShown(questItem, spacerFrame);
1157 getglobal(questItemName..i.."Name"):SetText(name);
1158 SetItemButtonCount(questItem, numItems);
1159 SetItemButtonTexture(questItem, texture);
1160 if ( isUsable ) then
1161 SetItemButtonTextureVertexColor(questItem, 1.0, 1.0, 1.0);
1162 SetItemButtonNameFrameVertexColor(questItem, 1.0, 1.0, 1.0);
1163 else
1164 SetItemButtonTextureVertexColor(questItem, 0.9, 0, 0);
1165 SetItemButtonNameFrameVertexColor(questItem, 0.9, 0, 0);
1166 end
1167 if ( i > 1 ) then
1168 if ( mod(i,2) == 1 ) then
1169 questItem:SetPoint("TOPLEFT", questItemName..(i - 2), "BOTTOMLEFT", 0, -2);
1170 else
1171 questItem:SetPoint("TOPLEFT", questItemName..(i - 1), "TOPRIGHT", 1, 0);
1172 end
1173 else
1174 questItem:SetPoint("TOPLEFT", questState.."ItemChooseText", "BOTTOMLEFT", -3, -5);
1175 end
1176  
1177 end
1178 else
1179 getglobal(questState.."ItemChooseText"):Hide();
1180 end
1181 local rewardsCount = 0;
1182 if ( numQuestRewards > 0 or money > 0 or numQuestSpellRewards > 0) then
1183 QuestFrame_SetTextColor(questItemReceiveText, material);
1184 -- Anchor the reward text differently if there are choosable rewards
1185 if ( numQuestChoices > 0 ) then
1186 questItemReceiveText:SetText(TEXT(REWARD_ITEMS));
1187 local index = numQuestChoices;
1188 if ( mod(index, 2) == 0 ) then
1189 index = index - 1;
1190 end
1191 questItemReceiveText:SetPoint("TOPLEFT", questItemName..index, "BOTTOMLEFT", 3, -5);
1192 else
1193 questItemReceiveText:SetText(TEXT(REWARD_ITEMS_ONLY));
1194 questItemReceiveText:SetPoint("TOPLEFT", questState.."RewardTitleText", "BOTTOMLEFT", 3, -5);
1195 end
1196 questItemReceiveText:Show();
1197 QuestFrame_SetAsLastShown(questItemReceiveText, spacerFrame);
1198 -- Setup mandatory rewards
1199 for i=1, numQuestRewards, 1 do
1200 questItem = getglobal(questItemName..(i + numQuestChoices));
1201 questItem.type = "reward";
1202 numItems = 1;
1203 if ( isQuestLog == 1 ) then
1204 name, texture, numItems, quality, isUsable = GetQuestLogRewardInfo(i);
1205 else
1206 name, texture, numItems, quality, isUsable = GetQuestItemInfo(questItem.type, i);
1207 end
1208 questItem:SetID(i)
1209 questItem:Show();
1210 -- For the tooltip
1211 questItem.rewardType = "item";
1212 QuestFrame_SetAsLastShown(questItem, spacerFrame);
1213 getglobal(questItemName..(i + numQuestChoices).."Name"):SetText(name);
1214 SetItemButtonCount(questItem, numItems);
1215 SetItemButtonTexture(questItem, texture);
1216 if ( isUsable ) then
1217 SetItemButtonTextureVertexColor(questItem, 1.0, 1.0, 1.0);
1218 SetItemButtonNameFrameVertexColor(questItem, 1.0, 1.0, 1.0);
1219 else
1220 SetItemButtonTextureVertexColor(questItem, 0.5, 0, 0);
1221 SetItemButtonNameFrameVertexColor(questItem, 1.0, 0, 0);
1222 end
1223  
1224 if ( i > 1 ) then
1225 if ( mod(i,2) == 1 ) then
1226 questItem:SetPoint("TOPLEFT", questItemName..((i + numQuestChoices) - 2), "BOTTOMLEFT", 0, -2);
1227 else
1228 questItem:SetPoint("TOPLEFT", questItemName..((i + numQuestChoices) - 1), "TOPRIGHT", 1, 0);
1229 end
1230 else
1231 questItem:SetPoint("TOPLEFT", questState.."ItemReceiveText", "BOTTOMLEFT", -3, -5);
1232 end
1233 rewardsCount = rewardsCount + 1;
1234 end
1235 -- Setup spell reward
1236 if ( numQuestSpellRewards > 0 ) then
1237 if ( isQuestLog == 1 ) then
1238 texture, name = GetQuestLogRewardSpell();
1239 else
1240 texture, name = GetRewardSpell();
1241 end
1242 questItem = getglobal(questItemName..(rewardsCount + numQuestChoices + 1));
1243 questItem:Show();
1244 -- For the tooltip
1245 questItem.rewardType = "spell";
1246 SetItemButtonCount(questItem, 0);
1247 SetItemButtonTexture(questItem, texture);
1248 getglobal(questItemName..(rewardsCount + numQuestChoices + 1).."Name"):SetText(name);
1249 if ( rewardsCount > 0 ) then
1250 if ( mod(rewardsCount,2) == 0 ) then
1251 questItem:SetPoint("TOPLEFT", questItemName..((rewardsCount + numQuestChoices) - 1), "BOTTOMLEFT", 0, -2);
1252 else
1253 questItem:SetPoint("TOPLEFT", questItemName..((rewardsCount + numQuestChoices)), "TOPRIGHT", 1, 0);
1254 end
1255 else
1256 questItem:SetPoint("TOPLEFT", questState.."ItemReceiveText", "BOTTOMLEFT", -3, -5);
1257 end
1258 end
1259 else
1260 questItemReceiveText:Hide();
1261 end
1262 if ( questState == "QuestReward" ) then
1263 QuestFrameCompleteQuestButton:Enable();
1264 QuestFrameRewardPanel.itemChoice = 0;
1265 QuestRewardItemHighlight:Hide();
1266 end
1267 end
1268  
1269  
1270 function QuestLogFrame_LockCorner()
1271 local Left = EQL3_QuestLogFrame:GetLeft();
1272 local Top = EQL3_QuestLogFrame:GetTop();
1273 if (Left and Top) then
1274 EQL3_QuestLogFrame:ClearAllPoints();
1275 EQL3_QuestLogFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", Left , Top);
1276 QuestlogOptions[EQL3_Player].LogLockPoints = {};
1277 QuestlogOptions[EQL3_Player].LogLockPoints.pointone = Left;
1278 QuestlogOptions[EQL3_Player].LogLockPoints.pointtwo = Top;
1279 elseif (QuestlogOptions[EQL3_Player].LogLockPoints and
1280 QuestlogOptions[EQL3_Player].LogLockPoints.pointone and
1281 QuestlogOptions[EQL3_Player].LogLockPoints.pointtwo) then
1282 EQL3_QuestLogFrame:ClearAllPoints();
1283 EQL3_QuestLogFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", QuestlogOptions[EQL3_Player].LogLockPoints.pointone,QuestlogOptions[EQL3_Player].LogLockPoints.pointtwo);
1284 end
1285 end
1286  
1287  
1288  
1289 function LookForCompletedQuests(ding)
1290 if ( not QuestlogOptions[EQL3_Player].CompletedQuests ) then
1291 QuestlogOptions[EQL3_Player].CompletedQuests = {};
1292 end
1293  
1294 local questID;
1295 local numEntries = GetNumQuestLogEntries();
1296 local questTitle, isComplete, isHeader;
1297  
1298 for i=1, numEntries, 1 do
1299 questID = i;
1300 questTitle, _, _, isHeader, _, isComplete = GetQuestLogTitle(questID);
1301  
1302 if(QuestlogOptions[EQL3_Player].CompletedQuests[questTitle]) then
1303 QuestlogOptions[EQL3_Player].CompletedQuests[questTitle].isOk = true;
1304 else
1305 QuestlogOptions[EQL3_Player].CompletedQuests[questTitle] = {};
1306 QuestlogOptions[EQL3_Player].CompletedQuests[questTitle].isOk = true;
1307 end
1308  
1309 if ( (not isHeader) and isComplete and ( not QuestlogOptions[EQL3_Player].CompletedQuests[questTitle].isCompleted ) ) then
1310 QuestlogOptions[EQL3_Player].CompletedQuests[questTitle].isCompleted = true;
1311 if( (ding == nil) or (ding~=false)) then
1312 UIErrorsFrame:AddMessage(questTitle.." Completed!", 1.0, 0.8, 0.0, 1.0, UIERRORS_HOLD_TIME);
1313 PlaySound("GnomeExploration");
1314 end
1315 end
1316 end
1317  
1318 --clean up
1319 for quest in QuestlogOptions[EQL3_Player].CompletedQuests do
1320 if ( QuestlogOptions[EQL3_Player].CompletedQuests[quest].isOk ) then
1321 QuestlogOptions[EQL3_Player].CompletedQuests[quest].isOk = false;
1322 else
1323 QuestlogOptions[EQL3_Player].CompletedQuests[quest] = nil;
1324 end
1325 end
1326 end