/trunk
GuildTracker = LibStub("AceAddon-3.0"):NewAddon("GuildTracker", "AceBucket-3.0", "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0") |
local DB_VERSION = 1 |
local ICON_DELETE = "|TInterface\\Buttons\\UI-GroupLoot-Pass-Up:16:16:0:0:16:16:0:16:0:16|t" |
local ICON_CHAT = "|TInterface\\ChatFrame\\UI-ChatWhisperIcon:16:16:0:0:16:16:0:16:0:16|t" |
Active = 8, |
LevelChange = 9, |
NoteChange = 10, |
NameChange = 11, |
OfficerNoteChange = 11, |
NameChange = 12, |
} |
local StateInfo = { |
template = "has gone up %d level%s and is now %d", |
}, |
[State.NoteChange] = { |
color = RGB2HEX(0.75,0.55,0.55), |
color = RGB2HEX(0.79,0.58,0.58), |
category = "Note", |
shorttext = "Note change", |
longtext = "got a new guild note", |
template = "note changed from \"%s\" to \"%s\"", |
}, |
[State.OfficerNoteChange] = { |
color = RGB2HEX(0.65,0.45,0.45), |
category = "Note", |
shorttext = "Officer note change", |
longtext = "got a new officer note", |
template = "officer note changed from \"%s\" to \"%s\"", |
}, |
[State.NameChange] = { |
color = RGB2HEX(0.3,0.75,0.3), |
category = "Name", |
self:Print(string.format("Creating new database for guild '%s'", guildname)) |
self.db.realm.guild[guildname] = { |
updated = time(), |
version = DB_VERSION, |
roster = {}, |
changes = {} |
} |
end |
self.GuildDB = self.db.realm.guild[guildname] |
self:UpgradeGuildDatabase() |
end |
-------------------------------------------------------------------------------- |
function GuildTracker:UpgradeGuildDatabase() |
-------------------------------------------------------------------------------- |
if self.GuildDB.version == nil then |
self:Debug("Upgrading database to version 1") |
self.GuildDB.version = 1 |
self.GuildDB.isOfficer = CanViewOfficerNote() |
end |
end |
-------------------------------------------------------------------------------- |
function GuildTracker:UpdateGuildRoster() |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
function GuildTracker:UpdateGuildChanges() |
-------------------------------------------------------------------------------- |
-- We don't know what guild we're updating yet |
if self.GuildDB == nil then |
return |
end |
-- Fail-safe when the roster returned 0 guild members; this can't be right so ignore |
if #self.GuildRoster == 0 then |
return |
end |
local oldRoster = self.GuildDB.roster |
-- If there's no saved roster data available, we can't determine any changes yet |
self:AddGuildChange(State.NoteChange, info, newPlayerInfo) |
end |
if newPlayerInfo[Field.OfficerNote] ~= info[Field.OfficerNote] and self.GuildDB.isOfficer == CanViewOfficerNote() then |
self:AddGuildChange(State.OfficerNoteChange, info, newPlayerInfo) |
end |
end |
end |
end |
self.GuildDB.updated = self.LastRosterUpdate |
self.GuildDB.isOfficer = CanViewOfficerNote() |
self:Debug(string.format("Roster: %d added, %d removed, %d updated", added, removed, updated)) |
end |
local oldName = change.oldinfo[Field.Name] |
local newName = change.newinfo[Field.Name] |
template = string.format(template, newName) |
elseif state == State.OfficerNoteChange then |
local oldNote = change.oldinfo[Field.OfficerNote] |
local newNote = change.newinfo[Field.OfficerNote] |
template = string.format(template, oldNote, newNote) |
end |
return stateColor, shortText, longText, template, category |
local txtName = RAID_CLASS_COLORS_hex[item[Field.Class]] .. item[Field.Name] |
local txtLevel = item[Field.Level] |
local txtRank = GuildControlGetRankName(item[Field.Rank]+1) |
local txtNote = item[Field.Note] |
local txtNote = (changeType == State.OfficerNoteChange) and item[Field.OfficerNote] or item[Field.Note] |
local txtOffline = self:GetFormattedLastOnline(item[Field.LastOnline]) |
local txtTimestamp, fullTimestamp = self:GetFormattedTimestamp(changeItem.timestamp) |
txtNote = CLR_YELLOW .. txtNote |
elseif changeType == State.NameChange then |
oldName = changeItem.oldinfo[Field.Name] |
elseif changeType == State.OfficerNoteChange then |
oldNote = changeItem.oldinfo[Field.OfficerNote] |
txtNote = CLR_YELLOW .. txtNote |
end |
lineNum = tooltip:AddLine() |
lineNum, colNum = tooltip:SetCell(lineNum, colNum, txtNote) |
if oldNote then |
tooltip:SetCellScript(lineNum, colNum-1, "OnEnter", ShowSimpleTooltip, {"Previous note: ", oldNote}) |
local caption = (changeType == State.OfficerNoteChange) and "Previous officer note: " or "Previous note: " |
tooltip:SetCellScript(lineNum, colNum-1, "OnEnter", ShowSimpleTooltip, {caption, oldNote}) |
tooltip:SetCellScript(lineNum, colNum-1, "OnLeave", HideSimpleTooltip) |
end |
## Title: Guild Tracker |
## Notes: Keeps track of changes in the guild roster between logins, and also shows who disabled their account |
## Author: Dracula |
## Version: 5.0.5-1 |
## Version: 5.0.5-2 |
## SavedVariables: GuildTrackerDB |
embeds.xml |
GuildTracker.lua |
GuildTracker.lua |