Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* To report the game to the lobby bot. | * To report the game to the lobby bot. | ||||
*/ | */ | ||||
var g_ServerName; | var g_ServerName; | ||||
var g_ServerPort; | var g_ServerPort; | ||||
/** | /** | ||||
* IP address of the STUN endpoint. | |||||
*/ | |||||
var g_StunEndpoint; | |||||
/** | |||||
* States whether the GUI is currently updated in response to network messages instead of user input | * States whether the GUI is currently updated in response to network messages instead of user input | ||||
* and therefore shouldn't send further messages to the network. | * and therefore shouldn't send further messages to the network. | ||||
*/ | */ | ||||
var g_IsInGuiUpdate = false; | var g_IsInGuiUpdate = false; | ||||
/** | /** | ||||
* Whether the current player is ready to start the game. | * Whether the current player is ready to start the game. | ||||
* 0 - not ready | * 0 - not ready | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
var g_LastGameStanza; | var g_LastGameStanza; | ||||
/** | /** | ||||
* Remembers if the current player viewed the AI settings of some playerslot. | * Remembers if the current player viewed the AI settings of some playerslot. | ||||
*/ | */ | ||||
var g_LastViewedAIPlayer = -1; | var g_LastViewedAIPlayer = -1; | ||||
/** | /** | ||||
* Current username. Cannot contain whitespace. | |||||
*/ | |||||
var g_Username = Engine.LobbyGetNick(); | |||||
/** | |||||
* Order in which the GUI elements will be shown. | * Order in which the GUI elements will be shown. | ||||
* All valid options are required to appear here. | * All valid options are required to appear here. | ||||
* The ones under "map" are shown in the map selection panel, | * The ones under "map" are shown in the map selection panel, | ||||
* the others in the "more options" dialog. | * the others in the "more options" dialog. | ||||
*/ | */ | ||||
var g_OptionOrderGUI = { | var g_OptionOrderGUI = { | ||||
"map": { | "map": { | ||||
"Dropdown": [ | "Dropdown": [ | ||||
▲ Show 20 Lines • Show All 558 Lines • ▼ Show 20 Lines | if (["offline", "server", "client"].indexOf(attribs.type) == -1) | ||||
cancelSetup(); | cancelSetup(); | ||||
return; | return; | ||||
} | } | ||||
g_IsNetworked = attribs.type != "offline"; | g_IsNetworked = attribs.type != "offline"; | ||||
g_IsController = attribs.type != "client"; | g_IsController = attribs.type != "client"; | ||||
g_ServerName = attribs.serverName; | g_ServerName = attribs.serverName; | ||||
g_ServerPort = attribs.serverPort; | g_ServerPort = attribs.serverPort; | ||||
g_StunEndpoint = attribs.stunEndpoint; | |||||
if (!g_IsNetworked) | if (!g_IsNetworked) | ||||
g_PlayerAssignments = { | g_PlayerAssignments = { | ||||
"local": { | "local": { | ||||
"name": singleplayerName(), | "name": singleplayerName(), | ||||
"player": 1 | "player": 1 | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 1,223 Lines • ▼ Show 20 Lines | function sendRegisterGameStanza() | ||||
if (!g_IsController || !Engine.HasXmppClient()) | if (!g_IsController || !Engine.HasXmppClient()) | ||||
return; | return; | ||||
let clients = formatClientsForStanza(); | let clients = formatClientsForStanza(); | ||||
let stanza = { | let stanza = { | ||||
"name": g_ServerName, | "name": g_ServerName, | ||||
"port": g_ServerPort, | "port": g_ServerPort, | ||||
"hostUsername": g_Username, | |||||
"mapName": g_GameAttributes.map, | "mapName": g_GameAttributes.map, | ||||
"niceMapName": getMapDisplayName(g_GameAttributes.map), | "niceMapName": getMapDisplayName(g_GameAttributes.map), | ||||
"mapSize": g_GameAttributes.mapType == "random" ? g_GameAttributes.settings.Size : "Default", | "mapSize": g_GameAttributes.mapType == "random" ? g_GameAttributes.settings.Size : "Default", | ||||
"mapType": g_GameAttributes.mapType, | "mapType": g_GameAttributes.mapType, | ||||
"victoryCondition": g_VictoryConditions.Title[g_VictoryConditions.Name.indexOf(g_GameAttributes.settings.GameType)], | "victoryCondition": g_VictoryConditions.Title[g_VictoryConditions.Name.indexOf(g_GameAttributes.settings.GameType)], | ||||
"nbp": clients.connectedPlayers, | "nbp": clients.connectedPlayers, | ||||
"maxnbp": g_GameAttributes.settings.PlayerData.length, | "maxnbp": g_GameAttributes.settings.PlayerData.length, | ||||
"players": clients.list, | "players": clients.list, | ||||
}; | }; | ||||
if (g_StunEndpoint !== undefined) | |||||
elexis: scope braces on a separate line | |||||
Not Done Inline Actions)\n { elexis: )\n { | |||||
{ | |||||
stanza.stunIP = g_StunEndpoint.ip; | |||||
stanza.stunPort = g_StunEndpoint.port; | |||||
} | |||||
// Only send the stanza if the relevant settings actually changed | // Only send the stanza if the relevant settings actually changed | ||||
if (g_LastGameStanza && Object.keys(stanza).every(prop => g_LastGameStanza[prop] == stanza[prop])) | if (g_LastGameStanza && Object.keys(stanza).every(prop => g_LastGameStanza[prop] == stanza[prop])) | ||||
return; | return; | ||||
g_LastGameStanza = stanza; | g_LastGameStanza = stanza; | ||||
Engine.SendRegisterGame(stanza); | Engine.SendRegisterGame(stanza); | ||||
} | } | ||||
Show All 13 Lines |
Wildfire Games · Phabricator
scope braces on a separate line