Quantcast
Detect when in system menu... - ESOUI
Thread Tools Display Modes
08/16/20, 07:47 AM   #1
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 157
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...
__________________
My Addons: ESO Master Recipe List - SALTI - LootDrop Reborn - Dungeon Tracker - EZReport - Chat Window Manager - Poison Master - Vampire's Woe ... (more)
Also co-author for: Azurah - Srendarr - Show Motifs

PC NA @IllusoryID
  Reply With Quote
08/16/20, 08:17 AM   #2
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 290
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)
__________________
EU Server - SŁĄuGhTerHĜuSe
  Reply With Quote
08/17/20, 12:59 AM   #3
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 157
Originally Posted by Scootworks View Post
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.
__________________
My Addons: ESO Master Recipe List - SALTI - LootDrop Reborn - Dungeon Tracker - EZReport - Chat Window Manager - Poison Master - Vampire's Woe ... (more)
Also co-author for: Azurah - Srendarr - Show Motifs

PC NA @IllusoryID

Last edited by Phinix : 08/17/20 at 01:04 AM.
  Reply With Quote
08/17/20, 06:10 AM   #4
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,101
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

Last edited by Baertram : 08/17/20 at 06:14 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Detect when in system menu...

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