vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -------------------------------------------------------------------------- |
2 | -- TitanQuestsUtils.lua |
||
3 | -------------------------------------------------------------------------- |
||
4 | --[[ |
||
5 | Contains various utility functions for Titan [Quests]. |
||
6 | ]]-- |
||
7 | |||
8 | -- |
||
9 | -- utility function to get the string tag for a quest |
||
10 | -- |
||
11 | function TitanPanelQuests_GetQuestTagText(questID) |
||
12 | local useTag = ""; |
||
13 | local Title, Level, Tag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questID); |
||
14 | |||
15 | -- Loc Note: Need to localize these tags - Ryessa |
||
16 | if ( Tag == ELITE ) then |
||
17 | useTag = "+" |
||
18 | elseif ( Tag == TITAN_QUESTS_DUNGEON ) then |
||
19 | useTag = "d"; |
||
20 | elseif ( Tag == TITAN_QUESTS_RAID ) then |
||
21 | useTag = "r"; |
||
22 | elseif ( Tag == TITAN_QUESTS_PVP ) then |
||
23 | useTag = "p"; |
||
24 | else |
||
25 | useTag = ""; |
||
26 | end |
||
27 | |||
28 | if ( isComplete ) then |
||
29 | --useTag = "C"; |
||
30 | end |
||
31 | |||
32 | return useTag; |
||
33 | end |
||
34 | |||
35 | -- |
||
36 | -- utility function to get the string tag for a watched quest |
||
37 | -- |
||
38 | function TitanPanelQuests_GetQuestWatchText(questID) |
||
39 | local questWatched; |
||
40 | |||
41 | if ( IsQuestWatched(questID) ) then |
||
42 | -- Loc Note: Need to localize this tag - Ryessa |
||
43 | questWatched = TitanPanelQuests_BlueText(" (W)"); |
||
44 | else |
||
45 | questWatched = ""; |
||
46 | end |
||
47 | |||
48 | return questWatched; |
||
49 | end |
||
50 | |||
51 | -- |
||
52 | -- utility function to get the string tag for a completed quest |
||
53 | -- |
||
54 | function TitanPanelQuests_GetQuestCompleteText(questID) |
||
55 | local completeTag; |
||
56 | local Title, Level, Tag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questID); |
||
57 | |||
58 | if ( isComplete ) then |
||
59 | completeTag = " ("..COMPLETE..")"; |
||
60 | else |
||
61 | completeTag = ""; |
||
62 | end |
||
63 | |||
64 | SelectQuestLogEntry(questID); |
||
65 | if ( IsCurrentQuestFailed() ) then |
||
66 | completeTag = " ("..TEXT(FAILED)..")"; |
||
67 | end |
||
68 | |||
69 | return completeTag; |
||
70 | end |
||
71 | |||
72 | -- |
||
73 | -- utility function to get the location string for a quest |
||
74 | -- |
||
75 | function TitanPanelQuests_GetQuestLocationText(questID) |
||
76 | local i; |
||
77 | local questLocation = ""; |
||
78 | |||
79 | local questlist = TitanPanelQuests_BuildQuestList(); |
||
80 | local numQuests = table.getn(questlist); |
||
81 | |||
82 | for i=1, numQuests do |
||
83 | if ( questID == questlist[i].questID ) then |
||
84 | questLocation = questlist[i].questLocation; |
||
85 | break; |
||
86 | end |
||
87 | end |
||
88 | |||
89 | if ( TitanGetVar(TITAN_QUESTS_ID, "SortByLocation") and TitanGetVar(TITAN_QUESTS_ID, "GroupBehavior") ) then |
||
90 | return ""; |
||
91 | else |
||
92 | return TitanUtils_GetNormalText(" ["..questLocation.."]"); |
||
93 | end |
||
94 | end |
||
95 | |||
96 | -- |
||
97 | -- utility function to get the string tag for a watched quest |
||
98 | -- |
||
99 | |||
100 | function TitanPanelQuests_GetQuestText(questID) |
||
101 | local Title, Level, Tag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questID); |
||
102 | local questTag; |
||
103 | local locationTag = TitanPanelQuests_GetQuestLocationText(questID); |
||
104 | |||
105 | questTag = TitanUtils_GetColoredText("["..Level..TitanPanelQuests_GetQuestTagText(questID).."] ",GetDifficultyColor(Level))..Title..TitanUtils_GetRedText(TitanPanelQuests_GetQuestCompleteText(questID))..locationTag..TitanPanelQuests_GetQuestWatchText(questID); |
||
106 | |||
107 | return questTag; |
||
108 | end |
||
109 | |||
110 | -- |
||
111 | -- IsWatchAllowed |
||
112 | -- |
||
113 | function TitanPanelQuests_IsWatchAllowed(questID) |
||
114 | if ( GetNumQuestLeaderBoards(questID) == 0 ) then |
||
115 | -- Set an error that there are no objectives for the quest, so it may not be watched. |
||
116 | UIErrorsFrame:AddMessage(QUEST_WATCH_NO_OBJECTIVES, 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME); |
||
117 | return false; |
||
118 | end |
||
119 | if ( GetNumQuestWatches() >= MAX_WATCHABLE_QUESTS ) then |
||
120 | -- Set an error message if trying to show too many quests |
||
121 | UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, MAX_WATCHABLE_QUESTS), 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME); |
||
122 | return false; |
||
123 | end |
||
124 | |||
125 | -- Retrieve the quest info for questID. |
||
126 | local Title, Level, Tag, isHeader, isCollapsed, isComplete; |
||
127 | Title, Level, Tag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questID); |
||
128 | if ( isComplete ) then |
||
129 | -- We can't watch a complete item. |
||
130 | return false; |
||
131 | end |
||
132 | return true; |
||
133 | end |
||
134 | |||
135 | -- |
||
136 | -- build quest list (returns table of current active quests) |
||
137 | -- |
||
138 | function TitanPanelQuests_BuildQuestList() |
||
139 | |||
140 | local NumEntries, NumQuests; |
||
141 | |||
142 | local Title, Level, Tag, isHeader, isCollapsed, isComplete; |
||
143 | local questIndex; |
||
144 | |||
145 | local Location; |
||
146 | |||
147 | local useTag; |
||
148 | local completeTag; |
||
149 | local questWatched = ""; |
||
150 | local diff; |
||
151 | |||
152 | local QuestList = { }; |
||
153 | |||
154 | NumEntries, NumQuests = GetNumQuestLogEntries(); |
||
155 | |||
156 | for questIndex=1, NumEntries do |
||
157 | Title, Level, Tag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questIndex); |
||
158 | |||
159 | if ( Level == 0 ) then |
||
160 | Location = Title; |
||
161 | else |
||
162 | local entry = { questID = questIndex, questTitle = Title, questLevel = Level, questTag = Tag, questisHeader = isHeader, questisComplete = isComplete, questLocation = Location }; |
||
163 | table.insert(QuestList, entry); |
||
164 | end |
||
165 | end |
||
166 | |||
167 | return QuestList; |
||
168 | end |
||
169 | |||
170 | -- |
||
171 | -- debug |
||
172 | -- |
||
173 | function TitanPanelQuests_DisplayTheList(thelist) |
||
174 | local i = 0; |
||
175 | for i=1, table.getn(thelist) do |
||
176 | TitanPanelQuests_ChatPrint(i..":"..thelist[i].questLevel..":"..thelist[i].questTitle..":"..thelist[i].questLocation..":"..thelist[i].questID.."\n"); |
||
177 | end |
||
178 | end |
||
179 | |||
180 | -- |
||
181 | -- blue text |
||
182 | -- |
||
183 | function TitanPanelQuests_BlueText(text) |
||
184 | if (text) then |
||
185 | local redColorCode = format("%02x", 0); |
||
186 | local greenColorCode = format("%02x", 0); |
||
187 | local blueColorCode = format("%02x", 255); |
||
188 | local colorCode = "|cff"..redColorCode..greenColorCode..blueColorCode; |
||
189 | return colorCode..text..FONT_COLOR_CODE_CLOSE; |
||
190 | end |
||
191 | end |
||
192 | |||
193 | -- |
||
194 | -- debug |
||
195 | -- |
||
196 | function TitanPanelQuests_ChatPrint(msg) |
||
197 | DEFAULT_CHAT_FRAME:AddMessage(msg); |
||
198 | end |