Mercurial > wow > guild-delta
changeset 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 |
files | gd.lua |
diffstat | 1 files changed, 36 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/gd.lua Mon Nov 01 18:36:46 2010 +0000 +++ b/gd.lua Fri Nov 05 03:57:42 2010 +0000 @@ -67,7 +67,7 @@ }, chatframe_num = { name = "Output Chatframe", - desc = "Which chat window to use for printing all the output during login", + desc = "Which chat window to prefer for printing all the output during login", type = 'range', min = 1, max = NUM_CHAT_WINDOWS, @@ -220,7 +220,7 @@ function addon.options.args.print_chatframes.func() for i = 1, NUM_CHAT_WINDOWS do - local cf = _G["ChatFrame"..i] + local cf = _G['ChatFrame'..i] if not cf then break end addon:Print(cf, "This is frame number", i) end @@ -239,7 +239,7 @@ "should use the Reset Log button below from time to time.\n\n".. "If you click inside the text area below, you can use Control-A to select all ".. "the text, and Control-C to copy it to your computer's clipboard. If you make ".. -"any changes to the text, they will be preserved. (You can remove uninteresting ".. +"any changes to the text, the changes will be preserved. (You can remove uninteresting ".. "changes, add reminders to yourself, and so forth.)\n\n" @@ -269,6 +269,7 @@ self.AddLogNote = nil self.FinishLog = nil end +-- Remove everything. function addon:unload() self:cleanup() LibStub("AceAddon-3.0").addons["GuildDelta"] = nil @@ -294,7 +295,7 @@ LibStub("AceConfig-3.0"):RegisterOptionsTable("GuildDelta", self.options) --[[self.optionsFrame =]] LibStub("AceConfigDialog-3.0"):AddToBlizOptions("GuildDelta", "Guild Delta") self:RegisterChatCommand("guilddelta", "OnChatCommand") - self:SetChat(false) + self:SetChat(self) log_ever_shown = SV.logging self.OnEnable = nil end @@ -309,27 +310,42 @@ end --- 0 args: called during startup to initialize --- 1 arg: resetting via menus to defaults (see arg field) --- 2 args: setting via menus to new value, number or custom name +-- 1 arg: (self) called during startup to initialize +-- (other) resetting via menus to defaults (see arg field) +-- 2 args: setting via menus to new value, number or custom name (see value) function addon:SetChat (info, value) local n, nframe - if info then -- coming via menu + local isauto = info == self + if isauto then + n = SV.chatframe + else -- coming via menu n = info.arg or value - else - n = SV.chatframe end if type(n) == 'number' then - nframe = _G["ChatFrame"..n] + if isauto then + -- start at the preferred number and find a non-minimized and + -- potentially visible frame + n = math.min(n,NUM_CHAT_WINDOWS) + local cf,cft + for i = n, 1, -1 do + cf = _G['ChatFrame'..i] + cft = _G[cf:GetName()..'Tab'] + if cft:IsVisible() then + n = i + break + end + end + end + nframe = _G['ChatFrame'..n] else - nframe = _G[n] + nframe = _G[n] -- advanced name end if type(nframe) == 'table' and type(nframe.AddMessage) == 'function' then - if type(info) ~= 'boolean' then + if not isauto then + SV.chatframe = n self:Print("Now printing to chat frame", n, (type(nframe.name)=='string' and ("(".. nframe.name .. ")") or "")) end - SV.chatframe = n chatframe = nframe else self:Printf("EEEEEEEK! '%s' was not a valid chat frame number/name, no change has been made.", n) @@ -357,6 +373,10 @@ self:RegisterEvent("PLAYER_LOGOUT") self.GuildUpdate = nil + if SV.logtext and #SV.logtext > 20000 then + self:Print("Your accumulated logfile has grown rather large; you should consider copying it out and clearing it.") + end + local guild, realm = (GetGuildInfo("player")), GetRealmName() local members = SV.members if members[realm] @@ -369,7 +389,7 @@ self:Print("GuildDelta initializing roster...") members[realm] = members[realm] or {} members[realm][guild] = self:current_guild_info(current_n) - return + return self:cleanup() end -- table.insert with notes if available @@ -470,6 +490,7 @@ if SV.logging then self:FinishLog(guild,realm) end members[realm][guild] = current + self:cleanup() end