From 5fd4fb2b3470ae56bc02dc38fd7b2aba7aba4e9a Mon Sep 17 00:00:00 2001 From: bb Date: Sat, 25 Dec 2021 21:06:21 +0000 Subject: [PATCH] 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. --- .../public/gui/lobby/LobbyPage/ProfilePanel.js | 4 ++-- .../gui/lobby/ProfilePage/ProfilePage.js | 18 +++++++++++++++++- .../mods/public/gui/prelobby/login/login.js | 5 ++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/public/gui/lobby/LobbyPage/ProfilePanel.js b/binaries/data/mods/public/gui/lobby/LobbyPage/ProfilePanel.js index 335b4df6f8..e8917e6a09 100644 --- a/binaries/data/mods/public/gui/lobby/LobbyPage/ProfilePanel.js +++ b/binaries/data/mods/public/gui/lobby/LobbyPage/ProfilePanel.js @@ -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; diff --git a/binaries/data/mods/public/gui/lobby/ProfilePage/ProfilePage.js b/binaries/data/mods/public/gui/lobby/ProfilePage/ProfilePage.js index bf08ee3ec9..1da822c6da 100644 --- a/binaries/data/mods/public/gui/lobby/ProfilePage/ProfilePage.js +++ b/binaries/data/mods/public/gui/lobby/ProfilePage/ProfilePage.js @@ -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; diff --git a/binaries/data/mods/public/gui/prelobby/login/login.js b/binaries/data/mods/public/gui/prelobby/login/login.js index 6127c904f8..60f5ceaaf4 100644 --- a/binaries/data/mods/public/gui/prelobby/login/login.js +++ b/binaries/data/mods/public/gui/prelobby/login/login.js @@ -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(); }