Changeset View
Changeset View
Standalone View
Standalone View
./gui/lobby/lobby.js
Context not available. | |||||
* Do a full update of the player listing, including ratings from cached C++ information. | * Do a full update of the player listing, including ratings from cached C++ information. | ||||
*/ | */ | ||||
function updatePlayerList() | function updatePlayerList() | ||||
{ | { | ||||
let playersBox = Engine.GetGUIObjectByName("playersBox"); | let playersBox = Engine.GetGUIObjectByName("playersBox"); | ||||
let buddys = Engine.ConfigDB_GetValue("user", "lobby.buddys"); | |||||
let sortBy = playersBox.selected_column || "name"; | let sortBy = playersBox.selected_column || "name"; | ||||
let sortOrder = playersBox.selected_column_order || 1; | let sortOrder = playersBox.selected_column_order || 1; | ||||
if (playersBox.selected > -1) | if (playersBox.selected > -1) | ||||
g_SelectedPlayer = playersBox.list[playersBox.selected]; | g_SelectedPlayer = playersBox.list[playersBox.selected]; | ||||
let buddyList = []; | |||||
let playerList = []; | let playerList = []; | ||||
let presenceList = []; | let presenceList = []; | ||||
let nickList = []; | let nickList = []; | ||||
let ratingList = []; | let ratingList = []; | ||||
let cleanPlayerList = Engine.GetPlayerList().sort((a, b) => { | let cleanPlayerList = Engine.GetPlayerList().sort((a, b) => { | ||||
let sortA, sortB; | let sortA, sortB; | ||||
switch (sortBy) | switch (sortBy) | ||||
{ | { | ||||
case 'buddy': | |||||
sortA = buddys.split("|").indexOf(a.name); | |||||
sortB = buddys.split("|").indexOf(b.name); | |||||
break; | |||||
case 'rating': | case 'rating': | ||||
sortA = +a.rating; | sortA = +a.rating; | ||||
sortB = +b.rating; | sortB = +b.rating; | ||||
break; | break; | ||||
case 'status': | case 'status': | ||||
Context not available. | |||||
let statusColor = g_PlayerStatuses[presence].color; | let statusColor = g_PlayerStatuses[presence].color; | ||||
let coloredName = colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + player.name); | let coloredName = colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + player.name); | ||||
let coloredPresence = '[color="' + statusColor + '"]' + g_PlayerStatuses[presence].status + "[/color]"; | let coloredPresence = '[color="' + statusColor + '"]' + g_PlayerStatuses[presence].status + "[/color]"; | ||||
let coloredRating = '[color="' + statusColor + '"]' + rating + "[/color]"; | let coloredRating = '[color="' + statusColor + '"]' + rating + "[/color]"; | ||||
if (buddys.split("|").indexOf(player.name) >=0) | |||||
buddyList.push('[color="120 120 120"]![/color]'); | |||||
else | |||||
buddyList.push('[color="120 120 120"].[/color]'); | |||||
playerList.push(coloredName); | playerList.push(coloredName); | ||||
presenceList.push(coloredPresence); | presenceList.push(coloredPresence); | ||||
ratingList.push(coloredRating); | ratingList.push(coloredRating); | ||||
nickList.push(player.name); | nickList.push(player.name); | ||||
} | } | ||||
playersBox.list_buddy = buddyList; | |||||
playersBox.list_name = playerList; | playersBox.list_name = playerList; | ||||
playersBox.list_status = presenceList; | playersBox.list_status = presenceList; | ||||
playersBox.list_rating = ratingList; | playersBox.list_rating = ratingList; | ||||
playersBox.list = nickList; | playersBox.list = nickList; | ||||
Context not available. | |||||
if (playersBox.selected != playersBox.list.indexOf(g_SelectedPlayer)) | if (playersBox.selected != playersBox.list.indexOf(g_SelectedPlayer)) | ||||
playersBox.selected = playersBox.list.indexOf(g_SelectedPlayer); | playersBox.selected = playersBox.list.indexOf(g_SelectedPlayer); | ||||
} | } | ||||
/** | /** | ||||
* Toggle buddy state for a player in playerlist within the user config | |||||
*/ | |||||
function toggleBuddy() | |||||
{ | |||||
var buddys = Engine.ConfigDB_GetValue("user", "lobby.buddys"); | |||||
let playerList = Engine.GetGUIObjectByName("playersBox"); | |||||
let name = playerList.list[playerList.selected]; | |||||
if (buddys.split("|").indexOf(name) >=0) | |||||
buddys = buddys.replace("|"+name, ""); | |||||
else | |||||
buddys = buddys + "|" + name; | |||||
Engine.ConfigDB_CreateValue("user", "lobby.buddys", buddys); | |||||
Engine.ConfigDB_WriteValueToFile("user", "lobby.buddys", buddys, "config/user.cfg"); | |||||
updatePlayerList(); | |||||
} | |||||
/** | |||||
* Display the profile of the selected player. | * Display the profile of the selected player. | ||||
* Displays N/A for all stats until updateProfile is called when the stats | * Displays N/A for all stats until updateProfile is called when the stats | ||||
* are actually received from the bot. | * are actually received from the bot. | ||||
* | * | ||||
* @param {string} caller - From which screen is the user requesting data from? | * @param {string} caller - From which screen is the user requesting data from? | ||||
Context not available. |
Wildfire Games · Phabricator