Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show First 20 Lines • Show All 1,071 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
function joinButton() | function joinButton() | ||||
{ | { | ||||
let game = selectedGame(); | let game = selectedGame(); | ||||
if (!game) | if (!game) | ||||
return; | return; | ||||
let rating = getRejoinRating(game); | let rating = getRejoinRating(game); | ||||
let username = rating ? g_Username + " (" + rating + ")" : g_Username; | let username = rating ? multiplayerName(g_Username) + " (" + rating + ")" : multiplayerName(g_Username); | ||||
if (game.state == "init" || stringifiedTeamListToPlayerData(game.players).some(player => player.Name == username)) | if (game.state == "init" || stringifiedTeamListToPlayerData(game.players).some(player => player.Name == username)) | ||||
joinSelectedGame(); | joinSelectedGame(); | ||||
else | else | ||||
messageBox( | messageBox( | ||||
400, 200, | 400, 200, | ||||
translate("The game has already started. Do you want to join as observer?"), | translate("The game has already started. Do you want to join as observer?"), | ||||
translate("Confirmation"), | translate("Confirmation"), | ||||
Show All 35 Lines | if (ip.split('.').length != 4) | ||||
}); | }); | ||||
return; | return; | ||||
} | } | ||||
Engine.PushGuiPage("page_gamesetup_mp.xml", { | Engine.PushGuiPage("page_gamesetup_mp.xml", { | ||||
"multiplayerGameType": "join", | "multiplayerGameType": "join", | ||||
"ip": ip, | "ip": ip, | ||||
"port": port, | "port": port, | ||||
"name": g_Username, | "name": multiplayerName(g_Username), | ||||
"rating": getRejoinRating(game), | "rating": getRejoinRating(game), | ||||
"useSTUN": !!game.stunIP, | "useSTUN": !!game.stunIP, | ||||
"hostJID": game.hostUsername + "@" + g_LobbyServer + "/0ad" | "hostJID": game.hostUsername + "@" + g_LobbyServer + "/0ad" | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Rejoin games with the original playername, even if the rating changed meanwhile. | * Rejoin games with the original playername, even if the rating changed meanwhile. | ||||
*/ | */ | ||||
function getRejoinRating(game) | function getRejoinRating(game) | ||||
{ | { | ||||
for (let player of stringifiedTeamListToPlayerData(game.players)) | for (let player of stringifiedTeamListToPlayerData(game.players)) | ||||
{ | { | ||||
let playerNickRating = splitRatingFromNick(player.Name); | let playerNickRating = splitRatingFromNick(player.Name); | ||||
if (playerNickRating.nick == g_Username) | if (playerNickRating.nick == multiplayerName(g_Username)) | ||||
return playerNickRating.rating; | return playerNickRating.rating; | ||||
} | } | ||||
return g_UserRating; | return g_UserRating; | ||||
} | } | ||||
/** | /** | ||||
* Open the dialog box to enter the game name. | * Open the dialog box to enter the game name. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator