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