mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
- Changed ChooseLevelMenu layout to have a vertical list for levels with a static preview set, as well as a separate tab for server configs if trying to create a server - Added field to set password for connecting to passworded servers on the JoinServerMenu - Added sanity check so you can't try and activate a menuList that has no children(caused error spam)
130 lines
3.2 KiB
Plaintext
130 lines
3.2 KiB
Plaintext
$BaseUI::scrollSpeedTimeMs = 250;
|
|
$BaseUI::scrollSchedule = 0;
|
|
|
|
function MainMenuGui::onAdd(%this)
|
|
{
|
|
}
|
|
|
|
function MainMenuGui::onWake(%this)
|
|
{
|
|
$MenuList = MainMenuButtonList;
|
|
$MenuList.listPosition = 0;
|
|
|
|
$MenuList.syncGui();
|
|
}
|
|
|
|
function MainMenuGui::onSleep(%this)
|
|
{
|
|
}
|
|
|
|
if(!isObject( BaseUIActionMap ) )
|
|
{
|
|
new ActionMap(BaseUIActionMap){};
|
|
|
|
BaseUIActionMap.bind( keyboard, w, BaseUINavigatePrev );
|
|
BaseUIActionMap.bind( keyboard, s, BaseUINavigateNext );
|
|
BaseUIActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", BaseUIStickNavigate );
|
|
BaseUIActionMap.bind( gamepad, upov, BaseUINavigatePrev );
|
|
BaseUIActionMap.bind( gamepad, dpov, BaseUINavigateNext );
|
|
|
|
BaseUIActionMap.bind( keyboard, Space, BaseUIActivateSelected );
|
|
BaseUIActionMap.bind( gamepad, btn_a, BaseUIActivateSelected );
|
|
|
|
BaseUIActionMap.bind( keyboard, Escape, BaseUIBackOut );
|
|
BaseUIActionMap.bind( gamepad, btn_b, BaseUIBackOut );
|
|
}
|
|
|
|
function BaseUINavigatePrev(%val)
|
|
{
|
|
if(%val)
|
|
{
|
|
$MenuList.listPosition -= 1;
|
|
if($MenuList.listPosition < 0)
|
|
$MenuList.listPosition = 0;
|
|
|
|
$MenuList.syncGUI();
|
|
|
|
$BaseUI::scrollSchedule = schedule($BaseUI::scrollSpeedTimeMs, 0, "BaseUINavigatePrev", 1);
|
|
}
|
|
else
|
|
{
|
|
cancel($BaseUI::scrollSchedule);
|
|
}
|
|
}
|
|
|
|
function BaseUINavigateNext(%val)
|
|
{
|
|
if(%val)
|
|
{
|
|
$MenuList.listPosition += 1;
|
|
if($MenuList.listPosition >= $MenuList.getCount())
|
|
$MenuList.listPosition = $MenuList.getCount()-1;
|
|
|
|
$MenuList.syncGUI();
|
|
|
|
$BaseUI::scrollSchedule = schedule($BaseUI::scrollSpeedTimeMs, 0, "BaseUINavigateNext", 1);
|
|
}
|
|
else
|
|
{
|
|
cancel($BaseUI::scrollSchedule);
|
|
}
|
|
}
|
|
|
|
function BaseUIStickNavigate(%val)
|
|
{
|
|
if(%val == 1)
|
|
BaseUINavigateNext(1);
|
|
else if(%val == -1)
|
|
BaseUINavigatePrev(1);
|
|
else
|
|
cancel($BaseUI::scrollSchedule);
|
|
}
|
|
|
|
function BaseUIBackOut(%val)
|
|
{
|
|
//we can't navigate further back than the MainMenuGui
|
|
if(%val && Canvas.getObject(Canvas.getCount()-1).getId() != MainMenuGui.getId())
|
|
{
|
|
Canvas.popDialog();
|
|
%topMenu = Canvas.getObject(Canvas.getCount()-1);
|
|
if(isObject(%topMenu))
|
|
{
|
|
//re-kick the on-wake so we can be fully up to date and relevently
|
|
//contexted
|
|
%topMenu.onWake();
|
|
}
|
|
}
|
|
}
|
|
|
|
function MainMenuButtonList::syncGUI(%this)
|
|
{
|
|
//%this.callOnChildren("setHighlighted", false);
|
|
|
|
%btn = %this.getObject(%this.listPosition);
|
|
%btn.setHighlighted(true);
|
|
|
|
//
|
|
//Update the button imagery to comply to the last input device we'd used
|
|
%device = Canvas.getLastInputDevice();
|
|
if(%device $= "mouse")
|
|
%device = "keyboard";
|
|
|
|
MainMenuGoButton.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIActivateSelected"));
|
|
}
|
|
|
|
function MainMenuButton::onHighlighted(%this, %highlighted)
|
|
{
|
|
if(%highlighted)
|
|
$MenuList.listPosition = MainMenuButtonList.getObjectIndex(%this);
|
|
}
|
|
|
|
function BaseUIActivateSelected()
|
|
{
|
|
if($MenuList.getCount() == 0 || $MenuList.listPosition >= $MenuList.getCount() || $MenuList.listPosition < 0)
|
|
return;
|
|
|
|
%btn = $MenuList.getObject($MenuList.listPosition);
|
|
|
|
if(%btn.isMethod("performClick"))
|
|
%btn.performClick();
|
|
} |