WoWInterface SVN Ara_Broker_Guild_Friends

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 5 to Rev 6
    Reverse comparison

Rev 5 → Rev 6

Ara_Broker_Guild_Friends.toc
1,11 → 1,9
## Interface: 30000
## Title: |cFFFFB366Ara|r - Guild & Friends
## Version: r3
## Version: r4
## Author: Ara
## Notes: A Data Broker plugin that provides guildmates & friends informations and interactions.
## Dependencies:
## OptionalDeps:
## SavedVariables:
## SavedVariablesPerCharacter:
## SavedVariables: AraBrokerGuildFriendsDB
 
## LoadManagers: AddonLoader
## X-LoadOn-Always: delayed
Ara_Broker_Guild_Friends.lua
3,9 → 3,10
 
local f = CreateFrame( "Frame", "AraBrokerGuildFriends" )
local t = CreateFrame"Frame"
--local dropdown, dropdown_init = CreateFrame( "Frame", "AraBrokerGuildFriendsDDFrame", nil, "UIDropDownMenuTemplate" )
 
local block, isGuild, leaving
local block, isGuild, leaving, horde, config
local defaultConfig = { showGuildNotes = true }
local guildEntries, friendEntries = {}, {}
 
local format, strfind, GetGuildRosterInfo, GetFriendInfo, RAID_CLASS_COLORS, CLASS_BUTTONS =
format, strfind, GetGuildRosterInfo, GetFriendInfo, RAID_CLASS_COLORS, CLASS_BUTTONS
24,14 → 25,11
end
 
 
local mejoin = format( ERR_GUILD_JOIN_S, UnitName"player" )
local friendOnline, friendOffline = gsub(ERR_FRIEND_ONLINE_SS,"\124Hplayer:%%s\124h%[%%s%]\124h",""), gsub(ERR_FRIEND_OFFLINE_S,"%%s","")
function f:CHAT_MSG_SYSTEM( event, msg )
if msg == mejoin or strfind( msg, friendOnline ) or strfind( msg, friendOffline ) then t.updateFriends = true end
if strfind( msg, friendOnline ) or strfind( msg, friendOffline ) then ShowFriends() end
end
 
local guildEntries, friendEntries = {}, {}
 
function f:FRIENDLIST_UPDATE()
for k,v in next,friendEntries do del(v) friendEntries[k]=nil end
local total, online = GetNumFriends(), 0
45,7 → 43,7
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 = total > 0 and format("%d/%d", online, total) or "No friends."
f.FriendsBlock.text = total > 0 and format(" %d/%d", online, total) or " No friends."
if( not isGuild and block )then f:FriendsOnEnter(block) end
end
 
58,7 → 56,6
return IsInGuild() and GuildRoster()
end
 
local horde
local hordeZones = "Orgrimmar,Undercity,Thunder Bluff,Silvermoon City,Tirisfal Glades,Durotar,The Barrens,Silverpine Forest,Mulgore,The Sepulcher,Eversong Woods,Ghostlands,"
local allianceZones = "Ironforge,Stormwind City,Darnassus,Azuremyst Isle,Bloodmyst Isle,Darkshore,Dun Morogh,Loch Modan,Wetlands,Elwynn Forest,Redridge Mountains,Westfall,Teldrassil,Duskwood,Darshire,Thelsamar,Deeprun Tram,The Exodar,Auberdine,Menethil Harbor,Theramore Isle"
local function GetZoneColor(zone)
138,17 → 135,28
end } )
 
 
local function SetButtonData( index, name, class, level, zone, notes, rank )
local function SetButtonData( index, name, class, level, zone, notes, rank, isGrouped )
local button = buttons[index]
button.fontName:SetText( name or "" )
button:Show()
if( class )then
if( index > 1 )then
button.icon:SetTexture"Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes"
local offset, left, right, bottom, top = 0.025, unpack( CLASS_BUTTONS[class] )
button.icon:SetTexCoord( left+offset, right-offset, bottom+offset, top-offset )
local color = RAID_CLASS_COLORS[class]
button.fontName:SetTextColor( color.r, color.g, color.b )
local classIcon = CLASS_BUTTONS[class]
if( classIcon )then
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( .5, .5, .5 )
else
local color = RAID_CLASS_COLORS[class]
button.fontName:SetTextColor( color.r, color.g, color.b )
end
else -- friend entry with non english client
button.icon:SetTexture""
button.fontName:SetTextColor( 1,1,0 )
end
color = GetDifficultyColor(level)
button.fontLevel:SetTextColor( color.r, color.g, color.b )
button.fontZone:SetTextColor( GetZoneColor(zone or "#") )
181,7 → 189,9
dist = abs( colpos - colspace[i]*.5 )
if( dist > prevDist )then dist, prevDist = i-1, -1 break else prevDist = dist end
end
SortGuildRoster( cols[ prevDist < 0 and dist or #colspace ] )
colpos = prevDist < 0 and dist or #colspace
if( not config.showGuildNotes and colpos == 5 )then colpos = 6 end
SortGuildRoster( cols[ colpos ] )
elseif( IsAltKeyDown() )then
InviteUnit( self.unit )
elseif( IsControlKeyDown() )then
210,6 → 220,7
local offsetEntries, button = isGuild and 1 or 0
local nameC, levelC, zoneC, notesC, rankC = 0, 0, 0, 0, 0
local nameW, levelW, zoneW, notesW, rankW
local hideNotes = isGuild and not config.showGuildNotes
 
local extraHeight, motd = 0
if( isGuild )then
219,7 → 230,7
end
 
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] )
button, nameW, levelW, zoneW, notesW, rankW = SetButtonData( i, entry[2], entry[3], entry[4], entry[5], entry[6], entry[7], entry[9] )
button:SetScript( "OnClick", onClickFunc )
button.unit = entry[1]
if( nameW > nameC )then nameC = nameW end
227,8 → 238,12
if( zoneW > zoneC )then zoneC = zoneW 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 )
end
 
if( hideNotes )then notesC = -GAP end
local maxWidth = ICON_SIZE + TEXT_OFFSET + nameC + levelC + zoneC + notesC + rankC + GAP * (isGuild and 4 or 3)
extraHeight = ceil( extraHeight / maxWidth )
 
273,31 → 288,38
function f:GuildOnEnter(dontShow)
if( not dontShow and InCombatLockdown() )then return 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
if( #guildEntries == 0 )then -- first entry, so add header
if( #guildEntries == 0 )then
guildEntries[1] = new( nil, "Name", "", "Lv", "Zone", "Notes", "Rank" )
end
local notes = note ~= "" and (offnote ~= "" and
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 )
guildEntries[#guildEntries+1] = new( name, status == "" and name or format( "%s %s", status, name ), class, level, zone, notes, rank, i, IsGrouped and IsGrouped(name) )
end
end
local g = f.GuildBlock
if( not IsInGuild() )then
g.text, g.value, g.label = "No Guild", nil, nil
else -- buttonbin/fortress --> "label: value" or "label: text" or "value" or "text"
g.text, g.value, g.label = " No Guild", nil, nil
else
g.label = " "..GetGuildInfo"player"
g.value = format( " %d/%d", #guildEntries-1, GetNumGuildMembers(true) )
g.text = format( "%s -%s", g.label, g.value )
end
-- f.GuildBlock.text = IsInGuild() and format( "%s - %d/%d", GetGuildInfo"player", numOnline, GetNumGuildMembers(true) ) or "No Guild"
return not dontShow and ShowTablet( self, true, guildEntries, OnGuildmateClick )
end
 
local function OnBlockClick(self, button, panelIndex)
if( button == "LeftButton" )then return ToggleFriendsFrame(panelIndex) end
if( isGuild )then
config.showGuildNotes = not config.showGuildNotes
ShowTablet( block, true, guildEntries, OnGuildmateClick )
end
end
 
local ldb = LibStub("LibDataBroker-1.1")
 
306,7 → 328,7
icon = "Interface\\AddOns\\Ara_Broker_Guild_Friends\\guild.tga",
OnEnter = f.GuildOnEnter,
OnLeave = function(self) return IsInGuild() and Menu_OnLeave(self) or GameTooltip:Hide() end,
OnClick = function(self) ToggleFriendsFrame(3) end,
OnClick = function(self,button) OnBlockClick(self,button,3) end,
} )
 
f.FriendsBlock = ldb:NewDataObject( "|cFFFFB366Ara|r Friends", {
314,15 → 336,9
icon = "Interface\\AddOns\\Ara_Broker_Guild_Friends\\friends.tga",
OnEnter = f.FriendsOnEnter,
OnLeave = function(self) Menu_OnLeave(self) GameTooltip:Hide() end,
OnClick = function(self) ToggleFriendsFrame(1) end,
OnClick = function(self,button) OnBlockClick(self,button,1) end,
} )
 
local orgShowFriends = ShowFriends
ShowFriends = function(...)
t.friendsTimer, t.updateFriends = 0, false
return orgShowFriends(...)
end
 
local orgGuildRoster = GuildRoster
GuildRoster = function(...)
t.guildTimer = 0
330,30 → 346,37
end
 
local function OnUpdate( self, elapsed )
t.guildTimer, t.friendsTimer = t.guildTimer + elapsed, t.friendsTimer + elapsed
t.guildTimer = t.guildTimer + elapsed
if( t.guildTimer > 15 )then
if IsInGuild() then GuildRoster() else t.guildTimer = 0 end
end
if( t.updateFriends and t.friendsTimer > 15 or t.friendsTimer > 300 )then
ShowFriends()
end
end
 
f.ADDON_LOADED = function( self, event, addon )
if( addon ~= "Ara_Broker_Guild_Friends" )then return end
AraBrokerGuildFriendsDB = AraBrokerGuildFriendsDB or defaultConfig
config = AraBrokerGuildFriendsDB
for k, v in next, defaultConfig do if config[k]==nil then config[k]=v end end
end
 
f.PLAYER_LOGIN = function( self, event )
horde = UnitFactionGroup"player" == "Horde"
SortGuildRoster"class" -- name, rank, note, online, zone, level, class
 
self: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 )
if( _G.Skinner )then
_G.Skinner:applySkin(self)
else
self: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 )
end
self:SetScale( UIParent:GetScale() )
self:SetFrameStrata"TOOLTIP"
self:SetClampedToScreen(true)
self:EnableMouse( true )
self:Show() -- possible fix for menu width bug
 
t.guildTimer, t.friendsTimer = 0, 0
t.guildTimer = 0
t:SetScript( "OnUpdate", OnUpdate )
self:SetScript( "OnEnter", Menu_OnEnter )
self:SetScript( "OnLeave", Menu_OnLeave )
370,5 → 393,6
self.PLAYER_LOGIN = nil
end
 
f:RegisterEvent"ADDON_LOADED"
f:SetScript( "OnEvent", function(self, event, ...) return self[event](self, event, ...) end )
return IsLoggedIn() and f:PLAYER_LOGIN() or f:RegisterEvent"PLAYER_LOGIN"
\ No newline at end of file +if IsLoggedIn() then f:PLAYER_LOGIN() GuildRoster() else f:RegisterEvent"PLAYER_LOGIN" end \ No newline at end of file