vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -------------------------------------------------------------------------- |
2 | -- FriendsFacts.lua |
||
3 | -------------------------------------------------------------------------- |
||
4 | --[[ |
||
5 | FriendsFacts v1.0 |
||
6 | |||
7 | author: AnduinLothar <Anduin@cosmosui.org> |
||
8 | |||
9 | Replaces an old Cosmos FrameXML/FriendsFrame.lua Hack. |
||
10 | |||
11 | Remember friends level, class and location after they've logged off. Thanks to George Warner for this original hack. |
||
12 | TODO: check how old the data is and not display it if older than some arbitrary value |
||
13 | |||
14 | Change Log: |
||
15 | v1.0 (2/19/05) |
||
16 | -Rerelease in addon form. |
||
17 | -Modified Width for offline overflow with long location names. |
||
18 | v1.1 (4/29/05) |
||
19 | -Friend info now stored for all friends and not just the ones you look at. |
||
20 | -nil index bug fixed. |
||
21 | |||
22 | ]]-- |
||
23 | |||
24 | |||
25 | local SavedFriendsList_Update = nil; |
||
26 | FriendsFacts_Enabled = true; |
||
27 | |||
28 | function FriendsFacts_OnLoad() |
||
29 | |||
30 | if ( FriendsFacts_Enabled ) then |
||
31 | -- Hook the FriendsList_Update handler |
||
32 | if (FriendsList_Update ~= SavedFriendsList_Update) then |
||
33 | SavedFriendsList_Update = FriendsList_Update; |
||
34 | FriendsList_Update = FriendsFacts_FriendsList_Update; |
||
35 | end |
||
36 | end |
||
37 | |||
38 | end |
||
39 | |||
40 | |||
41 | function FriendsFacts_OnEvent(event) |
||
42 | if ( event == "VARIABLES_LOADED" ) and ( FriendsFacts_Enabled ) then |
||
43 | |||
44 | if ( not FriendsFacts_Data ) then |
||
45 | FriendsFacts_Data = {}; |
||
46 | end |
||
47 | RegisterForSave("FriendsFacts_Data"); |
||
48 | |||
49 | end |
||
50 | end |
||
51 | |||
52 | |||
53 | function FriendsFacts_FriendsList_Update() |
||
54 | SavedFriendsList_Update(); |
||
55 | |||
56 | local nameLocationText; |
||
57 | local infoText; |
||
58 | local friendOffset = FauxScrollFrame_GetOffset(FriendsFrameFriendsScrollFrame); |
||
59 | local friendIndex; |
||
60 | local numFriends = GetNumFriends(); |
||
61 | |||
62 | for i=1, numFriends do |
||
63 | local name, level, class, area, connected = GetFriendInfo(i); |
||
64 | |||
65 | if (name) and (connected) then |
||
66 | if ( not FriendsFacts_Data[name] ) and ( FriendsFacts_Enabled ) then |
||
67 | FriendsFacts_Data[name] = {}; |
||
68 | end |
||
69 | if ( FriendsFacts_Enabled ) then |
||
70 | FriendsFacts_Data[name].level = level; |
||
71 | FriendsFacts_Data[name].class = class; |
||
72 | FriendsFacts_Data[name].area = area; |
||
73 | end |
||
74 | elseif (name) and (FriendsFacts_Enabled) and (i > friendOffset) and (i <= friendOffset+FRIENDS_TO_DISPLAY) and (FriendsFacts_Data[name]) then |
||
75 | nameLocationText = getglobal("FriendsFrameFriendButton"..(i-friendOffset).."ButtonTextNameLocation"); |
||
76 | infoText = getglobal("FriendsFrameFriendButton"..(i-friendOffset).."ButtonTextInfo"); |
||
77 | level = FriendsFacts_Data[name].level; |
||
78 | class = FriendsFacts_Data[name].class; |
||
79 | if ( not class ) then class = TEXT(UNKNOWN); end |
||
80 | area = FriendsFacts_Data[name].area; |
||
81 | if ( not area ) then area = TEXT(UNKNOWN); end |
||
82 | nameLocationText:SetText(format(TEXT(FRIENDS_FACTS_OFFLINE_TEMPLATE), name, area)); |
||
83 | if ( nameLocationText:GetWidth() > 275 ) then |
||
84 | nameLocationText:SetText(format(TEXT(FRIENDS_FACTS_OFFLINE_TEMPLATE_SHORT), name, area)); |
||
85 | nameLocationText:SetJustifyH("LEFT"); |
||
86 | nameLocationText:SetWidth(275); |
||
87 | end |
||
88 | if ( level ) and ( class ) then |
||
89 | infoText:SetText(format(TEXT(FRIENDS_LEVEL_TEMPLATE), level, class)); |
||
90 | end |
||
91 | end |
||
92 | end |
||
93 | end |
||
94 |