From d2b92363883c1e042bc94ad64d4759e27903e184 Mon Sep 17 00:00:00 2001 From: Imarok Date: Sun, 29 Jan 2017 17:31:18 +0000 Subject: [PATCH] Colorize the playername with rating in the lobby user profile Reviewed by: elexis Differential Revision: https://code.wildfiregames.com/D48 This was SVN commit r19185. --- binaries/data/mods/public/gui/lobby/lobby.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/binaries/data/mods/public/gui/lobby/lobby.js b/binaries/data/mods/public/gui/lobby/lobby.js index 37ead8cc8d..c783a5fdca 100644 --- a/binaries/data/mods/public/gui/lobby/lobby.js +++ b/binaries/data/mods/public/gui/lobby/lobby.js @@ -436,10 +436,7 @@ function updateProfile() { let attributes = Engine.GetProfile()[0]; - let user = sprintf(translate("%(nick)s (%(rating)s)"), { - "nick": attributes.player, - "rating": attributes.rating - }); + let user = colorPlayerName(attributes.player, attributes.rating); if (!Engine.GetGUIObjectByName("profileFetch").hidden) { @@ -1114,11 +1111,17 @@ function getPlayerColor(playername) * Returns the given playername wrapped in an appropriate color-tag. * * @param {string} playername + * @param {string} rating */ -function colorPlayerName(playername) +function colorPlayerName(playername, rating) { return '[color="' + getPlayerColor(playername.replace(g_ModeratorPrefix, "")) + '"]' + - playername + '[/color]'; + (rating ? sprintf( + translate("%(nick)s (%(rating)s)"), { + "nick": playername, + "rating": rating + }) : + playername) + '[/color]'; } function senderFont(text)