Mercurial > wow > guild-delta
comparison gd.lua @ 2:fb9a91642a60
Warn on large logfile. Avoid reporting to minimized frames.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Fri, 05 Nov 2010 03:57:42 +0000 |
| parents | f7c747904387 |
| children | 7b31138c3c8e |
comparison
equal
deleted
inserted
replaced
| 1:f7c747904387 | 2:fb9a91642a60 |
|---|---|
| 65 --func = print_chatframes filled in below | 65 --func = print_chatframes filled in below |
| 66 order = 10, | 66 order = 10, |
| 67 }, | 67 }, |
| 68 chatframe_num = { | 68 chatframe_num = { |
| 69 name = "Output Chatframe", | 69 name = "Output Chatframe", |
| 70 desc = "Which chat window to use for printing all the output during login", | 70 desc = "Which chat window to prefer for printing all the output during login", |
| 71 type = 'range', | 71 type = 'range', |
| 72 min = 1, | 72 min = 1, |
| 73 max = NUM_CHAT_WINDOWS, | 73 max = NUM_CHAT_WINDOWS, |
| 74 step = 1, | 74 step = 1, |
| 75 get = function() return tonumber(SV.chatframe) or --[[in case of custom name]]DEFAULT_CHAT end, | 75 get = function() return tonumber(SV.chatframe) or --[[in case of custom name]]DEFAULT_CHAT end, |
| 218 return ret | 218 return ret |
| 219 end | 219 end |
| 220 | 220 |
| 221 function addon.options.args.print_chatframes.func() | 221 function addon.options.args.print_chatframes.func() |
| 222 for i = 1, NUM_CHAT_WINDOWS do | 222 for i = 1, NUM_CHAT_WINDOWS do |
| 223 local cf = _G["ChatFrame"..i] | 223 local cf = _G['ChatFrame'..i] |
| 224 if not cf then break end | 224 if not cf then break end |
| 225 addon:Print(cf, "This is frame number", i) | 225 addon:Print(cf, "This is frame number", i) |
| 226 end | 226 end |
| 227 end | 227 end |
| 228 | 228 |
| 237 "Enabling logging will accumulate the text of the 'deltas' as you see them. ".. | 237 "Enabling logging will accumulate the text of the 'deltas' as you see them. ".. |
| 238 "This can grow large over time, depending on the activity of your guilds, so you ".. | 238 "This can grow large over time, depending on the activity of your guilds, so you ".. |
| 239 "should use the Reset Log button below from time to time.\n\n".. | 239 "should use the Reset Log button below from time to time.\n\n".. |
| 240 "If you click inside the text area below, you can use Control-A to select all ".. | 240 "If you click inside the text area below, you can use Control-A to select all ".. |
| 241 "the text, and Control-C to copy it to your computer's clipboard. If you make ".. | 241 "the text, and Control-C to copy it to your computer's clipboard. If you make ".. |
| 242 "any changes to the text, they will be preserved. (You can remove uninteresting ".. | 242 "any changes to the text, the changes will be preserved. (You can remove uninteresting ".. |
| 243 "changes, add reminders to yourself, and so forth.)\n\n" | 243 "changes, add reminders to yourself, and so forth.)\n\n" |
| 244 | 244 |
| 245 | 245 |
| 246 ----------------------------------------------------------------------------- | 246 ----------------------------------------------------------------------------- |
| 247 addon = LibStub("AceAddon-3.0"):NewAddon(addon, "GuildDelta", | 247 addon = LibStub("AceAddon-3.0"):NewAddon(addon, "GuildDelta", |
| 267 self.unload = nil | 267 self.unload = nil |
| 268 self.logquay = nil | 268 self.logquay = nil |
| 269 self.AddLogNote = nil | 269 self.AddLogNote = nil |
| 270 self.FinishLog = nil | 270 self.FinishLog = nil |
| 271 end | 271 end |
| 272 -- Remove everything. | |
| 272 function addon:unload() | 273 function addon:unload() |
| 273 self:cleanup() | 274 self:cleanup() |
| 274 LibStub("AceAddon-3.0").addons["GuildDelta"] = nil | 275 LibStub("AceAddon-3.0").addons["GuildDelta"] = nil |
| 275 l10n = nil; addon = nil; | 276 l10n = nil; addon = nil; |
| 276 -- put the userdata back so it counts as a Frame object again | 277 -- put the userdata back so it counts as a Frame object again |
| 292 self.options.args.version.name = | 293 self.options.args.version.name = |
| 293 "|cff30adffVersion " .. (GetAddOnMetadata("GuildDelta", "Version") or "?") .. "|r" | 294 "|cff30adffVersion " .. (GetAddOnMetadata("GuildDelta", "Version") or "?") .. "|r" |
| 294 LibStub("AceConfig-3.0"):RegisterOptionsTable("GuildDelta", self.options) | 295 LibStub("AceConfig-3.0"):RegisterOptionsTable("GuildDelta", self.options) |
| 295 --[[self.optionsFrame =]] LibStub("AceConfigDialog-3.0"):AddToBlizOptions("GuildDelta", "Guild Delta") | 296 --[[self.optionsFrame =]] LibStub("AceConfigDialog-3.0"):AddToBlizOptions("GuildDelta", "Guild Delta") |
| 296 self:RegisterChatCommand("guilddelta", "OnChatCommand") | 297 self:RegisterChatCommand("guilddelta", "OnChatCommand") |
| 297 self:SetChat(false) | 298 self:SetChat(self) |
| 298 log_ever_shown = SV.logging | 299 log_ever_shown = SV.logging |
| 299 self.OnEnable = nil | 300 self.OnEnable = nil |
| 300 end | 301 end |
| 301 | 302 |
| 302 | 303 |
| 307 LibStub("AceConfigCmd-3.0").HandleCommand(self, "guilddelta", "GuildDelta", input) | 308 LibStub("AceConfigCmd-3.0").HandleCommand(self, "guilddelta", "GuildDelta", input) |
| 308 end | 309 end |
| 309 end | 310 end |
| 310 | 311 |
| 311 | 312 |
| 312 -- 0 args: called during startup to initialize | 313 -- 1 arg: (self) called during startup to initialize |
| 313 -- 1 arg: resetting via menus to defaults (see arg field) | 314 -- (other) resetting via menus to defaults (see arg field) |
| 314 -- 2 args: setting via menus to new value, number or custom name | 315 -- 2 args: setting via menus to new value, number or custom name (see value) |
| 315 function addon:SetChat (info, value) | 316 function addon:SetChat (info, value) |
| 316 local n, nframe | 317 local n, nframe |
| 317 if info then -- coming via menu | 318 local isauto = info == self |
| 319 if isauto then | |
| 320 n = SV.chatframe | |
| 321 else -- coming via menu | |
| 318 n = info.arg or value | 322 n = info.arg or value |
| 323 end | |
| 324 if type(n) == 'number' then | |
| 325 if isauto then | |
| 326 -- start at the preferred number and find a non-minimized and | |
| 327 -- potentially visible frame | |
| 328 n = math.min(n,NUM_CHAT_WINDOWS) | |
| 329 local cf,cft | |
| 330 for i = n, 1, -1 do | |
| 331 cf = _G['ChatFrame'..i] | |
| 332 cft = _G[cf:GetName()..'Tab'] | |
| 333 if cft:IsVisible() then | |
| 334 n = i | |
| 335 break | |
| 336 end | |
| 337 end | |
| 338 end | |
| 339 nframe = _G['ChatFrame'..n] | |
| 319 else | 340 else |
| 320 n = SV.chatframe | 341 nframe = _G[n] -- advanced name |
| 321 end | |
| 322 if type(n) == 'number' then | |
| 323 nframe = _G["ChatFrame"..n] | |
| 324 else | |
| 325 nframe = _G[n] | |
| 326 end | 342 end |
| 327 if type(nframe) == 'table' and type(nframe.AddMessage) == 'function' then | 343 if type(nframe) == 'table' and type(nframe.AddMessage) == 'function' then |
| 328 if type(info) ~= 'boolean' then | 344 if not isauto then |
| 345 SV.chatframe = n | |
| 329 self:Print("Now printing to chat frame", n, | 346 self:Print("Now printing to chat frame", n, |
| 330 (type(nframe.name)=='string' and ("(".. nframe.name .. ")") or "")) | 347 (type(nframe.name)=='string' and ("(".. nframe.name .. ")") or "")) |
| 331 end | 348 end |
| 332 SV.chatframe = n | |
| 333 chatframe = nframe | 349 chatframe = nframe |
| 334 else | 350 else |
| 335 self:Printf("EEEEEEEK! '%s' was not a valid chat frame number/name, no change has been made.", n) | 351 self:Printf("EEEEEEEK! '%s' was not a valid chat frame number/name, no change has been made.", n) |
| 336 end | 352 end |
| 337 end | 353 end |
| 354 end | 370 end |
| 355 self:UnregisterEvent("GUILD_ROSTER_UPDATE") | 371 self:UnregisterEvent("GUILD_ROSTER_UPDATE") |
| 356 self:SetScript("OnEvent", self.PLAYER_LOGOUT) -- keepin' it real^H^H^H^Hsmall and kludgey | 372 self:SetScript("OnEvent", self.PLAYER_LOGOUT) -- keepin' it real^H^H^H^Hsmall and kludgey |
| 357 self:RegisterEvent("PLAYER_LOGOUT") | 373 self:RegisterEvent("PLAYER_LOGOUT") |
| 358 self.GuildUpdate = nil | 374 self.GuildUpdate = nil |
| 375 | |
| 376 if SV.logtext and #SV.logtext > 20000 then | |
| 377 self:Print("Your accumulated logfile has grown rather large; you should consider copying it out and clearing it.") | |
| 378 end | |
| 359 | 379 |
| 360 local guild, realm = (GetGuildInfo("player")), GetRealmName() | 380 local guild, realm = (GetGuildInfo("player")), GetRealmName() |
| 361 local members = SV.members | 381 local members = SV.members |
| 362 if members[realm] | 382 if members[realm] |
| 363 and members[realm][guild] | 383 and members[realm][guild] |
| 367 else | 387 else |
| 368 -- new user, or new guild, or any number of things | 388 -- new user, or new guild, or any number of things |
| 369 self:Print("GuildDelta initializing roster...") | 389 self:Print("GuildDelta initializing roster...") |
| 370 members[realm] = members[realm] or {} | 390 members[realm] = members[realm] or {} |
| 371 members[realm][guild] = self:current_guild_info(current_n) | 391 members[realm][guild] = self:current_guild_info(current_n) |
| 372 return | 392 return self:cleanup() |
| 373 end | 393 end |
| 374 | 394 |
| 375 -- table.insert with notes if available | 395 -- table.insert with notes if available |
| 376 -- concatentation of all strings faster than string.format | 396 -- concatentation of all strings faster than string.format |
| 377 local function tins (t, x) | 397 local function tins (t, x) |
| 468 end | 488 end |
| 469 end | 489 end |
| 470 | 490 |
| 471 if SV.logging then self:FinishLog(guild,realm) end | 491 if SV.logging then self:FinishLog(guild,realm) end |
| 472 members[realm][guild] = current | 492 members[realm][guild] = current |
| 493 self:cleanup() | |
| 473 end | 494 end |
| 474 | 495 |
| 475 | 496 |
| 476 function addon:MakeFieldList() | 497 function addon:MakeFieldList() |
| 477 if not fieldlist then | 498 if not fieldlist then |
