changeset 9:be450e79048a

add snapshots
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 09 Jun 2011 05:48:00 +0000
parents 215f95b5edc3
children 89babe1c1f6e
files gd.lua
diffstat 1 files changed, 62 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gd.lua	Tue Apr 26 21:42:16 2011 +0000
+++ b/gd.lua	Thu Jun 09 05:48:00 2011 +0000
@@ -1,7 +1,7 @@
 local nametag = ...
 local addon = CreateFrame("Frame")
 local L = LibStub("AceLocale-3.0"):GetLocale(nametag)
-local SV
+local SV, SVc
 
 local DEFAULT_CHAT = 2   -- combat log (no constant predefined for that)
 
@@ -143,6 +143,18 @@
 					set = "SetChat",
 					order = 26,
 				},
+				header = {
+					name = '',
+					type = 'header',
+					order = 30,
+				},
+				snapshot = {
+					name = L["Snapshot"],
+					desc = L["Show a text window with the current guild roster."],
+					type = 'execute',
+					order = 31,
+					func = "Snapshot",
+				},
 			},
 		},
 		persist = {
@@ -316,7 +328,7 @@
 	self.options.args.version.name =
 		"|cff30adffVersion " .. (GetAddOnMetadata(nametag, "Version") or "?") .. "|r"
 	LibStub("AceConfig-3.0"):RegisterOptionsTable(nametag, self.options)
-	--[[self.optionsFrame =]] LibStub("AceConfigDialog-3.0"):AddToBlizOptions(nametag, "Guild Delta")
+	self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(nametag, "Guild Delta")
 	self:RegisterChatCommand("guilddelta", "OnChatCommand")
 	self:SetChat(self)
 	log_ever_shown = SV.logging
@@ -376,6 +388,53 @@
 end
 
 
+function addon:Snapshot()
+	if self.optionsFrame:IsVisible() then
+		InterfaceOptionsFrameCancel:Click()
+		HideUIPanel(GameMenuFrame)
+	else
+		LibStub("AceConfigDialog-3.0"):Close(nametag)
+	end
+	GameTooltip:Hide()
+
+	local tinsert = table.insert
+	local fmt = "%-20s%-16s%-20s%-20s"
+	local results = {
+		fmt:format(CALENDAR_PLAYER_NAME, L["FIELD_rank"], LABEL_NOTE, OFFICER_NOTE_COLON),
+		('-'):rep(80),
+	}
+
+	for _,x in ipairs(SVc) do
+		tinsert (results, fmt:format(x.name, x.rank or '--', x.pnote or '--', x.onote or ''))
+	end
+
+	results = table.concat (results, '\n')
+
+	local GUI = LibStub("AceGUI-3.0")
+	local f = GUI:Create("Frame")
+	f:SetTitle(nametag)
+	f:SetStatusText("Use Ctrl-A and Ctrl-C to copy this text to your system clipboard.")
+	f:SetLayout("Fill")
+	f:SetStatusTable{width=700}
+
+	local eb = GUI:Create("MultiLineEditBox")
+	eb:SetFullWidth(true)
+	eb:SetFullHeight(true)
+	eb:SetLabel("Pressing the Escape key while typing will return keystroke control to the usual chat window.")
+	eb:DisableButton(true)
+	eb:SetText(results)
+
+	f:SetCallback("OnClose", function(_f)
+		eb:SetText''   -- hmmmm
+		GUI:Release(_f)
+	end)
+	f:AddChild(eb)
+	eb:SetFocus()
+	f:ApplyStatus()
+	f:Show()
+end
+
+
 -- Not a "normal" PLAYER_LOGOUT handler; this only fires if the player is in
 -- a guild and the update has already run.
 function addon:PLAYER_LOGOUT()
@@ -520,6 +579,7 @@
 	if SV.logging then self:FinishLog(guild,realm) end
 	if SV.notify_nochange and (not changes) then cprt(L["NOCHANGE"]) end
 	members[realm][guild] = current
+	SVc = current
 	self:cleanup()
 end