Restoring the colored profile name with the ranking and using the leaderboard names for autocompletion in the profile player search field.

Broken in 0a09bde961

Comments By: elexis, Dunedan, Silier, Freagarach
Patch By: Langbart
Differential Revision: D4262
fixes #6316

This was SVN commit r26112.
This commit is contained in:
bb
2021-12-25 21:06:21 +00:00
parent ac7dc057df
commit 5fd4fb2b34
3 changed files with 23 additions and 4 deletions
@@ -72,7 +72,7 @@ class ProfilePanel
if (!playerName)
return;
this.playernameText.caption = playerName;
this.playernameText.caption = PlayerColor.ColorPlayerName(escapeText(playerName));
this.updatePlayerRoleText(playerName);
this.rankText.caption = this.NotAvailable;
@@ -91,7 +91,7 @@ class ProfilePanel
if (attributes.rating == "-2" || attributes.player != this.requestedPlayer)
return;
this.playernameText.caption = attributes.player;
this.playernameText.caption = PlayerColor.ColorPlayerName(escapeText(attributes.player), attributes.rating);
this.updatePlayerRoleText(attributes.player);
this.rankText.caption = attributes.rank;
@@ -12,6 +12,8 @@ class ProfilePage
this.fetchInput = Engine.GetGUIObjectByName("fetchInput");
this.fetchInput.onPress = this.onPressLookup.bind(this);
this.fetchInput.onTab = this.autocomplete.bind(this);
this.fetchInput.tooltip = colorizeAutocompleteHotkey();
Engine.GetGUIObjectByName("viewProfileButton").onPress = this.onPressLookup.bind(this);
Engine.GetGUIObjectByName("profileBackButton").onPress = this.onPressClose.bind(this, true);
@@ -46,6 +48,20 @@ class ProfilePage
Engine.SendGetProfile(this.requestedPlayer);
}
autocomplete()
{
const listPlayerNames = Engine.GetPlayerList().map(player => escapeText(player.name));
// Remove duplicates with the board list. The board list has lower case names.
const listPlayerNamesLower = listPlayerNames.map(playerName => playerName.toLowerCase());
for (const entry of Engine.GetBoardList())
{
const escapedName = escapeText(entry.name);
if (!listPlayerNamesLower.includes(escapedName))
listPlayerNames.push(escapedName);
}
autoCompleteText(this.fetchInput, listPlayerNames);
}
onPressClose()
{
this.profilePage.hidden = true;
@@ -73,7 +89,7 @@ class ProfilePage
return;
}
this.profilePlayernameText.caption = escapeText(attributes.player);
this.profilePlayernameText.caption = PlayerColor.ColorPlayerName(escapeText(attributes.player), attributes.rating);
this.profileRankText.caption = attributes.rank;
this.profileHighestRatingText.caption = attributes.highestRating;
this.profileTotalGamesText.caption = attributes.totalGamesPlayed;
@@ -40,7 +40,9 @@ function continueButton()
Engine.ConnectXmppClient();
}
/**
* The data from Engine.SendGetBoardList() is used for the leaderboard, but also for autocompletion in the profile player search field.
*/
function onLogin(message)
{
saveCredentials();
@@ -48,4 +50,5 @@ function onLogin(message)
Engine.SwitchGuiPage("page_lobby.xml", {
"dialog": false
});
Engine.SendGetBoardList();
}