WoWInterface SVN Ara_Broker_Guild_Friends

Compare Revisions

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

Rev 6 → Rev 7

Ara_Broker_Guild_Friends.toc
1,9 → 1,10
## Interface: 30000
## Title: |cFFFFB366Ara|r - Guild & Friends
## Version: r4
## Version: r5
## Author: Ara
## Notes: A Data Broker plugin that provides guildmates & friends informations and interactions.
## SavedVariables: AraBrokerGuildFriendsDB
## X-Credits: Tekkub (picoGuild)
 
## LoadManagers: AddonLoader
## X-LoadOn-Always: delayed
Ara_Broker_Guild_Friends.lua
3,14 → 3,20
 
local f = CreateFrame( "Frame", "AraBrokerGuildFriends" )
local t = CreateFrame"Frame"
--local dropdown, dropdown_init = CreateFrame( "Frame", "AraBrokerGuildFriendsDDFrame", nil, "UIDropDownMenuTemplate" )
 
local block, isGuild, leaving, horde, config
local defaultConfig = { showGuildNotes = true }
local defaultConfig = { showGuildNotes = true, showGuildName = true, sortType = "class", sortDESC = false }
local guildEntries, friendEntries = {}, {}
 
local format, strfind, GetGuildRosterInfo, GetFriendInfo, RAID_CLASS_COLORS, CLASS_BUTTONS =
format, strfind, GetGuildRosterInfo, GetFriendInfo, RAID_CLASS_COLORS, CLASS_BUTTONS
 
local orgReloadUI = ReloadUI
ReloadUI = function(...)
config.reloading = true
orgReloadUI(...)
end
 
local tables = {}
 
33,6 → 39,7
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
40,7 → 47,7
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 "-" )
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) )
end
end
f.FriendsBlock.text = total > 0 and format(" %d/%d", online, total) or " No friends."
56,7 → 63,7
return IsInGuild() and GuildRoster()
end
 
local hordeZones = "Orgrimmar,Undercity,Thunder Bluff,Silvermoon City,Tirisfal Glades,Durotar,The Barrens,Silverpine Forest,Mulgore,The Sepulcher,Eversong Woods,Ghostlands,"
local hordeZones = "Orgrimmar,Undercity,Thunder Bluff,Silvermoon City,Durotar,Tirisfal Glades,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)
if( strfind( hordeZones , zone.."," ) )then if( horde )then return 0,1,0 else return 1,0,0 end end
72,7 → 79,7
return f:Hide()
end
 
local highlight = f:CreateTexture(nil,"ARTWORK")
local highlight = f:CreateTexture()
highlight:SetTexture"Interface\\QuestFrame\\UI-QuestTitleHighlight"
highlight:SetBlendMode"ADD"
highlight:SetAlpha(0)
134,7 → 141,6
return button
end } )
 
 
local function SetButtonData( index, name, class, level, zone, notes, rank, isGrouped )
local button = buttons[index]
button.fontName:SetText( name or "" )
148,7 → 154,7
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 )
button.fontName:SetTextColor( .55, .55, .55 )
else
local color = RAID_CLASS_COLORS[class]
button.fontName:SetTextColor( color.r, color.g, color.b )
170,7 → 176,6
return button, button.fontName:GetStringWidth()
end
 
 
local function EditMOTD()
f:Hide()
GuildMOTDEditButton:Click()
181,7 → 186,7
 
local function OnGuildmateClick( self, button )
if( not( self and self.unit ) )then return end
if( isGuild and button ~= "LeftButton" )then -- sort columns
if( isGuild and button ~= "LeftButton" and not IsModifierKeyDown() )then -- sort columns
local prevDist = GetCursorPosition() / self:GetEffectiveScale() - self:GetLeft()
local colpos, dist = colspace[1] - prevDist
for i=2, #colspace do
190,33 → 195,38
if( dist > prevDist )then dist, prevDist = i-1, -1 break else prevDist = dist end
end
colpos = prevDist < 0 and dist or #colspace
if( not config.showGuildNotes and colpos == 5 )then colpos = 6 end
SortGuildRoster( cols[ colpos ] )
colpos = not config.showGuildNotes and colpos == 5 and "rank" or cols[colpos]
if( config.sortType == colpos )then
config.sortDESC = not config.sortDESC
else
config.sortType, config.sortDESC = colpos, false
end
SortGuildRoster( colpos )
elseif( IsAltKeyDown() )then
InviteUnit( self.unit )
elseif( IsControlKeyDown() )then
if( not isGuild )then
FriendsFrame.NotesID = self.index - 1
StaticPopup_Show( "SET_FRIENDNOTE", self.unit )
elseif( CanEditPublicNote() )then
elseif( button == "RightButton" and CanEditOfficerNote() or button == "LeftButton" and CanEditPublicNote() )then
print( "button = "..button, "CanEditOfficerNote = ", CanEditOfficerNote(), "CanEditPublicNote = ", CanEditPublicNote() )
SetGuildRosterSelection( guildEntries[self.index][8] )
StaticPopup_Show("SET_GUILDPLAYERNOTE")
StaticPopup_Show( button == "RightButton" and "SET_GUILDOFFICERNOTE" or "SET_GUILDPLAYERNOTE" )
end
else
SetItemRef("player:"..self.unit, format( "|Hplayer:%s|h[%s]|h", self.unit, self.unit ), "LeftButton")
end
end
 
local function ShowTablet( self, _isGuild, entries, onClickFunc )
local function ShowTablet( self, _isGuild, entries )
isGuild = _isGuild
block = not leaving and block or self -- possible source of bugs when fast switching
if( InCombatLockdown() )then return end
if( isGuild and not IsInGuild() or #entries == 0 )then
GameTooltip:SetOwner(self)
GameTooltip:AddLine( isGuild and ERR_GUILD_PLAYER_NOT_IN_GUILD or "No friends online." )
return GameTooltip:Show()
end
Menu_OnEnter(self)
 
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
231,16 → 241,18
 
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] )
button:SetScript( "OnClick", onClickFunc )
button:SetScript( "OnClick", OnGuildmateClick )
button.unit = entry[1]
if( nameW > nameC )then nameC = nameW end
if( levelW > levelC )then levelC = levelW end
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 )
if( levelW )then
if( levelW > levelC )then levelC = levelW end
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
end
 
if( hideNotes )then notesC = -GAP end
272,6 → 284,7
f:SetWidth( maxWidth + GAP*2 )
f:SetHeight( BUTTON_HEIGHT * (#entries+offsetEntries+extraHeight) + GAP*2 )
 
Menu_OnEnter(self)
local showBelow = select( 2, block:GetCenter() ) > ( UIParent:GetHeight() / 2 )
f:ClearAllPoints()
f:SetPoint( showBelow and "TOP" or "BOTTOM", block, showBelow and "BOTTOM" or "TOP" )
281,12 → 294,12
 
 
function f:FriendsOnEnter()
if( InCombatLockdown() )then return end
return ShowTablet( self, false, friendEntries, OnGuildmateClick )
if( InCombatLockdown() )then f:Show() return Menu_OnEnter(f) end
return ShowTablet( self, false, friendEntries )
end
 
function f:GuildOnEnter(dontShow)
if( not dontShow and InCombatLockdown() )then return end
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
302,22 → 315,19
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
g.label = " "..GetGuildInfo"player"
g.value = format( " %d/%d", #guildEntries-1, GetNumGuildMembers(true) )
g.text = format( "%s -%s", g.label, g.value )
end
return not dontShow and ShowTablet( self, true, guildEntries, OnGuildmateClick )
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"
return not dontShow and ShowTablet( self, true, guildEntries )
end
 
local function OnBlockClick(self, button, panelIndex)
if( button == "LeftButton" )then return ToggleFriendsFrame(panelIndex) end
if( isGuild )then
local function OnBlockClick(self, button)
if( button == "LeftButton" )then
if( IsShiftKeyDown() and IsInGuild() )then
config.showGuildName = not config.showGuildName
f.GuildBlock.text = format( " %s%d/%d", config.showGuildName and GetGuildInfo"player"..": " or "", #guildEntries-1, GetNumGuildMembers(true) )
else ToggleFriendsFrame(3) end
elseif( not InCombatLockdown() )then
config.showGuildNotes = not config.showGuildNotes
ShowTablet( block, true, guildEntries, OnGuildmateClick )
ShowTablet( block, true, guildEntries )
end
end
 
328,7 → 338,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,button) OnBlockClick(self,button,3) end,
OnClick = function(self,button) OnBlockClick(self,button) end,
} )
 
f.FriendsBlock = ldb:NewDataObject( "|cFFFFB366Ara|r Friends", {
336,7 → 346,7
icon = "Interface\\AddOns\\Ara_Broker_Guild_Friends\\friends.tga",
OnEnter = f.FriendsOnEnter,
OnLeave = function(self) Menu_OnLeave(self) GameTooltip:Hide() end,
OnClick = function(self,button) OnBlockClick(self,button,1) end,
OnClick = function() ToggleFriendsFrame(1) end,
} )
 
local orgGuildRoster = GuildRoster
352,17 → 362,14
end
end
 
f.ADDON_LOADED = function( self, event, addon )
if( addon ~= "Ara_Broker_Guild_Friends" )then return end
function f:ADDON_LOADED( event, addon )
if( addon ~= "Ara_Broker_Guild_Friends" )then return else self:UnregisterEvent(event) 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
if( config.reloading )then config.reloading = nil else SortGuildRoster(config.sortType) if( config.sortDESC )then SortGuildRoster(config.sortType) end end
 
f.PLAYER_LOGIN = function( self, event )
horde = UnitFactionGroup"player" == "Horde"
SortGuildRoster"class" -- name, rank, note, online, zone, level, class
 
if( _G.Skinner )then
_G.Skinner:applySkin(self)
else
370,29 → 377,27
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
f:SetScale( UIParent:GetScale() )
f:SetFrameStrata"TOOLTIP"
f:SetClampedToScreen(true)
f:EnableMouse( true )
f:Show() -- possible fix for menu width bug
 
t.guildTimer = 0
t:SetScript( "OnUpdate", OnUpdate )
self:SetScript( "OnEnter", Menu_OnEnter )
self:SetScript( "OnLeave", Menu_OnLeave )
f:SetScript( "OnEnter", Menu_OnEnter )
f:SetScript( "OnLeave", Menu_OnLeave )
 
self:RegisterEvent"GUILD_ROSTER_UPDATE"
self:RegisterEvent"PLAYER_GUILD_UPDATE"
self:RegisterEvent"FRIENDLIST_UPDATE"
self:RegisterEvent"CHAT_MSG_SYSTEM"
f:RegisterEvent"GUILD_ROSTER_UPDATE"
f:RegisterEvent"PLAYER_GUILD_UPDATE"
f:RegisterEvent"FRIENDLIST_UPDATE"
f:RegisterEvent"CHAT_MSG_SYSTEM"
 
if IsInGuild() then GuildRoster() end
ShowFriends()
 
self:UnregisterEvent"PLAYER_LOGIN"
self.PLAYER_LOGIN = nil
GuildRoster()
f:GuildOnEnter(true)
f.ADDON_LOADED = nil
end
 
f:RegisterEvent"ADDON_LOADED"
f:SetScript( "OnEvent", function(self, event, ...) return self[event](self, event, ...) end )
if IsLoggedIn() then f:PLAYER_LOGIN() GuildRoster() else f:RegisterEvent"PLAYER_LOGIN" end
\ No newline at end of file +f:SetScript( "OnShow", function(self) f:SetBackdropColor( InCombatLockdown() and .22 or 0,0,0,.75) end ) \ No newline at end of file