Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/gamedescription.js
Show All 10 Lines | |||||
/** | /** | ||||
* XEP-0172 doesn't restrict nicknames, but our lobby policy does. | * XEP-0172 doesn't restrict nicknames, but our lobby policy does. | ||||
* So use this human readable delimiter to separate buddy names in the config file. | * So use this human readable delimiter to separate buddy names in the config file. | ||||
*/ | */ | ||||
var g_BuddyListDelimiter = ","; | var g_BuddyListDelimiter = ","; | ||||
/** | /** | ||||
* Returns the nickname without the lobby rating. | * @Returns {object} containing the name and rating seperately. | ||||
*/ | */ | ||||
function splitRatingFromNick(playerName) | function splitRatingFromNick(playerName) | ||||
{ | { | ||||
let result = /^(\S+)\ \((\d+)\)$/g.exec(playerName); | let result = /^(\S+)\ \((\d+)\)$/g.exec(playerName); | ||||
return { "nick": result ? result[1] : playerName, "rating": result ? +result[2] : "" }; | return { "nick": result ? result[1] : playerName, "rating": result ? +result[2] : "" }; | ||||
} | } | ||||
/** | /** | ||||
* Array of playernames that the current user has marked as buddies. | * Array of playernames that the current user has marked as buddies. | ||||
*/ | */ | ||||
var g_Buddies = Engine.ConfigDB_GetValue("user", "lobby.buddies").split(g_BuddyListDelimiter); | var g_Buddies = Engine.ConfigDB_GetValue("user", "lobby.buddies").split(g_BuddyListDelimiter); | ||||
/** | /** | ||||
* Denotes which players are a lobby buddy of the current user. | * Denotes which players are a lobby buddy of the current user. | ||||
*/ | */ | ||||
var g_BuddySymbol = '•'; | var g_BuddySymbol = '★'; | ||||
/** | /** | ||||
* Returns a formatted string describing the player assignments. | * Returns a formatted string describing the player assignments. | ||||
* Needs g_CivData to translate! | * Needs g_CivData to translate! | ||||
* | * | ||||
Silier: please revert the one space addition | |||||
Done Inline ActionsSure, but why? Grapjas: Sure, but why? | |||||
Not Done Inline Actionsbecause there is mechanism called "blame" which tracks who changed line as the last and this is making harder to track relevant changes Silier: because there is mechanism called "blame" which tracks who changed line as the last and this is… | |||||
Done Inline ActionsI see what you mean, but isn't it wrong to have a leading space everywhere? Shouldn't it be fixed? Grapjas: I see what you mean, but isn't it wrong to have a leading space everywhere? Shouldn't it be… | |||||
* @param {Object} playerDataArray - As known from game setup and sim state. | * @param {Object} playerDataArray - As known from game setup and sim state. | ||||
* @param {(string[]|false)} playerStates - One of "won", "defeated", "active" for each player. | * @param {(string[]|false)} playerStates - One of "won", "defeated", "active" for each player. | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function formatPlayerInfo(playerDataArray, playerStates) | function formatPlayerInfo(playerDataArray, playerStates) | ||||
{ | { | ||||
let playerDescriptions = {}; | let playerDescriptions = {}; | ||||
let playerIdx = 0; | let playerIdx = 0; | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | else | ||||
else | else | ||||
if (isActive) | if (isActive) | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s"); | playerDescription = translate("%(playerName)s"); | ||||
else | else | ||||
// Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | // Translation: Describe a player in a selected game, f.e. in the replay- or savegame menu | ||||
playerDescription = translate("%(playerName)s (%(state)s)"); | playerDescription = translate("%(playerName)s (%(state)s)"); | ||||
} | } | ||||
} | } | ||||
Not Done Inline ActionsI would cache this to variable splitRatingFromNick(playerData.Name) and then do .rating and .nick on that variable also let -> const on anything that will not be changed Silier: I would cache this to variable `splitRatingFromNick(playerData.Name)` and then do .rating and . | |||||
// Sort player descriptions by team | // Sort player descriptions by team | ||||
if (!playerDescriptions[teamIdx]) | if (!playerDescriptions[teamIdx]) | ||||
playerDescriptions[teamIdx] = []; | playerDescriptions[teamIdx] = []; | ||||
let playerNick = splitRatingFromNick(playerData.Name).nick; | let playerNick = splitRatingFromNick(playerData.Name).nick; | ||||
let playerRating = splitRatingFromNick(playerData.Name).rating; | |||||
playerRating ? playerRating = ' (' + coloredText(playerRating, PlayerColor.GetColorByRating(playerRating)) + ')' : playerRating = ""; | |||||
playerDescriptions[teamIdx].push(sprintf(playerDescription, { | playerDescriptions[teamIdx].push(sprintf(playerDescription, { | ||||
"playerName": | "playerName": | ||||
coloredText( | (g_Buddies.indexOf(playerNick) != -1 ? coloredText(g_BuddySymbol, "0 160 160") + " " : "") + | ||||
(g_Buddies.indexOf(playerNick) != -1 ? g_BuddySymbol + " " : "") + | coloredText(escapeText(playerNick), PlayerColor.ColorPlayerNameByRole(Engine.LobbyGetPlayerRole(playerNick))) + playerRating, | ||||
escapeText(playerData.Name), | |||||
(typeof getPlayerColor == 'function' ? | |||||
(isAI ? "white" : getPlayerColor(playerNick)) : | |||||
rgbToGuiColor(playerData.Color || g_Settings.PlayerDefaults[playerIdx].Color))), | |||||
Not Done Inline Actionsi think this should stay because colours are from the match Silier: i think this should stay because colours are from the match | |||||
Done Inline Actionsdon't understand what you mean, reword it. It colors player names in game details, which would only be white or purple as defined by playercolor function. Grapjas: don't understand what you mean, reword it. It colors player names in game details, which would… | |||||
"civ": | "civ": | ||||
!playerData.Civ ? | !playerData.Civ ? | ||||
translate("Unknown Civilization") : | translate("Unknown Civilization") : | ||||
g_CivData && g_CivData[playerData.Civ] && g_CivData[playerData.Civ].Name ? | g_CivData && g_CivData[playerData.Civ] && g_CivData[playerData.Civ].Name ? | ||||
translate(g_CivData[playerData.Civ].Name) : | translate(g_CivData[playerData.Civ].Name) : | ||||
playerData.Civ, | playerData.Civ, | ||||
▲ Show 20 Lines • Show All 325 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
please revert the one space addition