WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Undocking ChatFrame? (https://www.wowinterface.com/forums/showthread.php?t=58829)

Zax 07-05-21 09:51 AM

Undocking ChatFrame?
 
Hello,

As often Shadowlands loose my chat windows configuration, I'm trying to write a little LUA script to rebuild my chat frames.
I'm creating a new chat frame, say for example "Guild" and I would like this new chat frame to be undocked. I have the following code:
Code:

local frame = FCF_OpenNewWindow("Guild")

FCF_UnDockFrame(frame)
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", ChatFrame1, "TOPRIGHT", 60, 0)--***
frame:SetWidth(ChatFrame1:GetWidth())
frame:SetHeight(ChatFrame1:GetHeight())
FCF_UpdateButtonSide(frame)-- ???
FCF_SavePositionAndDimensions(frame)

The chat frame is well created at the right of the ChatFrame1, but its tab stays docked. :(




Another question: is there a way to reset all chats without the confirmation alert showned by FCF_ResetAllWindows()?

Thank you.

Fizzlemizz 07-05-21 10:35 AM

Quote:

is there a way to reset all chats without the confirmation...
Code:

FCF_ResetChatWindows()
For the tab you could try something like
Lua Code:
  1. local tab = _G[frame:GetName().."Tab"]
  2. tab:ClearAllPoints()
  3. tab:SetPoint("point", frame, "topoint", x, y)

But I'm not sure if the tab manager might not try to re-aquire it at some point so...

Zax 07-05-21 12:12 PM

Seems to work :) (though I was afraid it was just a cosmetic trick).
Thanks Fizzlemizz.

Still another question:
I'm unable to check with LUA the following checked channels (sorry, my UI is french localized):



I tried ChatFrame_AddMessageGroup(frame, value) with following values
"BG_SYSTEM_NEUTRAL", "BG_SYSTEM_ALLIANCE", "BG_SYSTEM_HORDE" and "BN_ALERT" without success.

Kanegasi 07-05-21 08:59 PM

You need to use the ChatTypeGroups, which are the table keys that include the message types themselves.

https://www.townlong-yak.com/framexm...tFrame.lua#131

If you want to add a single message type, use ChatFrame_AddSingleMessageType. There is no remove single message type function.

As for your code that enforces a chatframe, here's what I use if you want to pick it apart:

Standard docked creation:

Lua Code:
  1. -- 1 is the "default" frame where print() goes
  2. -- 2 is combat log
  3. -- 3 has been taken by the new Voice Text-to-Speech functionality
  4. -- you can still technically use 3, but the tab text is going to be purple
  5. local frame=ChatFrame4
  6. _G[frame:GetName().."Tab"].sizePadding=0
  7. FCF_SetWindowName(frame,"TAB NAME")
  8. FCF_SetWindowColor(frame,0,0,0)
  9. FCF_SetWindowAlpha(frame,0)
  10. FCF_UnDockFrame(frame)
  11. frame:SetClampRectInsets(0,0,0,0)
  12. PixelUtil.SetSize(frame,400,80)
  13. frame:ClearAllPoints()
  14. frame:SetPoint("BOTTOMLEFT",
  15.     PixelUtil.GetNearestPixelSize(3,frame:GetEffectiveScale()),
  16.     PixelUtil.GetNearestPixelSize(252,frame:GetEffectiveScale())
  17. )
  18. frame:SetUserPlaced(true)
  19. FCF_SavePositionAndDimensions(frame)
  20. FCF_DockFrame(frame,frame:GetID())
  21. frame.isStaticDocked=true
  22. FCF_SetUninteractable(frame,false)
  23. frame:Show()
  24. SetChatWindowShown(frame:GetID(),true)

Standard undocked creation:

Lua Code:
  1. local frame=ChatFrame5
  2. _G[frame:GetName().."Tab"].sizePadding=0
  3. FCF_SetWindowName(frame,"TAB NAME")
  4. FCF_SetWindowColor(frame,0,0,0)
  5. FCF_SetWindowAlpha(frame,0)
  6. FCF_UnDockFrame(frame)
  7. frame:SetClampRectInsets(0,0,0,0)
  8. PixelUtil.SetSize(frame,400,80)
  9. frame:ClearAllPoints()
  10. frame:SetPoint("BOTTOMLEFT",
  11.     PixelUtil.GetNearestPixelSize(3,frame:GetEffectiveScale()),
  12.     PixelUtil.GetNearestPixelSize(86,frame:GetEffectiveScale())
  13. )
  14. frame:SetUserPlaced(true)
  15. FCF_SavePositionAndDimensions(frame)
  16. FCF_SetLocked(frame,true)
  17. FCF_SetUninteractable(frame,false)
  18. frame:Show()
  19. SetChatWindowShown(frame:GetID(),true)

Along with some other code, including my own border and background, in tandem with Prat, this is what my chat looks like:



Some notes:
  • SetClampRectInsets allows the chat to sit right on the edge of the screen. In the screenshot, that is the lower left of my screen. The chatframes are exactly one pixel away from the edge.
  • PixelUtil functions automatically figure out the math behind pixel perfect sizing and placement, since my UI scale isn't 1.
  • The undock usage right before docking for the docked creation was necessary to prevent some weirdness, but I don't remember how or what since I've been using this setup for several expansions.
  • The rest of the functions all copy what the UI does when setting up chat frames, ensuring everything is covered and the frames are accepted.

Zax 07-06-21 05:38 AM

Great ! Thank you very much Kanegasi :)

After some quick tests, FCF_UnDockFrame(frame) doesn't seem to be called for a docked frame.

Concerning "Blizzard Alerts" channel, its real name is in fact "BN_INLINE_TOAST_ALERT".


All times are GMT -6. The time now is 11:07 PM.

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