Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 21 | Aranarth-82994 | local BUTTON_HEIGHT, ICON_SIZE, GAP, TEXT_OFFSET, MAX_ENTRIES = |
2 | 23 | Aranarth-82994 | 15, 13, 10, 5 |
3 | 2 | Aranarth-82994 | |
4 | 8 | Aranarth-82994 | local f = CreateFrame( "Frame", "AraBrokerGuildFriends", UIParent ) |
5 | 5 | Aranarth-82994 | local t = CreateFrame"Frame" |
6 | 2 | Aranarth-82994 | |
7 | 18 | Aranarth-82994 | local dontShow, block, horde, config, isGuild, tip, tipShown = true |
8 | 24 | Aranarth-82994 | local defaultConfig = { showGuildNotes = true, showGuildName = true, sortType = "class", sortDESC = false, scale = 1 } |
9 | 21 | Aranarth-82994 | local guildEntries, friendEntries, motd, slider, nbEntries = {}, {} |
10 | Aranarth-82994 | local sliderValue, hasSlider, ShowTablet = 0 |
|
11 | 20 | Aranarth-82994 | local RAID_CLASS_COLORS = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS |
12 | 27 | Aranarth-82994 | local L = {} |
13 | 2 | Aranarth-82994 | |
14 | 28 | Aranarth-82994 | local format, strfind, GetGuildRosterInfo, GetFriendInfo, CLASS_BUTTONS, GetDifficultyColor = |
15 | Aranarth-82994 | format, strfind, GetGuildRosterInfo, GetFriendInfo, CLASS_BUTTONS, GetQuestDifficultyColor |
|
16 | 2 | Aranarth-82994 | |
17 | 7 | Aranarth-82994 | local orgReloadUI = ReloadUI |
18 | Aranarth-82994 | ReloadUI = function(...) |
|
19 | Aranarth-82994 | config.reloading = true |
|
20 | Aranarth-82994 | orgReloadUI(...) |
|
21 | Aranarth-82994 | end |
|
22 | 2 | Aranarth-82994 | |
23 | Aranarth-82994 | local tables = {} |
|
24 | Aranarth-82994 | ||
25 | Aranarth-82994 | local new = function( ... ) |
|
26 | Aranarth-82994 | local table = tremove(tables) or {} |
|
27 | Aranarth-82994 | for i=1, select("#",...) do table[i] = select(i,...) end |
|
28 | Aranarth-82994 | return table |
|
29 | Aranarth-82994 | end |
|
30 | Aranarth-82994 | ||
31 | Aranarth-82994 | local del = function( table ) |
|
32 | Aranarth-82994 | tables[ #tables + 1 ] = wipe(table) |
|
33 | Aranarth-82994 | end |
|
34 | Aranarth-82994 | ||
35 | Aranarth-82994 | ||
36 | Aranarth-82994 | local friendOnline, friendOffline = gsub(ERR_FRIEND_ONLINE_SS,"\124Hplayer:%%s\124h%[%%s%]\124h",""), gsub(ERR_FRIEND_OFFLINE_S,"%%s","") |
|
37 | Aranarth-82994 | function f:CHAT_MSG_SYSTEM( event, msg ) |
|
38 | 6 | Aranarth-82994 | if strfind( msg, friendOnline ) or strfind( msg, friendOffline ) then ShowFriends() end |
39 | 2 | Aranarth-82994 | end |
40 | Aranarth-82994 | ||
41 | Aranarth-82994 | function f:FRIENDLIST_UPDATE() |
|
42 | Aranarth-82994 | for k,v in next,friendEntries do del(v) friendEntries[k]=nil end |
|
43 | Aranarth-82994 | local total, online = GetNumFriends(), 0 |
|
44 | Aranarth-82994 | for i = 1, total do |
|
45 | Aranarth-82994 | local name, level, class, zone, connected, status, note = GetFriendInfo(i) |
|
46 | 17 | Aranarth-82994 | if connected then |
47 | Aranarth-82994 | if online == 0 then |
|
48 | 2 | Aranarth-82994 | friendEntries[1] = new( nil, "Name", "", "Lv", "Zone", "Notes" ) |
49 | Aranarth-82994 | end |
|
50 | Aranarth-82994 | online = online + 1 |
|
51 | 28 | Aranarth-82994 | friendEntries[online+1] = new( name, status ~= "" and format("%s %s", tostring(status), tostring(name)) or name, L[class], level, zone or "Unknown", note and format("[%s]",note) or "-" ) |
52 | 2 | Aranarth-82994 | end |
53 | Aranarth-82994 | end |
|
54 | 18 | Aranarth-82994 | f.FriendsBlock.text = format(config.hideTotalFriends and " %d" or " %d/%d", online, total) |
55 | 17 | Aranarth-82994 | if not isGuild and block then f:FriendsOnEnter(block) end |
56 | 2 | Aranarth-82994 | end |
57 | Aranarth-82994 | ||
58 | Aranarth-82994 | function f:GUILD_ROSTER_UPDATE() |
|
59 | 17 | Aranarth-82994 | dontShow = not(isGuild and block) |
60 | Aranarth-82994 | f.GuildOnEnter(block) |
|
61 | 2 | Aranarth-82994 | end |
62 | Aranarth-82994 | ||
63 | Aranarth-82994 | function f:PLAYER_GUILD_UPDATE(event, unit) |
|
64 | 17 | Aranarth-82994 | if unit and unit ~= "player" then return end |
65 | 2 | Aranarth-82994 | return IsInGuild() and GuildRoster() |
66 | Aranarth-82994 | end |
|
67 | Aranarth-82994 | ||
68 | 7 | Aranarth-82994 | local hordeZones = "Orgrimmar,Undercity,Thunder Bluff,Silvermoon City,Durotar,Tirisfal Glades,The Barrens,Silverpine Forest,Mulgore,The Sepulcher,Eversong Woods,Ghostlands," |
69 | 20 | Aranarth-82994 | 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," |
70 | 2 | Aranarth-82994 | local function GetZoneColor(zone) |
71 | 17 | Aranarth-82994 | if strfind( hordeZones , zone.."," ) then if horde then return 0,1,0 else return 1,0,0 end end |
72 | Aranarth-82994 | if strfind( allianceZones, zone.."," ) then if horde then return 1,0,0 else return 0,1,0 end end |
|
73 | 2 | Aranarth-82994 | return 1,1,0 |
74 | Aranarth-82994 | end |
|
75 | Aranarth-82994 | ||
76 | 18 | Aranarth-82994 | local function ShowBlockHints() |
77 | 25 | Aranarth-82994 | local showBelow = UIParent:GetHeight()-f:GetTop()*f:GetScale() < f:GetBottom()*f:GetScale() |
78 | 18 | Aranarth-82994 | tip:SetOwner(f, "ANCHOR_NONE") |
79 | Aranarth-82994 | tip:SetPoint(showBelow and "TOP" or "BOTTOM", f, showBelow and "BOTTOM" or "TOP") |
|
80 | Aranarth-82994 | tip:AddLine"Hints [|cffffffffBlock|r]" |
|
81 | Aranarth-82994 | tip:AddLine("|cffff8020Click|r to open panel.", .2,1,.2) |
|
82 | Aranarth-82994 | tip:AddLine("|cffff8020Ctrl+Click|r to toggle hints.", .2,1,.2) |
|
83 | Aranarth-82994 | tip:AddLine("|cffff8020Shift+RightClick|r to toggle total number.", .2,1,.2) |
|
84 | Aranarth-82994 | if isGuild then |
|
85 | Aranarth-82994 | tip:AddLine("|cffff8020Shift+Click|r to toggle guild name.", .2,1,.2) |
|
86 | Aranarth-82994 | tip:AddLine("|cffff8020RightClick|r to toggle note column.", .2,1,.2) |
|
87 | Aranarth-82994 | else |
|
88 | Aranarth-82994 | tip:AddLine("|cffff8020EverythingElse|r to add a friend.", .2,1,.2) |
|
89 | Aranarth-82994 | end |
|
90 | Aranarth-82994 | tip:Show() |
|
91 | Aranarth-82994 | end |
|
92 | Aranarth-82994 | ||
93 | Aranarth-82994 | local function ShowHints(btn) |
|
94 | Aranarth-82994 | if not config.hideHints and btn and btn.unit then |
|
95 | 25 | Aranarth-82994 | local showBelow = UIParent:GetHeight()-f:GetTop()*f:GetScale() < f:GetBottom()*f:GetScale() |
96 | 18 | Aranarth-82994 | tip:SetOwner(f, "ANCHOR_NONE") |
97 | Aranarth-82994 | tip:SetPoint(showBelow and "TOP" or "BOTTOM", f, showBelow and "BOTTOM" or "TOP") |
|
98 | Aranarth-82994 | tip:AddLine"Hints" |
|
99 | Aranarth-82994 | tip:AddLine("|cffff8020Click|r to whisper.", .2,1,.2) |
|
100 | Aranarth-82994 | tip:AddLine("|cffff8020Alt+Click|r to invite.", .2,1,.2) |
|
101 | Aranarth-82994 | tip:AddLine("|cffff8020Shift+Click|r to query guild.", .2, 1, .2) |
|
102 | Aranarth-82994 | if not isGuild or CanEditPublicNote() then tip:AddLine("|cffff8020Ctrl+Click|r to edit note.", .2, 1, .2) end |
|
103 | Aranarth-82994 | if isGuild then |
|
104 | Aranarth-82994 | if CanEditOfficerNote() then tip:AddLine("|cffff8020Ctrl+RightClick|r to edit officer note.", .2, 1, .2) end |
|
105 | Aranarth-82994 | tip:AddLine("|cffff8020RightClick|r to sort closest column.", .2, 1, .2) |
|
106 | Aranarth-82994 | else |
|
107 | Aranarth-82994 | tip:AddLine("|cffff8020MiddleClick|r to remove friend.", .2, 1, .2) |
|
108 | Aranarth-82994 | end |
|
109 | 26 | Aranarth-82994 | tip:AddLine("|cffff8020Ctrl+MouseWheel|r to resize tooltip.", .2, 1, .2) |
110 | 18 | Aranarth-82994 | tip:Show() |
111 | Aranarth-82994 | tipShown = true |
|
112 | Aranarth-82994 | end |
|
113 | Aranarth-82994 | end |
|
114 | Aranarth-82994 | ||
115 | 7 | Aranarth-82994 | local highlight = f:CreateTexture() |
116 | 2 | Aranarth-82994 | highlight:SetTexture"Interface\\QuestFrame\\UI-QuestTitleHighlight" |
117 | Aranarth-82994 | highlight:SetBlendMode"ADD" |
|
118 | Aranarth-82994 | highlight:SetAlpha(0) |
|
119 | Aranarth-82994 | ||
120 | Aranarth-82994 | local function Menu_OnEnter(b) |
|
121 | 28 | Aranarth-82994 | if b and b.index then |
122 | 2 | Aranarth-82994 | highlight:SetAllPoints(b) |
123 | 18 | Aranarth-82994 | if b.index > 1 then |
124 | Aranarth-82994 | highlight:SetAlpha(1) |
|
125 | Aranarth-82994 | ShowHints(b) |
|
126 | Aranarth-82994 | end |
|
127 | 2 | Aranarth-82994 | end |
128 | Aranarth-82994 | end |
|
129 | Aranarth-82994 | ||
130 | Aranarth-82994 | local function Menu_OnLeave(b) |
|
131 | Aranarth-82994 | highlight:ClearAllPoints() |
|
132 | 18 | Aranarth-82994 | tip:Hide() |
133 | Aranarth-82994 | tipShown = false |
|
134 | 28 | Aranarth-82994 | if b and b.index and b.index > 1 then highlight:SetAlpha(0) end |
135 | 21 | Aranarth-82994 | if not MouseIsOver(f) then |
136 | Aranarth-82994 | sliderValue = 0 |
|
137 | Aranarth-82994 | block = nil |
|
138 | Aranarth-82994 | f:Hide() |
|
139 | Aranarth-82994 | end |
|
140 | 2 | Aranarth-82994 | end |
141 | Aranarth-82994 | ||
142 | Aranarth-82994 | local function CreateFS( index, parent, justify, anchor ) |
|
143 | 16 | Aranarth-82994 | local fs = parent:CreateFontString( nil, "OVERLAY", "SystemFont_Shadow_Med1" ) |
144 | 2 | Aranarth-82994 | fs:SetJustifyH( justify ) |
145 | Aranarth-82994 | fs:SetTextColor( 1, index == 1 and .8 or 1, 0 ) |
|
146 | 17 | Aranarth-82994 | if anchor then fs:SetPoint( "LEFT", anchor, "RIGHT", GAP, 0 ) end |
147 | 2 | Aranarth-82994 | return fs |
148 | Aranarth-82994 | end |
|
149 | Aranarth-82994 | ||
150 | 21 | Aranarth-82994 | local function EditMOTD() |
151 | Aranarth-82994 | f:Hide() |
|
152 | Aranarth-82994 | block = nil |
|
153 | Aranarth-82994 | GuildMOTDEditButton:Click() |
|
154 | Aranarth-82994 | end |
|
155 | Aranarth-82994 | ||
156 | Aranarth-82994 | local cols, colspace = { "class", "name", "level", "zone", "note", "rank" }, { ICON_SIZE } |
|
157 | Aranarth-82994 | ||
158 | Aranarth-82994 | local function OnGuildmateClick( self, button ) |
|
159 | Aranarth-82994 | if not( self and self.unit ) then return end |
|
160 | Aranarth-82994 | if isGuild and button ~= "LeftButton" and not IsModifierKeyDown() then -- sort columns |
|
161 | Aranarth-82994 | local prevDist = GetCursorPosition() / self:GetEffectiveScale() - self:GetLeft() |
|
162 | Aranarth-82994 | local colpos, dist = colspace[1] - prevDist |
|
163 | Aranarth-82994 | for i=2, #colspace do |
|
164 | Aranarth-82994 | colpos = colpos + colspace[i] + (i==2 and TEXT_OFFSET or GAP) |
|
165 | Aranarth-82994 | dist = abs( colpos - colspace[i]*.5 ) |
|
166 | Aranarth-82994 | if dist > prevDist then dist, prevDist = i-1, -1 break else prevDist = dist end |
|
167 | Aranarth-82994 | end |
|
168 | Aranarth-82994 | colpos = prevDist < 0 and dist or #colspace |
|
169 | Aranarth-82994 | colpos = not config.showGuildNotes and colpos == 5 and "rank" or cols[colpos] |
|
170 | Aranarth-82994 | if config.sortType == colpos then |
|
171 | Aranarth-82994 | config.sortDESC = not config.sortDESC |
|
172 | Aranarth-82994 | else |
|
173 | Aranarth-82994 | config.sortType, config.sortDESC = colpos, false |
|
174 | Aranarth-82994 | end |
|
175 | Aranarth-82994 | SortGuildRoster( colpos ) |
|
176 | Aranarth-82994 | elseif button == "MiddleButton" and not isGuild then |
|
177 | Aranarth-82994 | RemoveFriend( self.unit ) |
|
178 | Aranarth-82994 | elseif IsAltKeyDown() then |
|
179 | Aranarth-82994 | InviteUnit( self.unit ) |
|
180 | Aranarth-82994 | elseif IsControlKeyDown() then |
|
181 | Aranarth-82994 | if not isGuild then |
|
182 | Aranarth-82994 | FriendsFrame.NotesID = self.index - 1 |
|
183 | Aranarth-82994 | StaticPopup_Show( "SET_FRIENDNOTE", self.unit ) |
|
184 | Aranarth-82994 | elseif button == "LeftButton" and CanEditPublicNote() or button ~= "LeftButton" and CanEditOfficerNote() then |
|
185 | Aranarth-82994 | SetGuildRosterSelection( guildEntries[self.index][8] ) |
|
186 | Aranarth-82994 | StaticPopup_Show( button == "LeftButton" and "SET_GUILDPLAYERNOTE" or "SET_GUILDOFFICERNOTE" ) |
|
187 | Aranarth-82994 | end |
|
188 | Aranarth-82994 | else |
|
189 | Aranarth-82994 | SetItemRef("player:"..self.unit, "|Hplayer:"..self.unit.."|h["..self.unit.."]|h", "LeftButton") |
|
190 | Aranarth-82994 | end |
|
191 | Aranarth-82994 | end |
|
192 | Aranarth-82994 | ||
193 | Aranarth-82994 | local function Scroll(self, delta) |
|
194 | 24 | Aranarth-82994 | if IsControlKeyDown() then |
195 | Aranarth-82994 | config.scale = config.scale - delta * .05 |
|
196 | Aranarth-82994 | return ShowTablet(tipShown, isGuild) |
|
197 | Aranarth-82994 | end |
|
198 | 23 | Aranarth-82994 | slider:SetValue( sliderValue - delta * (IsModifierKeyDown() and 10 or 3) ) |
199 | 21 | Aranarth-82994 | end |
200 | Aranarth-82994 | ||
201 | Aranarth-82994 | local buttons = setmetatable( { }, { __index = function( table, key ) |
|
202 | 2 | Aranarth-82994 | local button = CreateFrame( "Button", nil, f ) |
203 | 5 | Aranarth-82994 | table[key] = button |
204 | 2 | Aranarth-82994 | button.index = key |
205 | 11 | Aranarth-82994 | button:SetNormalFontObject(GameFontNormal) |
206 | 2 | Aranarth-82994 | button:RegisterForClicks"AnyUp" |
207 | Aranarth-82994 | button:SetScript( "OnEnter", Menu_OnEnter ) |
|
208 | Aranarth-82994 | button:SetScript( "OnLeave", Menu_OnLeave ) |
|
209 | 21 | Aranarth-82994 | |
210 | Aranarth-82994 | button:EnableMouseWheel(true) |
|
211 | Aranarth-82994 | button:SetScript( "OnMouseWheel", Scroll) |
|
212 | Aranarth-82994 | ||
213 | 5 | Aranarth-82994 | button.fontName = CreateFS( key, button, "LEFT" ) |
214 | 17 | Aranarth-82994 | if key == 0 then |
215 | 20 | Aranarth-82994 | motd = button |
216 | Aranarth-82994 | motd.fontName:SetJustifyV"TOP" |
|
217 | Aranarth-82994 | motd.fontName:SetPoint( "TOPLEFT", motd, "TOPLEFT" ) |
|
218 | Aranarth-82994 | motd:SetPoint( "TOPLEFT", f, "TOPLEFT", GAP, -GAP ) |
|
219 | 2 | Aranarth-82994 | else |
220 | 20 | Aranarth-82994 | button:SetHeight( BUTTON_HEIGHT ) |
221 | 11 | Aranarth-82994 | button.icon = button:CreateTexture() |
222 | Aranarth-82994 | button.icon:SetWidth( ICON_SIZE ) button.icon:SetHeight( ICON_SIZE ) |
|
223 | 13 | Aranarth-82994 | button.icon:SetPoint( "LEFT", button, "LEFT" ) |
224 | 11 | Aranarth-82994 | |
225 | 13 | Aranarth-82994 | button.fontName:SetPoint( "LEFT", button.icon, "RIGHT", TEXT_OFFSET, 0 ) |
226 | 2 | Aranarth-82994 | button.fontLevel = CreateFS( key, button, "CENTER", button.fontName ) |
227 | Aranarth-82994 | button.fontZone = CreateFS( key, button, "CENTER", button.fontLevel ) |
|
228 | Aranarth-82994 | button.fontNotes = CreateFS( key, button, "CENTER", button.fontZone ) |
|
229 | Aranarth-82994 | button.fontRank = CreateFS( key, button, "RIGHT", button.fontNotes ) |
|
230 | Aranarth-82994 | end |
|
231 | Aranarth-82994 | return button |
|
232 | Aranarth-82994 | end } ) |
|
233 | Aranarth-82994 | ||
234 | 13 | Aranarth-82994 | local function SetButtonData( index, name, class, level, zone, notes, rank, inGroup, isGrouped ) |
235 | 2 | Aranarth-82994 | local button = buttons[index] |
236 | 9 | Aranarth-82994 | button.fontName:SetText( name or "" ) |
237 | 17 | Aranarth-82994 | if class then |
238 | Aranarth-82994 | if index > 1 then |
|
239 | 13 | Aranarth-82994 | local color = RAID_CLASS_COLORS[class] |
240 | 28 | Aranarth-82994 | button.fontName:SetTextColor( color.r, color.g, color.b ) |
241 | Aranarth-82994 | if inGroup then |
|
242 | Aranarth-82994 | button.icon:SetTexture(isGrouped and "Interface\\Buttons\\UI-CheckBox-Check" or "") |
|
243 | Aranarth-82994 | button.icon:SetTexCoord(.15,.85,.15,.85) |
|
244 | 13 | Aranarth-82994 | else |
245 | 28 | Aranarth-82994 | button.icon:SetTexture"Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes" |
246 | Aranarth-82994 | local offset, left, right, bottom, top = 0.025, unpack( CLASS_BUTTONS[class] ) |
|
247 | Aranarth-82994 | button.icon:SetTexCoord( left+offset, right-offset, bottom+offset, top-offset ) |
|
248 | 6 | Aranarth-82994 | end |
249 | 2 | Aranarth-82994 | color = GetDifficultyColor(level) |
250 | Aranarth-82994 | button.fontLevel:SetTextColor( color.r, color.g, color.b ) |
|
251 | Aranarth-82994 | button.fontZone:SetTextColor( GetZoneColor(zone or "#") ) |
|
252 | Aranarth-82994 | end |
|
253 | Aranarth-82994 | button.fontLevel:SetText( level or "" ) |
|
254 | Aranarth-82994 | button.fontZone:SetText( zone or "" ) |
|
255 | Aranarth-82994 | button.fontNotes:SetText( notes or "" ) |
|
256 | Aranarth-82994 | button.fontRank:SetText( rank or "" ) |
|
257 | Aranarth-82994 | return button, button.fontName:GetStringWidth(), button.fontLevel:GetStringWidth(), button.fontZone:GetStringWidth(), button.fontNotes:GetStringWidth(), button.fontRank:GetStringWidth() |
|
258 | Aranarth-82994 | end |
|
259 | Aranarth-82994 | return button, button.fontName:GetStringWidth() |
|
260 | Aranarth-82994 | end |
|
261 | Aranarth-82994 | ||
262 | 23 | Aranarth-82994 | local function UpdateScrollButtons(nbEntries) |
263 | Aranarth-82994 | local btn = buttons[1] |
|
264 | Aranarth-82994 | for i=2, #buttons do buttons[i]:Hide() end |
|
265 | Aranarth-82994 | for i=2, nbEntries do |
|
266 | Aranarth-82994 | button = buttons[sliderValue+i] |
|
267 | Aranarth-82994 | button:SetPoint("TOPLEFT", btn, "TOPLEFT", 0, BUTTON_HEIGHT*(1-i)) |
|
268 | Aranarth-82994 | button:Show() |
|
269 | Aranarth-82994 | end |
|
270 | Aranarth-82994 | end |
|
271 | Aranarth-82994 | ||
272 | 21 | Aranarth-82994 | ShowTablet = function( self, _isGuild ) |
273 | 9 | Aranarth-82994 | f:Show() |
274 | 2 | Aranarth-82994 | isGuild = _isGuild |
275 | 21 | Aranarth-82994 | |
276 | 24 | Aranarth-82994 | f:SetScale(config.scale) |
277 | 23 | Aranarth-82994 | MAX_ENTRIES = floor( WorldFrame:GetHeight() / ( BUTTON_HEIGHT * f:GetEffectiveScale() ) ) - (config.hideHints and 6 or 12) |
278 | Aranarth-82994 | slider:SetHeight(BUTTON_HEIGHT*MAX_ENTRIES) |
|
279 | Aranarth-82994 | ||
280 | 21 | Aranarth-82994 | local entries = isGuild and guildEntries or friendEntries |
281 | 9 | Aranarth-82994 | local hasEntries = #entries > 0 |
282 | 21 | Aranarth-82994 | hasSlider = #entries > MAX_ENTRIES |
283 | Aranarth-82994 | ||
284 | 17 | Aranarth-82994 | if not hasEntries then |
285 | 11 | Aranarth-82994 | entries[1] = new( nil, isGuild and ERR_GUILD_PLAYER_NOT_IN_GUILD or "No friends online.", "" ) |
286 | 23 | Aranarth-82994 | end |
287 | Aranarth-82994 | if hasSlider then |
|
288 | 21 | Aranarth-82994 | slider:SetMinMaxValues( 0, #entries - MAX_ENTRIES ) |
289 | Aranarth-82994 | slider:SetValue(sliderValue) |
|
290 | Aranarth-82994 | slider:Show() |
|
291 | 23 | Aranarth-82994 | else slider:Hide() end |
292 | 7 | Aranarth-82994 | |
293 | 21 | Aranarth-82994 | nbEntries = math.min( MAX_ENTRIES, #entries ) |
294 | 2 | Aranarth-82994 | local nameC, levelC, zoneC, notesC, rankC = 0, 0, 0, 0, 0 |
295 | Aranarth-82994 | local nameW, levelW, zoneW, notesW, rankW |
|
296 | 6 | Aranarth-82994 | local hideNotes = isGuild and not config.showGuildNotes |
297 | 21 | Aranarth-82994 | local extraHeight, button = 0 |
298 | 2 | Aranarth-82994 | |
299 | 11 | Aranarth-82994 | local isGrouped = GetNumRaidMembers()>0 and UnitInRaid or GetNumPartyMembers()>0 and UnitInParty or nil |
300 | 21 | Aranarth-82994 | for i = 1, #entries do |
301 | Aranarth-82994 | local entry = entries[i] |
|
302 | 20 | Aranarth-82994 | 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]) ) |
303 | 2 | Aranarth-82994 | button.unit = entry[1] |
304 | 11 | Aranarth-82994 | button:SetScript( "OnClick", OnGuildmateClick ) |
305 | 17 | Aranarth-82994 | if nameW > nameC then nameC = nameW end |
306 | Aranarth-82994 | if levelW and levelW>0 then |
|
307 | Aranarth-82994 | if levelW > levelC then levelC = levelW end |
|
308 | Aranarth-82994 | if zoneW > zoneC then zoneC = zoneW end |
|
309 | Aranarth-82994 | if notesW > notesC then notesC = notesW end |
|
310 | Aranarth-82994 | if rankW > rankC then rankC = rankW end |
|
311 | Aranarth-82994 | if hideNotes then button.fontNotes:Hide() else button.fontNotes:Show() end |
|
312 | 7 | Aranarth-82994 | button.fontRank:SetPoint( "LEFT", hideNotes and button.fontZone or button.fontNotes, "RIGHT", GAP, 0 ) |
313 | Aranarth-82994 | end |
|
314 | 2 | Aranarth-82994 | end |
315 | Aranarth-82994 | ||
316 | 17 | Aranarth-82994 | if hideNotes then notesC = -GAP end |
317 | 16 | Aranarth-82994 | local maxWidth = ICON_SIZE + TEXT_OFFSET + nameC + levelC + zoneC + notesC + rankC + GAP * (isGuild and 4 or 3) |
318 | 2 | Aranarth-82994 | |
319 | 17 | Aranarth-82994 | if isGuild and hasEntries then |
320 | 20 | Aranarth-82994 | SetButtonData( 0, "|cffffffffMOTD:|r "..GetGuildRosterMOTD() ) |
321 | Aranarth-82994 | if CanEditMOTD() then motd:SetScript( "OnClick", EditMOTD ) end |
|
322 | Aranarth-82994 | motd.fontName:SetWidth( maxWidth ) |
|
323 | 21 | Aranarth-82994 | extraHeight = motd.fontName:GetHeight() + BUTTON_HEIGHT |
324 | 2 | Aranarth-82994 | motd:SetWidth( maxWidth ) |
325 | 21 | Aranarth-82994 | motd:SetHeight( extraHeight ) |
326 | Aranarth-82994 | motd:Show() |
|
327 | 2 | Aranarth-82994 | buttons[1]:SetPoint( "TOPLEFT", motd, "BOTTOMLEFT" ) |
328 | 20 | Aranarth-82994 | else |
329 | 2 | Aranarth-82994 | buttons[0]:Hide() |
330 | 20 | Aranarth-82994 | buttons[1]:SetPoint( "TOPLEFT", f, "TOPLEFT", GAP, -GAP ) |
331 | 2 | Aranarth-82994 | end |
332 | Aranarth-82994 | ||
333 | 23 | Aranarth-82994 | UpdateScrollButtons(nbEntries) |
334 | 21 | Aranarth-82994 | |
335 | 2 | Aranarth-82994 | for i=1, #entries do |
336 | Aranarth-82994 | button = buttons[i] |
|
337 | 4 | Aranarth-82994 | button:SetWidth( maxWidth ) |
338 | 2 | Aranarth-82994 | button.fontName:SetWidth(nameC) |
339 | Aranarth-82994 | button.fontLevel:SetWidth(levelC) |
|
340 | Aranarth-82994 | button.fontZone:SetWidth(zoneC) |
|
341 | Aranarth-82994 | button.fontNotes:SetWidth(notesC) |
|
342 | Aranarth-82994 | button.fontRank:SetWidth(rankC) |
|
343 | Aranarth-82994 | end |
|
344 | Aranarth-82994 | colspace[2], colspace[3], colspace[4], colspace[5], colspace[6] = nameC, levelC, zoneC, notesC, rankC |
|
345 | Aranarth-82994 | ||
346 | 23 | Aranarth-82994 | if hasSlider then slider:SetPoint("TOPRIGHT", buttons[2], "TOPRIGHT", 19 + TEXT_OFFSET, BUTTON_HEIGHT*.5) end |
347 | 21 | Aranarth-82994 | f:SetWidth( maxWidth + GAP*2 + (hasSlider and 16 + TEXT_OFFSET*2 or 0) ) |
348 | Aranarth-82994 | f:SetHeight( BUTTON_HEIGHT * nbEntries + extraHeight + GAP*2 ) |
|
349 | 2 | Aranarth-82994 | |
350 | 21 | Aranarth-82994 | block = block or self |
351 | Aranarth-82994 | Menu_OnEnter(block) |
|
352 | 2 | Aranarth-82994 | local showBelow = select( 2, block:GetCenter() ) > ( UIParent:GetHeight() / 2 ) |
353 | Aranarth-82994 | f:ClearAllPoints() |
|
354 | Aranarth-82994 | f:SetPoint( showBelow and "TOP" or "BOTTOM", block, showBelow and "BOTTOM" or "TOP" ) |
|
355 | 18 | Aranarth-82994 | if not (tipShown or config.hideHints) then ShowBlockHints() end |
356 | 2 | Aranarth-82994 | end |
357 | Aranarth-82994 | ||
358 | Aranarth-82994 | ||
359 | Aranarth-82994 | function f:FriendsOnEnter() |
|
360 | 17 | Aranarth-82994 | if InCombatLockdown() then f:Show() return Menu_OnEnter(f) end |
361 | 21 | Aranarth-82994 | return ShowTablet( self, false ) |
362 | 2 | Aranarth-82994 | end |
363 | Aranarth-82994 | ||
364 | 15 | Aranarth-82994 | function f:GuildOnEnter() |
365 | 17 | Aranarth-82994 | if not dontShow and InCombatLockdown() then f:Show() return Menu_OnEnter(f) end |
366 | 2 | Aranarth-82994 | for k, v in next, guildEntries do del(v) guildEntries[k]=nil end |
367 | Aranarth-82994 | for i=1, GetNumGuildMembers(true) do |
|
368 | 28 | Aranarth-82994 | local name, rank, _, level, class, zone, note, offnote, connected, status = GetGuildRosterInfo(i) |
369 | 17 | Aranarth-82994 | if connected then |
370 | Aranarth-82994 | if #guildEntries == 0 then |
|
371 | 2 | Aranarth-82994 | guildEntries[1] = new( nil, "Name", "", "Lv", "Zone", "Notes", "Rank" ) |
372 | Aranarth-82994 | end |
|
373 | Aranarth-82994 | local notes = note ~= "" and (offnote ~= "" and |
|
374 | 5 | Aranarth-82994 | format( "[%s] - \124cffff9944[%s]\124r", note, offnote ) or |
375 | 2 | Aranarth-82994 | format( "[%s]", note )) or (offnote ~= "" and |
376 | 5 | Aranarth-82994 | format( "\124cffff9944[%s]\124r", offnote ) or "-") |
377 | 28 | Aranarth-82994 | guildEntries[#guildEntries+1] = new( name, status == "" and name or format( "%s %s", status, name ), L[class], level, zone, notes, rank, i ) |
378 | 2 | Aranarth-82994 | end |
379 | Aranarth-82994 | end |
|
380 | 19 | Aranarth-82994 | 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" |
381 | 21 | Aranarth-82994 | if dontShow then dontShow = false else return ShowTablet(self, true) end |
382 | 2 | Aranarth-82994 | end |
383 | Aranarth-82994 | ||
384 | Aranarth-82994 | ||
385 | Aranarth-82994 | local ldb = LibStub("LibDataBroker-1.1") |
|
386 | Aranarth-82994 | ||
387 | Aranarth-82994 | f.GuildBlock = ldb:NewDataObject( "|cFFFFB366Ara|r Guild", { |
|
388 | 14 | Aranarth-82994 | type = "data source", |
389 | 2 | Aranarth-82994 | text = GUILD, |
390 | 4 | Aranarth-82994 | icon = "Interface\\AddOns\\Ara_Broker_Guild_Friends\\guild.tga", |
391 | 2 | Aranarth-82994 | OnEnter = f.GuildOnEnter, |
392 | 9 | Aranarth-82994 | OnLeave = Menu_OnLeave, |
393 | 18 | Aranarth-82994 | OnClick = function(self, button) |
394 | Aranarth-82994 | if button == "LeftButton" then |
|
395 | Aranarth-82994 | if IsShiftKeyDown() and IsInGuild() then |
|
396 | Aranarth-82994 | config.showGuildName = not config.showGuildName |
|
397 | Aranarth-82994 | f.GuildBlock.text = format( " %s%d/%d", config.showGuildName and GetGuildInfo"player"..": " or "", #guildEntries-1, GetNumGuildMembers(true) ) |
|
398 | Aranarth-82994 | elseif IsControlKeyDown() then |
|
399 | Aranarth-82994 | config.hideHints = not config.hideHints |
|
400 | 21 | Aranarth-82994 | ShowTablet( block, isGuild ) |
401 | 18 | Aranarth-82994 | else ToggleFriendsFrame(3) end |
402 | Aranarth-82994 | elseif button == "RightButton" and IsShiftKeyDown() then |
|
403 | Aranarth-82994 | config.hideGuildTotal = not config.hideGuildTotal |
|
404 | Aranarth-82994 | f:GuildOnEnter() |
|
405 | Aranarth-82994 | elseif not InCombatLockdown() then |
|
406 | Aranarth-82994 | config.showGuildNotes = not config.showGuildNotes |
|
407 | 21 | Aranarth-82994 | ShowTablet( block, true ) |
408 | 18 | Aranarth-82994 | end |
409 | Aranarth-82994 | end, |
|
410 | 2 | Aranarth-82994 | } ) |
411 | Aranarth-82994 | ||
412 | Aranarth-82994 | f.FriendsBlock = ldb:NewDataObject( "|cFFFFB366Ara|r Friends", { |
|
413 | 14 | Aranarth-82994 | type = "data source", |
414 | 2 | Aranarth-82994 | text = FRIENDS, |
415 | 4 | Aranarth-82994 | icon = "Interface\\AddOns\\Ara_Broker_Guild_Friends\\friends.tga", |
416 | 2 | Aranarth-82994 | OnEnter = f.FriendsOnEnter, |
417 | 9 | Aranarth-82994 | OnLeave = Menu_OnLeave, |
418 | 18 | Aranarth-82994 | OnClick = function(self, btn) |
419 | Aranarth-82994 | if IsControlKeyDown() then |
|
420 | Aranarth-82994 | config.hideHints = not config.hideHints |
|
421 | 21 | Aranarth-82994 | ShowTablet( block, isGuild ) |
422 | 18 | Aranarth-82994 | elseif IsShiftKeyDown() then |
423 | Aranarth-82994 | config.hideTotalFriends = not config.hideTotalFriends |
|
424 | Aranarth-82994 | f:FRIENDLIST_UPDATE() |
|
425 | Aranarth-82994 | elseif IsModifierKeyDown() or btn~="LeftButton" then |
|
426 | Aranarth-82994 | StaticPopup_Show"ADD_FRIEND" |
|
427 | Aranarth-82994 | else |
|
428 | Aranarth-82994 | ToggleFriendsFrame(1) |
|
429 | Aranarth-82994 | end |
|
430 | Aranarth-82994 | end, |
|
431 | 2 | Aranarth-82994 | } ) |
432 | Aranarth-82994 | ||
433 | Aranarth-82994 | local orgGuildRoster = GuildRoster |
|
434 | Aranarth-82994 | GuildRoster = function(...) |
|
435 | 5 | Aranarth-82994 | t.guildTimer = 0 |
436 | 2 | Aranarth-82994 | return orgGuildRoster(...) |
437 | Aranarth-82994 | end |
|
438 | Aranarth-82994 | ||
439 | 17 | Aranarth-82994 | local orgShowFriends = ShowFriends |
440 | Aranarth-82994 | ShowFriends = function(...) |
|
441 | Aranarth-82994 | t.friendTimer = 0 |
|
442 | Aranarth-82994 | return orgShowFriends(...) |
|
443 | Aranarth-82994 | end |
|
444 | Aranarth-82994 | ||
445 | 2 | Aranarth-82994 | local function OnUpdate( self, elapsed ) |
446 | 6 | Aranarth-82994 | t.guildTimer = t.guildTimer + elapsed |
447 | 17 | Aranarth-82994 | if t.guildTimer > 15 then |
448 | 5 | Aranarth-82994 | if IsInGuild() then GuildRoster() else t.guildTimer = 0 end |
449 | 2 | Aranarth-82994 | end |
450 | 17 | Aranarth-82994 | t.friendTimer = t.friendTimer + elapsed |
451 | Aranarth-82994 | if t.friendTimer > 15 then ShowFriends() end |
|
452 | 2 | Aranarth-82994 | end |
453 | Aranarth-82994 | ||
454 | 7 | Aranarth-82994 | function f:ADDON_LOADED( event, addon ) |
455 | 23 | Aranarth-82994 | if addon ~= "Ara_Broker_Guild_Friends" then return else f:UnregisterEvent(event) end |
456 | 6 | Aranarth-82994 | AraBrokerGuildFriendsDB = AraBrokerGuildFriendsDB or defaultConfig |
457 | Aranarth-82994 | config = AraBrokerGuildFriendsDB |
|
458 | Aranarth-82994 | for k, v in next, defaultConfig do if config[k]==nil then config[k]=v end end |
|
459 | 17 | Aranarth-82994 | if config.reloading then config.reloading = nil else SortGuildRoster(config.sortType) if config.sortDESC then SortGuildRoster(config.sortType) end end |
460 | 2 | Aranarth-82994 | |
461 | 27 | Aranarth-82994 | for eng, loc in next, LOCALIZED_CLASS_NAMES_MALE do |
462 | Aranarth-82994 | L[loc] = eng |
|
463 | Aranarth-82994 | end |
|
464 | Aranarth-82994 | for eng, loc in next, LOCALIZED_CLASS_NAMES_FEMALE do |
|
465 | Aranarth-82994 | L[loc] = eng |
|
466 | Aranarth-82994 | end |
|
467 | Aranarth-82994 | ||
468 | 28 | Aranarth-82994 | tip = GameTooltip |
469 | 2 | Aranarth-82994 | horde = UnitFactionGroup"player" == "Horde" |
470 | 28 | Aranarth-82994 | if Skinner then |
471 | Aranarth-82994 | Skinner:applySkin(self) |
|
472 | 6 | Aranarth-82994 | else |
473 | 11 | Aranarth-82994 | f:SetBackdrop( { bgFile="Interface\\Buttons\\WHITE8X8", edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", |
474 | 6 | Aranarth-82994 | tile=true, tileSize=12, edgeSize=12, insets = { left=2, right=2, top=2, bottom=2 } } ) |
475 | 11 | Aranarth-82994 | f:SetBackdropColor( 0, 0, 0, .75 ) |
476 | 6 | Aranarth-82994 | end |
477 | 11 | Aranarth-82994 | f.red, f.green, f.blue, f.alpha = f:GetBackdropColor() |
478 | 7 | Aranarth-82994 | f:SetFrameStrata"TOOLTIP" |
479 | Aranarth-82994 | f:SetClampedToScreen(true) |
|
480 | 14 | Aranarth-82994 | f:EnableMouse(true) |
481 | 2 | Aranarth-82994 | |
482 | 5 | Aranarth-82994 | t:SetScript( "OnUpdate", OnUpdate ) |
483 | 7 | Aranarth-82994 | f:SetScript( "OnEnter", Menu_OnEnter ) |
484 | Aranarth-82994 | f:SetScript( "OnLeave", Menu_OnLeave ) |
|
485 | 2 | Aranarth-82994 | |
486 | 7 | Aranarth-82994 | f:RegisterEvent"GUILD_ROSTER_UPDATE" |
487 | Aranarth-82994 | f:RegisterEvent"PLAYER_GUILD_UPDATE" |
|
488 | Aranarth-82994 | f:RegisterEvent"FRIENDLIST_UPDATE" |
|
489 | Aranarth-82994 | f:RegisterEvent"CHAT_MSG_SYSTEM" |
|
490 | 2 | Aranarth-82994 | |
491 | 23 | Aranarth-82994 | slider = CreateFrame("Slider", nil, f) |
492 | Aranarth-82994 | slider:SetWidth(16) |
|
493 | Aranarth-82994 | slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") |
|
494 | Aranarth-82994 | slider:SetBackdrop( { |
|
495 | Aranarth-82994 | bgFile = "Interface\\Buttons\\UI-SliderBar-Background", |
|
496 | Aranarth-82994 | edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", |
|
497 | Aranarth-82994 | edgeSize = 8, tile = true, tileSize = 8, |
|
498 | Aranarth-82994 | insets = {left = 3, right = 3, top = 6, bottom = 6} |
|
499 | Aranarth-82994 | } ) |
|
500 | Aranarth-82994 | slider:SetValueStep(1) |
|
501 | Aranarth-82994 | slider:SetScript( "OnLeave", Menu_OnLeave ) |
|
502 | Aranarth-82994 | slider:SetScript( "OnValueChanged", function(self, value) |
|
503 | Aranarth-82994 | if hasSlider then |
|
504 | Aranarth-82994 | sliderValue = value |
|
505 | Aranarth-82994 | if block then UpdateScrollButtons(MAX_ENTRIES) end |
|
506 | Aranarth-82994 | end |
|
507 | Aranarth-82994 | end ) |
|
508 | Aranarth-82994 | ||
509 | 20 | Aranarth-82994 | ShowFriends() |
510 | Aranarth-82994 | if IsInGuild(buttons[0]) then GuildRoster() else t.guildTimer = 0 end |
|
511 | 15 | Aranarth-82994 | f:GuildOnEnter() |
512 | 7 | Aranarth-82994 | f.ADDON_LOADED = nil |
513 | 2 | Aranarth-82994 | end |
514 | Aranarth-82994 | ||
515 | 6 | Aranarth-82994 | f:RegisterEvent"ADDON_LOADED" |
516 | 2 | Aranarth-82994 | f:SetScript( "OnEvent", function(self, event, ...) return self[event](self, event, ...) end ) |
517 | 11 | Aranarth-82994 | f:SetScript( "OnShow", function(self) f:SetBackdropColor( InCombatLockdown() and f.red+.25 or f.red, f.green, f.blue, f.alpha) end ) |