Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js
Show All 24 Lines | |||||
var g_UserRating; | var g_UserRating; | ||||
function init(attribs) | function init(attribs) | ||||
{ | { | ||||
g_UserRating = attribs.rating; | g_UserRating = attribs.rating; | ||||
switch (attribs.multiplayerGameType) | switch (attribs.multiplayerGameType) | ||||
{ | { | ||||
case "dedicated": | |||||
{ | |||||
if (!Engine.HasXmppClient()) | |||||
{ | |||||
switchSetupPage("pageJoin"); | |||||
break; | |||||
} | |||||
if (startJoinFromLobby(attribs.name, attribs.hostJID, attribs.pass, attribs.secret)) | |||||
switchSetupPage("pageConnecting"); | |||||
break; | |||||
} | |||||
case "join": | case "join": | ||||
{ | { | ||||
if (!Engine.HasXmppClient()) | if (!Engine.HasXmppClient()) | ||||
{ | { | ||||
switchSetupPage("pageJoin"); | switchSetupPage("pageJoin"); | ||||
break; | break; | ||||
} | } | ||||
if (attribs.hasPassword) | if (attribs.hasPassword) | ||||
▲ Show 20 Lines • Show All 378 Lines • ▼ Show 20 Lines | function startJoin(playername, ip, port) | ||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerserver", ip, "config/user.cfg"); | Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerserver", ip, "config/user.cfg"); | ||||
Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerjoining.port", port, "config/user.cfg"); | Engine.ConfigDB_CreateAndWriteValueToFile("user", "multiplayerjoining.port", port, "config/user.cfg"); | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Connect via the lobby. | * Connect via the lobby. | ||||
*/ | */ | ||||
function startJoinFromLobby(playername, hostJID, password) | function startJoinFromLobby(playername, hostJID, password, secret) | ||||
{ | { | ||||
if (!Engine.HasXmppClient()) | if (!Engine.HasXmppClient()) | ||||
{ | { | ||||
cancelSetup(); | cancelSetup(); | ||||
messageBox( | messageBox( | ||||
400, 200, | 400, 200, | ||||
sprintf("You cannot join a lobby game without logging in to the lobby."), | sprintf("You cannot join a lobby game without logging in to the lobby."), | ||||
translate("Error") | translate("Error") | ||||
); | ); | ||||
return false; | return false; | ||||
} | } | ||||
try | try | ||||
{ | { | ||||
Engine.StartNetworkJoinLobby(playername + (g_UserRating ? " (" + g_UserRating + ")" : ""), hostJID, password); | Engine.StartNetworkJoinLobby(playername + (g_UserRating ? " (" + g_UserRating + ")" : ""), hostJID, password, secret); | ||||
} | } | ||||
catch (e) | catch (e) | ||||
{ | { | ||||
cancelSetup(); | cancelSetup(); | ||||
messageBox( | messageBox( | ||||
400, 200, | 400, 200, | ||||
sprintf(translate("Cannot join game: %(message)s."), { "message": e.message }), | sprintf(translate("Cannot join game: %(message)s."), { "message": e.message }), | ||||
translate("Error") | translate("Error") | ||||
Show All 22 Lines |
Wildfire Games · Phabricator