Jump to content

Detecting that MCM menu is open


Recommended Posts

I wanted to detect if the MCM menu is open for the hotkeys in my mcm menu. Alternatively to detect that no menu is open. I have the key conflict control in MCM working but I noticed that the actions for the keys still fire when in the menu, I'd like to stop that for when other users with config menus that have key conflict might detect a conflict with my menu keys.

 

I have tried

If code == hotkey && !UI.IsMenuOpen("Main Menu")

 

but once in the MCM menu the main menu is closed and I don't see anything else useful here:

https://www.creationkit.com/index.php?title=UI_Script

 

 

 

diziet

Link to comment
Share on other sites

Instead use if (!Utility.IsInMenuMode())

 

UI.IsMenuOpen checks for a specific menu, while the above is for all menus. I think it checks though if the game is paused, so it could conflict with a mod like Skyrim Souls, which un-pauses the game during some menus.

Link to comment
Share on other sites

This is a safety process block I developed for one of my mods. It helps to determine when it is safe to process the key press. You are more than welcome to use it. Probably requires SKSE but not 100% certain on that.

 

 

Bool Function SafeProcess()
	If (!Utility.IsInMenuMode()) \
	&& (!UI.IsMenuOpen("Dialogue Menu")) \
	&& (!UI.IsMenuOpen("Console")) \
	&& (!UI.IsMenuOpen("Crafting Menu")) \
	&& (!UI.IsMenuOpen("MessageBoxMenu")) \
	&& (!UI.IsMenuOpen("ContainerMenu")) \
	&& (!UI.IsTextInputEnabled())
		;IsInMenuMode to block when game is paused with menus open
		;Dialogue Menu check to block when dialog is open
		;Console check to block when console is open - console does not trigger IsInMenuMode and thus needs its own check
		;Crafting Menu check to block when crafting menus are open - game is not paused so IsInMenuMode does not work
		;MessageBoxMenu check to block when message boxes are open - while they pause the game, they do not trigger IsInMenuMode
		;ContainerMenu check to block when containers are accessed - while they pause the game, they do not trigger IsInMenuMode
		;IsTextInputEnabled check to block when editable text fields are open
		Return True
	Else
		Return False
	EndIf
EndFunction

 

 

 

EDIT: In case it is not clear the return value of the safety process block needs to be true in order to allow the key press to be processed.

Edited by IsharaMeradin
Link to comment
Share on other sites

This is a safety process block I developed for one of my mods. It helps to determine when it is safe to process the key press. You are more than welcome to use it. Probably requires SKSE but not 100% certain on that.

 

 

Bool Function SafeProcess()
	If (!Utility.IsInMenuMode()) \
	&& (!UI.IsMenuOpen("Dialogue Menu")) \
	&& (!UI.IsMenuOpen("Console")) \
	&& (!UI.IsMenuOpen("Crafting Menu")) \
	&& (!UI.IsMenuOpen("MessageBoxMenu")) \
	&& (!UI.IsMenuOpen("ContainerMenu")) \
	&& (!UI.IsTextInputEnabled())
		;IsInMenuMode to block when game is paused with menus open
		;Dialogue Menu check to block when dialog is open
		;Console check to block when console is open - console does not trigger IsInMenuMode and thus needs its own check
		;Crafting Menu check to block when crafting menus are open - game is not paused so IsInMenuMode does not work
		;MessageBoxMenu check to block when message boxes are open - while they pause the game, they do not trigger IsInMenuMode
		;ContainerMenu check to block when containers are accessed - while they pause the game, they do not trigger IsInMenuMode
		;IsTextInputEnabled check to block when editable text fields are open
		Return True
	Else
		Return False
	EndIf
EndFunction

 

 

 

EDIT: In case it is not clear the return value of the safety process block needs to be true in order to allow the key press to be processed.

 

Thanks for the example script <3

Link to comment
Share on other sites

  • 6 months later...

This is a safety process block I developed for one of my mods. It helps to determine when it is safe to process the key press. You are more than welcome to use it. Probably requires SKSE but not 100% certain on that.

 

 

THANK YOU!!!

Link to comment
Share on other sites

  • 1 year later...

I know this is an old topic, but I am still using this code and I also added to it to make it compatible with Skyrim Souls. Here's the updated code:

 

 

 

Bool Function SafeProcess()
If (!Utility.IsInMenuMode()) \
&& (!UI.IsMenuOpen("Dialogue Menu")) \
&& (!UI.IsMenuOpen("Console")) \
&& (!UI.IsMenuOpen("Crafting Menu")) \
&& (!UI.IsMenuOpen("MessageBoxMenu")) \
&& (!UI.IsMenuOpen("ContainerMenu")) \
&& (!UI.IsMenuOpen("InventoryMenu")) \
&& (!UI.IsMenuOpen("BarterMenu")) \
&& (!UI.IsTextInputEnabled())
;IsInMenuMode to block when game is paused with menus open
;Dialogue Menu check to block when dialog is open
;Console check to block when console is open - console does not trigger IsInMenuMode and thus needs its own check
;Crafting Menu check to block when crafting menus are open - game is not paused so IsInMenuMode does not work
;MessageBoxMenu check to block when message boxes are open - while they pause the game, they do not trigger IsInMenuMode
;ContainerMenu check to block when containers are accessed - while they pause the game, they do not trigger IsInMenuMode
;InventoryMenu check to block when inventory is open - when used with Skyrim Souls
;BarterMenu check to block when buy items in shop - when used with Skyrim Souls
;IsTextInputEnabled check to block when editable text fields are open
Return True
Else
Return False
EndIf
EndFunction

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...