Differential D4039 Diff 17917 ps/trunk/binaries/data/mods/public/gui/campaigns/default_menu/CampaignMenu.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/campaigns/default_menu/CampaignMenu.js
Show All 30 Lines | class CampaignMenu extends AutoWatcher | ||||
goBackToMainMenu() | goBackToMainMenu() | ||||
{ | { | ||||
this.run.save(); | this.run.save(); | ||||
Engine.SwitchGuiPage("page_pregame.xml", {}); | Engine.SwitchGuiPage("page_pregame.xml", {}); | ||||
} | } | ||||
startScenario() | startScenario() | ||||
{ | { | ||||
let level = this.getSelectedLevelData(); | const level = this.getSelectedLevelData(); | ||||
if (!meetsRequirements(this.run, level)) | if (!meetsRequirements(this.run, level)) | ||||
return; | return; | ||||
let settings = { | const settings = { | ||||
"mapType": level.MapType, | "mapType": level.MapType, | ||||
"map": "maps/" + level.Map, | "map": "maps/" + level.Map, | ||||
"settings": { | "settings": { | ||||
"CheatsEnabled": true | "CheatsEnabled": true | ||||
}, | }, | ||||
"campaignData": { | "campaignData": { | ||||
"run": this.run.filename, | "run": this.run.filename, | ||||
"levelID": this.levelSelection.list_data[this.selectedLevel], | "levelID": this.levelSelection.list_data[this.selectedLevel], | ||||
"data": this.run.data | "data": this.run.data | ||||
} | } | ||||
}; | }; | ||||
let assignments = { | const assignments = { | ||||
"local": { | "local": { | ||||
"player": 1, | "player": 1, | ||||
"name": Engine.ConfigDB_GetValue("user", "playername.singleplayer") || Engine.GetSystemUsername() | "name": Engine.ConfigDB_GetValue("user", "playername.singleplayer") || Engine.GetSystemUsername() | ||||
} | } | ||||
}; | }; | ||||
let gameSettings = new GameSettings().init(); | const gameSettings = new GameSettings().init(); | ||||
gameSettings.fromInitAttributes(settings); | gameSettings.fromInitAttributes(settings); | ||||
if (level.Preview) | if (level.Preview) | ||||
gameSettings.mapPreview.setCustom("cropped:" + 400/512 + "," + 300/512 + ":" + level.Preview); | gameSettings.mapPreview.setCustom("cropped:" + 400/512 + "," + 300/512 + ":" + level.Preview); | ||||
gameSettings.mapName.set(this.getLevelName(level)); | gameSettings.mapName.set(this.getLevelName(level)); | ||||
// TODO: level description should also be passed, ideally. | // TODO: level description should also be passed, ideally. | ||||
if (level.useGameSetup) | |||||
{ | |||||
// Setup some default AI on the non-human players. | |||||
for (let i = 1; i < gameSettings.playerCount.nbPlayers; ++i) | |||||
gameSettings.playerAI.set(i, { | |||||
"bot": g_Settings.PlayerDefaults[i + 1].AI, | |||||
"difficulty": +Engine.ConfigDB_GetValue("user", "gui.gamesetup.aidifficulty"), | |||||
"behavior": Engine.ConfigDB_GetValue("user", "gui.gamesetup.aibehavior"), | |||||
}); | |||||
const attributes = gameSettings.toInitAttributes(); | |||||
attributes.guiData = { | |||||
"lockSettings": { | |||||
"map": true, | |||||
}, | |||||
}; | |||||
Engine.SwitchGuiPage("page_gamesetup.xml", { | |||||
"gameSettings": attributes, | |||||
}); | |||||
return; | |||||
} | |||||
gameSettings.launchGame(assignments); | gameSettings.launchGame(assignments); | ||||
Engine.SwitchGuiPage("page_loading.xml", { | Engine.SwitchGuiPage("page_loading.xml", { | ||||
"attribs": gameSettings.toInitAttributes(), | "attribs": gameSettings.toInitAttributes(), | ||||
"playerAssignments": assignments | "playerAssignments": assignments | ||||
}); | }); | ||||
} | } | ||||
getSelectedLevelData() | getSelectedLevelData() | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator