vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- FastQuest 2.11 By Vashen ( Vashen@msn.com )
2 -- http://www.curse-gaming.com/mod.php?addid=812
3  
4 hQuestLog_Update = QuestLog_Update;
5 hQuestWatch_Update = QuestWatch_Update;
6  
7 local player = "DEFAULT";
8 local Formats = {};
9 Formats[0]="QuestName";
10 Formats[1]="[QuestLevel] QuestName";
11 Formats[2]="[QuestLevel+] QuestName";
12 Formats[3]="[QuestLevel] QuestName (Tag)";
13 local nFormats = 4;
14  
15  
16 function FastQuest_OnLoad()
17 this:RegisterEvent("VARIABLES_LOADED");
18 this:RegisterEvent("UI_INFO_MESSAGE");
19 this:RegisterEvent("QUEST_PROGRESS");
20 this:RegisterEvent("QUEST_COMPLETE");
21 SLASH_FQ1 = "/fastquest";
22 SLASH_FQ2 = "/fq";
23 SlashCmdList["FQ"] = FastQuest_SlashCmd;
24 qOut("|cff00ffffFastQuest 2.11 By Vashen is now loaded. |cffffffff/fq");
25 end
26  
27 function FastQuest_SlashCmd(msg)
28 if (msg) then
29 local cmd = gsub(msg, "%s*([^%s]+).*", "%1");
30 local info ="|cff00ffffFastQuest: |r|cffffffff";
31 if( cmd == "tag" ) then
32 info = (info.."Display of quest-tags has been ");
33 FQD[player].Tag=FastQuest_ToggleBoolean(FQD[player].Tag,info);
34 QuestLog_Update();
35 QuestWatch_Update();
36 return;
37 elseif( cmd == "autoadd" ) then
38 info = (info.."Automatic addition of changed quests to QuestTracker has been ");
39 FQD.AutoAdd=FastQuest_ToggleBoolean(FQD.AutoAdd,info);
40 return;
41 elseif( cmd == "autonotify" ) then
42 info = (info.."Automatic notification of party members regarding your quest progress has been ");
43 FQD.AutoNotify=FastQuest_ToggleBoolean(FQD.AutoNotify,info);
44 return;
45 elseif( cmd == "autocomplete" ) then
46 info = (info.."Automatic quest completion has been ");
47 FQD.AutoComplete=FastQuest_ToggleBoolean(FQD.AutoComplete,info);
48 return;
49 elseif( cmd == "lock" and FQD.NoDrag==false)then
50 qOut(info.." Movable components have been Locked");
51 FQD.Lock = true;
52 FastQuest_LockMovableParts();
53 return;
54 elseif( cmd == "unlock" and FQD.NoDrag==false)then
55 qOut(info.." Movable components have been Unlocked");
56 FQD.Lock = false;
57 FastQuest_LockMovableParts();
58 return;
59 elseif( cmd == "nodrag") then
60 info = (info.." Dragging is now ");
61 FQD.NoDrag=FastQuest_ToggleBoolean(FQD.NoDrag,info);
62 if (FQD.NoDrag == false ) then FQD.Lock = true;end
63 qOut("You must reload UI for this change to apply. Type /console reloadui");
64 return;
65 elseif( cmd == "reset" and FQD.NoDrag==false)then
66 qOut(info.." Movable components have been Reset");
67 FastQuestFrame:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", -20, -15);
68 dQuestWatchDragButton:SetPoint("TOPLEFT", "UIParent", "TOPRIGHT", -250, -250);
69 return;
70 elseif( cmd == "format" )then
71 if (FQD[player].Format==nil) then FQD[player].Format=1;end
72 if (FQD[player].Format==(nFormats-1)) then
73 FQD[player].Format=0;
74 else
75 FQD[player].Format=FQD[player].Format+1;
76 end
77 qOut(info.."Toggle beetween output formats ");
78 qOut("Selected format: "..Formats[FQD[player].Format]);
79 return;
80 elseif( cmd == "clear" ) then
81 qOut(info.."All quest tracker quests have been removed ");
82 for i = GetNumQuestWatches(), 1 , -1 do
83 local qID = GetQuestIndexForWatch(i)
84 FQD[player].tQuests[i] = " ";
85 RemoveQuestWatch(qID);
86 end
87 FQD[player].nQuests = 0;
88 QuestWatch_Update();
89 return;
90 end
91 qOut(info.."usage /fastquest [command] or /fq [command]");
92 qOut("|cffffffff/fq tag - Toggle display of quest tags (elite, raid,etc) ");
93 qOut("|cffffffff/fq lock(unlock) - Locks/Unlocks quest tracker window");
94 qOut("|cffffffff/fq nodrag - Toggle dragging of quest tracker, you must reload UI to apply");
95 qOut("|cffffffff/fq reset - Resets FastQuest moving components, draging must be enabled");
96 qOut("|cffffffff/fq autoadd - Toggle automatic addition of changed quests to QuestTracker");
97 qOut("|cffffffff/fq autonotify - Toggle automatic notification of party members");
98 qOut("|cffffffff/fq autocomplete - Toggle automatic completion of quests when turning them in");
99 qOut("|cffffffff/fq clear - Clear QuestTracker window from all quests");
100 qOut(info.."New version: http://www.curse-gaming.com/mod.php?addid=812");
101 end
102 end
103  
104 function FastQuest_OnEvent(event, message)
105 if ((event == "QUEST_PROGRESS") and (FQD.AutoComplete==true)) then
106 CompleteQuest();
107 elseif ((event == "QUEST_COMPLETE") and (FQD.AutoComplete==true)) then
108 if (GetNumQuestChoices() == 0) then
109 GetQuestReward(QuestFrameRewardPanel.itemChoice);
110 end
111 elseif(event == "VARIABLES_LOADED") then
112 if (FQD == nil) then FQD = {};end
113 if (FQD.Lock == nil) then FQD.Lock=true; end
114 if (FQD.NoDrag == nil) then FQD.NoDrag = false; end;
115 if (FQD.AutoNotify == nil) then FQD.AutoAdd = true; end
116 if (FQD.AutoComplete == nil) then FQD.AutoNotify = true; end;
117 FQD.AutoNotify = false;
118 UpdatePlayer();
119 FastQuest_LinkFrame(dQuestWatchDragButton:GetName(), QuestWatchFrame:GetName(), "RIGHT");
120 FastQuest_LockMovableParts();
121 elseif (event == "UI_INFO_MESSAGE" and message) then
122 local uQuestText = gsub(message,"(.*):%s*([-%d]+)%s*/%s*([-%d]+)%s*$","%1",1);
123 if ( uQuestText ~= message) then
124 if (FQD.AutoNotify == true) then
125 FastQuest_CheckDefaultChat(false);
126 SendChatMessage("FastQuest progress: "..message, DEFAULT_CHAT_FRAME.editBox.chatType);
127 end
128 if (FQD.AutoAdd==true and GetNumQuestWatches()<MAX_WATCHABLE_QUESTS) then
129 local qID = FastQuest_GetQuestID(uQuestText);
130 if (qID) then
131 if (not IsQuestWatched(qID)) then
132 FastQuest_Watch(qID,true);
133 end
134 end
135 end
136 end
137 end
138 end
139  
140 function QuestLogTitleButton_OnClick(button)
141 local qIndex = this:GetID() + FauxScrollFrame_GetOffset(QuestLogListScrollFrame);
142 local qTitle, qLevel, qTag, isHeader, isCollapsed = GetQuestLogTitle(qIndex);
143 if ( button == "LeftButton" ) then
144 QuestLog_SetSelection(qIndex);
145 if ( IsShiftKeyDown() and ChatFrameEditBox:IsVisible() ) then
146 if (FQD[player].Format==1) then
147 ChatFrameEditBox:Insert("["..qLevel.."] "..qTitle.." ");
148 elseif (FQD[player].Format==0) then
149 ChatFrameEditBox:Insert(" "..qTitle.." ");
150 elseif (FQD[player].Format==2) then
151 if (qTag) then qTag = "+" else qTag="";end
152 ChatFrameEditBox:Insert("["..qLevel..qTag.."] "..qTitle.." ");
153 elseif (FQD[player].Format==3) then
154 if (qTag) then qTag = (" ("..qTag..") ") else qTag="";end
155 ChatFrameEditBox:Insert("["..qLevel.."] "..qTitle..qTag);
156 else FQD[player].Format=1; end
157 elseif ( IsShiftKeyDown() ) then
158 FastQuest_Watch(qIndex,false);
159 elseif (IsControlKeyDown()) then
160 FastQuest_CheckDefaultChat(true);
161 if (FQD[player].Format==1) then
162 SendChatMessage("["..qLevel.."] "..qTitle, DEFAULT_CHAT_FRAME.editBox.chatType, GetDefaultLanguage());
163 elseif (FQD[player].Format==0) then
164 SendChatMessage(" "..qTitle.." ", DEFAULT_CHAT_FRAME.editBox.chatType, GetDefaultLanguage());
165 elseif (FQD[player].Format==2) then
166 if (qTag) then qTag = "+" else qTag="";end
167 SendChatMessage("["..qLevel..qTag.."] "..qTitle, DEFAULT_CHAT_FRAME.editBox.chatType, GetDefaultLanguage());
168 elseif (FQD[player].Format==3) then
169 if (qTag) then qTag = (" ("..qTag..") ") else qTag="";end
170 SendChatMessage("["..qLevel.."] "..qTitle..qTag, DEFAULT_CHAT_FRAME.editBox.chatType, GetDefaultLanguage());
171 else FQD[player].Format=1; end
172 local nObjectives = GetNumQuestLeaderBoards(qIndex);
173 if ( nObjectives > 0 ) then
174 for i=1, nObjectives do
175 oText, oType, oDone = GetQuestLogLeaderBoard(i, qIndex);
176 if ( not oText or strlen(oText) == 0 or oText == "" ) then oText = oType;end
177 if ( oDone ) then
178 SendChatMessage(" X "..oText, DEFAULT_CHAT_FRAME.editBox.chatType);
179 else
180 SendChatMessage(" - "..oText, DEFAULT_CHAT_FRAME.editBox.chatType);
181 end
182 end
183 end
184 end
185 QuestLog_Update();
186 elseif ( button == "RightButton" ) then
187 if ( ChatFrameEditBox:IsVisible() ) then
188 QuestLog_SetSelection(qIndex);
189 local qDescription, qObjectives = GetQuestLogQuestText();
190 if (qObjectives) then ChatFrameEditBox:Insert(qObjectives);end
191 return;
192 end
193 FastQuest_Watch(qIndex,false);
194 end
195 end
196  
197 function QuestLog_Update()
198 if (player == "DEFAULT" or FQD[player].tQuests == nil) then UpdatePlayer();end;
199 FastQuest_LockMovableParts();
200 local nEntries, nQuests = GetNumQuestLogEntries();
201 if (GetNumQuestWatches() < 1 and FQD[player].nQuests > 0) then
202 for i=1, nEntries do
203 SelectQuestLogEntry(i);
204 local qTitle, qLevel, qTag, isHeader, isCollapsed = GetQuestLogTitle(i + FauxScrollFrame_GetOffset(QuestLogListScrollFrame));
205 for j = 1, FQD[player].nQuests do
206 if (qTitle == FQD[player].tQuests[j] and not IsQuestWatched(i)) then
207 AddQuestWatch(i);
208 end
209 end
210 end
211 end
212 hQuestLog_Update();
213 for i=1, QUESTS_DISPLAYED, 1 do
214 if ( i <= nEntries ) then
215 local qTitle, qLevel, qTag, isHeader, isCollapsed = GetQuestLogTitle(i + FauxScrollFrame_GetOffset(QuestLogListScrollFrame));
216 local qLogTitle = getglobal("QuestLogTitle"..i);
217 local qCheck = getglobal("QuestLogTitle"..i.."Check");
218 qCheck:SetPoint("LEFT", qLogTitle:GetName(), "LEFT", 3, 0);
219 FastQuest_ChangeTitle(qLogTitle, qTitle, qLevel, qTag, isHeader, false);
220 end
221 end
222  
223 end
224  
225 function QuestWatch_Update()
226 hQuestWatch_Update();
227 local qDone; wID=1; oID=1; DoneID = -1;
228 FQD[player].nQuests = GetNumQuestWatches();
229 for i = 1, GetNumQuestWatches() do
230 FQD[player].tQuests[i] = " ";
231 local qID = GetQuestIndexForWatch(i);
232 if (qID) then
233 local qTitle, qLevel, qTag, isHeader, isCollapsed = GetQuestLogTitle(qID);
234 FQD[player].tQuests[i]= qTitle;
235 qLogTitle = getglobal( "QuestWatchLine" ..wID);
236 FastQuest_ChangeTitle(qLogTitle, qTitle, qLevel, qTag, isHeader, true);
237 qDone = true; oID = 1;
238 for j = 1, GetNumQuestLeaderBoards(qID) do
239 oID = j;
240 qLogTitle = getglobal( "QuestWatchLine" ..(wID+j));
241 local oTitle, oType, oDone = GetQuestLogLeaderBoard(j,qID);
242 if (oDone) then
243 qLogTitle:SetText("|cFFC0FFCF X "..oTitle.." ");
244 else
245 qLogTitle:SetText("|cFFFFFFFF - "..oTitle.." ");
246 qDone = false;
247 end
248 end
249 wID= wID+oID+1;
250 if (qDone) then DoneID = qID;end
251 end
252 end
253 if (DoneID>0) then
254 PlaySoundFile("sound/interface/igplayerBind.wav");
255 UIErrorsFrame:AddMessage("|cff00ffff"..GetQuestLogTitle(DoneID).." (COMPLETE)", 1.0, 1.0, 1.0, 1.0, 2);
256 if (FQD.AutoNotify==true) then
257 FastQuest_CheckDefaultChat(false);
258 SendChatMessage("FastQuest : "..GetQuestLogTitle(DoneID).." is now complete!", DEFAULT_CHAT_FRAME.editBox.chatType)
259 end
260 RemoveQuestWatch(DoneID);
261 QuestWatch_Update();
262 end
263 FQD[player].nQuests = GetNumQuestWatches();
264 FastQuest_LockMovableParts();
265 end
266  
267  
268 function FastQuest_ChangeTitle(qLogTitle, qTitle, qLevel, qTag, isHeader, Watch)
269 local ColorTag="";
270 local DifTag="";
271 if (qTitle and not isHeader) then
272 if (qTag and FQD[player].Tag==true) then DifTag = (" ("..qTag..") ");end
273 if (Watch) then
274 local cQuestLevel = GetDifficultyColor(qLevel);
275 ColorTag = string.format("|cff%02x%02x%02x", cQuestLevel.r * 255, cQuestLevel.g * 255, cQuestLevel.b * 255);
276 qLogTitle:SetText(ColorTag.." ["..qLevel.."] "..qTitle..DifTag);
277 else
278 qLogTitle:SetText(" ["..qLevel.."] "..qTitle.." ");
279 end
280 end
281 end
282  
283 function FastQuest_LinkFrame(dButton, pFrame)
284 if (FQD.NoDrag == false) then
285 getglobal(pFrame):ClearAllPoints();
286 getglobal(pFrame):SetPoint("TOPLEFT", dButton, "TOPRIGHT");
287 else
288 qOut("Fast Quest: Draging is disabled, use /fq nodrag to toggle you must also reload UI for changes to take affect");
289 FQD.Lock = true;
290 end
291 end
292  
293 function FastQuest_DragFrame(pFrame, mode)
294 if (FQD.NoDrag == false) then
295 if (mode == 0) then
296 pFrame:StartMoving();
297 else
298 pFrame:StopMovingOrSizing();
299 end
300 end
301 end
302  
303 function qOut (msg)
304 if( DEFAULT_CHAT_FRAME and msg) then
305 DEFAULT_CHAT_FRAME:AddMessage(msg);
306 end
307 end
308  
309 function FastQuest_LockMovableParts()
310 if (FQD[player].nQuests > 0 and QuestWatchFrame:IsVisible() and FQD.Lock==false and FQD.NoDrag==false) then
311 dQuestWatchDragButton:Show();
312 else
313 dQuestWatchDragButton:Hide();
314 end;
315 end
316  
317 function UpdatePlayer()
318 player = UnitName("player");
319 if (player == nil or player == UNKNOWNBEING or player == UKNOWNBEING or player == UNKNOWNOBJECT) then
320 player = "DEFAULT";end
321 if ( FQD[player] == nil or FQD[player].tQuests == nil ) then
322 FQD[player] = {
323 ["Format"] = 1;
324 ["Tag"] = false;
325 ["nQuests"] = 0;
326 ["tQuests"] = { };
327 }
328 for i=1, MAX_WATCHABLE_QUESTS, 1 do
329 FQD[player].tQuests[i]=" ";
330 end;
331 end
332 end
333  
334 function GetDifficultyColor(level)
335 local lDiff = level - UnitLevel("player");
336 if (lDiff >= 0) then
337 for i= 1.00, 0.10, -0.10 do
338 color = {r = 1.00, g = i, b = 0.00};
339 if ((i/0.10)==(10-lDiff)) then return color; end
340 end
341 elseif ( -lDiff < GetQuestGreenRange() ) then
342 for i= 0.90, 0.10, -0.10 do
343 color = {r = i, g = 1.00, b = 0.00};
344 if ((9-i/0.10)==(-1*lDiff)) then return color; end
345 end
346 elseif ( -lDiff == GetQuestGreenRange() ) then
347 color = {r = 0.50, g = 1.00, b = 0.50};
348 else
349 color = {r = 0.75, g = 0.75, b = 0.75};
350 end
351 return color;
352 end
353  
354 function FastQuest_Watch(qID, auto)
355 if (qID) then
356 if ((IsQuestWatched(qID)) and (auto == false)) then
357 RemoveQuestWatch(qID);
358 QuestWatch_Update();
359 QuestLog_Update();
360 else
361 if ((GetNumQuestLeaderBoards(qID) == 0) and (auto == false)) then
362 UIErrorsFrame:AddMessage(QUEST_WATCH_NO_OBJECTIVES, 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME);
363 return;
364 end
365 if (GetNumQuestWatches() >= MAX_WATCHABLE_QUESTS ) then
366 UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, MAX_WATCHABLE_QUESTS), 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME);
367 return;
368 end
369 AddQuestWatch(qID);
370 QuestWatch_Update();
371 QuestLog_Update();
372 end
373 end
374 end
375  
376 function FastQuest_GetQuestID(str)
377 local qSelected= GetQuestLogSelection();
378 for i=1, GetNumQuestLogEntries(), 1 do
379 SelectQuestLogEntry(i);
380 local qTitle, qLevel, qTag, isHeader, isCollapsed, qComplete = GetQuestLogTitle(i);
381 if (qTitle == str ) then return i; end
382 if(not isHeader) then
383 for j = 1, GetNumQuestLeaderBoards() do
384 local oText, oType, oDone = GetQuestLogLeaderBoard(j);
385 if ((oText==nil) or (oText=="")) then
386 oText = oType;
387 end
388 if (string.find(gsub(oText,"(.*): %d+/%d+","%1",1),gsub(str,"(.*): %d+/%d+","%1",1))) then
389 SelectQuestLogEntry(qSelected);
390 return i;
391 end
392 end
393 local qDescription, qObjectives = GetQuestLogQuestText();
394 if(string.find(qObjectives, str)) then
395 SelectQuestLogEntry(qSelected);
396 return i;
397 end
398 end
399 end
400 SelectQuestLogEntry(qSelected);
401 return nil;
402 end
403  
404 function FastQuest_CheckDefaultChat(allowGuild)
405 if ((DEFAULT_CHAT_FRAME.editBox.stickyType == "GUILD") and (allowGuild == false)) then
406 DEFAULT_CHAT_FRAME.editBox.chatType = "PARTY";
407 elseif ((DEFAULT_CHAT_FRAME.editBox.stickyType == "PARTY") and (GetNumPartyMembers() == 0)) then
408 DEFAULT_CHAT_FRAME.editBox.chatType = "SAY";
409 elseif ((DEFAULT_CHAT_FRAME.editBox.stickyType == "RAID") and (GetNumRaidMembers() == 0)) then
410 DEFAULT_CHAT_FRAME.editBox.chatType = "SAY";
411 end
412 end
413  
414 function FastQuest_ToggleBoolean ( bool, msg )
415 if( bool == false ) then
416 qOut(msg.."Enabled");
417 bool = true;
418 else
419 qOut(msg.."Disabled");
420 bool = false;
421 end
422 return bool;
423 end
424