/trunk
local t = CreateFrame"Frame" |
local block, isGuild, leaving, horde, config |
local defaultConfig = { showGuildNotes = true, showGuildName = true, sortType = "class", sortDESC = false } |
local defaultConfig = { showGuildNotes = true, showGuildName = true, sortType = "class", sortDESC = false, fontSize=12 } |
local guildEntries, friendEntries = {}, {} |
local format, strfind, GetGuildRosterInfo, GetFriendInfo, RAID_CLASS_COLORS, CLASS_BUTTONS = |
function f:FRIENDLIST_UPDATE() |
for k,v in next,friendEntries do del(v) friendEntries[k]=nil end |
local total, online = GetNumFriends(), 0 |
local IsGrouped = GetNumRaidMembers() > 0 and UnitInRaid or GetNumPartyMembers() > 0 and UnitInParty or nil |
for i = 1, total do |
local name, level, class, zone, connected, status, note = GetFriendInfo(i) |
if( connected )then |
friendEntries[1] = new( nil, "Name", "", "Lv", "Zone", "Notes" ) |
end |
online = online + 1 |
friendEntries[online+1] = new( name, status ~= "" and format("%s %s", tostring(status), tostring(name)) or name, class:gsub(" ",""):upper(), level, zone or "Unknown", note and format("[%s]",note) or "-", nil, nil, IsGrouped and IsGrouped(name) ) |
friendEntries[online+1] = new( name, status ~= "" and format("%s %s", tostring(status), tostring(name)) or name, class:gsub(" ",""):upper(), level, zone or "Unknown", note and format("[%s]",note) or "-" ) |
end |
end |
f.FriendsBlock.text = format(" %d/%d", online, total) |
local button = CreateFrame( "Button", nil, f ) |
table[key] = button |
button.index = key |
button:SetNormalFontObject(GameFontNormal) |
button:RegisterForClicks"AnyUp" |
button:SetHeight( BUTTON_HEIGHT ) |
button:SetScript( "OnEnter", Menu_OnEnter ) |
button:SetScript( "OnLeave", Menu_OnLeave ) |
button.fontName = CreateFS( key, button, "LEFT" ) |
if( key == 0 )then |
button.fontName:SetJustifyV"TOP" |
else |
if( key > 1 )then |
button.icon = button:CreateTexture( nil, "OVERLAY" ) |
button.icon:SetWidth( ICON_SIZE ) button.icon:SetHeight( ICON_SIZE ) |
button.icon:SetPoint( "LEFT", button, "LEFT" ) |
end |
button.check = button:CreateTexture() |
button.check:SetTexture(key>1 and "Interface\\Buttons\\UI-CheckBox-Check" or "") |
button.check:SetTexCoord(.15,.85,.15,.85) |
button.check:SetWidth(ICON_SIZE) button.check:SetHeight(ICON_SIZE) |
button.check:SetPoint("LEFT",button,"LEFT") |
button.fontName:SetPoint( "LEFT", button, "LEFT", ICON_SIZE + TEXT_OFFSET, 0 ) |
button.icon = button:CreateTexture() |
button.icon:SetWidth( ICON_SIZE ) button.icon:SetHeight( ICON_SIZE ) |
button.icon:SetPoint( "LEFT", button, "LEFT", ICON_SIZE+TEXT_OFFSET, 0 ) |
button.fontName:SetPoint( "LEFT", button.icon, "LEFT", ICON_SIZE+TEXT_OFFSET, 0 ) |
button.fontLevel = CreateFS( key, button, "CENTER", button.fontName ) |
button.fontZone = CreateFS( key, button, "CENTER", button.fontLevel ) |
button.fontNotes = CreateFS( key, button, "CENTER", button.fontZone ) |
button.icon:SetTexture"Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes" |
local offset, left, right, bottom, top = 0.025, unpack( classIcon ) |
button.icon:SetTexCoord( left+offset, right-offset, bottom+offset, top-offset ) |
button.icon:SetDesaturated(isGrouped and 1) |
if( isGrouped )then |
button.fontName:SetTextColor( .55, .55, .55 ) |
else |
local color = RAID_CLASS_COLORS[class] |
button.fontName:SetTextColor( color.r, color.g, color.b ) |
end |
if( useChecks )then button.check:SetAlpha(isGrouped and 1 or 0) end |
local color = RAID_CLASS_COLORS[class] |
button.fontName:SetTextColor( color.r, color.g, color.b ) |
else -- friend entry with non english client |
button.icon:SetTexture"" |
button.fontName:SetTextColor( 1,1,0 ) |
GuildMOTDEditButton:Click() |
end |
local colspace = { ICON_SIZE } |
local cols = { "class", "name", "level", "zone", "note", "rank" } |
local cols, colspace = { "class", "name", "level", "zone", "note", "rank" }, {} |
local function OnGuildmateClick( self, button ) |
if( not( self and self.unit ) )then return end |
if( not isGuild )then |
FriendsFrame.NotesID = self.index - 1 |
StaticPopup_Show( "SET_FRIENDNOTE", self.unit ) |
elseif( button == "RightButton" and CanEditOfficerNote() or button == "LeftButton" and CanEditPublicNote() )then |
print( "button = "..button, "CanEditOfficerNote = ", CanEditOfficerNote(), "CanEditPublicNote = ", CanEditPublicNote() ) |
elseif( button == "LeftButton" and CanEditPublicNote() or button ~= "LeftButton" and CanEditOfficerNote() )then |
SetGuildRosterSelection( guildEntries[self.index][8] ) |
StaticPopup_Show( button == "RightButton" and "SET_GUILDOFFICERNOTE" or "SET_GUILDPLAYERNOTE" ) |
StaticPopup_Show( button == "LeftButton" and "SET_GUILDPLAYERNOTE" or "SET_GUILDOFFICERNOTE" ) |
end |
else |
SetItemRef("player:"..self.unit, format( "|Hplayer:%s|h[%s]|h", self.unit, self.unit ), "LeftButton") |
isGuild = _isGuild |
block = not leaving and block or self -- possible source of bugs when fast switching |
local hasEntries = #entries > 0 |
if( not hasEntries )then entries[1] = new( nil, isGuild and ERR_GUILD_PLAYER_NOT_IN_GUILD or "No friends online.", "" ) end |
if( not hasEntries )then |
entries[1] = new( nil, isGuild and ERR_GUILD_PLAYER_NOT_IN_GUILD or "No friends online.", "" ) |
end |
local offsetEntries, button = isGuild and hasEntries and 1 or 0 |
local nameC, levelC, zoneC, notesC, rankC = 0, 0, 0, 0, 0 |
motd.fontName:ClearAllPoints() |
end |
local isGrouped = GetNumRaidMembers()>0 and UnitInRaid or GetNumPartyMembers()>0 and UnitInParty or nil |
for i, entry in ipairs(entries) do |
button, nameW, levelW, zoneW, notesW, rankW = SetButtonData( i, entry[2], entry[3], entry[4], entry[5], entry[6], entry[7], entry[9] ) |
if( hasEntries )then button:SetScript( "OnClick", OnGuildmateClick ) end |
button, nameW, levelW, zoneW, notesW, rankW = SetButtonData( i, entry[2], entry[3], entry[4], entry[5], entry[6], entry[7], isGrouped and isGrouped(entry[1] or "") ) |
button.unit = entry[1] |
button:SetScript( "OnClick", OnGuildmateClick ) |
if( nameW > nameC )then nameC = nameW end |
if( levelW and levelW>0 )then |
if( levelW > levelC )then levelC = levelW end |
if( notesW > notesC )then notesC = notesW end |
if( rankW > rankC )then rankC = rankW end |
if( hideNotes )then button.fontNotes:Hide() else button.fontNotes:Show() end |
button.fontRank:ClearAllPoints() |
button.fontRank:SetPoint( "LEFT", hideNotes and button.fontZone or button.fontNotes, "RIGHT", GAP, 0 ) |
if( isGrouped )then button.check:Show() else button.check:Hide() end |
button.icon:SetPoint( "LEFT", button, "LEFT", isGrouped and ICON_SIZE+TEXT_OFFSET or 0, 0 ) |
end |
end |
if( hideNotes )then notesC = -GAP end |
local maxWidth = ICON_SIZE + TEXT_OFFSET + nameC + levelC + zoneC + notesC + rankC + GAP * (isGuild and 4 or 3) -- (not hasEntries and 0 or isGuild and 4 or 3) |
local maxWidth = ICON_SIZE + TEXT_OFFSET + (isGrouped and ICON_SIZE+TEXT_OFFSET or 0) + nameC + levelC + zoneC + notesC + rankC + GAP * (isGuild and 4 or 3) |
extraHeight = ceil( extraHeight / maxWidth ) |
if( isGuild and hasEntries )then |
button.fontNotes:SetWidth(notesC) |
button.fontRank:SetWidth(rankC) |
end |
colspace[1] = isGrouped and ICON_SIZE*2 + TEXT_OFFSET or ICON_SIZE |
colspace[2], colspace[3], colspace[4], colspace[5], colspace[6] = nameC, levelC, zoneC, notesC, rankC |
f:SetWidth( maxWidth + GAP*2 ) |
function f:GuildOnEnter(dontShow) |
if( not dontShow and InCombatLockdown() )then f:Show() return Menu_OnEnter(f) end |
for k, v in next, guildEntries do del(v) guildEntries[k]=nil end |
local IsGrouped = GetNumRaidMembers() > 0 and UnitInRaid or GetNumPartyMembers() > 0 and UnitInParty or nil |
for i=1, GetNumGuildMembers(true) do |
local name, rank, _, level, _, zone, note, offnote, connected, status, class = GetGuildRosterInfo(i) |
if( connected )then |
format( "[%s] - \124cffff9944[%s]\124r", note, offnote ) or |
format( "[%s]", note )) or (offnote ~= "" and |
format( "\124cffff9944[%s]\124r", offnote ) or "-") |
guildEntries[#guildEntries+1] = new( name, status == "" and name or format( "%s %s", status, name ), class, level, zone, notes, rank, i, IsGrouped and IsGrouped(name) ) |
guildEntries[#guildEntries+1] = new( name, status == "" and name or format( "%s %s", status, name ), class, level, zone, notes, rank, i ) |
end |
end |
f.GuildBlock.text = IsInGuild() and format( " %s%d/%d", config.showGuildName and GetGuildInfo"player" and GetGuildInfo"player"..": " or "", #guildEntries-1, GetNumGuildMembers(true) ) or " No Guild" |
if( _G.Skinner )then |
_G.Skinner:applySkin(self) |
else |
self:SetBackdrop( { bgFile="Interface\\Buttons\\WHITE8X8", edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", |
f:SetBackdrop( { bgFile="Interface\\Buttons\\WHITE8X8", edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", |
tile=true, tileSize=12, edgeSize=12, insets = { left=2, right=2, top=2, bottom=2 } } ) |
self:SetBackdropColor( 0, 0, 0, .75 ) |
f:SetBackdropColor( 0, 0, 0, .75 ) |
end |
f.red, f.green, f.blue, f.alpha = f:GetBackdropColor() |
f:SetFrameStrata"TOOLTIP" |
f:SetClampedToScreen(true) |
f:EnableMouse( true ) |
f:RegisterEvent"ADDON_LOADED" |
f:SetScript( "OnEvent", function(self, event, ...) return self[event](self, event, ...) end ) |
f:SetScript( "OnShow", function(self) f:SetBackdropColor( InCombatLockdown() and .22 or 0,0,0,.75) end ) |
## Interface: 30000 |
## Title: |cFFFFB366Ara|r - Guild & Friends |
## Version: r8 |
## Version: r9 |
## Author: Ara |
## Notes: A Data Broker plugin that provides guildmates & friends informations and interactions. |
## SavedVariables: AraBrokerGuildFriendsDB |
## OptionalDeps: Skinner |
## X-Credits: Tekkub (picoGuild) |
## LoadManagers: AddonLoader |