vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | assert(BigWigs, "BigWigs not found!") |
2 | |||
3 | local BWL = nil |
||
4 | local BZ = AceLibrary("Babble-Zone-2.2") |
||
5 | local L = AceLibrary("AceLocale-2.2"):new("BigWigsVersionQuery") |
||
6 | local tablet = AceLibrary("Tablet-2.0") |
||
7 | local dewdrop = AceLibrary("Dewdrop-2.0") |
||
8 | |||
9 | local COLOR_GREEN = "00ff00" |
||
10 | local COLOR_RED = "ff0000" |
||
11 | local COLOR_WHITE = "ffffff" |
||
12 | |||
13 | --------------------------------- |
||
14 | -- Localization -- |
||
15 | --------------------------------- |
||
16 | |||
17 | L:RegisterTranslations("enUS", function() return { |
||
18 | ["versionquery"] = true, |
||
19 | ["Version Query"] = true, |
||
20 | ["Commands for querying the raid for Big Wigs versions."] = true, |
||
21 | ["Query already running, please wait 5 seconds before trying again."] = true, |
||
22 | ["Querying versions for "] = true, |
||
23 | ["Big Wigs Version Query"] = true, |
||
24 | ["Close window"] = true, -- I know, it's really a Tablet. |
||
25 | ["Showing version for "] = true, |
||
26 | ["Green versions are newer than yours, red are older, and white are the same."] = true, |
||
27 | ["Player"] = true, |
||
28 | ["Version"] = true, |
||
29 | ["Current zone"] = true, |
||
30 | ["<zone>"] = true, |
||
31 | ["Version query done."] = true, |
||
32 | ["Runs a version query on your current zone."] = true, |
||
33 | ["Closes the version query window."] = true, |
||
34 | ["current"] = true, |
||
35 | ["Runs a version query on the given zone."] = true, |
||
36 | ["Zone"] = true, |
||
37 | ["zone"] = true, |
||
38 | ["N/A"] = true, |
||
39 | ["BigWigs"] = true, |
||
40 | ["Runs a version query on the BigWigs core."] = true, |
||
41 | ["Nr Replies"] = true, |
||
42 | ["Ancient"] = true, |
||
43 | } end ) |
||
44 | |||
45 | L:RegisterTranslations("koKR", function() return { |
||
46 | ["Version Query"] = "버전 요청", |
||
47 | ["Commands for querying the raid for Big Wigs versions."] = "BigQigs 버전에 대한 공격대 요청 명령.", |
||
48 | ["Query already running, please wait 5 seconds before trying again."] = "이미 요청 중, 5초후 다시 시도하세요.", |
||
49 | ["Querying versions for "] = "버전 요청 중 : ", |
||
50 | ["Big Wigs Version Query"] = "BigWigs 버전 요청", |
||
51 | ["Close window"] = "창 닫기", -- I know, it's really a Tablet. |
||
52 | ["Showing version for "] = "버전 표시 중 ", |
||
53 | ["Green versions are newer than yours, red are older, and white are the same."] = "녹색 : 최신, 붉은색 : 이전, 흰색 : 같음(자신 기준)", |
||
54 | ["Player"] = "플레이어", |
||
55 | ["Version"] = "버전", |
||
56 | ["Current zone"] = "현재 지역", |
||
57 | ["<zone>"] = "<지역>", |
||
58 | ["Version query done."] = "버전 요청 완료.", |
||
59 | ["Runs a version query on your current zone."] = "현재 지역에 동작 모듈 버전 요청", |
||
60 | ["Closes the version query window."] = "버전 확인 창 닫기.", |
||
61 | ["Runs a version query on the given zone."] = "정해진 지역에 동작 모듈 버전 요청.", |
||
62 | ["Zone"] = "지역", |
||
63 | ["N/A"] = "N/A", |
||
64 | } end ) |
||
65 | |||
66 | L:RegisterTranslations("deDE", function() return { |
||
67 | ["versionquery"] = "Versionsabfrage", |
||
68 | ["Version Query"] = "Versionsabfrage", |
||
69 | ["Commands for querying the raid for Big Wigs versions."] = "Kommandos um den Schlachtzug nach verwendeten BigWigs Versionen abzufragen.", |
||
70 | ["Query already running, please wait 5 seconds before trying again."] = "Abfrage l\195\164uft bereits, bitte 5 Sekunden warten bis zum n\195\164chsten Versuch.", |
||
71 | ["Querying versions for "] = "Frage Versionen ab f\195\188r ", |
||
72 | ["Big Wigs Version Query"] = "BigWigs Versionsabfrage", |
||
73 | ["Close window"] = "Schlie\195\159e Fenster", -- I know, it's really a Tablet. |
||
74 | ["Showing version for "] = "Zeige Version f\195\188r ", |
||
75 | ["Green versions are newer than yours, red are older, and white are the same."] = "Gr\195\188ne Versionen sind neuer, rote sind \195\164lter, wei\195\159e sind gleich.", |
||
76 | ["Player"] = "Spieler", |
||
77 | ["Version"] = "Version", |
||
78 | ["Current zone"] = "Momentane Zone", |
||
79 | ["<zone>"] = "<zone>", |
||
80 | ["Version query done."] = "Versionsabfrage beendet.", |
||
81 | ["Runs a version query on your current zone."] = "Versionsabfrage f\195\188r die momentane Zone starten.", |
||
82 | ["Closes the version query window."] = "Schlie\195\159t das Versionsabfrage-Fenster.", |
||
83 | ["current"] = "gegenw\195\164rtig", |
||
84 | ["Runs a version query on the given zone."] = "Versionsabfrage in f\195\188r eine gegebene Zone starten.", |
||
85 | ["Zone"] = "Zone", |
||
86 | ["zone"] = "Zone", |
||
87 | ["N/A"] = "N/A", |
||
88 | ["BigWigs"] = "BigWigs", |
||
89 | ["Runs a version query on the BigWigs core."] = "Versionsabfrage f\195\188r die BigWigs Kernkomponente starten.", |
||
90 | ["Nr Replies"] = "Anzahl der Antworten", |
||
91 | ["Ancient"] = "Alt", |
||
92 | } end ) |
||
93 | |||
94 | L:RegisterTranslations("zhCN", function() return { |
||
95 | ["versionquery"] = "检查版本", |
||
96 | ["Version Query"] = "检查版本", |
||
97 | ["Commands for querying the raid for Big Wigs versions."] = "这个命令检查Big Wigs的版本", |
||
98 | ["Query already running, please wait 5 seconds before trying again."] = "检查中,请等5秒后再尝试", |
||
99 | ["Querying versions for "] = "检查版本 ", |
||
100 | ["Big Wigs Version Query"] = "Big Wigs版本检查", |
||
101 | ["Close window"] = "关闭窗口", -- I know, it's really a Tablet. |
||
102 | ["Showing version for "] = "显示版本 ", |
||
103 | ["Green versions are newer than yours, red are older, and white are the same."] = "绿色的版本比你的新,红色的比你的旧,白色的是相同", |
||
104 | ["Player"] = "玩家", |
||
105 | ["Version"] = "版本", |
||
106 | ["Current zone"] = "目前区域", |
||
107 | ["<zone>"] = "<区域>", |
||
108 | ["Version query done."] = "完成检查版本", |
||
109 | ["Runs a version query on your current zone."] = "检查当前区域的版本", |
||
110 | ["Closes the version query window."] = "关掉目前的检查版本窗口", |
||
111 | ["current"] = "目前", |
||
112 | ["Runs a version query on the given zone."] = "检查指定区域的版本", |
||
113 | ["Zone"] = "区域", |
||
114 | ["zone"] = "区域", |
||
115 | ["N/A"] = "N/A", |
||
116 | ["BigWigs"] = "BigWigs", |
||
117 | ["Runs a version query on the BigWigs core."] = "检查BigWigs内核的版本", |
||
118 | ["Nr Replies"] = "回复的数量", |
||
119 | ["Ancient"] = "旧的", |
||
120 | } end ) |
||
121 | |||
122 | L:RegisterTranslations("zhTW", function() return { |
||
123 | ["versionquery"] = "檢查版本", |
||
124 | ["Version Query"] = "檢查版本", |
||
125 | ["Commands for querying the raid for Big Wigs versions."] = "用於檢查BigWigs的版本", |
||
126 | ["Query already running, please wait 5 seconds before trying again."] = "檢查中,若要再次檢查,請稍後5秒", |
||
127 | ["Querying versions for "] = "檢查版本 ", |
||
128 | ["Big Wigs Version Query"] = "Big Wigs版本檢查", |
||
129 | ["Close window"] = "關閉窗口", -- I know, it's really a Tablet. |
||
130 | ["Showing version for "] = "顯示版本 ", |
||
131 | ["Green versions are newer than yours, red are older, and white are the same."] = "綠色的版本比你的新,紅色的比較舊,白色則表示版本相同", |
||
132 | ["Player"] = "玩家", |
||
133 | ["Version"] = "版本", |
||
134 | ["Current zone"] = "目前區域", |
||
135 | ["<zone>"] = "<區域>", |
||
136 | ["Version query done."] = "完成檢查版本", |
||
137 | ["Runs a version query on your current zone."] = "檢查目前區域的版本", |
||
138 | ["Closes the version query window."] = "關掉目前的檢查版本視窗", |
||
139 | ["current"] = "目前", |
||
140 | ["Runs a version query on the given zone."] = "檢查指定區域的版本", |
||
141 | ["Zone"] = "區域", |
||
142 | ["zone"] = "區域", |
||
143 | ["N/A"] = "N/A", |
||
144 | ["BigWigs"] = "BigWigs", |
||
145 | ["Runs a version query on the BigWigs core."] = "檢查BigWigs核心的版本", |
||
146 | ["Nr Replies"] = "回復的數量", |
||
147 | ["Ancient"] = "舊的", |
||
148 | } end ) |
||
149 | |||
150 | L:RegisterTranslations("frFR", function() return { |
||
151 | ["Version Query"] = "Vérification des versions", |
||
152 | ["Commands for querying the raid for Big Wigs versions."] = "Commandes de vérification des version de BigWigs du raid.", |
||
153 | ["Query already running, please wait 5 seconds before trying again."] = "Une vérification est déjà en cours, veuillez réessayer dans 5 secondes.", |
||
154 | ["Querying versions for "] = "Vérification des versions pour ", |
||
155 | ["Big Wigs Version Query"] = "Vérification des versions de BigWigs", |
||
156 | ["Close window"] = "Fermer la fenêtre", -- I know, it's really a Tablet. |
||
157 | ["Showing version for "] = "Affichage des versions pour ", |
||
158 | ["Green versions are newer than yours, red are older, and white are the same."] = "Les versions en verte sont plus récentes que vous, celles en rouge plus anciennes, et celles en blanc les mêmes que vous.", |
||
159 | ["Player"] = "Joueur", |
||
160 | --["Version"] = "Version", |
||
161 | ["Current zone"] = "Zone actuelle", |
||
162 | --["<zone>"] = "<zone>", |
||
163 | ["Version query done."] = "Vérification des versions terminée.", |
||
164 | ["Runs a version query on your current zone."] = "Effectue une vérification des versions dans votre zone.", |
||
165 | ["Closes the version query window."] = "Ferme la fenêtre de vérification des versions.", |
||
166 | ["Runs a version query on the given zone."] = "Effectue une vérification des versions dans la zone donnée.", |
||
167 | --["Zone"] = "Zone", |
||
168 | --["N/A"] = "N/A", |
||
169 | --["BigWigs"] = "BigWigs", |
||
170 | ["Runs a version query on the BigWigs core."] = "Effectue une vérification des versions du noyau de BigWigs.", |
||
171 | ["Nr Replies"] = "Nbre de réponses", |
||
172 | ["Ancient"] = "Ancien", |
||
173 | } end ) |
||
174 | |||
175 | --------------------------------- |
||
176 | -- Addon Declaration -- |
||
177 | --------------------------------- |
||
178 | |||
179 | BigWigsVersionQuery = BigWigs:NewModule("Version Query") |
||
180 | |||
181 | BigWigsVersionQuery.consoleCmd = L["versionquery"] |
||
182 | BigWigsVersionQuery.consoleOptions = { |
||
183 | type = "group", |
||
184 | name = L["Version Query"], |
||
185 | desc = L["Commands for querying the raid for Big Wigs versions."], |
||
186 | args = { |
||
187 | [L["BigWigs"]] = { |
||
188 | type = "execute", |
||
189 | name = L["BigWigs"], |
||
190 | desc = L["Runs a version query on the BigWigs core."], |
||
191 | func = function() BigWigsVersionQuery:QueryVersion("BigWigs") end, |
||
192 | }, |
||
193 | [L["current"]] = { |
||
194 | type = "execute", |
||
195 | name = L["Current zone"], |
||
196 | desc = L["Runs a version query on your current zone."], |
||
197 | func = function() BigWigsVersionQuery:QueryVersion() end, |
||
198 | }, |
||
199 | [L["zone"]] = { |
||
200 | type = "text", |
||
201 | name = L["Zone"], |
||
202 | desc = L["Runs a version query on the given zone."], |
||
203 | usage = L["<zone>"], |
||
204 | get = false, |
||
205 | set = function(zone) BigWigsVersionQuery:QueryVersion(zone) end, |
||
206 | }, |
||
207 | } |
||
208 | } |
||
209 | |||
210 | ------------------------------ |
||
211 | -- Initialization -- |
||
212 | ------------------------------ |
||
213 | |||
214 | function BigWigsVersionQuery:OnEnable() |
||
215 | self.queryRunning = nil |
||
216 | self.responseTable = {} |
||
217 | self.zoneRevisions = nil |
||
218 | self.currentZone = "" |
||
219 | |||
220 | BWL = AceLibrary("AceLocale-2.2"):new("BigWigs") |
||
221 | |||
222 | self:RegisterEvent("BigWigs_RecvSync") |
||
223 | self:TriggerEvent("BigWigs_ThrottleSync", "BWVQ", 0) |
||
224 | self:TriggerEvent("BigWigs_ThrottleSync", "BWVR", 0) |
||
225 | end |
||
226 | |||
227 | function BigWigsVersionQuery:PopulateRevisions() |
||
228 | self.zoneRevisions = {} |
||
229 | for name, module in self.core:IterateModules() do |
||
230 | if module:IsBossModule() and module.zonename and type(module.zonename) == "string" then |
||
231 | -- Make sure to get the enUS zone name. |
||
232 | local zone = BZ:HasReverseTranslation(module.zonename) and BZ:GetReverseTranslation(module.zonename) or module.zonename |
||
233 | -- Get the abbreviated name from BW Core. |
||
234 | local zoneAbbr = BWL:HasTranslation(zone) and BWL:GetTranslation(zone) or nil |
||
235 | if not self.zoneRevisions[zone] or module.revision > self.zoneRevisions[zone] then |
||
236 | self.zoneRevisions[zone] = module.revision |
||
237 | end |
||
238 | if zoneAbbr and (not self.zoneRevisions[zoneAbbr] or module.revision > self.zoneRevisions[zoneAbbr]) then |
||
239 | self.zoneRevisions[zoneAbbr] = module.revision |
||
240 | end |
||
241 | end |
||
242 | end |
||
243 | self.zoneRevisions["BigWigs"] = self.core.revision |
||
244 | end |
||
245 | |||
246 | ------------------------------ |
||
247 | -- Event Handlers -- |
||
248 | ------------------------------ |
||
249 | |||
250 | function BigWigsVersionQuery:UpdateVersions() |
||
251 | if not tablet:IsRegistered("BigWigs_VersionQuery") then |
||
252 | tablet:Register("BigWigs_VersionQuery", |
||
253 | "children", function() tablet:SetTitle(L["Big Wigs Version Query"]) |
||
254 | self:OnTooltipUpdate() end, |
||
255 | "clickable", true, |
||
256 | "showTitleWhenDetached", true, |
||
257 | "showHintWhenDetached", true, |
||
258 | "cantAttach", true, |
||
259 | "menu", function() |
||
260 | dewdrop:AddLine( |
||
261 | "text", L["BigWigs"], |
||
262 | "tooltipTitle", L["BigWigs"], |
||
263 | "tooltipText", L["Runs a version query on the BigWigs core."], |
||
264 | "func", function() self:QueryVersion("BigWigs") end) |
||
265 | dewdrop:AddLine( |
||
266 | "text", L["Current zone"], |
||
267 | "tooltipTitle", L["Current zone"], |
||
268 | "tooltipText", L["Runs a version query on your current zone."], |
||
269 | "func", function() self:QueryVersion() end) |
||
270 | dewdrop:AddLine( |
||
271 | "text", L["Close window"], |
||
272 | "tooltipTitle", L["Close window"], |
||
273 | "tooltipText", L["Closes the version query window."], |
||
274 | "func", function() tablet:Attach("BigWigs_VersionQuery"); dewdrop:Close() end) |
||
275 | end |
||
276 | ) |
||
277 | end |
||
278 | if tablet:IsAttached("BigWigs_VersionQuery") then |
||
279 | tablet:Detach("BigWigs_VersionQuery") |
||
280 | else |
||
281 | tablet:Refresh("BigWigs_VersionQuery") |
||
282 | end |
||
283 | end |
||
284 | |||
285 | function BigWigsVersionQuery:OnTooltipUpdate() |
||
286 | local zoneCat = tablet:AddCategory( |
||
287 | "columns", 1, |
||
288 | "text", L["Zone"], |
||
289 | "child_justify1", "LEFT" |
||
290 | ) |
||
291 | zoneCat:AddLine("text", self.currentZone) |
||
292 | local playerscat = tablet:AddCategory( |
||
293 | "columns", 1, |
||
294 | "text", L["Nr Replies"], |
||
295 | "child_justify1", "LEFT" |
||
296 | ) |
||
297 | playerscat:AddLine("text", self.responses) |
||
298 | local cat = tablet:AddCategory( |
||
299 | "columns", 2, |
||
300 | "text", L["Player"], |
||
301 | "text2", L["Version"], |
||
302 | "child_justify1", "LEFT", |
||
303 | "child_justify2", "RIGHT" |
||
304 | ) |
||
305 | for name, version in pairs(self.responseTable) do |
||
306 | if version == -1 then |
||
307 | cat:AddLine("text", name, "text2", "|cff"..COLOR_RED..L["N/A"].."|r") |
||
308 | else |
||
309 | if not self.zoneRevisions then self:PopulateRevisions() end |
||
310 | local color = COLOR_WHITE |
||
311 | if self.zoneRevisions[self.currentZone] and version > self.zoneRevisions[self.currentZone] then |
||
312 | color = COLOR_GREEN |
||
313 | elseif self.zoneRevisions[self.currentZone] and version < self.zoneRevisions[self.currentZone] then |
||
314 | color = COLOR_RED |
||
315 | end |
||
316 | cat:AddLine("text", name, "text2", "|cff"..color..version.."|r") |
||
317 | end |
||
318 | end |
||
319 | |||
320 | tablet:SetHint(L["Green versions are newer than yours, red are older, and white are the same."]) |
||
321 | end |
||
322 | |||
323 | function BigWigsVersionQuery:QueryVersion(zone) |
||
324 | if not self.zoneRevisions then self:PopulateRevisions() end |
||
325 | if self.queryRunning then |
||
326 | self.core:Print(L["Query already running, please wait 5 seconds before trying again."]) |
||
327 | return |
||
328 | end |
||
329 | if not zone or zone == "" then zone = GetRealZoneText() end |
||
330 | -- If this is a shorthand zone, convert it to enUS full. |
||
331 | -- Also, if this is a shorthand, we can't really know if the user is enUS or not. |
||
332 | if BWL:HasReverseTranslation(zone) then |
||
333 | zone = BWL:GetReverseTranslation(zone) |
||
334 | -- If there is a translation for this to GetLocale(), get it, so we can |
||
335 | -- print the zone name in the correct locale. |
||
336 | if BZ:HasTranslation(zone) then |
||
337 | zone = BZ:GetTranslation(zone) |
||
338 | end |
||
339 | end |
||
340 | |||
341 | -- ZZZ |zone| should be translated here. |
||
342 | self.core:Print(L["Querying versions for "].."|cff"..COLOR_GREEN..zone.."|r.") |
||
343 | |||
344 | -- If this is a non-enUS zone, convert it to enUS. |
||
345 | if BZ:HasReverseTranslation(zone) then zone = BZ:GetReverseTranslation(zone) end |
||
346 | |||
347 | self.currentZone = zone |
||
348 | |||
349 | self.queryRunning = true |
||
350 | self:ScheduleEvent( function() |
||
351 | self.queryRunning = nil |
||
352 | self.core:Print(L["Version query done."]) |
||
353 | end, 5) |
||
354 | |||
355 | self.responseTable = {} |
||
356 | if not self.zoneRevisions[zone] then |
||
357 | self.responseTable[UnitName("player")] = -1 |
||
358 | else |
||
359 | self.responseTable[UnitName("player")] = self.zoneRevisions[zone] |
||
360 | end |
||
361 | self.responses = 1 |
||
362 | self:UpdateVersions() |
||
363 | self:TriggerEvent("BigWigs_SendSync", "BWVQ "..zone) |
||
364 | end |
||
365 | |||
366 | --[[ Parses the new style reply, which is "1111 <nick>" ]] |
||
367 | function BigWigsVersionQuery:ParseReply2(reply) |
||
368 | -- If there's no space, it's just a version number we got. |
||
369 | local first, last = string.find(reply, " ") |
||
370 | if not first or not last then return reply, nil end |
||
371 | |||
372 | local rev = string.sub(reply, 1, first) |
||
373 | local nick = string.sub(reply, last + 1, string.len(reply)) |
||
374 | |||
375 | -- We need to check if rev or nick contains ':' - if it does, this is an old |
||
376 | -- style reply. |
||
377 | if tonumber(rev) == nil or string.find(rev, ":") or string.find(nick, ":") then |
||
378 | return self:ParseReply(reply), nil |
||
379 | end |
||
380 | return tonumber(rev), nick |
||
381 | end |
||
382 | |||
383 | --[[ Parses the old style reply, which was MC:REV BWL:REV, etc. ]] |
||
384 | function BigWigsVersionQuery:ParseReply(reply) |
||
385 | if not string.find(reply, ":") then return -1 end |
||
386 | local zone = BWL:HasTranslation(self.currentZone) and BWL:GetTranslation(self.currentZone) or self.currentZone |
||
387 | |||
388 | local zoneIndex, zoneEnd = string.find(reply, zone) |
||
389 | if not zoneIndex then return -1 end |
||
390 | |||
391 | local revision = string.sub(reply, zoneEnd + 2, zoneEnd + 6) |
||
392 | local convertedRev = tonumber(revision) |
||
393 | if revision and convertedRev ~= nil then return convertedRev end |
||
394 | |||
395 | return -1 |
||
396 | end |
||
397 | |||
398 | --[[ |
||
399 | -- Version reply syntax history: |
||
400 | -- Old Style: MC:REV BWL:REV ZG:REV |
||
401 | -- First Working Style: REV |
||
402 | -- New Style: REV QuereeNick |
||
403 | --]] |
||
404 | |||
405 | function BigWigsVersionQuery:BigWigs_RecvSync(sync, rest, nick) |
||
406 | if sync == "BWVQ" and nick ~= UnitName("player") and rest then |
||
407 | if not self.zoneRevisions then self:PopulateRevisions() end |
||
408 | if not self.zoneRevisions[rest] then |
||
409 | self:TriggerEvent("BigWigs_SendSync", "BWVR -1 "..nick) |
||
410 | else |
||
411 | self:TriggerEvent("BigWigs_SendSync", "BWVR " .. self.zoneRevisions[rest] .. " " .. nick) |
||
412 | end |
||
413 | elseif sync == "BWVR" and self.queryRunning and nick and rest then |
||
414 | -- Means it's either a old style or new style reply. |
||
415 | -- The "working style" is just the number, which was the second type of |
||
416 | -- version reply we had. |
||
417 | local revision, queryNick = nil, nil |
||
418 | if tonumber(rest) == nil then |
||
419 | revision, queryNick = self:ParseReply2(rest) |
||
420 | else |
||
421 | revision = tonumber(rest) |
||
422 | end |
||
423 | if queryNick == nil or queryNick == UnitName("player") then |
||
424 | self.responseTable[nick] = tonumber(revision) |
||
425 | self.responses = self.responses + 1 |
||
426 | self:UpdateVersions() |
||
427 | end |
||
428 | end |
||
429 | end |
||
430 |