ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Detect when in system menu... (https://www.esoui.com/forums/showthread.php?t=9345)

Phinix 08/16/20 07:47 AM

Detect when in system menu...
 
I have an addon I want to ignore callbacks when the game's system menu is open (the one when you hit Escape, where you log off).

I was going to set a boolean when in the menu, but I need to be able to reliable check specifically when the main system menu is open, and when it is closed in order to toggle it.

I was looking through SCENE_MANAGER but so far I am not finding it...

Scootworks 08/16/20 08:17 AM

i use something like this in one of my addonds. maybe it helps:

Lua Code:
  1. local lastSceneName = "empty"
  2.         local marketAnnouncement = "marketAnnouncement"
  3.         local gameMenuInGame = "gameMenuInGame"
  4.  
  5. SCENE_MANAGER:RegisterCallback("SceneStateChanged", function(scene, oldState, newState)
  6.             local sceneName = scene:GetName()
  7.             if sceneName == marketAnnouncement and lastSceneName ~= gameMenuInGame then
  8.                 if newState == SCENE_SHOWING or newState == SCENE_SHOWN then
  9.                     SCENE_MANAGER:Hide(sceneName)
  10.                 end
  11.             end
  12.             lastSceneName = sceneName
  13.         end)

Phinix 08/17/20 12:59 AM

Quote:

Originally Posted by Scootworks (Post 42122)
i use something like this in one of my addons. maybe it helps:

Thanks for that. I ended up using something a little different:

Code:

        if SCENE_MANAGER:IsShowing("gameMenuInGame") == false then
                -- do stuff
        end

Basically this was for ChatWindowManager, to avoid the auto-minimize when opening the system menu to logout always setting your last chat window state to minimize even if you had it maximized before that, when the option to remember the chat state was enabled.

Baertram 08/17/20 06:10 AM

If you ONLY need to detect if someone got the main menu opened (the one at the left if you press ESC) I think you need to do it like you did with the explicit check for the scene / or a fragment.
Lua Code:
  1. local function sceneChange(sceneName, oldState, newState)
  2.     if (newState == SCENE_SHOWN) then
  3.         -- do stuff
  4.     elseif (newState == SCENE_HIDDEN) then
  5.         -- do stuff
  6.     end
  7. end
  8.  
  9. local scene = SCENE_MANAGER:GetScene("gameMenuInGame")
  10. scene:RegisterCallback("StateChange", sceneChange)
Or directly use the global GAME_MENU_SCENE (https://github.com/esoui/esoui/blob/...ngame.lua#L132) to register the StateChange callback function.


If you want to detect if ANY menu was opened (e.g. also if you open the inventory and the top bar menu is shown) you'd need to register a callback function to the HUD_SCENE and/or HUD_UI_SCENE 's "StateChange" like described here:
https://wiki.esoui.com/Scene_Manager:_On_scene_change


All times are GMT -6. The time now is 06:08 AM.

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