Mercurial > wow > guild-delta
comparison gd.lua @ 9:be450e79048a
add snapshots
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Thu, 09 Jun 2011 05:48:00 +0000 |
| parents | baf66f6dd093 |
| children | 3961b0cc4642 |
comparison
equal
deleted
inserted
replaced
| 8:215f95b5edc3 | 9:be450e79048a |
|---|---|
| 1 local nametag = ... | 1 local nametag = ... |
| 2 local addon = CreateFrame("Frame") | 2 local addon = CreateFrame("Frame") |
| 3 local L = LibStub("AceLocale-3.0"):GetLocale(nametag) | 3 local L = LibStub("AceLocale-3.0"):GetLocale(nametag) |
| 4 local SV | 4 local SV, SVc |
| 5 | 5 |
| 6 local DEFAULT_CHAT = 2 -- combat log (no constant predefined for that) | 6 local DEFAULT_CHAT = 2 -- combat log (no constant predefined for that) |
| 7 | 7 |
| 8 local guild_selection, log_ever_shown | 8 local guild_selection, log_ever_shown |
| 9 addon.options = { | 9 addon.options = { |
| 141 return type(SV.chatframe) == 'string' and SV.chatframe or nil | 141 return type(SV.chatframe) == 'string' and SV.chatframe or nil |
| 142 end, | 142 end, |
| 143 set = "SetChat", | 143 set = "SetChat", |
| 144 order = 26, | 144 order = 26, |
| 145 }, | 145 }, |
| 146 header = { | |
| 147 name = '', | |
| 148 type = 'header', | |
| 149 order = 30, | |
| 150 }, | |
| 151 snapshot = { | |
| 152 name = L["Snapshot"], | |
| 153 desc = L["Show a text window with the current guild roster."], | |
| 154 type = 'execute', | |
| 155 order = 31, | |
| 156 func = "Snapshot", | |
| 157 }, | |
| 146 }, | 158 }, |
| 147 }, | 159 }, |
| 148 persist = { | 160 persist = { |
| 149 name = L["Logging"], | 161 name = L["Logging"], |
| 150 desc = L["Storing changes for later review"], | 162 desc = L["Storing changes for later review"], |
| 314 self:SetScript("OnEvent", self.GuildUpdate) | 326 self:SetScript("OnEvent", self.GuildUpdate) |
| 315 | 327 |
| 316 self.options.args.version.name = | 328 self.options.args.version.name = |
| 317 "|cff30adffVersion " .. (GetAddOnMetadata(nametag, "Version") or "?") .. "|r" | 329 "|cff30adffVersion " .. (GetAddOnMetadata(nametag, "Version") or "?") .. "|r" |
| 318 LibStub("AceConfig-3.0"):RegisterOptionsTable(nametag, self.options) | 330 LibStub("AceConfig-3.0"):RegisterOptionsTable(nametag, self.options) |
| 319 --[[self.optionsFrame =]] LibStub("AceConfigDialog-3.0"):AddToBlizOptions(nametag, "Guild Delta") | 331 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(nametag, "Guild Delta") |
| 320 self:RegisterChatCommand("guilddelta", "OnChatCommand") | 332 self:RegisterChatCommand("guilddelta", "OnChatCommand") |
| 321 self:SetChat(self) | 333 self:SetChat(self) |
| 322 log_ever_shown = SV.logging | 334 log_ever_shown = SV.logging |
| 323 self.OnEnable = nil | 335 self.OnEnable = nil |
| 324 end | 336 end |
| 371 end | 383 end |
| 372 chatframe = nframe | 384 chatframe = nframe |
| 373 else | 385 else |
| 374 self:Printf(L["'%s' was not a valid chat frame number/name, no change has been made."], n) | 386 self:Printf(L["'%s' was not a valid chat frame number/name, no change has been made."], n) |
| 375 end | 387 end |
| 388 end | |
| 389 | |
| 390 | |
| 391 function addon:Snapshot() | |
| 392 if self.optionsFrame:IsVisible() then | |
| 393 InterfaceOptionsFrameCancel:Click() | |
| 394 HideUIPanel(GameMenuFrame) | |
| 395 else | |
| 396 LibStub("AceConfigDialog-3.0"):Close(nametag) | |
| 397 end | |
| 398 GameTooltip:Hide() | |
| 399 | |
| 400 local tinsert = table.insert | |
| 401 local fmt = "%-20s%-16s%-20s%-20s" | |
| 402 local results = { | |
| 403 fmt:format(CALENDAR_PLAYER_NAME, L["FIELD_rank"], LABEL_NOTE, OFFICER_NOTE_COLON), | |
| 404 ('-'):rep(80), | |
| 405 } | |
| 406 | |
| 407 for _,x in ipairs(SVc) do | |
| 408 tinsert (results, fmt:format(x.name, x.rank or '--', x.pnote or '--', x.onote or '')) | |
| 409 end | |
| 410 | |
| 411 results = table.concat (results, '\n') | |
| 412 | |
| 413 local GUI = LibStub("AceGUI-3.0") | |
| 414 local f = GUI:Create("Frame") | |
| 415 f:SetTitle(nametag) | |
| 416 f:SetStatusText("Use Ctrl-A and Ctrl-C to copy this text to your system clipboard.") | |
| 417 f:SetLayout("Fill") | |
| 418 f:SetStatusTable{width=700} | |
| 419 | |
| 420 local eb = GUI:Create("MultiLineEditBox") | |
| 421 eb:SetFullWidth(true) | |
| 422 eb:SetFullHeight(true) | |
| 423 eb:SetLabel("Pressing the Escape key while typing will return keystroke control to the usual chat window.") | |
| 424 eb:DisableButton(true) | |
| 425 eb:SetText(results) | |
| 426 | |
| 427 f:SetCallback("OnClose", function(_f) | |
| 428 eb:SetText'' -- hmmmm | |
| 429 GUI:Release(_f) | |
| 430 end) | |
| 431 f:AddChild(eb) | |
| 432 eb:SetFocus() | |
| 433 f:ApplyStatus() | |
| 434 f:Show() | |
| 376 end | 435 end |
| 377 | 436 |
| 378 | 437 |
| 379 -- Not a "normal" PLAYER_LOGOUT handler; this only fires if the player is in | 438 -- Not a "normal" PLAYER_LOGOUT handler; this only fires if the player is in |
| 380 -- a guild and the update has already run. | 439 -- a guild and the update has already run. |
| 518 end | 577 end |
| 519 | 578 |
| 520 if SV.logging then self:FinishLog(guild,realm) end | 579 if SV.logging then self:FinishLog(guild,realm) end |
| 521 if SV.notify_nochange and (not changes) then cprt(L["NOCHANGE"]) end | 580 if SV.notify_nochange and (not changes) then cprt(L["NOCHANGE"]) end |
| 522 members[realm][guild] = current | 581 members[realm][guild] = current |
| 582 SVc = current | |
| 523 self:cleanup() | 583 self:cleanup() |
| 524 end | 584 end |
| 525 | 585 |
| 526 | 586 |
| 527 function addon:MakeFieldList() | 587 function addon:MakeFieldList() |
