vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | ------------------------------------------------------ |
2 | -- AdSpace.lua |
||
3 | ------------------------------------------------------ |
||
4 | FAS_VERSION = "11200.2"; |
||
5 | ------------------------------------------------------ |
||
6 | |||
7 | FAS_SPECIAL_VENDOR_COLOR = {r=1.0, g=0.5, b=0.25}; |
||
8 | FAS_INDENT = " "; |
||
9 | |||
10 | FAS_AllClasses = { "PALADIN", "SHAMAN", "MAGE", "PRIEST", "WARLOCK", "WARRIOR", "HUNTER", "ROGUE", "DRUID", "ANY" }; |
||
11 | |||
12 | -- Configuration |
||
13 | FAS_Config = { }; |
||
14 | |||
15 | FAS_Config_Default = { }; |
||
16 | FAS_Config_Default.ShowCost = false; |
||
17 | FAS_Config_Default.PostToRaid = true; |
||
18 | |||
19 | FAS_Config_Default.Recipes = true; |
||
20 | FAS_Config_Default.Librams = true; |
||
21 | FAS_Config_Default.Darkmoon = true; |
||
22 | FAS_Config_Default.AD = true; |
||
23 | FAS_Config_Default.ZG = true; |
||
24 | FAS_Config_Default.AQ20 = true; |
||
25 | FAS_Config_Default.AQ40 = true; |
||
26 | |||
27 | FAS_OptionsText = { |
||
28 | ["Recipes"] = FAS_OPTION_RECIPES, |
||
29 | ["ShowCost"] = FAS_OPTION_RECIPE_COST, |
||
30 | ["Librams"] = FAS_OPTION_LIBRAM, |
||
31 | ["Darkmoon"] = FAS_OPTION_DARKMOON, |
||
32 | ["AD"] = FAS_OPTION_AD, |
||
33 | ["ZG"] = FAS_OPTION_ZG.." "..GFWUtils.Gray(FAS_OPTION_ZG_FACTION), |
||
34 | ["AQ20"] = FAS_OPTION_AQ20.." "..GFWUtils.Gray(FAS_OPTION_AQ20_FACTION), |
||
35 | ["AQ40"] = FAS_OPTION_AQ40.." "..GFWUtils.Gray(FAS_OPTION_AQ40_FACTION), |
||
36 | ["PostToRaid"] = FAS_OPTION_POST_RAID, |
||
37 | }; |
||
38 | |||
39 | local function FAS_Tooltip_Hook(frame, name, link, source) |
||
40 | |||
41 | if (link) then |
||
42 | local _, _, itemID = string.find(link, "item:(%d+):%d+:%d+:%d+"); |
||
43 | itemID = tonumber(itemID); |
||
44 | local itemInfo = FAS_ItemInfo[itemID]; |
||
45 | |||
46 | if (FAS_Config.Recipes and itemInfo) then |
||
47 | if (source == "MERCHANT") then |
||
48 | return false; -- kinda silly to show merchants who sell this when we're seeing this at a merchant |
||
49 | end |
||
50 | local myFaction = UnitFactionGroup("player"); |
||
51 | local vendors = GFWTable.Merge(FAS_VendorInfo[myFaction][itemID], FAS_VendorInfo["Neutral"][itemID]); |
||
52 | local note = itemInfo.note; |
||
53 | |||
54 | local color; |
||
55 | local intro; |
||
56 | if (note) then |
||
57 | color = FAS_SPECIAL_VENDOR_COLOR; |
||
58 | else |
||
59 | color = GFW_FONT_COLOR; |
||
60 | end |
||
61 | if (FAS_Config.ShowCost) then |
||
62 | intro = string.format(SOLD_FOR_PRICE_BY, GFWUtils.TextGSC(itemInfo.b)); |
||
63 | else |
||
64 | intro = SOLD_BY; |
||
65 | end |
||
66 | |||
67 | if (table.getn(vendors) > 1) then |
||
68 | frame:AddLine(intro..":", color.r, color.g, color.b); |
||
69 | for i, aVendor in vendors do |
||
70 | local vendorLoc = FAS_VendorLocations[aVendor]; |
||
71 | if (vendorLoc) then |
||
72 | local vendorName = FAS_Localized[aVendor] or aVendor; |
||
73 | local vendorLocation = FAS_Localized[vendorLoc] or vendorLoc; |
||
74 | frame:AddLine(FAS_INDENT..string.format(VENDOR_LOCATION_FORMAT, vendorName, vendorLocation), color.r, color.g, color.b); |
||
75 | else |
||
76 | GFWUtils.PrintOnce(GFWUtils.Red("AdSpace "..FAS_VERSION.." error: ").."Can't find location for "..aVendor..". Please report to gazmik@fizzwidget.com.", 60); |
||
77 | return false; |
||
78 | end |
||
79 | end |
||
80 | elseif (table.getn(vendors) == 1) then |
||
81 | local vendorLoc = FAS_VendorLocations[vendors[1]]; |
||
82 | if (vendorLoc) then |
||
83 | local vendorName = FAS_Localized[vendors[1]] or vendors[1]; |
||
84 | local vendorLocation = FAS_Localized[vendorLoc] or vendorLoc; |
||
85 | frame:AddLine(intro.." "..string.format(VENDOR_LOCATION_FORMAT, vendorName, vendorLocation), color.r, color.g, color.b); |
||
86 | else |
||
87 | GFWUtils.PrintOnce(GFWUtils.Red("AdSpace "..FAS_VERSION.." error: ").."Can't find location for "..vendorName..". Please report to gazmik@fizzwidget.com.", 60); |
||
88 | return false; |
||
89 | end |
||
90 | else |
||
91 | local found = false; |
||
92 | for _, faction in {"Alliance", "Horde", "Neutral"} do |
||
93 | if (FAS_VendorInfo[faction][itemID]) then |
||
94 | found = true; |
||
95 | end |
||
96 | end |
||
97 | if not (found) then |
||
98 | GFWUtils.PrintOnce(GFWUtils.Red("AdSpace "..FAS_VERSION.." error: ")..link.."("..itemID..") is listed but has no vendors. Please report to gazmik@fizzwidget.com.", 60); |
||
99 | return false; |
||
100 | end |
||
101 | end |
||
102 | if (note ~= "") then |
||
103 | frame:AddLine(note, color.r, color.g, color.b); |
||
104 | end |
||
105 | return true; |
||
106 | end |
||
107 | |||
108 | local libramInfo = FAS_LibramInfo[itemID]; |
||
109 | if (FAS_Config.Librams and libramInfo) then |
||
110 | local color = FAS_SPECIAL_VENDOR_COLOR; |
||
111 | local returnToName = FAS_Localized[libramInfo.name] or libramInfo.name; |
||
112 | local returnToLocation = FAS_Localized[FAS_VendorLocations[libramInfo.name]] or FAS_VendorLocations[libramInfo.name]; |
||
113 | local bonus = FAS_Localized[libramInfo.bonus] or libramInfo.bonus; |
||
114 | frame:AddLine(RETURN_TO.." "..string.format(VENDOR_LOCATION_FORMAT, returnToName, returnToLocation), color.r, color.g, color.b); |
||
115 | frame:AddLine(string.format(ARCANUM_FORMAT, bonus), color.r, color.g, color.b); |
||
116 | return true; |
||
117 | end |
||
118 | |||
119 | local darkmoonInfo = FAS_DarkmoonInfo[itemID]; |
||
120 | if (FAS_Config.Darkmoon and darkmoonInfo) then |
||
121 | local color = FAS_SPECIAL_VENDOR_COLOR; |
||
122 | frame:AddLine(darkmoonInfo, color.r, color.g, color.b); |
||
123 | return true; |
||
124 | end |
||
125 | |||
126 | local tokenInfo = FAS_TokenInfo[itemID]; |
||
127 | if ((FAS_Config.ZG or FAS_Config.AQ20 or FAS_Config.AQ40) and tokenInfo) then |
||
128 | local color = FAS_SPECIAL_VENDOR_COLOR; |
||
129 | local addedLines; |
||
130 | for _, faction in FAS_TokenFactions do |
||
131 | local _, _, factionAbbrev = string.find(faction, "(.-)_FACTION"); |
||
132 | if (FAS_Config[factionAbbrev]) then |
||
133 | local reportLines = {}; |
||
134 | for _, class in FAS_AllClasses do |
||
135 | if (not (class == "SHAMAN" and UnitFactionGroup("player") == "Alliance") and |
||
136 | not (class == "PALADIN" and UnitFactionGroup("player") == "Horde")) then |
||
137 | for _, rewardID in tokenInfo do |
||
138 | local reward = FAS_TokenRewards[rewardID]; |
||
139 | if (reward and reward.class == class and reward.faction == faction) then |
||
140 | local repNeeded; |
||
141 | if (reward.rep) then |
||
142 | repNeeded = getglobal("FACTION_STANDING_LABEL"..reward.rep); |
||
143 | end |
||
144 | local reportLine = ""; |
||
145 | reportLine = reportLine .. reward.type; |
||
146 | if (repNeeded) then |
||
147 | reportLine = reportLine .. " ("..repNeeded..")"; |
||
148 | end |
||
149 | reportLine = reportLine .. ", "; |
||
150 | if (reportLines[class]) then |
||
151 | reportLines[class] = reportLines[class] .. reportLine; |
||
152 | else |
||
153 | reportLines[class] = reportLine; |
||
154 | end |
||
155 | end |
||
156 | end |
||
157 | if (reportLines[class]) then |
||
158 | reportLines[class] = string.gsub(reportLines[class], ", $", ""); |
||
159 | end |
||
160 | end |
||
161 | end |
||
162 | if (GFWTable.Count(reportLines) > 0) then |
||
163 | frame:AddLine(string.format(FAS_FACTION_REWARDS, getglobal(faction)), color.r, color.g, color.b); |
||
164 | addedLines = true; |
||
165 | for class, reportLine in reportLines do |
||
166 | frame:AddLine(" "..getglobal(class)..": "..reportLine, color.r, color.g, color.b); |
||
167 | end |
||
168 | end |
||
169 | end |
||
170 | end |
||
171 | if (addedLines) then |
||
172 | return true; |
||
173 | end |
||
174 | end |
||
175 | |||
176 | for key, tokenSetList in FAS_FactionTokenSets do |
||
177 | if (FAS_Config[key]) then |
||
178 | for _, coinSet in tokenSetList do |
||
179 | local found; |
||
180 | local otherCoins = {}; |
||
181 | for _, coinID in coinSet do |
||
182 | if (itemID == coinID) then |
||
183 | found = true; |
||
184 | else |
||
185 | local itemText = FAS_TokenNames[coinID]; |
||
186 | itemText = FAS_Localized[itemText] or itemText; |
||
187 | table.insert(otherCoins, itemText); |
||
188 | end |
||
189 | end |
||
190 | if (found) then |
||
191 | local color = FAS_SPECIAL_VENDOR_COLOR; |
||
192 | frame:AddLine(FAS_TURNIN.." "..getglobal(key.."_FACTION"), color.r, color.g, color.b); |
||
193 | if (table.getn(otherCoins) > 0) then |
||
194 | frame:AddDoubleLine(" ", FAS_WITH.." "..table.concat(otherCoins, ", "), color.r, color.g, color.b, color.r, color.g, color.b); |
||
195 | end |
||
196 | return true; |
||
197 | end |
||
198 | end |
||
199 | end |
||
200 | end |
||
201 | end |
||
202 | |||
203 | end |
||
204 | |||
205 | function FAS_OnLoad() |
||
206 | |||
207 | -- Register Slash Commands |
||
208 | SLASH_FAS1 = "/adspace"; |
||
209 | SLASH_FAS2 = "/ads"; |
||
210 | SlashCmdList["FAS"] = function(msg) |
||
211 | FAS_ChatCommandHandler(msg); |
||
212 | end |
||
213 | |||
214 | -- Register for Events |
||
215 | this:RegisterEvent("ADDON_LOADED"); |
||
216 | |||
217 | GFWTooltip_AddCallback("GFW_AdSpace", FAS_Tooltip_Hook); |
||
218 | |||
219 | table.insert(UISpecialFrames,"FAS_OptionsFrame"); |
||
220 | |||
221 | GFWUtils.Print("Fizzwidget AdSpace "..FAS_VERSION.." initialized!"); |
||
222 | end |
||
223 | |||
224 | function FAS_OnEvent(event, arg1) |
||
225 | |||
226 | -- Save Variables |
||
227 | if ( event == "ADDON_LOADED" ) then |
||
228 | if (FAS_Config.Tooltip) then |
||
229 | for key, value in FAS_Config_Default do |
||
230 | if (FAS_Config[key] == nil) then |
||
231 | FAS_Config[key] = FAS_Config_Default[key]; |
||
232 | end |
||
233 | end |
||
234 | FAS_Config.Tooltip = nil; |
||
235 | end |
||
236 | this:UnregisterEvent("ADDON_LOADED"); |
||
237 | end |
||
238 | end |
||
239 | |||
240 | function FAS_ChatCommandHandler(msg) |
||
241 | |||
242 | if ( msg == "" ) then |
||
243 | if FAS_OptionsFrame:IsVisible() then |
||
244 | HideUIPanel(FAS_OptionsFrame); |
||
245 | else |
||
246 | ShowUIPanel(FAS_OptionsFrame); |
||
247 | end |
||
248 | return; |
||
249 | end |
||
250 | |||
251 | -- Print Help |
||
252 | if ( msg == "help" ) or ( msg == "" ) then |
||
253 | GFWUtils.Print("Fizzwidget AdSpace "..FAS_VERSION..":"); |
||
254 | GFWUtils.Print("/adspace (or /ads)"); |
||
255 | GFWUtils.Print("- "..GFWUtils.Hilite("help").." - Print this helplist."); |
||
256 | GFWUtils.Print("- "..GFWUtils.Hilite("[item link]").." - Show info for an item in the chat window."); |
||
257 | GFWUtils.Print("- "..GFWUtils.Hilite("status").." - Check current settings."); |
||
258 | GFWUtils.Print("- "..GFWUtils.Hilite("recipes on").." | "..GFWUtils.Hilite("off").." - Show info for vendor-supplied recipes in tooltips."); |
||
259 | GFWUtils.Print("- "..GFWUtils.Hilite("showcost on").." | "..GFWUtils.Hilite("off").." - Also show vendor prices for recipes."); |
||
260 | GFWUtils.Print("- "..GFWUtils.Hilite("librams on").." | "..GFWUtils.Hilite("off").." - Show info for librams in tooltips."); |
||
261 | GFWUtils.Print("- "..GFWUtils.Hilite("darkmoon on").." | "..GFWUtils.Hilite("off").." - Show info for Darkmoon Faire grey item turn-ins in tooltips."); |
||
262 | GFWUtils.Print("- "..GFWUtils.Hilite("zg on").." | "..GFWUtils.Hilite("off").." - Show info for for special raid loot from Zul'Gurub (Zandalar Tribe rewards) in tooltips."); |
||
263 | GFWUtils.Print("- "..GFWUtils.Hilite("aq20 on").." | "..GFWUtils.Hilite("off").." - Show info for for special raid loot from Ruins of Ahn'Qiraj (Cenarion Circle rewards) in tooltips."); |
||
264 | GFWUtils.Print("- "..GFWUtils.Hilite("aq40 on").." | "..GFWUtils.Hilite("off").." - Show info for for special raid loot from Ahn'Qiraj (Brood of Nozdormu rewards) in tooltips."); |
||
265 | GFWUtils.Print("- "..GFWUtils.Hilite("post on").." | "..GFWUtils.Hilite("off").." - Post to raid/party chat when getting raid loot info via "..GFWUtils.Hilite("/ads [item link]").."."); |
||
266 | return; |
||
267 | end |
||
268 | |||
269 | if (msg == "version") then |
||
270 | GFWUtils.Print("Fizzwidget AdSpace "..FAS_VERSION); |
||
271 | return; |
||
272 | end |
||
273 | |||
274 | if ( msg == "status" ) then |
||
275 | local gotSomething; |
||
276 | if (FAS_Config.Recipes) then |
||
277 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("vendor-supplied recipes").." in tooltips."); |
||
278 | gotSomething = 1; |
||
279 | if (FAS_Config.ShowCost) then |
||
280 | GFWUtils.Print("Also showing vendor price for recipes."); |
||
281 | end |
||
282 | end |
||
283 | if (FAS_Config.Librams) then |
||
284 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("Librams").." in tooltips."); |
||
285 | gotSomething = 1; |
||
286 | end |
||
287 | if (FAS_Config.Darkmoon) then |
||
288 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("Darkmoon Faire grey item turn-ins").." in tooltips."); |
||
289 | gotSomething = 1; |
||
290 | end |
||
291 | if (FAS_Config.ZG) then |
||
292 | GFWUtils.Print("Showing info for special raid loot from "..GFWUtils.Hilite("Zul'Gurub (Zandalar Tribe rewards)").." in tooltips."); |
||
293 | gotSomething = 1; |
||
294 | end |
||
295 | if (FAS_Config.AQ20) then |
||
296 | GFWUtils.Print("Showing info for special raid loot from "..GFWUtils.Hilite("Ruins of Ahn'Qiraj (AQ20 Cenarion Circle rewards)").." in tooltips."); |
||
297 | gotSomething = 1; |
||
298 | end |
||
299 | if (FAS_Config.AQ40) then |
||
300 | GFWUtils.Print("Showing info for special raid loot from "..GFWUtils.Hilite("Ahn'Qiraj (AQ40 Brood of Nozdormu rewards)").." in tooltips."); |
||
301 | gotSomething = 1; |
||
302 | end |
||
303 | if ((FAS_Config.ZG or FAS_Config.AQ20 or FAS_Config.AQ40) and FAS_Config.PostToRaid) then |
||
304 | GFWUtils.Print("Will post to raid/party chat when showing info for raid loot via "..GFWUtils.Hilite("/ads [link]").."."); |
||
305 | end |
||
306 | if (not gotSomething) then |
||
307 | GFWUtils.Print("Not adding any info to tooltips."); |
||
308 | end |
||
309 | return; |
||
310 | end |
||
311 | |||
312 | if (msg == "test") then |
||
313 | local itemInfoCount = 0; |
||
314 | for itemID in FAS_ItemInfo do |
||
315 | local found = false; |
||
316 | for _, faction in {"Alliance", "Horde", "Neutral"} do |
||
317 | if (FAS_VendorInfo[faction][itemID]) then |
||
318 | found = true; |
||
319 | end |
||
320 | end |
||
321 | if not (found) then |
||
322 | GFWUtils.Print("Item ID "..itemID.." not found in FAS_VendorInfo."); |
||
323 | end |
||
324 | itemInfoCount = itemInfoCount + 1; |
||
325 | end |
||
326 | GFWUtils.Print(itemInfoCount.." entries in FAS_ItemInfo."); |
||
327 | for _, faction in {"Alliance", "Horde", "Neutral"} do |
||
328 | local vendorInfoCount = 0; |
||
329 | for itemID in FAS_VendorInfo[faction] do |
||
330 | if (FAS_ItemInfo[itemID] == nil) then |
||
331 | GFWUtils.Print("Item ID "..itemID.." not found in FAS_ItemInfo."); |
||
332 | end |
||
333 | vendorInfoCount = vendorInfoCount + 1; |
||
334 | end |
||
335 | GFWUtils.Print(vendorInfoCount.." entries in FAS_VendorInfo["..faction.."]."); |
||
336 | end |
||
337 | return; |
||
338 | end |
||
339 | |||
340 | local _, _, cmd, args = string.find(msg, "^([%l%d']+) *(.*)"); |
||
341 | if (cmd) then cmd = string.lower(cmd); end |
||
342 | |||
343 | if (cmd == "recipes" or cmd == "recipe") then |
||
344 | if (args == "on") then |
||
345 | FAS_Config.Recipes = true; |
||
346 | elseif (args == "off") then |
||
347 | FAS_Config.Recipes = nil; |
||
348 | else |
||
349 | FAS_Config.Recipes = not FAS_Config.Recipes; |
||
350 | end |
||
351 | if (FAS_Config.Recipes) then |
||
352 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("vendor-supplied recipes").." in tooltips."); |
||
353 | else |
||
354 | GFWUtils.Print(GFWUtils.Red("Not").."showing info for "..GFWUtils.Hilite("vendor-supplied recipes").." in tooltips."); |
||
355 | end |
||
356 | return; |
||
357 | end |
||
358 | if (cmd == "showcost" or cmd == "cost") then |
||
359 | if (args == "on") then |
||
360 | FAS_Config.ShowCost = true; |
||
361 | elseif (args == "off") then |
||
362 | FAS_Config.ShowCost = nil; |
||
363 | else |
||
364 | FAS_Config.ShowCost = not FAS_Config.ShowCost; |
||
365 | end |
||
366 | if (FAS_Config.ShowCost) then |
||
367 | GFWUtils.Print("Also showing vendor price for recipes."); |
||
368 | else |
||
369 | GFWUtils.Print(GFWUtils.Red("Not").."showing vendor price for recipes."); |
||
370 | end |
||
371 | return; |
||
372 | end |
||
373 | if (cmd == "librams" or cmd == "libram") then |
||
374 | if (args == "on") then |
||
375 | FAS_Config.Librams = true; |
||
376 | elseif (args == "off") then |
||
377 | FAS_Config.Librams = nil; |
||
378 | else |
||
379 | FAS_Config.Librams = not FAS_Config.Librams; |
||
380 | end |
||
381 | if (FAS_Config.Librams) then |
||
382 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("Librams").." in tooltips."); |
||
383 | else |
||
384 | GFWUtils.Print(GFWUtils.Red("Not").."showing info for "..GFWUtils.Hilite("Librams").." in tooltips."); |
||
385 | end |
||
386 | return; |
||
387 | end |
||
388 | if (cmd == "darkmoon") then |
||
389 | if (args == "on") then |
||
390 | FAS_Config.Darkmoon = true; |
||
391 | elseif (args == "off") then |
||
392 | FAS_Config.Darkmoon = nil; |
||
393 | else |
||
394 | FAS_Config.Darkmoon = not FAS_Config.Darkmoon; |
||
395 | end |
||
396 | if (FAS_Config.Darkmoon) then |
||
397 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("Darkmoon Faire grey item turn-ins").." in tooltips."); |
||
398 | else |
||
399 | GFWUtils.Print(GFWUtils.Red("Not").."showing info for "..GFWUtils.Hilite("Darkmoon Faire grey item turn-ins").." in tooltips."); |
||
400 | end |
||
401 | return; |
||
402 | end |
||
403 | if (cmd == "zg" or cmd == "zul'gurub" or cmd == "zulgurub" or cmd == "zandalar") then |
||
404 | if (args == "on") then |
||
405 | FAS_Config.ZG = true; |
||
406 | elseif (args == "off") then |
||
407 | FAS_Config.ZG = nil; |
||
408 | else |
||
409 | FAS_Config.ZG = not FAS_Config.ZG; |
||
410 | end |
||
411 | if (FAS_Config.ZG) then |
||
412 | GFWUtils.Print("Showing info for special raid loot from"..GFWUtils.Hilite("Zul'Gurub (Zandalar Tribe rewards)").." in tooltips."); |
||
413 | else |
||
414 | GFWUtils.Print(GFWUtils.Red("Not").."showing info for special raid loot from"..GFWUtils.Hilite("Zul'Gurub (Zandalar Tribe rewards)").." in tooltips."); |
||
415 | end |
||
416 | return; |
||
417 | end |
||
418 | if (cmd == "aq20" or cmd == "cenarion") then |
||
419 | if (args == "on") then |
||
420 | FAS_Config.AQ20 = true; |
||
421 | elseif (args == "off") then |
||
422 | FAS_Config.AQ20 = nil; |
||
423 | else |
||
424 | FAS_Config.AQ20 = not FAS_Config.AQ20; |
||
425 | end |
||
426 | if (FAS_Config.AQ20) then |
||
427 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("Ruins of Ahn'Qiraj (AQ20)").." special raid loot in tooltips."); |
||
428 | else |
||
429 | GFWUtils.Print(GFWUtils.Red("Not").."showing info for "..GFWUtils.Hilite("Ruins of Ahn'Qiraj (AQ20)").." special raid loot in tooltips."); |
||
430 | end |
||
431 | return; |
||
432 | end |
||
433 | if (cmd == "aq40" or cmd == "brood" or cmd == "nozdormu") then |
||
434 | if (args == "on") then |
||
435 | FAS_Config.AQ40 = true; |
||
436 | elseif (args == "off") then |
||
437 | FAS_Config.AQ40 = nil; |
||
438 | else |
||
439 | FAS_Config.AQ40 = not FAS_Config.AQ40; |
||
440 | end |
||
441 | if (FAS_Config.AQ40) then |
||
442 | GFWUtils.Print("Showing info for "..GFWUtils.Hilite("Ahn'Qiraj (AQ40)").." special raid loot in tooltips."); |
||
443 | else |
||
444 | GFWUtils.Print(GFWUtils.Red("Not").."showing info for "..GFWUtils.Hilite("Ahn'Qiraj (AQ40)").." special raid loot in tooltips."); |
||
445 | end |
||
446 | return; |
||
447 | end |
||
448 | if (cmd == "post" or cmd == "raid" or cmd == "party") then |
||
449 | if (args == "on") then |
||
450 | FAS_Config.PostToRaid = true; |
||
451 | elseif (args == "off") then |
||
452 | FAS_Config.PostToRaid = nil; |
||
453 | else |
||
454 | FAS_Config.PostToRaid = not FAS_Config.PostToRaid; |
||
455 | end |
||
456 | if (FAS_Config.PostToRaid) then |
||
457 | GFWUtils.Print("Will post to raid/party chat when getting info for raid loot via "..GFWUtils.Hilite("/ads [link]")"."); |
||
458 | else |
||
459 | GFWUtils.Print("Will only print to chat window when getting info for raid loot via "..GFWUtils.Hilite("/ads [link]")"."); |
||
460 | end |
||
461 | return; |
||
462 | end |
||
463 | |||
464 | if (args == nil or args == "") then |
||
465 | args = msg; |
||
466 | end |
||
467 | local postedText; |
||
468 | for itemLink in string.gfind(args, "|c%x+|Hitem:%d+:%d+:%d+:%d+|h%[.-%]|h|r") do |
||
469 | postedText = nil; |
||
470 | local _, _, itemID = string.find(itemLink, "|c%x+|Hitem:(%d+):%d+:%d+:%d+|h%[.-%]|h|r"); |
||
471 | if (itemID == nil or itemID == "") then |
||
472 | GFWUtils.Print("Usage: "..GFWUtils.Hilite("/ads info <item link>")); |
||
473 | return; |
||
474 | end |
||
475 | itemID = tonumber(itemID); |
||
476 | |||
477 | local itemInfo = FAS_ItemInfo[itemID]; |
||
478 | if (itemInfo) then |
||
479 | local myFaction = UnitFactionGroup("player"); |
||
480 | local vendors = GFWTable.Merge(FAS_VendorInfo[myFaction][itemID], FAS_VendorInfo["Neutral"][itemID]); |
||
481 | local note = itemInfo.note; |
||
482 | local intro = itemLink..": "..string.format(SOLD_FOR_PRICE_BY, GFWUtils.TextGSC(itemInfo.b)); |
||
483 | |||
484 | if (vendors == nil or vendors == {}) then |
||
485 | GFWUtils.Print(GFWUtils.Red("AdSpace "..FAS_VERSION.." error: ")..itemLink.."("..itemID..") is listed but has no vendors. Please report to gazmik@fizzwidget.com."); |
||
486 | return; |
||
487 | end |
||
488 | GFWUtils.Print(intro); |
||
489 | for i, aVendor in vendors do |
||
490 | local vendorName = FAS_Localized[aVendor] or aVendor; |
||
491 | local vendorLocation = FAS_Localized[FAS_VendorLocations[aVendor]] or FAS_VendorLocations[aVendor]; |
||
492 | GFWUtils.Print(string.format(VENDOR_LOCATION_FORMAT, vendorName, vendorLocation)); |
||
493 | end |
||
494 | if (note and note ~= "") then |
||
495 | GFWUtils.Print(GFWUtils.Hilite(note)); |
||
496 | end |
||
497 | postedText = 1; |
||
498 | end |
||
499 | |||
500 | local libramInfo = FAS_LibramInfo[itemID]; |
||
501 | if (libramInfo) then |
||
502 | local returnToName = FAS_Localized[libramInfo.name] or libramInfo.name; |
||
503 | local returnToLocation = FAS_Localized[FAS_VendorLocations[libramInfo.name]] or FAS_VendorLocations[libramInfo.name]; |
||
504 | local bonus = FAS_Localized[libramInfo.bonus] or libramInfo.bonus; |
||
505 | GFWUtils.Print(itemLink..": "..RETURN_TO.." "..string.format(VENDOR_LOCATION_FORMAT, returnToName, returnToLocation)); |
||
506 | GFWUtils.Print(bonus); |
||
507 | postedText = 1; |
||
508 | end |
||
509 | |||
510 | local darkmoonInfo = FAS_DarkmoonInfo[itemID]; |
||
511 | if (darkmoonInfo) then |
||
512 | GFWUtils.Print(itemLink..": "..darkmoonInfo); |
||
513 | postedText = 1; |
||
514 | end |
||
515 | |||
516 | local tokenInfo = FAS_TokenInfo[itemID]; |
||
517 | if (tokenInfo) then |
||
518 | for _, faction in FAS_TokenFactions do |
||
519 | local reportLines = {}; |
||
520 | for _, class in FAS_AllClasses do |
||
521 | for _, rewardID in tokenInfo do |
||
522 | local reward = FAS_TokenRewards[rewardID]; |
||
523 | if (reward and reward.class == class and reward.faction == faction) then |
||
524 | local link = GFWUtils.ItemLink(rewardID); |
||
525 | local repNeeded; |
||
526 | if (reward.rep) then |
||
527 | repNeeded = getglobal("FACTION_STANDING_LABEL"..reward.rep); |
||
528 | end |
||
529 | local reportLine = ""; |
||
530 | if (link) then |
||
531 | reportLine = reportLine .. link .. " - "; |
||
532 | end |
||
533 | reportLine = reportLine .. reward.type; |
||
534 | if (repNeeded) then |
||
535 | reportLine = reportLine .. " ("..repNeeded..")"; |
||
536 | end |
||
537 | reportLine = reportLine .. ", "; |
||
538 | if (reportLines[class]) then |
||
539 | reportLines[class] = reportLines[class] .. reportLine; |
||
540 | else |
||
541 | reportLines[class] = reportLine; |
||
542 | end |
||
543 | end |
||
544 | end |
||
545 | if (reportLines[class]) then |
||
546 | reportLines[class] = string.gsub(reportLines[class], ", $", ""); |
||
547 | end |
||
548 | end |
||
549 | if (GFWTable.Count(reportLines) > 0) then |
||
550 | local _, _, factionAbbrev = string.find(faction, "(.-)_FACTION"); |
||
551 | postedText = 1; |
||
552 | if (FAS_Config[factionAbbrev]) then |
||
553 | FAS_Post(itemLink..": "..string.format(FAS_FACTION_REWARDS, getglobal(faction))); |
||
554 | for class, reportLine in reportLines do |
||
555 | FAS_Post(" "..getglobal(class)..": "..reportLine); |
||
556 | end |
||
557 | else |
||
558 | FAS_Post(itemLink..": "..string.format(FAS_FACTION_REWARDS_COUNT, GFWTable.Count(reportLines), getglobal(faction))); |
||
559 | end |
||
560 | end |
||
561 | end |
||
562 | end |
||
563 | |||
564 | local rewardInfo = FAS_TokenRewards[itemID]; |
||
565 | if (rewardInfo) then |
||
566 | local link = GFWUtils.ItemLink(itemID); |
||
567 | FAS_Post(link..": "..string.format(ITEM_REQ_REPUTATION, getglobal(rewardInfo.faction), getglobal("FACTION_STANDING_LABEL"..rewardInfo.rep))); |
||
568 | local reportLines = {}; |
||
569 | for tokenID, rewards in FAS_TokenInfo do |
||
570 | if (GFWTable.KeyOf(rewards, itemID)) then |
||
571 | local itemText = GFWUtils.ItemLink(tokenID); |
||
572 | local itemQuality = FAS_TokenQuality[tokenID]; |
||
573 | if (itemText == nil) then |
||
574 | itemText = FAS_TokenNames[tokenID]; |
||
575 | itemText = FAS_Localized[itemText] or itemText; |
||
576 | local _, _, _, color = GetItemQualityColor(math.floor(itemQuality)); |
||
577 | itemText = color..itemText..FONT_COLOR_CODE_CLOSE; |
||
578 | end |
||
579 | if (rewardInfo == ENSCRIBE) then |
||
580 | -- ZG enchants take 1 each of any reagent |
||
581 | itemText = "1 x "..itemText; |
||
582 | else |
||
583 | -- other token quests take 1 epic only, or 5 of one green + 5 another green + 2 blue + 1 "special" |
||
584 | if (itemQuality == 2) then |
||
585 | itemText = "5 x "..itemText; |
||
586 | elseif (itemQuality == 3) then |
||
587 | itemText = "2 x "..itemText; |
||
588 | else |
||
589 | itemText = "1 x "..itemText; |
||
590 | end |
||
591 | end |
||
592 | table.insert(reportLines, itemText); |
||
593 | end |
||
594 | end |
||
595 | table.sort(reportLines); |
||
596 | for _, line in reportLines do |
||
597 | FAS_Post(line); |
||
598 | end |
||
599 | postedText = 1; |
||
600 | end |
||
601 | |||
602 | if (not postedText) then |
||
603 | GFWUtils.Print("Nothing known about "..itemLink.."."); |
||
604 | end |
||
605 | end |
||
606 | if (postedText) then |
||
607 | return; |
||
608 | end |
||
609 | -- if we made it down here, there were args we didn't understand... time to remind the user what to do. |
||
610 | FAS_ChatCommandHandler("help"); |
||
611 | |||
612 | end |
||
613 | |||
614 | function FAS_StripColor(text) |
||
615 | if (string.find(text, "|c%x+|Hitem:%d+:%d+:%d+:%d+|h%[.-%]|h|r")) then |
||
616 | return text; |
||
617 | else |
||
618 | return string.gsub(text, "|c"..string.rep("%x", 8).."(.-)|r", "%1"); |
||
619 | end |
||
620 | end |
||
621 | |||
622 | function FAS_Post(msg) |
||
623 | if (FAS_Config.PostToRaid and GetNumRaidMembers() > 0) then |
||
624 | msg = FAS_StripColor(msg); |
||
625 | SendChatMessage(msg, "RAID"); |
||
626 | elseif (FAS_Config.PostToRaid and GetNumPartyMembers() > 0) then |
||
627 | msg = FAS_StripColor(msg); |
||
628 | SendChatMessage(msg, "PARTY"); |
||
629 | else |
||
630 | GFWUtils.Print(msg); |
||
631 | end |
||
632 | end |
||
633 | |||
634 | function FAS_CheckMerchant(itemID) |
||
635 | for merchantIndex = 1, GetMerchantNumItems() do |
||
636 | local link = GetMerchantItemLink(merchantIndex); |
||
637 | local _, _, merchantItemID = string.find(link, "item:(%d+):%d+:%d+:%d+"); |
||
638 | if (tonumber(merchantItemID) == itemID) then |
||
639 | return true; |
||
640 | end |
||
641 | end |
||
642 | return false; |
||
643 | end |
||
644 | |||
645 | function FAS_OptionsShow() |
||
646 | |||
647 | FAS_VersionText:SetText("v. "..FAS_VERSION); |
||
648 | |||
649 | for option, description in FAS_OptionsText do |
||
650 | local button = getglobal("FAS_OptionsButton_"..option); |
||
651 | local text = getglobal("FAS_OptionsButton_"..option.."Text"); |
||
652 | |||
653 | if (button and text) then |
||
654 | button:SetChecked(FAS_Config[option]); |
||
655 | text:SetText(description); |
||
656 | end |
||
657 | end |
||
658 | |||
659 | end |
||
660 | |||
661 | function FAS_OptionsClick() |
||
662 | local button = this:GetName(); |
||
663 | local option = string.gsub(button, "FAS_OptionsButton_", ""); |
||
664 | FAS_Config[option] = this:GetChecked(); |
||
665 | end |
||
666 | |||
667 | -- private, for building localization tables |
||
668 | function FAS_Translate(langCode) |
||
669 | |||
670 | tempTranslations = {}; |
||
671 | |||
672 | local localizedVendorInfo = getglobal("FAS_VendorInfo_"..langCode); |
||
673 | local localizedVendorLocations = getglobal("FAS_VendorLocations_"..langCode); |
||
674 | for faction, factionVendorList in FAS_VendorInfo do |
||
675 | for itemID, vendorList in factionVendorList do |
||
676 | local localizedVendors = localizedVendorInfo[faction][itemID]; |
||
677 | if (localizedVendors and type(localizedVendors) == "table") then |
||
678 | for index, name in vendorList do |
||
679 | local localizedName = localizedVendors[index]; |
||
680 | |||
681 | if (localizedName == nil) then break; end |
||
682 | |||
683 | if (localizedName ~= name) then |
||
684 | if (tempTranslations[name] == nil) then |
||
685 | tempTranslations[name] = {}; |
||
686 | end |
||
687 | table.insert(tempTranslations[name], localizedName); |
||
688 | end |
||
689 | |||
690 | local location = FAS_VendorLocations[name]; |
||
691 | local localizedLocation = localizedVendorLocations[localizedName]; |
||
692 | if (localizedLocation and localizedLocation ~= location) then |
||
693 | if (tempTranslations[location] == nil) then |
||
694 | tempTranslations[location] = {}; |
||
695 | end |
||
696 | table.insert(tempTranslations[location], localizedLocation); |
||
697 | end |
||
698 | end |
||
699 | end |
||
700 | end |
||
701 | end |
||
702 | |||
703 | local localizedLibramInfo = getglobal("FAS_LibramInfo_"..langCode); |
||
704 | for itemID, libramInfo in FAS_LibramInfo do |
||
705 | local localizedInfo = localizedLibramInfo[itemID]; |
||
706 | if (localizedInfo and type(localizedInfo) == "table") then |
||
707 | |||
708 | if (localizedInfo.name ~= libramInfo.name) then |
||
709 | if (tempTranslations[libramInfo.name] == nil) then |
||
710 | tempTranslations[libramInfo.name] = {}; |
||
711 | end |
||
712 | table.insert(tempTranslations[libramInfo.name], localizedInfo.name); |
||
713 | end |
||
714 | if (localizedInfo.bonus ~= libramInfo.bonus) then |
||
715 | if (tempTranslations[libramInfo.bonus] == nil) then |
||
716 | tempTranslations[libramInfo.bonus] = {}; |
||
717 | end |
||
718 | table.insert(tempTranslations[libramInfo.bonus], localizedInfo.bonus); |
||
719 | end |
||
720 | |||
721 | local location = FAS_VendorLocations[libramInfo.name]; |
||
722 | local localizedLocation = localizedVendorLocations[localizedInfo.name]; |
||
723 | if (localizedLocation and localizedLocation ~= location) then |
||
724 | if (tempTranslations[location] == nil) then |
||
725 | tempTranslations[location] = {}; |
||
726 | end |
||
727 | table.insert(tempTranslations[location], localizedLocation); |
||
728 | end |
||
729 | end |
||
730 | end |
||
731 | |||
732 | FAS_Config[langCode] = {}; |
||
733 | for baseString, translations in tempTranslations do |
||
734 | if (table.getn(translations) == 1) then |
||
735 | FAS_Config[langCode][baseString] = translations[1]; |
||
736 | else |
||
737 | local mergedTranslations = {} |
||
738 | for _, translation in translations do |
||
739 | if (GFWTable.KeyOf(mergedTranslations, translation) == nil) then |
||
740 | table.insert(mergedTranslations, translation); |
||
741 | end |
||
742 | end |
||
743 | if (table.getn(mergedTranslations) == 1) then |
||
744 | FAS_Config[langCode][baseString] = mergedTranslations[1]; |
||
745 | else |
||
746 | FAS_Config[langCode][baseString] = mergedTranslations; |
||
747 | end |
||
748 | end |
||
749 | end |
||
750 | |||
751 | end |
||
752 |