WoWInterface SVN Ara_Broker_Guild_Friends

Compare Revisions

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

Rev 4 → Rev 5

Ara_Broker_Guild_Friends.lua
1,20 → 1,15
-- ShowTablet line 3: possible source of bugs (glitch) when trying to solve: block/self -> incorrect setpoint
 
local BUTTON_HEIGHT, ICON_SIZE, GAP, TEXT_OFFSET, TIMEOUT =
15, 13, 10, 5, .05
 
local f = CreateFrame( "Frame", "AraBrokerGuildFriends" )
local extraFrame = CreateFrame"Frame"
local dropdown, dropdown_init = CreateFrame( "Frame", "AraBrokerGuildFriendsDDFrame", nil, "UIDropDownMenuTemplate" )
local t = CreateFrame"Frame"
--local dropdown, dropdown_init = CreateFrame( "Frame", "AraBrokerGuildFriendsDDFrame", nil, "UIDropDownMenuTemplate" )
 
local block, isGuild, leaving
 
local L = setmetatable( {}, { __index = function(t,k) return k end } ) -- GetLocale()
 
local format, strfind, GetGuildRosterInfo, GetFriendInfo, RAID_CLASS_COLORS, CLASS_BUTTONS =
format, strfind, GetGuildRosterInfo, GetFriendInfo, RAID_CLASS_COLORS, CLASS_BUTTONS
 
---------------------------------[[ ]]--------------------------------
 
local tables = {}
 
32,11 → 27,10
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 then self.updateGuild = true return end
if strfind( msg, friendOnline ) or strfind( msg, friendOffline ) then self.updateFriends, self.updateGuild = true, true end
if msg == mejoin or strfind( msg, friendOnline ) or strfind( msg, friendOffline ) then t.updateFriends = true end
end
 
local friendEntries = {}
local guildEntries, friendEntries = {}, {}
 
function f:FRIENDLIST_UPDATE()
for k,v in next,friendEntries do del(v) friendEntries[k]=nil end
48,20 → 42,15
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 "-" )
end
end
f.FriendsBlock.text = total > 0 and format("%d/%d", online, total) or L["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
 
function f:GUILD_ROSTER_UPDATE()
local numOnline = 0
for i=1, GetNumGuildMembers() do
if( select( 9, GetGuildRosterInfo(i) ) )then numOnline = numOnline + 1 end
end
f.GuildBlock.text = IsInGuild() and format( "%s - %d/%d", GetGuildInfo"player", numOnline, GetNumGuildMembers(true) ) or L["No Guild"]
if( isGuild and block )then f:GuildOnEnter(block) end
f.GuildOnEnter( block, not( isGuild and block ) )
end
 
function f:PLAYER_GUILD_UPDATE(event, unit)
79,11 → 68,11
end
 
local function Menu_OnUpdate( frame, elapsed )
extraFrame.timer = extraFrame.timer + elapsed
if( extraFrame.timer <= TIMEOUT )then return end
extraFrame:SetScript( "OnUpdate", nil )
f:Hide()
f.timer = f.timer + elapsed
if( f.timer <= TIMEOUT )then return end
f:SetScript( "OnUpdate", nil )
block = nil
return f:Hide()
end
 
local highlight = f:CreateTexture(nil,"ARTWORK")
93,8 → 82,8
 
local function Menu_OnEnter(b)
leaving = false
extraFrame:SetScript( "OnUpdate", nil )
if(b.index)then
f:SetScript("OnUpdate",nil)
if( b.index )then
highlight:SetAllPoints(b)
if( b.index > 1)then highlight:SetAlpha(1) end
end
102,15 → 91,15
 
local function Menu_OnLeave(b)
leaving = true
extraFrame.timer = 0
extraFrame:SetScript( "OnUpdate", Menu_OnUpdate )
f.timer = 0
f:SetScript("OnUpdate", Menu_OnUpdate)
highlight:ClearAllPoints()
if(b.index and b.index > 1)then highlight:SetAlpha(0) end
if( b.index and b.index > 1 )then highlight:SetAlpha(0) end
end
 
local font, _, flags = GameFontNormal:GetFont()
local function CreateFS( index, parent, justify, anchor )
local fs = parent:CreateFontString( nil, "OVERLAY" )
local font, _, flags = GameFontNormal:GetFont()
fs:SetFont( font, 12, flags )
fs:SetJustifyH( justify )
fs:SetTextColor( 1, index == 1 and .8 or 1, 0 )
122,14 → 111,14
 
local buttons = setmetatable( { }, { __index = function( table, key )
local button = CreateFrame( "Button", nil, f )
rawset( table, key, button )
table[key] = button
button.index = key
button:RegisterForClicks"AnyUp"
button:SetHeight( BUTTON_HEIGHT )
button:SetScript( "OnEnter", Menu_OnEnter )
button:SetScript( "OnLeave", Menu_OnLeave )
 
button.fontName = CreateFS( key, button, "LEFT" )
button.fontName = CreateFS( key, button, "LEFT" )
if( key == 0 )then
button.fontName:SetJustifyV"TOP"
else
158,7 → 147,6
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 )
-- button.icon:SetTexCoord( unpack( CLASS_BUTTONS[class] ) )
local color = RAID_CLASS_COLORS[class]
button.fontName:SetTextColor( color.r, color.g, color.b )
color = GetDifficultyColor(level)
175,7 → 163,6
end
 
 
------------------------------[[ data feed ]]----------------------------
local function EditMOTD()
f:Hide()
GuildMOTDEditButton:Click()
197,9 → 184,14
SortGuildRoster( cols[ prevDist < 0 and dist or #colspace ] )
elseif( IsAltKeyDown() )then
InviteUnit( self.unit )
elseif( not isGuild and IsControlKeyDown() )then
FriendsFrame.NotesID = self.index - 1
StaticPopup_Show( "SET_FRIENDNOTE", self.unit )
elseif( IsControlKeyDown() )then
if( not isGuild )then
FriendsFrame.NotesID = self.index - 1
StaticPopup_Show( "SET_FRIENDNOTE", self.unit )
elseif( CanEditPublicNote() )then
SetGuildRosterSelection( guildEntries[self.index][8] )
StaticPopup_Show("SET_GUILDPLAYERNOTE")
end
else
SetItemRef("player:"..self.unit, format( "|Hplayer:%s|h[%s]|h", self.unit, self.unit ), "LeftButton")
end
211,7 → 203,7
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 L["No friends online."] )
GameTooltip:AddLine( isGuild and ERR_GUILD_PLAYER_NOT_IN_GUILD or "No friends online." )
return GameTooltip:Show()
end
Menu_OnEnter(self)
278,10 → 270,8
return ShowTablet( self, false, friendEntries, OnGuildmateClick )
end
 
local guildEntries = {}
 
function f:GuildOnEnter()
if( InCombatLockdown() )then return end
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
for i=1, GetNumGuildMembers(true) do
local name, rank, _, level, _, zone, note, offnote, connected, status, class = GetGuildRosterInfo(i)
290,13 → 280,22
guildEntries[1] = new( nil, "Name", "", "Lv", "Zone", "Notes", "Rank" )
end
local notes = note ~= "" and (offnote ~= "" and
format( "[%s] - [%s]", note, offnote ) or
format( "[%s] - \124cffff9944[%s]\124r", note, offnote ) or
format( "[%s]", note )) or (offnote ~= "" and
format( "[%s]", offnote ) or "-")
guildEntries[#guildEntries+1] = new( name, status == "" and name or format( "%s %s", status, name ), class, level, zone, notes, rank )
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 )
end
end
return ShowTablet( self, true, guildEntries, OnGuildmateClick )
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.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
 
 
320,44 → 319,42
 
local orgShowFriends = ShowFriends
ShowFriends = function(...)
f.friendsTimer, f.updateFriends = 0, false
t.friendsTimer, t.updateFriends = 0, false
return orgShowFriends(...)
end
 
local orgGuildRoster = GuildRoster
GuildRoster = function(...)
f.guildTimer, f.updateGuild = 0, false
t.guildTimer = 0
return orgGuildRoster(...)
end
 
local function OnUpdate( self, elapsed )
self.guildTimer, self.friendsTimer = self.guildTimer + elapsed, self.friendsTimer + elapsed
if( self.updateGuild and self.guildTimer > 15 or self.guildTimer > 300 )then
self.guildTimer, self.updateGuild = 0, false
if IsInGuild() then GuildRoster() end
t.guildTimer, t.friendsTimer = t.guildTimer + elapsed, t.friendsTimer + elapsed
if( t.guildTimer > 15 )then
if IsInGuild() then GuildRoster() else t.guildTimer = 0 end
end
if( self.updateFriends and self.friendsTimer > 15 or self.friendsTimer > 300 )then
if( t.updateFriends and t.friendsTimer > 15 or t.friendsTimer > 300 )then
ShowFriends()
end
end
 
-------------------------------[[ events ]]------------------------------
 
f.PLAYER_LOGIN = function( self, event )
horde = UnitFactionGroup"player" == "Horde"
SortGuildRoster"class" -- "name", "rank", "note", "online", "zone", "level", "class"
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 )
self:SetScale( UIParent:GetScale() )
self:SetFrameStrata"DIALOG"
self:SetFrameStrata"TOOLTIP"
self:SetClampedToScreen(true)
self:EnableMouse( true )
self:Show() -- possible fix for menu width bug (or TODO: put in PLAYER_ENTERING_WORLD)
self:Show() -- possible fix for menu width bug
 
self.guildTimer, self.friendsTimer = 0, 0
self:SetScript( "OnUpdate", OnUpdate )
t.guildTimer, t.friendsTimer = 0, 0
t:SetScript( "OnUpdate", OnUpdate )
self:SetScript( "OnEnter", Menu_OnEnter )
self:SetScript( "OnLeave", Menu_OnLeave )
 
Ara_Broker_Guild_Friends.toc
1,14 → 1,14
## Interface: 30000
## Title: |cFFFFB366Ara|r - Guild & Friends
## Version: r2
## Version: r3
## Notes: A Data Broker plugin that provides guildmates & friends informations and interactions.
## Dependencies:
## OptionalDeps:
## SavedVariables:
## SavedVariablesPerCharacter:
 
## _LoadManagers: AddonLoader
## _X-LoadOn-Always: delayed
## LoadManagers: AddonLoader
## X-LoadOn-Always: delayed
 
libs\LibStub.lua
libs\CallbackHandler-1.0.lua