Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/campaigns/default_menu/CampaignMenu.js
Show All 34 Lines | class CampaignMenu extends AutoWatcher | ||||
} | } | ||||
startScenario() | startScenario() | ||||
{ | { | ||||
const level = this.getSelectedLevelData(); | const level = this.getSelectedLevelData(); | ||||
if (!meetsRequirements(this.run, level)) | if (!meetsRequirements(this.run, level)) | ||||
return; | return; | ||||
// TODO: level description should also be passed, ideally. | |||||
const settings = { | const settings = { | ||||
"mapType": level.MapType, | "mapType": level.MapType, | ||||
"map": "maps/" + level.Map, | "map": "maps/" + level.Map, | ||||
// TODO: don't translate this here. | |||||
"mapName": this.getLevelName(level), | |||||
"mapPreview": level.Preview && "cropped:" + 400/512 + "," + 300/512 + ":" + level.Preview, | |||||
"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 | ||||
} | } | ||||
}; | }; | ||||
const 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() | ||||
} | } | ||||
}; | }; | ||||
const gameSettings = new GameSettings().init(); | const gameSettings = new GameSettings().init(); | ||||
gameSettings.fromInitAttributes(settings); | gameSettings.fromInitAttributes(settings); | ||||
if (level.Preview) | |||||
gameSettings.mapPreview.setCustom("cropped:" + 400/512 + "," + 300/512 + ":" + level.Preview); | |||||
gameSettings.mapName.set(this.getLevelName(level)); | |||||
// TODO: level description should also be passed, ideally. | |||||
if (level.useGameSetup) | if (level.useGameSetup) | ||||
{ | { | ||||
// Setup some default AI on the non-human players. | // Setup some default AI on the non-human players. | ||||
for (let i = 1; i < gameSettings.playerCount.nbPlayers; ++i) | for (let i = 1; i < gameSettings.playerCount.nbPlayers; ++i) | ||||
gameSettings.playerAI.set(i, { | gameSettings.playerAI.set(i, { | ||||
"bot": g_Settings.PlayerDefaults[i + 1].AI, | "bot": g_Settings.PlayerDefaults[i + 1].AI, | ||||
"difficulty": +Engine.ConfigDB_GetValue("user", "gui.gamesetup.aidifficulty"), | "difficulty": +Engine.ConfigDB_GetValue("user", "gui.gamesetup.aidifficulty"), | ||||
"behavior": Engine.ConfigDB_GetValue("user", "gui.gamesetup.aibehavior"), | "behavior": Engine.ConfigDB_GetValue("user", "gui.gamesetup.aibehavior"), | ||||
Show All 15 Lines | if (level.useGameSetup) | ||||
}, | }, | ||||
"gameSettings": attributes, | "gameSettings": attributes, | ||||
}); | }); | ||||
return; | return; | ||||
} | } | ||||
gameSettings.launchGame(assignments); | gameSettings.launchGame(assignments); | ||||
Engine.SwitchGuiPage("page_loading.xml", { | Engine.SwitchGuiPage("page_loading.xml", { | ||||
"attribs": gameSettings.toInitAttributes(), | "attribs": gameSettings.finalizedAttributes, | ||||
"playerAssignments": assignments | "playerAssignments": assignments | ||||
}); | }); | ||||
} | } | ||||
getSelectedLevelData() | getSelectedLevelData() | ||||
{ | { | ||||
if (this.selectedLevel === -1) | if (this.selectedLevel === -1) | ||||
return undefined; | return undefined; | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator