vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --
2 -- Define the basic styles.
3 --
4 local ConfabStyles = {
5 [0] = {
6 info = CONFAB_STYLE1_INFO,
7 style = 0,
8 docked = true,
9 dockpoints = {
10 [0] = {
11 point = "TOPLEFT",
12 relto = "ChatFrame1",
13 relpoint = "BOTTOMLEFT",
14 xoff = -5,
15 yoff = -1
16 },
17 [1] = {
18 point = "TOPRIGHT",
19 relto = "ChatFrame1",
20 relpoint = "BOTTOMRIGHT",
21 xoff = 5,
22 yoff = -1
23 }
24 }
25 },
26 [1] = {
27 info = CONFAB_STYLE2_INFO,
28 style = 1,
29 autohide = true, -- overrides the /conflag autohide option
30 docked = true,
31 dockpoints = {
32 [0] = {
33 point = "BOTTOMLEFT",
34 relto = "ChatFrame1",
35 relpoint = "BOTTOMLEFT",
36 xoff = -5,
37 yoff = -14
38 },
39 [1] = {
40 point = "BOTTOMRIGHT",
41 relto = "ChatFrame1",
42 relpoint = "BOTTOMRIGHT",
43 xoff = 5,
44 yoff = -14
45 }
46 }
47 },
48 [2] = {
49 info = CONFAB_STYLE3_INFO,
50 style = 2,
51 autohide = true, -- overrides the /conflag autohide option
52 docked = true,
53 dockpoints = {
54 [0] = {
55 point = "TOPLEFT",
56 relto = "ChatFrame1",
57 relpoint = "TOPLEFT",
58 xoff = -5,
59 yoff = 10
60 },
61 [1] = {
62 point = "TOPRIGHT",
63 relto = "ChatFrame1",
64 relpoint = "TOPRIGHT",
65 xoff = 5,
66 yoff = 10
67 }
68 }
69 },
70 [3] = {
71 info = CONFAB_STYLE4_INFO,
72 style = 3,
73 docked = true,
74 dockpoints = {
75 [0] = {
76 point = "BOTTOMLEFT",
77 relto = "ChatFrame1",
78 relpoint = "TOPLEFT",
79 xoff = -5,
80 yoff = -3
81 },
82 [1] = {
83 point = "BOTTOMRIGHT",
84 relto = "ChatFrame1",
85 relpoint = "TOPRIGHT",
86 xoff = 5,
87 yoff = -3
88 }
89 }
90 },
91 ["undock"] = {
92 info = CONFAB_UNDOCKED_INFO,
93 docked = false,
94 locked = false
95 }
96 };
97  
98  
99  
100 --
101 -- Change the chat groups to split out the Officer and Raid channels.
102 --
103 ChatTypeGroup["PARTY"] = {
104 "CHAT_MSG_PARTY"
105 };
106  
107 ChatTypeGroup["RAID"] = {
108 "CHAT_MSG_RAID"
109 };
110  
111 ChatTypeGroup["GUILD"] = {
112 "CHAT_MSG_GUILD",
113 "GUILD_MOTD"
114 };
115 ChatTypeGroup["OFFICER"] = {
116 "CHAT_MSG_OFFICER"
117 };
118  
119 --
120 -- Add them to the channel filter menu
121 --
122 ChannelMenuChatTypeGroups[6] = "RAID";
123 ChannelMenuChatTypeGroups[7] = "OFFICER";
124  
125  
126 --
127 -- Define some local variables
128 --
129 local OldEditBox = nil;
130 local OldChatFrameEditBox = nil;
131  
132 local PlayerName = nil;
133 local SLASH_TT = "/tt";
134 local SLASH_TELLTARGET = "/telltarget";
135 local SLASH_RT = "/rt";
136 local SLASH_RETELL = "/retell";
137 local LastSentTellTarget = nil;
138 local ShowFlag = false;
139 local InitDone = false;
140  
141 --
142 -- Define global variables
143 --
144 CONFAB_VERSION = "1.77"; -- obligatory version
145 ConfabUser = {}; -- table user data is saved in
146 ConfabDetails = {
147 name = "Confab",
148 description = "Customize the look and placement of the chat edit box",
149 version = CONFAB_VERSION,
150 releaseDate = "July 20, 2005",
151 author = "Kulyeh",
152 --email = "",
153 website = "http://www.curse-gaming.com",
154 category = MYADDONS_CATEGORY_CHAT,
155 frame = "Confab",
156 --optionsframe = "HelloWorldOptionsFrame"
157 };
158  
159 ConfabHelp = {};
160 ConfabHelp[1] = string.format(CONFAB_USAGE, "/confab").."\n"..CONFAB_HELP1..
161 "\n|cffffffff style1|cff00ff00|||cffffffffstyle2|cff00ff00|||cffffffffstyle3|cff00ff00|||cffffffffstyle4 |cff00ff00"..
162 "\n|cffffffff chatsticky off|cff00ff00|||cffffffffdefault|cff00ff00|||cffffffffconfab|cff00ff00|||cffffffffparty|cff00ff00|||cffffffffguild|cff00ff00|||cffffffffraid|cff00ff00|||cffffffffofficer|cff00ff00|||cffffffffsay|cff00ff00|||cffffffff1-10 |cff00ff00"..
163 "\n|cffffffff autohide on|cff00ff00|||cffffffffoff |cff00ff00\n|cffffffff undock |r|cff00ff00\n|cffffffff dock |cff00ff00[|cffffffffframe|cff00ff00] |cff00ff00"..
164 "\n|cffffffff autodock on|cff00ff00|||cffffffffoff |cff00ff00\n|cffffffff lock |cff00ff00\n|cffffffff unlock |cff00ff00"..
165 "\n|cffffffff enableArrowKeys |cff00ff00\n|cffffffff disableArrowKeys |cff00ff00\n|cffffffff texture |cff00ff00\n|cffffffff alpha |cff00ff00\n\n"..CONFAB_HELP14..
166 "\n|cffffffff /tt |cff00ff00\n|cffffffff /targettell |cff00ff00\n|cffffffff /telltarget |cff00ff00\n|cffffffff /rt, /retell |cff00ff00"..
167 "\n|cffffffff /targetsave, /tsave |cff00ff00\n|cffffffff /targetrestore, /trestore |cff00ff00";
168  
169  
170  
171 function Confab_OnLoad()
172  
173 if (not DEFAULT_CHAT_FRAME) then
174 DEFAULT_CHAT_FRAME = ChatFrame1;
175 end
176  
177 if (not SELECTED_CHAT_FRAME) then
178 SELECTED_CHAT_FRAME = ChatFrame1;
179 end
180  
181 if (DEFAULT_CHAT_FRAME.editBox) then
182 OldEditBox = DEFAULT_CHAT_FRAME.editBox;
183 OldChatFrameEditBox = ChatFrameEditBox;
184 end
185  
186  
187 SLASH_CONFAB1 = "/confab";
188 SLASH_CONFAB2 = "/cf";
189 SlashCmdList["CONFAB"] = function(msg)
190 ConfabSlashHandler(msg);
191 end
192  
193  
194 if (SlashCmdList["RT"] == nil) then
195 SLASH_RT1 = SLASH_RT;
196 SLASH_RT2 = SLASH_RETELL;
197 SlashCmdList["RT"] = function(msg)
198 --Confab_ReTell()
199 end
200 end
201  
202 SLASH_TT1 = SLASH_TT;
203 SlashCmdList["TT"] = function(msg)
204 Confab_TT(msg);
205 end
206  
207 SLASH_TARGETTELL1 = "/targettell";
208 SlashCmdList["TARGETTELL"] = function(msg)
209 Confab_TT();
210 end
211  
212 SLASH_TELLTARGET1 = SLASH_TELLTARGET;
213 SlashCmdList["TELLTARGET"] = function(msg)
214 if (msg ~= nil and strlen(msg) > 0) then
215 Confab_TT(msg);
216 end;
217 end
218  
219 SLASH_SAVETARGET1 = "/targetsave";
220 SLASH_SAVETARGET2 = "/tsave";
221 SlashCmdList["SAVETARGET"] = function(msg)
222 Confab_SaveTarget();
223 end
224  
225 SLASH_LOADTARGET1 = "/targetrestore";
226 SLASH_LOADTARGET2 = "/trestore";
227 SlashCmdList["LOADTARGET"] = function(msg)
228 Confab_LoadTarget();
229 end
230  
231  
232 this:RegisterEvent("VARIABLES_LOADED");
233 this:RegisterEvent("UNIT_NAME_UPDATE");
234 end
235  
236 function Confab_RegisterUltimateUI()
237 UltimateUI_RegisterConfiguration(
238 "UUI_CONFAB",
239 "SECTION",
240 "Confab",
241 "Options to configure your chat edit box."
242 );
243 UltimateUI_RegisterConfiguration(
244 "UUI_CONFAB_SEPARATOR",
245 "SEPARATOR",
246 "Confab",
247 "Options to configure your chat edit box."
248 );
249 UltimateUI_RegisterConfiguration(
250 "UUI_CONFAB_UNLOCK",
251 "CHECKBOX",
252 "Unlock edit box",
253 "Check to allow dragging of the edit box.",
254 Confab_Toggle,
255 1
256 );
257 end
258  
259 function Confab_Toggle(arg)
260 if( arg == 1 ) then
261 if (ConfabUser[PlayerName].currentstyle.docked) then
262 if (ConfabUser[PlayerName].autodock) then
263 ConfabUser[PlayerName].autodock = false;
264 Confab:Hide();
265 end
266 Confab_SetStyle(ConfabStyles["undock"], ConfabUser[PlayerName].autohide);
267 end
268 if (ConfabUser[PlayerName].currentstyle.locked) then
269 ConfabUser[PlayerName].currentstyle.locked = false;
270 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide);
271 end
272 elseif( arg == 0) then
273 if (not ConfabUser[PlayerName].currentstyle.locked) then
274 ConfabUser[PlayerName].currentstyle.locked = true;
275 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide);
276 end
277 else
278 DEFAULT_CHAT_FRAME:AddMessage("Confab_Toggle(arg) returned invalid arg.");
279 end
280 end
281  
282 local variablesLoaded = false;
283 function Confab_OnEvent(event)
284 if (event == "VARIABLES_LOADED") then
285 Confab_RegisterUltimateUI();
286 variablesLoaded = true;
287 if (not PlayerName) then
288 local playerName = UnitName("player");
289 if (playerName ~= UKNOWNBEING and playerName ~= UNKNOWNOBJECT) then
290 PlayerName = playerName .. ":"..GetCVar("realmName");
291 Confab_Init();
292 end
293 else
294 Confab_Init();
295 end
296 if(myAddOnsFrame_Register) then
297 -- Register the addon in myAddOns
298 myAddOnsFrame_Register(ConfabDetails, ConfabHelp);
299 end
300 elseif (event == "UNIT_NAME_UPDATE" and arg1 == "player") then
301 local playerName = UnitName("player");
302 if (playerName ~= UKNOWNBEING and playerName ~= UNKNOWNOBJECT) then
303 if (PlayerName == nil) then
304 PlayerName = playerName .. ":"..GetCVar("realmName");
305  
306 if (variablesLoaded) then
307 Confab_Init();
308 end
309 end
310 end
311 end
312 end
313  
314  
315 -- used for the autodock option.
316 function Confab_OnUpdate(elapsed)
317 if (InitDone) then
318 local chatFrame, chatTab;
319  
320 for j=1, NUM_CHAT_WINDOWS do
321 chatFrame = getglobal("ChatFrame"..j);
322 chatTab = getglobal("ChatFrame"..j.."Tab");
323 local tabname = chatTab:GetText();
324  
325 if (tabname ~= COMBAT_LOG and chatFrame:IsVisible() and MouseIsOver(chatFrame, 45, -10, -5, 5)) then
326 local name = chatFrame:GetName();
327  
328 if (chatFrame.isDocked) then
329 if (SELECTED_DOCK_FRAME == chatFrame) then
330 if (chatFrame.editBox.dockedTo and chatFrame.editBox.dockedTo ~= name) then
331 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide, name);
332 Confab_SetChannelSticky(chatFrame.editBox);
333 end
334 return;
335 end
336 else
337 if (chatFrame.editBox.dockedTo and chatFrame.editBox.dockedTo ~= name) then
338 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide, name);
339 Confab_SetChannelSticky(chatFrame.editBox);
340 end
341 return;
342 end
343 end
344 end
345 end
346 end
347  
348  
349 function Confab_SetEditBox(editBox)
350 -- copy over some of the basic stuff from the old editbox to the new one.
351 editBox.chatType = ChatFrameEditBox.chatType;
352 editBox.channelTarget = ChatFrameEditBox.channelTarget;
353 editBox.stickyType = ChatFrameEditBox.stickyType;
354 editBox.lastTell = ChatFrameEditBox.lastTell;
355 editBox.tellTarget = ChatFrameEditBox.tellTarget;
356  
357 if (ChatFrameEditBox.Org_IsVisible) then
358 ChatFrameEditBox.IsVisible = ChatFrameEditBox.Org_IsVisible;
359 ChatFrameEditBox.Org_IsVisible = nil;
360 end
361  
362 if (ChatFrameEditBox.Org_Hide) then
363 ChatFrameEditBox.Hide = ChatFrameEditBox.Org_Hide;
364 ChatFrameEditBox.Org_Hide = nil;
365 end
366  
367 -- re-assign the global variable to the new edit box.
368 ChatFrameEditBox = editBox;
369  
370 -- Since I have to muck with these to make the default Blizzard code to correctly work
371 -- with autohide off, save the originals off and re-assign
372 ChatFrameEditBox.Org_IsVisible = ChatFrameEditBox.IsVisible;
373 ChatFrameEditBox.IsVisible = Confab_IsVisible;
374  
375 ChatFrameEditBox.Org_Hide = ChatFrameEditBox.Hide;
376 ChatFrameEditBox.Hide = Confab_Hide;
377  
378  
379 local chatFrame = nil;
380 local chatFrameName = nil;
381 local chatTab = nil;
382  
383 -- Iterate through each of the chatframes and assign the editbox to the new one.
384 for i=1, NUM_CHAT_WINDOWS do
385 chatFrameName = "ChatFrame"..i;
386 chatTab = getglobal(chatFrameName.."Tab");
387 chatFrame = getglobal(chatFrameName);
388  
389 chatFrame.editBox = editBox;
390  
391 -- Since we are iterating through the chatframes, initialize the filter menu to correctly
392 -- assign the Raid and Officer filters (since I have to save that info myself).
393 if (ConfabUser[PlayerName][chatFrameName]) then
394 if (ConfabUser[PlayerName][chatFrameName]["RAID"]) then
395 ChatFrame_AddMessageGroup(chatFrame, "RAID");
396 end
397 if (ConfabUser[PlayerName][chatFrameName]["OFFICER"]) then
398 ChatFrame_AddMessageGroup(chatFrame, "OFFICER");
399 end
400 end
401  
402 -- Again, since we are iterating through the chatframes, set the chatframe sticky based on the chat tab text.
403 Confab_SetChatFrameSticky(chatFrame, chatTab:GetText());
404 end
405  
406 -- Save which editbox we are using
407 ConfabUser.editbox = editBox:GetName();
408 end
409  
410 local Org_ChatEdit_OnSpacePressed = ChatEdit_OnSpacePressed;
411 local Org_ChatEdit_OnEscapePressed = ChatEdit_OnEscapePressed;
412 local Org_ChatEdit_ParseText = ChatEdit_ParseText;
413 local Org_ChatFrame_OpenChat = ChatFrame_OpenChat;
414 local Org_ChatFrame_OnEvent = ChatFrame_OnEvent;
415 local Org_FCF_Close = FCF_Close;
416 local Org_FCFMessageTypeDropDown_OnClick = FCFMessageTypeDropDown_OnClick;
417 local Org_FCF_OpenNewWindow = FCF_OpenNewWindow;
418 local Org_FCF_SetWindowName = FCF_SetWindowName;
419 local Org_FCF_Tab_OnClick = FCF_Tab_OnClick;
420 local Org_FCF_UnDockFrame = FCF_UnDockFrame;
421 local Org_FCF_DockFrame = FCF_DockFrame;
422 local Org_FCF_OnUpdate = FCF_OnUpdate;
423  
424 local Org_ChatLock_OpenChat = ChatLock_OpenChat;
425  
426 -- Confab main init method.
427 function Confab_Init()
428 -- hide the main frame so events and updates are turned off
429 Confab:Hide();
430  
431 -- don't need these anymore, so might as well unregister them
432 this:UnregisterEvent("VARIABLES_LOADED");
433 this:UnregisterEvent("UNIT_NAME_UPDATE");
434  
435 if (Sea) then
436 Sea.util.hook("ChatEdit_OnSpacePressed", "Confab_ChatEdit_OnSpacePressed", "hide");
437 Sea.util.hook("ChatEdit_OnEscapePressed", "Confab_ChatEdit_OnEscapePressed", "replace");
438 Sea.util.hook("ChatEdit_ParseText", "Confab_ChatEdit_ParseText", "before");
439 Sea.util.hook("ChatFrame_OpenChat", "Confab_ChatFrame_OpenChat", "replace");
440 Sea.util.hook("ChatFrame_OnEvent", "Confab_ChatFrame_OnEvent", "after");
441 Sea.util.hook("FCF_Close", "Confab_FCF_Close", "before");
442 Sea.util.hook("FCFMessageTypeDropDown_OnClick", "Confab_FCFMessageTypeDropDown_OnClick", "before");
443 Sea.util.hook("FCF_OpenNewWindow", "Confab_FCF_OpenNewWindow", "after");
444 Sea.util.hook("FCF_SetWindowName", "Confab_FCF_SetWindowName", "after");
445 Sea.util.hook("FCF_Tab_OnClick", "Confab_FCF_Tab_OnClick", "replace"); -- Might have to change this to "hide"
446 Sea.util.hook("FCF_UnDockFrame", "Confab_FCF_UnDockFrame", "after");
447 Sea.util.hook("FCF_DockFrame", "Confab_FCF_DockFrame", "after");
448 Sea.util.hook("FCF_OnUpdate", "Confab_FCF_OnUpdate", "before");
449 else
450 -- Reset these as they might have changed since being loaded.
451 Org_ChatEdit_OnSpacePressed = ChatEdit_OnSpacePressed;
452 Org_ChatEdit_OnEscapePressed = ChatEdit_OnEscapePressed;
453 Org_ChatEdit_ParseText = ChatEdit_ParseText;
454 Org_ChatFrame_OpenChat = ChatFrame_OpenChat;
455 Org_ChatFrame_OnEvent = ChatFrame_OnEvent;
456 Org_FCF_Close = FCF_Close;
457 Org_FCFMessageTypeDropDown_OnClick = FCFMessageTypeDropDown_OnClick;
458 Org_FCF_OpenNewWindow = FCF_OpenNewWindow;
459 Org_FCF_SetWindowName = FCF_SetWindowName;
460 Org_FCF_Tab_OnClick = FCF_Tab_OnClick;
461 Org_FCF_UnDockFrame = FCF_UnDockFrame;
462 Org_FCF_DockFrame = FCF_DockFrame;
463 Org_FCF_OnUpdate = FCF_OnUpdate;
464  
465 ChatEdit_OnSpacePressed = Confab_ChatEdit_OnSpacePressed;
466 ChatEdit_OnEscapePressed = Confab_ChatEdit_OnEscapePressed;
467 ChatEdit_ParseText = Confab_ChatEdit_ParseText;
468 ChatFrame_OpenChat = Confab_ChatFrame_OpenChat;
469 ChatFrame_OnEvent = Confab_ChatFrame_OnEvent;
470 FCF_Close = Confab_FCF_Close;
471 FCFMessageTypeDropDown_OnClick = Confab_FCFMessageTypeDropDown_OnClick;
472 FCF_OpenNewWindow = Confab_FCF_OpenNewWindow;
473 FCF_SetWindowName = Confab_FCF_SetWindowName;
474 FCF_Tab_OnClick = Confab_FCF_Tab_OnClick;
475 FCF_UnDockFrame = Confab_FCF_UnDockFrame;
476 FCF_DockFrame = Confab_FCF_DockFrame;
477 FCF_OnUpdate = Confab_FCF_OnUpdate;
478 end
479  
480  
481 -- ChatLock mod Fix: replace ChatLock_OpenChat from the Chatlock mod with a corrected version.
482 if (ChatLock_OpenChat and CHATLOCK_VERSION) then
483 local version = tonumber(CHATLOCK_VERSION);
484  
485 if (version and version <= 2.1) then
486 ChatLock_OpenChat = Confab_ChatLock_OpenChatFix;
487 end
488 end
489  
490 -- is this a new player, if it is create the entry and make some default assignments
491 if (not ConfabUser[PlayerName]) then
492 ConfabUser[PlayerName] = {};
493 end
494  
495 if (not ConfabUser[PlayerName].currentstyle) then
496 ConfabUser[PlayerName].currentstyle = ConfabStyles[0];
497 end
498  
499 if (ConfabUser[PlayerName].autohide == nil) then
500 ConfabUser[PlayerName].autohide = true;
501 end
502  
503 -- set the default sticky and reset some of the depricated sicky values from prior versions
504 if (not ConfabUser[PlayerName].sticky or ConfabUser[PlayerName].sticky == "auto") then
505 ConfabUser[PlayerName].sticky = "default";
506 elseif (ConfabUser[PlayerName].sticky == "on") then
507 ConfabUser[PlayerName].sticky = "off";
508 elseif (ConfabUser[PlayerName].sticky == "confab") then
509 ChatTypeInfo["OFFICER"].sticky = 1;
510 ChatTypeInfo["CHANNEL"].sticky = 1;
511 end
512  
513 -- set the Raid and Officer menu check boxs to be selected by default
514 if (not ConfabUser[PlayerName]["ChatFrame1"]) then
515 ConfabUser[PlayerName]["ChatFrame1"] = {};
516 ConfabUser[PlayerName]["ChatFrame1"]["RAID"] = 1;
517 ConfabUser[PlayerName]["ChatFrame1"]["OFFICER"] = 1;
518 end
519  
520 if (not ConfabUser.editbox) then
521 ConfabUser.editbox = "ConfabEditBoxArrowsEnabled"
522 end
523  
524 Confab_SetEditBox(getglobal(ConfabUser.editbox));
525  
526 if (ConfabUser[PlayerName].alpha ~= nil) then
527 ConfabSetAlpha(ConfabUser[PlayerName].alpha);
528 end
529  
530 if (ConfabUser[PlayerName].texture) then
531 ConfabSetTexture(ConfabUser[PlayerName].texture);
532 end
533  
534 local relto = ConfabUser[PlayerName].relto;
535 local chatFrame = getglobal(relto);
536 local selDockFrame = SELECTED_DOCK_FRAME:GetName();
537  
538 if (relto and chatFrame.isDocked and selDockFrame ~= relto) then
539 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide, selDockFrame);
540 else
541 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide);
542 end
543  
544 Confab_SetChannelSticky(ChatFrameEditBox)
545  
546 if (ConfabUser[PlayerName].autodock) then
547 Confab:Show();
548 end
549  
550 if (SELECTED_DOCK_FRAME ~= ChatFrame1) then
551 FCF_SelectDockFrame(ChatFrame1);
552 ChatFrameEditBox.chatFrame = ChatFrame1;
553 end
554  
555 InitDone = true;
556 end
557  
558 --
559 -- code that determines whether you want to move or resize the editbox
560 -- If the cursor is in the left most region it resizes to the left
561 -- If the cursor is in the right most region it resizes to the right
562 -- Otherwise the cursor is somewhere in the middle, so do a move
563 --
564 function ConfabMoveOrResize()
565 if (MouseIsOver(ChatFrameEditBox)) then
566 local cx, cy = GetCursorPosition();
567 local scale = ChatFrameEditBox:GetScale();
568  
569 local left = ChatFrameEditBox:GetLeft() * scale;
570 local right = ChatFrameEditBox:GetRight() * scale;
571  
572 local phi = math.floor((right-left)/5);
573  
574 if (cx < (left+phi) and ChatFrameEditBox:IsResizable()) then
575 ChatFrameEditBox:StartSizing("LEFT");
576 return;
577 end
578  
579 if (cx > (right-phi) and ChatFrameEditBox:IsResizable()) then
580 ChatFrameEditBox:StartSizing("RIGHT");
581 return;
582 end
583  
584 if (ChatFrameEditBox:IsMovable()) then
585 ChatFrameEditBox:StartMoving()
586 end
587 end
588 end
589  
590 --
591 -- Save the current frame position so we can put it back there on relog
592 --
593 function ConfabSavePosition()
594 if (not ConfabUser[PlayerName].currentstyle.docked) then
595 ConfabUser[PlayerName].currentstyle.left = ChatFrameEditBox:GetLeft();
596 ConfabUser[PlayerName].currentstyle.top = ChatFrameEditBox:GetTop();
597 ConfabUser[PlayerName].currentstyle.width = ChatFrameEditBox:GetWidth();
598 end
599 end
600  
601 --
602 -- function to handle the Confab slash commands
603 --
604 function ConfabSlashHandler(orgMsg)
605 msg = string.lower(orgMsg);
606 if (msg == "style1") then
607 Confab_SetStyle(ConfabStyles[0], ConfabUser[PlayerName].autohide);
608 elseif (msg == "style2") then
609 Confab_SetStyle(ConfabStyles[1], ConfabUser[PlayerName].autohide);
610 elseif (msg == "style3") then
611 Confab_SetStyle(ConfabStyles[2], ConfabUser[PlayerName].autohide);
612 elseif (msg == "style4") then
613 Confab_SetStyle(ConfabStyles[3], ConfabUser[PlayerName].autohide);
614 elseif (string.find(msg, "^(texture)")) then
615 local _, _, _, _, value = string.find(orgMsg, "^(%a+)(%s+)([^%s]+)");
616 if (not value) then
617 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_TEXTURE_SETTO..ConfabUser[PlayerName].texture);
618 else
619 ConfabSetTexture(value);
620 end
621 elseif (string.find(msg, "^(alpha)")) then
622 local _, _, _, value = string.find(msg, "alpha(%s+)([^%s]+)");
623 local num = tonumber(value);
624 if (num ~= nil) then
625 ConfabSetAlpha(num);
626 else
627 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_ALPHA_SETTO..ChatFrameEditBox:GetAlpha());
628 end
629 elseif (string.find(msg, "^(autohide)")) then
630 local _, _, _, flag = string.find(msg, "autohide(%s+)([^%s]+)");
631 if (flag == nil) then
632 if (ConfabUser[PlayerName].autohide) then
633 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_AUTOHIDE_ON);
634 else
635 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_AUTOHIDE_OFF);
636 end
637 elseif (flag == "on") then
638 ConfabUser[PlayerName].autohide = true;
639 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, true);
640 elseif (flag == "off") then
641 ConfabUser[PlayerName].autohide = false;
642 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, false);
643 end
644 elseif (msg == "undock") then
645 if (ConfabUser[PlayerName].currentstyle.docked) then
646 if (ConfabUser[PlayerName].autodock) then
647 ConfabUser[PlayerName].autodock = false;
648 Confab:Hide();
649 end
650 Confab_SetStyle(ConfabStyles["undock"], ConfabUser[PlayerName].autohide);
651 end
652 elseif (string.find(msg, "^(autodock)")) then
653 local _, _, _, flag = string.find(msg, "autodock(%s+)([^%s]+)");
654 if (flag == nil) then
655 if (Confab:IsVisible()) then
656 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_AUTODOCK_ON);
657 else
658 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_AUTODOCK_OFF);
659 end
660 elseif (flag == "on") then
661 if (ConfabUser[PlayerName].currentstyle.docked) then
662 Confab:Show();
663 elseif (not ConfabUser[PlayerName].autodock) then
664 ConfabUser[PlayerName].relto = nil
665 Confab_SetStyle(ConfabStyles[ConfabUser[PlayerName].oldstyle], ConfabUser[PlayerName].autohide);
666 Confab:Show();
667 end
668 ConfabUser[PlayerName].autodock = true;
669 elseif (flag == "off") then
670 ConfabUser[PlayerName].autodock = false;
671 Confab:Hide();
672 end
673 elseif (string.find(msg, "^(dock)")) then
674 local _, _, _, _, frame = string.find(orgMsg, "^(%a+)(%s+)([^%s]+)");
675  
676 if (frame) then
677 Confab_SetStyle(ConfabStyles[1], ConfabUser[PlayerName].autohide, frame);
678 elseif ((not ConfabUser[PlayerName].currentstyle.docked)) then
679 Confab_SetStyle(ConfabStyles[ConfabUser[PlayerName].oldstyle], ConfabUser[PlayerName].autohide, SELECTED_DOCK_FRAME:GetName());
680 end
681 elseif (msg == "lock") then
682 if (not ConfabUser[PlayerName].currentstyle.locked) then
683 ConfabUser[PlayerName].currentstyle.locked = true;
684 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide);
685 end
686 elseif (msg == "unlock") then
687 if (ConfabUser[PlayerName].currentstyle.locked) then
688 ConfabUser[PlayerName].currentstyle.locked = false;
689 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide);
690 end
691 elseif (msg == "enablearrowkeys") then
692 Confab_SetEditBox(ConfabEditBoxArrowsEnabled);
693 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide);
694 elseif (msg == "disablearrowkeys") then
695 Confab_SetEditBox(ConfabEditBoxArrowsDisabled);
696 Confab_SetStyle(ConfabUser[PlayerName].currentstyle, ConfabUser[PlayerName].autohide);
697 elseif (string.find(msg, "^(chatsticky)")) then
698 ChatTypeInfo["OFFICER"].sticky = 0;
699 ChatTypeInfo["CHANNEL"].sticky = 0;
700 local _, _, _, flag = string.find(msg, "chatsticky(%s+)([^%s]+)");
701 if (flag == nil) then
702 local tmp = string.gsub(ConfabUser[PlayerName].sticky, "%a+(%d%d?)", "%1");
703 if (tmp == ConfabUser[PlayerName].sticky) then
704 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_CURRENTLY_SETTO.. ConfabUser[PlayerName].sticky.."'");
705 else
706 local channelNum, channelName = GetChannelName(tmp);
707 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_CURRENTLY_SETTO.. channelName.."'");
708 end
709 elseif (flag == "off") then
710 ConfabUser[PlayerName].sticky = "off";
711 ChatFrameEditBox.stickyType = "SAY"; -- need to set the sticky to something other then what it was even though its not used
712 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_SETTO.."off'");
713 elseif (flag == "default") then
714 ConfabUser[PlayerName].sticky = "default";
715 ChatFrameEditBox.stickyType = "SAY";
716 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_SETTO.."default'");
717 elseif (flag == "guild" or flag == "officer" or flag == "party" or flag == "raid" or flag == "say") then
718 ConfabUser[PlayerName].sticky = string.upper(flag);
719 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_SETTO.. flag.."'");
720 elseif (flag >= "0" and flag <= "9") then
721 local channelNum, channelName = GetChannelName(flag);
722 if ( channelNum > 0 ) then
723 ConfabUser[PlayerName].sticky = "CHANNEL"..flag;
724 ChatFrameEditBox.stickyType = "SAY";
725 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_SETTO.. channelName.."'");
726 end
727 elseif (flag == "confab") then
728 ChatTypeInfo["OFFICER"].sticky = 1;
729 ChatTypeInfo["CHANNEL"].sticky = 1;
730 ConfabUser[PlayerName].sticky = "confab";
731 ChatFrameEditBox.stickyType = "SAY";
732 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_SETTO.."confab'");
733 end
734 else
735 Confab_Help();
736 end
737 end
738  
739 --
740 -- Confab help
741 --
742 function Confab_Help()
743 DEFAULT_CHAT_FRAME:AddMessage(string.format(CONFAB_USAGE, "/confab"));
744 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_HELP1);
745 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff style1|cff00ff00|||cffffffffstyle2|cff00ff00|||cffffffffstyle3|cff00ff00|||cffffffffstyle4 |cff00ff00"..CONFAB_HELP2);
746 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff autohide on|cff00ff00|||cffffffffoff |cff00ff00"..CONFAB_HELP6);
747 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff undock |r|cff00ff00"..CONFAB_HELP7);
748 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff dock |cff00ff00[|cffffffffframe|cff00ff00] |cff00ff00"..CONFAB_HELP8);
749 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff autodock on|cff00ff00|||cffffffffoff |cff00ff00"..CONFAB_HELP5);
750 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff lock |cff00ff00"..CONFAB_HELP9);
751 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff unlock |cff00ff00"..CONFAB_HELP10);
752 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff chatsticky off|cff00ff00|||cffffffffdefault|cff00ff00|||cffffffffparty|cff00ff00|||cffffffffguild|cff00ff00|||cffffffffraid|cff00ff00|||cffffffffofficer|cff00ff00|||cffffffffsay|cff00ff00|||cffffffff1-10 |cff00ff00"..CONFAB_HELP11);
753 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff enableArrowKeys |cff00ff00"..CONFAB_HELP12);
754 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff disableArrowKeys |cff00ff00"..CONFAB_HELP13);
755 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff texture |cff00ff00"..CONFAB_HELP21);
756 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff alpha |cff00ff00"..CONFAB_HELP22);
757 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_HELP14);
758 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff /tt |cff00ff00"..CONFAB_HELP15);
759 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff /targettell |cff00ff00"..CONFAB_HELP16);
760 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff /telltarget |cff00ff00"..CONFAB_HELP20);
761 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff /rt, /retell |cff00ff00"..CONFAB_HELP17);
762 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff /targetsave, /tsave |cff00ff00"..CONFAB_HELP18);
763 DEFAULT_CHAT_FRAME:AddMessage("|cffffffff /targetrestore, /trestore |cff00ff00"..CONFAB_HELP19);
764 end
765  
766 --
767 -- Set style
768 --
769 function Confab_SetStyle(style, autohide, newrelto)
770 if (newrelto) then
771 ConfabUser[PlayerName].relto = newrelto;
772 end
773  
774 if (style) then
775 ChatFrameEditBox:ClearAllPoints();
776  
777 if (style.docked) then
778 style.locked = true; -- Docked is always locked, so override the style
779 local points = style.dockpoints;
780  
781 local cnt = 0;
782 local point = {};
783  
784 if (points) then
785 point = points[cnt];
786 end
787  
788 while (point) do
789 local basepoint = point.point;
790 if (basepoint == nil) then basepoint = "CENTER"; end;
791  
792 local relto = point.relto;
793 if (relto == nil) then relto = "UIParent"; end;
794  
795 local relpoint = point.relpoint;
796 if (relpoint == nil) then relpoint = "CENTER"; end;
797  
798 local xoff = point.xoff;
799 local yoff = point.yoff;
800 if (xoff == nil) then xoff = 0; end;
801 if (yoff == nil) then yoff = 0; end;
802  
803  
804 if (ConfabUser[PlayerName].relto) then
805 local s, m = pcall(ChatFrameEditBox.SetPoint,ChatFrameEditBox, basepoint, ConfabUser[PlayerName].relto, relpoint, xoff, yoff);
806  
807 if (not s) then -- If we had an error (like invalid framename) then use the template frame name.
808 ConfabUser[PlayerName].relto = nil;
809 DEFAULT_CHAT_FRAME:AddMessage(m);
810 ChatFrameEditBox:SetPoint(basepoint, relto, relpoint, xoff, yoff);
811 else
812 relto = ConfabUser[PlayerName].relto;
813 end
814 else
815 ChatFrameEditBox:SetPoint(basepoint, relto, relpoint, xoff, yoff);
816 end
817  
818 ChatFrameEditBox.dockedTo = relto;
819 ChatFrameEditBox.chatFrame = getglobal(relto);
820 cnt = cnt + 1;
821 point = points[cnt]
822 end
823 else
824 ChatFrameEditBox.chatFrame = SELECTED_DOCK_FRAME;
825 ChatFrameEditBox.dockedTo = nil;
826  
827 if (style.left and style.top) then
828 ChatFrameEditBox:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT", style.left, style.top);
829 else
830 ChatFrameEditBox:SetPoint("CENTER", "UIParent", "CENTER", 0, 0); -- default undocked placement
831 end
832  
833 if (style.width) then
834 ChatFrameEditBox:SetWidth(style.width);
835 else
836 ChatFrameEditBox:SetWidth(400); -- default width
837 end
838 end
839  
840  
841 if (style.info == nil) then style.info = CONFAB_STYLE_UNKNOWN; end;
842 style.text = style.info;
843  
844 if (autohide == nil) then autohide = true; end;
845 if (style.autohide ~= nil) then autohide = style.autohide; end;
846  
847 ConfabUser[PlayerName].autohide = autohide;
848  
849 if (not autohide and not ShowFlag) then
850 ChatFrameEditBox:EnableKeyboard(false);
851 ChatFrameEditBox:Show();
852 Confab_ClearHeader(ChatFrameEditBox);
853 style.text = style.text .. CONFAB_STYLE_NOAUTOHIDE;
854 end
855  
856 if (style.locked) then
857 ChatFrameEditBox:SetMovable(false);
858 ChatFrameEditBox:SetResizable(false);
859 style.text = style.text .. CONFAB_STYLE_LOCKED;
860 else
861 ChatFrameEditBox:SetMovable(true);
862 ChatFrameEditBox:SetResizable(true);
863 style.text = style.text .. CONFAB_STYLE_UNLOCKED
864 end
865  
866 if (ConfabUser[PlayerName].currentstyle.style ~= nil) then
867 ConfabUser[PlayerName].oldstyle = ConfabUser[PlayerName].currentstyle.style; -- remember previous style so we use it when we redock
868 end
869  
870 ConfabUser[PlayerName].currentstyle = style;
871 end
872 end
873  
874 --
875 -- Set editbox artwork alpha (0 is transparent, 1 is full opaque)
876 --
877 function ConfabSetAlpha(alpha)
878 if (alpha < 0 or alpha > 1) then
879 return;
880 end
881  
882 getglobal(ConfabUser.editbox.."Left"):SetAlpha(alpha);
883 getglobal(ConfabUser.editbox.."Middle"):SetAlpha(alpha);
884 getglobal(ConfabUser.editbox.."Right"):SetAlpha(alpha);
885  
886 ConfabUser[PlayerName].alpha = alpha;
887 end
888  
889 --
890 -- Set editbox artwork texture
891 --
892 function ConfabSetTexture(tname)
893 if (tname == nil) then
894 return;
895 end
896  
897 local path = nil;
898  
899 if (string.find(tname, "\\")) then
900 path = tname;
901 else
902 path = "Interface\\AddOns\\Confab\\Textures\\"..tname;
903 end
904  
905 -- clear the current textures so we can reload an existing texture
906 getglobal(ConfabUser.editbox.."Left"):SetTexture("");
907 getglobal(ConfabUser.editbox.."Middle"):SetTexture("");
908 getglobal(ConfabUser.editbox.."Right"):SetTexture("");
909  
910 -- load the new artwork texture
911 getglobal(ConfabUser.editbox.."Left"):SetTexture(path);
912 getglobal(ConfabUser.editbox.."Middle"):SetTexture(path);
913 getglobal(ConfabUser.editbox.."Right"):SetTexture(path);
914  
915 -- save the pathname to the artwork
916 ConfabUser[PlayerName].texture = tname;
917 end
918  
919 --
920 -- Set the frame sticky based on the name
921 -- name can be in the players locale or english
922 --
923 function Confab_SetChatFrameSticky(chatframe, name)
924 if (chatframe ~= ChatFrame1) then
925 chatframe.sticky = nil;
926 local tmp = strupper(name);
927  
928 if (tmp == strupper(CHAT_MSG_GUILD) or tmp == "GUILD") then
929 chatframe.sticky = "GUILD";
930 elseif (tmp == strupper(CHAT_MSG_PARTY) or tmp == "PARTY") then
931 chatframe.sticky = "PARTY";
932 elseif (tmp == strupper(CHAT_MSG_RAID) or tmp == "RAID") then
933 chatframe.sticky = "RAID";
934 elseif (tmp == strupper(CHAT_MSG_OFFICER) or tmp == "OFFICER") then
935 chatframe.sticky = "OFFICER";
936 else
937 local tell = gsub(CHAT_WHISPER_SEND, "%%s", ""); -- get rid of the %s
938 tell = gsub(tell, "%s", ""); -- get rid of all the whitespace
939 tell = gsub(tell, "(%a+):", "%1"); -- match the text that is left minus the :
940 if (string.find(tmp, strupper(tell)) or string.find(tmp, "^(TELL)")) then
941 chatframe.sticky = "WHISPER";
942 end
943 end
944 end
945 end
946  
947  
948 function Confab_SetChannelSticky(editBox)
949 if (editBox.chatFrame) then
950 local chatFrameSticky = editBox.chatFrame.sticky;
951 if (chatFrameSticky) then
952 if (chatFrameSticky ~= editBox.chatType) then
953 local tmp = editBox.chatType;
954 editBox.chatType = chatFrameSticky;
955  
956 if (chatFrameSticky == "WHISPER") then
957 local lastTell = ChatEdit_GetLastTellTarget(editBox);
958  
959 if (strlen(lastTell) > 0) then
960 editBox.tellTarget = lastTell;
961 elseif (not editBox.tellTarget) then
962 editBox.chatType = tmp;
963 end
964 end
965  
966 if (ShowFlag) then
967 ChatEdit_UpdateHeader(editBox);
968 end
969 end
970 elseif (PlayerName and (ConfabUser[PlayerName].sticky == "default" or ConfabUser[PlayerName].sticky == "confab")) then
971 if (editBox.chatFrame.oldChatType) then
972 editBox.chatType = editBox.chatFrame.oldChatType;
973 else
974 editBox.chatType = editBox.stickyType;
975 end
976  
977 if (ShowFlag) then
978 ChatEdit_UpdateHeader(editBox);
979 end
980 elseif (PlayerName and ConfabUser[PlayerName].sticky ~= "off") then
981 local tmp = string.gsub(ConfabUser[PlayerName].sticky, "%a+(%d%d?)", "%1");
982  
983 if (tmp == ConfabUser[PlayerName].sticky) then
984 editBox.chatType = ConfabUser[PlayerName].sticky;
985 else
986 editBox.channelTarget = tonumber(tmp);
987 editBox.chatType = "CHANNEL"
988 end
989  
990 if (ShowFlag) then
991 ChatEdit_UpdateHeader(editBox);
992 end
993 end
994 end
995 end
996  
997  
998 local prevTarget = nil;
999 local isPlayer = nil;
1000 local isFriend = nil;
1001 function Confab_SaveTarget()
1002 if (UnitExists("target")) then
1003 prevTarget = UnitName("target");
1004 isPlayer = UnitIsPlayer("target");
1005 isFriend = UnitIsFriend("player", "target");
1006 else
1007 prevTarget = nil;
1008 isPlayer = nil;
1009 isFriend = nil;
1010 end
1011 end
1012  
1013  
1014 function Confab_LoadTarget()
1015 if (SpellIsTargeting()) then
1016 SpellStopTargeting()
1017 end;
1018  
1019 if (prevTarget == nil) then
1020 ClearTarget();
1021 elseif (isPlayer or (not isPlayer and isFriend)) then
1022 TargetByName(prevTarget)
1023  
1024 if (UnitName("target") ~= prevTarget) then
1025 ClearTarget();
1026 end
1027 else
1028 TargetLastEnemy()
1029 end
1030 end
1031  
1032  
1033 function Confab_GetFriendlyTarget()
1034 local target = UnitName("target");
1035 if (target) then
1036 if (UnitIsFriend("player", "target") and UnitIsPlayer("target") and UnitExists("target")) then
1037 return target;
1038 end
1039 end
1040  
1041 return nil;
1042 end
1043  
1044  
1045 -- The SlashCmdList half of /tt function and for /targettell key bind
1046 function Confab_TT(msg)
1047 if (msg ~= nil and strlen(msg) > 0) then
1048 local target = Confab_GetFriendlyTarget();
1049 if (target) then
1050 SendChatMessage(msg, "WHISPER", GetLanguageByIndex(0), target);
1051 end
1052 return;
1053 end
1054  
1055 local lastname = ChatEdit_GetLastTellTarget(DEFAULT_CHAT_FRAME.editBox);
1056  
1057 if (strlen(lastname) > 0) then
1058 Confab_SaveTarget();
1059  
1060 TargetByName(lastname);
1061  
1062 if (UnitName("target") ~= lastname) then
1063 Confab_LoadTarget();
1064 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_UNABLE_TO_TARGET..lastname);
1065 end
1066 end
1067 end
1068  
1069  
1070 -- Function for /telltarget key bind
1071 function Confab_TellTarget(target)
1072 if (not target) then
1073 target = Confab_GetFriendlyTarget();
1074 end
1075  
1076 if (target) then
1077 ChatFrameEditBox.tellTarget = target;
1078 ChatFrameEditBox.chatType = "WHISPER";
1079 ChatEdit_UpdateHeader(ChatFrameEditBox);
1080 ChatFrame_OpenChat("");
1081 end
1082 end
1083  
1084  
1085 -- Function for /tt key bind
1086 function Confab_TTKeyBind()
1087 local target = Confab_GetFriendlyTarget();
1088 if (target) then
1089 Confab_TellTarget(target);
1090 else
1091 Confab_TT()
1092 end
1093 end
1094  
1095  
1096 -- Function for /rt key bind
1097 function Confab_ReTell()
1098 if (LastSentTellTarget) then
1099 ChatFrameEditBox.tellTarget = LastSentTellTarget;
1100 ChatFrameEditBox.chatType = "WHISPER";
1101 ChatEdit_UpdateHeader(ChatFrameEditBox);
1102 ChatFrame_OpenChat("");
1103 end
1104 end
1105  
1106  
1107 function Confab_OnShow()
1108 if (ShowFlag) then
1109 -- This is needed because of the way Blizzard checks for whether your in a party or not in ChatEdit_OnShow actually doesn't work.
1110 if (this.chatType == "PARTY" and (GetNumPartyMembers() == 0)) then
1111 this.chatType = "SAY";
1112 end
1113 ChatEdit_OnShow();
1114 end
1115 end
1116  
1117  
1118 function Confab_ClearHeader(editBox)
1119 local header = getglobal(editBox:GetName().."Header");
1120 if (header) then
1121 header:SetText("");
1122 editBox:SetTextInsets(-3000, 0, 0, 0); -- since I can't (or don't know how to) disable the cursor, I'll just move it off the scrren
1123 end
1124 end
1125  
1126  
1127 ------------------------------------------------------------------------------------------------------------
1128 -- start of the function hook methods
1129 ------------------------------------------------------------------------------------------------------------
1130 function Confab_IsVisible(obj)
1131 return ShowFlag;
1132 end
1133  
1134  
1135 function Confab_Hide(obj)
1136 if (ConfabUser[PlayerName].autohide) then
1137 obj:Org_Hide();
1138 else
1139 obj:ClearFocus()
1140 Confab_ClearHeader(obj);
1141 obj:EnableKeyboard(false);
1142 end
1143 end
1144  
1145  
1146 -- Function from the Chatlock mod, this is a corrected version of it.
1147 function Confab_ChatLock_OpenChatFix()
1148 ChatFrame_OpenChat();
1149 Org_ChatLock_OpenChat();
1150 end
1151  
1152  
1153 -- This makes editing most command history lines possible otherwise ChatEdit_ParseText eats the text.
1154 local SpacePressedFlag = false;
1155 Confab_ChatEdit_OnSpacePressed = function()
1156 local text = ChatFrameEditBox:GetText();
1157 local spccnt = 0;
1158  
1159 for w in string.gfind(text, "%s+") do
1160 spccnt = spccnt + 1;
1161 if (spccnt > 2) then return false; end;
1162 end
1163  
1164 SpacePressedFlag = true;
1165  
1166 if (not Sea) then
1167 Org_ChatEdit_OnSpacePressed()
1168 else
1169 return true;
1170 end
1171 end
1172  
1173  
1174 Confab_ChatEdit_OnEscapePressed = function(editBox)
1175 if (editBox.chatFrame and not editBox.chatFrame.sticky) then
1176 if (ConfabUser[PlayerName].sticky == "default" or ConfabUser[PlayerName].sticky == "confab") then
1177 editBox.chatType = editBox.stickyType;
1178 elseif (ConfabUser[PlayerName].sticky == "off") then
1179 editBox.stickyType = "SAY";
1180 else
1181 Confab_SetChannelSticky(editBox)
1182 editBox.stickyType = "SAY";
1183 end
1184 else
1185 Confab_SetChannelSticky(editBox);
1186 editBox.stickyType = "SAY";
1187 end
1188  
1189  
1190 if (not Sea) then
1191 local chatType = editBox.chatType;
1192 Org_ChatEdit_OnEscapePressed(editBox)
1193 editBox.chatType = chatType;
1194 else
1195 editBox:SetText("");
1196 editBox:Hide();
1197 end
1198  
1199 ShowFlag = false;
1200 end
1201  
1202  
1203 Confab_ChatEdit_ParseText = function(editBox, send)
1204 local text = editBox:GetText();
1205  
1206 if (strlen(text) > 0 and strsub(text, 1, 1) ~= "/") then
1207 if (send == 1 and editBox.chatType == "WHISPER") then
1208 LastSentTellTarget = editBox.tellTarget;
1209 end
1210 end
1211  
1212 if (strlen(text) > 0 and send == 0 and SpacePressedFlag) then
1213 SpacePressedFlag = false;
1214 local command = strupper(gsub(text, "/([^%s]+)(.*)", "/%1", 1));
1215 if (command == strupper(SLASH_TT) or command == strupper(SLASH_TELLTARGET)) then
1216 local target = Confab_GetFriendlyTarget();
1217 if (target) then
1218 editBox.tellTarget = target;
1219 editBox.chatType = "WHISPER";
1220 editBox:SetText("");
1221 ChatEdit_UpdateHeader(editBox);
1222 end
1223 elseif (command == strupper(SLASH_RT) or command == strupper(SLASH_RETELL)) then
1224 if (LastSentTellTarget) then
1225 editBox.tellTarget = LastSentTellTarget;
1226 editBox.chatType = "WHISPER";
1227 editBox:SetText("");
1228 ChatEdit_UpdateHeader(editBox);
1229 end
1230 end
1231 end
1232  
1233 if (not Sea) then
1234 Org_ChatEdit_ParseText(editBox, send);
1235 end
1236 end
1237  
1238  
1239 Confab_ChatFrame_OpenChat = function(text, chatFrame)
1240 if ( not chatFrame ) then
1241 chatFrame = DEFAULT_CHAT_FRAME;
1242 end
1243  
1244 if (chatFrame.editBox.chatType == "CHANNEL") then
1245 local channelNum, channelName = GetChannelName(chatFrame.editBox.channelTarget);
1246 if (channelNum <= 0) then
1247 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_CHAN_INVALID1);
1248 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_CHAN_INVALID2);
1249 chatFrame.editBox.chatType = "SAY"
1250 local tmp = string.gsub(ConfabUser[PlayerName].sticky, "%a+(%d%d?)", "%1");
1251 if (tmp >= "0" and tmp <= "9") then
1252 DEFAULT_CHAT_FRAME:AddMessage(CONFAB_STICKY_CHAN_INVALID3);
1253 ConfabUser[PlayerName].sticky = "default";
1254 end
1255 end
1256 end
1257  
1258 ShowFlag = true;
1259 chatFrame.editBox:EnableKeyboard(true);
1260 chatFrame.editBox:SetFocus();
1261  
1262 if (not Sea) then
1263 local type = chatFrame.editBox.chatType;
1264 local sticky = chatFrame.editBox.stickyType;
1265  
1266 chatFrame.editBox.stickyType = "SAY";
1267 Org_ChatFrame_OpenChat(text, chatFrame);
1268  
1269 chatFrame.editBox.stickyType = sticky;
1270 chatFrame.editBox.chatType = type;
1271 else
1272 chatFrame.editBox.setText = 1;
1273 chatFrame.editBox.text = text;
1274 end
1275  
1276 if (not ConfabUser[PlayerName].autohide) then
1277 local tmp = this;
1278 this = chatFrame.editBox;
1279 Confab_OnShow();
1280 this = tmp;
1281 else
1282 chatFrame.editBox:Show();
1283 end
1284  
1285 if ((chatFrame.editBox.stickyType == "PARTY") and (GetNumPartyMembers() == 0) ) then
1286 if (chatFrame.editBox.chatType ~= "WHISPER") then -- Fix for the reply bug after leaving a party when using the default chat sticky setting
1287 chatFrame.editBox.chatType = "SAY";
1288 ChatEdit_UpdateHeader(chatFrame.editBox);
1289 end
1290 elseif ((chatFrame.editBox.stickyType == "RAID") and (GetNumRaidMembers() == 0) ) then
1291 if (chatFrame.editBox.chatType ~= "WHISPER") then -- Fix for the reply bug after leaving a party when using the default chat sticky setting
1292 chatFrame.editBox.chatType = "SAY";
1293 ChatEdit_UpdateHeader(chatFrame.editBox);
1294 end
1295 end
1296 end
1297  
1298  
1299 -- makes sure the GM help ticket editbox gets focus
1300 local OrgHelpFrameOpenTicketShow = HelpFrameOpenTicket.Show;
1301 HelpFrameOpenTicket.Show = function(obj)
1302 OrgHelpFrameOpenTicketShow(obj);
1303 HelpFrameOpenTicketText:SetFocus();
1304 end;
1305  
1306  
1307 Confab_ChatFrame_OnEvent = function(event)
1308 if (not Sea) then
1309 Org_ChatFrame_OnEvent(event);
1310 end
1311  
1312 if ((event == "CHAT_MSG_PARTY" or event == "CHAT_MSG_GUILD" or
1313 event == "CHAT_MSG_OFFICER" or event == "CHAT_MSG_RAID") and this ~= ChatFrame1) then
1314 FCF_FlashTab();
1315 end
1316 end
1317  
1318  
1319 Confab_FCF_Close = function(frame)
1320 if ( not frame ) then
1321 frame = FCF_GetCurrentChatFrame();
1322 end
1323  
1324 -- Check to see if we are closing the window the edit box is docked to.
1325 if (frame.editBox.dockedTo == frame:GetName()) then
1326 ConfabUser[PlayerName].relto = nil;
1327 Confab_SetStyle(ConfabStyles[ConfabUser[PlayerName].oldstyle], ConfabUser[PlayerName].autohide);
1328 elseif (frame.editBox.chatFrame == frame) then
1329 frame.editBox.chatFrame = ChatFrame1;
1330 Confab_SetChannelSticky(ChatFrameEditBox);
1331 end
1332  
1333 if (not Sea) then
1334 Org_FCF_Close(frame);
1335 end
1336 end
1337  
1338  
1339 Confab_FCFMessageTypeDropDown_OnClick = function()
1340 -- For some reason the game refuses to save these in chat-cache.txt so I have to save them myself.
1341 if (this.value == "RAID" or this.value == "OFFICER") then
1342 local checked = UIDropDownMenuButton_GetChecked();
1343 local chatFrameName = FCF_GetCurrentChatFrame():GetName();
1344  
1345 if (not ConfabUser[PlayerName][chatFrameName]) then
1346 ConfabUser[PlayerName][chatFrameName] = {};
1347 end
1348  
1349 if (checked) then
1350 ConfabUser[PlayerName][chatFrameName][this.value] = nil;
1351 else
1352 ConfabUser[PlayerName][chatFrameName][this.value] = 1;
1353 end
1354 end
1355  
1356 if (not Sea) then
1357 Org_FCFMessageTypeDropDown_OnClick();
1358 end
1359 end
1360  
1361  
1362 Confab_FCF_OpenNewWindow = function(name)
1363 if (not Sea) then
1364 Org_FCF_OpenNewWindow(name);
1365 end
1366  
1367 local chatFrame;
1368 local chatTab;
1369 local frameName;
1370  
1371 for i=1, NUM_CHAT_WINDOWS do
1372 chatFrame = getglobal("ChatFrame"..i);
1373 chatTab = getglobal("ChatFrame"..i.."Tab");
1374 frameName = chatFrame:GetName();
1375 if (chatTab:GetText() == name) then
1376 ChatFrame_AddMessageGroup(chatFrame, "OFFICER");
1377 ChatFrame_AddMessageGroup(chatFrame, "RAID");
1378  
1379 if (not ConfabUser[PlayerName][frameName]) then
1380 ConfabUser[PlayerName][frameName] = {};
1381 end
1382 ConfabUser[PlayerName][frameName]["RAID"] = 1;
1383 ConfabUser[PlayerName][frameName]["OFFICER"] = 1;
1384 return;
1385 end
1386 end
1387 end
1388  
1389  
1390 Confab_FCF_SetWindowName = function(frame, name, doNotSave)
1391 if (not Sea) then
1392 Org_FCF_SetWindowName(frame, name, doNotSave);
1393 end
1394 Confab_SetChatFrameSticky(frame, name);
1395 Confab_SetChannelSticky(ChatFrameEditBox);
1396 end
1397  
1398  
1399 local prevChatFrameTab = nil;
1400 Confab_FCF_Tab_OnClick = function(button)
1401 if (button == "RightButton" and FCF_Get_ChatLocked()) then
1402 return;
1403 end
1404  
1405 --if (not Sea) then
1406 Org_FCF_Tab_OnClick(button);
1407 --end
1408  
1409 if (prevChatFrameTab) then
1410 prevChatFrameTab:EnableMouse(true);
1411 prevChatFrameTab = nil;
1412 end
1413  
1414 local chatFrame = getglobal("ChatFrame"..this:GetID());
1415 local buttonState = this:GetButtonState();
1416  
1417 if ((buttonState == "NORMAL" and chatFrame.isDocked) or
1418 (buttonState == "PUSHED" and FCF_Get_ChatLocked() and chatFrame.isDocked)) then
1419 if (not ChatFrameEditBox.chatFrame.sticky) then
1420 ChatFrameEditBox.chatFrame.oldChatType = ChatFrameEditBox.chatType;
1421 end
1422 ChatFrameEditBox.chatFrame = chatFrame;
1423 Confab_SetChannelSticky(ChatFrameEditBox);
1424 end
1425  
1426 if (FCF_Get_ChatLocked()) then
1427 prevChatFrameTab = this;
1428 this:EnableMouse(false);
1429 end
1430 end
1431  
1432  
1433 Confab_FCF_UnDockFrame = function(frame)
1434 if (not Sea) then
1435 Org_FCF_UnDockFrame(frame);
1436 end
1437  
1438 if (ChatFrameEditBox.dockedTo ~= frame:GetName()) then
1439 ChatFrameEditBox.chatFrame = SELECTED_DOCK_FRAME;
1440 Confab_SetChannelSticky(ChatFrameEditBox);
1441 end
1442 end
1443  
1444  
1445 Confab_FCF_DockFrame = function(frame, index)
1446 if (not Sea) then
1447 Org_FCF_DockFrame(frame, index);
1448 end
1449  
1450 ChatFrameEditBox.chatFrame = SELECTED_DOCK_FRAME;
1451 Confab_SetChannelSticky(ChatFrameEditBox);
1452 end
1453  
1454  
1455 Confab_FCF_OnUpdate = function(elapsed)
1456 if (prevChatFrameTab and not FCF_Get_ChatLocked()) then
1457 prevChatFrameTab:EnableMouse(true);
1458 prevChatFrameTab = nil;
1459 end
1460  
1461 if (not Sea) then
1462 Org_FCF_OnUpdate(elapsed);
1463 end
1464 end