WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Hiding ALL chat windows (https://www.wowinterface.com/forums/showthread.php?t=16134)

Everglow 05-01-08 05:08 PM

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 :)

Layrajha 05-02-08 05:20 AM

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.

Everglow 05-03-08 01:43 AM

Thank you Layrajha... you helped me a lot with your reply. :)

Everglow 05-03-08 04:15 AM

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?

Slakah 05-03-08 04:54 AM

Quote:

Originally Posted by Everglow (Post 90275)
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


Everglow 05-03-08 12:57 PM

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?

Slakah 05-03-08 02:58 PM

Quote:

Originally Posted by Everglow (Post 90301)
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")

Everglow 05-03-08 09:39 PM

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 05-03-08 09:44 PM

For anyone interested, the addon is called ChatToggle, which is now available here

Shirik 05-04-08 01:24 AM

Quote:

Originally Posted by Slakah (Post 90304)
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"

Quote:

Originally Posted by Slakah (Post 90304)
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


Slakah 05-04-08 03:45 AM

Quote:

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.

Seerah 05-04-08 04:25 PM

Quote:

Originally Posted by Shirik (Post 90317)
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.

Everglow 05-05-08 01:18 PM

Quote:

Originally Posted by Slakah (Post 90319)
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.

Layrajha 05-06-08 05:49 AM

Quote:

Originally Posted by Seerah (Post 90345)
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.

Everglow 05-06-08 01:29 PM

Quote:

Originally Posted by Layrajha (Post 90458)
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.

Quote:

Originally Posted by Layrajha (Post 90458)
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 ;))


All times are GMT -6. The time now is 07:49 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI