vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ --------------------------------------------------------------- |
2 | Call To Arms |
||
3 | --------------------------------------------------------------- |
||
4 | |||
5 | @Author: Sacha Beharry |
||
6 | @DateCreated: 26th May 2005 |
||
7 | @LastUpdate: 1st July 2006 |
||
8 | @Release: R10 |
||
9 | @Version: 1.6 |
||
10 | @Note: |
||
11 | ]] |
||
12 | |||
13 | CTA_RELEASEVERSION = "R10"; |
||
14 | CTA_RELEASENOTE = "R10 [1.6]"; |
||
15 | CTA_THIS_VERSION = 9; |
||
16 | |||
17 | --[[ --------------------------------------------------------------- |
||
18 | |||
19 | Web: |
||
20 | |||
21 | Filename: CallToArms.lua |
||
22 | |||
23 | Project Name: Call To Arms |
||
24 | |||
25 | Description: Main Program |
||
26 | |||
27 | Purpose: |
||
28 | --------------------------------------------------------------- |
||
29 | ]] |
||
30 | |||
31 | |||
32 | |||
33 | |||
34 | --[[ --------------------------------------------------------------- |
||
35 | Variables |
||
36 | --------------------------------------------------------------- |
||
37 | ]] |
||
38 | |||
39 | CTA_DEFAULT_RAID_CHANNEL = "CTAChannel"; |
||
40 | CTA_INVITE_MAGIC_WORD = "inviteme"; |
||
41 | CTA_PLAYER = "PLAYER"; |
||
42 | CTA_MAX_RESULTS_ITEMS = 20; |
||
43 | CTA_MAX_BLACKLIST_ITEMS = 15; |
||
44 | CTA_ALLIANCE = "Alliance"; |
||
45 | CTA_HORDE = "Horde"; |
||
46 | |||
47 | CTA_DEFAULT_LFM_TRIGGER = "\"lf%d*m\""; |
||
48 | CTA_DEFAULT_LFG_TRIGGER = "lfg"; |
||
49 | |||
50 | CTA_SavedVariables = { |
||
51 | |||
52 | version = 0, |
||
53 | |||
54 | runCount = 0, |
||
55 | |||
56 | GreyList = {}, |
||
57 | |||
58 | MinimapArcOffset = 223, |
||
59 | MinimapRadiusOffset = 75, |
||
60 | |||
61 | MinimapMsgArcOffset = 296, |
||
62 | MinimapMsgRadiusOffset = 95, |
||
63 | |||
64 | MainFrameTransparency = 0.85, |
||
65 | lfmTrigger = "\"lf%d*m\"", |
||
66 | lfgTrigger = "lfg" |
||
67 | }; |
||
68 | |||
69 | CTA_CommunicationChannel = "CTAChannel"; |
||
70 | CTA_MyRaid = nil; |
||
71 | CTA_RaidList = {}; |
||
72 | CTA_ResultsListOffset = 0; |
||
73 | CTA_BlackList = {}; |
||
74 | CTA_PlayerListOffset = 0; |
||
75 | CTA_MyRaidIsOnline = nil; |
||
76 | |||
77 | CTA_IgnoreBlacklisted = 1; |
||
78 | |||
79 | |||
80 | local CTA_RAID_TYPE_PVP = 1; |
||
81 | local CTA_RAID_TYPE_PVE = 0; |
||
82 | local CTA_GREYLISTED = 0; |
||
83 | local CTA_BLACKLISTED = 1; |
||
84 | local CTA_WHITELISTED = 2; |
||
85 | local CTA_MESSAGE = "M"; |
||
86 | local CTA_GENERAL = "I"; |
||
87 | local CTA_GROUP_UPDATE = "G"; |
||
88 | local CTA_BLOCK = "X"; |
||
89 | local CTA_SEARCH = "S"; |
||
90 | |||
91 | local CTA_MESSAGE_COLOURS = { |
||
92 | M = { r = 1, b = 1, g = 0.5 }, |
||
93 | I = { r = 1, b = 0.5, g = 1 }, |
||
94 | G = { r = 0.5, b = 0.5, g = 1 }, |
||
95 | X = { r = 1, b = 0.5, g = 0.5 }, |
||
96 | S = { r = 0.5, b = 1, g = 0.5 } |
||
97 | }; |
||
98 | |||
99 | local CTA_MyRaidPassword = nil; |
||
100 | local CTA_UpdateTicker = 0.0; |
||
101 | local CTA_SearchTimer = 0; |
||
102 | local CTA_SelectedResultListItem = 0; |
||
103 | local CTA_ChannelSpam = {}; |
||
104 | local CTA_SpamTimer = 0; |
||
105 | local CTA_PendingMembers = {}; |
||
106 | local CTA_GraceTimer = 0; |
||
107 | local CTA_HostingRaidGroup = nil; |
||
108 | CTA_InvitationRequests = {}; |
||
109 | local CTA_OutstandingRequests = 0; |
||
110 | local CTA_RequestTimer = 0; |
||
111 | |||
112 | |||
113 | |||
114 | |||
115 | CTA_PollBroadcast = nil; |
||
116 | CTA_PollApplyFilters = nil; |
||
117 | CTA_TimeSinceLastBroadcast = 0; |
||
118 | CTA_TimeSinceLastFilter = 0 |
||
119 | CTA_RawGroupList = {}; |
||
120 | CTA_JoinedChannel = nil; |
||
121 | CTA_AcidSummary = nil; |
||
122 | CTA_AnnounceTimer = 0; |
||
123 | |||
124 | CTA_WhoName = nil; |
||
125 | |||
126 | |||
127 | -- R7 BEGIN |
||
128 | |||
129 | local lfxChatMessageList = {}; |
||
130 | local autoannounce = nil; |
||
131 | |||
132 | --CTA_lfmTrigger = CTA_DEFAULT_LFM_TRIGGER; |
||
133 | --CTA_lfgTrigger = CTA_DEFAULT_LFG_TRIGGER; |
||
134 | |||
135 | CTA_CtaMessageList = {}; |
||
136 | |||
137 | CTA_ForwardTimer = 10; |
||
138 | CTA_WhoFlag = nil; |
||
139 | |||
140 | CTA_AcidDetails = nil; |
||
141 | CTA_PlayerIsAFK = nil; |
||
142 | |||
143 | CTA_Classes = {}; |
||
144 | |||
145 | --R7 END |
||
146 | |||
147 | --[[ --------------------------------------------------------------- |
||
148 | OnLoad and Slash Commands |
||
149 | --------------------------------------------------------------- |
||
150 | ]] |
||
151 | |||
152 | |||
153 | |||
154 | |||
155 | --[[ CTA_OnLoad() |
||
156 | --------------------------------------------------------------- |
||
157 | Register events and hook functions. |
||
158 | ]] |
||
159 | |||
160 | function CTA_OnLoad() |
||
161 | |||
162 | --Register Slash Command |
||
163 | SlashCmdList["CallToArmsCOMMAND"] = CTA_SlashHandler; |
||
164 | SLASH_CallToArmsCOMMAND1 = "/cta"; |
||
165 | |||
166 | --Register Event Listeners |
||
167 | this:RegisterEvent("CHAT_MSG_SYSTEM"); |
||
168 | this:RegisterEvent("PARTY_MEMBERS_CHANGED"); |
||
169 | this:RegisterEvent("PARTY_LEADER_CHANGED"); |
||
170 | this:RegisterEvent("CHAT_MSG_WHISPER"); |
||
171 | this:RegisterEvent("CHAT_MSG_CHANNEL"); |
||
172 | this:RegisterEvent("RAID_ROSTER_UPDATE"); |
||
173 | this:RegisterEvent("WHO_LIST_UPDATE"); |
||
174 | this:RegisterEvent("VARIABLES_LOADED"); |
||
175 | |||
176 | --Announce AddOn to user |
||
177 | CTA_Println( CTA_CALL_TO_ARMS_LOADED ); |
||
178 | CTA_Error("-[ CTA "..CTA_RELEASEVERSION.." ]-"); |
||
179 | |||
180 | CTA_Classes[1] = CTA_PRIEST; |
||
181 | CTA_Classes[2] = CTA_MAGE; |
||
182 | CTA_Classes[3] = CTA_WARLOCK; |
||
183 | CTA_Classes[4] = CTA_DRUID; |
||
184 | CTA_Classes[5] = CTA_HUNTER; |
||
185 | CTA_Classes[6] = CTA_ROGUE; |
||
186 | CTA_Classes[7] = CTA_WARRIOR; |
||
187 | if( UnitFactionGroup(CTA_PLAYER) == CTA_ALLIANCE ) then |
||
188 | CTA_Classes[8] = CTA_PALADIN; |
||
189 | else |
||
190 | CTA_Classes[8] = CTA_SHAMAN; |
||
191 | end |
||
192 | CTA_Classes[CTA_PRIEST] = 1; |
||
193 | CTA_Classes[CTA_MAGE] = 2; |
||
194 | CTA_Classes[CTA_WARLOCK] = 3; |
||
195 | CTA_Classes[CTA_DRUID] = 4; |
||
196 | CTA_Classes[CTA_HUNTER] = 5; |
||
197 | CTA_Classes[CTA_ROGUE] = 6; |
||
198 | CTA_Classes[CTA_WARRIOR] = 7; |
||
199 | CTA_Classes[CTA_PALADIN] = 8; |
||
200 | CTA_Classes[CTA_SHAMAN] = 8; |
||
201 | |||
202 | --Hook into ChatFrame to hide AddOn communication |
||
203 | local old_ChatFrame_OnEvent = ChatFrame_OnEvent; |
||
204 | function ChatFrame_OnEvent(event) |
||
205 | |||
206 | -- R5 : effectively makes blacklist an extended ignore list as well |
||
207 | if( arg2 and CTA_IgnoreBlacklisted and CTA_FindInList( arg2, CTA_BlackList ) ) then |
||
208 | --CTA_IconMsg( arg2, CTA_BLOCK ); -- left for testing, disabled for R7 |
||
209 | CTA_LogMsg( "Blocked message from "..arg2, CTA_BLOCK ); -- R7 |
||
210 | return; |
||
211 | end |
||
212 | |||
213 | if( strsub(event, 1, 16) == "CHAT_MSG_WHISPER" ) then |
||
214 | if( arg2 and arg1 and strsub(arg1, 1, 5) == "[CTA]" ) then |
||
215 | CTA_IconMsg( arg2, CTA_MESSAGE ); |
||
216 | CTA_LogMsg( arg2..": "..arg1, CTA_MESSAGE ); |
||
217 | return; --R3 |
||
218 | end |
||
219 | end |
||
220 | |||
221 | if( arg9 and CTA_MuteLFGChannelCheckButton:GetChecked() and arg9=="LookingForGroup" ) then |
||
222 | --CTA_IconMsg( arg1 ); -- for testing |
||
223 | return; |
||
224 | end |
||
225 | |||
226 | if ( not arg1 or strsub(event, 1, 16) ~= "CHAT_MSG_WHISPER" or strsub(arg1, 1, 5) ~= "/cta " ) then -- not arg1: R3 bug fix |
||
227 | if( not arg1 or not CTA_MainFrame:IsVisible() or not string.find( arg1, "Away from Keyboard") ) then -- not arg1: R3 bug fix |
||
228 | old_ChatFrame_OnEvent(event); |
||
229 | end |
||
230 | end |
||
231 | |||
232 | end |
||
233 | |||
234 | --Hook into FriendsFrame_OnEvent |
||
235 | local old_FriendsFrame_OnEvent = FriendsFrame_OnEvent; |
||
236 | function FriendsFrame_OnEvent() |
||
237 | if( event ~= "WHO_LIST_UPDATE" or ( CTA_OutstandingRequests == 0 and CTA_WhoFlag == nil ) ) then |
||
238 | --if( CTA_OutstandingRequests == 0 and CTA_WhoFlag == nil ) then |
||
239 | old_FriendsFrame_OnEvent(); |
||
240 | end |
||
241 | end |
||
242 | |||
243 | ScriptErrors:SetScript("OnShow", CTA_ScriptError ); |
||
244 | end |
||
245 | |||
246 | function CTA_ScriptError() |
||
247 | local message = ScriptErrors_Message:GetText(); |
||
248 | if (not message or not string.find( message, "CallToArms" ) ) then |
||
249 | --CTA_Println( "No CallToArms error found" ); |
||
250 | return; |
||
251 | end |
||
252 | |||
253 | |||
254 | local extMsg = "Error: "..message; |
||
255 | extMsg = extMsg..", Addons: "; |
||
256 | local numAddons = GetNumAddOns(); |
||
257 | for i = 1, numAddons do |
||
258 | if( IsAddOnLoaded( i ) ) then |
||
259 | local name = GetAddOnInfo( i ); |
||
260 | extMsg = extMsg..name..", "; |
||
261 | end |
||
262 | end |
||
263 | extMsg = extMsg.." Client: "..GetLocale(); |
||
264 | |||
265 | CTA_ErrorReportingFrameEditBox:SetText( extMsg ); |
||
266 | CTA_ErrorReportingFrame:Show(); |
||
267 | end |
||
268 | |||
269 | |||
270 | |||
271 | --[[ CTA_SlashHandler(com) |
||
272 | --------------------------------------------------------------- |
||
273 | For Slash Commands (surprise) |
||
274 | @arg The command String |
||
275 | ]] |
||
276 | |||
277 | function CTA_SlashHandler(com) |
||
278 | if( not com or com=="" ) then |
||
279 | CTA_Println( CTA_CALL_TO_ARMS.." "..CTA_RELEASEVERSION ); |
||
280 | CTA_Println( CTA_COMMANDS..": "..CTA_HELP.." | "..CTA_TOGGLE.." | "..CTA_ANNOUNCE_GROUP.." | "..CTA_DISSOLVE_RAID ); |
||
281 | |||
282 | CTA_Println( CTA_COMMANDS..": "..CTA_TOGGLE_MINIMAP ); |
||
283 | |||
284 | CTA_Println( "Beta commands:" ); |
||
285 | CTA_Println( "/error: starts CTA error reporting function. Only works if an error has already occurred." ); |
||
286 | return; |
||
287 | end |
||
288 | |||
289 | if( com==CTA_HELP ) then |
||
290 | CTA_Println( CTA_TOGGLE..": "..CTA_TOGGLE_HELP ); |
||
291 | CTA_Println( CTA_ANNOUNCE_GROUP..": "..CTA_ANNOUNCE_GROUP_HELP ); |
||
292 | CTA_Println( CTA_DISSOLVE_RAID..": "..CTA_DISSOLVE_RAID_HELP ); |
||
293 | return; |
||
294 | end |
||
295 | |||
296 | if( com==CTA_TOGGLE ) then |
||
297 | if( CTA_MainFrame:IsVisible() ) then |
||
298 | CTA_MainFrame:Hide(); |
||
299 | else |
||
300 | CTA_MainFrame:Show(); |
||
301 | end |
||
302 | return; |
||
303 | end |
||
304 | |||
305 | if( com==CTA_TOGGLE_MINIMAP ) then |
||
306 | if( CTA_MinimapIcon:IsVisible() ) then |
||
307 | CTA_MinimapIcon:Hide(); |
||
308 | else |
||
309 | CTA_MinimapIcon:Show(); |
||
310 | end |
||
311 | return; |
||
312 | end |
||
313 | |||
314 | if( com==CTA_DISSOLVE_RAID ) then |
||
315 | if( IsRaidLeader() ) then |
||
316 | CTA_DissolveRaid(); |
||
317 | else |
||
318 | CTA_Println( CTA_MUST_BE_LEADER_TO_DISSOLVE_RAID ); |
||
319 | end |
||
320 | return; |
||
321 | end |
||
322 | |||
323 | |||
324 | if( com==CTA_AUTO_ANNOUNCE_OFF ) then |
||
325 | autoannounce = nil; |
||
326 | CTA_AnnounceTimer = 0; |
||
327 | CTA_Println( "Auto announce OFF" ); |
||
328 | return; |
||
329 | end |
||
330 | |||
331 | for channelName in string.gfind( com, CTA_ANNOUNCE_GROUP.." (%w+)" ) do |
||
332 | autoannounce = channelName; |
||
333 | CTA_AnnounceTimer = 5; |
||
334 | CTA_Println( "Auto announce ON" ); |
||
335 | end |
||
336 | |||
337 | |||
338 | --[ [ |
||
339 | if( com=="error" ) then |
||
340 | CTA_ScriptError(); |
||
341 | return; |
||
342 | end |
||
343 | --]] |
||
344 | |||
345 | if( com=="test" ) then |
||
346 | local DefaultChannels = { GetChatWindowChannels(DEFAULT_CHAT_FRAME:GetID()) }; |
||
347 | local connected = nil; |
||
348 | if( DefaultChannels ) then |
||
349 | for item = 1, getn(DefaultChannels) do |
||
350 | CTA_Println( DefaultChannels[item] or "Null" ); |
||
351 | end |
||
352 | end |
||
353 | end |
||
354 | |||
355 | end |
||
356 | |||
357 | |||
358 | |||
359 | |||
360 | --[[ --------------------------------------------------------------- |
||
361 | OnUpdate and OnEvent |
||
362 | --------------------------------------------------------------- |
||
363 | ]] |
||
364 | |||
365 | |||
366 | |||
367 | --[[ CTA_OnUpdate() |
||
368 | --------------------------------------------------------------- |
||
369 | Keep the <var>CTA_UpdateTicker</var> running. |
||
370 | @arg The time elapsed since the last call to this function |
||
371 | ]] |
||
372 | |||
373 | function CTA_OnUpdate( arg1 ) |
||
374 | CTA_UpdateTicker = CTA_UpdateTicker + arg1; |
||
375 | if( CTA_UpdateTicker >= 1 ) then |
||
376 | |||
377 | if( CTA_AnnounceTimer > 0 ) then |
||
378 | CTA_AnnounceTimer = CTA_AnnounceTimer - 1; |
||
379 | |||
380 | -- r7 |
||
381 | if( CTA_AnnounceTimer == 0 and autoannounce ) then |
||
382 | if( CTA_PlayerIsAFK ) then |
||
383 | autoannounce = nil; |
||
384 | CTA_Println( "You are AFK: Setting auto announce to OFF" ); |
||
385 | elseif ( CTA_GetNumGroupMembers() > 1 and not CTA_MyRaid ) then |
||
386 | autoannouce = nil; |
||
387 | CTA_Println( "You have joined a group. LFG Auto announce OFF" ); |
||
388 | elseif( CTA_MyRaidIsOnline and CTA_MyRaid and CTA_AcidSummary ) then |
||
389 | CTA_SendChatMessage( CTA_AcidSummary, "CHANNEL", autoannounce ); |
||
390 | CTA_AnnounceTimer = 100; |
||
391 | PlaySound("TellMessage"); |
||
392 | CTA_IconMsg( "Announced LFM" ); |
||
393 | CTA_Println( "Announced LFM message to local channel" ); |
||
394 | elseif( CTA_LGMPrefixLabel:GetText() and CTA_LFGDescriptionEditBox:GetText() ~= "" ) then |
||
395 | CTA_SendChatMessage( CTA_LGMPrefixLabel:GetText()..CTA_LFGDescriptionEditBox:GetText(), "CHANNEL", autoannounce ); |
||
396 | CTA_AnnounceTimer = 100; |
||
397 | PlaySound("TellMessage"); |
||
398 | CTA_IconMsg( "Announced LFG" ); |
||
399 | CTA_Println( "Announced LFG message to local channel" ); |
||
400 | else |
||
401 | autoannounce = nil; |
||
402 | CTA_Println( "Nothing to announce: Setting auto announce to OFF" ); |
||
403 | end |
||
404 | end |
||
405 | -- /r7 |
||
406 | end |
||
407 | |||
408 | CTA_TimeSinceLastBroadcast = CTA_TimeSinceLastBroadcast + 1; |
||
409 | if( CTA_TimeSinceLastBroadcast > 15 ) then |
||
410 | CTA_TimeSinceLastBroadcast = 0; |
||
411 | |||
412 | --[[if( CTA_PlayerIsAFK ) then |
||
413 | CTA_PollBroadcast = nil; |
||
414 | else]] |
||
415 | |||
416 | if( CTA_MyRaidIsOnline and CTA_MyRaid ) then |
||
417 | CTA_PollBroadcast = 1; |
||
418 | elseif( CTA_LFGCheckButton:GetChecked() and CTA_LGMPrefixLabel:GetText() and CTA_LFGDescriptionEditBox:GetText() ~= "" ) then |
||
419 | if( CTA_GetNumGroupMembers() > 1 ) then |
||
420 | CTA_LFGCheckButton:SetChecked( 0 ); |
||
421 | CTA_Println( "You have joined a group. CTA has stopped listing you as looking for a group." ); |
||
422 | else |
||
423 | CTA_PollBroadcast = 3; |
||
424 | end |
||
425 | end |
||
426 | |||
427 | --/r7 |
||
428 | end |
||
429 | |||
430 | CTA_TimeSinceLastFilter = CTA_TimeSinceLastFilter + 1; |
||
431 | if( CTA_TimeSinceLastFilter > 15 ) then |
||
432 | CTA_TimeSinceLastFilter = 0; |
||
433 | CTA_PollApplyFilters = 1; |
||
434 | end |
||
435 | |||
436 | CTA_SpamTimer = CTA_SpamTimer + CTA_UpdateTicker; |
||
437 | if( CTA_SpamTimer > 10 ) then |
||
438 | CTA_ChannelSpam = {}; |
||
439 | CTA_SpamTimer = 0; |
||
440 | |||
441 | |||
442 | |||
443 | -- Ok, piggybacking 10s SpamTimer to implement |
||
444 | -- Polled Broadcasting and |
||
445 | -- Auto Search Updates. |
||
446 | |||
447 | if( CTA_PollApplyFilters ) then |
||
448 | CTA_TimeSinceLastFilter = 0; |
||
449 | CTA_ApplyFiltersToGroupList(); |
||
450 | end |
||
451 | |||
452 | |||
453 | if( CTA_PollBroadcast ) then |
||
454 | CTA_TimeSinceLastBroadcast = 0; |
||
455 | |||
456 | --[[if( CTA_PlayerIsAFK ) then |
||
457 | CTA_PollBroadcast = nil; |
||
458 | CTA_Println( "You are AFK: CTA broadcasts paused " ); |
||
459 | |||
460 | else]] |
||
461 | |||
462 | if( CTA_PollBroadcast == 3 ) then --r7 |
||
463 | if( CTA_LFGCheckButton:GetChecked() and CTA_LGMPrefixLabel:GetText() and CTA_LFGDescriptionEditBox:GetText() ~= "" ) then |
||
464 | |||
465 | local tim, minute = GetGameTime(); |
||
466 | if( tim < 10 ) then tim = "0"..tim; end |
||
467 | if( minute < 10 ) then tim = tim.."0"; end |
||
468 | tim = tim..minute; |
||
469 | |||
470 | local lfgT = CTA_LFGDescriptionEditBox:GetText(); |
||
471 | |||
472 | -- |
||
473 | if string.find( lfgT, ":") then lfgT = string.gsub(lfgT, ":", "."); end; |
||
474 | |||
475 | |||
476 | CTA_SendChatMessage( "/cta B<"..tim..":"..lfgT..":"..CTA_RELEASEVERSION..">", "CHANNEL", GetChannelName( CTA_CommunicationChannel ) ); |
||
477 | end |
||
478 | CTA_PollBroadcast = nil; |
||
479 | elseif( CTA_PollBroadcast == 2 ) then |
||
480 | CTA_SendChatMessage("/cta A<>", "CHANNEL", GetChannelName( CTA_CommunicationChannel ) ); |
||
481 | CTA_PollBroadcast = nil; |
||
482 | elseif( CTA_MyRaidIsOnline and CTA_MyRaid ) then |
||
483 | CTA_BroadcastRaidInfo(); |
||
484 | end |
||
485 | end |
||
486 | end |
||
487 | |||
488 | if( CTA_GraceTimer > 0 ) then |
||
489 | CTA_GraceTimer = CTA_GraceTimer - CTA_UpdateTicker; |
||
490 | CTA_IconMsg( floor(CTA_GraceTimer) ); |
||
491 | if( CTA_GraceTimer <= 0 ) then |
||
492 | if( CTA_MyRaid and not CTA_PlayerCanHostGroup() ) then |
||
493 | CTA_MyRaid = nil; |
||
494 | CTA_MyRaidIsOnline = nil; |
||
495 | CTA_HostingRaidGroup = nil; |
||
496 | CTA_SearchFrame:Show(); |
||
497 | CTA_MyRaidFrame:Hide(); |
||
498 | CTA_StartRaidFrame:Hide(); |
||
499 | else |
||
500 | CTA_MyRaidInstantUpdate(); |
||
501 | end |
||
502 | end |
||
503 | end |
||
504 | |||
505 | CTA_RequestTimer = CTA_RequestTimer + CTA_UpdateTicker; |
||
506 | if( CTA_RequestTimer > 5 ) then |
||
507 | if( CTA_OutstandingRequests > 0 ) then |
||
508 | CTA_LogMsg( CTA_OutstandingRequests.." invitation request(s) outstanding" ); |
||
509 | for name, data in CTA_InvitationRequests do |
||
510 | if( data.status == 1 ) then |
||
511 | SetWhoToUI(1); |
||
512 | CTA_WhoName = name; |
||
513 | SendWho("n-"..name); |
||
514 | --SendWho(name); |
||
515 | CTA_LogMsg( "Validating request from "..name ); |
||
516 | break; |
||
517 | end |
||
518 | end |
||
519 | else |
||
520 | --r7 |
||
521 | if( not FriendsFrame:IsVisible() ) then -- R10: This stops CTA from sending who requests while the friends frame is open |
||
522 | for i = 1, getn( CTA_CtaMessageList ) do |
||
523 | if( not CTA_CtaMessageList[i].who ) then --CTA_CtaMessageList[i].who = { level = 0 }; |
||
524 | SetWhoToUI(1); |
||
525 | local name = CTA_CtaMessageList[i].op or CTA_CtaMessageList[i].author; |
||
526 | CTA_WhoFlag = name; |
||
527 | SendWho("n-"..name); |
||
528 | --SendWho(name); |
||
529 | CTA_LogMsg( "Getting information on: "..name ); |
||
530 | break; |
||
531 | end |
||
532 | end |
||
533 | else |
||
534 | CTA_LogMsg( "CTA /who aborted: Social window open" ); |
||
535 | end |
||
536 | end |
||
537 | CTA_RequestTimer = 0; |
||
538 | end |
||
539 | |||
540 | CTA_ForwardTimer = CTA_ForwardTimer - 1; |
||
541 | if( CTA_ForwardTimer == 0 ) then |
||
542 | --[ [ R10: Prep to stop CTA LFX Forwarding in R11 |
||
543 | if( lfxChatMessageList[getn(lfxChatMessageList)] ) then |
||
544 | CTA_SendChatMessage( lfxChatMessageList[getn(lfxChatMessageList)].message, "CHANNEL", GetChannelName( CTA_CommunicationChannel ) ); |
||
545 | local name = lfxChatMessageList[getn(lfxChatMessageList)].author; |
||
546 | table.remove( lfxChatMessageList, getn(lfxChatMessageList) ); |
||
547 | CTA_LogMsg( "Forwarded msg from "..name..", lfx size is: "..getn(lfxChatMessageList) ); |
||
548 | end |
||
549 | --]] |
||
550 | CTA_ForwardTimer = 10; |
||
551 | end |
||
552 | |||
553 | CTA_UpdateTicker = 0; |
||
554 | end |
||
555 | end |
||
556 | |||
557 | |||
558 | |||
559 | |||
560 | --[[ CTA_OnEvent() |
||
561 | --------------------------------------------------------------- |
||
562 | Event handler. |
||
563 | @arg The event to be handled |
||
564 | ]] |
||
565 | |||
566 | function CTA_OnEvent( event ) |
||
567 | |||
568 | if(event == "VARIABLES_LOADED") then |
||
569 | CTA_MinimapArcSlider:SetValue( CTA_SavedVariables.MinimapArcOffset ); |
||
570 | CTA_MinimapRadiusSlider:SetValue( CTA_SavedVariables.MinimapRadiusOffset ); |
||
571 | CTA_MinimapMsgArcSlider:SetValue( CTA_SavedVariables.MinimapMsgArcOffset ); |
||
572 | CTA_MinimapMsgRadiusSlider:SetValue( CTA_SavedVariables.MinimapMsgRadiusOffset ); |
||
573 | CTA_UpdateMinimapIcon(); |
||
574 | CTA_AddGreyToBlack(); |
||
575 | CTA_ImportIgnoreListToGreyList(); |
||
576 | if( not CTA_SavedVariables.runCount or CTA_SavedVariables.runCount == 0 ) then |
||
577 | CTA_SavedVariables.runCount = 0; |
||
578 | CTA_MainFrame:Show(); |
||
579 | CTA_SearchFrame:Hide(); |
||
580 | CTA_MyRaidFrame:Hide(); |
||
581 | CTA_StartRaidFrame:Hide(); |
||
582 | CTA_SettingsFrame:Show(); |
||
583 | CTA_GreyListFrame:Hide(); |
||
584 | CTA_LogFrame:Hide(); |
||
585 | end |
||
586 | CTA_SavedVariables.runCount = CTA_SavedVariables.runCount + 1; |
||
587 | CTA_UpdateGreyListItems(); -- R7 B4 |
||
588 | CTA_UpdateResults(); -- R7 B4 |
||
589 | |||
590 | CTA_FrameTransparencySlider:SetValue( ( CTA_SavedVariables.MainFrameTransparency or 0.85 ) ); |
||
591 | CTA_MainFrame:SetAlpha( CTA_FrameTransparencySlider:GetValue() ); |
||
592 | |||
593 | if( not CTA_SavedVariables.lfgTrigger or strlen( CTA_SavedVariables.lfgTrigger ) < 3 ) then |
||
594 | CTA_SavedVariables.lfgTrigger = CTA_DEFAULT_LFG_TRIGGER; |
||
595 | CTA_SavedVariables.lfmTrigger = CTA_DEFAULT_LFM_TRIGGER; |
||
596 | end |
||
597 | |||
598 | if( not CTA_SavedVariables.version or CTA_SavedVariables.version < CTA_THIS_VERSION ) then |
||
599 | CTA_SavedVariables.lfgTrigger = CTA_DEFAULT_LFG_TRIGGER; |
||
600 | CTA_SavedVariables.lfmTrigger = CTA_DEFAULT_LFM_TRIGGER; |
||
601 | CTA_SavedVariables.version = CTA_THIS_VERSION; |
||
602 | CTA_Println( "CallToArms version updated. Resetting LFx triggers."); |
||
603 | |||
604 | end |
||
605 | |||
606 | CTA_SearchFrameLFGTriggerEditBox:SetText( CTA_SavedVariables.lfgTrigger or CTA_DEFAULT_LFG_TRIGGER ); |
||
607 | CTA_SearchFrameLFMTriggerEditBox:SetText( CTA_SavedVariables.lfmTrigger or CTA_DEFAULT_LFM_TRIGGER ); |
||
608 | |||
609 | |||
610 | end |
||
611 | |||
612 | -- for R2 to see if we can tell when a player does not accept your invitation to join the group |
||
613 | if ( event == "CHAT_MSG_SYSTEM" ) then |
||
614 | if ( string.find( arg1, "declines your group invitation" ) or string.find( arg1, "is already in a group" ) ) then |
||
615 | local name = string.gsub( arg1, "%s*([^%s]+).*", "%1" ); |
||
616 | CTA_RemoveRequest( name ); |
||
617 | CTA_LogMsg( name.." has declined the invitation - request removed" ); |
||
618 | CTA_MyRaidInstantUpdate(); |
||
619 | end |
||
620 | if ( string.find( arg1, "You are now AFK" ) ) then |
||
621 | --CTA_Println( "AFK" ); |
||
622 | CTA_PlayerIsAFK = 1; |
||
623 | end |
||
624 | if ( string.find( arg1, "You are no longer AFK" ) ) then |
||
625 | --CTA_Println( "NOT AFK" ); |
||
626 | CTA_PlayerIsAFK = nil; |
||
627 | end |
||
628 | end |
||
629 | |||
630 | -- Listen for Invitation requests |
||
631 | if ( event == "CHAT_MSG_WHISPER" ) then |
||
632 | if( CTA_MyRaidIsOnline and string.lower( strsub(arg1, 1, 8) ) == CTA_INVITE_MAGIC_WORD ) then |
||
633 | if( not CTA_FindInList( arg2, CTA_BlackList ) ) then -- R2 |
||
634 | if( CTA_ChannelSpam[arg2] == nil ) then |
||
635 | CTA_ChannelSpam[arg2] = 0; |
||
636 | end |
||
637 | CTA_ChannelSpam[arg2] = CTA_ChannelSpam[arg2] + 1; |
||
638 | if( CTA_ChannelSpam[arg2] > 12 ) then --r7 4 -> 12 |
||
639 | CTA_RemoveRequest( arg2 ); |
||
640 | CTA_SendAutoMsg(arg2.." "..CTA_WAS_BLACKLISTED, arg2); |
||
641 | CTA_IconMsg( arg2.." "..CTA_WAS_BLACKLISTED, CTA_BLOCK ); |
||
642 | CTA_AddPlayer( arg2, CTA_BLACKLISTED_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_BlackList ) |
||
643 | else |
||
644 | CTA_ReceiveRaidInvitationRequest( arg1, arg2 ); |
||
645 | end |
||
646 | end |
||
647 | end |
||
648 | |||
649 | if( CTA_MyRaidIsOnline and CTA_AcidDetails and string.lower( strsub(arg1, 1, 7) ) == "details" ) then |
||
650 | CTA_SendAutoMsg( CTA_AcidDetails, arg2 ) |
||
651 | end |
||
652 | |||
653 | if( string.lower( strsub(arg1, 1, 4) ) == "cta?" ) then |
||
654 | CTA_SendAutoMsg( CTA_ABOUT_CTA_MESSAGE, arg2 ) |
||
655 | end |
||
656 | end |
||
657 | |||
658 | -- Listen for Group information |
||
659 | |||
660 | |||
661 | |||
662 | |||
663 | |||
664 | --[[ --------------------------------------------------------------- |
||
665 | a b c d e f g |
||
666 | 1234567890123 |
||
667 | /cta A<1200255808060:~:~> |
||
668 | ^ ^ ^ ^ ^ ^ ^ |
||
669 | 4 3 2 2 2 ? ? |
||
670 | |||
671 | a - time of transmission (HHMM 24HR format) |
||
672 | b - lfm classes code (0 = none, .. , 255 = any class) |
||
673 | c - current group size and pv? type |
||
674 | d - maximum group size and password protection |
||
675 | e - minimum level to join group |
||
676 | f - group description |
||
677 | g - options (reserved for future releases) |
||
678 | |||
679 | a b c |
||
680 | 1234 |
||
681 | /cta B<1200:~:~> |
||
682 | ^ ^ ^ |
||
683 | 4 ? ? |
||
684 | |||
685 | a - time of transmission (HHMM 24HR format) |
||
686 | b - message |
||
687 | c - options (reserved for future releases) |
||
688 | |||
689 | a b c d |
||
690 | 1234 |
||
691 | /cta C<1200:~:~:~> |
||
692 | /cta D<1200:~:~:~> |
||
693 | ^ ^ ^ ^ |
||
694 | 4 ? ? ? |
||
695 | |||
696 | a - time of transmission (HHMM 24HR format) |
||
697 | b - op name |
||
698 | c - op message |
||
699 | d - options (reserved for future releases) |
||
700 | --------------------------------------------------------------- |
||
701 | ]] |
||
702 | |||
703 | |||
704 | if ( event == "CHAT_MSG_CHANNEL" ) then |
||
705 | |||
706 | |||
707 | -- Use channel event to delay joining of CTAChannel |
||
708 | if( not CTA_JoinedChannel ) then |
||
709 | CTA_Util.joinChannel( CTA_CommunicationChannel ); |
||
710 | CTA_JoinedChannel = 1; |
||
711 | end |
||
712 | |||
713 | |||
714 | if( arg9 == CTA_CommunicationChannel ) then |
||
715 | |||
716 | --R7 > Trusted CTA Channel Messages |
||
717 | |||
718 | if( arg1 == "/cta A<>" ) then |
||
719 | for i = 1, getn( CTA_CtaMessageList ) do |
||
720 | local name = CTA_CtaMessageList[i].author or "?"; |
||
721 | if( name == arg2 and not CTA_CtaMessageList[i].op ) then |
||
722 | table.remove( CTA_CtaMessageList , i ); |
||
723 | break; |
||
724 | end |
||
725 | end |
||
726 | CTA_PollApplyFilters = 1; |
||
727 | return; |
||
728 | end |
||
729 | |||
730 | for code, com, opt in string.gfind( arg1, "/cta A<(%d+):(.+):(.+)>" ) do |
||
731 | local tim = string.sub( code, 1, 4 ); |
||
732 | local cla = tonumber( string.sub( code, 5, 7 ) ); |
||
733 | local siz = tonumber( string.sub( code, 8, 9 ) ); |
||
734 | local max = tonumber( string.sub( code, 10, 11 ) ); |
||
735 | local min = tonumber( string.sub( code, 12, 13 ) ); |
||
736 | local pro = 0; |
||
737 | local typ = CTA_RAID_TYPE_PVE; |
||
738 | |||
739 | if( siz > 40 ) then |
||
740 | typ = CTA_RAID_TYPE_PVP; |
||
741 | siz = siz - 40; |
||
742 | end |
||
743 | if( max > 40 ) then |
||
744 | pro = 1; |
||
745 | max = max - 40; |
||
746 | end |
||
747 | |||
748 | for i = 1, getn(lfxChatMessageList) do |
||
749 | local name = lfxChatMessageList[i].author or "?"; |
||
750 | if( name == arg2 ) then |
||
751 | table.remove( lfxChatMessageList, i ); |
||
752 | break; |
||
753 | end |
||
754 | end |
||
755 | |||
756 | local whoData = nil; |
||
757 | |||
758 | for i = 1, getn( CTA_CtaMessageList ) do |
||
759 | local name = CTA_CtaMessageList[i].author or "?"; |
||
760 | if( name == arg2 and not CTA_CtaMessageList[i].op ) then |
||
761 | whoData = CTA_CtaMessageList[i].who; |
||
762 | table.remove( CTA_CtaMessageList , i ); |
||
763 | break; |
||
764 | end |
||
765 | end |
||
766 | |||
767 | -- R10: Show new messages in minimap icon text |
||
768 | if( CTA_ShowOnMinimapCheckButton:GetChecked() ) then |
||
769 | CTA_IconMsg( arg2..": "..com ); |
||
770 | end |
||
771 | |||
772 | |||
773 | local entry = {}; |
||
774 | entry.ctaType = "A"; |
||
775 | entry.author = arg2; |
||
776 | entry.message = com; |
||
777 | entry.time = tim; |
||
778 | entry.options = opt; |
||
779 | entry.who = whoData; |
||
780 | |||
781 | entry.pvtype = tonumber(typ); |
||
782 | entry.size = tonumber(siz); |
||
783 | entry.maxSize = tonumber(max); |
||
784 | entry.minLevel = tonumber(min); |
||
785 | entry.classes = tonumber(cla); |
||
786 | entry.passwordProtected = tonumber(pro); |
||
787 | |||
788 | table.insert( CTA_CtaMessageList, 1, entry ); |
||
789 | CTA_PollApplyFilters = 1; |
||
790 | return; |
||
791 | end |
||
792 | |||
793 | for code, com, opt in string.gfind( arg1, "/cta B<(%d+):(.+):(.+)>" ) do |
||
794 | |||
795 | for i = 1, getn(lfxChatMessageList) do |
||
796 | local name = lfxChatMessageList[i].author or "?"; |
||
797 | if( name == arg2 ) then |
||
798 | table.remove( lfxChatMessageList, i ); |
||
799 | break; |
||
800 | end |
||
801 | end |
||
802 | |||
803 | local whoData = nil; |
||
804 | |||
805 | for i = 1, getn( CTA_CtaMessageList ) do |
||
806 | local name = CTA_CtaMessageList[i].author or "?"; |
||
807 | if( name == arg2 and not CTA_CtaMessageList[i].op ) then |
||
808 | whoData = CTA_CtaMessageList[i].who; |
||
809 | table.remove( CTA_CtaMessageList , i ); |
||
810 | break; |
||
811 | end |
||
812 | end |
||
813 | |||
814 | -- R10: Show new messages in minimap icon text |
||
815 | if( CTA_ShowOnMinimapCheckButton:GetChecked() ) then |
||
816 | CTA_IconMsg( arg2..": "..com ); |
||
817 | end |
||
818 | |||
819 | local entry = {}; |
||
820 | entry.ctaType = "B"; |
||
821 | entry.author = arg2; |
||
822 | entry.message = com; |
||
823 | entry.time = code; |
||
824 | entry.options = opt; |
||
825 | entry.who = whoData; |
||
826 | |||
827 | table.insert( CTA_CtaMessageList, 1, entry ); |
||
828 | CTA_PollApplyFilters = 1; |
||
829 | return; |
||
830 | end |
||
831 | |||
832 | for code, opname, com, opt in string.gfind( arg1, "/cta C<(%d+):(.+):(.+):(.+)>" ) do |
||
833 | --[ [ Removed for beta 4 tests |
||
834 | if( CTA_Util.search( com, CTA_SavedVariables.lfmTrigger ) > 0 ) then |
||
835 | |||
836 | --]] |
||
837 | |||
838 | for i = 1, getn(lfxChatMessageList) do |
||
839 | local name = lfxChatMessageList[i].author or "?"; |
||
840 | if( name == opname ) then |
||
841 | table.remove( lfxChatMessageList, i ); |
||
842 | CTA_LogMsg( "Rx cta forward msg re: "..opname.." from "..arg2.." - Removed monitor entry" ); |
||
843 | break; |
||
844 | end |
||
845 | end |
||
846 | |||
847 | local whoData = nil; |
||
848 | |||
849 | for i = 1, getn( CTA_CtaMessageList ) do |
||
850 | local name = CTA_CtaMessageList[i].op or "?"; |
||
851 | if( name == opname ) then |
||
852 | whoData = CTA_CtaMessageList[i].who; |
||
853 | table.remove( CTA_CtaMessageList , i ); |
||
854 | break; |
||
855 | end |
||
856 | end |
||
857 | |||
858 | -- R10: Show new messages in minimap icon text |
||
859 | if( CTA_ShowOnMinimapCheckButton:GetChecked() ) then |
||
860 | CTA_IconMsg( opname..": "..com ); |
||
861 | end |
||
862 | |||
863 | local entry = {}; |
||
864 | entry.ctaType = "C"; |
||
865 | entry.author = arg2; |
||
866 | entry.message = com; |
||
867 | entry.time = code; |
||
868 | entry.options = opt; |
||
869 | entry.who = whoData; |
||
870 | |||
871 | entry.op = opname; |
||
872 | |||
873 | table.insert( CTA_CtaMessageList, 1, entry ); |
||
874 | CTA_PollApplyFilters = 1; |
||
875 | --[ [ Removed for beta 4 tests |
||
876 | end |
||
877 | --]] |
||
878 | return; |
||
879 | end |
||
880 | |||
881 | for code, opname, com, opt in string.gfind( arg1, "/cta D<(%d+):(.+):(.+):(.+)>" ) do |
||
882 | |||
883 | --[ [ Removed for beta 4 tests |
||
884 | if( CTA_Util.search( com, CTA_SavedVariables.lfgTrigger ) > 0 ) then |
||
885 | --]] |
||
886 | |||
887 | for i = 1, getn(lfxChatMessageList) do |
||
888 | local name = lfxChatMessageList[i].author or "?"; |
||
889 | if( name == opname ) then |
||
890 | table.remove( lfxChatMessageList, i ); |
||
891 | CTA_LogMsg( "Rx cta forward msg re: "..opname.." from "..arg2.." - Removed monitor entry" ); |
||
892 | break; |
||
893 | end |
||
894 | end |
||
895 | |||
896 | local whoData = nil; |
||
897 | |||
898 | for i = 1, getn( CTA_CtaMessageList ) do |
||
899 | local name = CTA_CtaMessageList[i].op or "?"; |
||
900 | if( name == opname ) then |
||
901 | whoData = CTA_CtaMessageList[i].who; |
||
902 | table.remove( CTA_CtaMessageList , i ); |
||
903 | break; |
||
904 | end |
||
905 | end |
||
906 | |||
907 | -- R10: Show new messages in minimap icon text |
||
908 | if( CTA_ShowOnMinimapCheckButton:GetChecked() ) then |
||
909 | CTA_IconMsg( opname..": "..com ); |
||
910 | end |
||
911 | |||
912 | local entry = {}; |
||
913 | entry.ctaType = "D"; |
||
914 | entry.author = arg2; |
||
915 | entry.message = com; |
||
916 | entry.time = code; |
||
917 | entry.options = opt; |
||
918 | entry.who = whoData; |
||
919 | |||
920 | entry.op = opname; |
||
921 | |||
922 | table.insert( CTA_CtaMessageList, 1, entry ); |
||
923 | CTA_PollApplyFilters = 1; |
||
924 | --[ [ Removed for beta 4 tests |
||
925 | end |
||
926 | --]] |
||
927 | return; |
||
928 | end |
||
929 | |||
930 | --[ [ R10: Prep to remove to stop forwarding messages in R11; global LFG channel introduced by Blizzard after R9 |
||
931 | |||
932 | elseif( CTA_MonitorChatCheckButton:GetChecked() ) then |
||
933 | if( not CTA_SavedVariables.lfmTrigger or strlen( CTA_SavedVariables.lfmTrigger ) < 3 ) then return; end |
||
934 | |||
935 | -- R7 |
||
936 | local channel = arg8 or "?"; |
||
937 | local author = arg2 or " "; |
||
938 | local ok = 0; |
||
939 | for word in string.gfind(author, "%w+") do |
||
940 | ok = ok + 1; |
||
941 | end |
||
942 | if( ok > 1 ) then return; end |
||
943 | |||
944 | local msg = arg1 or "?"; |
||
945 | local type = "C" |
||
946 | local score = CTA_Util.search( msg, CTA_SavedVariables.lfmTrigger ); |
||
947 | if( score == 0 ) then |
||
948 | score = CTA_Util.search( msg, CTA_SavedVariables.lfgTrigger ); |
||
949 | type = "D" |
||
950 | end |
||
951 | |||
952 | if( score == 0 ) then |
||
953 | return; |
||
954 | end |
||
955 | |||
956 | -- is a spam by another cta user |
||
957 | for i = 1, getn( CTA_CtaMessageList ) do |
||
958 | local name = CTA_CtaMessageList[i].author or "?"; |
||
959 | if( name == author and not CTA_CtaMessageList[i].op ) then |
||
960 | return; |
||
961 | end |
||
962 | end |
||
963 | |||
964 | local tim, minute = GetGameTime(); |
||
965 | if( tim < 10 ) then tim = "0"..tim; end |
||
966 | if( minute < 10 ) then tim = tim.."0"; end |
||
967 | tim = tim..minute; |
||
968 | for i = 1, getn(lfxChatMessageList) do |
||
969 | local name = lfxChatMessageList[i].author or "?"; |
||
970 | if( name == author ) then |
||
971 | table.remove( lfxChatMessageList, i ); |
||
972 | break; |
||
973 | end |
||
974 | end |
||
975 | |||
976 | -- |
||
977 | if string.find( msg, ":") then msg = string.gsub(msg, ":", "."); end; |
||
978 | |||
979 | local entry = {}; |
||
980 | entry.author = author; |
||
981 | entry.message = "/cta "..type.."<"..tim..":"..author..":"..msg..":x>"; |
||
982 | table.insert( lfxChatMessageList, 1, entry ); |
||
983 | |||
984 | CTA_Util.logPrintln( "Picked up lfx msg from "..author..", lfx size is: "..getn(lfxChatMessageList) ); |
||
985 | |||
986 | -- /R7 |
||
987 | --]] |
||
988 | end |
||
989 | end |
||
990 | |||
991 | -- Listen for Who information |
||
992 | if ( event == "WHO_LIST_UPDATE" ) then |
||
993 | if( CTA_WhoName and CTA_MyRaid ) then |
||
994 | local name, level, class, group = CTA_GetWhoInfo(); |
||
995 | --CTA_Println( "group: "..group ); |
||
996 | if( name ) then |
||
997 | if( CTA_FindInList( name, CTA_BlackList ) ) then |
||
998 | CTA_LogMsg( name.." has been blacklisted - Request denied and removed" ); |
||
999 | CTA_RemoveRequest(name); |
||
1000 | end |
||
1001 | |||
1002 | if( group == "yes" ) then |
||
1003 | CTA_LogMsg( name.." is already in a group - Request denied and removed" ); |
||
1004 | CTA_RemoveRequest(name); |
||
1005 | end |
||
1006 | |||
1007 | if( CTA_InvitationRequests[name] and CTA_InvitationRequests[name].status == 1 and CTA_MyRaid ) then |
||
1008 | CTA_OutstandingRequests = CTA_OutstandingRequests - 1; |
||
1009 | if( level >= CTA_MyRaid.minLevel and string.find( CTA_GetClassString(CTA_MyRaid.classes),class) ) then |
||
1010 | InviteByName( name ); |
||
1011 | CTA_LogMsg( name.."\'s request processed: Valid player - Invitation sent" ); |
||
1012 | |||
1013 | CTA_InvitationRequests[name].status = 2; |
||
1014 | CTA_InvitationRequests[name].class = class; |
||
1015 | CTA_InvitationRequests[name].level = level; |
||
1016 | |||
1017 | CTA_IconMsg( CTA_INVITATION_SENT_TO.." "..name, CTA_GROUP_UPDATE ); |
||
1018 | CTA_SendAutoMsg( CTA_INVITATION_SENT_MESSAGE, name ); |
||
1019 | CTA_MyRaidInstantUpdate(); |
||
1020 | else |
||
1021 | CTA_InvitationRequests[name] = nil; |
||
1022 | CTA_LogMsg( name.."\'s request processed: Invalid player - request removed" ); |
||
1023 | |||
1024 | CTA_SendAutoMsg( CTA_WRONG_LEVEL_OR_CLASS, name ); |
||
1025 | end |
||
1026 | end |
||
1027 | else |
||
1028 | CTA_LogMsg( "Player "..CTA_WhoName.." could not be found. Removing from requests list." ); |
||
1029 | CTA_RemoveRequest(CTA_WhoName); |
||
1030 | end |
||
1031 | CTA_WhoName = nil; |
||
1032 | elseif( CTA_WhoFlag ) then |
||
1033 | |||
1034 | local numWhos, totalCount = GetNumWhoResults(); |
||
1035 | local name, guild, level, race, class, zone, group; |
||
1036 | for i=1, totalCount do |
||
1037 | name, guild, level, race, class, zone, group = GetWhoInfo(i); |
||
1038 | if( not name or name == CTA_WhoFlag ) then |
||
1039 | --CTA_Println( "Name: "..name..", Group: "..( group or "Null" ) ); |
||
1040 | break; |
||
1041 | end |
||
1042 | end |
||
1043 | if( name ) then |
||
1044 | for i = 1, getn( CTA_CtaMessageList ) do |
||
1045 | local cname = CTA_CtaMessageList[i].op or CTA_CtaMessageList[i].author or "?"; |
||
1046 | if( name == cname ) then |
||
1047 | if( strlen( guild ) > 0 ) then |
||
1048 | guild = "<"..guild..">"; |
||
1049 | end |
||
1050 | |||
1051 | local entry = { |
||
1052 | level = level; |
||
1053 | class = class; |
||
1054 | zone = zone; |
||
1055 | guild = guild; |
||
1056 | grouped = group; |
||
1057 | }; |
||
1058 | CTA_CtaMessageList[i].who = entry; |
||
1059 | break; |
||
1060 | end |
||
1061 | end |
||
1062 | else |
||
1063 | for i = 1, getn( CTA_CtaMessageList ) do |
||
1064 | local cname = CTA_CtaMessageList[i].op or CTA_CtaMessageList[i].author or "?"; |
||
1065 | if( CTA_WhoFlag == cname ) then |
||
1066 | local entry = {}; |
||
1067 | entry.level = 0; |
||
1068 | --[[ |
||
1069 | entry.class = ; |
||
1070 | entry.zone = ; |
||
1071 | entry.guild = ; ]] |
||
1072 | CTA_CtaMessageList[i].who = entry; |
||
1073 | break; |
||
1074 | end |
||
1075 | end |
||
1076 | end |
||
1077 | CTA_WhoFlag = nil; |
||
1078 | end |
||
1079 | |||
1080 | SetWhoToUI(0); |
||
1081 | end |
||
1082 | |||
1083 | -- Group update |
||
1084 | if ( event == "RAID_ROSTER_UPDATE" or event == "PARTY_LEADER_CHANGED" or event == "PARTY_MEMBERS_CHANGED" ) then |
||
1085 | CTA_GraceTimer = 2; |
||
1086 | end |
||
1087 | |||
1088 | end |
||
1089 | |||
1090 | function CTA_GetWhoInfo() |
||
1091 | local numWhos, totalCount = GetNumWhoResults(); |
||
1092 | local name, guild, level, race, class, zone, group; |
||
1093 | for i=1, totalCount do |
||
1094 | name, guild, level, race, class, zone, group = GetWhoInfo(i); |
||
1095 | if( not name or name == CTA_WhoName ) then |
||
1096 | break; |
||
1097 | end |
||
1098 | end |
||
1099 | return name, level, class, group; |
||
1100 | end |
||
1101 | |||
1102 | |||
1103 | |||
1104 | |||
1105 | |||
1106 | |||
1107 | |||
1108 | |||
1109 | |||
1110 | |||
1111 | |||
1112 | |||
1113 | |||
1114 | |||
1115 | |||
1116 | |||
1117 | |||
1118 | |||
1119 | |||
1120 | --[[ --------------------------------------------------------------- |
||
1121 | Communication - System |
||
1122 | --------------------------------------------------------------- |
||
1123 | ]] |
||
1124 | |||
1125 | |||
1126 | |||
1127 | |||
1128 | --[[ CTA_JoinChannel() |
||
1129 | --------------------------------------------------------------- |
||
1130 | Attempts to join the <var>CTA_CommunicationChannel</var> |
||
1131 | channel. |
||
1132 | ]] |
||
1133 | |||
1134 | function CTA_JoinChannel() |
||
1135 | CTA_Util.joinChannel( CTA_CommunicationChannel ); |
||
1136 | end |
||
1137 | |||
1138 | |||
1139 | |||
1140 | |||
1141 | --[[ CTA_ConnectedToChannel() |
||
1142 | --------------------------------------------------------------- |
||
1143 | Determines whether the client has joined the specified channel. |
||
1144 | @arg The name of the channel |
||
1145 | @return nil, 1 if already connected to the channel |
||
1146 | ]] |
||
1147 | |||
1148 | function CTA_ConnectedToChannel( channel ) |
||
1149 | local DefaultChannels = { GetChatWindowChannels(DEFAULT_CHAT_FRAME:GetID()) }; |
||
1150 | local connected = nil; |
||
1151 | if( DefaultChannels ) then |
||
1152 | for item = 1, getn(DefaultChannels) do |
||
1153 | CTA_LogMsg( DefaultChannels[item] ); |
||
1154 | if( DefaultChannels[item] == channel ) then |
||
1155 | connected = 1; |
||
1156 | break; |
||
1157 | end |
||
1158 | end |
||
1159 | end |
||
1160 | return connected; |
||
1161 | end |
||
1162 | |||
1163 | |||
1164 | |||
1165 | |||
1166 | --[[ CTA_SendAutoMsg() |
||
1167 | --------------------------------------------------------------- |
||
1168 | Sends a chat message, by whisper, to the specified player. |
||
1169 | @arg The message to be sent |
||
1170 | @arg The recipient of the message |
||
1171 | ]] |
||
1172 | |||
1173 | function CTA_SendAutoMsg( message, player ) |
||
1174 | CTA_SendChatMessage( "[CTA] "..message, "WHISPER", player ); |
||
1175 | end |
||
1176 | |||
1177 | |||
1178 | |||
1179 | |||
1180 | --[[ CTA_SendChatMessage() |
||
1181 | --------------------------------------------------------------- |
||
1182 | Sends a chat message to the specified player or channel. |
||
1183 | @arg The message to be sent |
||
1184 | @arg The type of transmission eg. whisper, channel etc |
||
1185 | @arg The recipient player/channel of the message |
||
1186 | ]] |
||
1187 | |||
1188 | function CTA_SendChatMessage( message, messageType, channel ) |
||
1189 | local language = CTA_COMMON; |
||
1190 | if( UnitFactionGroup(CTA_PLAYER) ~= CTA_ALLIANCE ) then |
||
1191 | language = CTA_ORCISH; |
||
1192 | end |
||
1193 | SendChatMessage( string.gsub( message, "|c(%w+)|H(%w+):(.+)|h(.+)|h|r", "%4" ), messageType, language, channel ); |
||
1194 | end |
||
1195 | |||
1196 | |||
1197 | |||
1198 | |||
1199 | |||
1200 | |||
1201 | |||
1202 | |||
1203 | |||
1204 | |||
1205 | |||
1206 | |||
1207 | |||
1208 | |||
1209 | |||
1210 | |||
1211 | |||
1212 | |||
1213 | --[[ --------------------------------------------------------------- |
||
1214 | Invitations |
||
1215 | --------------------------------------------------------------- |
||
1216 | ]] |
||
1217 | |||
1218 | |||
1219 | |||
1220 | |||
1221 | --[[ CTA_SendPasswordRaidInvitationRequest() |
||
1222 | --------------------------------------------------------------- |
||
1223 | Sends a request with a pasword for an invitation |
||
1224 | ]] |
||
1225 | |||
1226 | function CTA_SendPasswordRaidInvitationRequest() |
||
1227 | local raid = CTA_RaidList[ CTA_SelectedResultListItem ]; |
||
1228 | local password = CTA_SafeSet( CTA_JoinRaidWindowEditBox:GetText(), "" ); |
||
1229 | if( password ~= "" ) then |
||
1230 | CTA_SendChatMessage( CTA_INVITE_MAGIC_WORD.." "..password, "WHISPER", raid.leader ); |
||
1231 | CTA_JoinRaidWindow:Hide(); |
||
1232 | end |
||
1233 | end |
||
1234 | |||
1235 | |||
1236 | |||
1237 | |||
1238 | --[[ CTA_SendRaidInvitationRequest() |
||
1239 | --------------------------------------------------------------- |
||
1240 | Sends a request for an invitation |
||
1241 | ]] |
||
1242 | |||
1243 | function CTA_SendRaidInvitationRequest() |
||
1244 | local raid = CTA_RaidList[ CTA_SelectedResultListItem ]; |
||
1245 | CTA_JoinRaidWindow:Hide(); |
||
1246 | CTA_RequestInviteButton:Disable(); |
||
1247 | |||
1248 | if( raid.passwordProtected == 1 ) then |
||
1249 | CTA_JoinRaidWindow:Show(); |
||
1250 | else |
||
1251 | CTA_SendChatMessage( CTA_INVITE_MAGIC_WORD, "WHISPER", raid.author ); |
||
1252 | end |
||
1253 | end |
||
1254 | |||
1255 | |||
1256 | |||
1257 | |||
1258 | --[[ CTA_ReceiveRaidInvitationRequest() |
||
1259 | --------------------------------------------------------------- |
||
1260 | Handles incoming invitation requests. |
||
1261 | @arg The invitation request with optional password |
||
1262 | @arg The name pf the player requesting the invitation |
||
1263 | ]] |
||
1264 | |||
1265 | function CTA_ReceiveRaidInvitationRequest( msg, author ) |
||
1266 | if( CTA_InvitationRequests[author] ) then return; end -- cheap short-circuit hack |
||
1267 | CTA_LogMsg( "Received invitation request from "..author ); |
||
1268 | if( CTA_MyRaid.size + getn(CTA_InvitationRequests) < CTA_MyRaid.maxSize ) then |
||
1269 | if( CTA_MyRaid.passwordProtected==1 ) then |
||
1270 | local password = string.gsub( string.sub( msg, 9 ), "%s*([^%s]+).*", "%1" ); |
||
1271 | |||
1272 | if( password and password==CTA_MyRaidPassword ) then |
||
1273 | CTA_AddRequest( author ); |
||
1274 | else |
||
1275 | CTA_SendAutoMsg( CTA_INCORRECT_PASSWORD_MESSAGE, author); |
||
1276 | end |
||
1277 | else |
||
1278 | CTA_AddRequest( author ); |
||
1279 | end |
||
1280 | else |
||
1281 | CTA_SendAutoMsg( CTA_NO_SPACE_MESSAGE, author); |
||
1282 | end |
||
1283 | end |
||
1284 | |||
1285 | |||
1286 | |||
1287 | |||
1288 | --[[ CTA_AddRequest() |
||
1289 | --------------------------------------------------------------- |
||
1290 | Adds a player's request for an invitation to join the group. |
||
1291 | @arg The name of the player requesting an invitaion |
||
1292 | ]] |
||
1293 | |||
1294 | function CTA_AddRequest( name ) |
||
1295 | CTA_InvitationRequests[name] = {}; |
||
1296 | CTA_InvitationRequests[name].status = 1; |
||
1297 | CTA_OutstandingRequests = CTA_OutstandingRequests + 1; |
||
1298 | end |
||
1299 | |||
1300 | |||
1301 | |||
1302 | |||
1303 | --[[ CTA_RemoveRequest() |
||
1304 | --------------------------------------------------------------- |
||
1305 | Removes a player's request for an invitation to join the group. |
||
1306 | @arg The name of the player requesting an invitaion |
||
1307 | ]] |
||
1308 | |||
1309 | function CTA_RemoveRequest( name ) |
||
1310 | if( CTA_InvitationRequests[name] ) then |
||
1311 | if( CTA_InvitationRequests[name].status == 1 ) then |
||
1312 | CTA_OutstandingRequests = CTA_OutstandingRequests - 1; |
||
1313 | end |
||
1314 | CTA_InvitationRequests[name] = nil; |
||
1315 | end |
||
1316 | end |
||
1317 | |||
1318 | |||
1319 | |||
1320 | |||
1321 | |||
1322 | |||
1323 | |||
1324 | |||
1325 | |||
1326 | |||
1327 | |||
1328 | |||
1329 | |||
1330 | --[[ --------------------------------------------------------------- |
||
1331 | Inter-AddOn Group Information Communication |
||
1332 | --------------------------------------------------------------- |
||
1333 | ]] |
||
1334 | |||
1335 | |||
1336 | |||
1337 | |||
1338 | --[[ CTA_BroadcastRaidInfo() |
||
1339 | --------------------------------------------------------------- |
||
1340 | Sends this group info to the CTA Channel. |
||
1341 | ]] |
||
1342 | |||
1343 | function CTA_BroadcastRaidInfo() |
||
1344 | CTA_PollBroadcast = nil; |
||
1345 | |||
1346 | if( CTA_MyRaidIsOnline == nil ) then return; end -- short circuit hack for push changeover in R5 |
||
1347 | |||
1348 | local myName = UnitName( CTA_PLAYER ); |
||
1349 | local myRaid = CTA_MyRaid; |
||
1350 | --local com = CTA_GetGroupType()..": [CTA R3 Pre-release Test Group] "..myRaid.comment; |
||
1351 | local com = myRaid.comment.." ("..CTA_GetGroupType()..")"; |
||
1352 | local typ = myRaid.pvtype; |
||
1353 | local siz = myRaid.size; |
||
1354 | local max = myRaid.maxSize; |
||
1355 | local min = myRaid.minLevel; |
||
1356 | local cla = myRaid.classes; |
||
1357 | local pro = myRaid.passwordProtected; |
||
1358 | local opt = myRaid.options; |
||
1359 | --local tim = myRaid.creationTime; ListChannelByName |
||
1360 | |||
1361 | local hour, minute = GetGameTime(); |
||
1362 | local tim = hour; |
||
1363 | if( hour < 10 ) then tim = "0"..tim; end |
||
1364 | if( minute < 10 ) then tim = tim.."0"; end |
||
1365 | tim = tim..minute; |
||
1366 | |||
1367 | if( typ == CTA_RAID_TYPE_PVP ) then |
||
1368 | siz = siz + 40; |
||
1369 | end |
||
1370 | |||
1371 | if( pro == 1 ) then |
||
1372 | max = max + 40; |
||
1373 | end |
||
1374 | |||
1375 | while( string.len( cla ) < 3 ) do |
||
1376 | cla = "0"..cla; |
||
1377 | end |
||
1378 | |||
1379 | while( string.len( siz ) < 2 ) do |
||
1380 | siz = "0"..siz; |
||
1381 | end |
||
1382 | while( string.len( max ) < 2 ) do |
||
1383 | max = "0"..max; |
||
1384 | end |
||
1385 | while( string.len( min ) < 2 ) do |
||
1386 | min = "0"..min; |
||
1387 | end |
||
1388 | |||
1389 | local code = ""..tim..cla..siz..max..min; |
||
1390 | -- |
||
1391 | if string.find( com, ":") then com = string.gsub(com, ":", "."); end; |
||
1392 | |||
1393 | CTA_SendChatMessage("/cta A<"..code..":"..com..":"..opt..">", "CHANNEL", GetChannelName( CTA_CommunicationChannel ) ); |
||
1394 | |||
1395 | --CTA_IconMsg( "Broadcast Sent" ); |
||
1396 | end |
||
1397 | |||
1398 | |||
1399 | |||
1400 | |||
1401 | |||
1402 | |||
1403 | |||
1404 | |||
1405 | |||
1406 | |||
1407 | |||
1408 | |||
1409 | |||
1410 | |||
1411 | |||
1412 | |||
1413 | |||
1414 | |||
1415 | |||
1416 | |||
1417 | |||
1418 | |||
1419 | |||
1420 | |||
1421 | |||
1422 | |||
1423 | |||
1424 | |||
1425 | |||
1426 | |||
1427 | |||
1428 | |||
1429 | |||
1430 | |||
1431 | |||
1432 | |||
1433 | |||
1434 | |||
1435 | |||
1436 | |||
1437 | |||
1438 | |||
1439 | |||
1440 | |||
1441 | |||
1442 | |||
1443 | |||
1444 | |||
1445 | |||
1446 | |||
1447 | |||
1448 | |||
1449 | |||
1450 | |||
1451 | |||
1452 | |||
1453 | |||
1454 | |||
1455 | |||
1456 | |||
1457 | |||
1458 | --[[ --------------------------------------------------------------- |
||
1459 | Functions Related To The Search Frame And The Group List |
||
1460 | --------------------------------------------------------------- |
||
1461 | ]] |
||
1462 | |||
1463 | |||
1464 | |||
1465 | |||
1466 | --[[ CTA_ApplyFiltersToGroupList() |
||
1467 | --------------------------------------------------------------- |
||
1468 | Applies filter settings to the group list and |
||
1469 | updates the score for each one. This score will be used by the |
||
1470 | <func>CTA_UpdateList()</func> function to refresh the results |
||
1471 | list with those groups with a score of at least 1. |
||
1472 | Called by CTA_SearchButton, will be renamed to ApplyFilters() |
||
1473 | or something to that effect. |
||
1474 | ]] |
||
1475 | |||
1476 | |||
1477 | function CTA_ApplyFiltersToGroupList() |
||
1478 | |||
1479 | |||
1480 | local showClasses = CTA_SafeSet( CTA_SearchFrameShowClassCheckButton:GetChecked(), 0 ); |
||
1481 | if( showClasses == 0 ) then |
||
1482 | showClasses = CTA_MyClassCode(); |
||
1483 | else |
||
1484 | showClasses = 0; |
||
1485 | end |
||
1486 | local showPVP = CTA_SafeSet( CTA_SearchFrameShowPVPCheckButton:GetChecked(), 0 ); |
||
1487 | local showPVE = CTA_SafeSet( CTA_SearchFrameShowPVECheckButton:GetChecked(), 0 ); |
||
1488 | local keywords = CTA_SafeSet( CTA_SearchFrameDescriptionEditBox:GetText(), "*" ); |
||
1489 | local showEmpty = CTA_SafeSet( CTA_SearchFrameShowEmptyCheckButton:GetChecked(), 0 ); |
||
1490 | local showFull = CTA_SafeSet( CTA_SearchFrameShowFullCheckButton:GetChecked(), 0 ); |
||
1491 | local showProtected = CTA_SafeSet( CTA_SearchFrameShowPasswordCheckButton:GetChecked(), 0 ); |
||
1492 | local showMinLevel = CTA_SafeSet( CTA_SearchFrameShowLevelCheckButton:GetChecked(), 0 ); |
||
1493 | if( showMinLevel == 0 ) then |
||
1494 | showMinLevel = UnitLevel(CTA_PLAYER); |
||
1495 | else |
||
1496 | showMinLevel = 60; |
||
1497 | end |
||
1498 | |||
1499 | CTA_RequestInviteButton:Disable(); |
||
1500 | CTA_ResultsListOffset = 0; |
||
1501 | CTA_SelectedResultListItem = 0; |
||
1502 | |||
1503 | local oldListSize = 0; |
||
1504 | if( CTA_RaidList ) then |
||
1505 | oldListSize = getn( CTA_RaidList ); |
||
1506 | end |
||
1507 | |||
1508 | |||
1509 | CTA_RaidList = nil; |
||
1510 | CTA_RaidList = {}; |
||
1511 | |||
1512 | local chr, cmn = GetGameTime(); |
||
1513 | cmn = cmn + 1; |
||
1514 | local pruneCount = 0; |
||
1515 | |||
1516 | local playerClass, playerMinLevel, playerMaxLevel; |
||
1517 | |||
1518 | for i=1, getn( CTA_CtaMessageList ) do |
||
1519 | local data = CTA_CtaMessageList[i]; |
||
1520 | if( data ) then |
||
1521 | |||
1522 | local ok = 1; |
||
1523 | local rhr = tonumber( string.sub( data.time, 1, 2 ) ) or 0; -- added: beta 4 hack re: beta 3 reported error |
||
1524 | local rmn = tonumber( string.sub( data.time, 3, 4 ) ) or 0; -- added: beta 4 hack re: beta 3 reported error |
||
1525 | local dmn = cmn - rmn; |
||
1526 | if( dmn < 0 ) then |
||
1527 | dmn = dmn + 60; |
||
1528 | end |
||
1529 | |||
1530 | |||
1531 | playerClass = CTA_PlayerClassDropDownText:GetText() or CTA_ANY_CLASS; |
||
1532 | if( strlen(CTA_PlayerMinLevelEditBox:GetText()) == 0 ) then |
||
1533 | playerMinLevel = 1; |
||
1534 | else |
||
1535 | playerMinLevel = tonumber( CTA_PlayerMinLevelEditBox:GetText() ); |
||
1536 | end |
||
1537 | if( strlen(CTA_PlayerMaxLevelEditBox:GetText()) == 0 ) then |
||
1538 | playerMaxLevel = 60; |
||
1539 | else |
||
1540 | playerMaxLevel = tonumber( CTA_PlayerMaxLevelEditBox:GetText() ); |
||
1541 | end |
||
1542 | |||
1543 | |||
1544 | if( data.ctaType == "A" ) then |
||
1545 | |||
1546 | if( dmn > 2 ) then |
||
1547 | table.remove( CTA_CtaMessageList , i ); |
||
1548 | pruneCount = pruneCount + 1; |
||
1549 | ok = nil; |
||
1550 | i = i - 1; |
||
1551 | end |
||
1552 | |||
1553 | if( ok and showClasses > 0 and CTA_CheckClasses( data.classes, showClasses ) == 0 ) then ok = nil; end |
||
1554 | if( ok and showEmpty == 0 and data.size <= 1 ) then ok = nil; end |
||
1555 | if( ok and showFull == 0 and data.size == data.maxSize ) then ok = nil; end |
||
1556 | if( ok and showPVP == 0 and data.pvtype == CTA_RAID_TYPE_PVP ) then ok = nil; end |
||
1557 | if( ok and showPVE == 0 and data.pvtype == CTA_RAID_TYPE_PVE ) then ok = nil; end |
||
1558 | if( ok and showProtected == 0 and CTA_MyRaidPassword ) then ok = nil; end |
||
1559 | if( ok and showMinLevel < data.minLevel ) then ok = nil; end |
||
1560 | if ( CTA_SearchDropDownText:GetText() == CTA_SHOW_PLAYERS_ONLY ) then ok = nil; end |
||
1561 | |||
1562 | elseif( data.ctaType == "B" ) then |
||
1563 | |||
1564 | if( dmn > 2 ) then |
||
1565 | table.remove( CTA_CtaMessageList , i ); |
||
1566 | pruneCount = pruneCount + 1; |
||
1567 | ok = nil; |
||
1568 | i = i - 1; |
||
1569 | end |
||
1570 | if ( CTA_SearchDropDownText:GetText() == CTA_SHOW_GROUPS_ONLY ) then ok = nil; end |
||
1571 | |||
1572 | if ( data.who and data.who.level ~= 0 ) then |
||
1573 | if( playerClass ~= CTA_ANY_CLASS and data.who.class ~= playerClass ) then ok = nil; end |
||
1574 | if( data.who.level < playerMinLevel or data.who.level > playerMaxLevel ) then ok = nil; end |
||
1575 | end |
||
1576 | |||
1577 | elseif( data.ctaType == "C" ) then |
||
1578 | if( not CTA_ShowLocalLFXMessagesCheckButton:GetChecked() ) then |
||
1579 | ok = nil; |
||
1580 | end |
||
1581 | |||
1582 | if( dmn > 15 ) then |
||
1583 | table.remove( CTA_CtaMessageList , i ); |
||
1584 | pruneCount = pruneCount + 1; |
||
1585 | ok = nil; |
||
1586 | i = i - 1; |
||
1587 | end |
||
1588 | if ( CTA_SearchDropDownText:GetText() == CTA_SHOW_PLAYERS_ONLY ) then ok = nil; end |
||
1589 | |||
1590 | elseif( data.ctaType == "D" ) then |
||
1591 | if( not CTA_ShowLocalLFXMessagesCheckButton:GetChecked() ) then |
||
1592 | ok = nil; |
||
1593 | end |
||
1594 | |||
1595 | if( dmn > 15 ) then |
||
1596 | table.remove( CTA_CtaMessageList , i ); |
||
1597 | pruneCount = pruneCount + 1; |
||
1598 | ok = nil; |
||
1599 | i = i - 1; |
||
1600 | end |
||
1601 | if ( CTA_SearchDropDownText:GetText() == CTA_SHOW_GROUPS_ONLY ) then ok = nil; end |
||
1602 | |||
1603 | if ( data.who and data.who.level ~= 0 ) then |
||
1604 | if( playerClass ~= CTA_ANY_CLASS and data.who.class ~= playerClass ) then ok = nil; end |
||
1605 | if( data.who.level < playerMinLevel or data.who.level > playerMaxLevel ) then ok = nil; end |
||
1606 | end |
||
1607 | |||
1608 | end |
||
1609 | |||
1610 | if( ok ) then |
||
1611 | local score = 1; |
||
1612 | if( keywords and keywords~="*" ) then |
||
1613 | score = SachaSearch( data.author.." "..data.message, keywords ); |
||
1614 | end |
||
1615 | if( score > 0 ) then |
||
1616 | data.elapsed = dmn; |
||
1617 | table.insert( CTA_RaidList, data ); |
||
1618 | end |
||
1619 | end |
||
1620 | |||
1621 | end |
||
1622 | end |
||
1623 | |||
1624 | if( pruneCount > 0 ) then |
||
1625 | CTA_LogMsg( "Removed "..pruneCount.." old result items." ); |
||
1626 | end |
||
1627 | |||
1628 | if ( oldListSize < getn( CTA_RaidList ) ) then |
||
1629 | --CTA_IconMsg( CTA_NEW_LFX ); |
||
1630 | --PlaySound("TellMessage"); |
||
1631 | end |
||
1632 | |||
1633 | CTA_PollApplyFilters = nil; |
||
1634 | CTA_UpdateResults(); |
||
1635 | end |
||
1636 | |||
1637 | |||
1638 | |||
1639 | |||
1640 | --[[ CTA_UpdateResults() UPDATE FUNCTION |
||
1641 | --------------------------------------------------------------- |
||
1642 | Updates the groups results list to show only those |
||
1643 | groups with a score of at least 1. |
||
1644 | Also updates the selected group as necessary. |
||
1645 | ]] |
||
1646 | --[[ |
||
1647 | |||
1648 | local entry = {}; |
||
1649 | entry.ctaType = "A"; |
||
1650 | entry.author = arg2; |
||
1651 | entry.message = com; |
||
1652 | entry.time = tonumber(tim); |
||
1653 | entry.options = opt; |
||
1654 | |||
1655 | entry.pvtype = tonumber(typ); |
||
1656 | entry.size = tonumber(siz); |
||
1657 | entry.maxSize = tonumber(max); |
||
1658 | entry.minLevel = tonumber(min); |
||
1659 | entry.classes = tonumber(cla); |
||
1660 | entry.passwordProtected = tonumber(pro); |
||
1661 | |||
1662 | - |
||
1663 | |||
1664 | local entry = {}; |
||
1665 | entry.ctaType = "B"; |
||
1666 | entry.author = arg2; |
||
1667 | entry.message = com; |
||
1668 | entry.time = tonumber(code); |
||
1669 | entry.options = opt; |
||
1670 | |||
1671 | - |
||
1672 | |||
1673 | local entry = {}; |
||
1674 | entry.ctaType = "C"; |
||
1675 | entry.author = arg2; |
||
1676 | entry.message = com; |
||
1677 | entry.time = tonumber(code); |
||
1678 | entry.options = opt; |
||
1679 | |||
1680 | entry.op = opname; |
||
1681 | |||
1682 | - |
||
1683 | |||
1684 | local entry = {}; |
||
1685 | entry.ctaType = "D"; |
||
1686 | entry.author = arg2; |
||
1687 | entry.message = com; |
||
1688 | entry.time = tonumber(code); |
||
1689 | entry.options = opt; |
||
1690 | |||
1691 | entry.op = opname; |
||
1692 | |||
1693 | ]] |
||
1694 | |||
1695 | function CTA_UpdateResults() |
||
1696 | local index = 1; |
||
1697 | local groupListLength = getn( CTA_RaidList ); |
||
1698 | |||
1699 | |||
1700 | |||
1701 | if( groupListLength ~= 0 ) then |
||
1702 | CTA_MinimapIconTextLabel:SetText( groupListLength ); |
||
1703 | CTA_MinimapIconTextLabel:Show(); |
||
1704 | else |
||
1705 | CTA_MinimapIconTextLabel:Hide(); |
||
1706 | end |
||
1707 | |||
1708 | if( groupListLength ~= 1 ) then |
||
1709 | CTA_ResultsLabel:SetText( CTA_RESULTS_FOUND.." "..groupListLength.." / "..CTA_getn( CTA_CtaMessageList ) ); |
||
1710 | else |
||
1711 | CTA_ResultsLabel:SetText( CTA_RESULTS_FOUND.." "..groupListLength ); |
||
1712 | end |
||
1713 | |||
1714 | |||
1715 | CTA_PageLabel:Show(); |
||
1716 | |||
1717 | local cpage = floor( CTA_ResultsListOffset / CTA_MAX_RESULTS_ITEMS ); |
||
1718 | local tpage = floor( groupListLength / CTA_MAX_RESULTS_ITEMS ); |
||
1719 | if( cpage == 0 or cpage <= CTA_ResultsListOffset / CTA_MAX_RESULTS_ITEMS ) then cpage = cpage + 1; end |
||
1720 | if( tpage == 0 or tpage < groupListLength / CTA_MAX_RESULTS_ITEMS ) then tpage = tpage + 1; end |
||
1721 | CTA_PageLabel:SetText( CTA_PAGE.." "..cpage.." / "..tpage ); |
||
1722 | |||
1723 | |||
1724 | while( index < CTA_MAX_RESULTS_ITEMS + 1 ) do |
||
1725 | local c = "CTA_NewItem"..index; |
||
1726 | if( getglobal( c ) ) then |
||
1727 | if( index+CTA_ResultsListOffset <= groupListLength ) then |
||
1728 | local entry = CTA_RaidList[index+CTA_ResultsListOffset]; |
||
1729 | |||
1730 | --[[ The background colour |
||
1731 | if( entry.ctaType== "A" or entry.ctaType== "B" ) then |
||
1732 | getglobal( c.."TexturePurple"):Show(); |
||
1733 | getglobal( c.."TextureBlue"):Hide(); |
||
1734 | else |
||
1735 | getglobal( c.."TexturePurple"):Hide(); |
||
1736 | getglobal( c.."TextureBlue"):Show(); |
||
1737 | end |
||
1738 | --]] |
||
1739 | |||
1740 | -- The text colour |
||
1741 | if( entry.ctaType== "A" or entry.ctaType== "C" ) then |
||
1742 | getglobal( c.."NameLabel"):SetTextColor( 1, 0.85, 0, 1 ); |
||
1743 | getglobal( c.."TextureGold"):Show(); |
||
1744 | getglobal( c.."TextureSilver"):Hide(); |
||
1745 | else |
||
1746 | getglobal( c.."NameLabel"):SetTextColor( 0.95, 0.95, 1, 1 ); |
||
1747 | getglobal( c.."TextureGold"):Hide(); |
||
1748 | getglobal( c.."TextureSilver"):Show(); |
||
1749 | end |
||
1750 | |||
1751 | -- get elapsed time |
||
1752 | local timeText = ""; |
||
1753 | if( entry.elapsed ) then |
||
1754 | timeText = entry.elapsed.." min"; |
||
1755 | if( entry.elapsed > 1 ) then timeText = timeText.."s"; end |
||
1756 | else |
||
1757 | timeText = entry.time; |
||
1758 | end |
||
1759 | |||
1760 | local mainText = ""; |
||
1761 | local moreText = ""; |
||
1762 | local rightText = timeText.." ago"; |
||
1763 | |||
1764 | if( entry.ctaType== "A" ) then |
||
1765 | |||
1766 | local typeText = CTA_PVP; |
||
1767 | local passwordText = CTA_NO; |
||
1768 | if( entry.pvtype == CTA_RAID_TYPE_PVE ) then typeText = CTA_PVE; end |
||
1769 | if( entry.passwordProtected == 1 ) then passwordText = CTA_YES; end |
||
1770 | local myClass = UnitClass( CTA_PLAYER ); |
||
1771 | local comment = entry.message; |
||
1772 | if( entry.minLevel > UnitLevel(CTA_PLAYER) or not string.find(CTA_GetClassString(entry.classes),myClass) ) then |
||
1773 | comment = "|cffff0000"..comment.."|r"; |
||
1774 | elseif( entry.passwordProtected == 1 ) then |
||
1775 | comment = "|cffffff00"..comment.."|r"; |
||
1776 | else |
||
1777 | comment = "|cff00ff00"..comment.."|r"; |
||
1778 | end |
||
1779 | |||
1780 | mainText = entry.author..": "..comment; |
||
1781 | moreText = "Type: "..typeText..", Size: "..entry.size.."/"..entry.maxSize..", Minimum level: "..entry.minLevel..", Password: "..passwordText; |
||
1782 | rightText = "CTA Group. Last updated ".. rightText; |
||
1783 | elseif( entry.ctaType== "B" ) then |
||
1784 | |||
1785 | mainText = entry.author..": "..entry.message; |
||
1786 | if( entry.who and entry.who.level ~= 0 ) then |
||
1787 | moreText = "Level "..entry.who.level.." "..entry.who.class..", "..entry.who.guild.." "..entry.who.zone; |
||
1788 | --[[ |
||
1789 | if( entry.grouped == "yes" ) then |
||
1790 | moreText = moreText.." - In a group at tiem of message "; |
||
1791 | else |
||
1792 | moreText = moreText.." (not in a group)"; |
||
1793 | end |
||
1794 | ]] |
||
1795 | end |
||
1796 | rightText = "CTA Player. Last updated ".. rightText; |
||
1797 | |||
1798 | elseif( entry.ctaType== "C" ) then |
||
1799 | |||
1800 | mainText = entry.op..": "..entry.message; |
||
1801 | if( entry.who and entry.who.level ~= 0 ) then |
||
1802 | moreText = "Level "..entry.who.level.." "..entry.who.class..", "..entry.who.guild.." "..entry.who.zone; |
||
1803 | end |
||
1804 | rightText = "forwarded by "..entry.author.." "..rightText; |
||
1805 | |||
1806 | elseif( entry.ctaType== "D" ) then |
||
1807 | |||
1808 | mainText = entry.op..": "..entry.message; |
||
1809 | if( entry.who and entry.who.level ~= 0 ) then |
||
1810 | moreText = "Level "..entry.who.level.." "..entry.who.class..", "..entry.who.guild.." "..entry.who.zone; |
||
1811 | end |
||
1812 | rightText = "forwarded by "..entry.author.." "..rightText; |
||
1813 | |||
1814 | end |
||
1815 | |||
1816 | |||
1817 | |||
1818 | -- Set the texts |
||
1819 | getglobal( c.."NameLabel"):SetText( mainText ); |
||
1820 | getglobal( c.."MoreLabel"):SetText( moreText ); |
||
1821 | getglobal( c.."MoreRightLabel"):SetText( rightText ); |
||
1822 | |||
1823 | if( CTA_SelectedResultListItem == index + CTA_ResultsListOffset ) then |
||
1824 | getglobal( c.."TextureSelected"):Show(); |
||
1825 | else |
||
1826 | getglobal( c.."TextureSelected"):Hide(); |
||
1827 | end |
||
1828 | |||
1829 | getglobal( c ):Show(); |
||
1830 | else |
||
1831 | getglobal( c ):Hide(); |
||
1832 | end |
||
1833 | end |
||
1834 | index = index + 1; |
||
1835 | end |
||
1836 | end |
||
1837 | |||
1838 | |||
1839 | |||
1840 | --[[ CTA_ListItem_OnMouseUp() |
||
1841 | --------------------------------------------------------------- |
||
1842 | Sets the caller item as the selected group and updates the |
||
1843 | <ui>CTA_RequestInviteButton</ui> button as necessary, then |
||
1844 | calls the <func>CTA_UpdateResults()</func> afterwards. |
||
1845 | ]] |
||
1846 | |||
1847 | function CTA_ListItem_OnMouseUp() |
||
1848 | local value = string.gsub( this:GetName(), "CTA_NewItem(%d+)", "%1" ); |
||
1849 | if( CTA_SelectedResultListItem == CTA_ResultsListOffset + value ) then |
||
1850 | CTA_SelectedResultListItem = 0; |
||
1851 | CTA_RequestInviteButton:Disable(); |
||
1852 | else |
||
1853 | CTA_SelectedResultListItem = CTA_ResultsListOffset + value; |
||
1854 | |||
1855 | local raid = CTA_RaidList[ CTA_ResultsListOffset + value ]; |
||
1856 | |||
1857 | -- R7 |
||
1858 | if (arg1 == "RightButton") then |
||
1859 | local name = raid.op or raid.author; |
||
1860 | --FriendsFrame_ShowDropdown(name, 1); |
||
1861 | |||
1862 | HideDropDownMenu(1); |
||
1863 | if ( name ~= UnitName("player") ) then |
||
1864 | FriendsDropDown.initialize = FriendsFrameDropDown_Initialize; |
||
1865 | FriendsDropDown.displayMode = "MENU"; |
||
1866 | FriendsDropDown.name = name; |
||
1867 | ToggleDropDownMenu(1, nil, FriendsDropDown, this:GetName()); |
||
1868 | end |
||
1869 | |||
1870 | return; |
||
1871 | end |
||
1872 | -- /R7 |
||
1873 | |||
1874 | if( raid.ctaType == "A" ) then -- for R7 goodness |
||
1875 | |||
1876 | local myClass = UnitClass( CTA_PLAYER ); |
||
1877 | if( raid.minLevel > UnitLevel (CTA_PLAYER ) or not string.find( CTA_GetClassString( raid.classes ),myClass ) ) then |
||
1878 | CTA_RequestInviteButton:Disable(); |
||
1879 | else |
||
1880 | CTA_RequestInviteButton:Enable(); |
||
1881 | end |
||
1882 | end |
||
1883 | end |
||
1884 | CTA_UpdateResults(); |
||
1885 | end |
||
1886 | |||
1887 | |||
1888 | |||
1889 | |||
1890 | --[[ CTA_ListItem_ShowTooltip() |
||
1891 | --------------------------------------------------------------- |
||
1892 | Set up and show the tooltip for the calling group list item. |
||
1893 | ]] |
||
1894 | |||
1895 | function CTA_ListItemAuxLeft_ShowTooltip() |
||
1896 | GameTooltip:ClearLines(); |
||
1897 | local parent = this:GetParent(); |
||
1898 | local value = CTA_ResultsListOffset + string.gsub( parent:GetName(), "CTA_NewItem(%d+)", "%1" ); |
||
1899 | |||
1900 | local entry = CTA_RaidList[value]; |
||
1901 | GameTooltip:SetOwner( this, "ANCHOR_BOTTOMLEFT" ); |
||
1902 | GameTooltip:ClearAllPoints(); |
||
1903 | GameTooltip:SetPoint("BOTTOMLEFT", parent:GetName(), "TOPLEFT", 0, 8); |
||
1904 | |||
1905 | if( entry == nil ) then return; end |
||
1906 | |||
1907 | GameTooltip:AddLine( ( entry.op or entry.author ) ); |
||
1908 | GameTooltip:AddLine( entry.message, 0.9, 0.9, 1.0, 1, 1 ); |
||
1909 | GameTooltip:Show(); |
||
1910 | end |
||
1911 | |||
1912 | |||
1913 | function CTA_ListItemAuxRight_ShowTooltip() |
||
1914 | |||
1915 | local parent = this:GetParent(); |
||
1916 | |||
1917 | GameTooltip:ClearLines(); |
||
1918 | local value = CTA_ResultsListOffset + string.gsub( parent:GetName(), "CTA_NewItem(%d+)", "%1" ); |
||
1919 | |||
1920 | local raid = CTA_RaidList[value]; |
||
1921 | GameTooltip:SetOwner( this, "ANCHOR_BOTTOMRIGHT" ); |
||
1922 | GameTooltip:ClearAllPoints(); |
||
1923 | GameTooltip:SetPoint("BOTTOMRIGHT", parent:GetName(), "TOPRIGHT", 0, 8); |
||
1924 | |||
1925 | if( raid == nil ) then return; end |
||
1926 | |||
1927 | if( raid.ctaType == "A" ) then -- R7 condition |
||
1928 | |||
1929 | local classes = { }; |
||
1930 | classes[1] = CTA_PRIEST; |
||
1931 | classes[2] = CTA_MAGE; |
||
1932 | classes[3] = CTA_WARLOCK; |
||
1933 | classes[4] = CTA_DRUID; |
||
1934 | classes[5] = CTA_HUNTER; |
||
1935 | classes[6] = CTA_ROGUE; |
||
1936 | classes[7] = CTA_WARRIOR; |
||
1937 | if( UnitFactionGroup(CTA_PLAYER) == CTA_ALLIANCE ) then |
||
1938 | classes[8] = CTA_PALADIN; |
||
1939 | else |
||
1940 | classes[8] = CTA_SHAMAN; |
||
1941 | end |
||
1942 | local groupClasses, ctaVersion = CTA_DecodeGroupClasses( raid.options ); |
||
1943 | if( groupClasses and ctaVersion ) then |
||
1944 | GameTooltip:AddLine( CTA_CTA_GROUP, 0.1, 0.9, 0.1, 1, 1 ); |
||
1945 | GameTooltip:AddLine( CTA_CURRENT_GROUP_CLASSES..":", 0.1, 0.9, 0.1, 1, 1 ); |
||
1946 | local classList = CTA_GetClassString(raid.classes); |
||
1947 | for i = 1, 8 do |
||
1948 | if( string.find(classList, classes[i]) ) then |
||
1949 | GameTooltip:AddDoubleLine( classes[i], groupClasses[i], 0.9, 0.9, 0.1, 0.1, 0.9, 0.1 ); |
||
1950 | else |
||
1951 | GameTooltip:AddDoubleLine( classes[i], groupClasses[i], 0.9, 0.9, 0.1, 0.9, 0.1, 0.1 ); |
||
1952 | end |
||
1953 | end |
||
1954 | GameTooltip:AddDoubleLine( CTA_VERSION, ctaVersion, 0.9, 0.9, 0.9, 0.1, 0.9, 0.1 ); |
||
1955 | else |
||
1956 | if( raid.classes == 255 ) then |
||
1957 | GameTooltip:AddLine( CTA_LFM_ANY_CLASS, 0.1, 0.9, 0.1 ); |
||
1958 | else |
||
1959 | local myClass = UnitClass( CTA_PLAYER ); |
||
1960 | local classList = CTA_GetClassString(raid.classes); |
||
1961 | |||
1962 | if( string.find(classList, myClass) ) then |
||
1963 | GameTooltip:AddLine( CTA_LFM_CLASSLIST..classList, 0.1, 0.9, 0.1 ); |
||
1964 | else |
||
1965 | if( not classList or classList == "" ) then |
||
1966 | GameTooltip:AddLine( CTA_NO_MORE_PLAYERS_NEEDED, 0.9, 0.1, 0.1 ); |
||
1967 | else |
||
1968 | GameTooltip:AddLine( CTA_LFM_CLASSLIST..classList, 0.9, 0.1, 0.1 ); |
||
1969 | end |
||
1970 | end |
||
1971 | end |
||
1972 | GameTooltip:AddLine( CTA_PRE_R7_USER, 0.3, 0.3, 0.3, 1, 1 ); |
||
1973 | end |
||
1974 | |||
1975 | elseif( raid.ctaType == "B" ) then -- R7 condition |
||
1976 | |||
1977 | GameTooltip:AddLine( CTA_CTA_PLAYER, 0.1, 0.9, 0.1, 1, 1 ); |
||
1978 | GameTooltip:AddDoubleLine( CTA_VERSION, raid.options, 0.9, 0.9, 0.9, 0.1, 0.9, 0.1 ); |
||
1979 | |||
1980 | elseif( raid.ctaType == "C" ) then -- R7 condition |
||
1981 | |||
1982 | GameTooltip:AddLine( CTA_NON_CTA_GROUP_MESSAGE, 0.3, 0.3, 0.3, 1, 1 ); |
||
1983 | |||
1984 | elseif( raid.ctaType == "D" ) then -- R7 condition |
||
1985 | |||
1986 | GameTooltip:AddLine( CTA_NON_CTA_PLAYER_MESSAGE, 0.3, 0.3, 0.3, 1, 1 ); |
||
1987 | |||
1988 | end |
||
1989 | |||
1990 | GameTooltip:Show(); |
||
1991 | end |
||
1992 | |||
1993 | |||
1994 | function CTA_ResultItem_Hover_On(parent) |
||
1995 | local value = CTA_ResultsListOffset + string.gsub( parent:GetName(), "CTA_NewItem(%d+)", "%1" ); |
||
1996 | local entry = CTA_RaidList[value]; |
||
1997 | if( entry == nil ) then return; end |
||
1998 | |||
1999 | parent:SetHeight( 32 ); |
||
2000 | getglobal( parent:GetName().."MoreLabel" ):Show(); |
||
2001 | getglobal( parent:GetName().."MoreRightLabel" ):Show(); |
||
2002 | if( entry.ctaType== "A" or entry.ctaType== "B" ) then |
||
2003 | getglobal( parent:GetName().."TexturePurple"):Show(); |
||
2004 | getglobal( parent:GetName().."TextureBlue"):Hide(); |
||
2005 | else |
||
2006 | getglobal( parent:GetName().."TexturePurple"):Hide(); |
||
2007 | getglobal( parent:GetName().."TextureBlue"):Show(); |
||
2008 | end |
||
2009 | |||
2010 | if( entry.ctaType== "A" ) then |
||
2011 | getglobal( parent:GetName().."TextureSelectedIcon"):SetTexture( "Interface\\Icons\\Spell_Holy_SealOfFury" ); |
||
2012 | elseif( entry.ctaType== "B" ) then |
||
2013 | getglobal( parent:GetName().."TextureSelectedIcon"):SetTexture( "Interface\\Icons\\Spell_Holy_RetributionAura" ); |
||
2014 | elseif( entry.ctaType== "C" ) then |
||
2015 | getglobal( parent:GetName().."TextureSelectedIcon"):SetTexture( "Interface\\Icons\\Spell_Holy_SealOfProtection" ); |
||
2016 | elseif( entry.ctaType== "D" ) then |
||
2017 | getglobal( parent:GetName().."TextureSelectedIcon"):SetTexture( "Interface\\Icons\\Spell_Holy_RighteousnessAura" ); |
||
2018 | end |
||
2019 | |||
2020 | getglobal( parent:GetName().."NameLabel"):SetPoint( "TOPLEFT", parent:GetName(), "TOPLEFT", 37, 0 ); |
||
2021 | getglobal( parent:GetName().."MoreLabel"):SetPoint( "LEFT", parent:GetName(), "LEFT", 37, -6 ); |
||
2022 | |||
2023 | getglobal( parent:GetName().."TextureSelectedBg"):Show(); |
||
2024 | getglobal( parent:GetName().."TextureSelectedIcon"):Show(); |
||
2025 | |||
2026 | end |
||
2027 | |||
2028 | function CTA_ResultItem_Hover_Off(parent) |
||
2029 | parent:SetHeight( 18 ); |
||
2030 | getglobal( parent:GetName().."MoreLabel" ):Hide(); |
||
2031 | getglobal( parent:GetName().."MoreRightLabel" ):Hide(); |
||
2032 | getglobal( parent:GetName().."TexturePurple"):Hide(); |
||
2033 | getglobal( parent:GetName().."TextureBlue"):Hide(); |
||
2034 | |||
2035 | getglobal( parent:GetName().."NameLabel"):SetPoint( "TOPLEFT", parent:GetName(), "TOPLEFT", 5, 0 ); |
||
2036 | getglobal( parent:GetName().."MoreLabel"):SetPoint( "LEFT", parent:GetName(), "LEFT", 5, -6 ); |
||
2037 | |||
2038 | getglobal( parent:GetName().."TextureSelectedBg"):Hide(); |
||
2039 | getglobal( parent:GetName().."TextureSelectedIcon"):Hide(); |
||
2040 | |||
2041 | end |
||
2042 | |||
2043 | |||
2044 | |||
2045 | |||
2046 | |||
2047 | |||
2048 | |||
2049 | |||
2050 | |||
2051 | |||
2052 | |||
2053 | |||
2054 | |||
2055 | |||
2056 | |||
2057 | |||
2058 | |||
2059 | |||
2060 | |||
2061 | |||
2062 | |||
2063 | |||
2064 | |||
2065 | |||
2066 | |||
2067 | |||
2068 | |||
2069 | |||
2070 | |||
2071 | |||
2072 | |||
2073 | |||
2074 | |||
2075 | |||
2076 | |||
2077 | |||
2078 | |||
2079 | |||
2080 | |||
2081 | |||
2082 | |||
2083 | |||
2084 | |||
2085 | |||
2086 | |||
2087 | |||
2088 | |||
2089 | |||
2090 | |||
2091 | |||
2092 | |||
2093 | |||
2094 | |||
2095 | --[[ --------------------------------------------------------------- |
||
2096 | Functions Related To Hosting A Group And The Acid Items |
||
2097 | --------------------------------------------------------------- |
||
2098 | ]] |
||
2099 | |||
2100 | |||
2101 | |||
2102 | |||
2103 | --[[ CTA_MyRaidInstantUpdate() UPDATE FUNCTION |
||
2104 | --------------------------------------------------------------- |
||
2105 | Called by CTA_MyRaidFrame Components. |
||
2106 | This is the longest, most elaborate and buggy function and has |
||
2107 | been hacked and updated far too many times. |
||
2108 | Todo: A complete rewrite of the function. |
||
2109 | ]] |
||
2110 | |||
2111 | function CTA_MyRaidInstantUpdate() |
||
2112 | if( CTA_MyRaid == nil ) then return; end |
||
2113 | |||
2114 | local myName = UnitName( CTA_PLAYER ); |
||
2115 | |||
2116 | local myComment = CTA_SafeSet( CTA_MyRaidFrameDescriptionEditBox:GetText(), CTA_NO_DESCRIPTION ); |
||
2117 | |||
2118 | local myRaidType = CTA_RAID_TYPE_PVE; |
||
2119 | if( CTA_MyRaidFramePVPCheckButton:GetChecked() ) then |
||
2120 | myRaidType = CTA_RAID_TYPE_PVP; |
||
2121 | end |
||
2122 | |||
2123 | -- Advanced Class Integration and Distribution |
||
2124 | -- ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID |
||
2125 | -- ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID |
||
2126 | |||
2127 | --[[ ------------------------------------ |
||
2128 | [Setup Acid Items] |
||
2129 | |||
2130 | If the acid item has no class list |
||
2131 | then it is hidden. |
||
2132 | ------------------------------------ |
||
2133 | ]] |
||
2134 | if( not CTA_Acid0.val ) then |
||
2135 | local classes = { }; |
||
2136 | classes[1] = CTA_PRIEST; |
||
2137 | classes[2] = CTA_MAGE; |
||
2138 | classes[3] = CTA_WARLOCK; |
||
2139 | classes[4] = CTA_DRUID; |
||
2140 | classes[5] = CTA_HUNTER; |
||
2141 | classes[6] = CTA_ROGUE; |
||
2142 | classes[7] = CTA_WARRIOR; |
||
2143 | if( UnitFactionGroup(CTA_PLAYER) == CTA_ALLIANCE ) then |
||
2144 | classes[8] = CTA_PALADIN; |
||
2145 | else |
||
2146 | classes[8] = CTA_SHAMAN; |
||
2147 | end |
||
2148 | |||
2149 | local num = 0; |
||
2150 | while( num < 9 ) do |
||
2151 | local item = getglobal( "CTA_Acid"..num ); |
||
2152 | local class = getglobal( "CTA_Acid"..num.."ClassNameLabel" ); |
||
2153 | |||
2154 | if( num > 0 ) then |
||
2155 | item.val = 0; |
||
2156 | item.cur = 0; |
||
2157 | else |
||
2158 | class:SetText( CTA_ANY_CLASS ); |
||
2159 | item.val = CTA_MyRaid.maxSize; |
||
2160 | getglobal( "CTA_Acid"..num.."LessButton"):Hide(); |
||
2161 | getglobal( "CTA_Acid"..num.."MoreButton"):Hide(); |
||
2162 | --getglobal( "CTA_Acid"..num.."EditButton"):Hide(); |
||
2163 | getglobal( "CTA_Acid"..num.."DeleteButton"):Hide(); |
||
2164 | end |
||
2165 | |||
2166 | num = num + 1; |
||
2167 | end |
||
2168 | end |
||
2169 | |||
2170 | |||
2171 | --[[ ------------------------------------ |
||
2172 | [Update the Max Size] |
||
2173 | |||
2174 | If the and sets up certain features |
||
2175 | for raid / party |
||
2176 | ------------------------------------ |
||
2177 | ]] |
||
2178 | |||
2179 | local myOldMax = CTA_MyRaid.maxSize; |
||
2180 | if( not myOldMax ) then myOldMax = 40; end |
||
2181 | |||
2182 | if ( IsRaidLeader() and GetNumRaidMembers() > 0 ) then CTA_HostingRaidGroup = 1; end |
||
2183 | local maxSizeLimit = 5; -- R2 |
||
2184 | CTA_ConvertToRaidButton:Hide(); |
||
2185 | CTA_MaxSizeHelpLabel:SetText( CTA_MAXIMUM_PLAYERS_HELP2 ); |
||
2186 | if( IsPartyLeader() and GetNumRaidMembers() == 0 ) then |
||
2187 | CTA_ConvertToRaidButton:Show(); |
||
2188 | else |
||
2189 | CTA_ConvertToRaidButton:Hide(); |
||
2190 | end |
||
2191 | if( CTA_HostingRaidGroup ) then |
||
2192 | maxSizeLimit = 40; |
||
2193 | CTA_MaxSizeHelpLabel:SetText( CTA_MAXIMUM_PLAYERS_HELP ); |
||
2194 | end |
||
2195 | if( IsRaidLeader() and GetNumRaidMembers() > 0 and GetNumRaidMembers() < 6 ) then |
||
2196 | CTA_ConvertToPartyButton:Show(); |
||
2197 | else |
||
2198 | CTA_ConvertToPartyButton:Hide(); |
||
2199 | end |
||
2200 | |||
2201 | if( CTA_MyRaid.maxSize > maxSizeLimit ) then |
||
2202 | CTA_MyRaid.maxSize = maxSizeLimit; |
||
2203 | end |
||
2204 | |||
2205 | local myMaxSize = CTA_SafeSetNumber( CTA_MyRaidFrameMaxSizeEditBox:GetText(), 5, maxSizeLimit ); |
||
2206 | if( not myMaxSize ) then |
||
2207 | myMaxSize = CTA_MyRaid.maxSize; |
||
2208 | else |
||
2209 | CTA_MyRaid.maxSize = tonumber(myMaxSize); |
||
2210 | end |
||
2211 | CTA_MyRaidFrameMaxSizeEditBox:SetText(""..myMaxSize); |
||
2212 | |||
2213 | |||
2214 | --[[ ------------------------------------ |
||
2215 | [Update ACID Scale] |
||
2216 | |||
2217 | According to the max size |
||
2218 | ------------------------------------ |
||
2219 | ]] |
||
2220 | |||
2221 | --if( myMaxSize ~= myOldMax ) then |
||
2222 | local num = 0; |
||
2223 | local cval = 0; |
||
2224 | while( num < 9 ) do |
||
2225 | local item = getglobal( "CTA_Acid"..num ); |
||
2226 | local ratio = item.val/myOldMax; |
||
2227 | item.val = floor(myMaxSize*ratio); |
||
2228 | cval = cval+item.val; |
||
2229 | num = num + 1; |
||
2230 | end |
||
2231 | if( cval < myMaxSize ) then |
||
2232 | CTA_Acid0.val = CTA_Acid0.val + (myMaxSize-cval); |
||
2233 | end |
||
2234 | num = 0; |
||
2235 | while( num < 9 and cval > myMaxSize ) do |
||
2236 | local item = getglobal( "CTA_Acid"..num ); |
||
2237 | if( item.val > 0 ) then |
||
2238 | item.val = item.val - 1; |
||
2239 | cval = cval - 1; |
||
2240 | else |
||
2241 | num = num + 1; |
||
2242 | end |
||
2243 | end |
||
2244 | --end |
||
2245 | --CTA_LogMsg( "Adjusted ACID Size ("..cval..")", CTA_GENERAL ); |
||
2246 | |||
2247 | |||
2248 | --[[ ------------------------------------ |
||
2249 | [Reset Acid item current size] |
||
2250 | |||
2251 | Set the current players in each rule |
||
2252 | to 0 |
||
2253 | ------------------------------------ |
||
2254 | ]] |
||
2255 | |||
2256 | |||
2257 | local num = 0; |
||
2258 | while( num < 9 ) do |
||
2259 | local item = getglobal( "CTA_Acid"..num ); |
||
2260 | item.cur = 0; |
||
2261 | num = num + 1; |
||
2262 | end |
||
2263 | |||
2264 | |||
2265 | --[[ ------------------------------------ |
||
2266 | [Update ACID items current size] |
||
2267 | |||
2268 | Big change here now |
||
2269 | ------------------------------------ |
||
2270 | ]] |
||
2271 | |||
2272 | |||
2273 | local name, level, class; |
||
2274 | local over = 0; |
||
2275 | num = 1; |
||
2276 | while ( num <= 40 ) do |
||
2277 | name, level, class = CTA_GetGroupMemberInfo( num ); |
||
2278 | if( name == nil ) then break; end |
||
2279 | local index = CTA_GetClassCode(class); |
||
2280 | |||
2281 | local bestItem = nil; |
||
2282 | for i = 1, 8 do |
||
2283 | local item = getglobal( "CTA_Acid"..i ); |
||
2284 | if( item.classes and item.classes[class] ) then |
||
2285 | if( not bestItem or CTA_getn(bestItem.classes) > CTA_getn(item.classes) ) then |
||
2286 | if( item.cur < item.val ) then |
||
2287 | bestItem = item; |
||
2288 | end |
||
2289 | end |
||
2290 | end |
||
2291 | end |
||
2292 | |||
2293 | if( not bestItem ) then |
||
2294 | over = over + 1; |
||
2295 | else |
||
2296 | bestItem.cur = bestItem.cur + 1; |
||
2297 | end |
||
2298 | --if( item.cur > item.val ) then over = over + 1; end |
||
2299 | |||
2300 | if( CTA_InvitationRequests[name] ) then |
||
2301 | CTA_RemoveRequest( name ); -- R2: Remove pending member if in raid |
||
2302 | CTA_LogMsg( name.." has joined the group - request removed" ); |
||
2303 | CTA_SendAutoMsg( CTA_PROMO..CTA_ANNOUNCE_JOIN_PROMPT, name ); |
||
2304 | end |
||
2305 | |||
2306 | num = num+1; |
||
2307 | end |
||
2308 | |||
2309 | |||
2310 | --[[ ------------------------------------ |
||
2311 | [Update the Group Size] |
||
2312 | |||
2313 | Take pendings into account etc |
||
2314 | ------------------------------------ |
||
2315 | ]] |
||
2316 | |||
2317 | |||
2318 | local pendingSize = 0; |
||
2319 | for name, data in CTA_InvitationRequests do |
||
2320 | if( name and data.status == 2 ) then -- R2: pending members |
||
2321 | --CTA_Println( name..": "..class ); |
||
2322 | local index = CTA_GetClassCode( data.class); |
||
2323 | local item = getglobal( "CTA_Acid"..index ); |
||
2324 | item.cur = item.cur + 1; |
||
2325 | pendingSize = pendingSize + 1; |
||
2326 | if( item.cur > item.val ) then over = over + 1; end |
||
2327 | end |
||
2328 | end |
||
2329 | |||
2330 | CTA_Acid0.cur = over; |
||
2331 | |||
2332 | --[[ |
||
2333 | local oldSize = CTA_MyRaid.size; |
||
2334 | CTA_MyRaid.size = CTA_GetNumGroupMembers() + pendingSize; |
||
2335 | local mySize = CTA_MyRaid.size; |
||
2336 | |||
2337 | if ( ( IsRaidLeader() and GetNumRaidMembers() > 0 ) ) then |
||
2338 | CTA_RaidSizeLabel:SetText( CTA_SIZE..": "..CTA_MyRaid.size.." ("..CTA_RAID..") ("..CTA_CURRENT..": "..CTA_GetNumGroupMembers().." "..CTA_PENDING..": "..pendingSize..")" ); |
||
2339 | |||
2340 | elseif( IsPartyLeader() and GetNumRaidMembers() == 0 ) then |
||
2341 | CTA_RaidSizeLabel:SetText( CTA_SIZE..": "..CTA_MyRaid.size.." ("..CTA_PARTY..") ("..CTA_CURRENT..": "..CTA_GetNumGroupMembers().." "..CTA_PENDING..": "..pendingSize..")" ); |
||
2342 | |||
2343 | end]] |
||
2344 | |||
2345 | local oldSize = CTA_MyRaid.size; |
||
2346 | CTA_MyRaid.size = CTA_GetNumGroupMembers(); |
||
2347 | local mySize = CTA_MyRaid.size; |
||
2348 | --CTA_Println( "Size = "..mySize ); |
||
2349 | CTA_RaidSizeLabel:SetText( CTA_SIZE..": "..CTA_MyRaid.size.." ("..CTA_CURRENT..": "..CTA_GetNumGroupMembers().." "..CTA_PENDING..": "..CTA_getn(CTA_InvitationRequests)..")" ); |
||
2350 | |||
2351 | |||
2352 | if( CTA_MyRaid.size > oldSize ) then |
||
2353 | PlaySound("TellMessage"); |
||
2354 | end |
||
2355 | CTA_IconMsg( CTA_GROUP_MEMBERS..CTA_MyRaid.size, CTA_GROUP_UPDATE); |
||
2356 | |||
2357 | -- R7 announce auto off |
||
2358 | |||
2359 | if( autoannounce and CTA_GetNumGroupMembers() >= CTA_MyRaid.maxSize ) then |
||
2360 | autoannouce = nil; |
||
2361 | CTA_AnnounceTimer = 0; |
||
2362 | CTA_Println( "Your group has the desired number of players. LFM Auto announce OFF" ); |
||
2363 | end |
||
2364 | |||
2365 | |||
2366 | --[[ ------------------------------------ |
||
2367 | [Update the Acid Items] |
||
2368 | |||
2369 | Accordingly |
||
2370 | ------------------------------------ |
||
2371 | ]] |
||
2372 | |||
2373 | |||
2374 | num = 0; |
||
2375 | |||
2376 | |||
2377 | CTA_AcidSummary = CTA_LFM..": "..CTA_MyRaid.comment.." ("..CTA_MyRaid.size.."/"..CTA_MyRaid.maxSize..")"..CTA_ANNOUNCE_SUMMARY_PROMPT; |
||
2378 | CTA_AcidDetails = CTA_LFM..": "..CTA_MyRaid.comment.." ("..CTA_MyRaid.size.."/"..CTA_MyRaid.maxSize..") - "; |
||
2379 | |||
2380 | while( num < 9 ) do |
||
2381 | local item = getglobal( "CTA_Acid"..num ); |
||
2382 | |||
2383 | if( item.classes or item:GetName()=="CTA_Acid0" ) then |
||
2384 | |||
2385 | |||
2386 | |||
2387 | local nam = getglobal( "CTA_Acid"..num.."ClassNameLabel" ); |
||
2388 | |||
2389 | |||
2390 | if( item:GetName()~="CTA_Acid0" ) then |
||
2391 | getglobal( "CTA_Acid"..num.."ClassNameLabel" ):Show(); |
||
2392 | --getglobal( "CTA_Acid"..num.."ClassPercentLabel" ):Show(); |
||
2393 | getglobal( "CTA_Acid"..num.."ClassAbsoluteLabel" ):Show(); |
||
2394 | getglobal( "CTA_Acid"..num.."ClassCurrentLabel" ):Show(); |
||
2395 | |||
2396 | getglobal( "CTA_Acid"..num.."LessButton"):Show(); |
||
2397 | getglobal( "CTA_Acid"..num.."MoreButton"):Show(); |
||
2398 | --getglobal( "CTA_Acid"..num.."EditButton"):Show(); |
||
2399 | getglobal( "CTA_Acid"..num.."DeleteButton"):SetText( "Edit" ); |
||
2400 | |||
2401 | nam:SetText( "" ); |
||
2402 | for key, val in item.classes do |
||
2403 | if( nam:GetText() ) then |
||
2404 | nam:SetText( nam:GetText()..key.."\n" ); |
||
2405 | else |
||
2406 | nam:SetText( key.."\n" ); |
||
2407 | end |
||
2408 | end |
||
2409 | end |
||
2410 | |||
2411 | local percent = getglobal( "CTA_Acid"..num.."ClassPercentLabel" ); |
||
2412 | local current = getglobal( "CTA_Acid"..num.."ClassAbsoluteLabel" ); |
||
2413 | local absolute = getglobal( "CTA_Acid"..num.."ClassCurrentLabel" ); |
||
2414 | local percentTex = getglobal( "CTA_Acid"..num.."PercentTexture" ); |
||
2415 | local currentTex = getglobal( "CTA_Acid"..num.."CurrentTexture" ); |
||
2416 | |||
2417 | local pval = floor(50*item.val/CTA_MyRaid.maxSize); --80 changed to 50 R5 |
||
2418 | if( pval > 50 ) then pval = 50; end -- cheapo fix |
||
2419 | local percentage = floor(100*item.val/CTA_MyRaid.maxSize); |
||
2420 | |||
2421 | percent:SetText( percentage.."%" ); |
||
2422 | absolute:SetText( "/"..item.val ); |
||
2423 | |||
2424 | if( item.val == 0) then |
||
2425 | percentTex:Hide(); |
||
2426 | absolute:SetTextColor( 0.5, 0.5, 0.5 ); |
||
2427 | else |
||
2428 | percentTex:SetHeight( pval ); |
||
2429 | absolute:SetTextColor( 1.0, 0.82, 0.0 ); |
||
2430 | percentTex:Show(); |
||
2431 | end |
||
2432 | |||
2433 | local cval = item.cur; |
||
2434 | local cpval = floor(50*cval/CTA_MyRaid.maxSize); --80 -> 50 R5 |
||
2435 | if( cpval > 50 ) then cpval = 50; end -- cheapo fix |
||
2436 | current:SetText( cval ); |
||
2437 | |||
2438 | if( cval == 0) then |
||
2439 | currentTex:Hide(); |
||
2440 | current:SetTextColor( 0.5, 0.5, 0.5 ); |
||
2441 | else |
||
2442 | current:SetTextColor( 1.0, 0.82, 0.0 ); |
||
2443 | currentTex:SetHeight( cpval ); |
||
2444 | currentTex:Show(); |
||
2445 | end |
||
2446 | if( cval > item.val and CTA_Acid0.cur > CTA_Acid0.val ) then |
||
2447 | current:SetTextColor( 1.0, 0.0, 0.0 ); |
||
2448 | end |
||
2449 | |||
2450 | local lfm = item.val-item.cur; |
||
2451 | if( lfm > 0 ) then |
||
2452 | if( num == 0 ) then |
||
2453 | CTA_AcidDetails = CTA_AcidDetails..(lfm).." "..CTA_ANY_CLASS..", "; |
||
2454 | else |
||
2455 | CTA_AcidDetails = CTA_AcidDetails..(lfm).." "; |
||
2456 | local f = nil; |
||
2457 | for k,v in item.classes do |
||
2458 | if( f ) then |
||
2459 | CTA_AcidDetails = CTA_AcidDetails.."/"; |
||
2460 | else |
||
2461 | f = 1; |
||
2462 | end |
||
2463 | CTA_AcidDetails = CTA_AcidDetails..k; |
||
2464 | |||
2465 | end |
||
2466 | CTA_AcidDetails = CTA_AcidDetails..", "; |
||
2467 | end |
||
2468 | end |
||
2469 | else |
||
2470 | |||
2471 | getglobal( "CTA_Acid"..num.."ClassNameLabel" ):Hide(); |
||
2472 | |||
2473 | --getglobal( "CTA_Acid"..num.."ClassPercentLabel" ):Hide(); |
||
2474 | getglobal( "CTA_Acid"..num.."ClassAbsoluteLabel" ):Hide(); |
||
2475 | getglobal( "CTA_Acid"..num.."ClassCurrentLabel" ):Hide(); |
||
2476 | |||
2477 | getglobal( "CTA_Acid"..num.."PercentTexture" ):Hide(); |
||
2478 | getglobal( "CTA_Acid"..num.."CurrentTexture" ):Hide(); |
||
2479 | |||
2480 | getglobal( "CTA_Acid"..num.."LessButton"):Hide(); |
||
2481 | getglobal( "CTA_Acid"..num.."MoreButton"):Hide(); |
||
2482 | --getglobal( "CTA_Acid"..num.."EditButton"):Hide(); |
||
2483 | getglobal( "CTA_Acid"..num.."DeleteButton"):SetText( "Add" ); |
||
2484 | |||
2485 | |||
2486 | --item:Hide(); |
||
2487 | end |
||
2488 | |||
2489 | num = num + 1; |
||
2490 | end |
||
2491 | |||
2492 | CTA_AcidDetails = CTA_AcidDetails..CTA_ANNOUNCE_DETAILS_PROMPT; |
||
2493 | |||
2494 | |||
2495 | CTA_AcidNote:SetText( CTA_AcidSummary ); |
||
2496 | |||
2497 | if( CTA_HostingRaidGroup and IsPartyLeader() and GetNumRaidMembers() == 0 ) then |
||
2498 | CTA_ConvertToRaid(); |
||
2499 | end |
||
2500 | |||
2501 | -- ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID |
||
2502 | -- ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID |
||
2503 | -- ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID ACID |
||
2504 | |||
2505 | local myMinLevel = CTA_SafeSetNumber( CTA_MyRaidFrameMinLevelEditBox:GetText(), 1, 60 ); |
||
2506 | if( not myMinLevel ) then |
||
2507 | CTA_MyRaidFrameMinLevelEditBox:SetText( CTA_MyRaid.minLevel ); |
||
2508 | myMinLevel = CTA_MyRaid.minLevel; |
||
2509 | end |
||
2510 | |||
2511 | local myClasses = 0; |
||
2512 | if( CTA_Acid0.cur < CTA_Acid0.val ) then |
||
2513 | myClasses = 255; |
||
2514 | else |
||
2515 | local num = 1; |
||
2516 | local b = 1; |
||
2517 | local combinedClasses = {}; |
||
2518 | for i = 1, 8 do |
||
2519 | local item = getglobal( "CTA_Acid"..i ); |
||
2520 | if( item.classes and item.cur < item.val ) then |
||
2521 | for k, v in item.classes do |
||
2522 | combinedClasses[ k ] = 1; |
||
2523 | end |
||
2524 | end |
||
2525 | end |
||
2526 | |||
2527 | for k,v in combinedClasses do |
||
2528 | local index = CTA_GetClassCode( k ); |
||
2529 | myClasses = myClasses + (2^(index - 1 )); |
||
2530 | end |
||
2531 | --[[ |
||
2532 | while( num < 9 ) do |
||
2533 | local item = getglobal( "CTA_Acid"..num ); |
||
2534 | if( item.cur < item.val ) then |
||
2535 | myClasses = myClasses + b; |
||
2536 | end |
||
2537 | b = b * 2; |
||
2538 | num = num + 1; |
||
2539 | end ]] |
||
2540 | end |
||
2541 | |||
2542 | local myUsePassword = 1; |
||
2543 | local oldPassword = CTA_MyRaidPassword; |
||
2544 | CTA_MyRaidPassword = CTA_MyRaidFramePasswordEditBox:GetText(); |
||
2545 | for space in string.gfind( CTA_MyRaidPassword, "(%s)" ) do |
||
2546 | CTA_MyRaidPassword = oldPassword; |
||
2547 | end |
||
2548 | if( not CTA_MyRaidPassword or CTA_MyRaidPassword== "" ) then |
||
2549 | myUsePassword = 0; |
||
2550 | CTA_MyRaidPassword = nil; |
||
2551 | CTA_MyRaidFramePasswordEditBox:SetText( "" ); |
||
2552 | |||
2553 | else |
||
2554 | CTA_MyRaidFramePasswordEditBox:SetText( CTA_MyRaidPassword ); |
||
2555 | end |
||
2556 | |||
2557 | local myName = UnitName(CTA_PLAYER); |
||
2558 | local myTime = CTA_MyRaid.creationTime; |
||
2559 | local myOptions = CTA_GetGroupClassesCode()..CTA_RELEASEVERSION..",R"; |
||
2560 | |||
2561 | CTA_SetRaidInfo( CTA_MyRaid, myName, 100, myComment, myRaidType, mySize, myMaxSize, myMinLevel, myClasses, myUsePassword, myTime, myOptions ); |
||
2562 | CTA_PollBroadcast = 1; |
||
2563 | --CTA_IconMsg( "Broadcast Polled" ); |
||
2564 | end |
||
2565 | |||
2566 | function CTA_AcidItemButton_OnClick() |
||
2567 | local item = getglobal( this:GetParent():GetName() ); |
||
2568 | |||
2569 | if( string.find( this:GetName(), "Delete" ) ) then |
||
2570 | CTA_StartEditAcidItem( item ); |
||
2571 | --[[ |
||
2572 | if( item.classes == nil ) then |
||
2573 | CTA_AddAcidItem( item ); |
||
2574 | else |
||
2575 | CTA_StartEditAcidItem(item); |
||
2576 | end]] |
||
2577 | elseif( string.find( this:GetName(), "Less" ) ) then |
||
2578 | if( item.val > 0 ) then |
||
2579 | item.val = item.val - 1; |
||
2580 | CTA_Acid0.val = CTA_Acid0.val + 1; |
||
2581 | end |
||
2582 | CTA_MyRaidInstantUpdate(); |
||
2583 | else |
||
2584 | if( CTA_Acid0.val > 0 ) then |
||
2585 | item.val = item.val + 1; |
||
2586 | CTA_Acid0.val = CTA_Acid0.val - 1; |
||
2587 | end |
||
2588 | CTA_MyRaidInstantUpdate(); |
||
2589 | end |
||
2590 | end |
||
2591 | |||
2592 | |||
2593 | |||
2594 | |||
2595 | --[[ CTA_StartEditAcidItem() |
||
2596 | --------------------------------------------------------------- |
||
2597 | Called by CTA_Acid(0-8) AddButton Components. |
||
2598 | All this function really does is set up the check buttons |
||
2599 | in the <ui>CTA_AcidEditDialog</ui> Frame before showing it |
||
2600 | to the user. |
||
2601 | ]] |
||
2602 | |||
2603 | function CTA_StartEditAcidItem( item ) |
||
2604 | for i = 1, 8 do |
||
2605 | getglobal( "CTA_AcidClassCheckButton"..i ):SetChecked( 0 ); |
||
2606 | end |
||
2607 | |||
2608 | if( UnitFactionGroup(CTA_PLAYER) == CTA_ALLIANCE ) then |
||
2609 | CTA_AcidClassCheckButton8TextLabel:SetText( CTA_PALADIN ); |
||
2610 | else |
||
2611 | CTA_AcidClassCheckButton8TextLabel:SetText( CTA_SHAMAN ); |
||
2612 | end |
||
2613 | |||
2614 | if( item.classes ) then |
||
2615 | for key, val in item.classes do |
||
2616 | |||
2617 | for i = 1, 8 do |
||
2618 | if ( getglobal( "CTA_AcidClassCheckButton"..i.."TextLabel" ):GetText() == key ) then |
||
2619 | getglobal( "CTA_AcidClassCheckButton"..i ):SetChecked( 1 ); |
||
2620 | end |
||
2621 | end |
||
2622 | end |
||
2623 | else |
||
2624 | item.classes = {}; |
||
2625 | end |
||
2626 | |||
2627 | CTA_AcidEditDialogHeadingLabel:SetText( CTA_EDIT_ACID_CLASSES ); |
||
2628 | CTA_AcidEditDialog.target = item:GetName(); |
||
2629 | |||
2630 | CTA_AcidEditDialog:Show(); |
||
2631 | end |
||
2632 | |||
2633 | |||
2634 | |||
2635 | |||
2636 | --[[ CTA_EditAcidItem() |
||
2637 | --------------------------------------------------------------- |
||
2638 | Called by the <ui>CTA_AcidEditDialog</ui>'s OKButton Component. |
||
2639 | Sets the Acid item's class list to what classes were checked |
||
2640 | by the user in the edit dialog. |
||
2641 | ]] |
||
2642 | |||
2643 | function CTA_EditAcidItem() |
||
2644 | local acidItem = getglobal( CTA_AcidEditDialog.target ); |
||
2645 | local checkCount = 0; |
||
2646 | acidItem.classes = {}; |
||
2647 | for i = 1, 8 do |
||
2648 | local checked = getglobal( "CTA_AcidClassCheckButton"..i ):GetChecked(); |
||
2649 | if( checked ) then |
||
2650 | acidItem.classes[ getglobal( "CTA_AcidClassCheckButton"..i.."TextLabel" ):GetText() ] = 0; |
||
2651 | checkCount = checkCount + 1; |
||
2652 | end |
||
2653 | end |
||
2654 | |||
2655 | if( checkCount == 0 or checkCount == 8 ) then |
||
2656 | acidItem.classes = nil; |
||
2657 | if( acidItem.val ) then |
||
2658 | CTA_Acid0.val = CTA_Acid0.val + acidItem.val; |
||
2659 | end |
||
2660 | acidItem.val = 0; |
||
2661 | end |
||
2662 | |||
2663 | CTA_AcidEditDialog:Hide(); |
||
2664 | CTA_MyRaidInstantUpdate(); |
||
2665 | |||
2666 | end |
||
2667 | |||
2668 | |||
2669 | |||
2670 | |||
2671 | --[[ CTA_getn() |
||
2672 | --------------------------------------------------------------- |
||
2673 | Utility function that returns the length of a list. |
||
2674 | @arg the list |
||
2675 | @return the length of the list |
||
2676 | ]] |
||
2677 | |||
2678 | function CTA_getn( list ) |
||
2679 | local c = 0; |
||
2680 | for i, j in list do |
||
2681 | c = c + 1; |
||
2682 | end |
||
2683 | return c; |
||
2684 | end |
||
2685 | |||
2686 | |||
2687 | |||
2688 | |||
2689 | --[[ CTA_StartAParty() |
||
2690 | --------------------------------------------------------------- |
||
2691 | Starts a party group. |
||
2692 | Called by StartARaidFrame's StartAPartyButton |
||
2693 | ]] |
||
2694 | |||
2695 | function CTA_StartAParty() |
||
2696 | CTA_HostingRaidGroup = nil; |
||
2697 | CTA_MyRaid = {}; |
||
2698 | CTA_SetRaidInfo( CTA_MyRaid, UnitName( CTA_PLAYER ), 100, "", CTA_RAID_TYPE_PVE, GetNumPartyMembers()+1, 5, 1, 255, 0, CTA_GetTime(), 0 ); |
||
2699 | CTA_MyRaidIsOnline = 1; |
||
2700 | CTA_ShowStartRaidFrame(); |
||
2701 | end |
||
2702 | |||
2703 | |||
2704 | |||
2705 | |||
2706 | --[[ CTA_StartARaid |
||
2707 | --------------------------------------------------------------- |
||
2708 | Starts a raid group. |
||
2709 | Called by StartARaidFrame's StartARaidButton |
||
2710 | ]] |
||
2711 | |||
2712 | function CTA_StartARaid() |
||
2713 | CTA_HostingRaidGroup = 1; |
||
2714 | CTA_MyRaid = {}; |
||
2715 | CTA_SetRaidInfo( CTA_MyRaid, UnitName( CTA_PLAYER ), 100, "", CTA_RAID_TYPE_PVE, GetNumRaidMembers(), 10, 1, 255, 0, CTA_GetTime(), 0 ); |
||
2716 | CTA_MyRaidIsOnline = 1; |
||
2717 | CTA_ShowStartRaidFrame(); |
||
2718 | end |
||
2719 | |||
2720 | |||
2721 | |||
2722 | |||
2723 | --[[ CTA_StopHosting() |
||
2724 | --------------------------------------------------------------- |
||
2725 | Stops hosting a group with CTA. |
||
2726 | ]] |
||
2727 | |||
2728 | function CTA_StopHosting() |
||
2729 | CTA_HostingRaidGroup = nil; |
||
2730 | CTA_MyRaid = nil; |
||
2731 | CTA_MyRaidIsOnline = nil; |
||
2732 | CTA_PollBroadcast = 2; |
||
2733 | |||
2734 | CTA_SearchFrame:Hide(); |
||
2735 | CTA_MyRaidFrame:Hide(); |
||
2736 | CTA_SettingsFrame:Hide(); |
||
2737 | CTA_GreyListFrame:Hide(); |
||
2738 | CTA_LogFrame:Hide(); |
||
2739 | |||
2740 | CTA_ShowStartRaidFrame(); |
||
2741 | end |
||
2742 | |||
2743 | |||
2744 | |||
2745 | |||
2746 | --[[ CTA_ShowStartRaidFrame() |
||
2747 | --------------------------------------------------------------- |
||
2748 | Prompts the user to start hosting a group with CTA or |
||
2749 | tells the user that s/he cannot currently host a group or |
||
2750 | shows the group information frame if user is already using |
||
2751 | CTA to host a group. |
||
2752 | ]] |
||
2753 | |||
2754 | function CTA_ShowStartRaidFrame() |
||
2755 | CTA_StartRaidFrame:Show(); |
||
2756 | |||
2757 | if( CTA_MyRaid ) then |
||
2758 | CTA_StartRaidFrame:Hide(); |
||
2759 | |||
2760 | if( CTA_ToggleViewableButton:GetText() == CTA_GO_OFFLINE ) then |
||
2761 | CTA_MyRaidIsOnline = 1; |
||
2762 | end |
||
2763 | |||
2764 | CTA_MyRaidFrameDescriptionEditBox:SetText(""..CTA_MyRaid.comment); |
||
2765 | |||
2766 | local myRaidType = CTA_MyRaid.pvtype; |
||
2767 | if( myRaidType == CTA_RAID_TYPE_PVP ) then |
||
2768 | CTA_MyRaidFramePVPCheckButton:SetChecked(1) |
||
2769 | CTA_MyRaidFramePVECheckButton:SetChecked(0) |
||
2770 | else |
||
2771 | CTA_MyRaidFramePVPCheckButton:SetChecked(0) |
||
2772 | CTA_MyRaidFramePVECheckButton:SetChecked(1) |
||
2773 | end |
||
2774 | |||
2775 | CTA_MyRaidFrameMaxSizeEditBox:SetText(""..CTA_MyRaid.maxSize); |
||
2776 | CTA_MyRaidFrameMinLevelEditBox:SetText(""..CTA_MyRaid.minLevel); |
||
2777 | |||
2778 | if( CTA_MyRaidPassword ) then |
||
2779 | CTA_MyRaidFramePasswordEditBox:SetText(CTA_MyRaidPassword); |
||
2780 | else |
||
2781 | CTA_MyRaidFramePasswordEditBox:SetText(""); |
||
2782 | end |
||
2783 | |||
2784 | CTA_MyRaidInstantUpdate(); |
||
2785 | CTA_MyRaidFrame:Show(); |
||
2786 | end |
||
2787 | |||
2788 | CTA_StartARaidButton:Hide(); |
||
2789 | CTA_StartAPartyButton:Hide(); |
||
2790 | |||
2791 | if ( CTA_PlayerCanHostGroup() ) then |
||
2792 | CTA_StartRaidLabel:SetText( CTA_PLAYER_CAN_START_A_GROUP ); |
||
2793 | |||
2794 | if( not CTA_MyRaid and IsRaidLeader() and GetNumRaidMembers() > 0 ) then |
||
2795 | CTA_StartARaidButton:Show(); |
||
2796 | elseif( not CTA_MyRaid and IsPartyLeader() and GetNumRaidMembers() == 0 ) then |
||
2797 | CTA_StartAPartyButton:Show(); |
||
2798 | CTA_StartARaidButton:Show(); |
||
2799 | else |
||
2800 | CTA_StartAPartyButton:Show(); |
||
2801 | CTA_StartARaidButton:Show(); |
||
2802 | end |
||
2803 | else |
||
2804 | CTA_StartRaidLabel:SetText( CTA_PLAYER_IS_RAID_MEMBER_NOT_LEADER ); |
||
2805 | end |
||
2806 | end |
||
2807 | |||
2808 | |||
2809 | |||
2810 | |||
2811 | --[[ CTA_AcidItem_ShowTooltip() |
||
2812 | --------------------------------------------------------------- |
||
2813 | Shows tooltip for acid items. |
||
2814 | ]] |
||
2815 | |||
2816 | function CTA_AcidItem_ShowTooltip() |
||
2817 | GameTooltip:SetOwner( this, "ANCHOR_TOP" ); |
||
2818 | GameTooltip:ClearLines(); |
||
2819 | GameTooltip:ClearAllPoints(); |
||
2820 | GameTooltip:SetPoint("TOPLEFT", this:GetName(), "BOTTOMLEFT", 0, -8); |
||
2821 | |||
2822 | local acidItem = this; |
||
2823 | if( not acidItem.classes and acidItem:GetName() ~= "CTA_Acid0" ) then |
||
2824 | GameTooltip:AddLine( CTA_NO_CLASSES_TOOLTIP ); |
||
2825 | GameTooltip:AddLine( CTA_NO_CLASSES_TOOLTIP2, 1, 1, 1, 1, 1 ); |
||
2826 | return; |
||
2827 | end |
||
2828 | |||
2829 | local needed = acidItem.val - acidItem.cur; |
||
2830 | if( needed < 0 ) then needed = 0; end |
||
2831 | |||
2832 | if( this:GetName() == "CTA_Acid0" ) then |
||
2833 | GameTooltip:AddDoubleLine( CTA_MAXIMUM_PLAYERS_ALLOWED..":", ""..this.val ); |
||
2834 | GameTooltip:AddDoubleLine( CTA_PLAYERS_IN_RAID..":", ""..this.cur ); |
||
2835 | GameTooltip:AddDoubleLine( CTA_NUMBER_OF_PLAYERS_NEEDED..":", ""..needed ); |
||
2836 | GameTooltip:AddLine( CTA_ANY_CLASS_TOOLTIP, 1, 1, 1, 1, 1 ); |
||
2837 | else |
||
2838 | GameTooltip:AddDoubleLine( CTA_MINIMUM_PLAYERS_WANTED..":", ""..this.val ); |
||
2839 | GameTooltip:AddDoubleLine( CTA_PLAYERS_IN_RAID..":", ""..this.cur ); |
||
2840 | GameTooltip:AddDoubleLine( CTA_NUMBER_OF_PLAYERS_NEEDED..":", ""..needed ); |
||
2841 | GameTooltip:AddLine( CTA_CLASS_TOOLTIP, 1, 1, 1, 1, 1 ); |
||
2842 | end |
||
2843 | |||
2844 | GameTooltip:Show(); |
||
2845 | end |
||
2846 | |||
2847 | |||
2848 | |||
2849 | |||
2850 | --[[ CTA_GetGroupMemberInfo() |
||
2851 | --------------------------------------------------------------- |
||
2852 | Returns information about a group member. |
||
2853 | @arg the index of the group member |
||
2854 | @return the name, level, class of the player. |
||
2855 | ]] |
||
2856 | |||
2857 | function CTA_GetGroupMemberInfo( index ) |
||
2858 | local name, rank, subgroup, level, class, fileName, zone, online, isDead; |
||
2859 | if ( IsRaidLeader() and GetNumRaidMembers() > 0 ) then |
||
2860 | name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(index); |
||
2861 | elseif ( IsPartyLeader() and GetNumPartyMembers() > 0 ) then |
||
2862 | local target = CTA_PLAYER; |
||
2863 | if( index > 1 and index < 6 ) then |
||
2864 | target = "PARTY"..(index-1); |
||
2865 | end |
||
2866 | name = UnitName(target); |
||
2867 | level = UnitLevel(target); |
||
2868 | class = UnitClass(target); |
||
2869 | elseif( GetNumRaidMembers() == 0 and GetNumPartyMembers() == 0 and index == 1 ) then |
||
2870 | local target = CTA_PLAYER; |
||
2871 | name = UnitName(target); |
||
2872 | level = UnitLevel(target); |
||
2873 | class = UnitClass(target); |
||
2874 | end |
||
2875 | return name, level, class; |
||
2876 | end |
||
2877 | |||
2878 | |||
2879 | |||
2880 | |||
2881 | --[[ CTA_GetNumGroupMembers() |
||
2882 | --------------------------------------------------------------- |
||
2883 | Returns information about a group member. |
||
2884 | @arg the index of the group member |
||
2885 | @return the name, level, class of the player. |
||
2886 | ]] |
||
2887 | |||
2888 | function CTA_GetNumGroupMembers() |
||
2889 | --[[ |
||
2890 | if( IsRaidLeader() ) then |
||
2891 | return GetNumRaidMembers(); |
||
2892 | elseif( IsPartyLeader() ) then |
||
2893 | return GetNumPartyMembers() + 1; |
||
2894 | else |
||
2895 | return 1; |
||
2896 | end |
||
2897 | ]] |
||
2898 | if( GetNumRaidMembers() > 0 ) then |
||
2899 | return GetNumRaidMembers(); |
||
2900 | elseif( GetNumPartyMembers() > 0 ) then |
||
2901 | return GetNumPartyMembers() + 1; |
||
2902 | else |
||
2903 | return 1; |
||
2904 | end |
||
2905 | |||
2906 | end |
||
2907 | |||
2908 | |||
2909 | |||
2910 | |||
2911 | --[[ CTA_DissolveRaid() |
||
2912 | --------------------------------------------------------------- |
||
2913 | Dissolves the group by removing each member. |
||
2914 | ]] |
||
2915 | |||
2916 | function CTA_DissolveRaid() |
||
2917 | CTA_IconMsg( CTA_DISSOLVING_RAID, CTA_GROUP_UPDATE ); |
||
2918 | num = 1; |
||
2919 | local numRaidMembers = GetNumRaidMembers(); |
||
2920 | local name, rank, subgroup, level, class, fileName, zone, online, isDead; |
||
2921 | local over = 0; |
||
2922 | while ( num <= numRaidMembers ) do |
||
2923 | name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(num); |
||
2924 | if( name ~= UnitName(CTA_PLAYER) ) then |
||
2925 | UninviteByName( name ); |
||
2926 | CTA_SendAutoMsg( CTA_DISSOLVING_THE_RAID_CHAT_MESSAGE, name); |
||
2927 | end |
||
2928 | num = num+1; |
||
2929 | end |
||
2930 | CTA_IconMsg( CTA_RAID_DISSOLVED, CTA_GROUP_UPDATE ); |
||
2931 | end |
||
2932 | |||
2933 | |||
2934 | |||
2935 | |||
2936 | --[[ CTA_ConvertToParty() |
||
2937 | --------------------------------------------------------------- |
||
2938 | convert your raid to a party. |
||
2939 | ]] |
||
2940 | |||
2941 | function CTA_ConvertToParty() --R2 (suggested by Sadris) |
||
2942 | CTA_IconMsg( CTA_CONVERTING_TO_PARTY, CTA_GROUP_UPDATE ); |
||
2943 | num = 1; |
||
2944 | local numRaidMembers = GetNumRaidMembers(); |
||
2945 | if( numRaidMembers > 5 ) then |
||
2946 | CTA_Println( CTA_CANNOT_CONVERT_TO_PARTY ); |
||
2947 | return; |
||
2948 | end |
||
2949 | local memberList = {}; |
||
2950 | local name, rank, subgroup, level, class, fileName, zone, online, isDead; |
||
2951 | local over = 0; |
||
2952 | while ( num <= numRaidMembers ) do |
||
2953 | name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(num); |
||
2954 | if( name ~= UnitName(CTA_PLAYER) ) then |
||
2955 | memberList[num] = name; |
||
2956 | UninviteByName( name ); |
||
2957 | CTA_MyRaidInstantUpdate(); |
||
2958 | |||
2959 | CTA_SendAutoMsg( CTA_CONVERTING_TO_PARTY_MESSAGE, name); |
||
2960 | end |
||
2961 | num = num+1; |
||
2962 | end |
||
2963 | for i = 1, numRaidMembers - 1 do |
||
2964 | InviteByName( memberList[i] ); |
||
2965 | end |
||
2966 | CTA_IconMsg( CTA_CONVERTING_TO_PARTY_DONE, CTA_GROUP_UPDATE ); |
||
2967 | CTA_HostingRaidGroup = nil; |
||
2968 | end |
||
2969 | |||
2970 | |||
2971 | |||
2972 | |||
2973 | --[[ CTA_GetGroupType() |
||
2974 | --------------------------------------------------------------- |
||
2975 | Returns a String representation of the type of group |
||
2976 | currently being hosted. |
||
2977 | @return CTA_GROUP or CTA_PARTY |
||
2978 | ]] |
||
2979 | |||
2980 | function CTA_GetGroupType() |
||
2981 | if ( CTA_HostingRaidGroup ) then |
||
2982 | return CTA_RAID; |
||
2983 | end |
||
2984 | return CTA_PARTY; |
||
2985 | end |
||
2986 | |||
2987 | |||
2988 | |||
2989 | |||
2990 | |||
2991 | --[[ CTA_ConvertToParty() |
||
2992 | --------------------------------------------------------------- |
||
2993 | Converts the raid to a party |
||
2994 | ]] |
||
2995 | |||
2996 | function CTA_ConvertToRaid() |
||
2997 | if( IsPartyLeader() ) then |
||
2998 | CTA_HostingRaidGroup = 1; |
||
2999 | ConvertToRaid(); |
||
3000 | end |
||
3001 | end |
||
3002 | |||
3003 | |||
3004 | |||
3005 | |||
3006 | --[[ CTA_PlayerCanHostGroup() |
||
3007 | --------------------------------------------------------------- |
||
3008 | Indicates whether a player can start hosting a group according |
||
3009 | to CTA logic. |
||
3010 | returns 1 if can host, nil if not |
||
3011 | ]] |
||
3012 | |||
3013 | function CTA_PlayerCanHostGroup() |
||
3014 | if ( ( IsRaidLeader() and GetNumRaidMembers() > 0 ) or |
||
3015 | ( IsPartyLeader() and GetNumRaidMembers() == 0 ) or |
||
3016 | ( GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 ) ) then |
||
3017 | return 1; |
||
3018 | else |
||
3019 | return nil; |
||
3020 | end |
||
3021 | end |
||
3022 | |||
3023 | |||
3024 | --[[ CTA_SetRaidInfo() |
||
3025 | --------------------------------------------------------------- |
||
3026 | Set group information for the specified group. |
||
3027 | ]] |
||
3028 | |||
3029 | function CTA_SetRaidInfo( raid, name, score, comment, groupType, size, maxSize, minLevel, classes, passwordProtected, creationTime, options ) |
||
3030 | raid.leader = name; |
||
3031 | raid.score = tonumber(score); |
||
3032 | raid.comment = comment; |
||
3033 | raid.pvtype = tonumber(groupType); |
||
3034 | raid.size = tonumber(size); |
||
3035 | raid.maxSize = tonumber(maxSize); |
||
3036 | raid.minLevel = tonumber(minLevel); |
||
3037 | raid.classes = tonumber(classes); |
||
3038 | raid.passwordProtected = tonumber(passwordProtected); |
||
3039 | raid.creationTime = creationTime; |
||
3040 | raid.options = options; |
||
3041 | end |
||
3042 | |||
3043 | |||
3044 | |||
3045 | |||
3046 | |||
3047 | |||
3048 | |||
3049 | |||
3050 | |||
3051 | |||
3052 | |||
3053 | |||
3054 | |||
3055 | |||
3056 | |||
3057 | |||
3058 | |||
3059 | |||
3060 | |||
3061 | |||
3062 | |||
3063 | |||
3064 | |||
3065 | |||
3066 | |||
3067 | |||
3068 | |||
3069 | |||
3070 | |||
3071 | |||
3072 | |||
3073 | |||
3074 | |||
3075 | |||
3076 | |||
3077 | |||
3078 | |||
3079 | |||
3080 | |||
3081 | |||
3082 | |||
3083 | |||
3084 | |||
3085 | |||
3086 | |||
3087 | |||
3088 | |||
3089 | |||
3090 | |||
3091 | |||
3092 | |||
3093 | |||
3094 | |||
3095 | |||
3096 | --[[ --------------------------------------------------------------- |
||
3097 | Functions Related To The Blacklist |
||
3098 | --------------------------------------------------------------- |
||
3099 | ]] |
||
3100 | |||
3101 | |||
3102 | |||
3103 | |||
3104 | --[[ CTA_UpdateGreyListItems() UPDATE FUNCTION |
||
3105 | --------------------------------------------------------------- |
||
3106 | Updates the list of blacklisted players. |
||
3107 | ]] |
||
3108 | |||
3109 | function CTA_UpdateGreyListItems() |
||
3110 | CTA_GreyListItem0NameLabel:SetText( CTA_NAME ); |
||
3111 | CTA_GreyListItem0NoteLabel:SetText( CTA_PLAYER_NOTE ); |
||
3112 | CTA_GreyListItem0StatusLabel:SetText( "" ); |
||
3113 | CTA_GreyListItem0:Show(); |
||
3114 | |||
3115 | local gls = getn(CTA_BlackList); |
||
3116 | if( not gls ) then |
||
3117 | gls = 0; |
||
3118 | end |
||
3119 | CTA_GreyListFramePageLabel:Show(); |
||
3120 | local cpage = floor( CTA_PlayerListOffset / CTA_MAX_BLACKLIST_ITEMS ); |
||
3121 | local tpage = floor( gls / CTA_MAX_BLACKLIST_ITEMS ); |
||
3122 | if( cpage == 0 or cpage <= CTA_PlayerListOffset / CTA_MAX_BLACKLIST_ITEMS ) then cpage = cpage + 1; end |
||
3123 | if( tpage == 0 or tpage < gls / CTA_MAX_BLACKLIST_ITEMS ) then tpage = tpage + 1; end |
||
3124 | CTA_GreyListFramePageLabel:SetText( CTA_PAGE.." "..cpage.." / "..tpage ); |
||
3125 | |||
3126 | |||
3127 | for index = 1, CTA_MAX_BLACKLIST_ITEMS do |
||
3128 | local item = getglobal( "CTA_GreyListItem"..index ); |
||
3129 | if( index + CTA_PlayerListOffset <= gls ) then |
||
3130 | local data = CTA_BlackList[ index + CTA_PlayerListOffset ]; |
||
3131 | getglobal( "CTA_GreyListItem"..index.."NameLabel" ):SetText( data.name ); |
||
3132 | local i = CTA_FindInList( data.name, CTA_SavedVariables.GreyList ); |
||
3133 | if( i ) then |
||
3134 | getglobal( "CTA_GreyListItem"..index.."NoteLabel" ):SetTextColor( 1, 1, 1 ); |
||
3135 | else |
||
3136 | getglobal( "CTA_GreyListItem"..index.."NoteLabel" ):SetTextColor( 1, 0, 0 ); |
||
3137 | end |
||
3138 | getglobal( "CTA_GreyListItem"..index.."NoteLabel" ):SetText( data.note ); |
||
3139 | getglobal( "CTA_GreyListItem"..index.."RatingLabel" ):SetText( data.rating ); |
||
3140 | getglobal( "CTA_GreyListItem"..index ):Show(); |
||
3141 | else |
||
3142 | item:Hide(); |
||
3143 | end |
||
3144 | end |
||
3145 | end |
||
3146 | |||
3147 | |||
3148 | |||
3149 | |||
3150 | --[[ CTA_ShowGreyListFrame() |
||
3151 | --------------------------------------------------------------- |
||
3152 | Show the Greylist frame |
||
3153 | ]] |
||
3154 | |||
3155 | function CTA_ShowGreyListFrame() |
||
3156 | --CTA_SearchFrame:Hide(); |
||
3157 | --CTA_MyRaidFrame:Hide(); |
||
3158 | --CTA_StartRaidFrame:Hide(); |
||
3159 | CTA_SettingsFrame:Hide(); |
||
3160 | CTA_LogFrame:Hide(); |
||
3161 | CTA_GreyListFrame:Show(); |
||
3162 | CTA_UpdateGreyListItems(); |
||
3163 | end |
||
3164 | |||
3165 | |||
3166 | |||
3167 | |||
3168 | --[[ CTA_EditGreyListItem() |
||
3169 | --------------------------------------------------------------- |
||
3170 | Shows the Edit frame for the selected Greylist item |
||
3171 | ]] |
||
3172 | |||
3173 | function CTA_EditGreyListItem() |
||
3174 | local listItem = getglobal( this:GetName() ); |
||
3175 | CTA_GreyListItemEditFrame.name = ( getglobal( listItem:GetName().."NameLabel" ):GetText() or "?" ); |
||
3176 | if( not CTA_FindInList( CTA_GreyListItemEditFrame.name, CTA_SavedVariables.GreyList ) ) then |
||
3177 | CTA_AddPlayer( CTA_GreyListItemEditFrame.name, CTA_DEFAULT_PLAYER_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_SavedVariables.GreyList ); |
||
3178 | end |
||
3179 | CTA_GreyListItemEditFrameEditBox:SetText( CTA_SavedVariables.GreyList[ CTA_FindInList( CTA_GreyListItemEditFrame.name, CTA_SavedVariables.GreyList ) ].note ); |
||
3180 | CTA_GreyListItemEditFrameTitleLabel:SetText( CTA_EDIT_PLAYER..": "..CTA_GreyListItemEditFrame.name ); |
||
3181 | CTA_GreyListItemEditFrame:Show(); |
||
3182 | end |
||
3183 | |||
3184 | |||
3185 | |||
3186 | |||
3187 | --[[ CTA_GreyListItemSaveChanges() |
||
3188 | --------------------------------------------------------------- |
||
3189 | Commits changes made to the selected Greylist item |
||
3190 | ]] |
||
3191 | |||
3192 | function CTA_GreyListItemSaveChanges() |
||
3193 | CTA_SavedVariables.GreyList[CTA_FindInList( CTA_GreyListItemEditFrame.name, CTA_SavedVariables.GreyList )].note = CTA_GreyListItemEditFrameEditBox:GetText(); |
||
3194 | CTA_BlackList[CTA_FindInList( CTA_GreyListItemEditFrame.name, CTA_BlackList )].note = CTA_GreyListItemEditFrameEditBox:GetText(); |
||
3195 | |||
3196 | CTA_GreyListItemEditFrame:Hide(); |
||
3197 | CTA_ShowGreyListFrame(); |
||
3198 | end |
||
3199 | |||
3200 | |||
3201 | |||
3202 | |||
3203 | --[[ CTA_DeletePlayer() |
||
3204 | --------------------------------------------------------------- |
||
3205 | Removes the player from the Greylist |
||
3206 | ]] |
||
3207 | |||
3208 | function CTA_DeletePlayer() |
||
3209 | table.remove( CTA_BlackList , CTA_FindInList( CTA_GreyListItemEditFrame.name, CTA_BlackList ) ); |
||
3210 | table.remove( CTA_SavedVariables.GreyList , CTA_FindInList( CTA_GreyListItemEditFrame.name, CTA_SavedVariables.GreyList ) ); |
||
3211 | CTA_GreyListItemEditFrame:Hide(); |
||
3212 | CTA_ShowGreyListFrame(); |
||
3213 | end |
||
3214 | |||
3215 | |||
3216 | |||
3217 | |||
3218 | --[[ |
||
3219 | function CTA_ImportFriendsToGreyList() |
||
3220 | numFriends = GetNumFriends(); |
||
3221 | for i=1,numFriends do |
||
3222 | local name, level, class, area, connected = GetFriendInfo(i); |
||
3223 | if( not CTA_SavedVariables.GreyList[name] ) then |
||
3224 | CTA_AddPlayer( name, CTA_DEFAULT_PLAYER_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_SavedVariables.GreyList ); |
||
3225 | end |
||
3226 | end |
||
3227 | end |
||
3228 | ]] |
||
3229 | |||
3230 | |||
3231 | |||
3232 | |||
3233 | --[[ CTA_ImportIgnoreListToGreyList() |
||
3234 | --------------------------------------------------------------- |
||
3235 | Adds players from the ignore list to the Greylist |
||
3236 | ]] |
||
3237 | |||
3238 | function CTA_ImportIgnoreListToGreyList() |
||
3239 | local numIgnores = GetNumIgnores(); |
||
3240 | for i = 1, numIgnores do |
||
3241 | local name = GetIgnoreName(i); |
||
3242 | CTA_AddPlayer( name, CTA_DEFAULT_IMPORTED_IGNORED_PLAYER_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_SavedVariables.GreyList ); |
||
3243 | CTA_AddPlayer( name, CTA_DEFAULT_IMPORTED_IGNORED_PLAYER_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_BlackList ); |
||
3244 | end |
||
3245 | end |
||
3246 | |||
3247 | |||
3248 | |||
3249 | |||
3250 | |||
3251 | --[[ CTA_AddGreyToBlack() |
||
3252 | --------------------------------------------------------------- |
||
3253 | Updates the Blacklist by adding Greylist entries to it. |
||
3254 | ]] |
||
3255 | |||
3256 | function CTA_AddGreyToBlack() |
||
3257 | for i = 1, getn(CTA_SavedVariables.GreyList) do |
||
3258 | CTA_AddToList( CTA_SavedVariables.GreyList[i], CTA_BlackList ); |
||
3259 | end |
||
3260 | end |
||
3261 | |||
3262 | |||
3263 | |||
3264 | |||
3265 | |||
3266 | --[[ CTA_AddPlayer() |
||
3267 | --------------------------------------------------------------- |
||
3268 | Adds a new player to the Greylist. |
||
3269 | @arg the name of the player |
||
3270 | @arg the note to be added |
||
3271 | @arg the status of the player |
||
3272 | @arg the rating of the player |
||
3273 | @arg the list in which to enter the data |
||
3274 | ]] |
||
3275 | |||
3276 | function CTA_AddPlayer( name, note, status, rating, list ) |
||
3277 | local data = { name=name, note=note, status=status, rating=rating }; |
||
3278 | CTA_AddToList( data, list ); |
||
3279 | CTA_UpdateGreyListItems(); |
||
3280 | end |
||
3281 | |||
3282 | |||
3283 | --[[ CTA_AddToList() |
||
3284 | --------------------------------------------------------------- |
||
3285 | Add data to list only if the name is not already in the List |
||
3286 | @arg the data to be added |
||
3287 | @arg the list in which to enter the data |
||
3288 | ]] |
||
3289 | |||
3290 | function CTA_AddToList( data, list ) |
||
3291 | if( not CTA_FindInList( data.name, list ) ) then |
||
3292 | table.insert( list, data ); |
||
3293 | end |
||
3294 | end |
||
3295 | |||
3296 | |||
3297 | |||
3298 | |||
3299 | --[[ CTA_FindInList() |
||
3300 | --------------------------------------------------------------- |
||
3301 | Returns the index of the data which has a name field that |
||
3302 | matches the name provided |
||
3303 | @arg the name to search for |
||
3304 | @arg the list in which to search for the data |
||
3305 | @return index if found, nil if not found |
||
3306 | ]] |
||
3307 | |||
3308 | function CTA_FindInList( name, list ) |
||
3309 | for i = 1, getn(list) do |
||
3310 | if( list[i].name == name ) then |
||
3311 | return i; |
||
3312 | end |
||
3313 | end |
||
3314 | return nil; |
||
3315 | end |
||
3316 | |||
3317 | |||
3318 | |||
3319 | |||
3320 | |||
3321 | |||
3322 | |||
3323 | |||
3324 | |||
3325 | |||
3326 | |||
3327 | |||
3328 | |||
3329 | |||
3330 | |||
3331 | |||
3332 | |||
3333 | |||
3334 | |||
3335 | |||
3336 | |||
3337 | |||
3338 | |||
3339 | |||
3340 | |||
3341 | |||
3342 | |||
3343 | |||
3344 | |||
3345 | |||
3346 | |||
3347 | |||
3348 | |||
3349 | |||
3350 | |||
3351 | |||
3352 | |||
3353 | |||
3354 | |||
3355 | |||
3356 | |||
3357 | |||
3358 | |||
3359 | |||
3360 | |||
3361 | |||
3362 | |||
3363 | |||
3364 | |||
3365 | |||
3366 | |||
3367 | |||
3368 | |||
3369 | |||
3370 | |||
3371 | |||
3372 | |||
3373 | --[[ --------------------------------------------------------------- |
||
3374 | Generic Functions Driven Directly By User Interface Events |
||
3375 | --------------------------------------------------------------- |
||
3376 | ]] |
||
3377 | |||
3378 | |||
3379 | |||
3380 | |||
3381 | --[[ CTA_ToggleMainFrame() |
||
3382 | --------------------------------------------------------------- |
||
3383 | Show/hide the Main Frame. If the search frame is visible |
||
3384 | and the main frame is opened the results list is automatically |
||
3385 | refreshed. |
||
3386 | Called by the minimap icon and the main frame's close button. |
||
3387 | ]] |
||
3388 | |||
3389 | function CTA_ToggleMainFrame() |
||
3390 | PlaySound("igCharacterInfoTab"); |
||
3391 | if( CTA_MainFrame:IsVisible() ) then |
||
3392 | CTA_MainFrame:Hide(); |
||
3393 | else |
||
3394 | CTA_MainFrame:Show(); |
||
3395 | --[[if( CTA_SearchFrame:IsVisible() ) then |
||
3396 | CTA_ApplyFiltersToGroupList(); |
||
3397 | end ]] |
||
3398 | end |
||
3399 | end |
||
3400 | |||
3401 | |||
3402 | |||
3403 | |||
3404 | --[[ CTA_Tab_OnCLick() |
||
3405 | --------------------------------------------------------------- |
||
3406 | Switches visibility of the frames in the main frame. |
||
3407 | Called by all tab buttons under the main frame. |
||
3408 | ]] |
||
3409 | |||
3410 | function CTA_Tab_OnCLick() |
||
3411 | PlaySound("igCharacterInfoTab"); |
||
3412 | CTA_SearchFrame:Hide(); |
||
3413 | CTA_StartRaidFrame:Hide(); |
||
3414 | CTA_MyRaidFrame:Hide(); |
||
3415 | --CTA_SettingsFrame:Hide(); |
||
3416 | --CTA_GreyListFrame:Hide(); |
||
3417 | --CTA_LogFrame:Hide(); |
||
3418 | CTA_MoreFeaturesFrame:Hide(); |
||
3419 | CTA_CannotLFGFrame:Hide(); |
||
3420 | |||
3421 | CTA_LFGFrame:Hide(); -- r7 |
||
3422 | |||
3423 | |||
3424 | CTA_ShowSearchButton:SetFrameLevel(CTA_MainFrame:GetFrameLevel() - 1); |
||
3425 | CTA_ShowMyRaidButton:SetFrameLevel(CTA_MainFrame:GetFrameLevel() - 1); |
||
3426 | --CTA_ShowPlayerListButton:SetFrameLevel(CTA_MainFrame:GetFrameLevel() - 1); |
||
3427 | --CTA_ShowSettingsButton:SetFrameLevel(CTA_MainFrame:GetFrameLevel() - 1); |
||
3428 | --CTA_ShowLogButton:SetFrameLevel(CTA_MainFrame:GetFrameLevel() - 1); |
||
3429 | |||
3430 | CTA_ShowLFGButton:SetFrameLevel(CTA_MainFrame:GetFrameLevel() - 1); -- r7 |
||
3431 | CTA_ShowMFFButton:SetFrameLevel(CTA_MainFrame:GetFrameLevel() - 1); |
||
3432 | |||
3433 | this:SetFrameLevel(CTA_MainFrame:GetFrameLevel() + 1); |
||
3434 | |||
3435 | if( this:GetName() == "CTA_ShowSearchButton" ) then |
||
3436 | CTA_SearchFrame:Show(); |
||
3437 | --[[CTA_ApplyFiltersToGroupList();]] |
||
3438 | elseif( this:GetName() == "CTA_ShowMyRaidButton" ) then |
||
3439 | CTA_ShowStartRaidFrame(); |
||
3440 | elseif( this:GetName() == "CTA_ShowPlayerListButton" ) then |
||
3441 | CTA_ShowGreyListFrame(); |
||
3442 | elseif( this:GetName() == "CTA_ShowSettingsButton" ) then |
||
3443 | CTA_SettingsFrame:Show(); |
||
3444 | elseif( this:GetName() == "CTA_ShowLogButton" ) then |
||
3445 | CTA_LogFrame:Show(); |
||
3446 | elseif( this:GetName() == "CTA_ShowLFGButton" ) then |
||
3447 | CTA_ShowLFGFrame(); |
||
3448 | elseif( this:GetName() == "CTA_ShowMFFButton" ) then |
||
3449 | CTA_MoreFeaturesFrame:Show(); |
||
3450 | end |
||
3451 | end |
||
3452 | |||
3453 | |||
3454 | |||
3455 | |||
3456 | --[[ CTA_DialogOKButton_OnCLick() |
||
3457 | --------------------------------------------------------------- |
||
3458 | Handles all 'Ok button' events generated by dialogs. |
||
3459 | ]] |
||
3460 | |||
3461 | function CTA_DialogOKButton_OnCLick() |
||
3462 | local item = this:GetParent(); |
||
3463 | if( item:GetName() == "CTA_AddPlayerFrame" ) then |
||
3464 | local name = CTA_AddPlayerFrameEditBox:GetText(); |
||
3465 | if( name and name ~= "" ) then |
||
3466 | CTA_AddPlayer( name, CTA_DEFAULT_PLAYER_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_SavedVariables.GreyList ); |
||
3467 | CTA_AddPlayer( name, CTA_DEFAULT_PLAYER_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_BlackList ); |
||
3468 | end |
||
3469 | CTA_AddPlayerFrame:Hide(); |
||
3470 | end |
||
3471 | |||
3472 | if( item:GetName() == "CTA_JoinRaidWindow" ) then |
||
3473 | CTA_SendPasswordRaidInvitationRequest(); |
||
3474 | end |
||
3475 | |||
3476 | if( item:GetName() == "CTA_AcidEditDialog" ) then |
||
3477 | CTA_EditAcidItem(); |
||
3478 | end |
||
3479 | |||
3480 | end |
||
3481 | |||
3482 | |||
3483 | |||
3484 | |||
3485 | --[[ CTA_UpdateMinimapIcon() |
||
3486 | --------------------------------------------------------------- |
||
3487 | Adjusts the minimap icon position. |
||
3488 | ]] |
||
3489 | |||
3490 | function CTA_UpdateMinimapIcon() |
||
3491 | CTA_MinimapIcon:SetPoint( "TOPLEFT", "Minimap", "TOPLEFT", |
||
3492 | 55 - ( ( CTA_SavedVariables.MinimapRadiusOffset ) * cos( CTA_SavedVariables.MinimapArcOffset ) ), |
||
3493 | ( ( CTA_SavedVariables.MinimapRadiusOffset ) * sin( CTA_SavedVariables.MinimapArcOffset ) ) - 55 |
||
3494 | ); |
||
3495 | CTA_MinimapMessageFrame:SetPoint( "TOPRIGHT", "Minimap", "TOPRIGHT", |
||
3496 | ( 0 - ( ( CTA_SavedVariables.MinimapMsgRadiusOffset ) * cos( CTA_SavedVariables.MinimapMsgArcOffset ) ) ) - 55, |
||
3497 | ( ( CTA_SavedVariables.MinimapMsgRadiusOffset ) * sin (CTA_SavedVariables.MinimapMsgArcOffset ) ) - 55 |
||
3498 | ); |
||
3499 | |||
3500 | end |
||
3501 | |||
3502 | |||
3503 | |||
3504 | |||
3505 | --[[ --------------------------------------------------------------- |
||
3506 | Utility Functions |
||
3507 | --------------------------------------------------------------- |
||
3508 | ]] |
||
3509 | |||
3510 | |||
3511 | -- Other Functions -- |
||
3512 | |||
3513 | -- Searches a specified String (source) for a keyword String (search) |
||
3514 | -- String patterns are not allowed - simple search keywords are used |
||
3515 | -- Returns a number representing the degree to which the search string |
||
3516 | -- was found in the specified string using my own scoring system. |
||
3517 | -- Number ( 0 - 100 ) |
||
3518 | -- |
||
3519 | function CTA_SearchScore( source, search, show ) |
||
3520 | local ad = string.lower( source ); |
||
3521 | local query = string.lower( search ); |
||
3522 | |||
3523 | if( string.find( ad, query ) ) then |
||
3524 | return 100, "|cff33ff33"..source.."|r"; |
||
3525 | else |
||
3526 | local sourceWords = {}; |
||
3527 | for word in string.gfind( ad, "%w+" ) do |
||
3528 | sourceWords[word] = word; |
||
3529 | end |
||
3530 | |||
3531 | local highlighted = source; |
||
3532 | |||
3533 | local score = 0; |
||
3534 | local total = 0; |
||
3535 | for word in string.gfind(query, "%w+") do |
||
3536 | total = total + 1; |
||
3537 | if( sourceWords[word] ) then |
||
3538 | score = score + 1; |
||
3539 | |||
3540 | if( show ) then |
||
3541 | local s, e = string.find( string.lower( highlighted ), word ); |
||
3542 | highlighted = string.sub( highlighted, 1, s-1 ).."|cff99ff33"..string.sub( highlighted, s, e ).."|r"..string.sub( highlighted, e+1 ); |
||
3543 | end |
||
3544 | elseif( string.find( ad, word ) ) then |
||
3545 | score = score + 0.9; |
||
3546 | |||
3547 | if( show ) then |
||
3548 | local s, e = string.find( string.lower( highlighted ), word ); |
||
3549 | highlighted = string.sub( highlighted, 1, s-1 ).."|cffccff33"..string.sub( highlighted, s, e ).."|r"..string.sub( highlighted, e+1 ); |
||
3550 | end |
||
3551 | end |
||
3552 | end |
||
3553 | |||
3554 | if( score > 0 ) then |
||
3555 | score = floor(99*score/total); |
||
3556 | end |
||
3557 | |||
3558 | return score, highlighted; |
||
3559 | end |
||
3560 | end |
||
3561 | |||
3562 | |||
3563 | -- Returns a String representation of the current time |
||
3564 | -- String ( eg. "14:40" ) |
||
3565 | function CTA_GetTime() |
||
3566 | local hour, minute = GetGameTime(); |
||
3567 | local t = hour; |
||
3568 | if( hour < 10 ) then t = "0"..t; end |
||
3569 | t = t..":"; |
||
3570 | if( minute < 10 ) then t = t.."0"; end |
||
3571 | t = t..minute; |
||
3572 | return t; |
||
3573 | end |
||
3574 | |||
3575 | |||
3576 | -- Returns a String from the specified textfield (uiVal) |
||
3577 | -- If the String is Nil, then (defaultVal) is returned |
||
3578 | -- String / defaultVal |
||
3579 | -- |
||
3580 | function CTA_SafeSet( uiVal, defaultVal ) |
||
3581 | if( not uiVal or uiVal=="" ) then |
||
3582 | return defaultVal; |
||
3583 | else |
||
3584 | return uiVal; |
||
3585 | end |
||
3586 | end |
||
3587 | |||
3588 | |||
3589 | -- Returns the number entered into the textfield (uiValue), |
||
3590 | -- if the number is valid, is no less than (min) and is no more then (max) |
||
3591 | -- Number / Nil |
||
3592 | -- |
||
3593 | function CTA_SafeSetNumber( uiValue, min, max ) |
||
3594 | for value in string.gfind( uiValue, "(%d+)" ) do |
||
3595 | if( value and value ~= "" and tonumber(value) >=min and tonumber(value) <= max ) then |
||
3596 | return tonumber(value); |
||
3597 | end |
||
3598 | end |
||
3599 | return nil; |
||
3600 | end |
||
3601 | |||
3602 | |||
3603 | -- Shows an error dialog with a title, text and close button |
||
3604 | -- |
||
3605 | function CTA_ShowError( title, text ) |
||
3606 | CTA_InformationDialogHeadingLabel:SetText( title ); |
||
3607 | CTA_InformationDialogContentLabel:SetText( text ); |
||
3608 | CTA_InformationDialog:Show(); |
||
3609 | end |
||
3610 | |||
3611 | |||
3612 | -- Returns the class code for this player. |
||
3613 | -- Number ( 1 - 8 ) |
||
3614 | -- |
||
3615 | function CTA_MyClassCode() |
||
3616 | local myClass = UnitClass(CTA_PLAYER); |
||
3617 | return CTA_GetClassCode(myClass); |
||
3618 | end |
||
3619 | |||
3620 | |||
3621 | -- Returns a String representaion of a class code |
||
3622 | -- String ( eg. "Priest" ) |
||
3623 | -- |
||
3624 | function CTA_GetClassCode( name ) |
||
3625 | local classes = { }; |
||
3626 | classes[CTA_PRIEST] = 1; |
||
3627 | classes[CTA_MAGE] = 2; |
||
3628 | classes[CTA_WARLOCK] = 3; |
||
3629 | classes[CTA_DRUID] = 4; |
||
3630 | classes[CTA_HUNTER] = 5; |
||
3631 | classes[CTA_ROGUE] = 6; |
||
3632 | classes[CTA_WARRIOR] = 7; |
||
3633 | classes[CTA_PALADIN] = 8; |
||
3634 | classes[CTA_SHAMAN] = 8; |
||
3635 | |||
3636 | return classes[name]; |
||
3637 | end |
||
3638 | |||
3639 | |||
3640 | -- Returns whether the class code (value) is in a class set (classSet) |
||
3641 | -- Number ( 1 / 0 ) |
||
3642 | -- |
||
3643 | function CTA_CheckClasses( classSet, value ) |
||
3644 | local b = ""; |
||
3645 | local c = classSet; |
||
3646 | |||
3647 | while( c > 0 ) do |
||
3648 | local d = mod(c, 2); |
||
3649 | b = d..b; |
||
3650 | c = floor(c/2); |
||
3651 | end |
||
3652 | while(string.len(b) < 8 ) do |
||
3653 | b = "0"..b; |
||
3654 | end |
||
3655 | |||
3656 | return tonumber( string.sub(b, 9-value, 9-value ) ); |
||
3657 | end |
||
3658 | |||
3659 | |||
3660 | -- Returns a String with all the class names represented by the class set |
||
3661 | -- String ( eg. "Priest Druid Warlock" ) |
||
3662 | -- |
||
3663 | function CTA_GetClassString( classSet ) |
||
3664 | local b = ""; |
||
3665 | local c = classSet; |
||
3666 | |||
3667 | local classes = { }; |
||
3668 | classes[1] = CTA_PRIEST; |
||
3669 | classes[2] = CTA_MAGE; |
||
3670 | classes[3] = CTA_WARLOCK; |
||
3671 | classes[4] = CTA_DRUID; |
||
3672 | classes[5] = CTA_HUNTER; |
||
3673 | classes[6] = CTA_ROGUE; |
||
3674 | classes[7] = CTA_WARRIOR; |
||
3675 | if( UnitFactionGroup(CTA_PLAYER) == CTA_ALLIANCE ) then |
||
3676 | classes[8] = CTA_PALADIN; |
||
3677 | else |
||
3678 | classes[8] = CTA_SHAMAN; |
||
3679 | end |
||
3680 | |||
3681 | while( c > 0 ) do |
||
3682 | local d = mod(c, 2); |
||
3683 | b = d..b; |
||
3684 | c = floor(c/2); |
||
3685 | end |
||
3686 | while(string.len(b) < 8 ) do |
||
3687 | b = "0"..b; |
||
3688 | end |
||
3689 | |||
3690 | local pos = 8; |
||
3691 | local t = ""; |
||
3692 | while( pos > 0 ) do |
||
3693 | if( string.sub(b, pos, pos) == "1" ) then |
||
3694 | t = t..classes[9-pos].." "; |
||
3695 | end |
||
3696 | pos = pos - 1; |
||
3697 | end |
||
3698 | return t; |
||
3699 | end |
||
3700 | |||
3701 | |||
3702 | -- Generic Tooltip Function |
||
3703 | -- |
||
3704 | function CTA_ShowTooltip() |
||
3705 | if( CTA_GenTooltips[this:GetName()] ) then |
||
3706 | GameTooltip:SetOwner( getglobal(this:GetName()), "ANCHOR_TOP" ); |
||
3707 | GameTooltip:ClearLines(); |
||
3708 | GameTooltip:ClearAllPoints(); |
||
3709 | GameTooltip:SetPoint("TOPLEFT", this:GetName(), "BOTTOMLEFT", 0, -2); |
||
3710 | GameTooltip:AddLine( CTA_GenTooltips[this:GetName()].tooltip1 ); |
||
3711 | GameTooltip:AddLine( CTA_GenTooltips[this:GetName()].tooltip2, 1, 1, 1, 1, 1 ); |
||
3712 | GameTooltip:Show(); |
||
3713 | end |
||
3714 | end |
||
3715 | |||
3716 | |||
3717 | |||
3718 | |||
3719 | --[[ --------------------------------------------------------------- |
||
3720 | DEBUG / PROVING GROUNDS |
||
3721 | --------------------------------------------------------------- |
||
3722 | ]] |
||
3723 | |||
3724 | function CTA_Error( s ) |
||
3725 | UIErrorsFrame:AddMessage(s, 0.75, 0.75, 1.0, 1.0, UIERRORS_HOLD_TIME); |
||
3726 | end |
||
3727 | |||
3728 | function CTA_Println( s ) |
||
3729 | local m = s; |
||
3730 | if( not m ) then |
||
3731 | m = "nil"; |
||
3732 | end |
||
3733 | |||
3734 | if( DEFAULT_CHAT_FRAME ) then |
||
3735 | DEFAULT_CHAT_FRAME:AddMessage( "CTA: "..m, 1, 1, 0.5); |
||
3736 | end |
||
3737 | end |
||
3738 | |||
3739 | function CTA_IconMsg( s, t ) |
||
3740 | local m = s; |
||
3741 | if( not m ) then |
||
3742 | m = "nil"; |
||
3743 | end |
||
3744 | |||
3745 | if( not t ) then |
||
3746 | CTA_MinimapMessageFrame:AddMessage(m, 1.0, 1.0, 0.5, 1.0, UIERRORS_HOLD_TIME); |
||
3747 | else |
||
3748 | local r = CTA_MESSAGE_COLOURS[t].r; |
||
3749 | local g = CTA_MESSAGE_COLOURS[t].g; |
||
3750 | local b = CTA_MESSAGE_COLOURS[t].b; |
||
3751 | |||
3752 | CTA_MinimapMessageFrame:AddMessage(m, r, g, b, 1.0, UIERRORS_HOLD_TIME); |
||
3753 | end |
||
3754 | end |
||
3755 | |||
3756 | function CTA_LogMsg( s, t ) |
||
3757 | local m = s; |
||
3758 | if( not m ) then |
||
3759 | m = "nil"; |
||
3760 | end |
||
3761 | m = "["..CTA_GetTime().."] "..m; |
||
3762 | |||
3763 | |||
3764 | if( not t ) then |
||
3765 | CTA_Log:AddMessage( m, 1.0, 1.0, 0.5 ); |
||
3766 | else |
||
3767 | local r = CTA_MESSAGE_COLOURS[t].r; |
||
3768 | local g = CTA_MESSAGE_COLOURS[t].g; |
||
3769 | local b = CTA_MESSAGE_COLOURS[t].b; |
||
3770 | |||
3771 | CTA_Log:AddMessage( m, r, g, b ); |
||
3772 | end |
||
3773 | end |
||
3774 | |||
3775 | |||
3776 | |||
3777 | |||
3778 | |||
3779 | |||
3780 | |||
3781 | -- R7 |
||
3782 | |||
3783 | |||
3784 | |||
3785 | |||
3786 | function SachaSearch( source, search ) |
||
3787 | if( not ( source and search ) ) then |
||
3788 | return nil; |
||
3789 | end |
||
3790 | |||
3791 | local s = trim( search ); |
||
3792 | local operator, op1, op2 = getOps( s ); |
||
3793 | |||
3794 | if( operator ) then |
||
3795 | local op1Res = SachaSearch( source, op1 ); |
||
3796 | if( not op1Res ) then |
||
3797 | return 0; |
||
3798 | elseif( op1Res > 0 and operator == "/" ) then |
||
3799 | return 1; |
||
3800 | elseif( op1Res == 0 and operator == "+" ) then |
||
3801 | return 0; |
||
3802 | end |
||
3803 | |||
3804 | local op2Res = SachaSearch( source, op2, verbose ); |
||
3805 | if( not op2Res ) then |
||
3806 | return 0; |
||
3807 | elseif( op2Res > 0 and ( op1Res > 0 or operator == "/" ) ) then |
||
3808 | return 1; |
||
3809 | end |
||
3810 | return 0; |
||
3811 | else |
||
3812 | local literal; |
||
3813 | if( string.sub( s, 1, 1 ) == "-" ) then |
||
3814 | return( 1 - SachaSearch( source, trim( string.sub( s, 2 ) ) ) ); |
||
3815 | elseif( string.sub( s, 1, 1 ) == "(" and string.sub( s, string.len( s ) ) == ")" ) then |
||
3816 | return SachaSearch( source, trim( string.sub( s, 2, string.len( s ) - 1 ) ) ); |
||
3817 | elseif( string.sub( s, 1, 1 ) == "\"" and string.sub( s, string.len( s ) ) == "\"" ) then |
||
3818 | s = trim( string.sub( s, 2, string.len( s ) - 1 ) ); |
||
3819 | literal = 1; |
||
3820 | end |
||
3821 | |||
3822 | if( literal ) then |
||
3823 | if( string.find( source, s ) ) then |
||
3824 | return 1; |
||
3825 | else |
||
3826 | return 0; |
||
3827 | end |
||
3828 | else |
||
3829 | if( SachaScoredSearch( source, s ) > 0 ) then |
||
3830 | return 1; |
||
3831 | else |
||
3832 | return 0; |
||
3833 | end |
||
3834 | end |
||
3835 | end |
||
3836 | end |
||
3837 | |||
3838 | function trim(s) |
||
3839 | if( not s ) then return nil; end |
||
3840 | return( string.gsub(s, "^%s*(.-)%s*$", "%1") or s ); |
||
3841 | end |
||
3842 | |||
3843 | function getOps( source ) |
||
3844 | local operatorFound = nil; |
||
3845 | local bracketCount = 0; |
||
3846 | local inQuote = 0; |
||
3847 | local pos = 0; |
||
3848 | |||
3849 | local currentChar; |
||
3850 | while( pos < string.len( source ) ) do |
||
3851 | currentChar = string.sub( source, pos, pos ); |
||
3852 | if( ( currentChar == "+" or currentChar == "/" ) and bracketCount == 0 and inQuote == 0 ) then |
||
3853 | operatorFound = 1; |
||
3854 | break; |
||
3855 | elseif( currentChar == "(" ) then |
||
3856 | bracketCount = bracketCount + 1; |
||
3857 | elseif( currentChar == ")" ) then |
||
3858 | bracketCount = bracketCount - 1; |
||
3859 | elseif( currentChar == "\"" ) then |
||
3860 | inQuote = 1 - inQuote; |
||
3861 | end |
||
3862 | pos = pos + 1; |
||
3863 | end |
||
3864 | |||
3865 | if( operatorFound ) then |
||
3866 | return currentChar, string.sub( source, 1, pos - 1 ), string.sub( source, pos + 1 ); |
||
3867 | end |
||
3868 | end |
||
3869 | |||
3870 | |||
3871 | function SachaScoredSearch( source, search ) |
||
3872 | local ad = string.lower( source ); |
||
3873 | local query = string.lower( search ); |
||
3874 | |||
3875 | if( string.find( ad, query ) ) then |
||
3876 | return 100; |
||
3877 | else |
||
3878 | local score = 0; |
||
3879 | local total = 0; |
||
3880 | for word in string.gfind(query, "%w+") do |
||
3881 | total = total + 1; |
||
3882 | if( string.find( ad, "%s+"..word.."%s+" ) ) then |
||
3883 | score = score + 1; |
||
3884 | elseif( string.find( ad, word ) ) then |
||
3885 | score = score + 0.9; |
||
3886 | end |
||
3887 | end |
||
3888 | |||
3889 | if( score > 0 and total > 0 ) then |
||
3890 | score = floor(99*score/total); |
||
3891 | end |
||
3892 | |||
3893 | return score; |
||
3894 | end |
||
3895 | end |
||
3896 | |||
3897 | |||
3898 | |||
3899 | function CTA_GetGroupClassesCode() |
||
3900 | local groupClasses = {}; |
||
3901 | groupClasses[1] = 0; |
||
3902 | groupClasses[2] = 0; |
||
3903 | groupClasses[3] = 0; |
||
3904 | groupClasses[4] = 0; |
||
3905 | groupClasses[5] = 0; |
||
3906 | groupClasses[6] = 0; |
||
3907 | groupClasses[7] = 0; |
||
3908 | groupClasses[8] = 0; |
||
3909 | |||
3910 | local name, level, class; |
||
3911 | for num = 1, 40 do |
||
3912 | name, level, class = CTA_GetGroupMemberInfo( num ); |
||
3913 | if( name == nil ) then break; end |
||
3914 | groupClasses[ CTA_GetClassCode(class) ] = groupClasses[ CTA_GetClassCode(class) ] + 1; |
||
3915 | end |
||
3916 | |||
3917 | local retVal = ""; |
||
3918 | for num = 1, 8 do |
||
3919 | retVal = retVal..groupClasses[ num ]..","; |
||
3920 | end |
||
3921 | return retVal; |
||
3922 | end |
||
3923 | |||
3924 | function CTA_DecodeGroupClasses( code ) |
||
3925 | if( not code or code == 0 ) then |
||
3926 | return; |
||
3927 | end |
||
3928 | |||
3929 | local classes = { }; |
||
3930 | classes[1] = CTA_PRIEST; |
||
3931 | classes[2] = CTA_MAGE; |
||
3932 | classes[3] = CTA_WARLOCK; |
||
3933 | classes[4] = CTA_DRUID; |
||
3934 | classes[5] = CTA_HUNTER; |
||
3935 | classes[6] = CTA_ROGUE; |
||
3936 | classes[7] = CTA_WARRIOR; |
||
3937 | if( UnitFactionGroup(CTA_PLAYER) == CTA_ALLIANCE ) then |
||
3938 | classes[8] = CTA_PALADIN; |
||
3939 | else |
||
3940 | classes[8] = CTA_SHAMAN; |
||
3941 | end |
||
3942 | |||
3943 | --local retVal; |
||
3944 | local retVal2; |
||
3945 | |||
3946 | for priest, mage, warlock, druid, hunter, rogue, warrior, hybrid, version, extra in string.gfind( code, "(%d+),(%d+),(%d+),(%d+),(%d+),(%d+),(%d+),(%d+),(.+),(.+)" ) do |
||
3947 | --[[ |
||
3948 | ^extra reserved for any future releases |
||
3949 | |||
3950 | NB: I might need it to implement the max level req for groups. |
||
3951 | |||
3952 | |||
3953 | ]] |
||
3954 | |||
3955 | classes[1] = priest; |
||
3956 | classes[2] = mage; |
||
3957 | classes[3] = warlock; |
||
3958 | classes[4] = druid; |
||
3959 | classes[5] = hunter; |
||
3960 | classes[6] = rogue; |
||
3961 | classes[7] = warrior; |
||
3962 | classes[8] = hybrid; |
||
3963 | |||
3964 | retVal2 = version; |
||
3965 | |||
3966 | end |
||
3967 | |||
3968 | return classes, retVal2; |
||
3969 | end |
||
3970 | |||
3971 | |||
3972 | |||
3973 | |||
3974 | function CTA_SearchDropDown_OnClick() |
||
3975 | UIDropDownMenu_SetSelectedID(CTA_SearchDropDown, this:GetID()); |
||
3976 | end |
||
3977 | |||
3978 | function CTA_SearchDropDown_Init() |
||
3979 | local info = {}; |
||
3980 | info.text = CTA_SHOW_PLAYERS_AND_GROUPS; |
||
3981 | info.func = CTA_SearchDropDown_OnClick; |
||
3982 | UIDropDownMenu_AddButton(info); |
||
3983 | |||
3984 | info = {}; |
||
3985 | info.text = CTA_SHOW_GROUPS_ONLY; |
||
3986 | info.func = CTA_SearchDropDown_OnClick; |
||
3987 | UIDropDownMenu_AddButton(info); |
||
3988 | |||
3989 | info = {}; |
||
3990 | info.text = CTA_SHOW_PLAYERS_ONLY; |
||
3991 | info.func = CTA_SearchDropDown_OnClick; |
||
3992 | UIDropDownMenu_AddButton(info); |
||
3993 | end |
||
3994 | |||
3995 | |||
3996 | function CTA_UpdateLFxButtonButton_OnClick() |
||
3997 | |||
3998 | local text = CTA_SearchFrameLFGTriggerEditBox:GetText() or ""; |
||
3999 | local ok = 1; |
||
4000 | for word in string.gfind(text, "%w+") do |
||
4001 | if( strlen( word ) < 3 ) then |
||
4002 | ok = nil; |
||
4003 | break; |
||
4004 | end |
||
4005 | end |
||
4006 | if( ok ) then |
||
4007 | local spos = string.find( text, CTA_DEFAULT_LFG_TRIGGER ) or 0; |
||
4008 | if( spos <= 0 ) then |
||
4009 | CTA_SavedVariables.lfgTrigger = CTA_DEFAULT_LFG_TRIGGER.." "..text; |
||
4010 | else |
||
4011 | CTA_SavedVariables.lfgTrigger = text; |
||
4012 | end |
||
4013 | end |
||
4014 | CTA_SearchFrameLFGTriggerEditBox:SetText( CTA_SavedVariables.lfgTrigger ); |
||
4015 | |||
4016 | text = CTA_SearchFrameLFMTriggerEditBox:GetText() or ""; |
||
4017 | local ok = 1; |
||
4018 | for word in string.gfind(text, "%w+") do |
||
4019 | if( strlen( word ) < 3 ) then |
||
4020 | ok = nil; |
||
4021 | break; |
||
4022 | end |
||
4023 | end |
||
4024 | if( ok ) then |
||
4025 | local spos = string.find( text, CTA_DEFAULT_LFM_TRIGGER ) or 0; |
||
4026 | if( spos <= 0 ) then |
||
4027 | CTA_SavedVariables.lfmTrigger = CTA_DEFAULT_LFM_TRIGGER.." "..text; |
||
4028 | else |
||
4029 | CTA_SavedVariables.lfmTrigger = text; |
||
4030 | end |
||
4031 | end |
||
4032 | CTA_SearchFrameLFMTriggerEditBox:SetText( CTA_SavedVariables.lfmTrigger ); |
||
4033 | |||
4034 | end |
||
4035 | |||
4036 | -- fix |
||
4037 | function CTA_UpdateLFxButtonButton_OnClick() |
||
4038 | |||
4039 | local text = CTA_SearchFrameLFGTriggerEditBox:GetText() or ""; |
||
4040 | local ok = 1; |
||
4041 | for word in string.gfind(text, ".+") do |
||
4042 | if( string.sub( word, 1, 1 ) == "\"" and string.sub( word, string.len( word ) ) == "\"" ) then |
||
4043 | if( strlen( word ) < 6 ) then |
||
4044 | ok = nil; |
||
4045 | break; |
||
4046 | end |
||
4047 | else |
||
4048 | if( strlen( word ) < 3 ) then |
||
4049 | ok = nil; |
||
4050 | break; |
||
4051 | end |
||
4052 | end |
||
4053 | end |
||
4054 | if( ok ) then |
||
4055 | CTA_SavedVariables.lfgTrigger = text; |
||
4056 | CTA_SearchFrameLFGTriggerEditBox:SetText( CTA_SavedVariables.lfgTrigger ); |
||
4057 | end |
||
4058 | text = CTA_SearchFrameLFMTriggerEditBox:GetText(); |
||
4059 | local ok = 1; |
||
4060 | for word in string.gfind(text, ".+") do |
||
4061 | if( string.sub( word, 1, 1 ) == "\"" and string.sub( word, string.len( word ) ) == "\"" ) then |
||
4062 | if( strlen( word ) < 6 ) then |
||
4063 | ok = nil; |
||
4064 | break; |
||
4065 | end |
||
4066 | else |
||
4067 | if( strlen( word ) < 3 ) then |
||
4068 | ok = nil; |
||
4069 | break; |
||
4070 | end |
||
4071 | end |
||
4072 | end |
||
4073 | if( ok ) then |
||
4074 | CTA_SavedVariables.lfmTrigger = text; |
||
4075 | CTA_SearchFrameLFMTriggerEditBox:SetText( CTA_SavedVariables.lfmTrigger ); |
||
4076 | end |
||
4077 | end |
||
4078 | |||
4079 | |||
4080 | function CTA_ShowLFGFrame() |
||
4081 | if ( CTA_GetNumGroupMembers() > 1 ) then |
||
4082 | CTA_CannotLFGFrame:Show(); |
||
4083 | CTA_LFGFrame:Hide(); |
||
4084 | else |
||
4085 | CTA_CannotLFGFrame:Hide(); |
||
4086 | CTA_LGMPrefixLabel:SetText( "Level "..UnitLevel( CTA_PLAYER ).." "..UnitClass( CTA_PLAYER ).." "..CTA_LFG.." " ); |
||
4087 | CTA_LFGFrame:Show(); |
||
4088 | end |
||
4089 | end |
||
4090 | |||
4091 | |||
4092 | function CTA_InitClassTable() |
||
4093 | CTA_Classes[1] = CTA_PRIEST; |
||
4094 | CTA_Classes[2] = CTA_MAGE; |
||
4095 | CTA_Classes[3] = CTA_WARLOCK; |
||
4096 | CTA_Classes[4] = CTA_DRUID; |
||
4097 | CTA_Classes[5] = CTA_HUNTER; |
||
4098 | CTA_Classes[6] = CTA_ROGUE; |
||
4099 | CTA_Classes[7] = CTA_WARRIOR; |
||
4100 | if( UnitFactionGroup(CTA_PLAYER) == CTA_ALLIANCE ) then |
||
4101 | CTA_Classes[8] = CTA_PALADIN; |
||
4102 | else |
||
4103 | CTA_Classes[8] = CTA_SHAMAN; |
||
4104 | end |
||
4105 | CTA_Classes[CTA_PRIEST] = 1; |
||
4106 | CTA_Classes[CTA_MAGE] = 2; |
||
4107 | CTA_Classes[CTA_WARLOCK] = 3; |
||
4108 | CTA_Classes[CTA_DRUID] = 4; |
||
4109 | CTA_Classes[CTA_HUNTER] = 5; |
||
4110 | CTA_Classes[CTA_ROGUE] = 6; |
||
4111 | CTA_Classes[CTA_WARRIOR] = 7; |
||
4112 | CTA_Classes[CTA_PALADIN] = 8; |
||
4113 | CTA_Classes[CTA_SHAMAN] = 8; |
||
4114 | end |
||
4115 | |||
4116 | |||
4117 | function CTA_PlayerClassDropDown_Init() |
||
4118 | if( not CTA_Classes[i] ) then |
||
4119 | CTA_InitClassTable(); |
||
4120 | end |
||
4121 | |||
4122 | local info = {}; |
||
4123 | info.text = CTA_ANY_CLASS; |
||
4124 | info.func = CTA_PlayerClassDropDown_OnClick; |
||
4125 | UIDropDownMenu_AddButton(info); |
||
4126 | |||
4127 | for i=1, 8 do |
||
4128 | info = {}; |
||
4129 | info.text = CTA_Classes[i]; |
||
4130 | info.func = CTA_PlayerClassDropDown_OnClick; |
||
4131 | UIDropDownMenu_AddButton(info); |
||
4132 | end |
||
4133 | end |
||
4134 | |||
4135 | function CTA_PlayerClassDropDown_OnClick() |
||
4136 | UIDropDownMenu_SetSelectedID(CTA_PlayerClassDropDown, this:GetID()); |
||
4137 | end |
||
4138 | |||
4139 | |||
4140 | |||
4141 | |||
4142 | --[[ |
||
4143 | |||
4144 | |||
4145 | |||
4146 | function CTA_InitLinks() |
||
4147 | |||
4148 | local old_SetItemRef = SetItemRef; |
||
4149 | function SetItemRef(link, text, button) |
||
4150 | for name, msg in string.gfind( link, "xhmsg:(%w+)<XH>(.+)" ) do |
||
4151 | |||
4152 | if( ItemRefTooltip:IsVisible() and lastName and lastName == name ) then |
||
4153 | |||
4154 | HideUIPanel(ItemRefTooltip); |
||
4155 | --ItemRefTooltip:Hide(); |
||
4156 | lastName = nil; |
||
4157 | |||
4158 | else |
||
4159 | lastName = name; |
||
4160 | |||
4161 | ShowUIPanel(ItemRefTooltip); |
||
4162 | if ( not ItemRefTooltip:IsVisible() ) then |
||
4163 | ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE"); |
||
4164 | end |
||
4165 | |||
4166 | ItemRefTooltip:ClearLines(); |
||
4167 | --ItemRefTooltip:ClearAllPoints(); |
||
4168 | |||
4169 | if( name == "eas" and msg == "eas" ) then |
||
4170 | |||
4171 | ItemRefTooltip:AddLine( EAS_NOTE[1], 1, 0.5, 0 ); |
||
4172 | ItemRefTooltip:AddLine( EAS_NOTE[2], 1, 1, 1, 1, 1 ); |
||
4173 | ItemRefTooltip:AddLine( EAS_NOTE[3] ); |
||
4174 | |||
4175 | else |
||
4176 | ItemRefTooltip:AddLine( "Message", 0.5, 0.5, 1 ); |
||
4177 | ItemRefTooltip:AddLine( name ); |
||
4178 | ItemRefTooltip:AddLine( msg, 1, 1, 1, 1, 1 ); |
||
4179 | end |
||
4180 | ItemRefTooltip:Show(); |
||
4181 | |||
4182 | -- |
||
4183 | --ShowUIPanel(ItemRefTooltip); |
||
4184 | --if ( not ItemRefTooltip:IsVisible() ) then |
||
4185 | -- ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE"); |
||
4186 | --end |
||
4187 | |||
4188 | end |
||
4189 | |||
4190 | return; |
||
4191 | end |
||
4192 | |||
4193 | lastName = nil; |
||
4194 | old_SetItemRef(link, text, button); |
||
4195 | end |
||
4196 | |||
4197 | |||
4198 | local old_ChatFrame_OnEvent = ChatFrame_OnEvent; |
||
4199 | function ChatFrame_OnEvent(event) |
||
4200 | if( string.find( event, "CHAT_MSG" ) and arg1 and arg2 and string.len(arg1) > 16 ) then |
||
4201 | local argl = string.lower(arg1); |
||
4202 | local start; --, _ = string.find( argl, "enchanting"); |
||
4203 | local score = 100; |
||
4204 | if( not start ) then |
||
4205 | score = Sacha_LightSearch( arg1, "bracer chest boots weapon armor fiery demon slaying beast crusader" ); |
||
4206 | if( score > 0 and ( string.find( argl, "chant") or string.find( argl, "ench") ) ) then |
||
4207 | start = 1; |
||
4208 | end |
||
4209 | end |
||
4210 | |||
4211 | if( start and Sacha_LightSearch( arg1, "trainer thorium item:" ) == 0 ) then |
||
4212 | arg1 = "|cff8888ff|Hxhmsg:"..arg2.."<XH>"..arg1.."|h[Enchantments]|h|r"; |
||
4213 | if( string.find(argl, "wts") ) then |
||
4214 | arg1 = "WTS "..arg1; |
||
4215 | elseif( string.find(argl, "wtb") ) then |
||
4216 | arg1 = "WTB "..arg1; |
||
4217 | else |
||
4218 | arg1 = "Regarding "..arg1; |
||
4219 | end |
||
4220 | end |
||
4221 | end |
||
4222 | old_ChatFrame_OnEvent(event); |
||
4223 | end |
||
4224 | |||
4225 | ChatPrintln( "|cffff8800|Hxhmsg:eas<XH>eas|h[Enchanter Ad Shrinker]|h|r loaded." ); |
||
4226 | |||
4227 | |||
4228 | end |
||
4229 | ]] |