Index: binaries/data/mods/public/gui/lobby/lobby.js =================================================================== --- binaries/data/mods/public/gui/lobby/lobby.js +++ binaries/data/mods/public/gui/lobby/lobby.js @@ -91,6 +91,11 @@ var g_GameList = {}; /** + * All games where buddy joined. + */ +var g_BuddyGames = undefined; + +/** * Used to restore the selection after updating the playerlist. */ var g_SelectedPlayer = ""; @@ -904,6 +909,9 @@ g_SelectedGamePort = g_GameList[gamesBox.selected].port; } + if (g_BuddyGames) + g_BuddyGames.stillRunning = !g_BuddyGames.stillRunning; + g_GameList = Engine.GetGameList().map(game => { game.hasBuddies = 0; @@ -911,6 +919,14 @@ // Compute average rating of participating players let playerRatings = []; + let initBuddyGames = !g_BuddyGames; + if (initBuddyGames) + g_BuddyGames = {"games": [], "stillRunning": true}; + if (!g_BuddyGames.games[game]) + g_BuddyGames.games[game] = {"running": g_BuddyGames.stillRunning, "buddies": []}; + else + g_BuddyGames.games[game].running = g_BuddyGames.stillRunning; + for (let player of stringifiedTeamListToPlayerData(game.players)) { let [nick, rating] = splitRatingFromNick(player.Name); @@ -918,6 +934,22 @@ if (player.Team != "observer") playerRatings.push(rating || g_DefaultLobbyRating); + if (g_Buddies.indexOf(nick) != -1 && + g_BuddyGames.games[game].buddies.indexOf(nick) == -1) + { + g_BuddyGames.games[game].buddies.push(nick); + let nickName = (player.role && player.role == "moderator" ? g_ModeratorPrefix : "") + nick; + if (!initBuddyGames) + addChatMessage({ + "info": true, + "text": sprintf( + translate("%(buddy)s has joined game %(game)s."), + {"buddy": coloredText(g_BuddySymbol + " " + nickName, getPlayerColor(nickName)), + "game": coloredText(g_BuddySymbol + " " + game.name, g_GameColors[game.state])} + )} + ); + } + // Sort games with playing buddies above games with spectating buddies if (game.hasBuddies < 2 && g_Buddies.indexOf(nick) != -1) game.hasBuddies = player.Team == "observer" ? 1 : 2; @@ -961,6 +993,11 @@ return 0; }); + if (g_BuddyGames) + for (let game in g_BuddyGames.games) + if (g_BuddyGames.games[game].running != g_BuddyGames.stillRunning) + delete g_BuddyGames.games[game]; + let list_buddy = []; let list_name = []; let list_mapName = []; @@ -1371,6 +1408,10 @@ return ""; } } + else if (msg.info) + formattedMessage = sprintf(translate("* %(info)s"), { + "info": msg.text + }); else { let senderString;