vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local compost = AceLibrary("Compost-2.0") |
2 | local tablet = AceLibrary("Tablet-2.0") |
||
3 | local BC = AceLibrary("Babble-Class-2.0") |
||
4 | local T = AceLibrary("Tourist-2.0") |
||
5 | local R = AceLibrary("RosterLib-2.0") |
||
6 | local L = AceLibrary("AceLocale-2.0"):new("FuBar_GuildFu") |
||
7 | |||
8 | FuBar_GuildFu = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "FuBarPlugin-2.0") |
||
9 | FuBar_GuildFu.hasIcon = true |
||
10 | FuBar_GuildFu.hasNoColor = true |
||
11 | FuBar_GuildFu.clickableTooltip = true |
||
12 | FuBar_GuildFu:RegisterDB("FuBar_GuildFuDB") |
||
13 | FuBar_GuildFu:RegisterDefaults("profile", { |
||
14 | text = { |
||
15 | show_displayed = true, |
||
16 | show_online = true, |
||
17 | show_total = true, |
||
18 | }, |
||
19 | tooltip = { |
||
20 | sort = "ZONE", |
||
21 | group_show = true, |
||
22 | name_color = "CLASS", |
||
23 | name_status = true, |
||
24 | class_show = false, |
||
25 | level_show = true, |
||
26 | level_color = "RELATIVE", |
||
27 | zone_show = true, |
||
28 | zone_color = "FACTION", |
||
29 | note_showpublic = true, |
||
30 | note_showofficer = true, |
||
31 | note_showauldlangsyne = true, |
||
32 | rank_show = true, |
||
33 | }, |
||
34 | filter = { |
||
35 | class_druid = true, |
||
36 | class_hunter = true, |
||
37 | class_mage = true, |
||
38 | class_paladin = true, |
||
39 | class_priest = true, |
||
40 | class_rogue = true, |
||
41 | class_shaman = true, |
||
42 | class_warlock = true, |
||
43 | class_warrior = true, |
||
44 | level_0109 = true, |
||
45 | level_1019 = true, |
||
46 | level_2029 = true, |
||
47 | level_3039 = true, |
||
48 | level_4049 = true, |
||
49 | level_5059 = true, |
||
50 | level_60 = true, |
||
51 | zone_bg = true, |
||
52 | zone_inst = true, |
||
53 | zone_open = true, |
||
54 | } |
||
55 | }) |
||
56 | |||
57 | function FuBar_GuildFu:OnInitialize() |
||
58 | self.lastUpdate = 0 |
||
59 | end |
||
60 | |||
61 | function FuBar_GuildFu:OnEnable() |
||
62 | self:RegisterEvent("PLAYER_GUILD_UPDATE") |
||
63 | |||
64 | R:Enable() |
||
65 | self:RegisterEvent("RosterLib_RosterChanged", "UpdateTooltip") |
||
66 | |||
67 | if IsInGuild() then |
||
68 | self:ScheduleRepeatingEvent("ScheduledGuildRoster", GuildRoster, 15) |
||
69 | self:RegisterEvent("GUILD_ROSTER_UPDATE") |
||
70 | GuildRoster() |
||
71 | end |
||
72 | end |
||
73 | |||
74 | function FuBar_GuildFu:GUILD_ROSTER_UPDATE() |
||
75 | if not arg1 or (arg1 and arg7 and arg8) then |
||
76 | -- print("[GuildFu] GUILD_ROSTER_UPDATE fired with args...", arg1) |
||
77 | self:Update() |
||
78 | end |
||
79 | end |
||
80 | |||
81 | function FuBar_GuildFu:PLAYER_GUILD_UPDATE() |
||
82 | if IsInGuild() then |
||
83 | if not self:IsEventRegistered("GUILD_ROSTER_UPDATE") then |
||
84 | self:ScheduleRepeatingEvent("ScheduledGuildRoster", GuildRoster, 15) |
||
85 | self:RegisterEvent("GUILD_ROSTER_UPDATE") |
||
86 | end |
||
87 | GuildRoster() |
||
88 | else |
||
89 | if self:IsEventRegistered("GUILD_ROSTER_UPDATE") then |
||
90 | self:CancelScheduledEvent("ScheduledGuildRoster") |
||
91 | self:UnregisterEvent("GUILD_ROSTER_UPDATE") |
||
92 | end |
||
93 | end |
||
94 | end |
||
95 | |||
96 | function FuBar_GuildFu:OnDisable() |
||
97 | R:Disable() |
||
98 | end |
||
99 | |||
100 | local function table_multiinsert(...) |
||
101 | if arg.n < 2 or type(arg[1]) ~= "table" then |
||
102 | return |
||
103 | end |
||
104 | for i = 2, arg.n, 1 do |
||
105 | table.insert(arg[1], arg[i]) |
||
106 | end |
||
107 | end |
||
108 | |||
109 | FuBar_GuildFu.sorts ={ |
||
110 | NAME = function(a,b) |
||
111 | return a[1]<b[1] |
||
112 | end, |
||
113 | CLASS = function(a,b) |
||
114 | if a[5]<b[5] then |
||
115 | return true |
||
116 | elseif a[5]>b[5] then |
||
117 | return false |
||
118 | else |
||
119 | if a[4]<b[4] then |
||
120 | return true |
||
121 | elseif a[4]>b[4] then |
||
122 | return false |
||
123 | else |
||
124 | return FuBar_GuildFu.sorts.NAME(a, b) |
||
125 | end |
||
126 | end |
||
127 | end, |
||
128 | LEVEL = function(a,b) |
||
129 | if a[4]<b[4] then |
||
130 | return true |
||
131 | elseif a[4]>b[4] then |
||
132 | return false |
||
133 | else |
||
134 | if a[5]<b[5] then |
||
135 | return true |
||
136 | elseif a[5]>b[5] then |
||
137 | return false |
||
138 | else |
||
139 | return FuBar_GuildFu.sorts.NAME(a, b) |
||
140 | end |
||
141 | end |
||
142 | end, |
||
143 | ZONE = function(a,b) |
||
144 | if a[6]<b[6] then |
||
145 | return true |
||
146 | elseif a[6]>b[6] then |
||
147 | return false |
||
148 | else |
||
149 | return FuBar_GuildFu.sorts.CLASS(a, b) |
||
150 | end |
||
151 | end, |
||
152 | RANK = function(a,b) |
||
153 | if a[3]<b[3] then |
||
154 | return true |
||
155 | elseif a[3]>b[3] then |
||
156 | return false |
||
157 | else |
||
158 | return FuBar_GuildFu.sorts.CLASS(a, b) |
||
159 | end |
||
160 | end, |
||
161 | } |
||
162 | |||
163 | function FuBar_GuildFu:OnDataUpdate() |
||
164 | if time() <= self.lastUpdate + 1 then return end |
||
165 | self.lastUpdate = time() |
||
166 | |||
167 | if self.players then |
||
168 | self.players = compost.Reclaim(self.players, 1) |
||
169 | end |
||
170 | self.players = compost:Acquire() |
||
171 | self.playersShown = 0 |
||
172 | self.playersOnline = 0 |
||
173 | self.playersTotal = 0 |
||
174 | |||
175 | if IsInGuild() then |
||
176 | SetGuildRosterShowOffline(1) |
||
177 | local numGuildMembers = GetNumGuildMembers() |
||
178 | local name, rank, rankIndex, level, class, zone, note, officernote, online, status |
||
179 | for i = 1, numGuildMembers, 1 do |
||
180 | name, rank, rankIndex, level, class, zone, note, officernote, online, status = GetGuildRosterInfo(i) |
||
181 | if note == "" then note = nil end |
||
182 | if officernote == "" then officernote = nil end |
||
183 | if not zone then zone = UNKNOWN end |
||
184 | if online then |
||
185 | self.playersOnline = self.playersOnline + 1 |
||
186 | if self:checkFilter(class, level, zone) then |
||
187 | self.playersShown = self.playersShown + 1 |
||
188 | table.insert(self.players, compost:Acquire(name, rank, rankIndex, level, class, zone, status, note, officernote)) |
||
189 | end |
||
190 | end |
||
191 | end |
||
192 | table.sort(self.players, self.sorts[self.db.profile.tooltip.sort]) |
||
193 | self.playersTotal = numGuildMembers |
||
194 | SetGuildRosterShowOffline(SHOW_OFFLINE_GUILD_MEMBERS) |
||
195 | end |
||
196 | end |
||
197 | |||
198 | function FuBar_GuildFu:OnTextUpdate() |
||
199 | if not IsInGuild() then |
||
200 | self:SetText(L"No Guild") |
||
201 | return |
||
202 | end |
||
203 | if self.playersTotal == 0 then |
||
204 | self:SetText(L"Updating...") |
||
205 | return |
||
206 | end |
||
207 | |||
208 | local temptext = "" |
||
209 | if self.db.profile.text.show_displayed then |
||
210 | temptext = temptext..self.playersShown |
||
211 | end |
||
212 | if self.db.profile.text.show_online then |
||
213 | if temptext ~= "" then |
||
214 | temptext = temptext.."/" |
||
215 | end |
||
216 | temptext = temptext..self.playersOnline |
||
217 | end |
||
218 | if self.db.profile.text.show_total then |
||
219 | if temptext ~= "" then |
||
220 | temptext = temptext.."/" |
||
221 | end |
||
222 | temptext = temptext..self.playersTotal |
||
223 | end |
||
224 | if temptext ~= "" then |
||
225 | self:SetText(temptext) |
||
226 | else |
||
227 | self:SetText("") |
||
228 | end |
||
229 | end |
||
230 | |||
231 | function FuBar_GuildFu:OnTooltipUpdate() |
||
232 | if not IsInGuild() then |
||
233 | local cat = tablet:AddCategory( |
||
234 | 'columns', 1, |
||
235 | 'text', L"You aren't in a guild.", |
||
236 | 'hideBlankLine', true, |
||
237 | 'showWithoutChildren', true |
||
238 | ) |
||
239 | return |
||
240 | end |
||
241 | |||
242 | if self.playersShown == 0 then |
||
243 | local cat = tablet:AddCategory( |
||
244 | 'columns', 1, |
||
245 | 'text', L"All guild mates offline or filtered.", |
||
246 | 'hideBlankLine', true, |
||
247 | 'showWithoutChildren', true |
||
248 | ) |
||
249 | return |
||
250 | end |
||
251 | |||
252 | local AuldLangSyne_loaded = IsAddOnLoaded("AuldLangSyne") |
||
253 | |||
254 | local cols = compost:Acquire() |
||
255 | table.insert(cols, L"Name") |
||
256 | if self.db.profile.tooltip.class_show then |
||
257 | table.insert(cols, L"Class") |
||
258 | end |
||
259 | if self.db.profile.tooltip.level_show then |
||
260 | table.insert(cols, L"Level") |
||
261 | end |
||
262 | if self.db.profile.tooltip.zone_show then |
||
263 | table.insert(cols, L"Zone") |
||
264 | end |
||
265 | if self.db.profile.tooltip.note_showpublic or (self.db.profile.tooltip.note_showofficer and CanViewOfficerNote()) or (AuldLangSyne_loaded and self.db.profile.tooltip.note_showauldlangsyne) then |
||
266 | table.insert(cols, L"Notes") |
||
267 | end |
||
268 | if self.db.profile.tooltip.rank_show then |
||
269 | table.insert(cols, L"Rank") |
||
270 | end |
||
271 | |||
272 | local cat = tablet:AddCategory( |
||
273 | 'columns', table.getn(cols) |
||
274 | ) |
||
275 | local header = compost:Acquire() |
||
276 | for i = 1, table.getn(cols) do |
||
277 | if i == 1 then |
||
278 | -- table_multiinsert(header, 'text', cols[i], 'textR', 1, 'textG', 1, 'textB', 1, 'justify', "CENTER") |
||
279 | table_multiinsert(header, 'text', cols[i], 'justify', "CENTER") |
||
280 | else |
||
281 | -- table_multiinsert(header, 'text'..i, cols[i], 'text'..i..'R', 1, 'text'..i..'G', 1, 'text'..i..'B', 1, 'justify'..i, "CENTER") |
||
282 | table_multiinsert(header, 'text'..i, cols[i], 'justify'..i, "CENTER") |
||
283 | end |
||
284 | end |
||
285 | cat:AddLine(unpack(header)) |
||
286 | cols = compost:Reclaim(cols) |
||
287 | header = compost:Reclaim(header) |
||
288 | local line |
||
289 | local colcount |
||
290 | local temptext |
||
291 | local classcolorR, classcolorG, classcolorG |
||
292 | local levelcolor |
||
293 | local zonecolorR, zonecolorG, zonecolorB |
||
294 | for i = 1, table.getn(self.players) do |
||
295 | classcolorR, classcolorG, classcolorB = BC:GetColor(self.players[i][5]) |
||
296 | levelcolor = GetDifficultyColor(self.players[i][4]) |
||
297 | line = compost:Acquire() |
||
298 | if self.db.profile.tooltip.name_status and self.players[i][7] ~= "" then |
||
299 | table_multiinsert(line, 'text', self.players[i][7].." "..self.players[i][1]) |
||
300 | else |
||
301 | table_multiinsert(line, 'text', self.players[i][1]) |
||
302 | end |
||
303 | if self.db.profile.tooltip.name_color == "CLASS" then |
||
304 | table_multiinsert(line, 'textR', classcolorR, 'textG', classcolorG, 'textB', classcolorB) |
||
305 | else |
||
306 | table_multiinsert(line, 'textR', 1, 'textG', 1, 'textB', 0) |
||
307 | end |
||
308 | colcount = 1 |
||
309 | if self.db.profile.tooltip.class_show then |
||
310 | colcount = colcount + 1 |
||
311 | table.insert(line, 'text'..colcount) |
||
312 | table.insert(line, self.players[i][5]) |
||
313 | table_multiinsert(line, 'text'..colcount..'R', classcolorR, 'text'..colcount..'G', classcolorG, 'text'..colcount..'B', classcolorB) |
||
314 | end |
||
315 | if self.db.profile.tooltip.level_show then |
||
316 | colcount = colcount + 1 |
||
317 | table.insert(line, 'text'..colcount) |
||
318 | table.insert(line, self.players[i][4]) |
||
319 | table_multiinsert(line, 'text'..colcount..'R', levelcolor.r, 'text'..colcount..'G', levelcolor.g, 'text'..colcount..'B', levelcolor.b) |
||
320 | end |
||
321 | if self.db.profile.tooltip.zone_show then |
||
322 | colcount = colcount + 1 |
||
323 | table.insert(line, 'text'..colcount) |
||
324 | table.insert(line, self.players[i][6]) |
||
325 | if self.db.profile.tooltip.zone_color == "FACTION" then |
||
326 | zonecolorR, zonecolorG, zonecolorB = T:GetFactionColor(self.players[i][6]) |
||
327 | elseif self.db.profile.tooltip.zone_color == "LEVEL" then |
||
328 | zonecolorR, zonecolorG, zonecolorB = T:GetLevelColor(self.players[i][6]) |
||
329 | else |
||
330 | zonecolorR, zonecolorG, zonecolorB = 1, 1, 0 |
||
331 | end |
||
332 | table_multiinsert(line, 'text'..colcount..'R', zonecolorR, 'text'..colcount..'G', zonecolorG, 'text'..colcount..'B', zonecolorB) |
||
333 | end |
||
334 | if self.db.profile.tooltip.note_showpublic or (self.db.profile.tooltip.note_showofficer and CanViewOfficerNote()) or (AuldLangSyne_loaded and self.db.profile.tooltip.note_showauldlangsyne) then |
||
335 | colcount = colcount + 1 |
||
336 | table.insert(line, 'text'..colcount) |
||
337 | temptext = "" |
||
338 | if self.db.profile.tooltip.note_showpublic then |
||
339 | temptext = ((self.players[i][8] and (" ["..self.players[i][8].."] ")) or " - ") |
||
340 | end |
||
341 | if self.db.profile.tooltip.note_showofficer and CanViewOfficerNote() then |
||
342 | temptext = temptext..((self.players[i][9] and (" ["..self.players[i][9].."] ")) or " - ") |
||
343 | end |
||
344 | if AuldLangSyne_loaded and self.db.profile.tooltip.note_showauldlangsyne then |
||
345 | temptext = temptext ..((AuldLangSyne.db.realm.guild[self.players[i][1]] and (" {"..AuldLangSyne.db.realm.guild[self.players[i][1]].."} ")) or "") |
||
346 | end |
||
347 | table.insert(line, temptext) |
||
348 | table_multiinsert(line, 'text'..colcount..'R', 1, 'text'..colcount..'G', 1, 'text'..colcount..'B', 0) |
||
349 | end |
||
350 | if self.db.profile.tooltip.rank_show then |
||
351 | colcount = colcount + 1 |
||
352 | table.insert(line, 'text'..colcount) |
||
353 | table.insert(line, self.players[i][2]) |
||
354 | table_multiinsert(line, 'text'..colcount..'R', 1, 'text'..colcount..'G', 1, 'text'..colcount..'B', 0) |
||
355 | end |
||
356 | table_multiinsert(line, 'func', 'OnNameClick', 'arg1', self, 'arg2', self.players[i][1]) |
||
357 | if self.db.profile.tooltip.group_show then |
||
358 | table_multiinsert(line, 'hasCheck', true, 'checked', R:GetUnitIDFromName(self.players[i][1]) and true) |
||
359 | -- 'checkIcon', self.factions[i].isCollapsed and "Interface\\Buttons\\UI-PlusButton-Up" or "Interface\\Buttons\\UI-MinusButton-Up", |
||
360 | end |
||
361 | |||
362 | cat:AddLine(unpack(line)) |
||
363 | line = compost:Reclaim(line) |
||
364 | end |
||
365 | end |
||
366 | |||
367 | function FuBar_GuildFu:OnClick() |
||
368 | ToggleFriendsFrame(3) |
||
369 | end |
||
370 | |||
371 | function FuBar_GuildFu:OnNameClick(name) |
||
372 | if not name then return end |
||
373 | if IsAltKeyDown() then |
||
374 | InviteByName(name) |
||
375 | else |
||
376 | SetItemRef("player:"..name, "|Hplayer:"..name.."|h["..name.."|h", "LeftButton") |
||
377 | end |
||
378 | end |
||
379 | |||
380 | function FuBar_GuildFu:checkFilter(class, level, zone) |
||
381 | if not self.db.profile.filter.class_druid and class == BC"Druid" then return false end |
||
382 | if not self.db.profile.filter.class_hunter and class == BC"Hunter" then return false end |
||
383 | if not self.db.profile.filter.class_mage and class == BC"Mage" then return false end |
||
384 | if not self.db.profile.filter.class_paladin and class == BC"Paladin" then return false end |
||
385 | if not self.db.profile.filter.class_priest and class == BC"Priest" then return false end |
||
386 | if not self.db.profile.filter.class_rogue and class == BC"Rogue" then return false end |
||
387 | if not self.db.profile.filter.class_shaman and class == BC"Shaman" then return false end |
||
388 | if not self.db.profile.filter.class_warlock and class == BC"Warlock" then return false end |
||
389 | if not self.db.profile.filter.class_warrior and class == BC"Warrior" then return false end |
||
390 | |||
391 | if not self.db.profile.filter.level_0109 and level < 10 then return false end |
||
392 | if not self.db.profile.filter.level_1019 and level >= 10 and level < 20 then return false end |
||
393 | if not self.db.profile.filter.level_2029 and level >= 20 and level < 30 then return false end |
||
394 | if not self.db.profile.filter.level_3039 and level >= 30 and level < 40 then return false end |
||
395 | if not self.db.profile.filter.level_4049 and level >= 40 and level < 50 then return false end |
||
396 | if not self.db.profile.filter.level_5059 and level >= 50 and level < 60 then return false end |
||
397 | if not self.db.profile.filter.level_60 and level == 60 then return false end |
||
398 | |||
399 | if not self.db.profile.filter.zone_bg and T:IsBattleground(zone) then return false end |
||
400 | if not self.db.profile.filter.zone_inst and T:IsInstance(zone) and not T:IsBattleground(zone) then return false end |
||
401 | if not self.db.profile.filter.zone_open and T:IsZone(zone) then return false end |
||
402 | |||
403 | return true |
||
404 | end |