mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
51 lines
2.4 KiB
Plaintext
51 lines
2.4 KiB
Plaintext
function MainMenuGui::onAdd(%this)
|
|
{
|
|
$activeControllerName = "K&M"; //default input type
|
|
}
|
|
|
|
function MainMenuGui::onWake(%this)
|
|
{
|
|
//In the BaseUI example case, the MainMenuGUI acts as our background
|
|
//So it's a logical control to set as our UINavigation as well. So we
|
|
//set the MainMenuGUI's superClass to UINavigation to integrate it into
|
|
//that namespace to open up page navigation
|
|
|
|
//At the same time, the MainMenuGUI control has the button holder, set to
|
|
//the MenuInputButtonContainer class, allowing us to set it as the active button
|
|
//holder here, prepping it for catching any button inputs to active commands
|
|
//Specifically, it sets the $activeMenuButtonContainer to be this, which allows
|
|
//other controls to manage what the behavior of the buttons is consistently
|
|
//without needing to worry about hardcoded names
|
|
MainMenuButtonHolder.setActive();
|
|
|
|
//We also have the MainMenuInputHandler, a GuiInputCtrl with the MenuInputHandler class
|
|
//This allows us to catch any input/axis event and pass it along to the active menuList
|
|
//or button containers to navigate the menus
|
|
//We set up this catch by making said control our first responder, here
|
|
MainMenuInputHandler.setFirstResponder();
|
|
|
|
//Lastly, we go ahead and display some actual navigable content up on our main menu here
|
|
//In this case, we set the MainMenuButtonList as our root page, so we always come back
|
|
//to having the main menu buttons on screen if every other page is closed.
|
|
//This will ultimately call MainMenuButtonList::onOpen(), so to see where the navigation
|
|
//chain continues, see that function.
|
|
%this.setRootPage(MainMenuButtonList);
|
|
|
|
//We also go ahead and mark for any future pages being added to the UINavigation's page stack
|
|
//to be prompted to resize when added. This isn't required, but helps keep pages formated to
|
|
//the current size of the UINavigation, which is useful when dealing with aspect ratio or resolution
|
|
//changes.
|
|
%this.resizePages = true;
|
|
}
|
|
|
|
function MainMenuButtonHolder::onWake(%this)
|
|
{
|
|
//Because the blan slate MainMenuGUI doesn't have anything we need to bother with inputs on
|
|
//we just go ahead and disable all the buttons in our MainMenuButtonHolder to have
|
|
// a clean slate
|
|
%this-->button1.disable();
|
|
%this-->button2.disable();
|
|
%this-->button3.disable();
|
|
%this-->button4.disable();
|
|
%this-->button5.disable();
|
|
} |