WoWInterface SVN Ara_Broker_Guild_Friends

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 20 to Rev 21
    Reverse comparison

Rev 20 → Rev 21

Ara_Broker_Guild_Friends.lua
1,13 → 1,14
-- TODO: scroll large guild members
local BUTTON_HEIGHT, ICON_SIZE, GAP, TEXT_OFFSET =
15, 13, 10, 5
local BUTTON_HEIGHT, ICON_SIZE, GAP, TEXT_OFFSET, MAX_ENTRIES =
15, 13, 10, 5, 45
 
local f = CreateFrame( "Frame", "AraBrokerGuildFriends", UIParent )
local t = CreateFrame"Frame"
 
local dontShow, block, horde, config, isGuild, tip, tipShown = true
local defaultConfig = { showGuildNotes = true, showGuildName = true, sortType = "class", sortDESC = false, fontSize=12 }
local guildEntries, friendEntries, buttons, motd = {}, {}
local guildEntries, friendEntries, motd, slider, nbEntries = {}, {}
local sliderValue, hasSlider, ShowTablet = 0
local RAID_CLASS_COLORS = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
 
local format, strfind, strupper, GetGuildRosterInfo, GetFriendInfo, CLASS_BUTTONS, GetDifficultyColor =
132,7 → 133,11
tip:Hide()
tipShown = false
if b.index and b.index > 1 then highlight:SetAlpha(0) end
if not MouseIsOver(f) then block = nil f:Hide() end
if not MouseIsOver(f) then
sliderValue = 0
block = nil
f:Hide()
end
end
 
local function CreateFS( index, parent, justify, anchor )
143,7 → 148,54
return fs
end
 
buttons = setmetatable( { }, { __index = function( table, key )
local function EditMOTD()
f:Hide()
block = nil
GuildMOTDEditButton:Click()
end
 
local cols, colspace = { "class", "name", "level", "zone", "note", "rank" }, { ICON_SIZE }
 
local function OnGuildmateClick( self, button )
if not( self and self.unit ) then return end
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
colpos = colpos + colspace[i] + (i==2 and TEXT_OFFSET or GAP)
dist = abs( colpos - colspace[i]*.5 )
if dist > prevDist then dist, prevDist = i-1, -1 break else prevDist = dist end
end
colpos = prevDist < 0 and dist or #colspace
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 button == "MiddleButton" and not isGuild then
RemoveFriend( self.unit )
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 button == "LeftButton" and CanEditPublicNote() or button ~= "LeftButton" and CanEditOfficerNote() then
SetGuildRosterSelection( guildEntries[self.index][8] )
StaticPopup_Show( button == "LeftButton" and "SET_GUILDPLAYERNOTE" or "SET_GUILDOFFICERNOTE" )
end
else
SetItemRef("player:"..self.unit, "|Hplayer:"..self.unit.."|h["..self.unit.."]|h", "LeftButton")
end
end
 
local function Scroll(self, delta)
if slider then slider:SetValue( sliderValue - delta * (IsModifierKeyDown() and 10 or 3) ) end
end
 
local buttons = setmetatable( { }, { __index = function( table, key )
local button = CreateFrame( "Button", nil, f )
table[key] = button
button.index = key
151,6 → 203,10
button:RegisterForClicks"AnyUp"
button:SetScript( "OnEnter", Menu_OnEnter )
button:SetScript( "OnLeave", Menu_OnLeave )
 
button:EnableMouseWheel(true)
button:SetScript( "OnMouseWheel", Scroll)
 
button.fontName = CreateFS( key, button, "LEFT" )
if key == 0 then
motd = button
159,7 → 215,7
motd:SetPoint( "TOPLEFT", f, "TOPLEFT", GAP, -GAP )
else
button:SetHeight( BUTTON_HEIGHT )
button:SetPoint( "TOPLEFT", buttons[key-1], "BOTTOMLEFT" )
-- button:SetPoint( "TOPLEFT", table[key-1], "BOTTOMLEFT" )
button.icon = button:CreateTexture()
button.icon:SetWidth( ICON_SIZE ) button.icon:SetHeight( ICON_SIZE )
button.icon:SetPoint( "LEFT", button, "LEFT" )
175,7 → 231,7
 
local function SetButtonData( index, name, class, level, zone, notes, rank, inGroup, isGrouped )
local button = buttons[index]
button:Show()
-- if index > nbEntries then button:Hide() else button:Show() end
button.fontName:SetText( name or "" )
if class then
if index > 1 then
208,65 → 264,52
return button, button.fontName:GetStringWidth()
end
 
local function EditMOTD()
f:Hide()
block = nil
GuildMOTDEditButton:Click()
end
 
local cols, colspace = { "class", "name", "level", "zone", "note", "rank" }, { ICON_SIZE }
 
local function OnGuildmateClick( self, button )
if not( self and self.unit ) then return end
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
colpos = colpos + colspace[i] + (i==2 and TEXT_OFFSET or GAP)
dist = abs( colpos - colspace[i]*.5 )
if dist > prevDist then dist, prevDist = i-1, -1 break else prevDist = dist end
end
colpos = prevDist < 0 and dist or #colspace
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 button == "MiddleButton" and not isGuild then
RemoveFriend( self.unit )
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 button == "LeftButton" and CanEditPublicNote() or button ~= "LeftButton" and CanEditOfficerNote() then
SetGuildRosterSelection( guildEntries[self.index][8] )
StaticPopup_Show( button == "LeftButton" and "SET_GUILDPLAYERNOTE" or "SET_GUILDOFFICERNOTE" )
end
else
SetItemRef("player:"..self.unit, "|Hplayer:"..self.unit.."|h["..self.unit.."]|h", "LeftButton")
end
end
 
local function ShowTablet( self, _isGuild, entries )
ShowTablet = function( self, _isGuild )
f:Show()
isGuild = _isGuild
block = block or self
 
local entries = isGuild and guildEntries or friendEntries
local hasEntries = #entries > 0
hasSlider = #entries > MAX_ENTRIES
 
if not hasEntries then
entries[1] = new( nil, isGuild and ERR_GUILD_PLAYER_NOT_IN_GUILD or "No friends online.", "" )
elseif hasSlider then
if not slider then
slider = CreateFrame("Slider", nil, f)
slider:SetWidth(16)
slider:SetHeight(BUTTON_HEIGHT*MAX_ENTRIES-1) -- 21 entries
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
slider:SetBackdrop( {
bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
edgeSize = 8, tile = true, tileSize = 8,
insets = {left = 3, right = 3, top = 6, bottom = 6}
} )
slider:SetValueStep(1)
slider:SetScript( "OnLeave", Menu_OnLeave )
slider:SetValue(1)
slider:SetScript( "OnValueChanged", function(self, value)
if hasSlider then sliderValue = value end
if block then ShowTablet(block, isGuild) end
end )
end
slider:SetMinMaxValues( 0, #entries - MAX_ENTRIES )
slider:SetValue(sliderValue)
slider:Show()
elseif slider then
slider:Hide()
end
 
nbEntries = math.min( MAX_ENTRIES, #entries )
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 = 0
local extraHeight, button = 0
 
local isGrouped = GetNumRaidMembers()>0 and UnitInRaid or GetNumPartyMembers()>0 and UnitInParty or nil
for i, entry in ipairs(entries) do
for i = 1, #entries do
local entry = entries[i]
button, nameW, levelW, zoneW, notesW, rankW = SetButtonData( i, entry[2], entry[3], entry[4], entry[5], entry[6], entry[7], isGrouped, isGrouped and entry[1] and isGrouped(entry[1]) )
button.unit = entry[1]
button:SetScript( "OnClick", OnGuildmateClick )
288,15 → 331,24
SetButtonData( 0, "|cffffffffMOTD:|r "..GetGuildRosterMOTD() )
if CanEditMOTD() then motd:SetScript( "OnClick", EditMOTD ) end
motd.fontName:SetWidth( maxWidth )
extraHeight = motd.fontName:GetHeight() + BUTTON_HEIGHT
motd:SetWidth( maxWidth )
motd:SetHeight( motd.fontName:GetHeight() + BUTTON_HEIGHT )
extraHeight = motd:GetHeight() + BUTTON_HEIGHT
motd:SetHeight( extraHeight )
motd:Show()
buttons[1]:SetPoint( "TOPLEFT", motd, "BOTTOMLEFT" )
else
buttons[0]:Hide()
buttons[1]:SetPoint( "TOPLEFT", f, "TOPLEFT", GAP, -GAP )
end
 
local btn = buttons[1]
for i=2, #buttons do buttons[i]:Hide() end
for i=2, nbEntries do
button = buttons[sliderValue+i]
button:SetPoint("TOPLEFT", btn, "TOPLEFT", 0, BUTTON_HEIGHT*(1-i))
button:Show()
end
 
for i=1, #entries do
button = buttons[i]
button:SetWidth( maxWidth )
308,21 → 360,22
end
colspace[2], colspace[3], colspace[4], colspace[5], colspace[6] = nameC, levelC, zoneC, notesC, rankC
 
f:SetWidth( maxWidth + GAP*2 )
f:SetHeight( BUTTON_HEIGHT * ( #entries + (isGuild and hasEntries and -1 or 0) ) + extraHeight + GAP*2 )
if slider then slider:SetPoint("TOPRIGHT", buttons[2], "TOPRIGHT", 19 + TEXT_OFFSET, BUTTON_HEIGHT*.5) end
f:SetWidth( maxWidth + GAP*2 + (hasSlider and 16 + TEXT_OFFSET*2 or 0) )
f:SetHeight( BUTTON_HEIGHT * nbEntries + extraHeight + GAP*2 )
 
Menu_OnEnter(self)
block = block or self
Menu_OnEnter(block)
local showBelow = select( 2, block:GetCenter() ) > ( UIParent:GetHeight() / 2 )
f:ClearAllPoints()
f:SetPoint( showBelow and "TOP" or "BOTTOM", block, showBelow and "BOTTOM" or "TOP" )
for i=#entries+1, #buttons do buttons[i]:Hide() end
if not (tipShown or config.hideHints) then ShowBlockHints() end
end
 
 
function f:FriendsOnEnter()
if InCombatLockdown() then f:Show() return Menu_OnEnter(f) end
return ShowTablet( self, false, friendEntries )
return ShowTablet( self, false )
end
 
function f:GuildOnEnter()
342,7 → 395,7
end
end
f.GuildBlock.text = IsInGuild() and format(config.hideGuildTotal and" %s%d"or" %s%d/%d", config.showGuildName and GetGuildInfo"player" and GetGuildInfo"player"..": " or "", #guildEntries-1, GetNumGuildMembers(true) ) or "No Guild"
if dontShow then dontShow = false else return ShowTablet(self, true, guildEntries) end
if dontShow then dontShow = false else return ShowTablet(self, true) end
end
 
 
361,14 → 414,14
f.GuildBlock.text = format( " %s%d/%d", config.showGuildName and GetGuildInfo"player"..": " or "", #guildEntries-1, GetNumGuildMembers(true) )
elseif IsControlKeyDown() then
config.hideHints = not config.hideHints
ShowTablet( block, isGuild, isGuild and guildEntries or friendEntries )
ShowTablet( block, isGuild )
else ToggleFriendsFrame(3) end
elseif button == "RightButton" and IsShiftKeyDown() then
config.hideGuildTotal = not config.hideGuildTotal
f:GuildOnEnter()
elseif not InCombatLockdown() then
config.showGuildNotes = not config.showGuildNotes
ShowTablet( block, true, guildEntries )
ShowTablet( block, true )
end
end,
} )
382,7 → 435,7
OnClick = function(self, btn)
if IsControlKeyDown() then
config.hideHints = not config.hideHints
ShowTablet( block, isGuild, isGuild and guildEntries or friendEntries )
ShowTablet( block, isGuild )
elseif IsShiftKeyDown() then
config.hideTotalFriends = not config.hideTotalFriends
f:FRIENDLIST_UPDATE()
Ara_Broker_Guild_Friends.toc
1,6 → 1,6
## Interface: 30200
## Title: |cFFFFB366Ara|r - Broker - Guild & Friends
## Version: r19
## Version: r20
## Author: Ara
## Notes: A Data Broker plugin that provides guildmates & friends informations and interactions.
## SavedVariables: AraBrokerGuildFriendsDB