Thread Tools Display Modes
05-01-08, 05:08 PM   #1
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
Hiding ALL chat windows

Is there a way to hide all chat windows, including the General Chat Window? I have only been able to find ChatFrame1 ,2 ,3 etc. but I cant seem to find the name of the General Chat Window object/frame, nor whether it can be hidden or at least collapsed to minimum size.

Thanks
__________________
Everglow - Sisters of Elune/US
  Reply With Quote
05-02-08, 05:20 AM   #2
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
You have 3 frames to hide for each of the (up to 10) chat frames:

ChatFrameX
ChatFrameXTab
ChatFrameXTabDockRegion

(where X has to be replaced with whatever integer is the ID of the frame you want to hide, from 1 to 10)

The chat frames will keep showing up from time to time on some events if you do that, so you have to do prevent them from showing up while you want them hidden (and cancel that afterward). An option is to set their "OnShow" script to call the "Hide()" method, so that a frame will hide every time it's shown.
  Reply With Quote
05-03-08, 01:43 AM   #3
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
Thank you Layrajha... you helped me a lot with your reply.
__________________
Everglow - Sisters of Elune/US
  Reply With Quote
05-03-08, 04:15 AM   #4
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
Unhappy

Ok... here is what I came up with for my table

Code:
13  for i = 1,7 do
14      CTChatWindows[i] = {}
15      CTChatWindows[i]["tab"] = {}
16      CTChatWindows[i]["main"] = {}
17      CTChatWindows[i]["region"] = {}
18      setmetatable(CTChatWindows[i]["tab"], {__index = getglobal("ChatFrame"..i.."Tab")})
19      setmetatable(CTChatWindows[i]["main"], {__index = getglobal("ChatFrame"..i)})
20      setmetatable(CTChatWindows[i]["region"], {__index = getglobal("ChatFrame"..i.."TabDockRegion")})
21      CTChatWindows[i]["default"] = CTChatWindows[i]["tab"]:IsShown()
22      CTChatWindows[i]["showing"] = CTChatWindows[i]["tab"]:IsShown()
23  end
24  CTChatWindows["auto"] = true
I run into an error on line 21: Attempt to find 'this' in non-framescript object.

As I understand it, if I set a global frame as a prototype, any attempt at calling a function that doesn't exist in my table will look up and execute the function in the prototype. What am I missing here? What is the proper way to set this up?
__________________
Everglow - Sisters of Elune/US
  Reply With Quote
05-03-08, 04:54 AM   #5
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Everglow View Post
Ok... here is what I came up with for my table

Code:
13  for i = 1,7 do
14      CTChatWindows[i] = {}
15      CTChatWindows[i]["tab"] = {}
16      CTChatWindows[i]["main"] = {}
17      CTChatWindows[i]["region"] = {}
18      setmetatable(CTChatWindows[i]["tab"], {__index = getglobal("ChatFrame"..i.."Tab")})
19      setmetatable(CTChatWindows[i]["main"], {__index = getglobal("ChatFrame"..i)})
20      setmetatable(CTChatWindows[i]["region"], {__index = getglobal("ChatFrame"..i.."TabDockRegion")})
21      CTChatWindows[i]["default"] = CTChatWindows[i]["tab"]:IsShown()
22      CTChatWindows[i]["showing"] = CTChatWindows[i]["tab"]:IsShown()
23  end
24  CTChatWindows["auto"] = true
I run into an error on line 21: Attempt to find 'this' in non-framescript object.

As I understand it, if I set a global frame as a prototype, any attempt at calling a function that doesn't exist in my table will look up and execute the function in the prototype. What am I missing here? What is the proper way to set this up?
I don't quite understand what your trying to achieve. If you want to hide all chat frames couldn't you just do:

Code:
local g = getfenv(0)

local function hideforever(frame)
    frame:SetScript("OnShow", frame.Hide)
    frame:Hide()
end

for i = 1, 7 do
    hideforever(g["ChatFrame"..i])
    hideforever(g["ChatFrame"..i.."Tab")
    hideforever(g["ChatFrame"..i.."TabDockRegion")
end
  Reply With Quote
05-03-08, 12:57 PM   #6
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
Thanks for the pointers, Slakah!

I've been looking at the global environment as an option, but hadn't tried implementing it yet (still learning the ins and outs of Lua)

In any case, I only want to hide the frames while in combat. I need to be able to switch out their OnShow, and run their IsShown, Show, and Hide functions so my questions are:

1. How can I store global frames in a table in such a way as to run its methods?
-- that is what I was trying to do in my code sample
2. Is there a way to copy a method to a local using the global environment?

or can I simply use
Code:
function ORIG_OnShow = g["ChatFrame"..i].OnShow
to save it and
Code:
g["ChatFrame"..i]:OnShow()
to run it?
__________________
Everglow - Sisters of Elune/US

Last edited by Everglow : 05-03-08 at 01:16 PM. Reason: add info
  Reply With Quote
05-03-08, 02:58 PM   #7
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Everglow View Post
1. How can I store global frames in a table in such a way as to run its methods?
it would be simply

Code:
local frames = {}
for i = 1,7 do
   frames[i] = getglobal("ChatFrame"..i)
end
or


Code:
local frames = {}
local g = getfenv(0)
for i = 1, 7 do 
   frames[i] = g["ChatFrame"..i]
end
I think the second method is moderately faster.

Then to say hide the frame do.

Code:
 frames.1:Hide()
or to hide all of them

Code:
 for i,v in ipairs(frames) do
   v:Hide()
end
2. Is there a way to copy a method to a local using the global environment?

http://www.wowwiki.com/index.php?tit...pt&action=edit

:GetScript("handle")
  Reply With Quote
05-03-08, 09:39 PM   #8
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
I actually couldn't get that to work, so I hooked the Chat_Frame_OnUpdate event handler, which is much simpler, and seems to work fine. hidden is just a boolean that indicates whether I'm hiding the frames or not. Thanks again for the input.

Code:
 
local ORIG_ChatFrame_OnUpdate = ChatFrame_OnUpdate
function ChatFrame_OnUpdate()
   if (hidden) then
      this:Hide()
   else
      ORIG_ChatFrame_OnUpdate()
   end
end
__________________
Everglow - Sisters of Elune/US

Last edited by Everglow : 05-03-08 at 09:40 PM. Reason: typo
  Reply With Quote
05-03-08, 09:44 PM   #9
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
Smile

For anyone interested, the addon is called ChatToggle, which is now available here
__________________
Everglow - Sisters of Elune/US
  Reply With Quote
05-04-08, 01:24 AM   #10
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
Originally Posted by Slakah View Post
I think the second method is moderately faster.
Yes, the second method is faster, though it should be pointed out that you should use the standard name _G, not the lowercase g you used, just to follow convention. Similarly, you should use the Blizzard-supplied _G available. To localize it, just do "local _G = _G"

Originally Posted by Slakah View Post
Then to say hide the frame do.

Code:
 frames.1:Hide()
This is illegal. You meant
Code:
frames[1]:Hide()
You also run into the problem of "what if they have more than 7 chat tabs?" Your best way of doing it would be:

Code:
local _G = _G
local x = 0;
repeat
   x = x + 1;
   local this = _G["ChatFrame"..x];
   if this then this:Hide() end;
until not this
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote
05-04-08, 03:45 AM   #11
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
This mod will remove all the chat frames from your interface while in combat, to avoid problems of clicking in dead spots.
tekChatBorderFix

Also why are you hooking OnUpdate, why not just set OnShow to hide the frame.
  Reply With Quote
05-04-08, 04:25 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Shirik View Post
You also run into the problem of "what if they have more than 7 chat tabs?"
You can only have up to 7 chat frames, iirc.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-05-08, 01:18 PM   #13
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
Originally Posted by Slakah View Post
tekChatBorderFix

Also why are you hooking OnUpdate, why not just set OnShow to hide the frame.
Well, my mod has the added bonus of making the screen less cluttered when in combat. Besides, even with Tekkub's fix, you might hover over a link in chat, or click on one, potentially popping up a big tooltip.

As to why I hooked OnUpdate, it's because otherwise I would have to set/reset 21 API scripts every time combat started/ended, meaning copying them to yet another table. Besides, it's more efficient to add a couple of instructions to a global handler (ie. the only added memory writes are to the cpu registers) than to be rewriting (in RAM) a frame event handler many times during play.
__________________
Everglow - Sisters of Elune/US
  Reply With Quote
05-06-08, 05:49 AM   #14
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
Originally Posted by Seerah View Post
You can only have up to 7 chat frames, iirc.
Isn't there a global variable for that anyway? Like MAX_CHAT_FRAMES or something like that? I remember something like that in ChatFrame.lua, even though it's quite old.

Also, I'm surprised that hooking only 1 function is enough for preventing the frames to show. From what I remembered, zoning would show the frames even if the OnUpdate function was hooked, etc. I remember that I hooked at least 3 functions before I was given a hint about the "OnShow = Hide" thing.
  Reply With Quote
05-06-08, 01:29 PM   #15
Everglow
An Aku'mai Servant
 
Everglow's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 36
Originally Posted by Layrajha View Post
Isn't there a global variable for that anyway? Like MAX_CHAT_FRAMES or something like that? I remember something like that in ChatFrame.lua, even though it's quite old.
There is a constant ("NUM_CHAT_WINDOWS" = 10) but when I used it, I received errors after 7. Apparently the game only constructs 7 instances of the parent.

Originally Posted by Layrajha View Post
Also, I'm surprised that hooking only 1 function is enough for preventing the frames to show. From what I remembered, zoning would show the frames even if the OnUpdate function was hooked, etc. I remember that I hooked at least 3 functions before I was given a hint about the "OnShow = Hide" thing.
In my limited testing, since hooking OnUpdate I haven't run into any circumstances where any ChatFrames reappear, including subzoning. I haven't tested a major zone change in combat yet (it's still Beta).

(I'm really hoping you'll install the addon and try some things out, Layrajha )
__________________
Everglow - Sisters of Elune/US
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Hiding ALL chat windows

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off