Torque3D/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript
JeffR 1acf4b2dae Adjusts engine cleanup ordering on shaderFeatureMgr to avoid periodic crashes on Mac ARM machines
Adds missing disconnect/timeout handling callbacks to the clientServer core module
Adds page refresh function to UINavigation to be able to selectively nudge the current page to refresh its contents if needbe
2022-06-05 01:21:38 -05:00

52 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();
//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;
//Lastly, we go ahead and display some actual navigable content up on our main menu here
//In this case, we set the MainMenuButtons 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 MainMenuButtons::onOpen(), so to see where the navigation
//chain continues, see that function.
%this.setRootPage(MainMenuButtons);
%this.refreshPage();
}
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();
}