Jump to content
Sign in to follow this  
SovietKitKat

Handling inputs on a GUI / Menu questions.

Recommended Posts

Does anyone have any ideas where to start with properly handling dialog/menu input capturing?

 

From digging around around the Reforger resources, it seems like a menu is the most appropriate class for what I'm trying to achieve (NPC quest menu)

 

I can display my dialog layout using the HUD manager, but I need to be able to handle inputs, so I've been trying to figure out how to define a Menu in a way that I can use the MenuManager, but OpenMenu requires an enum as a menu input and I haven't been able to determine how Reforger associates Menus to enums.

ChimeraMenuBase defines its own inherited enum, but I can't find where those enums associate to the UI classes with different names. They don't appear to exist in the project files at all. Am I missing something?

Share this post


Link to post
Share on other sites

Figured it out for my purposes after digging into Hexcavate and some additional trial and error. Here's what I had to do to get a new interactive menu defined.

 

1. Inherit chimeraMenus.conf and adding my layout as a new MenuPreset.

Adding a different menu config to the menuManager through addon.gproj didn't work during my earlier testing, but something else I did wrong further down the chain could have been mucking things up.

2. Creating a modded enum for ChimeraMenuPreset only containing my new dialog name.

modded enum ChimeraMenuPreset : ScriptMenuPresetEnum 
{
	NPCTalkDialog	
}

Again, trying to define my own enum instead of modding the existing preset didn't work.

 

Other Notes

For handling button inputs, I created my own Menu class inheriting MenuBase. You can get the widgets pretty easily from that point. Here's a snippet of my class in case it helps anyone else.

class POK_NPCTalkMenu : ChimeraMenuBase
{	
	Widget m_widget;
	
	...
	private ButtonWidget confirmButton;
	private SCR_ButtonBaseComponent confirmButtonComponent;
	
	override void OnMenuOpen() {
    
		m_widget = GetRootWidget();
		
		if(m_widget == null)
			return;
		
		...
        
		confirmButton = ButtonWidget.Cast( m_widget.FindAnyWidget( "Confirm" ) );
		confirmButtonComponent = SCR_ButtonBaseComponent.Cast(confirmButton.FindHandler(SCR_ButtonBaseComponent));
		
		// Add event to confirm button component to close the dialogue
		confirmButtonComponent.m_OnClicked.Insert(CloseDialogue);
	}
    
 	void CloseDialogue()
	{
		confirmButtonComponent.m_OnClicked.Remove(CloseDialogue);
		
		auto menu = ChimeraMenuPreset.NPCTalkDialog;
		g_Game.GetMenuManager().CloseMenuByPreset(menu);
	}

 

  • Like 3

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×