Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/autostart/autostart_client.js
- This file was added.
class AutoStartClient | |||||
{ | |||||
constructor(initData) | |||||
{ | |||||
this.playerAssignments = {}; | |||||
try | |||||
{ | |||||
Engine.StartNetworkJoin(initData.playerName, initData.ip, initData.port, initData.storeReplay); | |||||
} | |||||
catch (e) | |||||
{ | |||||
const message = sprintf(translate("Cannot join game: %(message)s."), { "message": e.message }); | |||||
messageBox(400, 200, message, translate("Error")); | |||||
} | |||||
} | |||||
onTick() | |||||
{ | |||||
while (true) | |||||
{ | |||||
const message = Engine.PollNetworkClient(); | |||||
if (!message) | |||||
break; | |||||
switch (message.type) | |||||
{ | |||||
case "players": | |||||
this.playerAssignments = message.newAssignments; | |||||
Engine.SendNetworkReady(2); | |||||
break; | |||||
case "start": | |||||
this.onLaunch(message); | |||||
// Process further pending netmessages in the session page. | |||||
return true; | |||||
default: | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
lyv: Should this time out or something eventually? It just freezes up currently if there is no host. | |||||
Done Inline ActionsI think that can be added later™. The point of this feature is to be easy to use for testing I think, so I don't think we care that much about dev UX wraitii: I think that can be added later™. The point of this feature is to be easy to use for testing I… | |||||
/** | |||||
* In the visual autostart path, we need to show the loading screen. | |||||
* Overload this as appropriate, the default implementation works for the public mod. | |||||
*/ | |||||
onLaunch(message) | |||||
{ | |||||
Engine.SwitchGuiPage("page_loading.xml", { | |||||
"attribs": message.initAttributes, | |||||
"isRejoining": true, | |||||
"playerAssignments": this.playerAssignments | |||||
}); | |||||
} | |||||
} |
Wildfire Games · Phabricator
Should this time out or something eventually? It just freezes up currently if there is no host.