Code:
local GLogCopyFrame = CreateFrame("Frame", "GLogCopyFrame", UIParent)
tinsert(UISpecialFrames, "GLogCopyFrame")
GLogCopyFrame:SetBackdrop({
bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 3, right = 3, top = 5, bottom = 3 }
})
GLogCopyFrame:SetBackdropColor(0,0,0,1)
GLogCopyFrame:SetWidth(500)
GLogCopyFrame:SetHeight(400)
GLogCopyFrame:SetPoint("CENTER", UIParent, "CENTER")
GLogCopyFrame:Hide()
GLogCopyFrame:SetFrameStrata("DIALOG")
GLogCopyFrame:SetToplevel(true)
local scrollArea = CreateFrame("ScrollFrame", "GLogCopyScroll", GLogCopyFrame, "UIPanelScrollFrameTemplate")
scrollArea:SetPoint("TOPLEFT", GLogCopyFrame, "TOPLEFT", 8, -30)
scrollArea:SetPoint("BOTTOMRIGHT", GLogCopyFrame, "BOTTOMRIGHT", -30, 8)
local editBox = CreateFrame("EditBox", nil, GLogCopyFrame)
editBox:SetMultiLine(true)
editBox:SetMaxLetters(99999)
editBox:EnableMouse(true)
editBox:SetAutoFocus(false)
editBox:SetFontObject(ChatFontNormal)
editBox:SetWidth(400)
editBox:SetHeight(270)
editBox:SetScript("OnEscapePressed", function(self)
if self:HasFocus() then
self:ClearFocus()
else
GLogCopyFrame:Hide()
end
end)
GLogCopyFrame.editBox = editBox
scrollArea:SetScrollChild(editBox)
local close = CreateFrame("Button", nil, GLogCopyFrame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", GLogCopyFrame, "TOPRIGHT")
local button = CreateFrame("Button")
local Sanitize = function(text)
button:SetText(text)
return button:GetText()
end
GLogCopyFrame.On_Show = function(self)
GLogCopyFrame:RegisterEvent("GUILD_EVENT_LOG_UPDATE")
QueryGuildEventLog()
end
GLogCopyFrame.On_Hide = function(self)
GLogCopyFrame.editBox:SetText("")
GLogCopyFrame:UnregisterEvent("GUILD_EVENT_LOG_UPDATE")
end
GLogCopyFrame.On_Event = function(self,event,...)
GLogCopyFrame.editBox:SetText("")
local numEvents = GetNumGuildEvents()
local evtype, player1, player2, rank, year, month, day, hour
local msg
local buffer = ""
for i = numEvents, 1, -1 do
evtype, player1, player2, rank, year, month, day, hour = GetGuildEventInfo(i)
if ( not player1 ) then
player1 = UNKNOWN
end
if ( not player2 ) then
player2 = UNKNOWN
end
if ( evtype == "invite" ) then
msg = format(GUILDEVENT_TYPE_INVITE, player1, player2)
elseif ( evtype == "join" ) then
msg = format(GUILDEVENT_TYPE_JOIN, player1)
elseif ( evtype == "promote" ) then
msg = format(GUILDEVENT_TYPE_PROMOTE, player1, player2, rank)
elseif ( evtype == "demote" ) then
msg = format(GUILDEVENT_TYPE_DEMOTE, player1, player2, rank)
elseif ( evtype == "remove" ) then
msg = format(GUILDEVENT_TYPE_REMOVE, player1, player2)
elseif ( evtype == "quit" ) then
msg = format(GUILDEVENT_TYPE_QUIT, player1)
end
if ( msg ) then
buffer = buffer..msg.."|cff009999 "..format(GUILD_BANK_LOG_TIME, Sanitize(RecentTimeDate(year, month, day, hour))).."|r|n"
end
end
GLogCopyFrame.editBox:SetText(buffer)
end
GLogCopyFrame:SetScript("OnShow",GLogCopyFrame.On_Show)
GLogCopyFrame:SetScript("OnHide",GLogCopyFrame.On_Hide)
GLogCopyFrame:SetScript("OnEvent",GLogCopyFrame.On_Event)
SLASH_GLOGCPY1 = "/glogcpy"
SlashCmdList.GLOGCPY = function()
GLogCopyFrame:SetShown(not GLogCopyFrame:IsShown())
end
Drycoded for the most part.
I'm assuming your goal was to get the guild log someplace to copy it from.
/glogcpy should show the editbox with the guild log, ctrl+a to select all, ctrl+c to copy.
To turn this code into an addon you can use
http://addon.bool.no/