Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/autostart/autostart.js
- This file was added.
class Autostart | |||||
{ | |||||
constructor(data) | |||||
{ | |||||
this.data = data; | |||||
let mapCache = new MapCache(); | |||||
this.settings = new GameSettings(); | |||||
this.settings.Init(); | |||||
this.settings.map.mapCache = mapCache; | |||||
this.settings.LegacyDeserialize(data); | |||||
this.player = 1; | |||||
} | |||||
getGameAttributes() | |||||
{ | |||||
let ret = this.settings.LegacySerialize(); | |||||
// TODO: this overwrites some things which are legitimately game settings. | |||||
for (let key in this.data) | |||||
ret[key] = this.data[key]; | |||||
warn(uneval(ret)); | |||||
return ret; | |||||
} | |||||
startGame() | |||||
{ | |||||
this.settings.prepareForLaunch(); | |||||
// TODO: this doesn't actually work, | |||||
// because it doesn't listen to the net "start" message. | |||||
if (Engine.HasNetClient()) | |||||
{ | |||||
Engine.SetNetworkGameAttributes(this.getGameAttributes()); | |||||
Engine.SetRankedGame(this.settings.rating.enabled); | |||||
Engine.StartNetworkGame(); | |||||
} | |||||
else | |||||
{ | |||||
Engine.StartGame(this.getGameAttributes(), this.player); | |||||
this.switchToLoadingPage(); | |||||
} | |||||
} | |||||
switchToLoadingPage() | |||||
{ | |||||
Engine.SwitchGuiPage("page_loading.xml", { | |||||
"attribs": this.settings.LegacySerialize(), | |||||
"playerAssignments": { | |||||
"local": { | |||||
"name": "autostart", | |||||
"player": this.player | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
} |
Wildfire Games · Phabricator