Index: binaries/data/mods/public/gui/autostart/autostart.js =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/autostart/autostart.js @@ -0,0 +1,57 @@ +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 + } + } + }); + } +} Index: binaries/data/mods/public/gui/autostart/autostart.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/autostart/autostart.xml @@ -0,0 +1,11 @@ + + + +