Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/pregame/MainMenuPage.js
- This file was copied from binaries/data/mods/public/gui/pregame/mainmenu.js.
/** | /** | ||||
* Available backgrounds, added by the files in backgrounds/. | * This is the handler that coordinates all other handlers on this GUI page. | ||||
*/ | */ | ||||
var g_BackgroundLayerData = []; | class MainMenuPage | ||||
var g_BackgroundHandler; | |||||
var g_MenuHandler; | |||||
var g_SplashScreenHandler; | |||||
function init(data, hotloadData) | |||||
{ | { | ||||
g_MenuHandler = new MainMenuItemHandler(g_MainMenuItems); | constructor(data, hotloadData, mainMenuItems, backgroundLayerData, projectInformation, communityButtons) | ||||
g_BackgroundHandler = new BackgroundHandler(pickRandom(g_BackgroundLayerData)); | |||||
g_SplashScreenHandler = new SplashScreenHandler(data, hotloadData && hotloadData.splashScreenHandler); | |||||
new MusicHandler(); | |||||
new ProjectInformationHandler(g_ProjectInformation); | |||||
new CommunityButtonHandler(); | |||||
} | |||||
function onTick() | |||||
{ | { | ||||
g_MenuHandler.onTick(); | this.backgroundHandler = new BackgroundHandler(pickRandom(backgroundLayerData)); | ||||
g_BackgroundHandler.onTick(); | this.menuHandler = new MainMenuItemHandler(mainMenuItems); | ||||
g_SplashScreenHandler.onTick(); | this.splashScreenHandler = new SplashScreenHandler(data, hotloadData && hotloadData.splashScreenHandler); | ||||
this.musicHandler = new MusicHandler(); | |||||
this.projectInformationHandler = new ProjectInformationHandler(projectInformation); | |||||
this.communityButtonHandler = new CommunityButtonHandler(communityButtons); | |||||
} | } | ||||
function getHotloadData() | getHotloadData() | ||||
{ | { | ||||
return { | return { | ||||
"splashScreenHandler": g_SplashScreenHandler.getHotloadData() | "splashScreenHandler": this.splashScreenHandler.getHotloadData() | ||||
}; | }; | ||||
} | } | ||||
} | |||||
class MusicHandler | class MusicHandler | ||||
{ | { | ||||
constructor() | constructor() | ||||
{ | { | ||||
initMusic(); | initMusic(); | ||||
global.music.setState(global.music.states.MENU); | global.music.setState(global.music.states.MENU); | ||||
} | } | ||||
} | } | ||||
class ProjectInformationHandler | class ProjectInformationHandler | ||||
{ | { | ||||
constructor(projectInformation) | constructor(projectInformation) | ||||
{ | { | ||||
for (let objectName in projectInformation) | for (let objectName in projectInformation) | ||||
for (let propertyName in projectInformation[objectName]) | for (let propertyName in projectInformation[objectName]) | ||||
Engine.GetGUIObjectByName(objectName)[propertyName] = projectInformation[objectName][propertyName]; | Engine.GetGUIObjectByName(objectName)[propertyName] = projectInformation[objectName][propertyName]; | ||||
} | } | ||||
} | } | ||||
class CommunityButtonHandler | class CommunityButtonHandler | ||||
{ | { | ||||
constructor() | constructor(communityButtons) | ||||
{ | { | ||||
let buttons = Engine.GetGUIObjectByName("communityButtons").children; | let buttons = Engine.GetGUIObjectByName("communityButtons").children; | ||||
g_CommunityButtons.forEach((buttonInfo, i) => { | communityButtons.forEach((buttonInfo, i) => { | ||||
let button = buttons[i]; | let button = buttons[i]; | ||||
button.hidden = false; | button.hidden = false; | ||||
for (let propertyName in buttonInfo) | for (let propertyName in buttonInfo) | ||||
button[propertyName] = buttonInfo[propertyName]; | button[propertyName] = buttonInfo[propertyName]; | ||||
}); | }); | ||||
if (buttons.length < g_CommunityButtons.length) | if (buttons.length < communityButtons.length) | ||||
error("GUI page has space for " + buttons.length + " community buttons, but " + menuItems.length + " items are provided!"); | error("GUI page has space for " + buttons.length + " community buttons, but " + menuItems.length + " items are provided!"); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator