ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Search/Requests (https://www.esoui.com/forums/forumdisplay.php?f=165)
-   -   Hide chat in menu (https://www.esoui.com/forums/showthread.php?t=4173)

Balver 12/28/14 10:18 PM

Hide chat in menu
 
I'm looking for an addon that automatically hides the chat window when I open a menu or use the bank or a crafting station.

Ayantir 12/29/14 07:35 AM

could add this into pChat .. will have a look on it.

Baertram 01/03/15 02:56 PM

Maybe this helps. Taken from the gamemenu scene source code "here"

Lua Code:
  1. local wasChatMaximized
  2. local function OnShow(gameMenu)
  3.     RebuildTree(gameMenu)
  4.     wasChatMaximized = not CHAT_SYSTEM:IsMinimized()
  5.     if wasChatMaximized then
  6.         CHAT_SYSTEM:Minimize()
  7.     end
  8. end
  9. local function OnHide(gameMenu)
  10.     if wasChatMaximized and CHAT_SYSTEM:IsMinimized()then
  11.         CHAT_SYSTEM:Maximize()
  12.     end
  13.     wasChatMaximized = nil
  14. end

Too bad it is local :-( But maybe you can use this code of CHAT_SYSTEM to simply hide (Minimize) /show (Maximize) the chat.

Garkin 01/03/15 04:05 PM

Quote:

Originally Posted by Baertram (Post 18129)
Maybe this helps. Taken from the gamemenu scene source code "here"

Lua Code:
  1. local wasChatMaximized
  2. local function OnShow(gameMenu)
  3.     RebuildTree(gameMenu)
  4.     wasChatMaximized = not CHAT_SYSTEM:IsMinimized()
  5.     if wasChatMaximized then
  6.         CHAT_SYSTEM:Minimize()
  7.     end
  8. end
  9. local function OnHide(gameMenu)
  10.     if wasChatMaximized and CHAT_SYSTEM:IsMinimized()then
  11.         CHAT_SYSTEM:Maximize()
  12.     end
  13.     wasChatMaximized = nil
  14. end

Too bad it is local :-( But maybe you can use this code of CHAT_SYSTEM to simply hide (Minimize) /show (Maximize) the chat.

It is local, but if you take a look how those functions are used:

xml Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="ZO_GameMenu_InGame" inherits="ZO_GameMenu_Template" hidden="true">
  4.             <OnInitialized>
  5.                 ZO_GameMenu_InGame_Initialize(self)
  6.             </OnInitialized>
  7.         </TopLevelControl>
  8.     </Controls>
  9. </GuiXml>

Lua Code:
  1. function ZO_GameMenu_InGame_Initialize(self)
  2.     local GAME_MENU_INGAME = ZO_GameMenu_Initialize(self, OnShow, OnHide)
  3.  
  4.     --some other code
  5. end

Lua Code:
  1. function ZO_GameMenu_Initialize(control, onShowFunction, onHideFunction)
  2.     local gameMenu = ZO_GameMenuManager:New(control)
  3.     control.OnShow = onShowFunction
  4.     control.OnHide = onHideFunction
  5.     control.gameMenu = gameMenu
  6.     return gameMenu
  7. end

You can see, that there is a global reference to those functions:
Code:

ZO_GameMenu_InGame:OnShow()
ZO_GameMenu_InGame:OnHide()


Baertram 01/03/15 04:29 PM

Yes, I saw this before, thanks Garkin.

The OnHide function should be fine.
But the OnShow function of the "game menu ingame" in total isn't the thing needed here as it would also rebuild the game menu tree.

I think you could simply use the CHAT_SYSTEM:Maximize() and CHAT_SYSTEM:Minimize() functions here to show/hide the chat as a bank/crafting station/etc. scene gets to the state OnShown e.g.

Ayantir 01/03/15 04:37 PM

I'm already working on this. I prehook SCENE_MANAGER:SetState() and use CHAT_SYSTEM:Minimize() and :Maximize() for my part.

Just need to disable it at 1st state (when addon loads) and check if scene manager is on "hudui" or not.

Garkin 01/03/15 05:24 PM

Quote:

Originally Posted by Ayantir (Post 18134)
I'm already working on this. I prehook SCENE_MANAGER:SetState() and use CHAT_SYSTEM:Minimize() and :Maximize() for my part.

Just need to disable it at 1st state (when addon loads) and check if scene manager is on "hudui" or not.

Usually everything, what you want to do when scene is showing or hiding, is done by registering to StateChange callback, something like:
Lua Code:
  1. local function OnStateChange(oldState, newState)
  2.     if newState == SCENE_SHOWING then
  3.         CHAT_SYSTEM:Minimize()
  4.     elseif newState == SCENE_HIDDEN then
  5.         CHAT_SYSTEM:Maximize()
  6.     end
  7. end
  8.  
  9. local scene = SCENE_MANAGER:GetScene("bank")
  10. scene:RegisterCallback("StateChange", OnStateChange)
But if it works, do it as you like.

Ayantir 01/04/15 04:24 PM

Quote:

Originally Posted by Garkin (Post 18136)
Usually everything, what you want to do when scene is showing or hiding, is done by registering to StateChange callback, something like:
Lua Code:
  1. local function OnStateChange(oldState, newState)
  2.     if newState == SCENE_SHOWING then
  3.         CHAT_SYSTEM:Minimize()
  4.     elseif newState == SCENE_HIDDEN then
  5.         CHAT_SYSTEM:Maximize()
  6.     end
  7. end
  8.  
  9. local scene = SCENE_MANAGER:GetScene("bank")
  10. scene:RegisterCallback("StateChange", OnStateChange)
But if it works, do it as you like.


SetState triggers too often and SetBaseScene get a little bug when prehooking.

So I used your method :

Lua Code:
  1. function pChat.onSceneStateChange(oldState, newState)
  2.  
  3.     if pChat.opts.chatMinimizedInMenus then
  4.         if newState == SCENE_HIDDEN then
  5.             CHAT_SYSTEM:Minimize()
  6.         end
  7.     end
  8.  
  9.     if pChat.opts.chatMaximizedAfterMenus then
  10.         if newState == SCENE_SHOWING then
  11.             CHAT_SYSTEM:Maximize()
  12.         end
  13.     end
  14.    
  15. end
  16.  
  17. -- RegisterCallback for Maximize/Minimize chat when entering/leaving scenes
  18. -- "hud" is base scene (with "hudui") -- This declaration has to be set AFTER pChat.onSceneStateChange declaration
  19. pChat.hud = SCENE_MANAGER:GetScene("hud")
  20. pChat.hud:RegisterCallback("StateChange", pChat.onSceneStateChange)

Thank you :)

Anyway, option asked added in pChat 1.17 :)

Balver 01/05/15 02:53 AM

Thanks for adding this :).


All times are GMT -6. The time now is 02:17 AM.

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