Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js
Show All 22 Lines | |||||
var g_PlayerAssignments; // used when rejoining | var g_PlayerAssignments; // used when rejoining | ||||
var g_UserRating; | var g_UserRating; | ||||
/** | /** | ||||
* Object containing the IP address and port of the STUN server. | * Object containing the IP address and port of the STUN server. | ||||
*/ | */ | ||||
var g_StunEndpoint; | var g_StunEndpoint; | ||||
function constructServerName(playerName) | |||||
elexis: make is a bit bold. Construct?
Don't you dare making this the first function of this file | |||||
Not Done Inline Actionsballsy :P elexis: ballsy :P | |||||
{ | |||||
return sprintf(translate("%(name)s's game"), { "name": playerName }); | |||||
} | |||||
function init(attribs) | function init(attribs) | ||||
{ | { | ||||
g_UserRating = attribs.rating; | g_UserRating = attribs.rating; | ||||
switch (attribs.multiplayerGameType) | switch (attribs.multiplayerGameType) | ||||
{ | { | ||||
case "join": | case "join": | ||||
{ | { | ||||
if (Engine.HasXmppClient()) | if (Engine.HasXmppClient()) | ||||
{ | { | ||||
if (startJoin(attribs.name, attribs.ip, getValidPort(attribs.port), attribs.useSTUN, attribs.hostJID)) | if (startJoin(attribs.name, attribs.ip, getValidPort(attribs.port), attribs.useSTUN, attribs.hostJID)) | ||||
switchSetupPage("pageConnecting"); | switchSetupPage("pageConnecting"); | ||||
} | } | ||||
else | else | ||||
switchSetupPage("pageJoin"); | switchSetupPage("pageJoin"); | ||||
break; | break; | ||||
} | } | ||||
case "host": | case "host": | ||||
{ | { | ||||
Engine.GetGUIObjectByName("hostSTUNWrapper").hidden = !Engine.HasXmppClient(); | Engine.GetGUIObjectByName("hostSTUNWrapper").hidden = !Engine.HasXmppClient(); | ||||
if (Engine.HasXmppClient()) | if (Engine.HasXmppClient()) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("hostPlayerName").caption = attribs.name; | Engine.GetGUIObjectByName("hostPlayerName").caption = attribs.name; | ||||
Engine.GetGUIObjectByName("hostServerName").caption = | Engine.GetGUIObjectByName("hostServerName").caption = constructServerName(attribs.name); | ||||
sprintf(translate("%(name)s's game"), { "name": attribs.name }); | |||||
Engine.GetGUIObjectByName("useSTUN").checked = Engine.ConfigDB_GetValue("user", "lobby.stun.enabled") == "true"; | Engine.GetGUIObjectByName("useSTUN").checked = Engine.ConfigDB_GetValue("user", "lobby.stun.enabled") == "true"; | ||||
} | } | ||||
switchSetupPage("pageHost"); | switchSetupPage("pageHost"); | ||||
break; | break; | ||||
} | } | ||||
default: | default: | ||||
Show All 37 Lines | if (!Engine.GetGUIObjectByName("pageJoin").hidden) | ||||
let joinPort = Engine.GetGUIObjectByName("joinPort").caption; | let joinPort = Engine.GetGUIObjectByName("joinPort").caption; | ||||
if (startJoin(joinPlayerName, joinServer, getValidPort(joinPort), false)) | if (startJoin(joinPlayerName, joinServer, getValidPort(joinPort), false)) | ||||
switchSetupPage("pageConnecting"); | switchSetupPage("pageConnecting"); | ||||
} | } | ||||
else if (!Engine.GetGUIObjectByName("pageHost").hidden) | else if (!Engine.GetGUIObjectByName("pageHost").hidden) | ||||
{ | { | ||||
let hostPlayerName = Engine.GetGUIObjectByName("hostPlayerName").caption; | let hostPlayerName = Engine.GetGUIObjectByName("hostPlayerName").caption; | ||||
let hostServerName = Engine.GetGUIObjectByName("hostServerName").caption; | let hostServerName = Engine.HasXmppClient() ? Engine.GetGUIObjectByName("hostServerName").caption : constructServerName(hostPlayerName); | ||||
Done Inline ActionsWhy is there a different code flow depending on being in the lobby? elexis: Why is there a different code flow depending on being in the lobby? | |||||
Not Done Inline ActionsIn the lobby you can change the servername. Imarok: In the lobby you can change the servername.
In gamesetup it just takes the playername at init… | |||||
Not Done Inline ActionsWhy wouldn't you be able to chose the servername when hosting a game outside of the lobby if it's displayed outside of the lobby too? elexis: Why wouldn't you be able to chose the servername when hosting a game outside of the lobby if… | |||||
Not Done Inline ActionsAs in should we make that pregame dialog more simple and always allow typing the gamename and never allow typing the playername (since that is selectable in the options?). Can be done afterwards I guess. elexis: As in should we make that pregame dialog more simple and always allow typing the gamename and… | |||||
let hostPort = Engine.GetGUIObjectByName("hostPort").caption; | let hostPort = Engine.GetGUIObjectByName("hostPort").caption; | ||||
if (!hostServerName) | if (!hostServerName) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("hostFeedback").caption = translate("Please enter a valid server name."); | Engine.GetGUIObjectByName("hostFeedback").caption = translate("Please enter a valid server name."); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | if (!g_StunEndpoint) | ||||
cancelSetup(); | cancelSetup(); | ||||
hostFeedback.caption = translate("Failed to host via STUN."); | hostFeedback.caption = translate("Failed to host via STUN."); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
try | try | ||||
{ | { | ||||
if (g_UserRating) | Engine.StartNetworkHost( playername + (g_UserRating ? " (" + g_UserRating + ")" : ""), | ||||
Engine.StartNetworkHost(playername + " (" + g_UserRating + ")", port); | port, | ||||
else | servername); | ||||
Done Inline Actionsternary and one line per arg to avoid the increasing redundancy? elexis: ternary and one line per arg to avoid the increasing redundancy? | |||||
elexisUnsubmitted Not Done Inline Actions-1 space elexis: -1 space | |||||
Engine.StartNetworkHost(playername, port); | |||||
} | } | ||||
catch (e) | catch (e) | ||||
{ | { | ||||
cancelSetup(); | cancelSetup(); | ||||
messageBox( | messageBox( | ||||
400, 200, | 400, 200, | ||||
sprintf(translate("Cannot host game: %(message)s."), { "message": e.message }), | sprintf(translate("Cannot host game: %(message)s."), { "message": e.message }), | ||||
translate("Error") | translate("Error") | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
make is a bit bold. Construct?
Don't you dare making this the first function of this file