vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | GRAY_FONT_COLOR_CODE = "|cff808080"; |
2 | TITANFRIENDS_ARTWORK_PATH = "Interface\\AddOns\\TitanFriends\\" |
||
3 | |||
4 | function TitanPanelFriendsButton_OnLoad() |
||
5 | this.registry = { |
||
6 | id = "Friends", |
||
7 | menuText = TITAN_FRIENDS_MENU_TEXT, |
||
8 | buttonTextFunction = "TitanPanelFriendsButton_GetButtonText", |
||
9 | tooltipTitle = TITAN_FRIENDS_TOOLTIP, |
||
10 | tooltipTextFunction = "TitanPanelFriendsButton_GetTooltipText", |
||
11 | |||
12 | icon = TITANFRIENDS_ARTWORK_PATH.."TitanFriends", |
||
13 | iconWidth = 16, |
||
14 | savedVariables = { |
||
15 | ShowIcon = 1, |
||
16 | ShowLabelText = 1, |
||
17 | } |
||
18 | |||
19 | }; |
||
20 | |||
21 | this:RegisterEvent("FRIENDLIST_SHOW"); |
||
22 | this:RegisterEvent("FRIENDLIST_UPDATE"); |
||
23 | end |
||
24 | |||
25 | function TitanPanelFriendsButton_OnEvent() |
||
26 | TitanPanelButton_UpdateButton("Friends"); |
||
27 | TitanPanelButton_UpdateTooltip(); |
||
28 | end |
||
29 | |||
30 | function TitanPanelFriendsButton_OnEnter() |
||
31 | -- refresh the friends list |
||
32 | ShowFriends(); |
||
33 | end |
||
34 | |||
35 | |||
36 | |||
37 | function TitanPanelRightClickMenu_PrepareFriendsMenu() |
||
38 | local info = {}; |
||
39 | local id = "Friends"; |
||
40 | |||
41 | |||
42 | -- create the Whisper submenu items |
||
43 | |||
44 | if ( UIDROPDOWNMENU_MENU_LEVEL == 2 ) then |
||
45 | |||
46 | if ( UIDROPDOWNMENU_MENU_VALUE == TITAN_FRIENDS_MENU_WHISPER ) then |
||
47 | |||
48 | -- generate a list of online friends and set up whisper |
||
49 | local NumFriends = GetNumFriends(); |
||
50 | |||
51 | local friend_name, friend_level, friend_class, friend_area, friend_connected |
||
52 | local friendIndex |
||
53 | |||
54 | -- get a count of the number of online friends |
||
55 | for friendIndex=1, NumFriends do |
||
56 | friend_name, friend_level, friend_class, friend_area, friend_connected = GetFriendInfo(friendIndex); |
||
57 | if ( friend_connected ) then |
||
58 | info = {}; |
||
59 | info.text = friend_name; |
||
60 | info.func = friendWhisper; |
||
61 | info.value = friend_name; |
||
62 | UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL); |
||
63 | end |
||
64 | end |
||
65 | end |
||
66 | |||
67 | |||
68 | if ( UIDROPDOWNMENU_MENU_VALUE == TITAN_FRIENDS_MENU_INVITE ) then |
||
69 | |||
70 | -- generate a list of online friends and set up whisper |
||
71 | local NumFriends = GetNumFriends(); |
||
72 | |||
73 | local friend_name, friend_level, friend_class, friend_area, friend_connected |
||
74 | local friendIndex |
||
75 | |||
76 | -- get a count of the number of online friends |
||
77 | for friendIndex=1, NumFriends do |
||
78 | friend_name, friend_level, friend_class, friend_area, friend_connected = GetFriendInfo(friendIndex); |
||
79 | if ( friend_connected ) then |
||
80 | info = {}; |
||
81 | info.text = friend_name; |
||
82 | info.func = friendInvite; |
||
83 | info.value = friend_name; |
||
84 | UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL); |
||
85 | end |
||
86 | end |
||
87 | end |
||
88 | return; |
||
89 | end |
||
90 | |||
91 | TitanPanelRightClickMenu_AddTitle(TitanPlugins[id].menuText); |
||
92 | |||
93 | -- create the title for the Whisper submenu |
||
94 | info = {}; |
||
95 | info.text = TITAN_FRIENDS_MENU_WHISPER; |
||
96 | info.value = TITAN_FRIENDS_MENU_WHISPER; |
||
97 | info.hasArrow = 1; |
||
98 | UIDropDownMenu_AddButton(info); |
||
99 | |||
100 | -- create the title for the Invite submenu |
||
101 | info = {}; |
||
102 | info.text = TITAN_FRIENDS_MENU_INVITE; |
||
103 | info.value = TITAN_FRIENDS_MENU_INVITE; |
||
104 | info.hasArrow = 1; |
||
105 | UIDropDownMenu_AddButton(info); |
||
106 | |||
107 | TitanPanelRightClickMenu_AddSpacer(); |
||
108 | |||
109 | TitanPanelRightClickMenu_AddToggleIcon("Friends"); |
||
110 | TitanPanelRightClickMenu_AddToggleLabelText("Friends"); |
||
111 | |||
112 | -- default Titan Panel right-click menu options |
||
113 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_CUSTOMIZE..TITAN_PANEL_MENU_POPUP_IND, id, TITAN_PANEL_MENU_FUNC_CUSTOMIZE); |
||
114 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, id, TITAN_PANEL_MENU_FUNC_HIDE); |
||
115 | |||
116 | end |
||
117 | |||
118 | function friendInvite() |
||
119 | InviteByName( this.value ); |
||
120 | end |
||
121 | |||
122 | function friendWhisper() |
||
123 | if ( not ChatFrameEditBox:IsVisible() ) then |
||
124 | ChatFrame_OpenChat("/w "..this.value.." "); |
||
125 | else |
||
126 | ChatFrameEditBox:SetText("/w "..this.value.." "); |
||
127 | end |
||
128 | end |
||
129 | |||
130 | |||
131 | function TitanPanelFriendsButton_GetButtonText(id) |
||
132 | local id = TitanUtils_GetButton(id, true); |
||
133 | local NumFriends = GetNumFriends(); |
||
134 | local NumFriendsOnline = 0; |
||
135 | |||
136 | local friend_name, friend_level, friend_class, friend_area, friend_connected |
||
137 | local friendIndex |
||
138 | |||
139 | -- get a count of the number of online friends |
||
140 | for friendIndex=1, NumFriends do |
||
141 | friend_name, friend_level, friend_class, friend_area, friend_connected = GetFriendInfo(friendIndex); |
||
142 | if ( friend_connected ) then |
||
143 | NumFriendsOnline = NumFriendsOnline + 1; |
||
144 | end |
||
145 | end |
||
146 | |||
147 | -- create string for Titan bar display |
||
148 | local buttonRichText = format(TITAN_FRIENDS_BUTTON_TEXT, TitanUtils_GetGreenText(NumFriendsOnline), TitanUtils_GetHighlightText(NumFriends)); |
||
149 | return TITAN_FRIENDS_BUTTON_LABEL, buttonRichText; |
||
150 | end |
||
151 | |||
152 | function TitanPanelFriendsButton_GetTooltipText() |
||
153 | local NumFriends = GetNumFriends(); |
||
154 | local tooltipRichText = ""; |
||
155 | |||
156 | local friend_name, friend_level, friend_class, friend_area, friend_connected |
||
157 | local friendIndex |
||
158 | |||
159 | -- create tooltip |
||
160 | for friendIndex=1, NumFriends do |
||
161 | friend_name, friend_level, friend_class, friend_area, friend_connected = GetFriendInfo(friendIndex); |
||
162 | if ( friend_connected ) then |
||
163 | tooltipRichText = tooltipRichText..TitanUtils_GetNormalText(friend_name)..TitanUtils_GetHighlightText(" - "..friend_area.." ["..friend_level.." "..friend_class.."]").."\n"; |
||
164 | end |
||
165 | end |
||
166 | |||
167 | -- remove the last \n |
||
168 | tooltipRichText = string.sub(tooltipRichText, 1, string.len(tooltipRichText)-1); |
||
169 | |||
170 | return tooltipRichText; |
||
171 | end |